CreateRectangle.cs 49 KB

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