MethodCutOffDialog.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. using OpenCvSharp;
  2. using PaintDotNet.DedicatedAnalysis.GrainSize.GBT6394_2017;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Drawing.Drawing2D;
  8. using System.Windows.Forms;
  9. namespace PaintDotNet.DedicatedAnalysis.GrainSize.YST347
  10. {
  11. internal class MethodCutOffDialog : GrainSizeStandardDialog
  12. {
  13. /// <summary>
  14. /// 测定结果暂存
  15. /// </summary>
  16. private List<DataTable> dataTable1s = new List<DataTable>();
  17. /// <summary>
  18. /// 储存点击保存结果后的所有原图与分析图
  19. /// </summary>
  20. private Dictionary<string, List<Bitmap>> bitCeDingDic = new Dictionary<string, List<Bitmap>>();
  21. #region 组件
  22. private GroupBox groupBox10;
  23. private Button button10;
  24. private Button button7_0;
  25. private GroupBox groupBox11;
  26. private CheckBox checkBox5_0;
  27. private CheckBox checkBox4;
  28. private CheckBox checkBox3_0;
  29. private Button button1;
  30. private Button button4;
  31. private DataGridView dataGridView1;
  32. private GroupBox groupBox5;
  33. private DataGridViewTextBoxColumn Column11;
  34. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
  35. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
  36. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
  37. private Button button8;
  38. private Button button6_0;
  39. private RadioButton radioButton_Black;
  40. #endregion 组件
  41. /// <summary>
  42. /// 构造函数
  43. /// </summary>
  44. /// <param name="appWorkspace"></param>
  45. /// <param name="dialogText"></param>
  46. public MethodCutOffDialog(AppWorkspace appWorkspace) : base(appWorkspace, false, true)
  47. {
  48. }
  49. #region 初始化组件
  50. private void InitializeLanguageText()
  51. {
  52. this.groupBox10.Text = PdnResources.GetString("Menu.sectionoperation.text");
  53. this.button8.Text = PdnResources.GetString("Menu.1.5/2section.text");
  54. this.button6_0.Text = PdnResources.GetString("Menu.0.5sectionstyle.text");
  55. this.button10.Text = PdnResources.GetString("Menu.Setting.Text");
  56. this.button7_0.Text = PdnResources.GetString("Menu.1section.text");
  57. this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  58. this.checkBox5_0.Text = PdnResources.GetString("Menu.displaysections.text");
  59. this.checkBox4.Text = PdnResources.GetString("Menu.displaygrid.text");
  60. this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
  61. this.button1.Text = PdnResources.GetString("Menu.Savemeasurementresults.text");
  62. this.button4.Text = PdnResources.GetString("Menu.Deletemeasurementresult.text");
  63. this.Column11.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text");
  64. this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Lengthofdetectionline.text");
  65. this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Nnlines.text");
  66. this.dataGridViewTextBoxColumn4.HeaderText = PdnResources.GetString("Menu.Thenumberofsections.text");
  67. this.groupBox5.Text = PdnResources.GetString("Menu.measurementresults.text");
  68. this.Text = "YST347(" + PdnResources.GetString("Menu.Interceptmethod.text") + ")";
  69. }
  70. private void InitializeComponent()
  71. {
  72. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  73. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
  74. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
  75. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
  76. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
  77. this.groupBox10 = new System.Windows.Forms.GroupBox();
  78. this.button8 = new System.Windows.Forms.Button();
  79. this.button6_0 = new System.Windows.Forms.Button();
  80. this.button10 = new System.Windows.Forms.Button();
  81. this.button7_0 = new System.Windows.Forms.Button();
  82. this.groupBox11 = new System.Windows.Forms.GroupBox();
  83. this.checkBox5_0 = new System.Windows.Forms.CheckBox();
  84. this.checkBox4 = new System.Windows.Forms.CheckBox();
  85. this.checkBox3_0 = new System.Windows.Forms.CheckBox();
  86. this.button1 = new System.Windows.Forms.Button();
  87. this.button4 = new System.Windows.Forms.Button();
  88. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  89. this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  90. this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  91. this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  92. this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  93. this.groupBox5 = new System.Windows.Forms.GroupBox();
  94. this.groupBox_analysisResult1.SuspendLayout();
  95. this.groupBox10.SuspendLayout();
  96. this.groupBox11.SuspendLayout();
  97. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  98. this.groupBox5.SuspendLayout();
  99. this.SuspendLayout();
  100. //
  101. // groupBox_img
  102. //
  103. this.groupBox_img.Size = new System.Drawing.Size(158, 428);
  104. //
  105. // groupBox_review
  106. //
  107. this.groupBox_review.Size = new System.Drawing.Size(575, 428);
  108. //
  109. // groupBox_report
  110. //
  111. this.groupBox_report.Location = new System.Drawing.Point(974, 506);
  112. //
  113. // groupBox6groupBox_analysisResult2
  114. //
  115. this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 506);
  116. //
  117. // groupBox_analysisResult1
  118. //
  119. this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 506);
  120. //
  121. // groupBox10
  122. //
  123. this.groupBox10.Controls.Add(this.button8);
  124. this.groupBox10.Controls.Add(this.button6_0);
  125. this.groupBox10.Controls.Add(this.button10);
  126. this.groupBox10.Controls.Add(this.button7_0);
  127. this.groupBox10.Location = new System.Drawing.Point(179, 555);
  128. this.groupBox10.Name = "groupBox10";
  129. this.groupBox10.Size = new System.Drawing.Size(208, 89);
  130. this.groupBox10.TabIndex = 38;
  131. this.groupBox10.TabStop = false;
  132. //
  133. // button8
  134. //
  135. this.button8.BackColor = System.Drawing.SystemColors.Control;
  136. this.button8.Location = new System.Drawing.Point(109, 52);
  137. this.button8.Name = "button8";
  138. this.button8.Size = new System.Drawing.Size(95, 26);
  139. this.button8.TabIndex = 13;
  140. this.button8.UseVisualStyleBackColor = false;
  141. this.button8.Click += new System.EventHandler(this.button8_Click);
  142. //
  143. // button6_0
  144. //
  145. this.button6_0.BackColor = System.Drawing.SystemColors.Control;
  146. this.button6_0.Location = new System.Drawing.Point(8, 53);
  147. this.button6_0.Name = "button6_0";
  148. this.button6_0.Size = new System.Drawing.Size(95, 26);
  149. this.button6_0.TabIndex = 12;
  150. this.button6_0.UseVisualStyleBackColor = false;
  151. this.button6_0.Click += new System.EventHandler(this.button6_0_Click);
  152. //
  153. // button10
  154. //
  155. this.button10.BackColor = System.Drawing.SystemColors.Control;
  156. this.button10.Location = new System.Drawing.Point(107, 20);
  157. this.button10.Name = "button10";
  158. this.button10.Size = new System.Drawing.Size(95, 26);
  159. this.button10.TabIndex = 11;
  160. this.button10.UseVisualStyleBackColor = false;
  161. this.button10.Click += new System.EventHandler(this.button10_Click);
  162. //
  163. // button7_0
  164. //
  165. this.button7_0.BackColor = System.Drawing.SystemColors.Control;
  166. this.button7_0.Location = new System.Drawing.Point(6, 20);
  167. this.button7_0.Name = "button7_0";
  168. this.button7_0.Size = new System.Drawing.Size(95, 26);
  169. this.button7_0.TabIndex = 8;
  170. this.button7_0.UseVisualStyleBackColor = false;
  171. this.button7_0.Click += new System.EventHandler(this.button7_0_Click);
  172. //
  173. // groupBox11
  174. //
  175. this.groupBox11.Controls.Add(this.checkBox5_0);
  176. this.groupBox11.Controls.Add(this.checkBox4);
  177. this.groupBox11.Controls.Add(this.checkBox3_0);
  178. this.groupBox11.Location = new System.Drawing.Point(393, 555);
  179. this.groupBox11.Name = "groupBox11";
  180. this.groupBox11.Size = new System.Drawing.Size(142, 89);
  181. this.groupBox11.TabIndex = 39;
  182. this.groupBox11.TabStop = false;
  183. //
  184. // checkBox5_0
  185. //
  186. this.checkBox5_0.AutoSize = true;
  187. this.checkBox5_0.Checked = true;
  188. this.checkBox5_0.CheckState = System.Windows.Forms.CheckState.Checked;
  189. this.checkBox5_0.Location = new System.Drawing.Point(15, 59);
  190. this.checkBox5_0.Name = "checkBox5_0";
  191. this.checkBox5_0.Size = new System.Drawing.Size(15, 14);
  192. this.checkBox5_0.TabIndex = 2;
  193. this.checkBox5_0.UseVisualStyleBackColor = true;
  194. this.checkBox5_0.CheckedChanged += new System.EventHandler(this.checkBox5_0_CheckedChanged);
  195. //
  196. // checkBox4
  197. //
  198. this.checkBox4.AutoSize = true;
  199. this.checkBox4.Checked = true;
  200. this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked;
  201. this.checkBox4.Location = new System.Drawing.Point(15, 37);
  202. this.checkBox4.Name = "checkBox4";
  203. this.checkBox4.Size = new System.Drawing.Size(15, 14);
  204. this.checkBox4.TabIndex = 1;
  205. this.checkBox4.UseVisualStyleBackColor = true;
  206. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  207. //
  208. // checkBox3_0
  209. //
  210. this.checkBox3_0.AutoSize = true;
  211. this.checkBox3_0.Checked = true;
  212. this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
  213. this.checkBox3_0.Location = new System.Drawing.Point(15, 15);
  214. this.checkBox3_0.Name = "checkBox3_0";
  215. this.checkBox3_0.Size = new System.Drawing.Size(15, 14);
  216. this.checkBox3_0.TabIndex = 0;
  217. this.checkBox3_0.UseVisualStyleBackColor = true;
  218. this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
  219. //
  220. // button1
  221. //
  222. this.button1.BackColor = System.Drawing.SystemColors.Control;
  223. this.button1.Location = new System.Drawing.Point(139, 11);
  224. this.button1.Name = "button1";
  225. this.button1.Size = new System.Drawing.Size(101, 23);
  226. this.button1.TabIndex = 5;
  227. this.button1.UseVisualStyleBackColor = false;
  228. this.button1.Click += new System.EventHandler(this.button1_Click);
  229. //
  230. // button4
  231. //
  232. this.button4.BackColor = System.Drawing.SystemColors.Control;
  233. this.button4.Location = new System.Drawing.Point(246, 11);
  234. this.button4.Name = "button4";
  235. this.button4.Size = new System.Drawing.Size(101, 23);
  236. this.button4.TabIndex = 4;
  237. this.button4.UseVisualStyleBackColor = false;
  238. this.button4.Click += new System.EventHandler(this.button4_Click);
  239. //
  240. // dataGridView1
  241. //
  242. this.dataGridView1.AllowUserToAddRows = false;
  243. this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  244. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  245. dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
  246. dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  247. dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
  248. dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  249. dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  250. dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  251. this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
  252. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  253. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  254. this.Column11,
  255. this.dataGridViewTextBoxColumn1,
  256. this.dataGridViewTextBoxColumn2,
  257. this.dataGridViewTextBoxColumn4});
  258. this.dataGridView1.Location = new System.Drawing.Point(6, 36);
  259. this.dataGridView1.MultiSelect = false;
  260. this.dataGridView1.Name = "dataGridView1";
  261. this.dataGridView1.ReadOnly = true;
  262. this.dataGridView1.RowHeadersVisible = false;
  263. this.dataGridView1.RowTemplate.Height = 23;
  264. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  265. this.dataGridView1.Size = new System.Drawing.Size(341, 103);
  266. this.dataGridView1.TabIndex = 29;
  267. //
  268. // Column11
  269. //
  270. dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  271. this.Column11.DefaultCellStyle = dataGridViewCellStyle2;
  272. this.Column11.Name = "Column11";
  273. this.Column11.ReadOnly = true;
  274. this.Column11.Width = 66;
  275. //
  276. // dataGridViewTextBoxColumn1
  277. //
  278. dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  279. this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle3;
  280. this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
  281. this.dataGridViewTextBoxColumn1.ReadOnly = true;
  282. //
  283. // dataGridViewTextBoxColumn2
  284. //
  285. dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  286. this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle4;
  287. this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
  288. this.dataGridViewTextBoxColumn2.ReadOnly = true;
  289. //
  290. // dataGridViewTextBoxColumn4
  291. //
  292. dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  293. this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle5;
  294. this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
  295. this.dataGridViewTextBoxColumn4.ReadOnly = true;
  296. this.dataGridViewTextBoxColumn4.Width = 72;
  297. //
  298. // groupBox5
  299. //
  300. this.groupBox5.Controls.Add(this.dataGridView1);
  301. this.groupBox5.Controls.Add(this.button4);
  302. this.groupBox5.Controls.Add(this.button1);
  303. this.groupBox5.Location = new System.Drawing.Point(179, 652);
  304. this.groupBox5.Name = "groupBox5";
  305. this.groupBox5.Size = new System.Drawing.Size(355, 145);
  306. this.groupBox5.TabIndex = 40;
  307. this.groupBox5.TabStop = false;
  308. //
  309. // MethodCutOffDialog
  310. //
  311. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  312. this.ClientSize = new System.Drawing.Size(1127, 1005);
  313. this.Controls.Add(this.groupBox5);
  314. this.Controls.Add(this.groupBox10);
  315. this.Controls.Add(this.groupBox11);
  316. this.Name = "MethodCutOffDialog";
  317. this.Load += new System.EventHandler(this.MethodCutOffDialog_Load);
  318. this.Controls.SetChildIndex(this.groupBox11, 0);
  319. this.Controls.SetChildIndex(this.groupBox10, 0);
  320. this.Controls.SetChildIndex(this.groupBox5, 0);
  321. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  322. this.Controls.SetChildIndex(this.groupBox_img, 0);
  323. this.Controls.SetChildIndex(this.groupBox_review, 0);
  324. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  325. this.Controls.SetChildIndex(this.groupBox_report, 0);
  326. this.groupBox_analysisResult1.ResumeLayout(false);
  327. this.groupBox10.ResumeLayout(false);
  328. this.groupBox11.ResumeLayout(false);
  329. this.groupBox11.PerformLayout();
  330. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  331. this.groupBox5.ResumeLayout(false);
  332. this.ResumeLayout(false);
  333. }
  334. #endregion 初始化组件
  335. #region 需继承方法
  336. protected override void refreshWhileImgChanged()
  337. {
  338. if (this.dataGridView1.Rows.Count > 0)
  339. {
  340. foreach (DataGridViewRow gridViewRow in this.dataGridView1.Rows)
  341. {
  342. foreach (var dataTable in this.dataTable1s)
  343. {
  344. if (dataTable.TableName.Equals(gridViewRow.Tag))
  345. {
  346. this.dataTable1s.Remove(dataTable);
  347. break;
  348. }
  349. }
  350. if (bitCeDingDic.ContainsKey((string)gridViewRow.Tag))
  351. bitCeDingDic.Remove((string)gridViewRow.Tag);
  352. }
  353. this.dataGridView1.Rows.Clear();
  354. }
  355. }
  356. /// <summary>
  357. /// 保存结果
  358. /// </summary>
  359. protected override void buildListBox_analysisResult()
  360. {
  361. if (this.matOrg == null)
  362. {
  363. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  364. return;
  365. }
  366. if (this.dataGridView1.Rows.Count == 0)
  367. {
  368. MessageBox.Show(PdnResources.GetString("Menu.Nomeasurementresult.text"));
  369. return;
  370. }
  371. string imgName = getCurrentWorkspace().GetFriendlyName();
  372. string tag = getCurrentWorkTag();
  373. DataTable dataTable = new DataTable();
  374. bool replace = false;
  375. int add = 0;
  376. foreach (ListViewItem item in this.listView2.Items)
  377. {
  378. if (item.Tag.Equals(tag))
  379. {
  380. add++;
  381. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  382. if (dr == DialogResult.OK)
  383. {
  384. replace = true;
  385. }
  386. break;
  387. }
  388. }
  389. if (replace || this.listView2.Items.Count == 0 || add == 0)
  390. {
  391. if (!replace)
  392. {
  393. ListViewItem listViewItem = new ListViewItem();
  394. listViewItem.SubItems[0].Text = imgName;
  395. listViewItem.Tag = "" + tag;
  396. if (this.listView2.Items.Count == 0)
  397. this.listView2.Items.Add(listViewItem);
  398. else
  399. this.listView2.Items.Insert(0, listViewItem);
  400. }
  401. this.dataGridView2.Rows.Clear();
  402. DataGridViewRow dgvr = new DataGridViewRow();
  403. dgvr.Tag = tag;
  404. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  405. {
  406. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  407. }
  408. dgvr.Cells[0].Value = imgName;
  409. DataGridViewRow firRow = this.dataGridView1.Rows[0];
  410. object value1 = firRow.Cells[0].Value;//网格
  411. object value2 = firRow.Cells[1].Value;//网格长度
  412. object value3 = firRow.Cells[2].Value;//网格条数
  413. double value2Total = 0;
  414. foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  415. {
  416. value2Total += (double.Parse(Row.Cells[1].Value.ToString()) * double.Parse(Row.Cells[2].Value.ToString()));//网格总长度
  417. }
  418. double value4Total = 0;
  419. foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  420. {
  421. value4Total += double.Parse(Row.Cells[3].Value.ToString());//交点个数
  422. }
  423. if (value4Total == 0)
  424. {
  425. MessageBox.Show(PdnResources.GetString("Menu.Nomeasurementresult.text"));
  426. return;
  427. }
  428. //double value4Per = value4Total / this.dataGridView1.Rows.Count;
  429. dgvr.Cells[1].Value = value1;
  430. dgvr.Cells[2].Value = value2Total;
  431. dgvr.Cells[3].Value = value4Total;
  432. //dgvr.Cells[4].Value = value4Per;//级别
  433. decimal M = 1;// this.getGainMultiple();
  434. dgvr.Cells[4].Value = 6.6439 * Math.Log10((value4Total * (double)M) / value2Total) - 3.2877;
  435. this.dataGridView2.Rows.Add(dgvr);
  436. dataTable.TableName = tag;
  437. foreach (System.Data.DataTable dataTable1 in dataTables)
  438. {
  439. if (dataTable1.TableName.Equals(dataTable.TableName))
  440. {
  441. dataTables.Remove(dataTable1);
  442. break;
  443. }
  444. }
  445. for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
  446. {
  447. dataTable.Columns.Add("" + i);
  448. }
  449. DataRow dataRow = dataTable.NewRow();
  450. dataRow["0"] = imgName;
  451. dataRow["1"] = dgvr.Cells[1].Value;// "网格1";
  452. dataRow["2"] = dgvr.Cells[2].Value;
  453. dataRow["3"] = dgvr.Cells[3].Value;
  454. dataRow["4"] = dgvr.Cells[4].Value;
  455. dataTable.Rows.Add(dataRow);
  456. this.dataTables.Add(dataTable);
  457. if (this.allShow)
  458. AllShow();
  459. this.RefreshDataGridView4();
  460. //保存处理后的图片
  461. List<Bitmap> tempBit = new List<Bitmap>();
  462. //Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  463. //tempBit.Add(originalBit);
  464. //Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  465. //Graphics graphics = Graphics.FromImage(newBit);
  466. //Draw(graphics);
  467. //tempBit.Add(newBit);
  468. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitCeDingDic)
  469. {
  470. tempBit.Add(kv.Value[0]);
  471. tempBit.Add(kv.Value[1]);
  472. }
  473. if (bitDic.ContainsKey(tag))
  474. bitDic[tag] = tempBit;
  475. else
  476. bitDic.Add(tag, tempBit);
  477. //中间数据-拼接中间数据
  478. List<List<string>> dataList = new List<List<string>>();
  479. List<string> columnName = new List<string>();
  480. columnName.Add(PdnResources.GetString("Menu.Tools.GridLine.Text"));
  481. columnName.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Lengthofdetectionline.text"));
  482. columnName.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Nnlines.text"));
  483. columnName.Add(PdnResources.GetString("Menu.Thenumberofsections.text"));
  484. dataList.Add(columnName);
  485. foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  486. {
  487. List<string> strList = new List<string>();
  488. strList.Add(Row.Cells[0].Value.ToString());
  489. strList.Add(Row.Cells[1].Value.ToString());
  490. strList.Add(Row.Cells[2].Value.ToString());
  491. strList.Add(Row.Cells[3].Value.ToString());
  492. dataList.Add(strList);
  493. }
  494. bool isExist = false;//是否已存在进行替换
  495. int modelIndex = -1;//要替换的下标
  496. for (int j = 0; j < tempDataModel.Count; j++)
  497. {
  498. if (tempDataModel[j].tagName.Equals(tag))
  499. {
  500. isExist = true;
  501. modelIndex = j;
  502. break;
  503. }
  504. }
  505. if (isExist && modelIndex > -1)
  506. tempDataModel[modelIndex].dataList = dataList;
  507. else
  508. {
  509. Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
  510. newModel.tagName = tag;
  511. newModel.picName = imgName;
  512. newModel.dataList = dataList;
  513. tempDataModel.Add(newModel);
  514. }
  515. }
  516. }
  517. //是否绘制辅助线
  518. protected override bool drawGuideLines()
  519. {
  520. return checkBox4.Checked;
  521. }
  522. //是否绘制截点
  523. protected override bool drawGuidePoints()
  524. {
  525. return (matOrg != null && this.checkBox5_0.Checked);
  526. }
  527. //辅助线类型
  528. protected override string[] getTypeNames()
  529. {
  530. return new string[] {
  531. PdnResources.GetString("Menu.Verticalauxiliaryline.text"),
  532. PdnResources.GetString("Menu.Horizontalauxiliaryline.text")};
  533. }
  534. protected override string getTemplateName()
  535. {
  536. return "Template.Manager.item3.GrainSizeCutOff_YST347";
  537. }
  538. protected override string getProjectEngineeringName()
  539. {
  540. return "Menu.DedicatedAnalysis.NonferrousMetal.CopperAlloy.Text";
  541. }
  542. protected override string getModelName()
  543. {
  544. return "GrainGBT32461CutOffMethodModel.xml";
  545. }
  546. protected override void SubclassInitialize()
  547. {
  548. InitializeComponent();
  549. InitializeLanguageText();
  550. }
  551. #endregion
  552. private void MethodCutOffDialog_Load(object sender, EventArgs e)
  553. {
  554. this.groupBox_img.Size = new System.Drawing.Size(158, 722);
  555. this.groupBox_review.Size = new System.Drawing.Size(575, 722);
  556. this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 800);
  557. this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 800);
  558. this.groupBox_report.Location = new System.Drawing.Point(974, 800);
  559. }
  560. /// <summary>
  561. /// 是否显示网格
  562. /// </summary>
  563. /// <param name="sender"></param>
  564. /// <param name="e"></param>
  565. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  566. {
  567. this.documentWorkspace.Refresh();
  568. }
  569. /// <summary>
  570. /// 是否显示截点
  571. /// </summary>
  572. /// <param name="sender"></param>
  573. /// <param name="e"></param>
  574. private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
  575. {
  576. if (!this.checkBox4.Checked)
  577. MessageBox.Show(PdnResources.GetString("Menu.Nogrid.text")+"!");
  578. this.documentWorkspace.Refresh();
  579. }
  580. /// <summary>
  581. /// 是否显示晶界
  582. /// </summary>
  583. /// <param name="sender"></param>
  584. /// <param name="e"></param>
  585. private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
  586. {
  587. if (!showOrimat() && getGrainBoundryChecked() && checkBox3_0.Checked)
  588. {
  589. this.documentWorkspace.PhaseModels[1].choise = true;
  590. }
  591. else
  592. {
  593. this.documentWorkspace.PhaseModels[1].choise = false;
  594. }
  595. this.documentWorkspace.Refresh();
  596. }
  597. /// <summary>
  598. /// 设置截点样式
  599. /// </summary>
  600. /// <param name="sender"></param>
  601. /// <param name="e"></param>
  602. private void button10_Click(object sender, EventArgs e)
  603. {//###
  604. GrainSizeStandard.IntegrationClass.GrainSurveyPointStyleSettingDialog grainSurveyPointStyleSettingDialog = new GrainSizeStandard.IntegrationClass.GrainSurveyPointStyleSettingDialog();//###
  605. grainSurveyPointStyleSettingDialog.StartPosition = FormStartPosition.CenterScreen;
  606. grainSurveyPointStyleSettingDialog.ShowDialog(this);
  607. }
  608. /// <summary>
  609. /// 鼠标按下
  610. /// </summary>
  611. /// <param name="drawArea"></param>
  612. /// <param name="e"></param>
  613. protected override void OnMouseDown(object sender, MouseEventArgs e)
  614. {
  615. if (this.documentWorkspace.CompositionSurface == null)
  616. return;
  617. // 换算后的点
  618. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  619. if (point1.X <= this.documentWorkspace.CompositionSurface.Width
  620. && point1.X >= 0
  621. && point1.Y >= 0
  622. && point1.Y <= this.documentWorkspace.CompositionSurface.Height)
  623. {
  624. RectangleF rectangleF;
  625. // 复合辅助线
  626. int add = guideClass.getAddOfRStyle(point1, this.comboBox1.SelectedItem, out rectangleF);
  627. if (add == 0 && styleClass.PointKb > 0)
  628. rectangleF = guideClass.RectangleFLine;
  629. //手动添加截点
  630. styleClass.OnMouseDownFirst(point1, rectangleF, this.linePointList, sender, e);
  631. }
  632. if (styleClass.PointKb == 0)
  633. {
  634. //辅助线缩放
  635. guideClass.OnMouseDown(point1, sender, e);
  636. //辅助线移动
  637. base.OnMouseDown(sender, e);//##
  638. }
  639. //手动删除截点或取消添加截点
  640. styleClass.OnMouseDownNext(point1, sender, e);
  641. }
  642. private int dataTable1sTagInc = 0;
  643. /// <summary>
  644. /// 保存测定结果
  645. /// </summary>
  646. /// <param name="sender"></param>
  647. /// <param name="e"></param>
  648. private void button1_Click(object sender, EventArgs e)
  649. {
  650. if (this.matOrg == null)
  651. {
  652. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  653. return;
  654. }
  655. DataTable dataTable = new DataTable();
  656. //this.dataGridView111114.Rows.Clear();
  657. DataGridViewRow dgvr = new DataGridViewRow();
  658. dataTable1sTagInc++;
  659. dgvr.Tag = dataTable1sTagInc + "";
  660. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  661. {
  662. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  663. }
  664. dgvr.Cells[0].Value = this.comboBox1.SelectedItem;
  665. dgvr.Cells[1].Value = guideClass.LineLength;
  666. dgvr.Cells[2].Value = guideClass.LineDec;
  667. double countPoints = styleClass.getCountPoints();
  668. dgvr.Cells[3].Value = countPoints;// (float)this.p1RectangleFs.Count + (float)this.p2RectangleFs.Count / 2;
  669. this.dataGridView1.Rows.Add(dgvr);
  670. dataTable.TableName = (string)dgvr.Tag;
  671. for (int i = 0; i < this.dataGridView1.Columns.Count; i++)
  672. {
  673. dataTable.Columns.Add("" + i);
  674. }
  675. DataRow dataRow = dataTable.NewRow();
  676. dataRow["0"] = dgvr.Cells[0].Value;
  677. dataRow["1"] = dgvr.Cells[1].Value;
  678. dataRow["2"] = dgvr.Cells[2].Value;
  679. dataRow["3"] = countPoints;// Convert.ToDecimal(this.p1RectangleFs.Count) + Convert.ToDecimal(this.p2RectangleFs.Count) / 2;
  680. dataTable.Rows.Add(dataRow);
  681. this.dataTable1s.Add(dataTable);
  682. //保存处理后的图片
  683. List<Bitmap> tempBit = new List<Bitmap>();
  684. Bitmap originalBit = this.bitmap;// this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  685. tempBit.Add(originalBit);
  686. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  687. Graphics graphics = Graphics.FromImage(newBit);
  688. if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
  689. {
  690. Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;
  691. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  692. }
  693. if (this.documentWorkspace.PhaseModels[1].choise && this.documentWorkspace.PhaseModels[1].mat != null)
  694. {
  695. Mat targetMat = this.documentWorkspace.PhaseModels[1].mat;
  696. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  697. }
  698. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  699. drawSubclass/*Draw*/(graphics);
  700. tempBit.Add(newBit);
  701. if (bitCeDingDic.ContainsKey((string)dgvr.Tag))
  702. bitCeDingDic[(string)dgvr.Tag] = tempBit;
  703. else
  704. bitCeDingDic.Add((string)dgvr.Tag, tempBit);
  705. }
  706. /// <summary>
  707. /// 删除测定结果
  708. /// </summary>
  709. /// <param name="sender"></param>
  710. /// <param name="e"></param>
  711. private void button4_Click(object sender, EventArgs e)
  712. {
  713. if (this.dataGridView1.Rows.Count > 0)
  714. {
  715. if (this.dataGridView1.SelectedRows.Count > 0)
  716. {
  717. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  718. if (dr == DialogResult.OK)
  719. {
  720. DataGridViewRow gridViewRow = this.dataGridView1.SelectedRows[0];
  721. int selectIndex = gridViewRow.Index;
  722. foreach (var dataTable in this.dataTable1s)
  723. {
  724. if (dataTable.TableName.Equals(gridViewRow.Tag))
  725. {
  726. this.dataTable1s.Remove(dataTable);
  727. break;
  728. }
  729. }
  730. if (bitCeDingDic.ContainsKey((string)gridViewRow.Tag))
  731. bitCeDingDic.Remove((string)gridViewRow.Tag);
  732. this.dataGridView1.Rows.RemoveAt(selectIndex);
  733. //RefreshDataGridView1();
  734. }
  735. }
  736. else
  737. {
  738. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
  739. }
  740. }
  741. else
  742. {
  743. MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
  744. }
  745. }
  746. private void AllShow()
  747. {
  748. this.dataGridView2.Rows.Clear();
  749. for (int i = 0; i < this.dataTables.Count; i++)
  750. {
  751. DataGridViewRow dgvr = new DataGridViewRow();
  752. dgvr.Tag = this.dataTables[i].TableName;
  753. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  754. {
  755. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  756. }
  757. for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
  758. {
  759. //if (c > 2 && c < 4)
  760. // dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[0][c]), Convert.ToInt32(this.numericUpDown1_0.Value)).ToString();
  761. //else
  762. dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
  763. }
  764. this.dataGridView2.Rows.Add(dgvr);
  765. }
  766. }
  767. private void button6_0_Click(object sender, EventArgs e)
  768. {
  769. if (this.matOrg != null)
  770. {
  771. //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
  772. styleClass.PointKb = 1;
  773. }
  774. else
  775. {
  776. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  777. }
  778. }
  779. /// <summary>
  780. /// 1截点添加
  781. /// </summary>
  782. /// <param name="sender"></param>
  783. /// <param name="e"></param>
  784. private void button7_0_Click(object sender, EventArgs e)
  785. {
  786. if (this.matOrg != null)
  787. {
  788. //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
  789. styleClass.PointKb = 2;
  790. }
  791. else
  792. {
  793. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  794. }
  795. }
  796. private void button8_Click(object sender, EventArgs e)
  797. {
  798. if (this.matOrg != null)
  799. {
  800. //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
  801. styleClass.PointKb = 3;
  802. }
  803. else
  804. {
  805. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  806. }
  807. }
  808. }
  809. }