MethodCutOffDialog.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064
  1. using OpenCvSharp;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8. namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.GBT4296
  9. {
  10. internal class MethodCutOffDialog : GrainSizeStandardDialog
  11. {
  12. /// <summary>
  13. /// 测定结果暂存
  14. /// </summary>
  15. private List<DataTable> dataTable1s = new List<DataTable>();
  16. /// <summary>
  17. /// 储存点击保存结果后的所有原图与分析图
  18. /// </summary>
  19. private Dictionary<string, List<Bitmap>> bitCeDingDic = new Dictionary<string, List<Bitmap>>();
  20. #region 组件
  21. private GroupBox groupBox10;
  22. private Button button10;
  23. private Button button7_0;
  24. private GroupBox groupBox11;
  25. private CheckBox checkBox5_0;
  26. private CheckBox checkBox4;
  27. private CheckBox checkBox3_0;
  28. private DataGridViewTextBoxColumn ColumnTotal1;
  29. private DataGridViewTextBoxColumn ColumnTotal2;
  30. private DataGridViewTextBoxColumn ColumnTotal3;
  31. private Button button1;
  32. private Button button4;
  33. private DataGridView dataGridView1;
  34. private GroupBox groupBox5;
  35. private DataGridViewTextBoxColumn Column11;
  36. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
  37. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
  38. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
  39. private Button button8;
  40. private Button button6_0;
  41. #endregion 组件
  42. /// <summary>
  43. /// 构造函数
  44. /// </summary>
  45. /// <param name="appWorkspace"></param>
  46. /// <param name="dialogText"></param>
  47. public MethodCutOffDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) : base(appWorkspace, menuItem, null, 0)
  48. {
  49. }
  50. #region 初始化组件
  51. private void InitializeLanguageText()
  52. {
  53. this.groupBox10.Text = PdnResources.GetString("Menu.sectionoperation.text");
  54. this.button8.Text = PdnResources.GetString("Menu.1.5/2section.text");
  55. this.button6_0.Text = PdnResources.GetString("Menu.0.5sectionstyle.text");
  56. this.button10.Text = PdnResources.GetString("Menu.Setting.Text");
  57. this.button7_0.Text = PdnResources.GetString("Menu.1section.text");
  58. this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  59. this.checkBox5_0.Text = PdnResources.GetString("Menu.displaysections.text");
  60. this.checkBox4.Text = PdnResources.GetString("Menu.displaygrid.text");
  61. this.checkBox3_0.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
  62. this.button1.Text = PdnResources.GetString("Menu.Savemeasurementresults.text");
  63. this.button4.Text = PdnResources.GetString("Menu.Deletemeasurementresult.text");
  64. this.Column11.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text");
  65. this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Lengthofdetectionline.text");
  66. this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Nnlines.text");
  67. this.dataGridViewTextBoxColumn4.HeaderText = PdnResources.GetString("Menu.Thenumberofsections.text");
  68. this.groupBox5.Text = PdnResources.GetString("Menu.measurementresults.text");
  69. this.Text = "GBT4296(" + PdnResources.GetString("Menu.Interceptmethod.text") + ")";
  70. this.ColumnTotal1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  71. this.ColumnTotal2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  72. this.ColumnTotal3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  73. this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  74. this.ColumnTotal1,
  75. this.ColumnTotal2,
  76. this.ColumnTotal3});
  77. //
  78. // ColumnTotal1
  79. //
  80. this.ColumnTotal1.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Gridsize.text") + "(μm)";
  81. this.ColumnTotal1.Name = "ColumnTotal1";
  82. this.ColumnTotal1.ReadOnly = true;
  83. //
  84. // ColumnTotal2
  85. //
  86. this.ColumnTotal2.HeaderText = PdnResources.GetString("Menu.Numberofgrains.text");
  87. this.ColumnTotal2.Name = "ColumnTotal2";
  88. this.ColumnTotal2.ReadOnly = true;
  89. //
  90. // ColumnTotal3
  91. //
  92. this.ColumnTotal3.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
  93. this.ColumnTotal3.Name = "ColumnTotal3";
  94. this.ColumnTotal3.ReadOnly = true;
  95. }
  96. private void InitializeComponent()
  97. {
  98. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  99. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
  100. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
  101. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
  102. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
  103. this.groupBox10 = new System.Windows.Forms.GroupBox();
  104. this.button8 = new System.Windows.Forms.Button();
  105. this.button6_0 = new System.Windows.Forms.Button();
  106. this.button10 = new System.Windows.Forms.Button();
  107. this.button7_0 = new System.Windows.Forms.Button();
  108. this.groupBox11 = new System.Windows.Forms.GroupBox();
  109. this.checkBox5_0 = new System.Windows.Forms.CheckBox();
  110. this.checkBox4 = new System.Windows.Forms.CheckBox();
  111. this.checkBox3_0 = new System.Windows.Forms.CheckBox();
  112. this.button1 = new System.Windows.Forms.Button();
  113. this.button4 = new System.Windows.Forms.Button();
  114. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  115. this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  116. this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  117. this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  118. this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  119. this.groupBox5 = new System.Windows.Forms.GroupBox();
  120. this.groupBox_analysisResult1.SuspendLayout();
  121. this.groupBox10.SuspendLayout();
  122. this.groupBox11.SuspendLayout();
  123. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  124. this.groupBox5.SuspendLayout();
  125. this.SuspendLayout();
  126. //
  127. // groupBox10
  128. //
  129. this.groupBox10.Controls.Add(this.button8);
  130. this.groupBox10.Controls.Add(this.button6_0);
  131. this.groupBox10.Controls.Add(this.button10);
  132. this.groupBox10.Controls.Add(this.button7_0);
  133. this.groupBox10.Location = new System.Drawing.Point(179, 375);
  134. this.groupBox10.Name = "groupBox10";
  135. this.groupBox10.Size = new System.Drawing.Size(208, 89);
  136. this.groupBox10.TabIndex = 38;
  137. this.groupBox10.TabStop = false;
  138. //
  139. // button8
  140. //
  141. this.button8.BackColor = System.Drawing.SystemColors.Control;
  142. this.button8.Location = new System.Drawing.Point(107, 52);
  143. this.button8.Name = "button8";
  144. this.button8.Size = new System.Drawing.Size(95, 26);
  145. this.button8.TabIndex = 13;
  146. this.button8.UseVisualStyleBackColor = false;
  147. this.button8.Click += new System.EventHandler(this.button8_Click);
  148. //
  149. // button6_0
  150. //
  151. this.button6_0.BackColor = System.Drawing.SystemColors.Control;
  152. this.button6_0.Location = new System.Drawing.Point(6, 53);
  153. this.button6_0.Name = "button6_0";
  154. this.button6_0.Size = new System.Drawing.Size(95, 26);
  155. this.button6_0.TabIndex = 12;
  156. this.button6_0.UseVisualStyleBackColor = false;
  157. this.button6_0.Click += new System.EventHandler(this.button6_0_Click);
  158. //
  159. // button10
  160. //
  161. this.button10.BackColor = System.Drawing.SystemColors.Control;
  162. this.button10.Location = new System.Drawing.Point(107, 20);
  163. this.button10.Name = "button10";
  164. this.button10.Size = new System.Drawing.Size(95, 26);
  165. this.button10.TabIndex = 11;
  166. this.button10.UseVisualStyleBackColor = false;
  167. this.button10.Click += new System.EventHandler(this.button10_Click);
  168. //
  169. // button7_0
  170. //
  171. this.button7_0.BackColor = System.Drawing.SystemColors.Control;
  172. this.button7_0.Location = new System.Drawing.Point(6, 20);
  173. this.button7_0.Name = "button7_0";
  174. this.button7_0.Size = new System.Drawing.Size(95, 26);
  175. this.button7_0.TabIndex = 8;
  176. this.button7_0.UseVisualStyleBackColor = false;
  177. this.button7_0.Click += new System.EventHandler(this.button7_0_Click);
  178. //
  179. // groupBox11
  180. //
  181. this.groupBox11.Controls.Add(this.checkBox5_0);
  182. this.groupBox11.Controls.Add(this.checkBox4);
  183. this.groupBox11.Controls.Add(this.checkBox3_0);
  184. this.groupBox11.Location = new System.Drawing.Point(393, 375);
  185. this.groupBox11.Name = "groupBox11";
  186. this.groupBox11.Size = new System.Drawing.Size(142, 89);
  187. this.groupBox11.TabIndex = 39;
  188. this.groupBox11.TabStop = false;
  189. //
  190. // checkBox5_0
  191. //
  192. this.checkBox5_0.AutoSize = true;
  193. this.checkBox5_0.Checked = true;
  194. this.checkBox5_0.CheckState = System.Windows.Forms.CheckState.Checked;
  195. this.checkBox5_0.Location = new System.Drawing.Point(15, 59);
  196. this.checkBox5_0.Name = "checkBox5_0";
  197. this.checkBox5_0.Size = new System.Drawing.Size(15, 14);
  198. this.checkBox5_0.TabIndex = 2;
  199. this.checkBox5_0.UseVisualStyleBackColor = true;
  200. this.checkBox5_0.CheckedChanged += new System.EventHandler(this.checkBox5_0_CheckedChanged);
  201. //
  202. // checkBox4
  203. //
  204. this.checkBox4.AutoSize = true;
  205. this.checkBox4.Checked = true;
  206. this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked;
  207. this.checkBox4.Location = new System.Drawing.Point(15, 37);
  208. this.checkBox4.Name = "checkBox4";
  209. this.checkBox4.Size = new System.Drawing.Size(15, 14);
  210. this.checkBox4.TabIndex = 1;
  211. this.checkBox4.UseVisualStyleBackColor = true;
  212. this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
  213. //
  214. // checkBox3_0
  215. //
  216. this.checkBox3_0.AutoSize = true;
  217. this.checkBox3_0.Checked = true;
  218. this.checkBox3_0.CheckState = System.Windows.Forms.CheckState.Checked;
  219. this.checkBox3_0.Location = new System.Drawing.Point(15, 15);
  220. this.checkBox3_0.Name = "checkBox3_0";
  221. this.checkBox3_0.Size = new System.Drawing.Size(15, 14);
  222. this.checkBox3_0.TabIndex = 0;
  223. this.checkBox3_0.UseVisualStyleBackColor = true;
  224. this.checkBox3_0.CheckedChanged += new System.EventHandler(this.checkBox3_0_CheckedChanged);
  225. //
  226. // button1
  227. //
  228. this.button1.BackColor = System.Drawing.SystemColors.Control;
  229. this.button1.Location = new System.Drawing.Point(139, 11);
  230. this.button1.Name = "button1";
  231. this.button1.Size = new System.Drawing.Size(101, 23);
  232. this.button1.TabIndex = 5;
  233. this.button1.UseVisualStyleBackColor = false;
  234. this.button1.Click += new System.EventHandler(this.button1_Click);
  235. //
  236. // button4
  237. //
  238. this.button4.BackColor = System.Drawing.SystemColors.Control;
  239. this.button4.Location = new System.Drawing.Point(246, 11);
  240. this.button4.Name = "button4";
  241. this.button4.Size = new System.Drawing.Size(101, 23);
  242. this.button4.TabIndex = 4;
  243. this.button4.UseVisualStyleBackColor = false;
  244. this.button4.Click += new System.EventHandler(this.button4_Click);
  245. //
  246. // dataGridView1
  247. //
  248. this.dataGridView1.AllowUserToAddRows = false;
  249. this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  250. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  251. dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
  252. dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  253. dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
  254. dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  255. dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  256. dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  257. this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
  258. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  259. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  260. this.Column11,
  261. this.dataGridViewTextBoxColumn1,
  262. this.dataGridViewTextBoxColumn2,
  263. this.dataGridViewTextBoxColumn4});
  264. this.dataGridView1.Location = new System.Drawing.Point(6, 36);
  265. this.dataGridView1.MultiSelect = false;
  266. this.dataGridView1.Name = "dataGridView1";
  267. this.dataGridView1.ReadOnly = true;
  268. this.dataGridView1.RowHeadersVisible = false;
  269. this.dataGridView1.RowTemplate.Height = 23;
  270. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  271. this.dataGridView1.Size = new System.Drawing.Size(341, 103);
  272. this.dataGridView1.TabIndex = 29;
  273. //
  274. // Column11
  275. //
  276. dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  277. this.Column11.DefaultCellStyle = dataGridViewCellStyle2;
  278. this.Column11.Name = "Column11";
  279. this.Column11.ReadOnly = true;
  280. this.Column11.Width = 66;
  281. //
  282. // dataGridViewTextBoxColumn1
  283. //
  284. dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  285. this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle3;
  286. this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
  287. this.dataGridViewTextBoxColumn1.ReadOnly = true;
  288. //
  289. // dataGridViewTextBoxColumn2
  290. //
  291. dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  292. this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle4;
  293. this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
  294. this.dataGridViewTextBoxColumn2.ReadOnly = true;
  295. //
  296. // dataGridViewTextBoxColumn4
  297. //
  298. dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  299. this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle5;
  300. this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
  301. this.dataGridViewTextBoxColumn4.ReadOnly = true;
  302. this.dataGridViewTextBoxColumn4.Width = 72;
  303. //
  304. // groupBox5
  305. //
  306. this.groupBox5.Controls.Add(this.dataGridView1);
  307. this.groupBox5.Controls.Add(this.button4);
  308. this.groupBox5.Controls.Add(this.button1);
  309. this.groupBox5.Location = new System.Drawing.Point(179, 472);
  310. this.groupBox5.Name = "groupBox5";
  311. this.groupBox5.Size = new System.Drawing.Size(355, 145);
  312. this.groupBox5.TabIndex = 40;
  313. this.groupBox5.TabStop = false;
  314. //
  315. // MethodCutOffDialog
  316. //
  317. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  318. this.ClientSize = new System.Drawing.Size(1127, 980);
  319. this.Controls.Add(this.groupBox5);
  320. this.Controls.Add(this.groupBox10);
  321. this.Controls.Add(this.groupBox11);
  322. this.Name = "MethodCutOffDialog";
  323. this.Load += new System.EventHandler(this.MethodCutOffDialog_Load);
  324. this.Controls.SetChildIndex(this.groupBox11, 0);
  325. this.Controls.SetChildIndex(this.groupBox10, 0);
  326. this.Controls.SetChildIndex(this.groupBox5, 0);
  327. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  328. this.Controls.SetChildIndex(this.groupBox_img, 0);
  329. this.Controls.SetChildIndex(this.groupBox_review, 0);
  330. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  331. this.Controls.SetChildIndex(this.groupBox_report, 0);
  332. this.groupBox_analysisResult1.ResumeLayout(false);
  333. this.groupBox10.ResumeLayout(false);
  334. this.groupBox11.ResumeLayout(false);
  335. this.groupBox11.PerformLayout();
  336. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  337. this.groupBox5.ResumeLayout(false);
  338. this.ResumeLayout(false);
  339. }
  340. #endregion 初始化组件
  341. #region 需继承方法
  342. protected override void refreshWhileImgChanged()
  343. {
  344. object ShowGrainBoundry;
  345. if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
  346. this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
  347. if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格
  348. this.checkBox4.Checked = (bool)ShowGrainBoundry;
  349. if (GetParamValue1(ParamKey_displaysections, out ShowGrainBoundry))//显示截点
  350. this.checkBox5_0.Checked = (bool)ShowGrainBoundry;
  351. if (this.dataGridView1.Rows.Count > 0)
  352. {
  353. foreach (DataGridViewRow gridViewRow in this.dataGridView1.Rows)
  354. {
  355. foreach (var dataTable in this.dataTable1s)
  356. {
  357. if (dataTable.TableName.Equals(gridViewRow.Tag))
  358. {
  359. this.dataTable1s.Remove(dataTable);
  360. break;
  361. }
  362. }
  363. if (bitCeDingDic.ContainsKey((string)gridViewRow.Tag))
  364. bitCeDingDic.Remove((string)gridViewRow.Tag);
  365. }
  366. this.dataGridView1.Rows.Clear();
  367. }
  368. }
  369. /// <summary>
  370. /// 保存结果
  371. /// </summary>
  372. protected override void buildListBox_analysisResult(string imagesKey, int analysisPicture, bool saveAll = false)
  373. {
  374. if (this.imageMat == null)
  375. {
  376. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  377. return;
  378. }
  379. if (this.dataGridView1.Rows.Count == 0)
  380. {
  381. MessageBox.Show(PdnResources.GetString("Menu.Nomeasurementresult.text"));
  382. return;
  383. }
  384. double value4Total = 0;
  385. foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  386. {
  387. value4Total += double.Parse(Row.Cells[3].Value.ToString());//交点个数
  388. }
  389. if (value4Total == 0)
  390. {
  391. MessageBox.Show("请添加截点后保存结果"/*PdnResources.GetString("Menu.Nomeasurementresult.text")*/);
  392. return;
  393. }
  394. //if (this.comboBox1.SelectedItem == null || PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem))
  395. //{
  396. // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!");
  397. // return;
  398. //}
  399. string imgName = getCurrentWorkspace().GetFriendlyName();
  400. string tag = getCurrentWorkTag();
  401. DataTable dataTable = new DataTable();
  402. bool replace = false;
  403. int add = 0;
  404. foreach (ListViewItem item in this.listView2.Items)
  405. {
  406. if (item.Tag.Equals(tag))
  407. {
  408. add++;
  409. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  410. if (dr == DialogResult.OK)
  411. {
  412. replace = true;
  413. }
  414. break;
  415. }
  416. }
  417. if (replace || this.listView2.Items.Count == 0 || add == 0)
  418. {
  419. if (!replace)
  420. {
  421. ListViewItem listViewItem = new ListViewItem();
  422. listViewItem.SubItems[0].Text = imgName;
  423. listViewItem.Tag = "" + tag;
  424. if (this.listView2.Items.Count == 0)
  425. this.listView2.Items.Add(listViewItem);
  426. else
  427. this.listView2.Items.Insert(0, listViewItem);
  428. }
  429. this.dataGridView2.Rows.Clear();
  430. DataGridViewRow dgvr = new DataGridViewRow();
  431. dgvr.Tag = tag;
  432. foreach (DataGridViewColumn c in this.dataGridView2.Columns)
  433. {
  434. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  435. }
  436. dgvr.Cells[0].Value = imgName;
  437. DataGridViewRow firRow = this.dataGridView1.Rows[0];
  438. object value1 = firRow.Cells[0].Value;//网格
  439. object value2 = firRow.Cells[1].Value;//网格长度
  440. object value3 = firRow.Cells[2].Value;//网格条数
  441. double value2Total = 0;
  442. foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  443. {
  444. value2Total += (double.Parse(Row.Cells[1].Value.ToString()) * double.Parse(Row.Cells[2].Value.ToString()));//网格总长度
  445. }
  446. //double value4Total = 0;
  447. //foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  448. //{
  449. // value4Total += double.Parse(Row.Cells[3].Value.ToString());//交点个数
  450. //}
  451. //if (value4Total == 0)
  452. //{
  453. // MessageBox.Show(PdnResources.GetString("Menu.Nomeasurementresult.text"));
  454. // return;
  455. //}
  456. ////double value4Per = value4Total / this.dataGridView1.Rows.Count;
  457. dgvr.Cells[1].Value = value1;
  458. dgvr.Cells[2].Value = value2Total;
  459. dgvr.Cells[3].Value = value4Total;
  460. decimal M = 1;// this.getGainMultiple();
  461. double small_l = value2Total / (value4Total * (double)M);
  462. //毫米转微米
  463. decimal A = Convert.ToDecimal(small_l * 1);
  464. double[] lengths = {453, 320 , 269, 226, 190, 177, 160, 135, 113, 106,
  465. 95.0, 89.0, 80.0, 67.3, 62.0, 56.6, 53.2, 47.6, 44.3, 40.0, 35.4, 33.6, 31.0,
  466. 28.3, 26.6 , 23.8, 22.2, 20.0, 17.7, 16.8, 14.1, 13.3, 11.9,
  467. 10.0, 8.86, 8.41, 7.98, 7.07, 6.20, 5.95, 5.32, 5.00, 4.43, 4.20, 3.54, 2.97
  468. , 2.66, 2.50, 2.22};
  469. // 差值
  470. decimal differenceNew;
  471. decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)A - 1.22, (double)A - 454)));
  472. int first = 0;
  473. if ((double)A < lengths[lengths.Length - 1])
  474. first = lengths.Length - 1;
  475. else
  476. for (int firstI = 0; firstI < lengths.Length; firstI++)
  477. {
  478. double item = lengths[firstI];
  479. differenceNew = Math.Abs(A - Convert.ToDecimal(item));
  480. if (differenceNew < differenceOld)
  481. {
  482. differenceOld = Math.Abs(A - Convert.ToDecimal(item));
  483. first = firstI;
  484. }
  485. }
  486. string[] valueG = {"00A", "0" , "0.5", "1.0", "1.5", "1.5", "2.0", "2.5", "3.0", "3.0",
  487. "3.5", "3.5", "4.0", "4.5", "4.5", "5.0", "5.0", "5.5", "5.5", "6.0", "6.0", "6.5", "6.5",
  488. "7.0", "7.0" , "7.5", "7.5", "8.0", "8.0", "8.5", "9.0", "9.0", "9.5",
  489. "10.0", "10.0", "10.5", "10.5", "11.0", "11.0", "11.5", "11.5", "12.0", "12.0", "12.5", "13.0", "13.5"
  490. , "13.5", "14.0", "14.0"};
  491. dgvr.Cells[4].Value = valueG[first];
  492. this.dataGridView2.Rows.Add(dgvr);
  493. dataTable.TableName = tag;
  494. foreach (System.Data.DataTable dataTable1 in dataTables)
  495. {
  496. if (dataTable1.TableName.Equals(dataTable.TableName))
  497. {
  498. dataTables.Remove(dataTable1);
  499. break;
  500. }
  501. }
  502. for (int i = 0; i < this.dataGridView2.Columns.Count; i++)
  503. {
  504. dataTable.Columns.Add("" + i);
  505. }
  506. DataRow dataRow = dataTable.NewRow();
  507. dataRow["0"] = imgName;
  508. dataRow["1"] = dgvr.Cells[1].Value;// "网格1";
  509. dataRow["2"] = dgvr.Cells[2].Value;
  510. dataRow["3"] = dgvr.Cells[3].Value;
  511. dataRow["4"] = dgvr.Cells[4].Value;
  512. dataTable.Rows.Add(dataRow);
  513. this.dataTables.Add(dataTable);
  514. if (this.allShow)
  515. AllShow();
  516. this.RefreshDataGridView4();
  517. //保存处理后的图片
  518. double pantographRatio = this.appWorkspace.DocumentWorkspaces[this.selectPicture].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
  519. List<Bitmap> tempBit = new List<Bitmap>();
  520. //Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
  521. //tempBit.Add(originalBit);
  522. //Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  523. //Graphics graphics = Graphics.FromImage(newBit);
  524. //Draw(graphics);
  525. //tempBit.Add(newBit);
  526. foreach (KeyValuePair<string, List<Bitmap>> kv in this.bitCeDingDic)
  527. {
  528. kv.Value[0].Tag = pantographRatio;
  529. kv.Value[1].Tag = pantographRatio;
  530. tempBit.Add(kv.Value[0]);
  531. tempBit.Add(kv.Value[1]);
  532. }
  533. if (bitDic.ContainsKey(tag))
  534. bitDic[tag] = tempBit;
  535. else
  536. bitDic.Add(tag, tempBit);
  537. //中间数据-拼接中间数据
  538. List<List<string>> dataList = new List<List<string>>();
  539. List<string> columnName = new List<string>();
  540. columnName.Add(PdnResources.GetString("Menu.Tools.GridLine.Text"));
  541. columnName.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Lengthofdetectionline.text"));
  542. columnName.Add(PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Nnlines.text"));
  543. columnName.Add(PdnResources.GetString("Menu.Thenumberofsections.text"));
  544. dataList.Add(columnName);
  545. foreach (DataGridViewRow Row in this.dataGridView1.Rows)
  546. {
  547. List<string> strList = new List<string>();
  548. strList.Add(Row.Cells[0].Value.ToString());
  549. strList.Add(Row.Cells[1].Value.ToString());
  550. strList.Add(Row.Cells[2].Value.ToString());
  551. strList.Add(Row.Cells[3].Value.ToString());
  552. dataList.Add(strList);
  553. }
  554. bool isExist = false;//是否已存在进行替换
  555. int modelIndex = -1;//要替换的下标
  556. for (int j = 0; j < tempDataModel.Count; j++)
  557. {
  558. if (tempDataModel[j].tagName.Equals(tag))
  559. {
  560. isExist = true;
  561. modelIndex = j;
  562. break;
  563. }
  564. }
  565. if (isExist && modelIndex > -1)
  566. tempDataModel[modelIndex].dataList = dataList;
  567. else
  568. {
  569. Base.Functionodel.ExportProjectModel newModel = new Base.Functionodel.ExportProjectModel();
  570. newModel.tagName = tag;
  571. newModel.picName = imgName;
  572. newModel.dataList = dataList;
  573. tempDataModel.Add(newModel);
  574. }
  575. }
  576. }
  577. /// <summary>
  578. /// 是否显示晶界
  579. /// </summary>
  580. /// <returns></returns>
  581. protected override Boolean ShowGrainBoundryChecked()
  582. {
  583. return checkBox3_0.Checked;
  584. }
  585. //是否绘制辅助线
  586. protected override bool showGridChecked()
  587. {
  588. return checkBox4.Checked;
  589. }
  590. //是否绘制截点
  591. protected override bool drawGuidePoints()
  592. {
  593. return (imageMat != null && this.checkBox5_0.Checked);
  594. }
  595. //是否显示截点
  596. protected override Boolean drawDisplaySections()//##1
  597. {
  598. return this.checkBox5_0.Checked;
  599. }
  600. //辅助线类型
  601. protected override string[] getTypeNames()
  602. {
  603. return new string[] {
  604. PdnResources.GetString("Menu.Verticalauxiliaryline.text"),
  605. PdnResources.GetString("Menu.Horizontalauxiliaryline.text")};
  606. }
  607. protected override string getTemplateName()
  608. {
  609. return "Template.Manager.item3.GrainSizeCutOff_GBT4296";
  610. }
  611. protected override string getProjectEngineeringName()
  612. {
  613. return "Menu.DedicatedAnalysis.NonferrousMetal.MagnesiumAlloy.Text";
  614. }
  615. protected override string getModelName()
  616. {
  617. return "GrainGBT32461CutOffMethodModel.xml";
  618. }
  619. protected override void SubclassInitialize()
  620. {
  621. InitializeComponent();
  622. InitializeLanguageText();
  623. }
  624. #endregion
  625. private DataGridViewTextBoxColumn Column1;
  626. private DataGridViewTextBoxColumn Column2;
  627. private DataGridViewTextBoxColumn Column3;
  628. private DataGridViewTextBoxColumn Column4;
  629. private DataGridViewTextBoxColumn Column5;
  630. private void MethodCutOffDialog_Load(object sender, EventArgs e)
  631. {
  632. this.button_ApplyToAll.Visible = false;
  633. this.button_SaveAll.Visible = false;
  634. this.btn_Grainboundarytoreproduce.Location = new System.Drawing.Point(912, 20);
  635. this.btn_saveresult.Location = new System.Drawing.Point(993, 20);
  636. object ShowGrainBoundry;
  637. if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界
  638. this.checkBox3_0.Checked = (bool)ShowGrainBoundry;
  639. if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格
  640. this.checkBox4.Checked = (bool)ShowGrainBoundry;
  641. if (GetParamValue1(ParamKey_displaysections, out ShowGrainBoundry))//显示截点
  642. this.checkBox5_0.Checked = (bool)ShowGrainBoundry;
  643. this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  644. this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  645. this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  646. this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  647. this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  648. this.Column1.Name = "Column1";
  649. this.Column1.ReadOnly = true;
  650. //
  651. // Column2
  652. //
  653. this.Column2.Name = "Column2";
  654. this.Column2.ReadOnly = true;
  655. //
  656. // Column3
  657. //
  658. this.Column3.Name = "Column3";
  659. this.Column3.ReadOnly = true;
  660. //
  661. // Column4
  662. //
  663. this.Column4.Name = "Column4";
  664. this.Column4.ReadOnly = true;
  665. //
  666. // Column5
  667. //
  668. this.Column5.Name = "Column5";
  669. this.Column5.ReadOnly = true;
  670. this.Column5.HeaderText = PdnResources.GetString("Menu.Averagegrainsizegrade.text");
  671. this.Column4.HeaderText = PdnResources.GetString("Menu.Numberofgrains.text");
  672. this.Column3.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Gridsize.text") + "(μm)";
  673. this.Column2.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text");
  674. this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text");
  675. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  676. this.Column1,
  677. this.Column2,
  678. this.Column3,
  679. this.Column4,
  680. this.Column5});
  681. this.groupBox_img.Size = new System.Drawing.Size(158, 672);
  682. this.groupBox_review.Size = new System.Drawing.Size(575, 672);
  683. this.groupBox_analysisResult1.Location = new System.Drawing.Point(12, 750);
  684. this.groupBox6groupBox_analysisResult2.Location = new System.Drawing.Point(242, 750);
  685. this.groupBox_report.Location = new System.Drawing.Point(974, 750);
  686. DetailListStringIndex.Add(0);
  687. DetailListStringIndex.Add(1);
  688. DetailListStringIndex.Add(3);
  689. DetailListStringIndex.Add(4/*5*/);//##############
  690. DetailListNotDoubleIndex.Add(0);
  691. DetailListNotDoubleIndex.Add(1);
  692. DetailListNotDoubleIndex.Add(3);
  693. DetailListNotDoubleIndex.Add(4);
  694. IndexChangedFromIndex.Clear();
  695. IndexChangedToIndex.Clear();
  696. IndexChangedFromIndex.Add(2);
  697. IndexChangedFromIndex.Add(3);
  698. IndexChangedToIndex.Add(0, new int[] { 2/*1*/, 0 });//求和
  699. IndexChangedToIndex.Add(1, new int[] { 2/*1*/, 1 });//求和
  700. //IndexChangedToIndex.Add(2, new int[] { 2, 2 });//平均
  701. IndexChangedToIndex.Add(2, new int[] { 3, -1/*0*/ });//级别
  702. }
  703. /// <summary>
  704. /// 计算汇总列表的平均晶粒度级别
  705. /// </summary>
  706. /// <returns></returns>
  707. protected override string getGradeTotalCal(DataGridViewRow dgvr, int digits)
  708. {
  709. double value2Total = double.Parse(dgvr.Cells[0].Value.ToString());
  710. double value4Total = double.Parse(dgvr.Cells[1].Value.ToString());
  711. decimal M = 1;// this.getGainMultiple();
  712. double small_l = value2Total / (value4Total * (double)M);
  713. //毫米转微米
  714. decimal A = Convert.ToDecimal(small_l * 1);
  715. double[] lengths = {453, 320 , 269, 226, 190, 177, 160, 135, 113, 106,
  716. 95.0, 89.0, 80.0, 67.3, 62.0, 56.6, 53.2, 47.6, 44.3, 40.0, 35.4, 33.6, 31.0,
  717. 28.3, 26.6 , 23.8, 22.2, 20.0, 17.7, 16.8, 14.1, 13.3, 11.9,
  718. 10.0, 8.86, 8.41, 7.98, 7.07, 6.20, 5.95, 5.32, 5.00, 4.43, 4.20, 3.54, 2.97
  719. , 2.66, 2.50, 2.22};
  720. // 差值
  721. decimal differenceNew;
  722. decimal differenceOld = Math.Abs(Convert.ToDecimal(Math.Max((double)A - 1.22, (double)A - 454)));
  723. int first = 0;
  724. if ((double)A < lengths[lengths.Length - 1])
  725. first = lengths.Length - 1;
  726. else
  727. for (int firstI = 0; firstI < lengths.Length; firstI++)
  728. {
  729. double item = lengths[firstI];
  730. differenceNew = Math.Abs(A - Convert.ToDecimal(item));
  731. if (differenceNew < differenceOld)
  732. {
  733. differenceOld = Math.Abs(A - Convert.ToDecimal(item));
  734. first = firstI;
  735. }
  736. }
  737. string[] valueG = {"00A", "0" , "0.5", "1.0", "1.5", "1.5", "2.0", "2.5", "3.0", "3.0",
  738. "3.5", "3.5", "4.0", "4.5", "4.5", "5.0", "5.0", "5.5", "5.5", "6.0", "6.0", "6.5", "6.5",
  739. "7.0", "7.0" , "7.5", "7.5", "8.0", "8.0", "8.5", "9.0", "9.0", "9.5",
  740. "10.0", "10.0", "10.5", "10.5", "11.0", "11.0", "11.5", "11.5", "12.0", "12.0", "12.5", "13.0", "13.5"
  741. , "13.5", "14.0", "14.0"};
  742. return valueG[first];
  743. }
  744. /// <summary>
  745. /// 是否显示网格
  746. /// </summary>
  747. /// <param name="sender"></param>
  748. /// <param name="e"></param>
  749. private void checkBox4_CheckedChanged(object sender, EventArgs e)
  750. {
  751. this.documentWorkspace.Refresh();
  752. }
  753. /// <summary>
  754. /// 是否显示截点
  755. /// </summary>
  756. /// <param name="sender"></param>
  757. /// <param name="e"></param>
  758. private void checkBox5_0_CheckedChanged(object sender, EventArgs e)
  759. {
  760. if (!this.checkBox4.Checked)
  761. MessageBox.Show(PdnResources.GetString("Menu.Nogrid.text")+"!");
  762. this.documentWorkspace.Refresh();
  763. }
  764. /// <summary>
  765. /// 是否显示晶界
  766. /// </summary>
  767. /// <param name="sender"></param>
  768. /// <param name="e"></param>
  769. private void checkBox3_0_CheckedChanged(object sender, EventArgs e)
  770. {
  771. if (!showOrimat() && getGrainBoundryChecked() && checkBox3_0.Checked)
  772. {
  773. this.documentWorkspace.PhaseModels[1].choise = true;
  774. }
  775. else
  776. {
  777. this.documentWorkspace.PhaseModels[1].choise = false;
  778. }
  779. this.documentWorkspace.Refresh();
  780. }
  781. /// <summary>
  782. /// 设置截点样式
  783. /// </summary>
  784. /// <param name="sender"></param>
  785. /// <param name="e"></param>
  786. private void button10_Click(object sender, EventArgs e)
  787. {//###
  788. GrainSizeStandard.IntegrationClass.GrainSurveyPointStyleSettingDialog grainSurveyPointStyleSettingDialog = new GrainSizeStandard.IntegrationClass.GrainSurveyPointStyleSettingDialog();//###
  789. grainSurveyPointStyleSettingDialog.StartPosition = FormStartPosition.CenterScreen;
  790. grainSurveyPointStyleSettingDialog.ShowDialog(this);
  791. }
  792. /// <summary>
  793. /// 鼠标按下
  794. /// </summary>
  795. /// <param name="drawArea"></param>
  796. /// <param name="e"></param>
  797. protected override void OnMouseDown(object sender, MouseEventArgs e)
  798. {
  799. if (this.documentWorkspace.CompositionSurface == null)
  800. return;
  801. // 换算后的点
  802. PointF point1 = documentWorkspace.GetScalePoint(e.Location);
  803. if (point1.X <= this.documentWorkspace.CompositionSurface.Width
  804. && point1.X >= 0
  805. && point1.Y >= 0
  806. && point1.Y <= this.documentWorkspace.CompositionSurface.Height)
  807. {
  808. RectangleF rectangleF = new RectangleF();
  809. // 复合辅助线
  810. int add = GSSClass.GuideClass.getAddOfRStyle(point1, this.comboBox1.SelectedItem, out rectangleF);
  811. if (add == 0 && GSSClass.styleClass.PointKb > 0)
  812. rectangleF = GSSClass.GuideClass.guideModel.RectangleFLine;
  813. //手动添加截点
  814. if (this.documentWorkspace.ActiveTool == Annotation.Enum.DrawToolType.InclusionNoEffect && GSSClass.styleClass.OnMouseDownNext(point1, sender, e))
  815. GSSClass.styleClass.OnMouseDownFirst(point1, rectangleF, GSSClass.standardModel.linePointList, sender, e);
  816. }
  817. if (GSSClass.styleClass.PointKb == 0)
  818. {
  819. //辅助线缩放
  820. GSSClass.GuideClass.OnMouseDown(point1, sender, e);
  821. //辅助线移动
  822. base.OnMouseDown(sender, e);//##
  823. }
  824. ////手动删除截点或取消添加截点
  825. //GSSClass.styleClass.OnMouseDownNext(point1, sender, e);
  826. }
  827. private int dataTable1sTagInc = 0;
  828. /// <summary>
  829. /// 保存测定结果
  830. /// </summary>
  831. /// <param name="sender"></param>
  832. /// <param name="e"></param>
  833. private void button1_Click(object sender, EventArgs e)
  834. {
  835. if (this.imageMat == null)
  836. {
  837. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  838. return;
  839. }
  840. if (this.comboBox1.SelectedItem == null || PdnResources.GetString("Menu.Pleaseselecttheauxiliarylineused.text").Equals(this.comboBox1.SelectedItem))
  841. {
  842. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectauxiliaryline.text") + "!");
  843. return;
  844. }
  845. DataTable dataTable = new DataTable();
  846. //this.dataGridView111114.Rows.Clear();
  847. DataGridViewRow dgvr = new DataGridViewRow();
  848. dataTable1sTagInc++;
  849. dgvr.Tag = dataTable1sTagInc + "";
  850. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  851. {
  852. dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell);
  853. }
  854. dgvr.Cells[0].Value = this.comboBox1.SelectedItem;
  855. dgvr.Cells[1].Value = GSSClass.GuideClass.LineLength;
  856. dgvr.Cells[2].Value = GSSClass.GuideClass.LineDec;
  857. double countPoints = GSSClass.styleClass.styleModel.getCountPoints();
  858. dgvr.Cells[3].Value = countPoints;
  859. this.dataGridView1.Rows.Add(dgvr);
  860. dataTable.TableName = (string)dgvr.Tag;
  861. for (int i = 0; i < this.dataGridView1.Columns.Count; i++)
  862. {
  863. dataTable.Columns.Add("" + i);
  864. }
  865. DataRow dataRow = dataTable.NewRow();
  866. dataRow["0"] = dgvr.Cells[0].Value;
  867. dataRow["1"] = dgvr.Cells[1].Value;
  868. dataRow["2"] = dgvr.Cells[2].Value;
  869. dataRow["3"] = countPoints;
  870. dataTable.Rows.Add(dataRow);
  871. this.dataTable1s.Add(dataTable);
  872. //保存处理后的图片
  873. List<Bitmap> tempBit = new List<Bitmap>();
  874. Bitmap originalBit = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(this.imageMat);// this.bitmap;
  875. tempBit.Add(originalBit);
  876. Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
  877. Graphics graphics = Graphics.FromImage(newBit);
  878. if (this.documentWorkspace.PhaseModels[0].choise && this.documentWorkspace.PhaseModels[0].mat != null)
  879. {
  880. Mat targetMat = this.documentWorkspace.PhaseModels[0].mat;
  881. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  882. }
  883. if (this.documentWorkspace.PhaseModels[1].choise && this.documentWorkspace.PhaseModels[1].mat != null)
  884. {
  885. Mat targetMat = this.documentWorkspace.PhaseModels[1].mat;
  886. graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(targetMat), 0, 0, targetMat.Width, targetMat.Height);
  887. }
  888. graphics.SmoothingMode = SmoothingMode.AntiAlias;
  889. drawSubclass/*Draw*/(graphics);
  890. tempBit.Add(newBit);
  891. if (bitCeDingDic.ContainsKey((string)dgvr.Tag))
  892. bitCeDingDic[(string)dgvr.Tag] = tempBit;
  893. else
  894. bitCeDingDic.Add((string)dgvr.Tag, tempBit);
  895. }
  896. /// <summary>
  897. /// 删除测定结果
  898. /// </summary>
  899. /// <param name="sender"></param>
  900. /// <param name="e"></param>
  901. private void button4_Click(object sender, EventArgs e)
  902. {
  903. if (this.dataGridView1.Rows.Count > 0)
  904. {
  905. if (this.dataGridView1.SelectedRows.Count > 0)
  906. {
  907. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  908. if (dr == DialogResult.OK)
  909. {
  910. DataGridViewRow gridViewRow = this.dataGridView1.SelectedRows[0];
  911. int selectIndex = gridViewRow.Index;
  912. foreach (var dataTable in this.dataTable1s)
  913. {
  914. if (dataTable.TableName.Equals(gridViewRow.Tag))
  915. {
  916. this.dataTable1s.Remove(dataTable);
  917. break;
  918. }
  919. }
  920. if (bitCeDingDic.ContainsKey((string)gridViewRow.Tag))
  921. bitCeDingDic.Remove((string)gridViewRow.Tag);
  922. this.dataGridView1.Rows.RemoveAt(selectIndex);
  923. //RefreshDataGridView1();
  924. }
  925. }
  926. else
  927. {
  928. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!");
  929. }
  930. }
  931. else
  932. {
  933. MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!");
  934. }
  935. }
  936. private void AllShow()
  937. {
  938. this.dataGridView2.Rows.Clear();
  939. for (int i = 0; i < this.dataTables.Count; i++)
  940. {
  941. DataGridViewRow dgvr = new DataGridViewRow();
  942. dgvr.Tag = this.dataTables[i].TableName;
  943. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  944. {
  945. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  946. }
  947. for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
  948. {
  949. //if (c > 2 && c < 4)
  950. // dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[0][c]), Convert.ToInt32(this.numericUpDown1_0.Value)).ToString();
  951. //else
  952. dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
  953. }
  954. this.dataGridView2.Rows.Add(dgvr);
  955. }
  956. }
  957. private void button6_0_Click(object sender, EventArgs e)
  958. {
  959. if (this.imageMat != null)
  960. {
  961. //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
  962. GSSClass.styleClass.PointKb = 1;
  963. }
  964. else
  965. {
  966. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  967. }
  968. }
  969. /// <summary>
  970. /// 1截点添加
  971. /// </summary>
  972. /// <param name="sender"></param>
  973. /// <param name="e"></param>
  974. private void button7_0_Click(object sender, EventArgs e)
  975. {
  976. if (this.imageMat != null)
  977. {
  978. //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
  979. GSSClass.styleClass.PointKb = 2;
  980. }
  981. else
  982. {
  983. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  984. }
  985. }
  986. private void button8_Click(object sender, EventArgs e)
  987. {
  988. if (this.imageMat != null)
  989. {
  990. //MessageBox.Show(PdnResources.GetString("Menu.ftbuttontoaddainterceptadd.Text")+"!");
  991. GSSClass.styleClass.PointKb = 3;
  992. }
  993. else
  994. {
  995. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!");
  996. }
  997. }
  998. }
  999. }