MetalsHoleAreaEditingDialog.cs 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  1. using OpenCvSharp;
  2. using PaintDotNet.Adjust;
  3. using PaintDotNet.Base.Functionodel;
  4. using PaintDotNet.CustomControl;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Drawing;
  8. using System.Drawing.Drawing2D;
  9. using System.Windows.Forms;
  10. using Point = System.Drawing.Point;
  11. using PaintDotNet.Annotation;
  12. namespace PaintDotNet.DedicatedAnalysis.NonferrousMetals.IntegrationClass
  13. {
  14. internal class MetalsHoleAreaEditingDialog : Form
  15. {
  16. /// <summary>
  17. /// 公共按钮
  18. /// </summary>
  19. private CommonControlButtons commonControlButtons;
  20. /// <summary>
  21. /// 主控件
  22. /// </summary>
  23. private AppWorkspace appWorkspace;
  24. private DocumentWorkspaceWindow documentWorkspace;
  25. /// <summary>
  26. /// 外接矩形,或者是计算的矩形
  27. /// </summary>
  28. protected RectangleF rectangle = new RectangleF();
  29. ///// <summary>
  30. ///// 用于get处理后的图像
  31. ///// </summary>
  32. //private Mat phaseMat;
  33. ///// <summary>
  34. ///// 辅助线集成
  35. ///// </summary>
  36. //private GrainSizeGuideClass guideClass;
  37. //public object SelectedItem;
  38. Color phaseColor;
  39. Mat phaseMatCopy = new Mat();
  40. ///// <summary>
  41. ///// 当前处理的程序
  42. ///// </summary>
  43. //private Data.Action.Action911 action = new Data.Action.Action911();
  44. ///( 0,没有操作 1,折线添加 2,直线添加)
  45. /// <summary>
  46. /// 操作类型
  47. /// 0,没有操作 21,多边形添加 22,圆形添加 23,矩形添加 24,椭圆添加
  48. /// 11,多边形删除 12,圆形删除 13,矩形删除 14,椭圆删除
  49. /// </summary>
  50. private int pointKtype = 0;
  51. /// <summary>
  52. /// 起始点
  53. /// </summary>
  54. private Point startPoint = new Point(-1, -1);
  55. /// <summary>
  56. /// 是否绘制了起始点
  57. /// </summary>
  58. private bool drawedStartPoint = false;
  59. /// <summary>
  60. /// 结束点
  61. /// </summary>
  62. private Point endPoint = new Point(-1, -1);
  63. /// <summary>
  64. /// 折线点的集合
  65. /// </summary>
  66. public List<Point> pointArray = new List<Point>();
  67. /// <summary>
  68. /// 是否显示视场
  69. /// </summary>
  70. Boolean ShowDrawClassView = true;
  71. private GroupBox groupBox1;
  72. private GroupBox groupBox2;
  73. private Button button2;
  74. private Button button1;
  75. private Button button3;
  76. private Button button4;
  77. private Button button32;
  78. private Button button42;
  79. private Button button8;
  80. private Button button7;
  81. private Button button6;
  82. private Button button5;
  83. private TriangleTrackBar trackBar2;
  84. private TextBox textBox1;
  85. private Label label1;
  86. private TrackBar trackBar1;
  87. private Button button9;
  88. private GroupBox groupBox7;
  89. //public GrainSizeGuideClass GuideClass
  90. //{
  91. // set
  92. // {
  93. // this.guideClass = value;
  94. // }
  95. //}
  96. public MetalsHoleAreaEditingDialog(AppWorkspace appWorkspace, int focusedItemIndex, Color phaseColor, Mat analyzeMat, Boolean ShowDrawClassView = true)
  97. {
  98. this.ShowDrawClassView = ShowDrawClassView;
  99. this.appWorkspace = appWorkspace;
  100. InitializeComponent();
  101. InitializeLanguageText();
  102. //
  103. //初始化图像控件
  104. //
  105. this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
  106. this.documentWorkspace.Dock = DockStyle.Fill;
  107. this.documentWorkspace.HookMouseEvents();
  108. this.documentWorkspace.AuxiliaryLineEnabled = false;
  109. this.documentWorkspace.Visible = false;
  110. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  111. this.documentWorkspace.panel.Paint += Panel_Paint;
  112. this.documentWorkspace.panel.MouseMove += onMouseMove;
  113. this.documentWorkspace.panel.MouseUp += onMouseUp;
  114. this.documentWorkspace.panel.Click += new EventHandler(this.pictureBox1_Click);
  115. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;//禁止视场移动
  116. this.groupBox7.Controls.Add(documentWorkspace);
  117. //
  118. //初始化操作按钮
  119. //
  120. this.commonControlButtons = new CommonControlButtons();
  121. this.commonControlButtons.Dock = DockStyle.Top;
  122. this.commonControlButtons.Height = 30;
  123. this.commonControlButtons.HideZoomToWindowAndActualSize();
  124. this.groupBox7.Controls.Add(commonControlButtons);
  125. this.phaseColor = phaseColor;
  126. {
  127. //
  128. //初始化相
  129. //
  130. PhaseModel model = new PhaseModel();
  131. model.choise = true;
  132. model.mat = null;
  133. model.color = phaseColor.ToArgb();// Color.Green/*panel2.BackColor*/.ToArgb();
  134. model.position = this.documentWorkspace.PhaseModels.Count + 1;
  135. model.name = PdnResources.GetString("Menu.Binarization.text");
  136. this.documentWorkspace.PhaseModels.Add(model);
  137. }
  138. this.documentWorkspace.PhaseModels[0].mat = analyzeMat;// phaseMat;
  139. this.documentWorkspace.PhaseModels[0].mat.CopyTo(phaseMatCopy);
  140. this.documentWorkspace.Refresh();
  141. /// <summary>
  142. /// 选中图片的mat
  143. Mat imageMat = this.appWorkspace.DocumentWorkspaces[focusedItemIndex].CompositionSurface.CreatedAliasedMat();
  144. Document document = Document.FromImageMat(imageMat.Clone());
  145. this.documentWorkspace.Document = document;
  146. this.documentWorkspace.Visible = true;
  147. if (ShowDrawClassView)
  148. {
  149. this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[focusedItemIndex].GraphicsList;
  150. }
  151. else
  152. {
  153. GraphicsList itemGraphicsList = this.appWorkspace.DocumentWorkspaces[focusedItemIndex].GraphicsList;
  154. GraphicsList graphicsList = new GraphicsList();
  155. for (int j = 0; j < itemGraphicsList.Count; j++)
  156. {
  157. if (itemGraphicsList[j].objectType != Annotation.Enum.DrawClass.View)
  158. graphicsList.Add(itemGraphicsList[j]);
  159. }
  160. this.documentWorkspace.GraphicsList = graphicsList;
  161. }
  162. InitCommonButtonEvent();
  163. }
  164. #region 矩形拖动
  165. /// <summary>
  166. /// 鼠标按下
  167. /// </summary>
  168. /// <param name="drawArea"></param>
  169. /// <param name="e"></param>
  170. private void OnMouseDown(object sender, MouseEventArgs e)
  171. {
  172. // 换算后的点
  173. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  174. if (point1.X <= this.documentWorkspace.CompositionSurface.Width
  175. && point1.X >= 0
  176. && point1.Y >= 0
  177. && point1.Y <= this.documentWorkspace.CompositionSurface.Height)
  178. {
  179. if (e.Button == MouseButtons.Left/* && e.Clicks == 1*/&& this.pointKtype >= 1)
  180. {
  181. if (!drawedStartPoint)
  182. {
  183. drawedStartPoint = true;
  184. startPoint = new Point((int)point1.X, (int)point1.Y);
  185. return;
  186. }
  187. }
  188. }
  189. else if (this.pointKtype == 14 || this.pointKtype == 13 || this.pointKtype == 12
  190. || this.pointKtype == 24 || this.pointKtype == 23 || this.pointKtype == 22)
  191. {
  192. if (!drawedStartPoint)
  193. {
  194. drawedStartPoint = true;
  195. startPoint = new Point((int)point1.X, (int)point1.Y);
  196. return;
  197. }
  198. }
  199. else
  200. return;
  201. // 右键完成操作
  202. if (e.Button == MouseButtons.Right)
  203. {
  204. }
  205. }
  206. /// <summary>
  207. /// 移动
  208. /// </summary>
  209. /// <param name="sender"></param>
  210. /// <param name="e"></param>
  211. private void onMouseMove(object sender, MouseEventArgs e)
  212. {
  213. // 换算后的点
  214. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  215. if (e.Button == MouseButtons.Left)
  216. {
  217. // 椭圆删除/圆形删除
  218. if ((this.pointKtype == 14 || this.pointKtype == 12
  219. || this.pointKtype == 24 || this.pointKtype == 22) && drawedStartPoint)
  220. {
  221. endPoint = new Point((int)point1.X, (int)point1.Y);
  222. if (this.startPoint.X < this.endPoint.X)
  223. {
  224. this.rectangle.X = this.startPoint.X;
  225. this.rectangle.Width = this.endPoint.X - this.startPoint.X;
  226. }
  227. else
  228. {
  229. this.rectangle.X = this.endPoint.X;
  230. this.rectangle.Width = this.startPoint.X - this.endPoint.X;
  231. }
  232. if (this.startPoint.Y < this.endPoint.Y)
  233. {
  234. this.rectangle.Y = this.startPoint.Y;
  235. this.rectangle.Height = this.endPoint.Y - this.startPoint.Y;
  236. }
  237. else
  238. {
  239. this.rectangle.Y = this.endPoint.Y;
  240. this.rectangle.Height = this.startPoint.Y - this.endPoint.Y;
  241. }
  242. this.documentWorkspace.Refresh();
  243. }
  244. // 矩形删除
  245. if ((this.pointKtype == 13 || this.pointKtype == 23) && drawedStartPoint)
  246. {
  247. endPoint = new Point((int)point1.X, (int)point1.Y);
  248. if (this.startPoint.X < this.endPoint.X)
  249. {
  250. this.rectangle.X = this.startPoint.X;
  251. this.rectangle.Width = this.endPoint.X - this.startPoint.X;
  252. }
  253. else
  254. {
  255. this.rectangle.X = this.endPoint.X;
  256. this.rectangle.Width = this.startPoint.X - this.endPoint.X;
  257. }
  258. if (this.startPoint.Y < this.endPoint.Y)
  259. {
  260. this.rectangle.Y = this.startPoint.Y;
  261. this.rectangle.Height = this.endPoint.Y - this.startPoint.Y;
  262. }
  263. else
  264. {
  265. this.rectangle.Y = this.endPoint.Y;
  266. this.rectangle.Height = this.startPoint.Y - this.endPoint.Y;
  267. }
  268. this.documentWorkspace.Refresh();
  269. }
  270. //// 直线添加
  271. //if (this.pointKtype == 2 && drawedStartPoint)
  272. //{
  273. // endPoint = new Point((int)point1.X, (int)point1.Y);
  274. // this.documentWorkspace.Refresh();
  275. //}
  276. }
  277. }
  278. /// <summary>
  279. /// 鼠标抬起
  280. /// </summary>
  281. /// <param name="sender"></param>
  282. /// <param name="e"></param>
  283. private void onMouseUp(object sender, MouseEventArgs e)
  284. {
  285. // 换算后的点
  286. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  287. if (point1.X <= this.documentWorkspace.CompositionSurface.Width
  288. && point1.X >= 0
  289. && point1.Y >= 0
  290. && point1.Y <= this.documentWorkspace.CompositionSurface.Height) { }
  291. else
  292. {
  293. if (this.pointKtype == 14 || this.pointKtype == 13 || this.pointKtype == 12
  294. || this.pointKtype == 24 || this.pointKtype == 23 || this.pointKtype == 22)
  295. {
  296. //if (point1.X >= this.documentWorkspace.CompositionSurface.Width)
  297. // point1.X = this.documentWorkspace.CompositionSurface.Width - 1;
  298. //if (point1.X < 0)
  299. // point1.X = 0;
  300. //if (point1.Y >= this.documentWorkspace.CompositionSurface.Height)
  301. // point1.Y = this.documentWorkspace.CompositionSurface.Height - 1;
  302. //if (point1.Y < 0)
  303. // point1.Y = 0;
  304. }
  305. else
  306. return;
  307. }
  308. if (e.Button == MouseButtons.Right)
  309. {
  310. // 折线删除
  311. if ((this.pointKtype == 11 || this.pointKtype == 21) && pointArray.Count > 1)
  312. {
  313. pointArray.Add(new Point((int)point1.X, (int)point1.Y));
  314. endPoint = new Point((int)point1.X, (int)point1.Y);
  315. List<PointF> pointFArray = new List<PointF>();
  316. foreach (var item in pointArray)
  317. {
  318. pointFArray.Add(new PointF(item.X, item.Y));
  319. }
  320. if (this.pointKtype == 21)
  321. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.PolygonAdd(this.documentWorkspace.PhaseModels[0].mat, phaseColor.ToArgb(), pointFArray);
  322. else
  323. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.PolygonDelete(this.documentWorkspace.PhaseModels[0].mat, pointFArray);
  324. this.documentWorkspace.PhaseModels[0].mat.CopyTo(phaseMatCopy);
  325. ////保存处理后的图片
  326. //Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  327. //Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  328. //Graphics graphics = Graphics.FromImage(newBit);
  329. //Draw(graphics);
  330. //this.documentWorkspace.PhaseModels[0].mat/* = phaseMat*/ = PaintDotNet.Camera.Tools.ToMat(newBit);
  331. this.rectangle.X = -1;
  332. this.rectangle.Y = -1;
  333. this.rectangle.Width = 0;
  334. this.rectangle.Height = 0;
  335. pointArray.Clear();
  336. startPoint = new Point(-1, -1);
  337. drawedStartPoint = false;
  338. endPoint = new Point(-1, -1);
  339. this.pointKtype = 0;
  340. this.documentWorkspace.Refresh();
  341. }
  342. //// 折线添加
  343. //if (this.pointKtype == 1 && pointArray.Count > 1)
  344. //{
  345. // pointArray.Add(new Point((int)point1.X, (int)point1.Y));
  346. // endPoint = new Point((int)point1.X, (int)point1.Y);
  347. // //List<Point> alPoints = this.findAllPoints(pointArray);
  348. // //if (alPoints.Count > 1)
  349. // // analyzePoints.Add(alPoints.ToArray());
  350. // //保存处理后的图片
  351. // Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  352. // Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  353. // Graphics graphics = Graphics.FromImage(newBit);
  354. // Draw(graphics);
  355. // this.documentWorkspace.PhaseModels[0].mat/* = phaseMat*/ = PaintDotNet.Camera.Tools.ToMat(newBit);
  356. // this.documentWorkspace.PhaseModels[0].mat.CopyTo(phaseMatCopy);
  357. // pointArray.Clear();
  358. // startPoint = new Point(-1, -1);
  359. // drawedStartPoint = false;
  360. // endPoint = new Point(-1, -1);
  361. // this.pointKtype = 0;
  362. // this.documentWorkspace.Refresh();
  363. //}
  364. }
  365. if (e.Button == MouseButtons.Left)
  366. {
  367. // 圆形删除/椭圆删除
  368. if ((this.pointKtype == 14 || this.pointKtype == 12
  369. || this.pointKtype == 24 || this.pointKtype == 22) && drawedStartPoint)
  370. {
  371. endPoint = new Point((int)point1.X, (int)point1.Y);
  372. if (this.startPoint.X < this.endPoint.X)
  373. {
  374. this.rectangle.X = this.startPoint.X;
  375. this.rectangle.Width = this.endPoint.X - this.startPoint.X;
  376. }
  377. else
  378. {
  379. this.rectangle.X = this.endPoint.X;
  380. this.rectangle.Width = this.startPoint.X - this.endPoint.X;
  381. }
  382. if (this.startPoint.Y < this.endPoint.Y)
  383. {
  384. this.rectangle.Y = this.startPoint.Y;
  385. this.rectangle.Height = this.endPoint.Y - this.startPoint.Y;
  386. }
  387. else
  388. {
  389. this.rectangle.Y = this.endPoint.Y;
  390. this.rectangle.Height = this.startPoint.Y - this.endPoint.Y;
  391. }
  392. if (this.pointKtype == 14 || this.pointKtype == 24)
  393. if (this.pointKtype == 24)
  394. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.EllipseAdd(this.documentWorkspace.PhaseModels[0].mat, phaseColor.ToArgb(), this.rectangle);
  395. else
  396. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.OvalDelete(this.documentWorkspace.PhaseModels[0].mat, this.rectangle);
  397. else
  398. {
  399. if (this.pointKtype == 22)
  400. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.EllipseAdd(this.documentWorkspace.PhaseModels[0].mat, phaseColor.ToArgb()
  401. , new RectangleF(this.rectangle.X, this.rectangle.Y, Math.Min(this.rectangle.Width, this.rectangle.Height), Math.Min(this.rectangle.Width, this.rectangle.Height)));
  402. else
  403. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.OvalDelete(this.documentWorkspace.PhaseModels[0].mat
  404. , new RectangleF(this.rectangle.X, this.rectangle.Y, Math.Min(this.rectangle.Width, this.rectangle.Height), Math.Min(this.rectangle.Width, this.rectangle.Height)));
  405. }
  406. this.documentWorkspace.PhaseModels[0].mat.CopyTo(phaseMatCopy);
  407. this.rectangle.X = -1;
  408. this.rectangle.Y = -1;
  409. this.rectangle.Width = 0;
  410. this.rectangle.Height = 0;
  411. startPoint = new Point(-1, -1);
  412. drawedStartPoint = false;
  413. endPoint = new Point(-1, -1);
  414. this.pointKtype = 0;
  415. this.documentWorkspace.Refresh();
  416. }
  417. // 矩形删除
  418. if ((this.pointKtype == 13 || this.pointKtype == 23) && drawedStartPoint)
  419. {
  420. endPoint = new Point((int)point1.X, (int)point1.Y);
  421. if (this.startPoint.X < this.endPoint.X)
  422. {
  423. this.rectangle.X = this.startPoint.X;
  424. this.rectangle.Width = this.endPoint.X - this.startPoint.X;
  425. }
  426. else
  427. {
  428. this.rectangle.X = this.endPoint.X;
  429. this.rectangle.Width = this.startPoint.X - this.endPoint.X;
  430. }
  431. if (this.startPoint.Y < this.endPoint.Y)
  432. {
  433. this.rectangle.Y = this.startPoint.Y;
  434. this.rectangle.Height = this.endPoint.Y - this.startPoint.Y;
  435. }
  436. else
  437. {
  438. this.rectangle.Y = this.endPoint.Y;
  439. this.rectangle.Height = this.startPoint.Y - this.endPoint.Y;
  440. }
  441. if (this.pointKtype == 23)
  442. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.RectangleAdd(this.documentWorkspace.PhaseModels[0].mat, phaseColor.ToArgb(), this.rectangle);
  443. else
  444. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.RectangleDelete(this.documentWorkspace.PhaseModels[0].mat, this.rectangle);
  445. this.documentWorkspace.PhaseModels[0].mat.CopyTo(phaseMatCopy);
  446. ////保存处理后的图片
  447. //Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  448. //Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  449. //Graphics graphics = Graphics.FromImage(newBit);
  450. //Draw(graphics);
  451. //this.documentWorkspace.PhaseModels[0].mat/* = phaseMat*/ = PaintDotNet.Camera.Tools.ToMat(newBit);
  452. this.rectangle.X = -1;
  453. this.rectangle.Y = -1;
  454. this.rectangle.Width = 0;
  455. this.rectangle.Height = 0;
  456. startPoint = new Point(-1, -1);
  457. drawedStartPoint = false;
  458. endPoint = new Point(-1, -1);
  459. this.pointKtype = 0;
  460. this.documentWorkspace.Refresh();
  461. }
  462. // 折线添加/折线删除
  463. if (this.pointKtype == 1 || this.pointKtype == 11 || this.pointKtype == 21)
  464. {
  465. pointArray.Add(new Point((int)point1.X, (int)point1.Y));
  466. if (!drawedStartPoint)
  467. {
  468. drawedStartPoint = true;
  469. startPoint = new Point((int)point1.X, (int)point1.Y);
  470. }
  471. this.documentWorkspace.Refresh();
  472. }
  473. //// 直线添加
  474. //if (this.pointKtype == 2 && drawedStartPoint)
  475. //{
  476. // endPoint = new Point((int)point1.X, (int)point1.Y);
  477. // //保存处理后的图片
  478. // Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat);
  479. // Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  480. // Graphics graphics = Graphics.FromImage(newBit);
  481. // Draw(graphics);
  482. // this.documentWorkspace.PhaseModels[0].mat/* = phaseMat*/ = PaintDotNet.Camera.Tools.ToMat(newBit);
  483. // this.documentWorkspace.PhaseModels[0].mat.CopyTo(phaseMatCopy);
  484. // startPoint = new Point(-1, -1);
  485. // drawedStartPoint = false;
  486. // endPoint = new Point(-1, -1);
  487. // this.pointKtype = 0;
  488. // this.documentWorkspace.Refresh();
  489. //}
  490. }
  491. }
  492. #endregion
  493. /// <summary>
  494. /// surfaceBox双击事件
  495. /// 目前是参考AxioVision
  496. /// 应该是把每次选的点都取最高和最低的BGR
  497. /// </summary>
  498. /// <param name="sender"></param>
  499. /// <param name="e"></param>
  500. private unsafe void pictureBox1_Click(object sender, EventArgs e)
  501. {
  502. }
  503. /// <summary>
  504. /// 画布绘制
  505. /// </summary>
  506. /// <param name="sender"></param>
  507. /// <param name="e"></param>
  508. private void Panel_Paint(object sender, PaintEventArgs e)
  509. {
  510. if (this.documentWorkspace.CompositionSurface != null)
  511. {
  512. //
  513. // 以下是计算绘制图片的位置和大小并绘制图片
  514. //
  515. System.Drawing.Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  516. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  517. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  518. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  519. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  520. //
  521. // 以下是绘制网格、标注、测量、视场等开始
  522. //
  523. e.Graphics.TranslateTransform(x, y);
  524. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  525. //if (this.checkBox4_0.Checked)//显示网格
  526. Draw(e.Graphics);
  527. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  528. e.Graphics.TranslateTransform(-x, -y);
  529. }
  530. }
  531. /// <summary>
  532. /// 绘制
  533. /// </summary>
  534. private void Draw(Graphics g)
  535. {
  536. // 抗锯齿
  537. g.SmoothingMode = SmoothingMode.AntiAlias;
  538. //圆形删除/椭圆删除
  539. if ((this.pointKtype == 14 || this.pointKtype == 12
  540. || this.pointKtype == 24 || this.pointKtype == 22) && (this.rectangle.Width > 0 || this.rectangle.Height > 0))
  541. {
  542. Pen pen = new Pen(Color.FromArgb(255, 255 - this.phaseColor.R, 255 - this.phaseColor.G, 255 - this.phaseColor.B), 1);
  543. pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
  544. if (this.pointKtype == 14 || this.pointKtype == 24)
  545. g.DrawEllipse(pen, this.rectangle);
  546. else
  547. g.DrawEllipse(pen, new RectangleF(this.rectangle.X, this.rectangle.Y, Math.Min(this.rectangle.Width, this.rectangle.Height), Math.Min(this.rectangle.Width, this.rectangle.Height)));
  548. pen.Dispose();
  549. }
  550. //矩形删除
  551. if ((this.pointKtype == 13 || this.pointKtype == 23) && (this.rectangle.Width > 0 || this.rectangle.Height > 0))
  552. {
  553. Pen pen = new Pen(Color.FromArgb(255, 255 - this.phaseColor.R, 255 - this.phaseColor.G, 255 - this.phaseColor.B), 1);
  554. pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
  555. g.DrawRectangle(pen, new Rectangle((int)this.rectangle.X, (int)this.rectangle.Y, (int)this.rectangle.Width, (int)this.rectangle.Height));
  556. pen.Dispose();
  557. }
  558. // 折线删除
  559. if ((this.pointKtype == 11 || this.pointKtype == 21) && pointArray.Count >= 2)
  560. {
  561. Pen pen = new Pen(Color.FromArgb(255, 255 - this.phaseColor.R, 255 - this.phaseColor.G, 255 - this.phaseColor.B), 1);
  562. pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
  563. g.DrawPolygon(pen, pointArray.ToArray());
  564. pen.Dispose();
  565. }
  566. //// 直线添加
  567. //if (this.pointKtype == 2 && drawedStartPoint && this.endPoint.X > -1 && this.endPoint.Y > -1)
  568. //{
  569. // Pen pen = new Pen(this.phaseColor, this.trackBar1.Value);
  570. // //pen.DashStyle = DashStyle.Dash;
  571. // g.DrawLine(pen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
  572. // pen.Dispose();
  573. //}
  574. //// 折线添加
  575. //if (this.pointKtype == 1 && pointArray.Count >= 2)
  576. //{
  577. // Pen pen = new Pen(this.phaseColor, this.trackBar1.Value);
  578. // g.DrawLines(pen, pointArray.ToArray());
  579. // pen.Dispose();
  580. //}
  581. }
  582. private void InitializeLanguageText()
  583. {
  584. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  585. this.button9.Text = PdnResources.GetString("CommonAction.Undo");
  586. this.button2.Text = PdnResources.GetString("Menu.File.Close.Text");
  587. this.button1.Text = PdnResources.GetString("Form.OkButton.Text");
  588. this.groupBox2.Text = "操作按钮";// PdnResources.GetString("Menu.BinaryAction.Text");
  589. this.button8.Text = PdnResources.GetString("Menu.Ellipsedelete.text");
  590. this.button7.Text = PdnResources.GetString("Menu.BinaryAction.RectangleDelete.Text");
  591. this.button6.Text = PdnResources.GetString("Menu.rounddelete.text");
  592. this.button5.Text = PdnResources.GetString("Menu.BinaryAction.PolygonleDelete.Text");
  593. this.label1.Text = PdnResources.GetString("Menu.Linewidth.text") + ":";
  594. this.button4.Text = "圆形添加";// PdnResources.GetString("Menu.Lineadd.text");
  595. this.button3.Text = "多边形添加";// PdnResources.GetString("Menu.Polylineadd.text");
  596. this.button42.Text = "椭圆添加";// PdnResources.GetString("Menu.Lineadd.text");
  597. this.button32.Text = "矩形添加";// PdnResources.GetString("Menu.Polylineadd.text");
  598. this.groupBox7.Text = PdnResources.GetString("Menu.Preview.text");
  599. this.Text = "修改孔隙";// PdnResources.GetString("Menu.filter.text");
  600. }
  601. private void InitializeComponent()
  602. {
  603. this.groupBox1 = new System.Windows.Forms.GroupBox();
  604. this.button9 = new System.Windows.Forms.Button();
  605. this.button2 = new System.Windows.Forms.Button();
  606. this.button1 = new System.Windows.Forms.Button();
  607. this.groupBox2 = new System.Windows.Forms.GroupBox();
  608. this.button8 = new System.Windows.Forms.Button();
  609. this.trackBar1 = new System.Windows.Forms.TrackBar();
  610. this.button7 = new System.Windows.Forms.Button();
  611. this.trackBar2 = new PaintDotNet.CustomControl.TriangleTrackBar();
  612. this.button6 = new System.Windows.Forms.Button();
  613. this.textBox1 = new System.Windows.Forms.TextBox();
  614. this.button5 = new System.Windows.Forms.Button();
  615. this.label1 = new System.Windows.Forms.Label();
  616. this.button4 = new System.Windows.Forms.Button();
  617. this.button3 = new System.Windows.Forms.Button();
  618. this.button42 = new System.Windows.Forms.Button();
  619. this.button32 = new System.Windows.Forms.Button();
  620. this.groupBox7 = new System.Windows.Forms.GroupBox();
  621. this.groupBox1.SuspendLayout();
  622. this.groupBox2.SuspendLayout();
  623. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
  624. this.SuspendLayout();
  625. //
  626. // groupBox1
  627. //
  628. this.groupBox1.Controls.Add(this.button9);
  629. this.groupBox1.Controls.Add(this.button2);
  630. this.groupBox1.Controls.Add(this.button1);
  631. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  632. this.groupBox1.Name = "groupBox1";
  633. this.groupBox1.Size = new System.Drawing.Size(808, 45);
  634. this.groupBox1.TabIndex = 0;
  635. this.groupBox1.TabStop = false;
  636. //
  637. // button9
  638. //
  639. this.button9.Location = new System.Drawing.Point(468, 13);
  640. this.button9.Name = "button9";
  641. this.button9.Size = new System.Drawing.Size(91, 26);
  642. this.button9.TabIndex = 3;
  643. this.button9.UseVisualStyleBackColor = true;
  644. this.button9.Visible = false;
  645. //
  646. // button2
  647. //
  648. this.button2.Location = new System.Drawing.Point(694, 13);
  649. this.button2.Name = "button2";
  650. this.button2.Size = new System.Drawing.Size(91, 26);
  651. this.button2.TabIndex = 1;
  652. this.button2.UseVisualStyleBackColor = true;
  653. this.button2.Click += new System.EventHandler(this.button2_Click);
  654. //
  655. // button1
  656. //
  657. this.button1.Location = new System.Drawing.Point(582, 13);
  658. this.button1.Name = "button1";
  659. this.button1.Size = new System.Drawing.Size(91, 26);
  660. this.button1.TabIndex = 0;
  661. this.button1.UseVisualStyleBackColor = true;
  662. this.button1.Click += new System.EventHandler(this.button1_Click);
  663. //
  664. // groupBox2
  665. //
  666. this.groupBox2.Controls.Add(this.button8);
  667. this.groupBox2.Controls.Add(this.trackBar1);
  668. this.groupBox2.Controls.Add(this.button7);
  669. this.groupBox2.Controls.Add(this.trackBar2);
  670. this.groupBox2.Controls.Add(this.button6);
  671. this.groupBox2.Controls.Add(this.textBox1);
  672. this.groupBox2.Controls.Add(this.button5);
  673. this.groupBox2.Controls.Add(this.label1);
  674. this.groupBox2.Controls.Add(this.button4);
  675. this.groupBox2.Controls.Add(this.button3);
  676. this.groupBox2.Controls.Add(this.button42);
  677. this.groupBox2.Controls.Add(this.button32);
  678. this.groupBox2.Location = new System.Drawing.Point(12, 63);
  679. this.groupBox2.Name = "groupBox2";
  680. this.groupBox2.Size = new System.Drawing.Size(233, 199);
  681. this.groupBox2.TabIndex = 1;
  682. this.groupBox2.TabStop = false;
  683. //
  684. // button8
  685. //
  686. this.button8.Location = new System.Drawing.Point(134, 151);
  687. this.button8.Name = "button8";
  688. this.button8.Size = new System.Drawing.Size(73, 26);
  689. this.button8.TabIndex = 7;
  690. this.button8.UseVisualStyleBackColor = true;
  691. this.button8.Click += new System.EventHandler(this.button8_Click);
  692. //
  693. // trackBar1
  694. //
  695. this.trackBar1.AutoSize = false;
  696. this.trackBar1.Location = new System.Drawing.Point(107, 69);
  697. this.trackBar1.Maximum = 50;
  698. this.trackBar1.Minimum = 1;
  699. this.trackBar1.Name = "trackBar1";
  700. this.trackBar1.Size = new System.Drawing.Size(104, 31);
  701. this.trackBar1.TabIndex = 21;
  702. this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
  703. this.trackBar1.Value = 1;
  704. this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
  705. this.trackBar1.Visible = false;
  706. //
  707. // button7
  708. //
  709. this.button7.Location = new System.Drawing.Point(27, 151);
  710. this.button7.Name = "button7";
  711. this.button7.Size = new System.Drawing.Size(73, 26);
  712. this.button7.TabIndex = 6;
  713. this.button7.UseVisualStyleBackColor = true;
  714. this.button7.Click += new System.EventHandler(this.button7_Click);
  715. //
  716. // trackBar2
  717. //
  718. this.trackBar2.Location = new System.Drawing.Point(108, 69);
  719. this.trackBar2.Maximum = 50;
  720. this.trackBar2.Minimum = 1;
  721. this.trackBar2.Name = "trackBar2";
  722. this.trackBar2.Size = new System.Drawing.Size(102, 24);
  723. this.trackBar2.TabIndex = 20;
  724. this.trackBar2.Value = 1;
  725. this.trackBar2.Visible = false;
  726. //
  727. // button6
  728. //
  729. this.button6.Location = new System.Drawing.Point(134, 117);
  730. this.button6.Name = "button6";
  731. this.button6.Size = new System.Drawing.Size(73, 26);
  732. this.button6.TabIndex = 5;
  733. this.button6.UseVisualStyleBackColor = true;
  734. this.button6.Click += new System.EventHandler(this.button6_Click);
  735. //
  736. // textBox1
  737. //
  738. this.textBox1.Location = new System.Drawing.Point(68, 69);
  739. this.textBox1.Name = "textBox1";
  740. this.textBox1.Size = new System.Drawing.Size(32, 21);
  741. this.textBox1.TabIndex = 19;
  742. this.textBox1.Text = "1";
  743. this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
  744. this.textBox1.Visible = false;
  745. //
  746. // button5
  747. //
  748. this.button5.Location = new System.Drawing.Point(27, 117);
  749. this.button5.Name = "button5";
  750. this.button5.Size = new System.Drawing.Size(73, 26);
  751. this.button5.TabIndex = 4;
  752. this.button5.UseVisualStyleBackColor = true;
  753. this.button5.Click += new System.EventHandler(this.button5_Click);
  754. //
  755. // label1
  756. //
  757. this.label1.AutoSize = true;
  758. this.label1.Location = new System.Drawing.Point(28, 73);
  759. this.label1.Name = "label1";
  760. this.label1.Size = new System.Drawing.Size(0, 12);
  761. this.label1.TabIndex = 18;
  762. this.label1.Visible = false;
  763. //
  764. // button4
  765. //
  766. this.button4.Location = new System.Drawing.Point(135, 31);
  767. this.button4.Name = "button4";
  768. this.button4.Size = new System.Drawing.Size(73, 26);
  769. this.button4.TabIndex = 3;
  770. this.button4.UseVisualStyleBackColor = true;
  771. this.button4.Click += new System.EventHandler(this.button4_Click);
  772. //
  773. // button3
  774. //
  775. this.button3.Location = new System.Drawing.Point(28, 31);
  776. this.button3.Name = "button3";
  777. this.button3.Size = new System.Drawing.Size(73, 26);
  778. this.button3.TabIndex = 2;
  779. this.button3.UseVisualStyleBackColor = true;
  780. this.button3.Click += new System.EventHandler(this.button3_Click);
  781. //
  782. // button42
  783. //
  784. this.button42.Location = new System.Drawing.Point(135, 69);
  785. this.button42.Name = "button42";
  786. this.button42.Size = new System.Drawing.Size(73, 26);
  787. this.button42.TabIndex = 32;
  788. this.button42.UseVisualStyleBackColor = true;
  789. this.button42.Click += new System.EventHandler(this.button42_Click);
  790. //
  791. // button32
  792. //
  793. this.button32.Location = new System.Drawing.Point(28, 69);
  794. this.button32.Name = "button32";
  795. this.button32.Size = new System.Drawing.Size(73, 26);
  796. this.button32.TabIndex = 22;
  797. this.button32.UseVisualStyleBackColor = true;
  798. this.button32.Click += new System.EventHandler(this.button32_Click);
  799. //
  800. // groupBox7
  801. //
  802. this.groupBox7.Location = new System.Drawing.Point(251, 63);
  803. this.groupBox7.Name = "groupBox7";
  804. this.groupBox7.Size = new System.Drawing.Size(569, 502);
  805. this.groupBox7.TabIndex = 1;
  806. this.groupBox7.TabStop = false;
  807. //
  808. // MetalsHoleAreaEditingDialog
  809. //
  810. this.ClientSize = new System.Drawing.Size(832, 577);
  811. this.Controls.Add(this.groupBox2);
  812. this.Controls.Add(this.groupBox7);
  813. this.Controls.Add(this.groupBox1);
  814. this.MaximizeBox = false;
  815. this.MinimizeBox = false;
  816. this.Name = "MetalsHoleAreaEditingDialog";
  817. this.groupBox1.ResumeLayout(false);
  818. this.groupBox2.ResumeLayout(false);
  819. this.groupBox2.PerformLayout();
  820. ((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
  821. this.ResumeLayout(false);
  822. }
  823. /// <summary>
  824. /// 多边形添加
  825. /// </summary>
  826. /// <param name="sender"></param>
  827. /// <param name="e"></param>
  828. private void button3_Click(object sender, EventArgs e)
  829. {
  830. pointArray.Clear();
  831. startPoint = new Point(-1, -1);
  832. drawedStartPoint = false;
  833. endPoint = new Point(-1, -1);
  834. this.rectangle.X = -1;
  835. this.rectangle.Y = -1;
  836. this.rectangle.Width = 0;
  837. this.rectangle.Height = 0;
  838. this.pointKtype = 21;
  839. this.documentWorkspace.Refresh();
  840. //pointArray.Clear();
  841. //startPoint = new Point(-1, -1);
  842. //drawedStartPoint = false;
  843. //endPoint = new Point(-1, -1);
  844. //pointKtype = 21;
  845. //this.documentWorkspace.Refresh();
  846. }
  847. /// <summary>
  848. /// 圆线添加
  849. /// </summary>
  850. /// <param name="sender"></param>
  851. /// <param name="e"></param>
  852. private void button4_Click(object sender, EventArgs e)
  853. {
  854. startPoint = new Point(-1, -1);
  855. drawedStartPoint = false;
  856. endPoint = new Point(-1, -1);
  857. this.rectangle.X = -1;
  858. this.rectangle.Y = -1;
  859. this.rectangle.Width = 0;
  860. this.rectangle.Height = 0;
  861. this.pointKtype = 22;
  862. this.documentWorkspace.Refresh();
  863. }
  864. /// <summary>
  865. /// 矩形添加
  866. /// </summary>
  867. /// <param name="sender"></param>
  868. /// <param name="e"></param>
  869. private void button32_Click(object sender, EventArgs e)
  870. {
  871. startPoint = new Point(-1, -1);
  872. drawedStartPoint = false;
  873. endPoint = new Point(-1, -1);
  874. this.rectangle.X = -1;
  875. this.rectangle.Y = -1;
  876. this.rectangle.Width = 0;
  877. this.rectangle.Height = 0;
  878. this.pointKtype = 23;
  879. this.documentWorkspace.Refresh();
  880. }
  881. /// <summary>
  882. /// 椭圆添加
  883. /// </summary>
  884. /// <param name="sender"></param>
  885. /// <param name="e"></param>
  886. private void button42_Click(object sender, EventArgs e)
  887. {
  888. startPoint = new Point(-1, -1);
  889. drawedStartPoint = false;
  890. endPoint = new Point(-1, -1);
  891. this.rectangle.X = -1;
  892. this.rectangle.Y = -1;
  893. this.rectangle.Width = 0;
  894. this.rectangle.Height = 0;
  895. this.pointKtype = 24;
  896. this.documentWorkspace.Refresh();
  897. }
  898. ///// <summary>
  899. ///// 折线添加
  900. ///// </summary>
  901. ///// <param name="sender"></param>
  902. ///// <param name="e"></param>
  903. //private void button3_Click(object sender, EventArgs e)
  904. //{
  905. // pointArray.Clear();
  906. // startPoint = new Point(-1, -1);
  907. // drawedStartPoint = false;
  908. // endPoint = new Point(-1, -1);
  909. // pointKtype = 1;
  910. // this.documentWorkspace.Refresh();
  911. //}
  912. ///// <summary>
  913. ///// 直线添加
  914. ///// </summary>
  915. ///// <param name="sender"></param>
  916. ///// <param name="e"></param>
  917. //private void button4_Click(object sender, EventArgs e)
  918. //{
  919. // startPoint = new Point(-1, -1);
  920. // drawedStartPoint = false;
  921. // endPoint = new Point(-1, -1);
  922. // pointKtype = 2;
  923. // this.documentWorkspace.Refresh();
  924. //}
  925. private void InitCommonButtonEvent()
  926. {
  927. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  928. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  929. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  930. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  931. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  932. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  933. }
  934. private void zoomInButton_Click(object sender, EventArgs e)
  935. {
  936. this.documentWorkspace.ZoomIn();
  937. }
  938. private void zoomOutButton_Click(object sender, EventArgs e)
  939. {
  940. this.documentWorkspace.ZoomOut();
  941. }
  942. private void zoomToWindowButton_Click(object sender, EventArgs e)
  943. {
  944. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  945. }
  946. private void actualSizeButton_Click(object sender, EventArgs e)
  947. {
  948. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  949. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  950. }
  951. private void pointerButton_Click(object sender, EventArgs e)
  952. {
  953. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionNoEffect;
  954. this.documentWorkspace.Cursor = Cursors.Default;
  955. }
  956. private void mobileModeButton_Click(object sender, EventArgs e)
  957. {
  958. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  959. }
  960. //确定按钮点击事件
  961. private void button1_Click(object sender, EventArgs e)
  962. {
  963. this.phaseMatCopy = this.documentWorkspace.PhaseModels[0].mat;
  964. this.DialogResult = DialogResult.OK;
  965. this.Close();
  966. }
  967. /// <summary>
  968. /// 用于get处理后的图像
  969. /// </summary>
  970. public Mat PhaseMat
  971. {
  972. get
  973. {
  974. return this.phaseMatCopy;
  975. }
  976. //set
  977. //{
  978. // this.phaseMatCopy = value;
  979. //}
  980. }
  981. /// <summary>
  982. /// 矩形删除
  983. /// </summary>
  984. /// <param name="sender"></param>
  985. /// <param name="e"></param>
  986. private void button7_Click(object sender, EventArgs e)
  987. {
  988. startPoint = new Point(-1, -1);
  989. drawedStartPoint = false;
  990. endPoint = new Point(-1, -1);
  991. this.rectangle.X = -1;
  992. this.rectangle.Y = -1;
  993. this.rectangle.Width = 0;
  994. this.rectangle.Height = 0;
  995. this.pointKtype = 13;
  996. this.documentWorkspace.Refresh();
  997. }
  998. /// <summary>
  999. /// 椭圆删除
  1000. /// </summary>
  1001. /// <param name="sender"></param>
  1002. /// <param name="e"></param>
  1003. private void button8_Click(object sender, EventArgs e)
  1004. {
  1005. startPoint = new Point(-1, -1);
  1006. drawedStartPoint = false;
  1007. endPoint = new Point(-1, -1);
  1008. this.rectangle.X = -1;
  1009. this.rectangle.Y = -1;
  1010. this.rectangle.Width = 0;
  1011. this.rectangle.Height = 0;
  1012. this.pointKtype = 14;
  1013. this.documentWorkspace.Refresh();
  1014. }
  1015. /// <summary>
  1016. /// 圆形删除
  1017. /// </summary>
  1018. /// <param name="sender"></param>
  1019. /// <param name="e"></param>
  1020. private void button6_Click(object sender, EventArgs e)
  1021. {
  1022. startPoint = new Point(-1, -1);
  1023. drawedStartPoint = false;
  1024. endPoint = new Point(-1, -1);
  1025. this.rectangle.X = -1;
  1026. this.rectangle.Y = -1;
  1027. this.rectangle.Width = 0;
  1028. this.rectangle.Height = 0;
  1029. this.pointKtype = 12;
  1030. this.documentWorkspace.Refresh();
  1031. }
  1032. /// <summary>
  1033. /// 多边形删除
  1034. /// </summary>
  1035. /// <param name="sender"></param>
  1036. /// <param name="e"></param>
  1037. private void button5_Click(object sender, EventArgs e)
  1038. {
  1039. pointArray.Clear();
  1040. startPoint = new Point(-1, -1);
  1041. drawedStartPoint = false;
  1042. endPoint = new Point(-1, -1);
  1043. this.rectangle.X = -1;
  1044. this.rectangle.Y = -1;
  1045. this.rectangle.Width = 0;
  1046. this.rectangle.Height = 0;
  1047. this.pointKtype = 11;
  1048. this.documentWorkspace.Refresh();
  1049. }
  1050. private void button2_Click(object sender, EventArgs e)
  1051. {
  1052. this.Close();
  1053. }
  1054. /// <summary>
  1055. /// 线宽改变
  1056. /// </summary>
  1057. /// <param name="sender"></param>
  1058. /// <param name="e"></param>
  1059. private void textBox1_TextChanged(object sender, EventArgs e)
  1060. {
  1061. int valueT;
  1062. if (!int.TryParse(textBox1.Text, out valueT))
  1063. return;
  1064. if (this.trackBar1.Minimum > valueT)
  1065. valueT = this.trackBar1.Minimum;
  1066. if (this.trackBar1.Maximum < valueT)
  1067. valueT = this.trackBar1.Maximum;
  1068. this.trackBar1.Value = valueT;
  1069. //this.textBox1.Text = valueT + "";
  1070. this.documentWorkspace.Refresh();
  1071. }
  1072. private void trackBar1_Scroll(object sender, EventArgs e)
  1073. {
  1074. this.textBox1.Text = this.trackBar1.Value + "";
  1075. this.documentWorkspace.Refresh();
  1076. }
  1077. }
  1078. }