DebrisSelectionValidConditionDialog.cs 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  1. using PaintDotNet.Base.CommTool;
  2. using PaintDotNet.Base.Enum;
  3. using PaintDotNet.Base.Functionodel;
  4. using PaintDotNet.CustomControl;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.IO;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. namespace PaintDotNet.GeneralAnalysis
  16. {
  17. /// <summary>
  18. /// 颗粒统计-条件设置
  19. /// </summary>
  20. internal class DebrisSelectionValidConditionDialog : PdnBaseForm
  21. {
  22. private GroupBox groupBox1;
  23. private Button button4;
  24. private Button button3;
  25. private Button button2;
  26. private GroupBox groupBox2;
  27. private Button button5;
  28. private Button button6;
  29. private Button button7;
  30. private Button button8;
  31. private GroupBox groupBox3;
  32. private Button button1;
  33. private ListView listView1;
  34. private GroupBox groupBox4;
  35. private PictureBox pictureBox1;
  36. private RichTextBox richTextBox1;
  37. private ListView listView2;
  38. private DataGridView dataGridView1;
  39. /// <summary>
  40. /// 父级窗体
  41. /// </summary>
  42. private DebrisSelectionDialog debrisSelectionDialog;
  43. /// <summary>
  44. /// xml对象
  45. /// </summary>
  46. private DebrisSelectionModel debrisSelectionModel;
  47. public DebrisSelectionValidConditionDialog(DebrisSelectionDialog debrisSelectionDialog)
  48. {
  49. this.debrisSelectionDialog = debrisSelectionDialog;
  50. this.debrisSelectionModel = debrisSelectionDialog.debrisSelectionModel;
  51. InitializeComponent();
  52. InitializeLanguageText();
  53. InitOtherTools();
  54. InitSavedCondition();
  55. }
  56. private void InitializeLanguageText()
  57. {
  58. this.button8.Text = PdnResources.GetString("Menu.LabelAction.MoveDownAction.Text");
  59. this.groupBox3.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Conditionselection.text");
  60. this.groupBox4.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Descriptionofstatisticaldata.text");
  61. this.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Conditionsetting.text");
  62. this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
  63. this.button4.Text = PdnResources.GetString("Menu.File.Save.Text");
  64. this.button3.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
  65. this.button2.Text = PdnResources.GetString("Menu.Rename.text");
  66. this.button1.Text = PdnResources.GetString("Menu.New.text");
  67. this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Aconditionalrecordhasbeenadded.text");
  68. this.button5.Text = "< " + PdnResources.GetString("Menu.Addto.text");
  69. this.button6.Text = PdnResources.GetString("Menu.Moveout.text") + " >";
  70. this.button7.Text = PdnResources.GetString("Menu.LabelAction.MoveUpAction.Text");
  71. }
  72. private void InitializeComponent()
  73. {
  74. this.groupBox1 = new System.Windows.Forms.GroupBox();
  75. this.button4 = new System.Windows.Forms.Button();
  76. this.button3 = new System.Windows.Forms.Button();
  77. this.button2 = new System.Windows.Forms.Button();
  78. this.button1 = new System.Windows.Forms.Button();
  79. this.groupBox2 = new System.Windows.Forms.GroupBox();
  80. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  81. this.listView2 = new System.Windows.Forms.ListView();
  82. this.button5 = new System.Windows.Forms.Button();
  83. this.button6 = new System.Windows.Forms.Button();
  84. this.button7 = new System.Windows.Forms.Button();
  85. this.button8 = new System.Windows.Forms.Button();
  86. this.groupBox3 = new System.Windows.Forms.GroupBox();
  87. this.groupBox4 = new System.Windows.Forms.GroupBox();
  88. this.richTextBox1 = new System.Windows.Forms.RichTextBox();
  89. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  90. this.listView1 = new System.Windows.Forms.ListView();
  91. this.groupBox1.SuspendLayout();
  92. this.groupBox2.SuspendLayout();
  93. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  94. this.groupBox3.SuspendLayout();
  95. this.groupBox4.SuspendLayout();
  96. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  97. this.SuspendLayout();
  98. //
  99. // groupBox1
  100. //
  101. this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  102. | System.Windows.Forms.AnchorStyles.Right)));
  103. this.groupBox1.Controls.Add(this.button4);
  104. this.groupBox1.Controls.Add(this.button3);
  105. this.groupBox1.Controls.Add(this.button2);
  106. this.groupBox1.Controls.Add(this.button1);
  107. this.groupBox1.Location = new System.Drawing.Point(13, 13);
  108. this.groupBox1.Name = "groupBox1";
  109. this.groupBox1.Size = new System.Drawing.Size(705, 54);
  110. this.groupBox1.TabIndex = 0;
  111. this.groupBox1.TabStop = false;
  112. this.groupBox1.Text = "操作";
  113. //
  114. // button4
  115. //
  116. this.button4.Location = new System.Drawing.Point(618, 20);
  117. this.button4.Name = "button4";
  118. this.button4.Size = new System.Drawing.Size(75, 23);
  119. this.button4.TabIndex = 3;
  120. this.button4.Text = "保存";
  121. this.button4.UseVisualStyleBackColor = true;
  122. this.button4.Click += new System.EventHandler(this.button4_Click);
  123. //
  124. // button3
  125. //
  126. this.button3.Location = new System.Drawing.Point(538, 20);
  127. this.button3.Name = "button3";
  128. this.button3.Size = new System.Drawing.Size(75, 23);
  129. this.button3.TabIndex = 2;
  130. this.button3.Text = "删除";
  131. this.button3.UseVisualStyleBackColor = true;
  132. this.button3.Click += new System.EventHandler(this.button3_Click);
  133. //
  134. // button2
  135. //
  136. this.button2.Location = new System.Drawing.Point(457, 20);
  137. this.button2.Name = "button2";
  138. this.button2.Size = new System.Drawing.Size(75, 23);
  139. this.button2.TabIndex = 1;
  140. this.button2.Text = "重命名";
  141. this.button2.UseVisualStyleBackColor = true;
  142. this.button2.Click += new System.EventHandler(this.button2_Click);
  143. //
  144. // button1
  145. //
  146. this.button1.Location = new System.Drawing.Point(376, 20);
  147. this.button1.Name = "button1";
  148. this.button1.Size = new System.Drawing.Size(75, 23);
  149. this.button1.TabIndex = 0;
  150. this.button1.Text = "新建";
  151. this.button1.UseVisualStyleBackColor = true;
  152. this.button1.Click += new System.EventHandler(this.button1_Click);
  153. //
  154. // groupBox2
  155. //
  156. this.groupBox2.Controls.Add(this.dataGridView1);
  157. this.groupBox2.Controls.Add(this.listView2);
  158. this.groupBox2.Location = new System.Drawing.Point(13, 74);
  159. this.groupBox2.Name = "groupBox2";
  160. this.groupBox2.Size = new System.Drawing.Size(407, 411);
  161. this.groupBox2.TabIndex = 1;
  162. this.groupBox2.TabStop = false;
  163. this.groupBox2.Text = "已添加条件设置记录";
  164. //
  165. // dataGridView1
  166. //
  167. this.dataGridView1.AllowUserToAddRows = false;
  168. this.dataGridView1.AllowUserToDeleteRows = false;
  169. this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  170. | System.Windows.Forms.AnchorStyles.Left)
  171. | System.Windows.Forms.AnchorStyles.Right)));
  172. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  173. this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
  174. this.dataGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
  175. this.dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
  176. this.dataGridView1.Location = new System.Drawing.Point(135, 21);
  177. this.dataGridView1.MultiSelect = false;
  178. this.dataGridView1.Name = "dataGridView1";
  179. this.dataGridView1.RowHeadersVisible = false;
  180. this.dataGridView1.RowTemplate.Height = 23;
  181. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  182. this.dataGridView1.Size = new System.Drawing.Size(266, 367);
  183. this.dataGridView1.TabIndex = 1;
  184. this.dataGridView1.CurrentCellDirtyStateChanged += new System.EventHandler(this.dataGridView1_CurrentCellDirtyStateChanged);
  185. //
  186. // listView2
  187. //
  188. this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
  189. | System.Windows.Forms.AnchorStyles.Left)));
  190. this.listView2.FullRowSelect = true;
  191. this.listView2.HideSelection = false;
  192. this.listView2.Location = new System.Drawing.Point(7, 21);
  193. this.listView2.MultiSelect = false;
  194. this.listView2.Name = "listView2";
  195. this.listView2.Size = new System.Drawing.Size(121, 367);
  196. this.listView2.TabIndex = 0;
  197. this.listView2.UseCompatibleStateImageBehavior = false;
  198. this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged);
  199. //
  200. // button5
  201. //
  202. this.button5.Location = new System.Drawing.Point(426, 173);
  203. this.button5.Name = "button5";
  204. this.button5.Size = new System.Drawing.Size(75, 23);
  205. this.button5.TabIndex = 2;
  206. this.button5.Text = "添加";
  207. this.button5.UseVisualStyleBackColor = true;
  208. this.button5.Click += new System.EventHandler(this.button5_Click);
  209. //
  210. // button6
  211. //
  212. this.button6.Location = new System.Drawing.Point(426, 202);
  213. this.button6.Name = "button6";
  214. this.button6.Size = new System.Drawing.Size(75, 23);
  215. this.button6.TabIndex = 3;
  216. this.button6.Text = "移出";
  217. this.button6.UseVisualStyleBackColor = true;
  218. this.button6.Click += new System.EventHandler(this.button6_Click);
  219. //
  220. // button7
  221. //
  222. this.button7.Location = new System.Drawing.Point(426, 353);
  223. this.button7.Name = "button7";
  224. this.button7.Size = new System.Drawing.Size(75, 23);
  225. this.button7.TabIndex = 4;
  226. this.button7.Text = "向上移动";
  227. this.button7.UseVisualStyleBackColor = true;
  228. this.button7.Click += new System.EventHandler(this.button7_Click);
  229. //
  230. // button8
  231. //
  232. this.button8.Location = new System.Drawing.Point(426, 382);
  233. this.button8.Name = "button8";
  234. this.button8.Size = new System.Drawing.Size(75, 23);
  235. this.button8.TabIndex = 5;
  236. this.button8.Text = "向下移动";
  237. this.button8.UseVisualStyleBackColor = true;
  238. this.button8.Click += new System.EventHandler(this.button8_Click);
  239. //
  240. // groupBox3
  241. //
  242. this.groupBox3.Controls.Add(this.groupBox4);
  243. this.groupBox3.Controls.Add(this.listView1);
  244. this.groupBox3.Location = new System.Drawing.Point(507, 74);
  245. this.groupBox3.Name = "groupBox3";
  246. this.groupBox3.Size = new System.Drawing.Size(211, 411);
  247. this.groupBox3.TabIndex = 6;
  248. this.groupBox3.TabStop = false;
  249. this.groupBox3.Text = "条件选择";
  250. //
  251. // groupBox4
  252. //
  253. this.groupBox4.Controls.Add(this.richTextBox1);
  254. this.groupBox4.Controls.Add(this.pictureBox1);
  255. this.groupBox4.Location = new System.Drawing.Point(17, 279);
  256. this.groupBox4.Name = "groupBox4";
  257. this.groupBox4.Size = new System.Drawing.Size(182, 126);
  258. this.groupBox4.TabIndex = 1;
  259. this.groupBox4.TabStop = false;
  260. this.groupBox4.Visible = false;
  261. //
  262. // richTextBox1
  263. //
  264. this.richTextBox1.BackColor = System.Drawing.SystemColors.Control;
  265. this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
  266. this.richTextBox1.Location = new System.Drawing.Point(95, 29);
  267. this.richTextBox1.Name = "richTextBox1";
  268. this.richTextBox1.ReadOnly = true;
  269. this.richTextBox1.Size = new System.Drawing.Size(75, 80);
  270. this.richTextBox1.TabIndex = 1;
  271. this.richTextBox1.Text = "";
  272. //
  273. // pictureBox1
  274. //
  275. this.pictureBox1.BackColor = System.Drawing.Color.White;
  276. this.pictureBox1.Location = new System.Drawing.Point(10, 29);
  277. this.pictureBox1.Name = "pictureBox1";
  278. this.pictureBox1.Size = new System.Drawing.Size(80, 80);
  279. this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
  280. this.pictureBox1.TabIndex = 0;
  281. this.pictureBox1.TabStop = false;
  282. //
  283. // listView1
  284. //
  285. this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
  286. | System.Windows.Forms.AnchorStyles.Right)));
  287. this.listView1.FullRowSelect = true;
  288. this.listView1.HideSelection = false;
  289. this.listView1.Location = new System.Drawing.Point(27, 20);
  290. this.listView1.MultiSelect = false;
  291. this.listView1.Name = "listView1";
  292. this.listView1.Size = new System.Drawing.Size(160, 385);
  293. this.listView1.TabIndex = 0;
  294. this.listView1.UseCompatibleStateImageBehavior = false;
  295. this.listView1.SelectedIndexChanged += new System.EventHandler(this.listView1_SelectedIndexChanged);
  296. this.listView1.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDoubleClick);
  297. //
  298. // DebrisSelectionValidConditionDialog
  299. //
  300. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  301. this.ClientSize = new System.Drawing.Size(730, 497);
  302. this.Controls.Add(this.groupBox3);
  303. this.Controls.Add(this.button8);
  304. this.Controls.Add(this.button7);
  305. this.Controls.Add(this.button6);
  306. this.Controls.Add(this.button5);
  307. this.Controls.Add(this.groupBox2);
  308. this.Controls.Add(this.groupBox1);
  309. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  310. this.MaximizeBox = false;
  311. this.MinimizeBox = false;
  312. this.Name = "DebrisSelectionValidConditionDialog";
  313. this.Text = "条件设置";
  314. this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.DebrisSelectionValidConditionDialog_FormClosed);
  315. this.Controls.SetChildIndex(this.groupBox1, 0);
  316. this.Controls.SetChildIndex(this.groupBox2, 0);
  317. this.Controls.SetChildIndex(this.button5, 0);
  318. this.Controls.SetChildIndex(this.button6, 0);
  319. this.Controls.SetChildIndex(this.button7, 0);
  320. this.Controls.SetChildIndex(this.button8, 0);
  321. this.Controls.SetChildIndex(this.groupBox3, 0);
  322. this.groupBox1.ResumeLayout(false);
  323. this.groupBox2.ResumeLayout(false);
  324. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  325. this.groupBox3.ResumeLayout(false);
  326. this.groupBox4.ResumeLayout(false);
  327. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  328. this.ResumeLayout(false);
  329. }
  330. /// <summary>
  331. /// 加载其他工具
  332. /// </summary>
  333. private void InitOtherTools()
  334. {
  335. //
  336. //已添加listview
  337. //
  338. this.listView2.View = View.Details;
  339. ColumnHeader header0 = new ColumnHeader();
  340. header0.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Alistofconditionshasbeenadded.text");
  341. header0.Width = 114;
  342. this.listView2.Columns.Add(header0);
  343. this.listView2.SelectedItems.Clear();
  344. //
  345. //已添加datagridview
  346. //
  347. this.dataGridView1.ColumnHeadersHeight = 35;
  348. DataGridViewTextBoxColumn h1 = new DataGridViewTextBoxColumn();
  349. h1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  350. h1.Width = 80;
  351. DataGridViewComboBoxColumn h2 = new DataGridViewComboBoxColumn();
  352. h2.Width = 55;
  353. DataGridViewTextBoxColumn h3 = new DataGridViewTextBoxColumn();
  354. h3.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  355. h3.Width = 55;
  356. DataGridViewComboBoxColumn h4 = new DataGridViewComboBoxColumn();
  357. h4.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  358. h4.Width = 55;
  359. this.dataGridView1.Columns.Add(h1);
  360. this.dataGridView1.Columns.Add(h2);
  361. this.dataGridView1.Columns.Add(h3);
  362. this.dataGridView1.Columns.Add(h4);
  363. DataGridViewHelper helper = new DataGridViewHelper(this.dataGridView1);
  364. helper.Headers.Add(new DataGridViewHelper.TopHeader(0, 1, PdnResources.GetString("Menu.projectname.text")));
  365. helper.Headers.Add(new DataGridViewHelper.TopHeader(1, 1, PdnResources.GetString("Menu.judgementconditions.text")));
  366. helper.Headers.Add(new DataGridViewHelper.TopHeader(2, 1, PdnResources.GetString("Menu.Conditionvalue.text")));
  367. helper.Headers.Add(new DataGridViewHelper.TopHeader(3, 1, PdnResources.GetString("Menu.associatedcondition.text")));
  368. this.dataGridView1.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  369. this.dataGridView1.Columns[0].ReadOnly = true;
  370. this.dataGridView1.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//文字居中
  371. this.dataGridView1.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
  372. this.dataGridView1.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  373. this.dataGridView1.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
  374. this.dataGridView1.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  375. this.dataGridView1.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable;
  376. this.dataGridView1.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  377. this.dataGridView1.AllowUserToResizeRows = false;
  378. this.dataGridView1.AllowUserToResizeColumns = false;
  379. //
  380. //条件选择listview
  381. //
  382. this.listView1.View = View.Details;
  383. ColumnHeader header1 = new ColumnHeader();
  384. header1.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.Conditionlist.text");
  385. header1.Width = 138;
  386. this.listView1.Columns.Add(header1);
  387. foreach (KeyValuePair<Enum, Object> entry in InvariantData.debrisSelectionparameters)
  388. {
  389. ListViewItem listViewItem = new ListViewItem();
  390. listViewItem.Tag = entry.Key;
  391. listViewItem.SubItems[0].Text = entry.Value.ToString();
  392. this.listView1.Items.Add(listViewItem);
  393. }
  394. this.listView1.SelectedItems.Clear();
  395. }
  396. /// <summary>
  397. /// 加载已保存的条件
  398. /// </summary>
  399. private void InitSavedCondition()
  400. {
  401. if(this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList.Count > 0)
  402. {
  403. for(int i = 0; i < this.debrisSelectionModel.debrisSelectionList.Count; i++)
  404. {
  405. ListViewItem listViewItem = new ListViewItem();
  406. listViewItem.Name = this.debrisSelectionModel.debrisSelectionList[i].itemName;
  407. listViewItem.SubItems[0].Text = this.debrisSelectionModel.debrisSelectionList[i].itemName;
  408. this.listView2.Items.Add(listViewItem);
  409. }
  410. this.listView2.SelectedItems.Clear();
  411. }
  412. }
  413. /// <summary>
  414. /// 条件选择的切换事件
  415. /// </summary>
  416. /// <param name="sender"></param>
  417. /// <param name="e"></param>
  418. private void listView1_SelectedIndexChanged(object sender, EventArgs e)
  419. {
  420. if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count == 1)
  421. {
  422. switch ((DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), this.listView1.SelectedItems[0].Tag.ToString()))
  423. {
  424. case DebrisSelectionParameters.area:
  425. this.richTextBox1.Text = PdnResources.GetString("Menu.areaofaregionthatit.Text")+"。";
  426. this.pictureBox1.Image = PdnResources.GetImageResource("Images.CalcArea.png").Reference;
  427. break;
  428. case DebrisSelectionParameters.areaRatio:
  429. this.richTextBox1.Text = PdnResources.GetString("Menu.heratiooftheareaofanentire.Text")+"。";
  430. this.pictureBox1.Image = null;
  431. break;
  432. case DebrisSelectionParameters.perimeter:
  433. this.richTextBox1.Text = PdnResources.GetString("Menu.Theperimeterregion.Text")+"。";
  434. this.pictureBox1.Image = null;
  435. break;
  436. case DebrisSelectionParameters.longAxis:
  437. this.richTextBox1.Text = PdnResources.GetString("Menu.ongsideofthesmallestenclosingrect.Text")+"。";
  438. this.pictureBox1.Image = null;
  439. break;
  440. case DebrisSelectionParameters.shortAxis:
  441. this.richTextBox1.Text = PdnResources.GetString("Menu.rtsideofthesmallestenclosingrectangleofregion.Text")+"。";
  442. this.pictureBox1.Image = null;
  443. break;
  444. case DebrisSelectionParameters.centerX:
  445. this.richTextBox1.Text = PdnResources.GetString("Menu.atessmallestenclosingrectangleo.Text")+"。";
  446. this.pictureBox1.Image = null;
  447. break;
  448. case DebrisSelectionParameters.centerY:
  449. this.richTextBox1.Text = PdnResources.GetString("Menu.ordinateYofthecenterpointofthe.Text")+"。";
  450. this.pictureBox1.Image = null;
  451. break;
  452. case DebrisSelectionParameters.inclinationAngle:
  453. this.richTextBox1.Text = PdnResources.GetString("Menu.reafitstheAngleofthelon.Text")+"。";
  454. this.pictureBox1.Image = PdnResources.GetImageResource("Images.EllipseAngle.png").Reference;
  455. break;
  456. case DebrisSelectionParameters.objectAppearance:
  457. this.richTextBox1.Text = PdnResources.GetString("Menu.aspectratiooftheenclosingr.Text")+"。";
  458. this.pictureBox1.Image = null;
  459. break;
  460. case DebrisSelectionParameters.height:
  461. this.richTextBox1.Text = PdnResources.GetString("Menu.heightofanareaadjacenttoarec.Text")+"。";
  462. this.pictureBox1.Image = null;
  463. break;
  464. case DebrisSelectionParameters.width:
  465. this.richTextBox1.Text = PdnResources.GetString("Menu.thofarectangleurroundingaregio.Text")+"。";
  466. this.pictureBox1.Image = null;
  467. break;
  468. case DebrisSelectionParameters.aspectRatio:
  469. this.richTextBox1.Text = PdnResources.GetString("Menu.oofwidthtoheightofaregionenclosin.Text")+"。";
  470. this.pictureBox1.Image = null;
  471. break;
  472. case DebrisSelectionParameters.redDensity:
  473. this.richTextBox1.Text = PdnResources.GetString("Menu.Themaximumgrayvalueofanarear.Text")+"。";
  474. this.pictureBox1.Image = null;
  475. break;
  476. case DebrisSelectionParameters.greenDensity:
  477. this.richTextBox1.Text = PdnResources.GetString("Menu.ximumgrayvalueofanareagreenhannel.Text")+"。";
  478. this.pictureBox1.Image = null;
  479. break;
  480. case DebrisSelectionParameters.blueDensity:
  481. this.richTextBox1.Text = PdnResources.GetString("Menu.grayvalueofanareabluechannel.Text")+"。";
  482. this.pictureBox1.Image = null;
  483. break;
  484. /*case DebrisSelectionParameters.maxDensity:
  485. break;
  486. case DebrisSelectionParameters.minDensity:
  487. break;
  488. case DebrisSelectionParameters.avgDensity:
  489. break;
  490. case DebrisSelectionParameters.sumDensity:
  491. break;*/
  492. case DebrisSelectionParameters.majorAxis:
  493. this.richTextBox1.Text = PdnResources.GetString("Menu.Halfofthelongsid.Text")+"。";
  494. this.pictureBox1.Image = null;
  495. break;
  496. case DebrisSelectionParameters.minorAxis:
  497. this.richTextBox1.Text = PdnResources.GetString("Menu.shortestsideofthesmallestenclosingrectangleofa.Text")+"。";
  498. this.pictureBox1.Image = null;
  499. break;
  500. case DebrisSelectionParameters.circumcircleDiameter:
  501. this.richTextBox1.Text = PdnResources.GetString("Menu.rofthesmallestcircumscribedcircle.Text")+"。";
  502. this.pictureBox1.Image = null;
  503. break;
  504. case DebrisSelectionParameters.nodularity:
  505. this.richTextBox1.Text = PdnResources.GetString("Menu.tioftheareaofaregiontotheare.Text")+"。";
  506. this.pictureBox1.Image = null;
  507. break;
  508. case DebrisSelectionParameters.equalCircleDiameter:
  509. this.richTextBox1.Text = PdnResources.GetString("Menu.diameterofanareawhose.Text")+"。";
  510. this.pictureBox1.Image = null;
  511. break;
  512. case DebrisSelectionParameters.maxCaliperDiameter:
  513. this.richTextBox1.Text = PdnResources.GetString("Menu.maximudeterminedbasedondistancemea.Text")+"。";
  514. this.pictureBox1.Image = PdnResources.GetImageResource("Images.FeretMaximum.png").Reference;
  515. break;
  516. case DebrisSelectionParameters.minCaliperDiameter:
  517. this.richTextBox1.Text = PdnResources.GetString("Menu.umcaliperdiameterisd.Text")+"。";
  518. this.pictureBox1.Image = PdnResources.GetImageResource("Images.FeretMaximum.png").Reference;
  519. break;
  520. case DebrisSelectionParameters.avgCaliperDiameter:
  521. this.richTextBox1.Text = PdnResources.GetString("Menu.rminedbasedodistancmeasuremenandtheminimumva.Text")+"。";
  522. this.pictureBox1.Image = PdnResources.GetImageResource("Images.FeretMaximum.png").Reference;
  523. break;
  524. case DebrisSelectionParameters.maxGray:
  525. this.richTextBox1.Text = PdnResources.GetString("Menu.Themaximumgrayvalueof.Text")+"。";
  526. this.pictureBox1.Image = null;
  527. break;
  528. case DebrisSelectionParameters.minGray:
  529. this.richTextBox1.Text = PdnResources.GetString("Menu.Theminimumgrayvalueofanarea.Text")+"。";
  530. this.pictureBox1.Image = null;
  531. break;
  532. case DebrisSelectionParameters.avgGray:
  533. this.richTextBox1.Text = PdnResources.GetString("Menu.Theaveragegrayvalueofanarea.Text")+"。";
  534. this.pictureBox1.Image = null;
  535. break;
  536. case DebrisSelectionParameters.fiberLength:
  537. this.richTextBox1.Text = PdnResources.GetString("Menu.Thelengthoafibrousregion.Text")+"。";
  538. this.pictureBox1.Image = PdnResources.GetImageResource("Images.FibrelengthFormula.png").Reference;
  539. break;
  540. case DebrisSelectionParameters.fillArea:
  541. this.richTextBox1.Text = PdnResources.GetString("Menu.Thelengthoafibrousregion.Text") + "。";
  542. this.pictureBox1.Image = PdnResources.GetImageResource("Images.FibrelengthFormula.png").Reference;
  543. break;
  544. case DebrisSelectionParameters.waistDepth:
  545. this.richTextBox1.Text = PdnResources.GetString("Menu.Thelengthoafibrousregion.Text") + "。";
  546. this.pictureBox1.Image = PdnResources.GetImageResource("Images.FibrelengthFormula.png").Reference;
  547. break;
  548. case DebrisSelectionParameters.waistDepthShort:
  549. this.richTextBox1.Text = PdnResources.GetString("Menu.Thelengthoafibrousregion.Text") + "。";
  550. this.pictureBox1.Image = PdnResources.GetImageResource("Images.FibrelengthFormula.png").Reference;
  551. break;
  552. }
  553. }
  554. }
  555. /// <summary>
  556. /// 新建按钮
  557. /// </summary>
  558. /// <param name="sender"></param>
  559. /// <param name="e"></param>
  560. private void button1_Click(object sender, EventArgs e)
  561. {
  562. using (DebrisSelectionAddConditionDialog debrisSelectionAddConditionDialog = new DebrisSelectionAddConditionDialog(this, null, -1))
  563. {
  564. debrisSelectionAddConditionDialog.StartPosition = FormStartPosition.CenterScreen;
  565. debrisSelectionAddConditionDialog.ShowDialog();
  566. }
  567. }
  568. /// <summary>
  569. /// 重命名按钮
  570. /// </summary>
  571. /// <param name="sender"></param>
  572. /// <param name="e"></param>
  573. private void button2_Click(object sender, EventArgs e)
  574. {
  575. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
  576. {
  577. using (DebrisSelectionAddConditionDialog debrisSelectionAddConditionDialog = new DebrisSelectionAddConditionDialog(this,
  578. this.listView2.SelectedItems[0].Text , this.listView2.SelectedItems[0].Index))
  579. {
  580. debrisSelectionAddConditionDialog.StartPosition = FormStartPosition.CenterScreen;
  581. debrisSelectionAddConditionDialog.ShowDialog();
  582. }
  583. }
  584. else
  585. MessageBox.Show(PdnResources.GetString("Menu.Pleaseseledfirst.text"));
  586. }
  587. /// <summary>
  588. /// 删除按钮
  589. /// </summary>
  590. /// <param name="sender"></param>
  591. /// <param name="e"></param>
  592. private void button3_Click(object sender, EventArgs e)
  593. {
  594. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
  595. {
  596. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousurselecteditem.text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  597. if (dr == DialogResult.OK)
  598. {
  599. this.debrisSelectionModel.debrisSelectionList.RemoveAt(this.listView2.SelectedItems[0].Index);
  600. this.listView2.Items.Remove(this.listView2.SelectedItems[0]);
  601. this.listView2.SelectedItems.Clear();
  602. this.dataGridView1.Rows.Clear();
  603. }
  604. }
  605. else
  606. MessageBox.Show(PdnResources.GetString("Menu.Pleaseseeletefirst.text"));
  607. }
  608. /// <summary>
  609. /// 保存按钮
  610. /// </summary>
  611. /// <param name="sender"></param>
  612. /// <param name="e"></param>
  613. private void button4_Click(object sender, EventArgs e)
  614. {
  615. string debrisSelectionModelInfo = XmlSerializeHelper.XmlSerialize<DebrisSelectionModel>(this.debrisSelectionModel);
  616. if (FileOperationHelper.WriteStringToFile(debrisSelectionModelInfo, this.debrisSelectionDialog.filePath, FileMode.Create))
  617. this.Close();
  618. else
  619. MessageBox.Show(PdnResources.GetString("Menu.Savefailed.text"));
  620. }
  621. /// <summary>
  622. /// 刷新当前选中对象的条件model
  623. /// </summary>
  624. private void ResetDebrisSelectionModel()
  625. {
  626. if(this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
  627. {
  628. int rowIndex = this.listView2.SelectedItems[0].Index;//选中记录的下标
  629. //新增
  630. if(rowIndex == this.debrisSelectionModel.debrisSelectionList.Count)
  631. {
  632. DebrisSelectionModel.DebrisSelection debrisSelection = new DebrisSelectionModel.DebrisSelection();
  633. debrisSelection.itemName = this.listView2.SelectedItems[0].Text;
  634. debrisSelection.conditionList = new List<DebrisSelectionModel.Condition>();
  635. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  636. {
  637. try
  638. {
  639. DebrisSelectionModel.Condition condition = new DebrisSelectionModel.Condition();
  640. condition.conditionName = this.dataGridView1.Rows[i].Cells[0].Tag.ToString();
  641. condition.judgeCondition = Array.IndexOf(InvariantData.judgeCondition, this.dataGridView1.Rows[i].Cells[1].Value.ToString());
  642. condition.conditionNum = double.Parse(this.dataGridView1.Rows[i].Cells[2].Value.ToString());
  643. condition.joinCondition = Array.IndexOf(InvariantData.joinCondition, this.dataGridView1.Rows[i].Cells[3].Value.ToString());
  644. debrisSelection.conditionList.Add(condition);
  645. }
  646. catch (Exception ex)
  647. {
  648. continue;
  649. }
  650. }
  651. this.debrisSelectionModel.debrisSelectionList.Add(debrisSelection);
  652. }
  653. //编辑
  654. else if (rowIndex < this.debrisSelectionModel.debrisSelectionList.Count)
  655. {
  656. this.debrisSelectionModel.debrisSelectionList[rowIndex].itemName = this.listView2.SelectedItems[0].Text;
  657. this.debrisSelectionModel.debrisSelectionList[rowIndex].conditionList = new List<DebrisSelectionModel.Condition>();
  658. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  659. {
  660. try
  661. {
  662. DebrisSelectionModel.Condition condition = new DebrisSelectionModel.Condition();
  663. condition.conditionName = this.dataGridView1.Rows[i].Cells[0].Tag.ToString();
  664. condition.judgeCondition = Array.IndexOf(InvariantData.judgeCondition, ((DataGridViewComboBoxCell)(this.dataGridView1.Rows[i].Cells[1])).Value.ToString());
  665. condition.conditionNum = double.Parse(this.dataGridView1.Rows[i].Cells[2].Value.ToString());
  666. condition.joinCondition = Array.IndexOf(InvariantData.joinCondition, this.dataGridView1.Rows[i].Cells[3].Value.ToString());
  667. this.debrisSelectionModel.debrisSelectionList[rowIndex].conditionList.Add(condition);
  668. }
  669. catch (Exception ex)
  670. {
  671. continue;
  672. }
  673. }
  674. }
  675. }
  676. }
  677. /// <summary>
  678. /// 添加按钮
  679. /// </summary>
  680. /// <param name="sender"></param>
  681. /// <param name="e"></param>
  682. private void button5_Click(object sender, EventArgs e)
  683. {
  684. if(this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1 && this.listView1.SelectedItems != null &&
  685. this.listView1.SelectedItems.Count == 1)
  686. {
  687. DataGridViewRow row = new DataGridViewRow();
  688. row.Height = 25;
  689. row.Cells.Add(CreateTextBoxCell(this.listView1.SelectedItems[0].Text, this.listView1.SelectedItems[0].Tag));
  690. row.Cells.Add(CreateComboBoxCell(InvariantData.judgeCondition, ""));
  691. row.Cells.Add(CreateTextBoxCell("0", ""));
  692. row.Cells.Add(CreateComboBoxCell(InvariantData.joinCondition, ""));
  693. this.dataGridView1.Rows.Add(row);
  694. this.dataGridView1.ClearSelection();
  695. this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Selected = true;
  696. ResetDebrisSelectionModel();
  697. }
  698. }
  699. /// <summary>
  700. /// 移出按钮
  701. /// </summary>
  702. /// <param name="sender"></param>
  703. /// <param name="e"></param>
  704. private void button6_Click(object sender, EventArgs e)
  705. {
  706. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
  707. {
  708. if(this.dataGridView1.SelectedRows.Count>0)
  709. {
  710. this.dataGridView1.Rows.Remove(this.dataGridView1.SelectedRows[0]);
  711. this.dataGridView1.ClearSelection();
  712. ResetDebrisSelectionModel();
  713. }
  714. }
  715. }
  716. /// <summary>
  717. /// 向上移动
  718. /// </summary>
  719. /// <param name="sender"></param>
  720. /// <param name="e"></param>
  721. private void button7_Click(object sender, EventArgs e)
  722. {
  723. if (this.dataGridView1.Rows.Count < 1)
  724. return;
  725. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1
  726. && this.dataGridView1.SelectedRows.Count>0)
  727. {
  728. int rowIndex = this.dataGridView1.SelectedRows[0].Index;
  729. if(rowIndex > 0)
  730. {
  731. this.dataGridView1.Rows.Insert(rowIndex - 1, CopyDataGridViewRow(this.dataGridView1.SelectedRows[0]));
  732. this.dataGridView1.Rows.RemoveAt(rowIndex + 1);
  733. this.dataGridView1.ClearSelection();
  734. this.dataGridView1.Rows[rowIndex - 1].Selected = true;
  735. ResetDebrisSelectionModel();
  736. }
  737. }
  738. }
  739. /// <summary>
  740. /// 向下移动
  741. /// </summary>
  742. /// <param name="sender"></param>
  743. /// <param name="e"></param>
  744. private void button8_Click(object sender, EventArgs e)
  745. {
  746. if (this.dataGridView1.Rows.Count < 1)
  747. return;
  748. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1
  749. && this.dataGridView1.SelectedRows.Count>0)
  750. {
  751. int rowIndex = this.dataGridView1.SelectedRows[0].Index;
  752. if(rowIndex < this.dataGridView1.Rows.Count - 1)
  753. {
  754. this.dataGridView1.Rows.Insert(rowIndex + 2, CopyDataGridViewRow(this.dataGridView1.SelectedRows[0]));
  755. this.dataGridView1.Rows.RemoveAt(rowIndex);
  756. this.dataGridView1.ClearSelection();
  757. this.dataGridView1.Rows[rowIndex + 1].Selected = true;
  758. ResetDebrisSelectionModel();
  759. }
  760. }
  761. }
  762. /// <summary>
  763. /// 拷贝表格内的选中行
  764. /// </summary>
  765. /// <param name="selectedRow"></param>
  766. /// <returns></returns>
  767. private DataGridViewRow CopyDataGridViewRow(DataGridViewRow selectedRow)
  768. {
  769. DataGridViewRow row = new DataGridViewRow();
  770. row.Height = 25;
  771. DataGridViewTextBoxCell cell1 = (DataGridViewTextBoxCell)selectedRow.Cells[0];
  772. DataGridViewComboBoxCell cell2 = (DataGridViewComboBoxCell)selectedRow.Cells[1];
  773. DataGridViewTextBoxCell cell3 = (DataGridViewTextBoxCell)selectedRow.Cells[2];
  774. DataGridViewComboBoxCell cell4 = (DataGridViewComboBoxCell)selectedRow.Cells[3];
  775. row.Cells.Add(CreateTextBoxCell(cell1.Value.ToString(), cell1.Tag));
  776. row.Cells.Add(CreateComboBoxCell(InvariantData.judgeCondition, cell2.Tag));
  777. row.Cells.Add(CreateTextBoxCell(cell3.Value.ToString(), cell3.Tag));
  778. row.Cells.Add(CreateComboBoxCell(InvariantData.joinCondition, cell4.Tag));
  779. row.Cells[1].Value = cell2.Value.ToString();
  780. row.Cells[3].Value = cell4.Value.ToString();
  781. return row;
  782. }
  783. /// <summary>
  784. /// 向已经添加列表添加新项目
  785. /// </summary>
  786. /// <param name="itemName"></param>
  787. /// <param name="editStatus"></param>
  788. /// <param name="editIndex"></param>
  789. public void AddContentToListview(string itemName, bool editStatus, int editIndex)
  790. {
  791. //编辑
  792. if (editStatus)
  793. {
  794. if(editIndex > -1)
  795. {
  796. this.listView2.Items[editIndex].Name = itemName;
  797. this.listView2.Items[editIndex].Text = itemName;
  798. this.listView2.SelectedItems.Clear();
  799. this.listView2.Items[editIndex].Selected = true;
  800. this.debrisSelectionModel.debrisSelectionList[editIndex].itemName = itemName;
  801. }
  802. }
  803. //新增
  804. else
  805. {
  806. ListViewItem listViewItem = new ListViewItem();
  807. listViewItem.Name = itemName;
  808. listViewItem.SubItems[0].Text = itemName;
  809. this.listView2.Items.Add(listViewItem);
  810. this.listView2.SelectedItems.Clear();
  811. DebrisSelectionModel.DebrisSelection debrisSelection = new DebrisSelectionModel.DebrisSelection();
  812. debrisSelection.itemName = itemName;
  813. debrisSelection.conditionList = new List<DebrisSelectionModel.Condition>();
  814. this.debrisSelectionModel.debrisSelectionList.Add(debrisSelection);
  815. }
  816. }
  817. /// <summary>
  818. /// 添加内容单元格
  819. /// </summary>
  820. /// <param name="text"></param>
  821. /// <param name="tag"></param>
  822. /// <returns></returns>
  823. private DataGridViewTextBoxCell CreateTextBoxCell(string text, object tag)
  824. {
  825. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  826. textboxcell.Value = text;
  827. textboxcell.Tag = tag;
  828. return textboxcell;
  829. }
  830. /// <summary>
  831. /// 添加下拉框单元格
  832. /// </summary>
  833. /// <returns></returns>
  834. private DataGridViewComboBoxCell CreateComboBoxCell(string[] strArr, object tag)
  835. {
  836. DataGridViewComboBoxCell comboboxCell = new DataGridViewComboBoxCell();
  837. comboboxCell.DataSource = strArr;
  838. comboboxCell.Tag = tag;
  839. comboboxCell.Value = strArr[0];
  840. comboboxCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox;
  841. return comboboxCell;
  842. }
  843. /// <summary>
  844. /// 切换已添加list的选中
  845. /// </summary>
  846. /// <param name="sender"></param>
  847. /// <param name="e"></param>
  848. private void listView2_SelectedIndexChanged(object sender, EventArgs e)
  849. {
  850. this.dataGridView1.Rows.Clear();
  851. if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count == 1)
  852. {
  853. if (this.debrisSelectionModel != null && this.debrisSelectionModel.debrisSelectionList.Count > 0)
  854. {
  855. DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.listView2.SelectedItems[0].Text));
  856. if(model != null && model.conditionList.Count > 0)
  857. {
  858. for(int i = 0; i < model.conditionList.Count; i++)
  859. {
  860. DataGridViewRow row = new DataGridViewRow();
  861. row.Height = 25;
  862. DebrisSelectionParameters parameter = (DebrisSelectionParameters)Enum.Parse(typeof(DebrisSelectionParameters), model.conditionList[i].conditionName);
  863. object paraName = new object();
  864. InvariantData.debrisSelectionparameters.TryGetValue(parameter, out paraName);
  865. row.Cells.Add(CreateTextBoxCell(paraName.ToString(), model.conditionList[i].conditionName));
  866. row.Cells.Add(CreateComboBoxCell(InvariantData.judgeCondition, ""));
  867. row.Cells.Add(CreateTextBoxCell(model.conditionList[i].conditionNum.ToString(), ""));
  868. row.Cells.Add(CreateComboBoxCell(InvariantData.joinCondition, ""));
  869. row.Cells[1].Value = InvariantData.judgeCondition[model.conditionList[i].judgeCondition];
  870. row.Cells[3].Value = InvariantData.joinCondition[model.conditionList[i].joinCondition];
  871. this.dataGridView1.Rows.Add(row);
  872. }
  873. this.dataGridView1.ClearSelection();
  874. }
  875. }
  876. }
  877. }
  878. /// <summary>
  879. /// 窗体关闭
  880. /// </summary>
  881. /// <param name="sender"></param>
  882. /// <param name="e"></param>
  883. private void DebrisSelectionValidConditionDialog_FormClosed(object sender, FormClosedEventArgs e)
  884. {
  885. this.debrisSelectionDialog.ReloadDebrisSelectionFromXml();
  886. this.debrisSelectionDialog.RefreshDebrisComboBox();
  887. }
  888. /// <summary>
  889. /// 动态修改条件的model
  890. /// </summary>
  891. /// <param name="sender"></param>
  892. /// <param name="e"></param>
  893. private void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e)
  894. {
  895. if (this.dataGridView1.IsCurrentCellDirty)
  896. {
  897. this.dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
  898. DebrisSelectionModel.DebrisSelection model = this.debrisSelectionModel.debrisSelectionList.Find(a => a.itemName.Equals(this.listView2.SelectedItems[0].Text));
  899. //循环处理this.debrisSelectionModel
  900. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  901. {
  902. double v;
  903. if (((DataGridViewTextBoxCell)this.dataGridView1.Rows[i].Cells[2]).Value != null && double.TryParse(((DataGridViewTextBoxCell)this.dataGridView1.Rows[i].Cells[2]).Value.ToString(), out v))
  904. {
  905. //this.debrisSelectionModel.debrisSelectionList[this.comboBox3.SelectedIndex].conditionList[i].conditionNum = v;// double.Parse(((DataGridViewTextBoxCell)this.dataGridView3.Rows[i].Cells[2]).Value.ToString());
  906. }
  907. else
  908. {
  909. ((DataGridViewTextBoxCell)this.dataGridView1.Rows[i].Cells[2]).Value = model.conditionList[i].conditionNum;
  910. }
  911. }
  912. ResetDebrisSelectionModel();
  913. }
  914. }
  915. private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
  916. {
  917. ListViewHitTestInfo info = this.listView1.HitTest(e.X, e.Y);
  918. if (info.Item != null)
  919. {
  920. this.button5.PerformClick();
  921. }
  922. }
  923. }
  924. }