CreateRectangle.cs 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331
  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. //SEMCenterPoint = m_RegionF.Location;
  900. var scalePs = new List<PointF>();
  901. foreach (var p in m_PolygonPoints)
  902. {
  903. float x, y;
  904. x = (p.X - mousePoint.X) / curZoom * deltaZoom + p.X;
  905. y = (p.Y - mousePoint.Y) / curZoom * deltaZoom + p.Y;
  906. scalePs.Add(new PointF(x, y));
  907. }
  908. m_PolygonPoints = scalePs;
  909. if (this.subItems.Count != 0)
  910. {
  911. foreach (var g in subItems)
  912. {
  913. g.Zoom(mousePoint,zoomNum);
  914. }
  915. }
  916. }
  917. public void Move(PointF location)
  918. {
  919. PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
  920. float X1;
  921. float Y1;
  922. X1 = (m_RegionF.X + offset.X);
  923. Y1 = (m_RegionF.Y + offset.Y);
  924. m_RegionF = new RectangleF(X1, Y1, m_RegionF.Width, m_RegionF.Height);
  925. m_refPoint.X = m_refPoint.X + offset.X;
  926. m_refPoint.Y = m_refPoint.Y + offset.Y;
  927. BSEImageWitdh = m_RegionF.Width;
  928. BSEImageHeight = m_RegionF.Height;
  929. BSEImageLocation = m_RegionF.Location;
  930. //SEMCenterPoint = m_RegionF.Location;
  931. LineStartPoint = m_RegionF.Location;
  932. m_DraggingPoint = new Point((int)location.X,(int)location.Y);
  933. var scalePs = new List<PointF>();
  934. foreach (var p in m_PolygonPoints)
  935. {
  936. float x, y;
  937. x = (p.X + offset.X);
  938. y = (p.Y + offset.Y);
  939. scalePs.Add(new PointF(x, y));
  940. }
  941. m_PolygonPoints = scalePs;
  942. if (this.subItems.Count != 0)
  943. {
  944. foreach (var g in subItems)
  945. {
  946. g.Move(location);
  947. }
  948. }
  949. }
  950. public void PositionAltering(PointF location,bool ifZoomCoord)
  951. {
  952. PointF offset = new PointF(location.X - DraggingPoint.X, location.Y - DraggingPoint.Y);
  953. PointF realShift;
  954. if (ifZoomCoord)
  955. {
  956. realShift = new PointF(offset.X / m_zoomNum, offset.Y / m_zoomNum);
  957. }
  958. else
  959. {
  960. realShift = new PointF(offset.X , offset.Y );
  961. }
  962. m_OrigineRegionF = new RectangleF(m_OrigineRegionF.X+realShift.X, m_OrigineRegionF.Y+realShift.Y, m_OrigineRegionF.Width, m_OrigineRegionF.Height);
  963. SetInitRegionF(m_OrigineRegionF);
  964. BSEImageWitdh = m_RegionF.Width;
  965. BSEImageHeight = m_RegionF.Height;
  966. BSEImageLocation = m_RegionF.Location;
  967. LineStartPoint = m_RegionF.Location;
  968. var scalePs = new List<PointF>();
  969. var OriginalPs = new List<PointF>();
  970. foreach (var p in m_PolygonPoints)
  971. {
  972. float x, y;
  973. x = (p.X + offset.X);
  974. y = (p.Y + offset.Y);
  975. scalePs.Add(new PointF(x, y));
  976. }
  977. m_PolygonPoints = scalePs;
  978. foreach (var p in m_originalPolygonPoints)
  979. {
  980. OriginalPs.Add(new PointF(p.X + realShift.X, p.Y + realShift.Y));
  981. }
  982. m_originalPolygonPoints = OriginalPs;
  983. m_DraggingPoint = new Point((int)location.X, (int)location.Y);
  984. if (this.subItems.Count != 0)
  985. {
  986. foreach (var g in subItems)
  987. {
  988. g.PositionAltering(location,ifZoomCoord);
  989. }
  990. }
  991. }
  992. public CRectangleGDIObject Duplicate(CreateRectangleType newType)
  993. {
  994. CRectangleGDIObject r = new CRectangleGDIObject();
  995. r.NameOrHoleName = this.nameOrHoleName;
  996. r.SampleName = this.SampleName;
  997. r.m_OrigineRegionF = this.m_OrigineRegionF;
  998. r.IsWorkSample = this.IsWorkSample;
  999. r.m_RegionF = this.m_RegionF;
  1000. r.m_refPoint = this.m_refPoint;
  1001. r.m_zoomNum = this.m_zoomNum;
  1002. r.shape = this.shape;
  1003. r.createType = newType;
  1004. return r;
  1005. }
  1006. virtual public bool ifRectangleIntersect(CRectangleGDIObject othergdi)
  1007. {
  1008. return true;
  1009. }
  1010. #endregion
  1011. //是否设置为选择样品
  1012. private bool m_IsAlter;
  1013. //是否存在帧图信息
  1014. //是否设置为拖动
  1015. private bool m_IsDragging;
  1016. private bool m_IsMoving;
  1017. //是否为工作样品
  1018. private bool m_IsWorkSample;
  1019. private CreateRectangleType createType;
  1020. private ShapeType shape;
  1021. private string id;
  1022. protected string nameOrHoleName="";
  1023. public string sampleName="";
  1024. //样品孔中样品的数量
  1025. public int sampleCount = 0;
  1026. public string strContent;
  1027. private Color selColor;
  1028. private PointF m_DraggingPoint;
  1029. private int m_sequenceNum;
  1030. protected RectangleF m_RegionF;
  1031. //绘制时与移动缩放时记录的位置与尺寸
  1032. protected RectangleF m_OrigineRegionF;
  1033. //private GraphicsPath g_Path=new GraphicsPath();
  1034. private PointF startPoint;
  1035. private PointF endPoint;
  1036. //绘制颗粒图
  1037. private Color lineColor;
  1038. private float lineLength;
  1039. private PointF lineStartPoint;
  1040. private int otsX;
  1041. private int otsY;
  1042. //绘制样品孔BSE图像
  1043. private Image bseImage;
  1044. //绘制样品孔BSE图像宽度
  1045. private float bseImageWidth;
  1046. //绘制样品孔BSE图像高度
  1047. private float bseImageHeight;
  1048. //绘制样品孔BSE图像位置
  1049. private PointF bseImageLocation;
  1050. //绘制SEM中心位置
  1051. private PointF semCenterPoint;
  1052. private List<PointF> m_PolygonPoints=new List<PointF>();
  1053. //绘制时与移动缩放时记录的位置
  1054. private List<PointF> m_originalPolygonPoints = new List<PointF>();
  1055. private List<CRectangleGDIObject> subItems=new List<CRectangleGDIObject>();
  1056. protected float m_zoomNum=1;
  1057. private PointF m_refPoint=new PointF(0,0);
  1058. }
  1059. public enum SEMControlIndex
  1060. {
  1061. Magnification=0,
  1062. WorkingDistance=1
  1063. }
  1064. public enum XYIndex
  1065. {
  1066. X = 0,
  1067. Y = 1
  1068. }
  1069. public enum CreateRectangleType
  1070. {
  1071. //样品台-圆形
  1072. SampleBackGround_Circle = -1,
  1073. //圆形
  1074. Circle = 0,
  1075. //圆角矩形
  1076. SampleBackGround_Rectangle = 1,
  1077. //样品孔中的文字
  1078. Text = 2,
  1079. //矩形
  1080. Rectangle = 3,
  1081. //选择的样品
  1082. SelectSample = 4,
  1083. //测量区域
  1084. MeasureArea = 5,
  1085. //帧图-直线绘制方式
  1086. SingleLine = 6,
  1087. //表样-矩形
  1088. SpecimenRectangle = 7,
  1089. //表样-圆形
  1090. SpecimenCircle = 8,
  1091. //帧图-矩形绘制
  1092. FieldRectangle = 9,
  1093. //颗粒直线图
  1094. ParticleLine = 10,
  1095. //颗粒分布图 鼠标
  1096. ParticleAreaRectangle = 11,
  1097. //绘制拍摄样品孔BSE照片
  1098. DrawFrameOfHoleBSEImage = 12,
  1099. //绘制sem中心点+
  1100. DrawSEMCenterPoint=13,
  1101. //绘制BSE采集标记
  1102. DrawBSEElementSignPoint = 14,
  1103. //多边形
  1104. Polygon = 15,
  1105. //多边形完成标识
  1106. DrawPolygonFinish = 16,
  1107. //圆形三点法
  1108. CircleByThreePoints=17,
  1109. RingShape=18
  1110. }
  1111. public enum ColorType
  1112. {
  1113. SingleColor,//帧图fd8f8f
  1114. RoundRectangleColor,//c8c8c8圆角矩形
  1115. SampleBackGroundColor,//c0c0c0圆角矩形
  1116. FontColor,//90ee90文字颜色
  1117. SampleColor,//f4f4f4 样品未选择
  1118. SampleSelColor//505050 样品选择后
  1119. }
  1120. public enum GrayLevel
  1121. {
  1122. Min=0,
  1123. Max=255
  1124. }
  1125. }