InclusionEditDialog.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929
  1. using PaintDotNet.Annotation;
  2. using PaintDotNet.Annotation.Command;
  3. using PaintDotNet.Annotation.DedicatedAnalysis;
  4. using PaintDotNet.Annotation.Enum;
  5. using PaintDotNet.Base.DedicatedAnalysis.Inclusions;
  6. using PaintDotNet.Base.DedicatedAnalysis.Inclusions.Model;
  7. using PaintDotNet.Base.Functionodel;
  8. using PaintDotNet.CustomControl;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.MethodOfAssessment;
  17. using static PaintDotNet.DedicatedAnalysis.Inclusions.InclusionsStandardDialog;
  18. namespace PaintDotNet.DedicatedAnalysis.Inclusions
  19. {
  20. class InclusionEditDialog: Form
  21. {
  22. #region 属性
  23. private System.Windows.Forms.GroupBox groupBox1;
  24. private System.Windows.Forms.Button btn_close;
  25. private System.Windows.Forms.GroupBox groupBox2;
  26. private System.Windows.Forms.Label label4;
  27. private System.Windows.Forms.Label label3;
  28. private System.Windows.Forms.NumericUpDown numericUpDown2;
  29. private System.Windows.Forms.NumericUpDown numericUpDown1;
  30. private System.Windows.Forms.Label label2;
  31. private System.Windows.Forms.GroupBox groupBox_review;
  32. private System.Windows.Forms.GroupBox groupBox3;
  33. private System.Windows.Forms.Button button5;
  34. private System.Windows.Forms.Button button4;
  35. private System.Windows.Forms.Button button3;
  36. private System.Windows.Forms.Button button1;
  37. private System.Windows.Forms.Button button2;
  38. private Label label5;
  39. private Label label1;
  40. private Label label6;
  41. private TextBox textBox3;
  42. private NumericUpDown numericUpDown3;
  43. private ComboBox comboBox2;
  44. private ComboBox comboBox1;
  45. private DocumentItem documentItem;
  46. private CommonControlButtons commonControlButtons;
  47. private DocumentWorkspaceWindow documentWorkspace;
  48. private AppWorkspace appWorkspace;
  49. private AnalysisResult analysisResult;
  50. private System.Action closeCallback;
  51. private ISurfaceBox drawArea;
  52. private ComboBox comboBox3;
  53. private Label label7;
  54. private bool is_showRectangle;
  55. private bool is_showOval;
  56. private int is_full;
  57. private int isK;
  58. private List<InclusionDrawObject> selectedInclusion = new List<InclusionDrawObject>();
  59. // 选定夹杂物类型 操作 记录点
  60. private System.Drawing.Point? selectedTypesOfInclusionsPoint = null;
  61. private System.Drawing.RectangleF? selectedTypesOfInclusionsRectangle = null;
  62. private enum SelectionMode
  63. {
  64. None,
  65. NetSelection, // group selection is active
  66. Move, // object(s) are moves
  67. Size // object is resized
  68. }
  69. #endregion
  70. #region 初始化
  71. private void InitializeLanguageText()
  72. {
  73. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  74. this.btn_close.Text = PdnResources.GetString("Form.OkButton.Text");
  75. this.button2.Text = PdnResources.GetString("ConfirmLanguageDialog.CancelTB.ActionText");
  76. this.groupBox2.Text = PdnResources.GetString("Menu.Inclusionproperties.text");
  77. this.label6.Text = PdnResources.GetString("Menu.Chemicalproperties.text");
  78. this.label5.Text = PdnResources.GetString("Menu.Typeofinclusion.text");
  79. this.label1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Classificationofinclusions.text");
  80. this.label4.Text = PdnResources.GetString("Menu.area.text");
  81. this.label3.Text = PdnResources.GetString("Menu.width.text");
  82. this.label2.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text");
  83. this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
  84. this.groupBox3.Text = PdnResources.GetString("Menu.operation.text");
  85. this.button5.Text = PdnResources.GetString("Menu.polygonadd.text");
  86. this.button4.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  87. this.button3.Text = PdnResources.GetString("Menu.Split.text");
  88. this.button1.Text = PdnResources.GetString("Menu.combination.text");
  89. this.label7.Text = PdnResources.GetString("Menu.color.text");
  90. this.Text = PdnResources.GetString("Menu.Inclusionsedit.text");
  91. }
  92. private void InitializeComponent()
  93. {
  94. this.groupBox1 = new System.Windows.Forms.GroupBox();
  95. this.btn_close = new System.Windows.Forms.Button();
  96. this.button2 = new System.Windows.Forms.Button();
  97. this.groupBox2 = new System.Windows.Forms.GroupBox();
  98. this.comboBox3 = new System.Windows.Forms.ComboBox();
  99. this.label7 = new System.Windows.Forms.Label();
  100. this.comboBox2 = new System.Windows.Forms.ComboBox();
  101. this.comboBox1 = new System.Windows.Forms.ComboBox();
  102. this.textBox3 = new System.Windows.Forms.TextBox();
  103. this.label6 = new System.Windows.Forms.Label();
  104. this.label5 = new System.Windows.Forms.Label();
  105. this.label1 = new System.Windows.Forms.Label();
  106. this.label4 = new System.Windows.Forms.Label();
  107. this.label3 = new System.Windows.Forms.Label();
  108. this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
  109. this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
  110. this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
  111. this.label2 = new System.Windows.Forms.Label();
  112. this.groupBox_review = new System.Windows.Forms.GroupBox();
  113. this.groupBox3 = new System.Windows.Forms.GroupBox();
  114. this.button5 = new System.Windows.Forms.Button();
  115. this.button4 = new System.Windows.Forms.Button();
  116. this.button3 = new System.Windows.Forms.Button();
  117. this.button1 = new System.Windows.Forms.Button();
  118. this.groupBox1.SuspendLayout();
  119. this.groupBox2.SuspendLayout();
  120. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
  121. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
  122. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
  123. this.groupBox3.SuspendLayout();
  124. this.SuspendLayout();
  125. //
  126. // groupBox1
  127. //
  128. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  129. | System.Windows.Forms.AnchorStyles.Right)));
  130. this.groupBox1.Controls.Add(this.btn_close);
  131. this.groupBox1.Controls.Add(this.button2);
  132. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  133. this.groupBox1.Name = "groupBox1";
  134. this.groupBox1.Size = new System.Drawing.Size(1145, 53);
  135. this.groupBox1.TabIndex = 12;
  136. this.groupBox1.TabStop = false;
  137. //
  138. // btn_close
  139. //
  140. this.btn_close.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  141. this.btn_close.Location = new System.Drawing.Point(972, 21);
  142. this.btn_close.Name = "btn_close";
  143. this.btn_close.Size = new System.Drawing.Size(75, 23);
  144. this.btn_close.TabIndex = 3;
  145. this.btn_close.UseVisualStyleBackColor = true;
  146. this.btn_close.Click += new System.EventHandler(this.btn_close_Click);
  147. //
  148. // button2
  149. //
  150. this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
  151. this.button2.Location = new System.Drawing.Point(1053, 21);
  152. this.button2.Name = "button2";
  153. this.button2.Size = new System.Drawing.Size(75, 23);
  154. this.button2.TabIndex = 2;
  155. this.button2.UseVisualStyleBackColor = true;
  156. this.button2.Click += new System.EventHandler(this.button2_Click);
  157. //
  158. // groupBox2
  159. //
  160. this.groupBox2.Controls.Add(this.comboBox3);
  161. this.groupBox2.Controls.Add(this.label7);
  162. this.groupBox2.Controls.Add(this.comboBox2);
  163. this.groupBox2.Controls.Add(this.comboBox1);
  164. this.groupBox2.Controls.Add(this.textBox3);
  165. this.groupBox2.Controls.Add(this.label6);
  166. this.groupBox2.Controls.Add(this.label5);
  167. this.groupBox2.Controls.Add(this.label1);
  168. this.groupBox2.Controls.Add(this.label4);
  169. this.groupBox2.Controls.Add(this.label3);
  170. this.groupBox2.Controls.Add(this.numericUpDown2);
  171. this.groupBox2.Controls.Add(this.numericUpDown3);
  172. this.groupBox2.Controls.Add(this.numericUpDown1);
  173. this.groupBox2.Controls.Add(this.label2);
  174. this.groupBox2.Location = new System.Drawing.Point(12, 71);
  175. this.groupBox2.Name = "groupBox2";
  176. this.groupBox2.Size = new System.Drawing.Size(224, 408);
  177. this.groupBox2.TabIndex = 18;
  178. this.groupBox2.TabStop = false;
  179. //
  180. // comboBox3
  181. //
  182. this.comboBox3.FormattingEnabled = true;
  183. this.comboBox3.Location = new System.Drawing.Point(100, 135);
  184. this.comboBox3.Name = "comboBox3";
  185. this.comboBox3.Size = new System.Drawing.Size(111, 20);
  186. this.comboBox3.TabIndex = 13;
  187. //
  188. // label7
  189. //
  190. this.label7.AutoSize = true;
  191. this.label7.Location = new System.Drawing.Point(12, 139);
  192. this.label7.Name = "label7";
  193. this.label7.Size = new System.Drawing.Size(0, 12);
  194. this.label7.TabIndex = 12;
  195. //
  196. // comboBox2
  197. //
  198. this.comboBox2.FormattingEnabled = true;
  199. this.comboBox2.Location = new System.Drawing.Point(100, 161);
  200. this.comboBox2.Name = "comboBox2";
  201. this.comboBox2.Size = new System.Drawing.Size(111, 20);
  202. this.comboBox2.TabIndex = 11;
  203. //
  204. // comboBox1
  205. //
  206. this.comboBox1.FormattingEnabled = true;
  207. this.comboBox1.Items.AddRange(new object[] {
  208. "α",
  209. "β",
  210. "γ",
  211. "δ"});
  212. this.comboBox1.Location = new System.Drawing.Point(100, 187);
  213. this.comboBox1.Name = "comboBox1";
  214. this.comboBox1.Size = new System.Drawing.Size(111, 20);
  215. this.comboBox1.TabIndex = 10;
  216. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  217. //
  218. // textBox3
  219. //
  220. this.textBox3.Location = new System.Drawing.Point(100, 244);
  221. this.textBox3.Name = "textBox3";
  222. this.textBox3.Size = new System.Drawing.Size(111, 21);
  223. this.textBox3.TabIndex = 9;
  224. this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
  225. //
  226. // label6
  227. //
  228. this.label6.AutoSize = true;
  229. this.label6.Location = new System.Drawing.Point(12, 247);
  230. this.label6.Name = "label6";
  231. this.label6.Size = new System.Drawing.Size(0, 12);
  232. this.label6.TabIndex = 7;
  233. //
  234. // label5
  235. //
  236. this.label5.AutoSize = true;
  237. this.label5.Location = new System.Drawing.Point(12, 164);
  238. this.label5.Name = "label5";
  239. this.label5.Size = new System.Drawing.Size(0, 12);
  240. this.label5.TabIndex = 7;
  241. //
  242. // label1
  243. //
  244. this.label1.AutoSize = true;
  245. this.label1.Location = new System.Drawing.Point(12, 190);
  246. this.label1.Name = "label1";
  247. this.label1.Size = new System.Drawing.Size(0, 12);
  248. this.label1.TabIndex = 7;
  249. //
  250. // label4
  251. //
  252. this.label4.AutoSize = true;
  253. this.label4.Location = new System.Drawing.Point(12, 79);
  254. this.label4.Name = "label4";
  255. this.label4.Size = new System.Drawing.Size(0, 12);
  256. this.label4.TabIndex = 7;
  257. //
  258. // label3
  259. //
  260. this.label3.AutoSize = true;
  261. this.label3.Location = new System.Drawing.Point(12, 52);
  262. this.label3.Name = "label3";
  263. this.label3.Size = new System.Drawing.Size(0, 12);
  264. this.label3.TabIndex = 8;
  265. //
  266. // numericUpDown2
  267. //
  268. this.numericUpDown2.DecimalPlaces = 10;
  269. this.numericUpDown2.Location = new System.Drawing.Point(100, 50);
  270. this.numericUpDown2.Maximum = new decimal(new int[] {
  271. 1241513983,
  272. 370409800,
  273. 542101,
  274. 0});
  275. this.numericUpDown2.Name = "numericUpDown2";
  276. this.numericUpDown2.ReadOnly = true;
  277. this.numericUpDown2.Size = new System.Drawing.Size(111, 21);
  278. this.numericUpDown2.TabIndex = 5;
  279. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  280. //
  281. // numericUpDown3
  282. //
  283. this.numericUpDown3.DecimalPlaces = 10;
  284. this.numericUpDown3.Location = new System.Drawing.Point(100, 77);
  285. this.numericUpDown3.Maximum = new decimal(new int[] {
  286. 1241513983,
  287. 370409800,
  288. 542101,
  289. 0});
  290. this.numericUpDown3.Name = "numericUpDown3";
  291. this.numericUpDown3.ReadOnly = true;
  292. this.numericUpDown3.Size = new System.Drawing.Size(111, 21);
  293. this.numericUpDown3.TabIndex = 6;
  294. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  295. //
  296. // numericUpDown1
  297. //
  298. this.numericUpDown1.DecimalPlaces = 10;
  299. this.numericUpDown1.Location = new System.Drawing.Point(100, 24);
  300. this.numericUpDown1.Maximum = new decimal(new int[] {
  301. 1241513983,
  302. 370409800,
  303. 542101,
  304. 0});
  305. this.numericUpDown1.Name = "numericUpDown1";
  306. this.numericUpDown1.ReadOnly = true;
  307. this.numericUpDown1.Size = new System.Drawing.Size(111, 21);
  308. this.numericUpDown1.TabIndex = 6;
  309. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  310. //
  311. // label2
  312. //
  313. this.label2.AutoSize = true;
  314. this.label2.Location = new System.Drawing.Point(12, 26);
  315. this.label2.Name = "label2";
  316. this.label2.Size = new System.Drawing.Size(0, 12);
  317. this.label2.TabIndex = 4;
  318. //
  319. // groupBox_review
  320. //
  321. this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  322. | System.Windows.Forms.AnchorStyles.Left)
  323. | System.Windows.Forms.AnchorStyles.Right)));
  324. this.groupBox_review.Location = new System.Drawing.Point(242, 71);
  325. this.groupBox_review.Name = "groupBox_review";
  326. this.groupBox_review.Size = new System.Drawing.Size(915, 661);
  327. this.groupBox_review.TabIndex = 19;
  328. this.groupBox_review.TabStop = false;
  329. //
  330. // groupBox3
  331. //
  332. this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  333. | System.Windows.Forms.AnchorStyles.Left)));
  334. this.groupBox3.Controls.Add(this.button5);
  335. this.groupBox3.Controls.Add(this.button4);
  336. this.groupBox3.Controls.Add(this.button3);
  337. this.groupBox3.Controls.Add(this.button1);
  338. this.groupBox3.Location = new System.Drawing.Point(12, 485);
  339. this.groupBox3.Name = "groupBox3";
  340. this.groupBox3.Size = new System.Drawing.Size(224, 247);
  341. this.groupBox3.TabIndex = 20;
  342. this.groupBox3.TabStop = false;
  343. //
  344. // button5
  345. //
  346. this.button5.Location = new System.Drawing.Point(95, 49);
  347. this.button5.Name = "button5";
  348. this.button5.Size = new System.Drawing.Size(75, 23);
  349. this.button5.TabIndex = 0;
  350. this.button5.UseVisualStyleBackColor = true;
  351. this.button5.Click += new System.EventHandler(this.button5_Click);
  352. //
  353. // button4
  354. //
  355. this.button4.Location = new System.Drawing.Point(14, 49);
  356. this.button4.Name = "button4";
  357. this.button4.Size = new System.Drawing.Size(75, 23);
  358. this.button4.TabIndex = 0;
  359. this.button4.UseVisualStyleBackColor = true;
  360. this.button4.Click += new System.EventHandler(this.button4_Click);
  361. //
  362. // button3
  363. //
  364. this.button3.Location = new System.Drawing.Point(95, 20);
  365. this.button3.Name = "button3";
  366. this.button3.Size = new System.Drawing.Size(75, 23);
  367. this.button3.TabIndex = 0;
  368. this.button3.UseVisualStyleBackColor = true;
  369. this.button3.Click += new System.EventHandler(this.button3_Click);
  370. //
  371. // button1
  372. //
  373. this.button1.Location = new System.Drawing.Point(14, 20);
  374. this.button1.Name = "button1";
  375. this.button1.Size = new System.Drawing.Size(75, 23);
  376. this.button1.TabIndex = 0;
  377. this.button1.UseVisualStyleBackColor = true;
  378. this.button1.Click += new System.EventHandler(this.button1_Click);
  379. //
  380. // InclusionEditDialog
  381. //
  382. this.ClientSize = new System.Drawing.Size(1177, 744);
  383. this.Controls.Add(this.groupBox3);
  384. this.Controls.Add(this.groupBox_review);
  385. this.Controls.Add(this.groupBox2);
  386. this.Controls.Add(this.groupBox1);
  387. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  388. this.Name = "InclusionEditDialog";
  389. this.groupBox1.ResumeLayout(false);
  390. this.groupBox2.ResumeLayout(false);
  391. this.groupBox2.PerformLayout();
  392. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
  393. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
  394. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
  395. this.groupBox3.ResumeLayout(false);
  396. this.ResumeLayout(false);
  397. }
  398. public void Initialize(AnalysisResult tempAnalysisResult)
  399. {
  400. this.FormClosed += new FormClosedEventHandler(formClosed);
  401. InclusionsGlobalSettings inclusionsGlobalSettings = MethodOfAssessment.activeMethod.inclusionsStandard.globalSettings;
  402. this.comboBox2.Items.AddRange(inclusionsGlobalSettings.typeDics.Keys.ToArray());
  403. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  404. this.comboBox3.Items.AddRange(inclusionsGlobalSettings.colorOfInclusions.Keys.ToArray());
  405. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  406. //
  407. //初始化图像控件
  408. //
  409. this.documentWorkspace = new DocumentWorkspaceWindow(this.appWorkspace);
  410. this.documentWorkspace.Cursor = Cursors.Default;
  411. this.documentWorkspace.Dock = DockStyle.Fill;
  412. this.documentWorkspace.HookMouseEvents();
  413. this.documentWorkspace.AuxiliaryLineEnabled = false;
  414. this.documentWorkspace.Visible = false;
  415. this.groupBox_review.Controls.Add(documentWorkspace);
  416. this.documentWorkspace.Visible = true;
  417. this.documentWorkspace.ActiveTool = DrawToolType.InclusionSelect;
  418. this.documentWorkspace.Document = Document.FromImageMat(this.documentItem.imageMat.Clone());
  419. this.documentWorkspace.GraphicsList = this.documentItem.graphicsList;
  420. this.documentWorkspace.PhaseModels = new List<PhaseModel>();
  421. this.documentWorkspace.PhaseModels.AddRange(this.documentItem.phaseModels);
  422. this.drawArea = this.documentWorkspace;
  423. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  424. this.documentWorkspace.panel.MouseUp += OnMouseUp;
  425. this.documentWorkspace.panel.MouseMove += OnMouseMove;
  426. //
  427. //初始化操作按钮
  428. //
  429. this.commonControlButtons = new CommonControlButtons();
  430. this.commonControlButtons.Dock = DockStyle.Top;
  431. this.commonControlButtons.Height = 30;
  432. this.commonControlButtons.HideZoomToWindowAndActualSize();
  433. this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
  434. this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
  435. this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
  436. this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
  437. this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
  438. this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
  439. groupBox_review.Controls.Add(this.commonControlButtons);
  440. foreach (var item in tempAnalysisResult.inclusions)
  441. {
  442. this.documentWorkspace.GraphicsList.Add(new InclusionDrawObject(this.documentWorkspace, item));
  443. }
  444. ToolInclusionSelect.CleanAndDrawInclusionAll(this.documentWorkspace, tempAnalysisResult.inclusions,true,is_showOval, is_full);
  445. }
  446. #endregion
  447. #region 构造函数
  448. public InclusionEditDialog(string Text, AppWorkspace appWorkspace, DocumentItem documentItem , AnalysisResult analysisResult, System.Action closeCallback, bool is_showRectangle, bool is_showOval,int is_full,int isK)
  449. {
  450. this.appWorkspace = appWorkspace;
  451. this.documentItem = documentItem;
  452. this.analysisResult = analysisResult;
  453. this.closeCallback = closeCallback;
  454. this.isK = isK;
  455. this.is_showOval = is_showOval;
  456. this.is_showRectangle = is_showRectangle;
  457. this.is_full = is_full;
  458. InitializeComponent();
  459. InitializeLanguageText();
  460. Initialize(analysisResult);
  461. string[] titleList = Text.Split('_');
  462. if (titleList.Count() > 0 && titleList[0] == "EN10247")
  463. {
  464. this.label1.Visible = true;
  465. this.comboBox1.Visible = true;
  466. }
  467. else
  468. {
  469. this.label1.Visible = false;
  470. this.comboBox1.Visible = false;
  471. }
  472. MethodOfAssessment.activeMethod.is_full = is_full;
  473. }
  474. #endregion
  475. #region 事件
  476. #region 公共按钮
  477. private void zoomInButton_Click(object sender, EventArgs e)
  478. {
  479. this.documentWorkspace.ZoomIn();
  480. }
  481. private void zoomOutButton_Click(object sender, EventArgs e)
  482. {
  483. this.documentWorkspace.ZoomOut();
  484. }
  485. private void zoomToWindowButton_Click(object sender, EventArgs e)
  486. {
  487. this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
  488. }
  489. private void actualSizeButton_Click(object sender, EventArgs e)
  490. {
  491. this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
  492. this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
  493. }
  494. private void pointerButton_Click(object sender, EventArgs e)
  495. {
  496. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.InclusionSelect;
  497. }
  498. private void mobileModeButton_Click(object sender, EventArgs e)
  499. {
  500. this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
  501. }
  502. #endregion
  503. #region [滑动选中]
  504. /// <summary>
  505. /// Left mouse button is pressed
  506. /// </summary>
  507. /// <param name="drawArea"></param>
  508. /// <param name="e"></param>
  509. private void OnMouseDown(object sender, MouseEventArgs e)
  510. {
  511. if (e.Button == MouseButtons.Left)
  512. {
  513. this.selectedTypesOfInclusionsPoint = e.Location;
  514. }
  515. }
  516. /// <summary>
  517. /// Mouse is moved.
  518. /// None button is pressed, or left button is pressed.
  519. /// </summary>
  520. /// <param name="drawArea"></param>
  521. /// <param name="e"></param>
  522. private void OnMouseMove(object sender, MouseEventArgs e)
  523. {
  524. Pen pen = new Pen(Color.Black,3);
  525. if (this.selectedTypesOfInclusionsPoint == null)
  526. {
  527. return;
  528. }
  529. this.documentWorkspace.Refresh();
  530. float x = Math.Min(this.selectedTypesOfInclusionsPoint.Value.X, e.Location.X);
  531. float y = Math.Min(this.selectedTypesOfInclusionsPoint.Value.Y, e.Location.Y);
  532. float width = Math.Abs(this.selectedTypesOfInclusionsPoint.Value.X - e.Location.X);
  533. float height = Math.Abs(this.selectedTypesOfInclusionsPoint.Value.Y - e.Location.Y);
  534. this.documentWorkspace.panel.CreateGraphics().DrawRectangles(pen, new RectangleF[] { new RectangleF(x, y, width, height) });
  535. }
  536. /// <summary>
  537. /// Right mouse button is released
  538. /// </summary>
  539. /// <param name="drawArea"></param>
  540. /// <param name="e"></param>
  541. private void OnMouseUp(object sender, MouseEventArgs e)
  542. {
  543. if (e.Button == MouseButtons.Left)
  544. {
  545. this.selectedInclusion.Clear();
  546. if (this.selectedTypesOfInclusionsPoint == null) {
  547. return;
  548. }
  549. var startPoint = this.documentWorkspace.GetScalePoint(this.selectedTypesOfInclusionsPoint.Value);
  550. var lastPoint = this.documentWorkspace.GetScalePoint(e.Location);
  551. RectangleF rectangle = new RectangleF(Math.Min(lastPoint.X , startPoint.X), Math.Min(lastPoint.Y, startPoint.Y), Math.Abs(lastPoint.X - startPoint.X), Math.Abs(lastPoint.Y - startPoint.Y));
  552. for (int i = 0; i < drawArea.GraphicsList.Count; i++)
  553. {
  554. if (!(drawArea.GraphicsList[i] is InclusionDrawObject))
  555. {
  556. continue;
  557. }
  558. InclusionDrawObject drawObject = (InclusionDrawObject)drawArea.GraphicsList[i];
  559. if (rectangle.Contains(drawObject.inclusion.rectProfile) || rectangle.IntersectsWith(drawObject.inclusion.rectProfile))
  560. {
  561. drawObject.drawToolType = DrawToolType.InclusionSelect;
  562. drawObject.Selected = true;
  563. this.selectedInclusion.Add(drawObject);
  564. }
  565. }
  566. // 先清除事件 操作完再加回来
  567. this.numericUpDown1.ValueChanged -= new System.EventHandler(this.numericUpDown1_ValueChanged);
  568. this.numericUpDown2.ValueChanged -= new System.EventHandler(this.numericUpDown2_ValueChanged);
  569. this.numericUpDown3.ValueChanged -= new System.EventHandler(this.numericUpDown3_ValueChanged);
  570. this.comboBox1.SelectedIndexChanged -= new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  571. this.comboBox2.SelectedIndexChanged -= new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  572. this.comboBox3.SelectedIndexChanged -= new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  573. this.textBox3.TextChanged -= new System.EventHandler(this.textBox3_TextChanged);
  574. if (selectedInclusion.Count == 1)
  575. {
  576. if (selectedInclusion[0].inclusion.shape == ParticleShape.Globular && selectedInclusion[0].inclusion.arrangement == InclusionArrangement.Scattered)
  577. {
  578. this.label2.Text = PdnResources.GetString("Menu.diameter.text");
  579. this.label3.Visible = false;
  580. this.numericUpDown2.Visible = false;
  581. this.numericUpDown1.Value = new Decimal(selectedInclusion[0].inclusion.diameter);
  582. }
  583. else
  584. {
  585. this.label2.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text");
  586. this.label3.Visible = true;
  587. this.numericUpDown2.Visible = true;
  588. this.numericUpDown1.Value = new Decimal(selectedInclusion[0].inclusion.physicalLength);
  589. this.numericUpDown2.Value = new Decimal(selectedInclusion[0].inclusion.physicalWidth);
  590. }
  591. if (this.isK == 1) {
  592. this.numericUpDown3.Value = new Decimal(selectedInclusion[0].inclusion.areaK);
  593. }
  594. else {
  595. this.numericUpDown3.Value = new Decimal(selectedInclusion[0].inclusion.area);
  596. }
  597. this.comboBox1.Text = selectedInclusion[0].inclusion.classes.ToString();
  598. this.comboBox3.Text = selectedInclusion[0].inclusion.color == null ? "" : selectedInclusion[0].inclusion.color.colorName;
  599. this.comboBox2.Text = selectedInclusion[0].inclusion.type.type;
  600. this.textBox3.Text = selectedInclusion[0].inclusion.chemicalCharacteristics;
  601. this.numericUpDown1.ReadOnly = false;
  602. this.numericUpDown2.ReadOnly = false;
  603. this.numericUpDown3.ReadOnly = false;
  604. this.comboBox1.Enabled = true;
  605. this.comboBox2.Enabled = true;
  606. this.comboBox3.Enabled = true;
  607. this.textBox3.ReadOnly = false;
  608. }
  609. else
  610. {
  611. this.label2.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text");
  612. this.numericUpDown2.Visible = true;
  613. this.label3.Visible = true;
  614. this.numericUpDown1.ReadOnly = true;
  615. this.numericUpDown2.ReadOnly = true;
  616. this.numericUpDown3.ReadOnly = true;
  617. this.comboBox1.Enabled = false;
  618. this.comboBox2.Enabled = false;
  619. this.comboBox3.Enabled = false;
  620. this.textBox3.ReadOnly = true;
  621. this.numericUpDown1.Value = 0;
  622. this.numericUpDown2.Value = 0;
  623. this.numericUpDown3.Value = 0;
  624. this.comboBox1.Text = "";
  625. this.comboBox2.Text = "";
  626. this.textBox3.Text = "";
  627. }
  628. this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
  629. this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
  630. this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
  631. this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
  632. this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
  633. this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged);
  634. this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
  635. this.selectedTypesOfInclusionsPoint = null;
  636. this.selectedTypesOfInclusionsRectangle = null;
  637. }
  638. this.documentWorkspace.Refresh();
  639. }
  640. #endregion
  641. private void button1_Click(object sender, EventArgs e)
  642. {
  643. var surface = this.documentWorkspace;
  644. List<Inclusion> selectedInclusions = new List<Inclusion>();
  645. List<Inclusion> allInclusions = new List<Inclusion>();
  646. InclusionsStandard standard = MethodOfAssessment.activeMethod.inclusionsStandard;
  647. for (int i = surface.GraphicsList.Count - 1; i >= 0; i--)
  648. {
  649. DrawObject drawObject = surface.GraphicsList[i];
  650. if (drawObject.drawToolType == DrawToolType.InclusionSelect)
  651. {
  652. surface.GraphicsList.RemoveObj(drawObject);
  653. InclusionDrawObject inclusionDraw = (InclusionDrawObject)drawObject;
  654. allInclusions.Add(inclusionDraw.inclusion);
  655. if (drawObject.Selected)
  656. {
  657. selectedInclusions.Add(inclusionDraw.inclusion);
  658. }
  659. }
  660. }
  661. if (selectedInclusions.Count == 0)
  662. {
  663. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectinclusionsfirst.text"));
  664. ToolInclusionSelect.DrawInclusion(surface, allInclusions,is_full);
  665. return;
  666. }
  667. standard.inclusionsCombination(allInclusions, selectedInclusions);
  668. ToolInclusionSelect.DrawInclusion(surface, allInclusions, is_full);
  669. }
  670. private void button3_Click(object sender, EventArgs e)
  671. {
  672. var surface = this.documentWorkspace;
  673. List<Inclusion> selectedInclusions = new List<Inclusion>();
  674. List<Inclusion> allInclusions = new List<Inclusion>();
  675. InclusionsStandard standard = null;
  676. for (int i = surface.GraphicsList.Count - 1; i >= 0; i--)
  677. {
  678. DrawObject drawObject = surface.GraphicsList[i];
  679. if (drawObject.drawToolType == DrawToolType.InclusionSelect)
  680. {
  681. surface.GraphicsList.RemoveObj(drawObject);
  682. InclusionDrawObject inclusionDraw = (InclusionDrawObject)drawObject;
  683. if (standard == null)
  684. {
  685. standard = inclusionDraw.inclusion.standard;
  686. }
  687. allInclusions.Add(inclusionDraw.inclusion);
  688. if (drawObject.Selected)
  689. {
  690. selectedInclusions.Add(inclusionDraw.inclusion);
  691. }
  692. }
  693. }
  694. standard.inclusionsCombinationSplit(allInclusions, selectedInclusions);
  695. surface.Refresh();
  696. ToolInclusionSelect.DrawInclusion(surface, allInclusions, is_full);
  697. }
  698. private void formClosed(object sender, EventArgs e)
  699. {
  700. this.closeCallback();
  701. }
  702. private void button2_Click(object sender, EventArgs e)
  703. {
  704. this.Close();
  705. }
  706. private void button5_Click(object sender, EventArgs e)
  707. {
  708. this.documentWorkspace.panel.MouseDown -= OnMouseDown;
  709. this.documentWorkspace.panel.MouseUp -= OnMouseUp;
  710. this.documentWorkspace.panel.MouseMove -= OnMouseMove;
  711. this.documentWorkspace.panel.MouseUp += StopWrite;
  712. this.documentWorkspace.ActiveTool = DrawToolType.InclusionPolygon;
  713. }
  714. private void StopWrite(object sender, MouseEventArgs e)
  715. {
  716. this.documentWorkspace.panel.MouseUp -= StopWrite;
  717. this.documentWorkspace.panel.MouseDown += OnMouseDown;
  718. this.documentWorkspace.panel.MouseUp += OnMouseUp;
  719. this.documentWorkspace.panel.MouseMove += OnMouseMove;
  720. this.btn_close.Focus();
  721. }
  722. private void btn_close_Click(object sender, EventArgs e)
  723. {
  724. if (this.isK != 1)
  725. {
  726. analysisResult.inclusions.Clear();
  727. for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  728. {
  729. DrawObject drawObject = this.documentWorkspace.GraphicsList[i];
  730. if (drawObject.drawToolType == DrawToolType.InclusionSelect)
  731. {
  732. analysisResult.inclusions.Add(((InclusionDrawObject)drawObject).inclusion);
  733. }
  734. }
  735. }
  736. else {
  737. for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++)
  738. {
  739. DrawObject drawObject = this.documentWorkspace.GraphicsList[i];
  740. if (drawObject.drawToolType == DrawToolType.InclusionSelect)
  741. {
  742. if (((InclusionDrawObject)drawObject).inclusion.isEdit == 1)
  743. {
  744. analysisResult.inclusions.Add(((InclusionDrawObject)drawObject).inclusion);
  745. }
  746. else {
  747. ((InclusionDrawObject)drawObject).inclusion.isEdit = 2;
  748. }
  749. }
  750. }
  751. }
  752. analysisResult.buildResultBody();
  753. this.Close();
  754. }
  755. private void numericUpDown1_ValueChanged(object sender, EventArgs e)
  756. {
  757. if (selectedInclusion.Count != 1)
  758. {
  759. return;
  760. }
  761. if (selectedInclusion[0].inclusion.shape == ParticleShape.Globular && selectedInclusion[0].inclusion.arrangement == InclusionArrangement.Scattered)
  762. {
  763. selectedInclusion[0].inclusion.physicalLength = Decimal.ToDouble(this.numericUpDown1.Value);
  764. }
  765. else
  766. {
  767. selectedInclusion[0].inclusion.diameter = Decimal.ToDouble(this.numericUpDown1.Value);
  768. }
  769. }
  770. private void numericUpDown2_ValueChanged(object sender, EventArgs e)
  771. {
  772. if (selectedInclusion.Count != 1)
  773. {
  774. return;
  775. }
  776. selectedInclusion[0].inclusion.physicalWidth = Decimal.ToDouble(this.numericUpDown2.Value);
  777. }
  778. private void numericUpDown3_ValueChanged(object sender, EventArgs e)
  779. {
  780. if (selectedInclusion.Count != 1)
  781. {
  782. return;
  783. }
  784. selectedInclusion[0].inclusion.area = Decimal.ToDouble(this.numericUpDown3.Value);
  785. }
  786. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  787. {
  788. if (selectedInclusion.Count != 1)
  789. {
  790. return;
  791. }
  792. selectedInclusion[0].inclusion.classes = (ClassesOfInclusions)Enum.Parse(typeof(ClassesOfInclusions), this.comboBox1.Text);
  793. }
  794. private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
  795. {
  796. if (selectedInclusion.Count != 1)
  797. {
  798. return;
  799. }
  800. InclusionsGlobalSettings inclusionsGlobalSettings = MethodOfAssessment.activeMethod.inclusionsStandard.globalSettings;
  801. selectedInclusion[0].inclusion.type = inclusionsGlobalSettings.typeDics[this.comboBox2.Text];
  802. this.documentWorkspace.Refresh();
  803. }
  804. private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
  805. {
  806. if (selectedInclusion.Count != 1)
  807. {
  808. return;
  809. }
  810. InclusionsGlobalSettings inclusionsGlobalSettings = MethodOfAssessment.activeMethod.inclusionsStandard.globalSettings;
  811. selectedInclusion[0].inclusion.color = inclusionsGlobalSettings.colorOfInclusions[this.comboBox3.Text];
  812. this.documentWorkspace.Refresh();
  813. }
  814. private void textBox3_TextChanged(object sender, EventArgs e)
  815. {
  816. if (selectedInclusion.Count != 1)
  817. {
  818. return;
  819. }
  820. selectedInclusion[0].inclusion.chemicalCharacteristics = this.textBox3.Text;
  821. this.documentWorkspace.Refresh();
  822. }
  823. private void button4_Click(object sender, EventArgs e)
  824. {
  825. if (selectedInclusion.Count == 0) {
  826. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectinclusions.text"));
  827. return;
  828. }
  829. if (MessageBox.Show(PdnResources.GetString("Menu.Areyousuretodeletetheinclusions?.text")+"?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
  830. {
  831. foreach (var item in selectedInclusion)
  832. {
  833. this.analysisResult.inclusions.Remove(item.inclusion);
  834. this.documentWorkspace.GraphicsList.RemoveObj(item);
  835. }
  836. selectedInclusion.Clear();
  837. this.documentWorkspace.Refresh();
  838. }
  839. }
  840. #endregion
  841. #region 私有方法
  842. #endregion
  843. }
  844. }