SpheroidizationGradingEditDialog.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. using OpenCvSharp;
  2. using PaintDotNet.Adjust;
  3. using PaintDotNet.Annotation.Enum;
  4. using PaintDotNet.Base.CommTool;
  5. using PaintDotNet.CustomControl;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Drawing.Drawing2D;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. namespace PaintDotNet.DedicatedAnalysis.SpheroidizedStructure.GBT38770
  17. {
  18. internal class SpheroidizationGradingEditDialog : Form
  19. {
  20. #region 控件
  21. private GroupBox groupBox1;
  22. private GroupBox groupBox2;
  23. private GroupBox groupBox3;
  24. private Button button2;
  25. private Button button1;
  26. private ComboBox comboBox1;
  27. private Label label2;
  28. private Label label1;
  29. private Button button5;
  30. private Button button4;
  31. private Button button3;
  32. private GroupBox groupBox4;
  33. private Label label3;
  34. #endregion
  35. /// <summary>
  36. /// 图像面板
  37. /// </summary>
  38. private DocumentWorkspaceWindow documentWorkspace;
  39. /// <summary>
  40. /// 公共控件
  41. /// </summary>
  42. private CommonControlButtons commonControlButtons;
  43. /// <summary>
  44. /// 图片
  45. /// </summary>
  46. private Mat imageMat;
  47. /// <summary>
  48. /// 球状长宽比
  49. /// </summary>
  50. private decimal globulAraspectRatio;
  51. /// <summary>
  52. /// 片状长宽比
  53. /// </summary>
  54. private decimal flakAspectRatio;
  55. /// <summary>
  56. /// 直径
  57. /// </summary>
  58. private double length;
  59. /// <summary>
  60. /// 圆心
  61. /// </summary>
  62. private PointF center;
  63. /// <summary>
  64. /// 点集合
  65. /// </summary>
  66. List<RectangleF> points = new List<RectangleF>();
  67. /// <summary>
  68. /// 停止绘制
  69. /// </summary>
  70. private bool stop;
  71. /// <summary>
  72. /// 操作区分 0:折线分割 1:多边形添加 2:圆形添加
  73. /// </summary>
  74. private int operation = -1;
  75. /// <summary>
  76. /// 是否绘制
  77. /// </summary>
  78. private bool canDraw = true;
  79. /// <summary>
  80. /// 确定
  81. /// </summary>
  82. private bool determine = false;
  83. Mat mat = new Mat();
  84. Mat mat1 = new Mat();
  85. public SpheroidizationGradingEditDialog(DocumentWorkspaceWindow documentWorkspace, Mat imageMat, decimal globulAraspectRatio, decimal flakAspectRatio)
  86. {
  87. InitializeComponent();
  88. InitializeLanguageText();
  89. this.globulAraspectRatio = globulAraspectRatio;
  90. this.flakAspectRatio = flakAspectRatio;
  91. this.comboBox1.SelectedIndex = 0;
  92. this.imageMat = imageMat;
  93. this.documentWorkspace = documentWorkspace;
  94. this.documentWorkspace.PhaseModels[0].mat.CopyTo(this.mat);
  95. this.documentWorkspace.PhaseModels[0].mat.CopyTo(this.mat1);
  96. this.groupBox4.Controls.Add(documentWorkspace);
  97. Document document = Document.FromImageMat(imageMat.Clone());//待测试效率
  98. this.documentWorkspace.Document = document;
  99. this.documentWorkspace.Visible = true;
  100. this.commonControlButtons = new CommonControlButtons();
  101. this.commonControlButtons.Dock = DockStyle.Top;
  102. this.commonControlButtons.Height = 30;
  103. this.commonControlButtons.HideZoomToWindowAndActualSize();
  104. this.groupBox4.Controls.Add(commonControlButtons);
  105. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  106. this.documentWorkspace.panel.Paint += Panel_Paint;
  107. this.documentWorkspace.panel.MouseMove += onMouseMove;
  108. this.documentWorkspace.panel.MouseUp += onMouseUp;
  109. InitCommonButtonEvent();
  110. }
  111. #region 公共按钮
  112. private void InitCommonButtonEvent()
  113. {
  114. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  115. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  116. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  117. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  118. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  119. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  120. }
  121. private void zoomInButton_Click(object sender, EventArgs e)
  122. {
  123. this.documentWorkspace.ZoomIn();
  124. }
  125. private void zoomOutButton_Click(object sender, EventArgs e)
  126. {
  127. this.documentWorkspace.ZoomOut();
  128. }
  129. private void zoomToWindowButton_Click(object sender, EventArgs e)
  130. {
  131. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  132. }
  133. private void actualSizeButton_Click(object sender, EventArgs e)
  134. {
  135. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  136. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  137. }
  138. private void pointerButton_Click(object sender, EventArgs e)
  139. {
  140. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
  141. }
  142. private void mobileModeButton_Click(object sender, EventArgs e)
  143. {
  144. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  145. }
  146. #endregion
  147. #region 初始化
  148. private void InitializeLanguageText()
  149. {
  150. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  151. this.button2.Text = PdnResources.GetString("Menu.File.Close.Text");
  152. this.button1.Text = PdnResources.GetString("Form.OkButton.Text");
  153. this.groupBox2.Text = PdnResources.GetString("Menu.Imagement.Measurementlist.Attributes.text");
  154. this.comboBox1.Items.AddRange(new object[] {
  155. PdnResources.GetString("Menu.Globularcarbide.Text"),
  156. PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.lamellarpearlite.text")});
  157. this.label2.Text = PdnResources.GetString("Menu.Aspectio.Text") + ":";
  158. this.label1.Text = PdnResources.GetString("Menu.Type.text") + ":";
  159. this.groupBox3.Text = PdnResources.GetString("Menu.BinaryAction.Text");
  160. this.button5.Text = PdnResources.GetString("Menu.Thecircularadded.Text");
  161. this.button4.Text = PdnResources.GetString("Menu.polygonadd.text");
  162. this.button3.Text = PdnResources.GetString("Menu.Linesegmentation.Text");
  163. this.groupBox4.Text = PdnResources.GetString("Menu.organizationalproperties.Text");
  164. this.Text = PdnResources.GetString("Menu.anizationhierarchicalediting.Text");
  165. }
  166. private void InitializeComponent()
  167. {
  168. this.groupBox1 = new System.Windows.Forms.GroupBox();
  169. this.button2 = new System.Windows.Forms.Button();
  170. this.button1 = new System.Windows.Forms.Button();
  171. this.groupBox2 = new System.Windows.Forms.GroupBox();
  172. this.label3 = new System.Windows.Forms.Label();
  173. this.comboBox1 = new System.Windows.Forms.ComboBox();
  174. this.label2 = new System.Windows.Forms.Label();
  175. this.label1 = new System.Windows.Forms.Label();
  176. this.groupBox3 = new System.Windows.Forms.GroupBox();
  177. this.button5 = new System.Windows.Forms.Button();
  178. this.button4 = new System.Windows.Forms.Button();
  179. this.button3 = new System.Windows.Forms.Button();
  180. this.groupBox4 = new System.Windows.Forms.GroupBox();
  181. this.groupBox1.SuspendLayout();
  182. this.groupBox2.SuspendLayout();
  183. this.groupBox3.SuspendLayout();
  184. this.SuspendLayout();
  185. //
  186. // groupBox1
  187. //
  188. this.groupBox1.Controls.Add(this.button2);
  189. this.groupBox1.Controls.Add(this.button1);
  190. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  191. this.groupBox1.Name = "groupBox1";
  192. this.groupBox1.Size = new System.Drawing.Size(862, 60);
  193. this.groupBox1.TabIndex = 0;
  194. this.groupBox1.TabStop = false;
  195. //
  196. // button2
  197. //
  198. this.button2.Location = new System.Drawing.Point(751, 19);
  199. this.button2.Name = "button2";
  200. this.button2.Size = new System.Drawing.Size(96, 27);
  201. this.button2.TabIndex = 1;
  202. this.button2.UseVisualStyleBackColor = true;
  203. this.button2.Click += new System.EventHandler(this.button2_Click);
  204. //
  205. // button1
  206. //
  207. this.button1.Location = new System.Drawing.Point(649, 20);
  208. this.button1.Name = "button1";
  209. this.button1.Size = new System.Drawing.Size(96, 27);
  210. this.button1.TabIndex = 0;
  211. this.button1.UseVisualStyleBackColor = true;
  212. this.button1.Click += new System.EventHandler(this.button1_Click);
  213. //
  214. // groupBox2
  215. //
  216. this.groupBox2.Controls.Add(this.label3);
  217. this.groupBox2.Controls.Add(this.comboBox1);
  218. this.groupBox2.Controls.Add(this.label2);
  219. this.groupBox2.Controls.Add(this.label1);
  220. this.groupBox2.Location = new System.Drawing.Point(12, 78);
  221. this.groupBox2.Name = "groupBox2";
  222. this.groupBox2.Size = new System.Drawing.Size(214, 86);
  223. this.groupBox2.TabIndex = 1;
  224. this.groupBox2.TabStop = false;
  225. //
  226. // label3
  227. //
  228. this.label3.AutoSize = true;
  229. this.label3.Location = new System.Drawing.Point(72, 60);
  230. this.label3.Name = "label3";
  231. this.label3.Size = new System.Drawing.Size(23, 12);
  232. this.label3.TabIndex = 2;
  233. this.label3.Text = "< 0";
  234. //
  235. // comboBox1
  236. //
  237. this.comboBox1.FormattingEnabled = true;
  238. this.comboBox1.Location = new System.Drawing.Point(56, 25);
  239. this.comboBox1.Name = "comboBox1";
  240. this.comboBox1.Size = new System.Drawing.Size(110, 20);
  241. this.comboBox1.TabIndex = 0;
  242. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  243. //
  244. // label2
  245. //
  246. this.label2.AutoSize = true;
  247. this.label2.Location = new System.Drawing.Point(13, 60);
  248. this.label2.Name = "label2";
  249. this.label2.Size = new System.Drawing.Size(53, 12);
  250. this.label2.TabIndex = 1;
  251. //
  252. // label1
  253. //
  254. this.label1.AutoSize = true;
  255. this.label1.Location = new System.Drawing.Point(13, 29);
  256. this.label1.Name = "label1";
  257. this.label1.Size = new System.Drawing.Size(41, 12);
  258. this.label1.TabIndex = 0;
  259. //
  260. // groupBox3
  261. //
  262. this.groupBox3.Controls.Add(this.button5);
  263. this.groupBox3.Controls.Add(this.button4);
  264. this.groupBox3.Controls.Add(this.button3);
  265. this.groupBox3.Location = new System.Drawing.Point(12, 170);
  266. this.groupBox3.Name = "groupBox3";
  267. this.groupBox3.Size = new System.Drawing.Size(214, 94);
  268. this.groupBox3.TabIndex = 1;
  269. this.groupBox3.TabStop = false;
  270. //
  271. // button5
  272. //
  273. this.button5.Location = new System.Drawing.Point(6, 53);
  274. this.button5.Name = "button5";
  275. this.button5.Size = new System.Drawing.Size(96, 27);
  276. this.button5.TabIndex = 3;
  277. this.button5.UseVisualStyleBackColor = true;
  278. this.button5.Click += new System.EventHandler(this.button5_Click);
  279. //
  280. // button4
  281. //
  282. this.button4.Location = new System.Drawing.Point(112, 20);
  283. this.button4.Name = "button4";
  284. this.button4.Size = new System.Drawing.Size(96, 27);
  285. this.button4.TabIndex = 2;
  286. this.button4.UseVisualStyleBackColor = true;
  287. this.button4.Click += new System.EventHandler(this.button4_Click);
  288. //
  289. // button3
  290. //
  291. this.button3.Location = new System.Drawing.Point(6, 20);
  292. this.button3.Name = "button3";
  293. this.button3.Size = new System.Drawing.Size(96, 27);
  294. this.button3.TabIndex = 1;
  295. this.button3.UseVisualStyleBackColor = true;
  296. this.button3.Click += new System.EventHandler(this.button3_Click);
  297. //
  298. // groupBox4
  299. //
  300. this.groupBox4.Location = new System.Drawing.Point(232, 78);
  301. this.groupBox4.Name = "groupBox4";
  302. this.groupBox4.Size = new System.Drawing.Size(642, 521);
  303. this.groupBox4.TabIndex = 1;
  304. this.groupBox4.TabStop = false;
  305. //
  306. // SpheroidizationGradingEditDialog
  307. //
  308. this.ClientSize = new System.Drawing.Size(886, 611);
  309. this.Controls.Add(this.groupBox4);
  310. this.Controls.Add(this.groupBox3);
  311. this.Controls.Add(this.groupBox2);
  312. this.Controls.Add(this.groupBox1);
  313. this.Name = "SpheroidizationGradingEditDialog";
  314. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SpheroidizationGradingEditDialog_FormClosing);
  315. this.groupBox1.ResumeLayout(false);
  316. this.groupBox2.ResumeLayout(false);
  317. this.groupBox2.PerformLayout();
  318. this.groupBox3.ResumeLayout(false);
  319. this.ResumeLayout(false);
  320. }
  321. #endregion
  322. /// <summary>
  323. /// 关闭
  324. /// </summary>
  325. /// <param name="sender"></param>
  326. /// <param name="e"></param>
  327. private void button2_Click(object sender, EventArgs e)
  328. {
  329. this.operation = -1;
  330. this.points.Clear();
  331. SpheroidizationGradingDialog spheroidizationGradingDialog = (SpheroidizationGradingDialog)this.Owner;
  332. this.documentWorkspace.PhaseModels[0].mat = this.mat1;
  333. spheroidizationGradingDialog.EditPageClose(this.documentWorkspace);
  334. this.Close();
  335. }
  336. /// <summary>
  337. /// 切换
  338. /// </summary>
  339. /// <param name="sender"></param>
  340. /// <param name="e"></param>
  341. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  342. {
  343. if (PdnResources.GetString("Menu.Globularcarbide.Text").Equals(this.comboBox1.SelectedItem))
  344. this.label3.Text = "< " + this.globulAraspectRatio.ToString();
  345. if (PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.lamellarpearlite.text").Equals(this.comboBox1.SelectedItem))
  346. this.label3.Text = "> " + this.flakAspectRatio.ToString();
  347. }
  348. /// <summary>
  349. /// 折线分割
  350. /// </summary>
  351. /// <param name="sender"></param>
  352. /// <param name="e"></param>
  353. private void button3_Click(object sender, EventArgs e)
  354. {
  355. this.points.Clear();
  356. this.canDraw = true;
  357. this.operation = 0;
  358. this.stop = true;
  359. }
  360. /// <summary>
  361. /// 多边形添加
  362. /// </summary>
  363. /// <param name="sender"></param>
  364. /// <param name="e"></param>
  365. private void button4_Click(object sender, EventArgs e)
  366. {
  367. this.points.Clear();
  368. this.canDraw = true;
  369. this.operation = 1;
  370. this.stop = true;
  371. }
  372. /// <summary>
  373. /// 圆形添加
  374. /// </summary>
  375. /// <param name="sender"></param>
  376. /// <param name="e"></param>
  377. private void button5_Click(object sender, EventArgs e)
  378. {
  379. this.points.Clear();
  380. this.canDraw = true;
  381. this.operation = 2;
  382. this.stop = true;
  383. }
  384. /// <summary>
  385. /// 画布绘制
  386. /// </summary>
  387. /// <param name="sender"></param>
  388. /// <param name="e"></param>
  389. private void Panel_Paint(object sender, PaintEventArgs e)
  390. {
  391. if (this.documentWorkspace.CompositionSurface != null)
  392. {
  393. //
  394. // 以下是计算绘制图片的位置和大小并绘制图片
  395. //
  396. System.Drawing.Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
  397. int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
  398. int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
  399. int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2;
  400. int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2;
  401. //
  402. // 以下是绘制网格、标注、测量、视场等开始
  403. //
  404. e.Graphics.TranslateTransform(x, y);
  405. e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
  406. Draw(e.Graphics);
  407. e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
  408. e.Graphics.TranslateTransform(-x, -y);
  409. }
  410. }
  411. /// <summary>
  412. /// 绘制
  413. /// </summary>
  414. private void Draw(Graphics graphics)
  415. {
  416. if(this.canDraw)
  417. {
  418. Pen linePen = new Pen(Color.Black, 3);
  419. linePen.DashStyle = DashStyle.DashDotDot;
  420. // 抗锯齿
  421. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  422. if (this.operation == 0)
  423. {
  424. List<PointF> points = new List<PointF>();
  425. foreach (var point in this.points)
  426. {
  427. points.Add(new PointF(point.X + 1, point.Y + 1));
  428. }
  429. if (points.Count > 1)
  430. graphics.DrawLines(linePen, points.ToArray());
  431. }
  432. else if (this.operation == 1)
  433. {
  434. List<PointF> points = new List<PointF>();
  435. foreach (var point in this.points)
  436. {
  437. points.Add(new PointF(point.X + 1, point.Y + 1));
  438. }
  439. if (points.Count > 0)
  440. graphics.DrawPolygon(linePen, points.ToArray());
  441. }
  442. else if (this.operation == 2)
  443. {
  444. if (this.points.Count == 2)
  445. {
  446. // 判断位置
  447. PointF pointF = new PointF(this.points[0].X + 1, this.points[0].Y + 1);
  448. PointF pointF1 = new PointF(this.points[1].X + 1, this.points[1].Y + 1);
  449. // 直径
  450. this.length = BasicCalculationHelper.GetDistance(pointF, pointF1, 10);
  451. double x = (pointF.X + pointF1.X) / 2;
  452. double y = (pointF.Y + pointF1.Y) / 2;
  453. // 圆心
  454. this.center = new PointF((float)x, (float)y);
  455. if (pointF.X != pointF1.X || pointF.Y != pointF1.Y)
  456. graphics.DrawEllipse(linePen, center.X - (float)length / 2, center.Y - (float)length / 2, (float)length, (float)length);
  457. }
  458. }
  459. }
  460. }
  461. /// <summary>
  462. /// 鼠标按下
  463. /// </summary>
  464. /// <param name="drawArea"></param>
  465. /// <param name="e"></param>
  466. private void OnMouseDown(object sender, MouseEventArgs e)
  467. {
  468. // 换算后的点
  469. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  470. if(e.Button == MouseButtons.Left)
  471. {
  472. if((this.operation == 0 || this.operation == 1) && this.stop)
  473. {
  474. RectangleF pointF = new RectangleF(point1.X - 1, point1.Y - 1, 2, 2);
  475. points.Add(pointF);
  476. pointF = new RectangleF(point1.X, point1.Y, 2, 2);
  477. points.Add(pointF);
  478. }
  479. else if(this.operation == 2 && this.stop)
  480. {
  481. RectangleF pointF = new RectangleF(point1.X - 1, point1.Y - 1, 2, 2);
  482. points.Add(pointF);
  483. pointF = new RectangleF(point1.X, point1.Y, 2, 2);
  484. points.Add(pointF);
  485. }
  486. }
  487. else
  488. {
  489. if(this.operation == 1)
  490. {
  491. List<PointF> points = new List<PointF>();
  492. foreach (var point in this.points)
  493. {
  494. points.Add(new PointF(point.X + 1, point.Y + 1));
  495. }
  496. if (points.Count > 2)
  497. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.PolygonAdd
  498. (this.mat, this.documentWorkspace.PhaseModels[0].color, points);
  499. }
  500. else if(this.operation == 0)
  501. {
  502. List<PointF> points = new List<PointF>();
  503. foreach (var point in this.points)
  504. {
  505. points.Add(new PointF(point.X + 1, point.Y + 1));
  506. }
  507. if (points.Count > 1)
  508. {
  509. for (int i = 0; i < points.Count; i++)
  510. {
  511. if(i > 0)
  512. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.LineSplit
  513. (this.mat, points[i - 1], points[i], 3);
  514. }
  515. }
  516. }
  517. this.stop = false;
  518. this.canDraw = false;
  519. }
  520. this.documentWorkspace.Refresh();
  521. }
  522. /// <summary>
  523. /// 移动
  524. /// </summary>
  525. /// <param name="sender"></param>
  526. /// <param name="e"></param>
  527. private void onMouseMove(object sender, MouseEventArgs e)
  528. {
  529. // 换算后的点
  530. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  531. if (this.operation == 2 && this.stop)
  532. {
  533. if (this.points.Count == 2)
  534. {
  535. if (points.Count > 0)
  536. {
  537. RectangleF pointF = new RectangleF(point1.X - 1, point1.Y - 1, 2, 2);
  538. points[1] = pointF;
  539. this.documentWorkspace.Refresh();
  540. }
  541. }
  542. }
  543. else if ((this.operation == 0 || this.operation == 1) && this.stop)
  544. {
  545. if (points.Count > 0)
  546. {
  547. RectangleF pointF = new RectangleF(point1.X - 1, point1.Y - 1, 2, 2);
  548. points[this.points.Count - 1] = pointF;
  549. this.documentWorkspace.Refresh();
  550. }
  551. }
  552. }
  553. /// <summary>
  554. /// 鼠标抬起
  555. /// </summary>
  556. /// <param name="sender"></param>
  557. /// <param name="e"></param>
  558. private void onMouseUp(object sender, MouseEventArgs e)
  559. {
  560. // 换算后的点
  561. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  562. if(this.operation == 2 && this.stop)
  563. {
  564. RectangleF pointF = new RectangleF(point1.X - 1, point1.Y - 1, 2, 2);
  565. points.Add(pointF);
  566. this.operation = -1;
  567. this.canDraw = false;
  568. this.documentWorkspace.PhaseModels[0].mat = PreActionIntent.EllipseAdd
  569. (this.mat, this.documentWorkspace.PhaseModels[0].color, new RectangleF
  570. ((float)this.center.X - (float)this.length / 2, (float)this.center.Y - (float)this.length / 2, (float)this.length, (float)this.length));
  571. this.documentWorkspace.Refresh();
  572. }
  573. }
  574. /// <summary>
  575. /// 确定按钮
  576. /// </summary>
  577. /// <param name="sender"></param>
  578. /// <param name="e"></param>
  579. private void button1_Click(object sender, EventArgs e)
  580. {
  581. this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.SpheroidizationGradingEditDialog_FormClosing);
  582. this.operation = -1;
  583. this.points.Clear();
  584. SpheroidizationGradingDialog spheroidizationGradingDialog = (SpheroidizationGradingDialog)this.Owner;
  585. this.documentWorkspace.PhaseModels[0].mat = this.mat;
  586. spheroidizationGradingDialog.EditPageClose(this.documentWorkspace);
  587. this.Close();
  588. }
  589. private void SpheroidizationGradingEditDialog_FormClosing(object sender, FormClosingEventArgs e)
  590. {
  591. this.operation = -1;
  592. this.points.Clear();
  593. SpheroidizationGradingDialog spheroidizationGradingDialog = (SpheroidizationGradingDialog)this.Owner;
  594. this.documentWorkspace.PhaseModels[0].mat = this.mat1;
  595. spheroidizationGradingDialog.EditPageClose(this.documentWorkspace);
  596. }
  597. }
  598. }