MetalsHoleAreaEditingDialog.cs 49 KB

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