CreateRectangle.cs 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Drawing.Drawing2D;
  5. using System.Windows.Forms;
  6. namespace OTSMeasureApp
  7. {
  8. public class CRectangleGDIObject /*: CRectangleGDIObject */// 同样的方式可以从ADraggableGDIObject生成其它图形的继承角类,比如矩形,三形等等。。
  9. {
  10. public CRectangleGDIObject()
  11. {
  12. ID = System.Guid.NewGuid().ToString();
  13. OTSX = -1;
  14. OTSY = -1;
  15. }
  16. /// <summary>
  17. /// 创建图形
  18. /// </summary>
  19. /// <param name="startx">X位置</param>
  20. /// <param name="starty">Y位置</param>
  21. /// <param name="width">宽度</param>
  22. /// <param name="height">高度</param>
  23. /// <param name="cType">图形类型:createType=0 圆角矩形 createType=1 圆形 createType=2 文字</param>
  24. /// <param name="content">文字内容</param>
  25. public CRectangleGDIObject(float startx, float starty, float width, float height, CreateRectangleType cType, string content, string name)
  26. {
  27. var rec = new RectangleF(startx, starty, width, height);
  28. m_OrigineRegionF = rec;
  29. SetInitRegionF(m_OrigineRegionF);
  30. CreateType = cType;
  31. strContent = content;
  32. NameOrHoleName = name;
  33. ID = System.Guid.NewGuid().ToString();
  34. OTSX = -1;
  35. OTSY = -1;
  36. }
  37. public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType)
  38. {
  39. m_OrigineRegionF = rect;
  40. SetInitRegionF(m_OrigineRegionF);
  41. CreateType = cType;
  42. ID = System.Guid.NewGuid().ToString();
  43. //startPoint = new PointF(rect.Left, rect.Top);
  44. //EndPoint = new PointF(rect.Right, rect.Bottom);
  45. OTSX = -1;
  46. OTSY = -1;
  47. }
  48. public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType, string name)
  49. {
  50. m_OrigineRegionF = rect;
  51. SetInitRegionF(m_OrigineRegionF);
  52. CreateType = cType;
  53. NameOrHoleName = name;
  54. ID = System.Guid.NewGuid().ToString();
  55. OTSX = -1;
  56. OTSY = -1;
  57. }
  58. public CRectangleGDIObject(RectangleF rect, CreateRectangleType cType, ShapeType shape, string name, Color selColor)
  59. {
  60. m_OrigineRegionF = rect;
  61. SetInitRegionF(m_OrigineRegionF);
  62. CreateType = cType;
  63. NameOrHoleName = name;
  64. Shape = shape;
  65. SelColor = selColor;
  66. ID = System.Guid.NewGuid().ToString();
  67. OTSX = -1;
  68. OTSY = -1;
  69. }
  70. public CRectangleGDIObject(RectangleF rectMeasure, CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
  71. {
  72. m_OrigineRegionF = rectMeasure;
  73. SetInitRegionF(m_OrigineRegionF);
  74. CreateType = cType;
  75. NameOrHoleName = name;
  76. Shape = shape;
  77. SelColor = selColor;
  78. SampleName = sampleName;
  79. ID = System.Guid.NewGuid().ToString();
  80. OTSX = -1;
  81. OTSY = -1;
  82. }
  83. //绘制帧图
  84. public CRectangleGDIObject(RectangleF rectSingle, CreateRectangleType cType, string name, string sampleName, Color selColor)
  85. {
  86. m_OrigineRegionF = rectSingle;
  87. SetInitRegionF(m_OrigineRegionF);
  88. CreateType = cType;
  89. NameOrHoleName = name;
  90. Shape = 0;
  91. SelColor = selColor;
  92. SampleName = sampleName;
  93. ID = System.Guid.NewGuid().ToString();
  94. OTSX = -1;
  95. OTSY = -1;
  96. }
  97. //绘制帧图
  98. public CRectangleGDIObject(RectangleF rectField, int OTSx, int OTSy, CreateRectangleType cType, string name, string sampleName, Color selColor)
  99. {
  100. m_OrigineRegionF = rectField;
  101. SetInitRegionF(m_OrigineRegionF);
  102. CreateType = cType;
  103. NameOrHoleName = name;
  104. Shape = 0;
  105. SelColor = selColor;
  106. SampleName = sampleName;
  107. ID = System.Guid.NewGuid().ToString();
  108. OTSX = OTSx;
  109. OTSY = OTSy;
  110. }
  111. /// <summary>
  112. /// 获取样品孔中BSE图像
  113. /// </summary>
  114. /// <param name="rect">位置大小</param>
  115. /// <param name="sampleHoleName">所在样品孔名称</param>
  116. /// <param name="bseImage">图像信息</param>
  117. /// <param name="bseImageWitdh">图像宽度</param>
  118. /// <param name="bseImageHeight">图像高度</param>
  119. /// <param name="drawImageLocation">图像开始位置</param>
  120. /// <param name="cType">绘制类型</param>
  121. public CRectangleGDIObject(RectangleF rect, int OTSx, int OTSy, string sampleName, string sampleHoleName, float bseImageWitdh, float bseImageHeight, CreateRectangleType cType)
  122. {
  123. m_OrigineRegionF = rect;
  124. SetInitRegionF(m_OrigineRegionF);
  125. NameOrHoleName = sampleHoleName;
  126. SampleName = sampleName;
  127. //生成编号
  128. ID = System.Guid.NewGuid().ToString();
  129. //图像信息
  130. //BSEImage = bseImage;
  131. //图像宽度
  132. BSEImageWitdh = bseImageWitdh;
  133. //图像高度
  134. BSEImageHeight = bseImageHeight;
  135. //图像位置
  136. BSEImageLocation = rect.Location;
  137. OTSX = OTSx;
  138. OTSY = OTSy;
  139. //绘制类型
  140. CreateType = cType;
  141. }
  142. public CRectangleGDIObject(RectangleF rect, Point ImgPoint, float m_Multiple, CreateRectangleType cType)
  143. {
  144. m_OrigineRegionF = rect;
  145. SetInitRegionF(m_OrigineRegionF);
  146. CreateType = cType;
  147. ID = System.Guid.NewGuid().ToString();
  148. OTSX = -1;
  149. OTSY = -1;
  150. }
  151. /// <summary>
  152. /// 获取多边形点集合
  153. /// </summary>
  154. /// <param name="mPoint"></param>
  155. /// <param name="cType"></param>
  156. public CRectangleGDIObject(List<PointF> mPoint, CreateRectangleType cType, ShapeType shape, string name, string sampleName, Color selColor)
  157. {
  158. ID = System.Guid.NewGuid().ToString();
  159. this.SetOriginalPolygonPointFList(mPoint);
  160. NameOrHoleName = name;
  161. SampleName = sampleName;
  162. CreateType = cType;
  163. Shape = shape;
  164. SelColor = selColor;
  165. }
  166. #region 变量重写
  167. public virtual void OnPaint(PaintEventArgs e)
  168. {
  169. if (createType == CreateRectangleType.SampleBackGround_Rectangle)
  170. {
  171. //获取颜色
  172. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.RoundRectangleColor);
  173. Color myColor = ColorTranslator.FromHtml(ColorStr);
  174. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  175. GraphicsPath grPath = CreateRoundedRectanglePath(m_RegionF, 20);
  176. e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
  177. e.Graphics.FillPath(sampleBrush, grPath);
  178. e.Graphics.DrawPath(Pens.Black, grPath);
  179. }
  180. //样品台-圆形
  181. else if (createType == CreateRectangleType.SampleBackGround_Circle)
  182. {
  183. //获取颜色
  184. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SampleBackGroundColor);
  185. Color myColor = ColorTranslator.FromHtml(ColorStr);
  186. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  187. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  188. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  189. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  190. e.Graphics.FillEllipse(sampleBrush, m_RegionF);
  191. e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
  192. }
  193. //圆形
  194. else if (createType == CreateRectangleType.Circle)
  195. {
  196. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.White);
  197. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  198. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  199. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  200. e.Graphics.FillEllipse(sampleBrush, m_RegionF);
  201. e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
  202. }
  203. //文字
  204. else if (createType == CreateRectangleType.Text)
  205. {
  206. //设置文字对齐方式
  207. StringFormat sf = new StringFormat();
  208. sf.Alignment = StringAlignment.Center;
  209. sf.LineAlignment = StringAlignment.Center;
  210. //文字颜色
  211. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.FontColor);
  212. Color myColor = ColorTranslator.FromHtml(ColorStr);
  213. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  214. SolidBrush solidBrush = new SolidBrush(Color.FromArgb(50, Color.Black));
  215. //字体大小 根据样品孔Rectangle大小
  216. float fontSize = m_RegionF.Width / 4;
  217. Font font = new Font("宋体", fontSize, FontStyle.Regular);
  218. if (fontSize == 0)
  219. {
  220. font = new Font("宋体", 5, FontStyle.Regular);
  221. }
  222. //消除锯齿
  223. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  224. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  225. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  226. //绘制文字阴影
  227. RectangleF rectFont = m_RegionF;
  228. rectFont.X += 2;
  229. rectFont.Y += 2;
  230. e.Graphics.DrawString(strContent, font, solidBrush, rectFont, sf);
  231. e.Graphics.DrawString(strContent, font, sampleBrush, m_RegionF, sf);
  232. }
  233. //矩形
  234. else if (createType == CreateRectangleType.Rectangle)
  235. {
  236. Color myColor = System.Drawing.Color.White;
  237. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  238. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  239. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  240. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  241. e.Graphics.FillRectangle(sampleBrush, m_RegionF);
  242. var m_Region = new Rectangle();
  243. m_Region.X = (int)m_RegionF.X;
  244. m_Region.Y = (int)m_RegionF.Y;
  245. m_Region.Width = (int)m_RegionF.Width;
  246. m_Region.Height = (int)m_RegionF.Height;
  247. e.Graphics.DrawRectangle(Pens.Black, m_Region);
  248. }
  249. //选择样品台
  250. else if (createType == CreateRectangleType.SelectSample)
  251. {
  252. Color myColor = selColor;
  253. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  254. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  255. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  256. e.Graphics.CompositingQuality = CompositingQuality.AssumeLinear;//再加一点
  257. if (Shape == 0)
  258. {
  259. e.Graphics.FillEllipse(sampleBrush, m_RegionF);
  260. e.Graphics.DrawEllipse(Pens.Black, m_RegionF);
  261. }
  262. else
  263. {
  264. e.Graphics.FillRectangle(sampleBrush, m_RegionF);
  265. var m_Region = new Rectangle();
  266. m_Region.X = (int)m_RegionF.X;
  267. m_Region.Y = (int)m_RegionF.Y;
  268. m_Region.Width = (int)m_RegionF.Width;
  269. m_Region.Height = (int)m_RegionF.Height;
  270. e.Graphics.DrawRectangle(Pens.Black, m_Region);
  271. }
  272. }
  273. //测试区域
  274. else if (createType == CreateRectangleType.MeasureArea)
  275. {
  276. Color myColor = selColor;
  277. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  278. Pen p = new Pen(myColor, 1);
  279. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  280. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  281. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  282. if (Shape == 0)
  283. {
  284. e.Graphics.DrawEllipse(p, m_RegionF);
  285. }
  286. else
  287. {
  288. var m_Region = new Rectangle();
  289. m_Region.X = (int)m_RegionF.X;
  290. m_Region.Y = (int)m_RegionF.Y;
  291. m_Region.Width = (int)m_RegionF.Width;
  292. m_Region.Height = (int)m_RegionF.Height;
  293. e.Graphics.DrawRectangle(p, m_Region);
  294. }
  295. }
  296. //绘制帧图 直线
  297. else if (createType == CreateRectangleType.SingleLine)
  298. {
  299. //设置颜色
  300. string ColorStr = OTSSamplespaceGraphicsPanelFun.GetColorValue(ColorType.SingleColor);
  301. Color myColor = ColorTranslator.FromHtml(ColorStr);
  302. //设置画笔
  303. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  304. Pen pen = new Pen(sampleBrush, 0.0001f);
  305. //未抗锯齿
  306. e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
  307. e.Graphics.InterpolationMode = InterpolationMode.Default;
  308. e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
  309. //设置直线位置与尺寸
  310. PointF startPointF = new PointF(startPoint.X, startPoint.Y);
  311. PointF endPointF = new PointF(endPoint.X, endPoint.Y);
  312. //度量单位
  313. e.Graphics.PageUnit = GraphicsUnit.Display;
  314. e.Graphics.DrawLine(pen, startPointF, endPointF);
  315. }
  316. //绘制标样
  317. else if (createType == CreateRectangleType.SpecimenRectangle)
  318. {
  319. Color myColor = System.Drawing.Color.Black;
  320. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  321. Pen pen = new Pen(sampleBrush, 0.0001f);
  322. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  323. var m_Region = new Rectangle();
  324. m_Region.X = (int)m_RegionF.X;
  325. m_Region.Y = (int)m_RegionF.Y;
  326. m_Region.Width = (int)m_RegionF.Width;
  327. m_Region.Height = (int)m_RegionF.Height;
  328. e.Graphics.DrawRectangle(pen, m_Region);
  329. e.Graphics.FillRectangle(sampleBrush, m_Region);
  330. }
  331. //绘制标样
  332. else if (createType == CreateRectangleType.SpecimenCircle)
  333. {
  334. Color myColor = System.Drawing.Color.Black;
  335. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  336. Pen pen = new Pen(sampleBrush, 0.0001f);
  337. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
  338. e.Graphics.DrawEllipse(pen, m_RegionF);
  339. e.Graphics.FillEllipse(sampleBrush, m_RegionF);
  340. }
  341. //绘制帧图
  342. else if (createType == CreateRectangleType.FieldRectangle)
  343. {
  344. Color myColor = SelColor;
  345. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  346. Pen pen = new Pen(sampleBrush, 0.01f);
  347. e.Graphics.SmoothingMode = SmoothingMode.Default;
  348. //设置直线位置与尺寸
  349. PointF startPointF = new PointF(m_RegionF.Left, m_RegionF.Top);
  350. PointF endPointF = new PointF(m_RegionF.Right, m_RegionF.Bottom);
  351. float fontSize = m_RegionF.Width / 4;
  352. Font font;
  353. if (fontSize == 0)
  354. {
  355. font = new Font("宋体", 5, FontStyle.Regular);
  356. }
  357. else
  358. {
  359. font = new Font("宋体", fontSize, FontStyle.Regular);
  360. }
  361. StringFormat sf = new StringFormat();
  362. sf.Alignment = StringAlignment.Center;
  363. sf.LineAlignment = StringAlignment.Center;
  364. e.Graphics.DrawString(m_sequenceNum.ToString(), font, sampleBrush, m_RegionF, sf);
  365. //绘制帧图
  366. e.Graphics.DrawRectangle(pen, startPointF.X, startPointF.Y, endPointF.X - startPointF.X, endPointF.Y - startPointF.Y);
  367. }
  368. //绘制颗粒
  369. else if (createType == CreateRectangleType.ParticleLine)
  370. {
  371. Color myColor = LineColor;
  372. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  373. Pen pen = new Pen(sampleBrush, 0.01f);
  374. e.Graphics.SmoothingMode = SmoothingMode.Default;
  375. //设置直线位置与长度
  376. PointF startPointF = LineStartPoint;
  377. float length = LineLength;
  378. PointF endPointF = new PointF(startPointF.X + length, startPointF.Y);
  379. e.Graphics.DrawLine(pen, startPointF, endPointF);
  380. }
  381. //矩形
  382. else if (createType == CreateRectangleType.ParticleAreaRectangle)
  383. {
  384. Color myColor = System.Drawing.Color.White;
  385. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  386. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  387. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  388. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  389. var m_Region = new Rectangle();
  390. m_Region.X = (int)m_RegionF.X;
  391. m_Region.Y = (int)m_RegionF.Y;
  392. m_Region.Width = (int)m_RegionF.Width;
  393. m_Region.Height = (int)m_RegionF.Height;
  394. e.Graphics.DrawRectangle(Pens.Black, m_Region);
  395. }
  396. //绘制样品孔BSE图像
  397. else if (createType == CreateRectangleType.DrawFrameOfHoleBSEImage)
  398. {
  399. Color myColor = System.Drawing.Color.White;
  400. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  401. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  402. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  403. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  404. //设置直线位置与尺寸
  405. PointF startPointF = new PointF(m_RegionF.Left, m_RegionF.Top);
  406. PointF endPointF = new PointF(m_RegionF.Right + 2, m_RegionF.Bottom + 2);
  407. //绘制样品孔中图像信息
  408. if (BSEImage != null)
  409. {
  410. e.Graphics.DrawImage(BSEImage, startPointF.X, startPointF.Y, endPointF.X - startPointF.X, endPointF.Y - startPointF.Y);
  411. }
  412. }
  413. else if (createType == CreateRectangleType.DrawSEMCenterPoint)
  414. {
  415. Color myColor = System.Drawing.Color.Red;
  416. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  417. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  418. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  419. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  420. //X轴线
  421. PointF startPointX = semCenterPoint;
  422. startPointX.X = startPointX.X - 3;
  423. PointF endPointX = semCenterPoint;
  424. endPointX.X = endPointX.X + 3;
  425. //Y轴线
  426. PointF startPointY = semCenterPoint;
  427. startPointY.Y = startPointY.Y - 3;
  428. PointF endPointY = semCenterPoint;
  429. endPointY.Y = endPointY.Y + 3;
  430. //绘制XY轴交叉线+
  431. Pen pen = new Pen(sampleBrush, 0.0001f);
  432. e.Graphics.DrawLine(pen, startPointX, endPointX);
  433. e.Graphics.DrawLine(pen, startPointY, endPointY);
  434. }
  435. //绘制BSE标记
  436. else if (createType == CreateRectangleType.DrawBSEElementSignPoint)
  437. {
  438. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Green);
  439. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  440. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  441. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  442. Pen pen = new Pen(sampleBrush, 2f);
  443. int X = (int)m_OrigineRegionF.X;
  444. int Y = (int)m_OrigineRegionF.Y;
  445. e.Graphics.DrawLine(pen, new Point(X - 8, Y), new Point(X + 8, Y));
  446. e.Graphics.DrawLine(pen, new Point(X, Y - 8), new Point(X, Y + 8));
  447. }
  448. //绘制多边形测量区域
  449. else if (createType == CreateRectangleType.Polygon)
  450. {
  451. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  452. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  453. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  454. Color myColor = selColor;
  455. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  456. Pen pen = new Pen(myColor, 1);
  457. if (GetPolygonPointFList().Count > 0)
  458. {
  459. List<PointF> PolygonPointF = new List<PointF>();
  460. foreach (var item in m_PolygonPoints)
  461. {
  462. PolygonPointF.Add(item);
  463. }
  464. if (PolygonDrawingEndPoint.X != 0 && PolygonDrawingEndPoint.Y != 0)
  465. {
  466. PolygonPointF.Add(PolygonDrawingEndPoint);
  467. }
  468. e.Graphics.DrawLines(pen, PolygonPointF.ToArray());
  469. }
  470. }//多边形测量区域完成标识
  471. else if (createType == CreateRectangleType.DrawPolygonFinish)
  472. {
  473. Color myColor = selColor;
  474. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  475. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  476. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  477. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  478. Pen pen = new Pen(myColor, 1);
  479. var m_Region = new Rectangle();
  480. m_Region.X = (int)m_RegionF.X;
  481. m_Region.Y = (int)m_RegionF.Y;
  482. m_Region.Width = (int)m_RegionF.Width;
  483. m_Region.Height = (int)m_RegionF.Height;
  484. e.Graphics.DrawRectangle(pen, m_Region);
  485. }
  486. //绘制多边形测量区域
  487. else if (createType == CreateRectangleType.CircleByThreePoints)
  488. {
  489. Color myColor = selColor;
  490. System.Drawing.SolidBrush sampleBrush = new System.Drawing.SolidBrush(myColor);
  491. Pen p = new Pen(myColor, 1);
  492. e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //图片柔顺模式选择
  493. e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;//高质量
  494. e.Graphics.CompositingQuality = CompositingQuality.HighQuality;//再加一点
  495. var m_Region = new Rectangle();
  496. m_Region.X = (int)m_RegionF.X;
  497. m_Region.Y = (int)m_RegionF.Y;
  498. m_Region.Width = (int)m_RegionF.Width;
  499. m_Region.Height = (int)m_RegionF.Height;
  500. e.Graphics.DrawEllipse(p, m_Region);
  501. }
  502. }
  503. public Image BSEImage
  504. {
  505. get { return bseImage; }
  506. set { bseImage = value; }
  507. }
  508. public float BSEImageWitdh
  509. {
  510. get { return bseImageWidth; }
  511. set { bseImageWidth = value; }
  512. }
  513. public float BSEImageHeight
  514. {
  515. get { return bseImageHeight; }
  516. set { bseImageHeight = value; }
  517. }
  518. public PointF BSEImageLocation
  519. {
  520. get { return bseImageLocation; }
  521. set { bseImageLocation = value; }
  522. }
  523. public Color LineColor
  524. {
  525. get { return lineColor; }
  526. set { lineColor = value; }
  527. }
  528. public float LineLength
  529. {
  530. get { return lineLength; }
  531. set { lineLength = value; }
  532. }
  533. public PointF LineStartPoint
  534. {
  535. get { return lineStartPoint; }
  536. set { lineStartPoint = value; }
  537. }
  538. //public PointF SEMCenterPoint
  539. //{
  540. // get { return semCenterPoint; }
  541. // set { semCenterPoint = value; }
  542. //}
  543. public int OTSX
  544. {
  545. get { return otsX; }
  546. set { otsX = value; }
  547. }
  548. public int OTSY
  549. {
  550. get { return otsY; }
  551. set { otsY = value; }
  552. }
  553. public CreateRectangleType CreateType
  554. {
  555. get { return createType; }
  556. set { createType = value; }
  557. }
  558. public ShapeType Shape
  559. {
  560. get { return shape; }
  561. set { shape = value; }
  562. }
  563. public Color SelColor
  564. {
  565. get { return selColor; }
  566. set { selColor = value; }
  567. }
  568. public string NameOrHoleName//holename when they are not field rectangle gdi object.
  569. {
  570. get { return nameOrHoleName; }
  571. set { nameOrHoleName = value; }
  572. }
  573. public string ID
  574. {
  575. get { return id; }
  576. set { id = value; }
  577. }
  578. public string SampleName
  579. {
  580. get { return sampleName; }
  581. set { sampleName = value; }
  582. }
  583. public int SampleCount
  584. {
  585. get { return sampleCount; }
  586. set { sampleCount = value; }
  587. }
  588. public string StrContent
  589. {
  590. get { return strContent; }
  591. set { strContent = value; }
  592. }
  593. public RectangleF GetZoomedRegion
  594. {
  595. get {
  596. var m_Region = new RectangleF();
  597. m_Region.X = m_RegionF.X;
  598. m_Region.Y = m_RegionF.Y;
  599. m_Region.Width = m_RegionF.Width;
  600. m_Region.Height = m_RegionF.Height;
  601. return m_Region;
  602. }
  603. }
  604. public List<PointF> GetVertexPoints()
  605. {
  606. List<PointF> vertexPoint = new List<PointF>();
  607. var region = this.GetZoomedRegionF();
  608. vertexPoint.Add(region.Location);
  609. vertexPoint.Add(new PointF(region.X, region.Y + region.Height));
  610. vertexPoint.Add(new PointF(region.X + region.Width, region.Y));
  611. vertexPoint.Add(new PointF(region.X + region.Width, region.Y + region.Height));
  612. return vertexPoint;
  613. }
  614. public RectangleF GetZoomedRegionF()
  615. {
  616. return m_RegionF;
  617. }
  618. public void SetInitRegionF(RectangleF OrigineRegionF)//not zoomed regine value
  619. {
  620. float x1, y1;
  621. x1 = OrigineRegionF.X * m_zoomNum + m_refPoint.X;
  622. y1 = OrigineRegionF.Y * m_zoomNum + m_refPoint.Y;
  623. float w1, h1;
  624. w1 = OrigineRegionF.Width * m_zoomNum;
  625. h1 = OrigineRegionF.Height * m_zoomNum;
  626. m_OrigineRegionF = OrigineRegionF;
  627. m_RegionF = new RectangleF(x1, y1, w1, h1);
  628. }
  629. internal void SetZoomedRegionF(RectangleF scaleRectangleF)
  630. {
  631. float x1, y1;
  632. x1 = (scaleRectangleF.X-m_refPoint.X) / m_zoomNum ;
  633. y1 = (scaleRectangleF.Y-m_refPoint.Y) / m_zoomNum ;
  634. float w1, h1;
  635. w1 = scaleRectangleF.Width / m_zoomNum;
  636. h1 = scaleRectangleF.Height / m_zoomNum;
  637. m_OrigineRegionF = new RectangleF(x1, y1, w1, h1);
  638. m_RegionF = scaleRectangleF;
  639. }
  640. private Rectangle GetMinRectangleOfPolygon(List<PointF> polygonPointList)
  641. {
  642. if (polygonPointList != null)
  643. {
  644. if (polygonPointList.Count > 0)
  645. {
  646. int pCount = polygonPointList.Count;
  647. float minX = polygonPointList[0].X;
  648. float minY = polygonPointList[0].Y;
  649. float maxX = polygonPointList[0].X;
  650. float maxY = polygonPointList[0].Y;
  651. //获取最小X,Y 最大X,Y
  652. for (int i = 0; i < pCount; i++)
  653. {
  654. minX = Math.Min(minX, polygonPointList[i].X);
  655. minY = Math.Min(minY, polygonPointList[i].Y);
  656. maxX = Math.Max(maxX, polygonPointList[i].X);
  657. maxY = Math.Max(maxY, polygonPointList[i].Y);
  658. }
  659. //创建外接矩形
  660. Rectangle rect = new Rectangle();
  661. rect.Location = new Point((int)minX, (int)minY);
  662. rect.Size = new Size((int)maxX - (int)minX, (int)maxY - (int)minY);
  663. return rect;
  664. }
  665. }
  666. return new Rectangle();
  667. }
  668. public RectangleF GetOrigionalDrawRegionF()
  669. { return m_OrigineRegionF; }
  670. public List<PointF> GetOriginalPolygonPointFList()
  671. { return m_originalPolygonPoints; }
  672. public void SetOriginalPolygonPointFList(List<PointF> value)
  673. {
  674. if (m_zoomNum != 1)
  675. {
  676. var ps = new List<PointF>();
  677. foreach (var p in value)
  678. {
  679. var p1 = new PointF();
  680. p1.X = p.X * m_zoomNum+m_refPoint.X;
  681. p1.Y = p.Y *m_zoomNum+ m_refPoint.Y;
  682. ps.Add(p1);
  683. }
  684. m_PolygonPoints = ps;
  685. m_originalPolygonPoints = value;
  686. }
  687. else
  688. {
  689. m_originalPolygonPoints = value;
  690. m_PolygonPoints = value;
  691. }
  692. }
  693. public List<PointF> GetPolygonPointFList()
  694. { return m_PolygonPoints; }
  695. public void SetPolygonPointFList(List<PointF> value)
  696. {
  697. if (m_zoomNum != 1)
  698. {
  699. var ps = new List<PointF>();
  700. foreach (var p in value)
  701. {
  702. var p1 = new PointF();
  703. p1.X = (p.X - m_refPoint.X) / m_zoomNum;
  704. p1.Y = (p.Y - m_refPoint.Y) / m_zoomNum;
  705. ps.Add(p1);
  706. }
  707. m_originalPolygonPoints = ps;
  708. m_PolygonPoints = value;
  709. }
  710. else
  711. {
  712. m_originalPolygonPoints = value;
  713. m_PolygonPoints = value;
  714. }
  715. var region = GetMinRectangleOfPolygon(m_PolygonPoints);
  716. SetZoomedRegionF(region);
  717. }
  718. public GraphicsPath GetGPath()
  719. {
  720. var measureItem = this;
  721. //重新绘制测量区域路径
  722. GraphicsPath GPath = new GraphicsPath();
  723. if (measureItem.CreateType == CreateRectangleType.Polygon)
  724. {
  725. GraphicsPath PolygonMeasurePath = new GraphicsPath();
  726. PolygonMeasurePath.AddPolygon(measureItem.GetPolygonPointFList().ToArray());
  727. GPath = PolygonMeasurePath;
  728. }
  729. else if (measureItem.CreateType == CreateRectangleType.CircleByThreePoints)
  730. {
  731. GPath.AddEllipse(GetZoomedRegionF());
  732. }
  733. else
  734. {
  735. if (measureItem.Shape == (int)CreateRectangleType.Circle)
  736. {
  737. GPath.AddEllipse(GetZoomedRegionF());
  738. }
  739. else
  740. {
  741. GPath.AddRectangle(GetZoomedRegionF());
  742. }
  743. }
  744. return GPath;
  745. }
  746. public PointF PolygonDrawingEndPoint
  747. {
  748. get { return endPoint; }
  749. set { endPoint = value; }
  750. }
  751. public Point GetZoomedCenterPoint()
  752. {
  753. Point pCenterPoint = new Point();
  754. //获取在工作窗口中X,Y位置
  755. pCenterPoint.X = (int)(this.GetZoomedRegion.X + this.GetZoomedRegion.Width / 2);
  756. pCenterPoint.Y = (int)(this.GetZoomedRegion.Y + this.GetZoomedRegion.Height / 2);
  757. return pCenterPoint;
  758. }
  759. public PointF GetCenterPoint()
  760. {
  761. PointF pCenterPoint = new PointF();
  762. //获取在工作窗口中X,Y位置
  763. pCenterPoint.X = (this.GetOrigionalDrawRegionF().X + this.GetOrigionalDrawRegionF().Width / 2);
  764. pCenterPoint.Y = (this.GetOrigionalDrawRegionF().Y + this.GetOrigionalDrawRegionF().Height / 2);
  765. return pCenterPoint;
  766. }
  767. #endregion
  768. public bool IsDragging
  769. {
  770. get { return m_IsDragging; }
  771. set { m_IsDragging = value; }
  772. }
  773. public bool IsAltering// changing the size by gui operating.
  774. {
  775. get { return m_IsAlter; }
  776. set { m_IsAlter = value; }
  777. }
  778. public bool IsWorkSample
  779. {
  780. get { return m_IsWorkSample; }
  781. set { m_IsWorkSample = value; }
  782. }
  783. public PointF DraggingPoint
  784. {
  785. get { return m_DraggingPoint; }
  786. set {
  787. m_DraggingPoint = value;
  788. if (subItems.Count != 0)
  789. {
  790. foreach (var item in subItems)
  791. {
  792. item.DraggingPoint = m_DraggingPoint;
  793. }
  794. }
  795. }
  796. }
  797. public int SequenceNum { get => m_sequenceNum; set => m_sequenceNum = value; }
  798. public bool IsMoving { get => m_IsMoving; set => m_IsMoving = value; }
  799. public PointF GetDisplayRefPoint()
  800. { return m_refPoint; }
  801. public void SetDisplayRefPoint(PointF value)
  802. {
  803. m_refPoint = value;
  804. SetInitRegionF(m_OrigineRegionF);
  805. if (m_originalPolygonPoints.Count != 0)
  806. {
  807. this.SetPolygonPointFList(m_originalPolygonPoints);
  808. }
  809. }
  810. public float GetZoomNumber()
  811. { return m_zoomNum; }
  812. public void SetZoomNumber(float value)
  813. {
  814. m_zoomNum = value;
  815. SetInitRegionF(m_OrigineRegionF);
  816. if (m_originalPolygonPoints.Count != 0)
  817. {
  818. this.SetPolygonPointFList(m_originalPolygonPoints);
  819. }
  820. }
  821. #region 画圆角矩形
  822. internal static GraphicsPath CreateRoundedRectanglePath(RectangleF rect, int cornerRadius)
  823. {
  824. GraphicsPath roundedRect = new GraphicsPath();
  825. roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
  826. roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
  827. roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
  828. roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
  829. roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
  830. roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
  831. roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
  832. roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
  833. roundedRect.CloseFigure();
  834. return roundedRect;
  835. }
  836. public bool IfZoomContains(Point mousePoint)
  837. {
  838. if (mousePoint.X > m_RegionF.Left && mousePoint.X < m_RegionF.Left + m_RegionF.Width)
  839. {
  840. if (mousePoint.Y > m_RegionF.Top && mousePoint.Y < m_RegionF.Top + m_RegionF.Height)
  841. {
  842. return true;
  843. }
  844. }
  845. return false;
  846. }
  847. public bool IfContains(PointF thePoint)
  848. {
  849. if (thePoint.X > m_OrigineRegionF.Left && thePoint.X < m_OrigineRegionF.Left + m_OrigineRegionF.Width)
  850. {
  851. if (thePoint.Y > m_OrigineRegionF.Top && thePoint.Y < m_OrigineRegionF.Top + m_OrigineRegionF.Height)
  852. {
  853. return true;
  854. }
  855. }
  856. return false;
  857. }
  858. public List<CRectangleGDIObject> SubItems()
  859. {
  860. if (subItems == null) subItems = new List<CRectangleGDIObject>();
  861. return subItems;
  862. }
  863. public void AddSubItems(CRectangleGDIObject item)
  864. {
  865. if (subItems == null) subItems = new List<CRectangleGDIObject>();
  866. subItems.Add(item);
  867. }
  868. public void ClearSubItems()
  869. {
  870. subItems.Clear();
  871. }
  872. public void Zoom(PointF mousePoint, float zoomNum)
  873. {
  874. float X1;
  875. float curZoom = m_zoomNum;
  876. float deltaZoom = zoomNum - curZoom;
  877. float Y1;
  878. if (zoomNum == 1)
  879. {
  880. m_zoomNum = 1;
  881. m_RegionF = m_OrigineRegionF;
  882. m_refPoint = new PointF(0, 0);
  883. m_PolygonPoints = m_originalPolygonPoints;
  884. }
  885. else
  886. {
  887. X1 = (m_RegionF.X - mousePoint.X) / curZoom * deltaZoom + m_RegionF.X;
  888. Y1 = (m_RegionF.Y - mousePoint.Y) / curZoom * deltaZoom + m_RegionF.Y;
  889. m_refPoint.X = (m_refPoint.X - mousePoint.X) / curZoom * deltaZoom + m_refPoint.X;
  890. m_refPoint.Y = (m_refPoint.Y - mousePoint.Y) / curZoom * deltaZoom + m_refPoint.Y;
  891. float Width = GetOrigionalDrawRegionF().Width * zoomNum;
  892. float Height = GetOrigionalDrawRegionF().Height * zoomNum;
  893. m_RegionF = new RectangleF(X1, Y1, Width, Height);
  894. m_zoomNum = zoomNum;
  895. }
  896. BSEImageWitdh = m_RegionF.Width;
  897. BSEImageHeight = m_RegionF.Height;
  898. BSEImageLocation = m_RegionF.Location;
  899. var scalePs = new List<PointF>();
  900. foreach (var p in m_PolygonPoints)
  901. {
  902. float x, y;
  903. x = (p.X - mousePoint.X) / curZoom * deltaZoom + p.X;
  904. y = (p.Y - mousePoint.Y) / curZoom * deltaZoom + p.Y;
  905. scalePs.Add(new PointF(x, y));
  906. }
  907. m_PolygonPoints = scalePs;
  908. if (this.subItems.Count != 0)
  909. {
  910. foreach (var g in subItems)
  911. {
  912. g.Zoom(mousePoint,zoomNum);
  913. }
  914. }
  915. }
  916. public void Move(PointF location)
  917. {
  918. PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
  919. float X1;
  920. float Y1;
  921. X1 = (m_RegionF.X + offset.X);
  922. Y1 = (m_RegionF.Y + offset.Y);
  923. m_RegionF = new RectangleF(X1, Y1, m_RegionF.Width, m_RegionF.Height);
  924. m_refPoint.X = m_refPoint.X + offset.X;
  925. m_refPoint.Y = m_refPoint.Y + offset.Y;
  926. BSEImageWitdh = m_RegionF.Width;
  927. BSEImageHeight = m_RegionF.Height;
  928. BSEImageLocation = m_RegionF.Location;
  929. //SEMCenterPoint = m_RegionF.Location;
  930. LineStartPoint = m_RegionF.Location;
  931. m_DraggingPoint = new Point((int)location.X,(int)location.Y);
  932. var scalePs = new List<PointF>();
  933. foreach (var p in m_PolygonPoints)
  934. {
  935. float x, y;
  936. x = (p.X + offset.X);
  937. y = (p.Y + offset.Y);
  938. scalePs.Add(new PointF(x, y));
  939. }
  940. m_PolygonPoints = scalePs;
  941. if (this.subItems.Count != 0)
  942. {
  943. foreach (var g in subItems)
  944. {
  945. g.Move(location);
  946. }
  947. }
  948. }
  949. public void PositionAltering(PointF location,bool ifZoomCoord)
  950. {
  951. PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
  952. PointF realShift;
  953. if (ifZoomCoord)
  954. {
  955. realShift = new PointF(offset.X / m_zoomNum, offset.Y / m_zoomNum);
  956. }
  957. else
  958. {
  959. realShift = new PointF(offset.X , offset.Y );
  960. }
  961. m_OrigineRegionF = new RectangleF(m_OrigineRegionF.X+realShift.X, m_OrigineRegionF.Y+realShift.Y, m_OrigineRegionF.Width, m_OrigineRegionF.Height);
  962. SetInitRegionF(m_OrigineRegionF);
  963. BSEImageWitdh = m_RegionF.Width;
  964. BSEImageHeight = m_RegionF.Height;
  965. BSEImageLocation = m_RegionF.Location;
  966. LineStartPoint = m_RegionF.Location;
  967. var scalePs = new List<PointF>();
  968. var OriginalPs = new List<PointF>();
  969. foreach (var p in m_PolygonPoints)
  970. {
  971. float x, y;
  972. x = (p.X + offset.X);
  973. y = (p.Y + offset.Y);
  974. scalePs.Add(new PointF(x, y));
  975. }
  976. m_PolygonPoints = scalePs;
  977. foreach (var p in m_originalPolygonPoints)
  978. {
  979. OriginalPs.Add(new PointF(p.X + realShift.X, p.Y + realShift.Y));
  980. }
  981. m_originalPolygonPoints = OriginalPs;
  982. m_DraggingPoint = new Point((int)location.X, (int)location.Y);
  983. if (this.subItems.Count != 0)
  984. {
  985. foreach (var g in subItems)
  986. {
  987. g.PositionAltering(location,ifZoomCoord);
  988. }
  989. }
  990. }
  991. public CRectangleGDIObject Duplicate(CreateRectangleType newType)
  992. {
  993. CRectangleGDIObject r = new CRectangleGDIObject();
  994. r.NameOrHoleName = this.nameOrHoleName;
  995. r.SampleName = this.SampleName;
  996. r.m_OrigineRegionF = this.m_OrigineRegionF;
  997. r.IsWorkSample = this.IsWorkSample;
  998. r.m_RegionF = this.m_RegionF;
  999. r.m_refPoint = this.m_refPoint;
  1000. r.m_zoomNum = this.m_zoomNum;
  1001. r.shape = this.shape;
  1002. r.createType = newType;
  1003. return r;
  1004. }
  1005. virtual public bool ifRectangleIntersect(CRectangleGDIObject othergdi)
  1006. {
  1007. return true;
  1008. }
  1009. #endregion
  1010. //是否设置为选择样品
  1011. private bool m_IsAlter;
  1012. //是否存在帧图信息
  1013. //是否设置为拖动
  1014. private bool m_IsDragging;
  1015. private bool m_IsMoving;
  1016. //是否为工作样品
  1017. private bool m_IsWorkSample;
  1018. private CreateRectangleType createType;
  1019. private ShapeType shape;
  1020. private string id;
  1021. protected string nameOrHoleName="";
  1022. public string sampleName="";
  1023. //样品孔中样品的数量
  1024. public int sampleCount = 0;
  1025. public string strContent;
  1026. private Color selColor;
  1027. private PointF m_DraggingPoint;
  1028. private int m_sequenceNum;
  1029. protected RectangleF m_RegionF;
  1030. //绘制时与移动缩放时记录的位置与尺寸
  1031. protected RectangleF m_OrigineRegionF;
  1032. //private GraphicsPath g_Path=new GraphicsPath();
  1033. private PointF startPoint;
  1034. private PointF endPoint;
  1035. //绘制颗粒图
  1036. private Color lineColor;
  1037. private float lineLength;
  1038. private PointF lineStartPoint;
  1039. private int otsX;
  1040. private int otsY;
  1041. //绘制样品孔BSE图像
  1042. private Image bseImage;
  1043. //绘制样品孔BSE图像宽度
  1044. private float bseImageWidth;
  1045. //绘制样品孔BSE图像高度
  1046. private float bseImageHeight;
  1047. //绘制样品孔BSE图像位置
  1048. private PointF bseImageLocation;
  1049. //绘制SEM中心位置
  1050. private PointF semCenterPoint;
  1051. private List<PointF> m_PolygonPoints=new List<PointF>();
  1052. //绘制时与移动缩放时记录的位置
  1053. private List<PointF> m_originalPolygonPoints = new List<PointF>();
  1054. private List<CRectangleGDIObject> subItems=new List<CRectangleGDIObject>();
  1055. protected float m_zoomNum=1;
  1056. private PointF m_refPoint=new PointF(0,0);
  1057. }
  1058. public enum XYIndex
  1059. {
  1060. X = 0,
  1061. Y = 1
  1062. }
  1063. public enum CreateRectangleType
  1064. {
  1065. //样品台-圆形
  1066. SampleBackGround_Circle = -1,
  1067. //圆形
  1068. Circle = 0,
  1069. //圆角矩形
  1070. SampleBackGround_Rectangle = 1,
  1071. //样品孔中的文字
  1072. Text = 2,
  1073. //矩形
  1074. Rectangle = 3,
  1075. //选择的样品
  1076. SelectSample = 4,
  1077. //测量区域
  1078. MeasureArea = 5,
  1079. //帧图-直线绘制方式
  1080. SingleLine = 6,
  1081. //表样-矩形
  1082. SpecimenRectangle = 7,
  1083. //表样-圆形
  1084. SpecimenCircle = 8,
  1085. //帧图-矩形绘制
  1086. FieldRectangle = 9,
  1087. //颗粒直线图
  1088. ParticleLine = 10,
  1089. //颗粒分布图 鼠标
  1090. ParticleAreaRectangle = 11,
  1091. //绘制拍摄样品孔BSE照片
  1092. DrawFrameOfHoleBSEImage = 12,
  1093. //绘制sem中心点+
  1094. DrawSEMCenterPoint=13,
  1095. //绘制BSE采集标记
  1096. DrawBSEElementSignPoint = 14,
  1097. //多边形
  1098. Polygon = 15,
  1099. //多边形完成标识
  1100. DrawPolygonFinish = 16,
  1101. //圆形三点法
  1102. CircleByThreePoints=17,
  1103. RingShape=18
  1104. }
  1105. public enum ColorType
  1106. {
  1107. SingleColor,//帧图fd8f8f
  1108. RoundRectangleColor,//c8c8c8圆角矩形
  1109. SampleBackGroundColor,//c0c0c0圆角矩形
  1110. FontColor,//90ee90文字颜色
  1111. SampleColor,//f4f4f4 样品未选择
  1112. SampleSelColor//505050 样品选择后
  1113. }
  1114. public enum GrayLevel
  1115. {
  1116. Min=0,
  1117. Max=255
  1118. }
  1119. }