MethodADialog.cs 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  1. using Metis.ParameterSet;
  2. using OpenCvSharp;
  3. using PaintDotNet.Base;
  4. using PaintDotNet.Base.CommTool;
  5. using PaintDotNet.Data.Param;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Drawing.Drawing2D;
  11. using System.Linq;
  12. using System.Windows.Forms;
  13. //using OpenCvSharp.Extensions;
  14. namespace PaintDotNet.DedicatedAnalysis.PetroleumGeology.SYT6103
  15. {
  16. internal class MethodADialog : PetroleumGeologyStandardDialog
  17. {
  18. /// <summary>
  19. /// 测定结果暂存
  20. /// </summary>
  21. private List<DataTable> dataTable1s = new List<DataTable>();
  22. /// <summary>
  23. /// 储存点击保存结果后的所有原图与分析图
  24. /// </summary>
  25. private Dictionary<string, List<Bitmap>> bitCeDingDic = new Dictionary<string, List<Bitmap>>();
  26. // <summary>
  27. /// 保存窗口参数 range
  28. /// </summary>
  29. private GrainSizeAnalysisModel analysisModel;
  30. private const string ParamKey_Report = "report";//报告设置
  31. private const string ParamKey_SortMicron = "sortMicron";//分类微米
  32. private const string ParamKey_SortDiam = "sortDiam";//分类直径
  33. private const string ParamKey_LongDiam = "longDiam";//长径
  34. private const string ParamKey_ShortDiam = "shortDiam";//短径
  35. private const string ParamKey_AvgDiam = "avgDiam";//平均径
  36. private const string ParamKey_EqualDiam = "equalDiam";//等效圆直径
  37. private const string ParamKey_Threshold = "threshold";//喉道阈值
  38. private const string ParamKey_Number = "number";//显示孔隙编号
  39. private const string ParamKey_NumberFontSize = "numberFontSize";//编号字体大小
  40. private const string ParamKey_NumberColour = "numberColour";//编号颜色
  41. private const string ParamKey_Diameter = "diameter";//显示孔隙直径
  42. private const string ParamKey_DiameterFontSize = "diameterFontSize";//直径字体大小
  43. private const string ParamKey_DiameterColour = "diameterColour";//直径颜色
  44. private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数
  45. #region 组件
  46. private DataGridViewTextBoxColumn Column11;
  47. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
  48. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
  49. private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
  50. private GroupBox groupBox1;
  51. private GroupBox groupBox2;
  52. private Label label1;
  53. private Label label8;
  54. private RadioButton radioButton5;
  55. private RadioButton radioButton6;
  56. private RadioButton radioButton3;
  57. private RadioButton radioButton4;
  58. private RadioButton radioButton7;
  59. private RadioButton radioButton8;
  60. private Label label3;
  61. private Label label4;
  62. private TextBox textBox5;
  63. private Button button2;
  64. private DataGridView dataGridView1;
  65. private GroupBox groupBox3;
  66. private TextBox textBox1;
  67. private CheckBox checkBox2;
  68. private Label label5;
  69. private CheckBox checkBox1;
  70. private Label label7;
  71. private Panel panel3;
  72. private TextBox textBox2;
  73. private Label label9;
  74. private Label label6;
  75. private Panel panel1;
  76. private GroupBox groupBox5;
  77. private GroupBox groupBox4;
  78. private Button button3;
  79. /// <summary>
  80. /// 是否脚本运行
  81. /// </summary>
  82. private Boolean initScriptValues = false;
  83. #endregion 组件
  84. /// <summary>
  85. /// 构造函数
  86. /// </summary>
  87. /// <param name="appWorkspace"></param>
  88. /// <param name="dialogText"></param>
  89. public MethodADialog(AppWorkspace appWorkspace, string dialogText, PdnMenuItem menuItem) : base(appWorkspace, dialogText, false, menuItem)
  90. {
  91. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  92. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  93. this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
  94. foreach (var item in this.analysisModel.ListParam)
  95. item.setValue();
  96. //如果是脚本执行,将参数带入
  97. if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
  98. {
  99. this.initScriptValues = true;//ScriptAutomatic
  100. //Boolean initScriptValues = true;
  101. ////在这里反射出对应功能的参数类
  102. string className = InvariantData.path_Action + ".Action" + menuId;
  103. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  104. foreach (Args arg in param.Lists)
  105. {
  106. Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
  107. if (param1.value != null)
  108. arg.Value = param1.value;
  109. getValue(arg.key, arg.Value);
  110. }
  111. appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
  112. }
  113. else
  114. {//读取上次关闭窗口时保存的参数
  115. GetListParamModel();
  116. }
  117. }
  118. #region 初始化组件
  119. private void InitializeLanguageText()
  120. {
  121. this.checkBox1.Text = PdnResources.GetString("Menu.Displaypmeter.text");
  122. this.label5.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";
  123. this.checkBox2.Text = PdnResources.GetString("Menu.Displayporediameter.text");
  124. this.label6.Text = PdnResources.GetString("Menu.color.text") + ":";
  125. this.label9.Text = PdnResources.GetString("Menu.Fontsize.text") + ":";
  126. this.label7.Text = PdnResources.GetString("Menu.color.text") + ":";
  127. this.groupBox3.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
  128. this.label3.Text = PdnResources.GetString("Menu.Throatthreshold.text") + ":";
  129. this.button3.Text = PdnResources.GetString("Menu.Manualsegmentation.text");
  130. this.button2.Text = PdnResources.GetString("Menu.Automaticsegmentation.text");
  131. this.groupBox2.Text = PdnResources.GetString("Menu.Throatsegmentation.text");
  132. this.label8.Text = PdnResources.GetString("Menu.Classificationmethod.text") + ":";
  133. this.radioButton7.Text = PdnResources.GetString("Menu.Accordingtotheonofmicrons.text");
  134. this.radioButton8.Text = PdnResources.GetString("Menu.Accordingtotheclassificationofmicrons.text");
  135. this.label1.Text = PdnResources.GetString("Menu.Classificationofdiameter.text") + ":";
  136. this.radioButton3.Text = PdnResources.GetString("Menu.Equivalentcirculardiameter.text");
  137. this.radioButton6.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.majoraxis.text");
  138. this.radioButton4.Text = PdnResources.GetString("Menu.Theaveragediameter.text");
  139. this.radioButton5.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.short trail.text");
  140. this.groupBox1.Text = PdnResources.GetString("Menu.paramssettings.text");
  141. this.dataGridViewTextBoxColumn4.HeaderText = PdnResources.GetString("Menu.Gradeclassification.text");
  142. this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Apparentdiameterofparticle.text");
  143. this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Thethroatwidth.text");
  144. this.Column11.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.holearea.text");
  145. }
  146. private void InitializeComponent()
  147. {
  148. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  149. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
  150. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
  151. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
  152. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
  153. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  154. this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  155. this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  156. this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  157. this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  158. this.groupBox1 = new System.Windows.Forms.GroupBox();
  159. this.groupBox5 = new System.Windows.Forms.GroupBox();
  160. this.radioButton5 = new System.Windows.Forms.RadioButton();
  161. this.radioButton4 = new System.Windows.Forms.RadioButton();
  162. this.radioButton6 = new System.Windows.Forms.RadioButton();
  163. this.radioButton3 = new System.Windows.Forms.RadioButton();
  164. this.label1 = new System.Windows.Forms.Label();
  165. this.groupBox4 = new System.Windows.Forms.GroupBox();
  166. this.radioButton8 = new System.Windows.Forms.RadioButton();
  167. this.radioButton7 = new System.Windows.Forms.RadioButton();
  168. this.label8 = new System.Windows.Forms.Label();
  169. this.groupBox2 = new System.Windows.Forms.GroupBox();
  170. this.button2 = new System.Windows.Forms.Button();
  171. this.button3 = new System.Windows.Forms.Button();
  172. this.label4 = new System.Windows.Forms.Label();
  173. this.textBox5 = new System.Windows.Forms.TextBox();
  174. this.label3 = new System.Windows.Forms.Label();
  175. this.groupBox3 = new System.Windows.Forms.GroupBox();
  176. this.label7 = new System.Windows.Forms.Label();
  177. this.panel3 = new System.Windows.Forms.Panel();
  178. this.textBox2 = new System.Windows.Forms.TextBox();
  179. this.label9 = new System.Windows.Forms.Label();
  180. this.label6 = new System.Windows.Forms.Label();
  181. this.panel1 = new System.Windows.Forms.Panel();
  182. this.textBox1 = new System.Windows.Forms.TextBox();
  183. this.checkBox2 = new System.Windows.Forms.CheckBox();
  184. this.label5 = new System.Windows.Forms.Label();
  185. this.checkBox1 = new System.Windows.Forms.CheckBox();
  186. this.groupBox_report.SuspendLayout();
  187. this.groupBox_analysisResult1.SuspendLayout();
  188. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit();
  189. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  190. this.groupBox1.SuspendLayout();
  191. this.groupBox5.SuspendLayout();
  192. this.groupBox4.SuspendLayout();
  193. this.groupBox2.SuspendLayout();
  194. this.groupBox3.SuspendLayout();
  195. this.SuspendLayout();
  196. //
  197. // dataGridView1
  198. //
  199. this.dataGridView1.AllowUserToAddRows = false;
  200. this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
  201. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  202. dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
  203. dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  204. dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
  205. dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  206. dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  207. dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  208. this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
  209. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  210. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  211. this.Column11,
  212. this.dataGridViewTextBoxColumn1,
  213. this.dataGridViewTextBoxColumn2,
  214. this.dataGridViewTextBoxColumn4});
  215. this.dataGridView1.Location = new System.Drawing.Point(6, 36);
  216. this.dataGridView1.MultiSelect = false;
  217. this.dataGridView1.Name = "dataGridView1";
  218. this.dataGridView1.ReadOnly = true;
  219. this.dataGridView1.RowHeadersVisible = false;
  220. this.dataGridView1.RowTemplate.Height = 23;
  221. this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  222. this.dataGridView1.Size = new System.Drawing.Size(341, 103);
  223. this.dataGridView1.TabIndex = 29;
  224. //
  225. // Column11
  226. //
  227. dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  228. this.Column11.DefaultCellStyle = dataGridViewCellStyle2;
  229. this.Column11.Name = "Column11";
  230. this.Column11.ReadOnly = true;
  231. this.Column11.Width = 66;
  232. //
  233. // dataGridViewTextBoxColumn1
  234. //
  235. dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  236. this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle3;
  237. this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
  238. this.dataGridViewTextBoxColumn1.ReadOnly = true;
  239. //
  240. // dataGridViewTextBoxColumn2
  241. //
  242. dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  243. this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle4;
  244. this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
  245. this.dataGridViewTextBoxColumn2.ReadOnly = true;
  246. //
  247. // dataGridViewTextBoxColumn4
  248. //
  249. dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  250. this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle5;
  251. this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
  252. this.dataGridViewTextBoxColumn4.ReadOnly = true;
  253. this.dataGridViewTextBoxColumn4.Width = 72;
  254. //
  255. // groupBox1
  256. //
  257. this.groupBox1.Controls.Add(this.groupBox5);
  258. this.groupBox1.Controls.Add(this.label1);
  259. this.groupBox1.Controls.Add(this.groupBox4);
  260. this.groupBox1.Controls.Add(this.label8);
  261. this.groupBox1.Location = new System.Drawing.Point(179, 365);
  262. this.groupBox1.Name = "groupBox1";
  263. this.groupBox1.Size = new System.Drawing.Size(360, 96);
  264. this.groupBox1.TabIndex = 41;
  265. this.groupBox1.TabStop = false;
  266. //
  267. // groupBox5
  268. //
  269. this.groupBox5.Controls.Add(this.radioButton5);
  270. this.groupBox5.Controls.Add(this.radioButton4);
  271. this.groupBox5.Controls.Add(this.radioButton6);
  272. this.groupBox5.Controls.Add(this.radioButton3);
  273. this.groupBox5.Location = new System.Drawing.Point(79, 50);
  274. this.groupBox5.Name = "groupBox5";
  275. this.groupBox5.Size = new System.Drawing.Size(269, 40);
  276. this.groupBox5.TabIndex = 26;
  277. this.groupBox5.TabStop = false;
  278. //
  279. // radioButton5
  280. //
  281. this.radioButton5.AutoSize = true;
  282. this.radioButton5.Location = new System.Drawing.Point(65, 14);
  283. this.radioButton5.Name = "radioButton5";
  284. this.radioButton5.Size = new System.Drawing.Size(14, 13);
  285. this.radioButton5.TabIndex = 29;
  286. this.radioButton5.UseVisualStyleBackColor = true;
  287. this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
  288. //
  289. // radioButton4
  290. //
  291. this.radioButton4.AutoSize = true;
  292. this.radioButton4.Location = new System.Drawing.Point(118, 14);
  293. this.radioButton4.Name = "radioButton4";
  294. this.radioButton4.Size = new System.Drawing.Size(14, 13);
  295. this.radioButton4.TabIndex = 26;
  296. this.radioButton4.UseVisualStyleBackColor = true;
  297. this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
  298. //
  299. // radioButton6
  300. //
  301. this.radioButton6.AutoSize = true;
  302. this.radioButton6.Checked = true;
  303. this.radioButton6.Location = new System.Drawing.Point(9, 14);
  304. this.radioButton6.Name = "radioButton6";
  305. this.radioButton6.Size = new System.Drawing.Size(14, 13);
  306. this.radioButton6.TabIndex = 28;
  307. this.radioButton6.TabStop = true;
  308. this.radioButton6.UseVisualStyleBackColor = true;
  309. this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
  310. //
  311. // radioButton3
  312. //
  313. this.radioButton3.AutoSize = true;
  314. this.radioButton3.Location = new System.Drawing.Point(183, 14);
  315. this.radioButton3.Name = "radioButton3";
  316. this.radioButton3.Size = new System.Drawing.Size(14, 13);
  317. this.radioButton3.TabIndex = 27;
  318. this.radioButton3.UseVisualStyleBackColor = true;
  319. this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
  320. //
  321. // label1
  322. //
  323. this.label1.AutoSize = true;
  324. this.label1.Location = new System.Drawing.Point(6, 66);
  325. this.label1.Name = "label1";
  326. this.label1.Size = new System.Drawing.Size(0, 12);
  327. this.label1.TabIndex = 23;
  328. //
  329. // groupBox4
  330. //
  331. this.groupBox4.Controls.Add(this.radioButton8);
  332. this.groupBox4.Controls.Add(this.radioButton7);
  333. this.groupBox4.Location = new System.Drawing.Point(79, 10);
  334. this.groupBox4.Name = "groupBox4";
  335. this.groupBox4.Size = new System.Drawing.Size(179, 40);
  336. this.groupBox4.TabIndex = 0;
  337. this.groupBox4.TabStop = false;
  338. //
  339. // radioButton8
  340. //
  341. this.radioButton8.AutoSize = true;
  342. this.radioButton8.Checked = true;
  343. this.radioButton8.Location = new System.Drawing.Point(6, 15);
  344. this.radioButton8.Name = "radioButton8";
  345. this.radioButton8.Size = new System.Drawing.Size(14, 13);
  346. this.radioButton8.TabIndex = 24;
  347. this.radioButton8.TabStop = true;
  348. this.radioButton8.UseVisualStyleBackColor = true;
  349. this.radioButton8.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged);
  350. //
  351. // radioButton7
  352. //
  353. this.radioButton7.AutoSize = true;
  354. this.radioButton7.Location = new System.Drawing.Point(89, 15);
  355. this.radioButton7.Name = "radioButton7";
  356. this.radioButton7.Size = new System.Drawing.Size(14, 13);
  357. this.radioButton7.TabIndex = 25;
  358. this.radioButton7.UseVisualStyleBackColor = true;
  359. this.radioButton7.CheckedChanged += new System.EventHandler(this.radioButton7_CheckedChanged);
  360. //
  361. // label8
  362. //
  363. this.label8.AutoSize = true;
  364. this.label8.Location = new System.Drawing.Point(6, 30);
  365. this.label8.Name = "label8";
  366. this.label8.Size = new System.Drawing.Size(0, 12);
  367. this.label8.TabIndex = 22;
  368. //
  369. // groupBox2
  370. //
  371. this.groupBox2.Controls.Add(this.button2);
  372. this.groupBox2.Controls.Add(this.button3);
  373. this.groupBox2.Controls.Add(this.label4);
  374. this.groupBox2.Controls.Add(this.textBox5);
  375. this.groupBox2.Controls.Add(this.label3);
  376. this.groupBox2.Location = new System.Drawing.Point(179, 467);
  377. this.groupBox2.Name = "groupBox2";
  378. this.groupBox2.Size = new System.Drawing.Size(360, 53);
  379. this.groupBox2.TabIndex = 42;
  380. this.groupBox2.TabStop = false;
  381. //
  382. // button2
  383. //
  384. this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right;
  385. this.button2.Location = new System.Drawing.Point(183, 19);
  386. this.button2.Name = "button2";
  387. this.button2.Size = new System.Drawing.Size(75, 23);
  388. this.button2.TabIndex = 36;
  389. this.button2.UseVisualStyleBackColor = true;
  390. this.button2.Click += new System.EventHandler(this.button2_Click);
  391. //
  392. // button3
  393. //
  394. this.button3.Anchor = System.Windows.Forms.AnchorStyles.Right;
  395. this.button3.Location = new System.Drawing.Point(271, 19);
  396. this.button3.Name = "button3";
  397. this.button3.Size = new System.Drawing.Size(75, 23);
  398. this.button3.TabIndex = 35;
  399. this.button3.UseVisualStyleBackColor = true;
  400. this.button3.Click += new System.EventHandler(this.button3_Click);
  401. //
  402. // label4
  403. //
  404. this.label4.AutoSize = true;
  405. this.label4.Location = new System.Drawing.Point(114, 25);
  406. this.label4.Name = "label4";
  407. this.label4.Size = new System.Drawing.Size(23, 12);
  408. this.label4.TabIndex = 30;
  409. this.label4.Text = "μm";
  410. //
  411. // textBox5
  412. //
  413. this.textBox5.Location = new System.Drawing.Point(77, 21);
  414. this.textBox5.Name = "textBox5";
  415. this.textBox5.Size = new System.Drawing.Size(31, 21);
  416. this.textBox5.TabIndex = 34;
  417. this.textBox5.Text = "10";
  418. //
  419. // label3
  420. //
  421. this.label3.AutoSize = true;
  422. this.label3.Location = new System.Drawing.Point(6, 25);
  423. this.label3.Name = "label3";
  424. this.label3.Size = new System.Drawing.Size(0, 12);
  425. this.label3.TabIndex = 30;
  426. //
  427. // groupBox3
  428. //
  429. this.groupBox3.Controls.Add(this.label7);
  430. this.groupBox3.Controls.Add(this.panel3);
  431. this.groupBox3.Controls.Add(this.textBox2);
  432. this.groupBox3.Controls.Add(this.label9);
  433. this.groupBox3.Controls.Add(this.label6);
  434. this.groupBox3.Controls.Add(this.panel1);
  435. this.groupBox3.Controls.Add(this.textBox1);
  436. this.groupBox3.Controls.Add(this.checkBox2);
  437. this.groupBox3.Controls.Add(this.label5);
  438. this.groupBox3.Controls.Add(this.checkBox1);
  439. this.groupBox3.Location = new System.Drawing.Point(179, 524);
  440. this.groupBox3.Name = "groupBox3";
  441. this.groupBox3.Size = new System.Drawing.Size(360, 82);
  442. this.groupBox3.TabIndex = 42;
  443. this.groupBox3.TabStop = false;
  444. //
  445. // label7
  446. //
  447. this.label7.AutoSize = true;
  448. this.label7.Location = new System.Drawing.Point(227, 54);
  449. this.label7.Name = "label7";
  450. this.label7.Size = new System.Drawing.Size(0, 12);
  451. this.label7.TabIndex = 44;
  452. //
  453. // panel3
  454. //
  455. this.panel3.BackColor = System.Drawing.Color.Gray;
  456. this.panel3.Location = new System.Drawing.Point(274, 49);
  457. this.panel3.Name = "panel3";
  458. this.panel3.Size = new System.Drawing.Size(72, 21);
  459. this.panel3.TabIndex = 43;
  460. this.panel3.Click += new System.EventHandler(this.panel2_Click);
  461. //
  462. // textBox2
  463. //
  464. this.textBox2.Location = new System.Drawing.Point(166, 49);
  465. this.textBox2.Name = "textBox2";
  466. this.textBox2.Size = new System.Drawing.Size(47, 21);
  467. this.textBox2.TabIndex = 42;
  468. this.textBox2.Text = "6";
  469. this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
  470. //
  471. // label9
  472. //
  473. this.label9.AutoSize = true;
  474. this.label9.Location = new System.Drawing.Point(119, 54);
  475. this.label9.Name = "label9";
  476. this.label9.Size = new System.Drawing.Size(0, 12);
  477. this.label9.TabIndex = 41;
  478. //
  479. // label6
  480. //
  481. this.label6.AutoSize = true;
  482. this.label6.Location = new System.Drawing.Point(227, 28);
  483. this.label6.Name = "label6";
  484. this.label6.Size = new System.Drawing.Size(0, 12);
  485. this.label6.TabIndex = 40;
  486. //
  487. // panel1
  488. //
  489. this.panel1.BackColor = System.Drawing.Color.Black;
  490. this.panel1.Location = new System.Drawing.Point(274, 23);
  491. this.panel1.Name = "panel1";
  492. this.panel1.Size = new System.Drawing.Size(72, 21);
  493. this.panel1.TabIndex = 39;
  494. this.panel1.Click += new System.EventHandler(this.panel1_Click);
  495. //
  496. // textBox1
  497. //
  498. this.textBox1.Location = new System.Drawing.Point(166, 23);
  499. this.textBox1.Name = "textBox1";
  500. this.textBox1.Size = new System.Drawing.Size(47, 21);
  501. this.textBox1.TabIndex = 38;
  502. this.textBox1.Text = "6";
  503. this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
  504. //
  505. // checkBox2
  506. //
  507. this.checkBox2.Anchor = System.Windows.Forms.AnchorStyles.Right;
  508. this.checkBox2.AutoSize = true;
  509. this.checkBox2.Location = new System.Drawing.Point(95, 52);
  510. this.checkBox2.Name = "checkBox2";
  511. this.checkBox2.Size = new System.Drawing.Size(15, 14);
  512. this.checkBox2.TabIndex = 25;
  513. this.checkBox2.UseVisualStyleBackColor = true;
  514. this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
  515. //
  516. // label5
  517. //
  518. this.label5.AutoSize = true;
  519. this.label5.Location = new System.Drawing.Point(119, 28);
  520. this.label5.Name = "label5";
  521. this.label5.Size = new System.Drawing.Size(0, 12);
  522. this.label5.TabIndex = 37;
  523. //
  524. // checkBox1
  525. //
  526. this.checkBox1.Anchor = System.Windows.Forms.AnchorStyles.Right;
  527. this.checkBox1.AutoSize = true;
  528. this.checkBox1.Location = new System.Drawing.Point(95, 27);
  529. this.checkBox1.Name = "checkBox1";
  530. this.checkBox1.Size = new System.Drawing.Size(15, 14);
  531. this.checkBox1.TabIndex = 24;
  532. this.checkBox1.UseVisualStyleBackColor = true;
  533. this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged);
  534. //
  535. // MethodADialog
  536. //
  537. this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
  538. this.ClientSize = new System.Drawing.Size(1127, 830);
  539. this.Controls.Add(this.groupBox3);
  540. this.Controls.Add(this.groupBox2);
  541. this.Controls.Add(this.groupBox1);
  542. this.Name = "MethodADialog";
  543. this.Text = "SYT6103-2004";
  544. this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MethodADialog_FormClosing);
  545. this.Load += new System.EventHandler(this.MethodADialog_Load);
  546. this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0);
  547. this.Controls.SetChildIndex(this.groupBox_img, 0);
  548. this.Controls.SetChildIndex(this.groupBox_review, 0);
  549. this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0);
  550. this.Controls.SetChildIndex(this.groupBox_report, 0);
  551. this.Controls.SetChildIndex(this.groupBox1, 0);
  552. this.Controls.SetChildIndex(this.groupBox2, 0);
  553. this.Controls.SetChildIndex(this.groupBox3, 0);
  554. this.groupBox_report.ResumeLayout(false);
  555. this.groupBox_report.PerformLayout();
  556. this.groupBox_analysisResult1.ResumeLayout(false);
  557. ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit();
  558. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  559. this.groupBox1.ResumeLayout(false);
  560. this.groupBox1.PerformLayout();
  561. this.groupBox5.ResumeLayout(false);
  562. this.groupBox5.PerformLayout();
  563. this.groupBox4.ResumeLayout(false);
  564. this.groupBox4.PerformLayout();
  565. this.groupBox2.ResumeLayout(false);
  566. this.groupBox2.PerformLayout();
  567. this.groupBox3.ResumeLayout(false);
  568. this.groupBox3.PerformLayout();
  569. this.ResumeLayout(false);
  570. }
  571. #endregion 初始化组件
  572. #region 需继承方法
  573. protected override void drawSubclass(Graphics graphics)
  574. {
  575. if (showOrimat())
  576. return;
  577. //if (matGeology != null && matGeology.Width > 0 && matGeology.Height > 0)
  578. //{
  579. // graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(matGeology), 0, 0);
  580. //}
  581. base.drawSubclass(graphics);
  582. if (lstAttribute.Count > 0/* && holeNumberVisible*/)
  583. {
  584. float text1Font;
  585. if (float.TryParse(this.textBox1.Text.ToString(), out text1Font))
  586. { }
  587. else
  588. {
  589. text1Font = 6;
  590. }
  591. float text2Font;
  592. if (float.TryParse(this.textBox2.Text.ToString(), out text2Font))
  593. { }
  594. else
  595. {
  596. text2Font = 6;
  597. }
  598. //foreach (var attribute in lstAttribute)
  599. //{
  600. // if (attribute[7] == 27)
  601. // {
  602. // graphics.DrawString(/*attribute[0] + */"" + attribute[7], myFont, new SolidBrush(/*this.panel1.BackColor*/Color.Green), (float)attribute[1] - 3, (float)attribute[2] - 3);
  603. // }
  604. // else
  605. // graphics.DrawString(/*attribute[0] + */"" + attribute[7], myFont, bush, (float)attribute[1] - 3, (float)attribute[2] - 3);
  606. //}
  607. if (this.checkBox1.Checked && this.checkBox2.Checked)
  608. {
  609. foreach (var attribute in lstAttribute)
  610. {
  611. graphics.DrawString("" + attribute[7] + ":", new Font("宋体", text1Font), new SolidBrush(this.panel1.BackColor), new PointF((float)attribute[1] - 3, (float)attribute[2] - 3));
  612. SizeF sizeF = graphics.MeasureString("" + attribute[7] + ":", new Font("宋体", text1Font));
  613. graphics.DrawString("" + Math.Round(this.getHolesD(attribute), Convert.ToInt32(this.numericUpDown1_0.Value)) + "", new Font("宋体", text2Font), new SolidBrush(this.panel3.BackColor), new PointF((float)attribute[1] - 2 - 3 + sizeF.Width, (float)attribute[2] - 3));
  614. }
  615. }
  616. else if (!this.checkBox1.Checked && this.checkBox2.Checked)
  617. {
  618. foreach (var attribute in lstAttribute)
  619. {
  620. graphics.DrawString("" + Math.Round(this.getHolesD(attribute), Convert.ToInt32(this.numericUpDown1_0.Value)), new Font("宋体", text2Font), new SolidBrush(this.panel3.BackColor), new PointF((float)attribute[1] - 3, (float)attribute[2] - 3));
  621. }
  622. }
  623. else if (this.checkBox1.Checked && !this.checkBox2.Checked)
  624. {
  625. foreach (var attribute in lstAttribute)
  626. {
  627. graphics.DrawString("" + attribute[7] + "", new Font("宋体", text1Font), new SolidBrush(this.panel1.BackColor), new PointF((float)attribute[1] - 3, (float)attribute[2] - 3));
  628. }
  629. }
  630. }
  631. }
  632. protected override void refreshWhileImgChanged()
  633. {
  634. if (this.dataGridView1.Rows.Count > 0)
  635. {
  636. //foreach (DataGridViewRow gridViewRow in this.dataGridView1.Rows)
  637. //{
  638. // foreach (var dataTable in this.dataTable1s)
  639. // {
  640. // if (dataTable.TableName.Equals(gridViewRow.Tag))
  641. // {
  642. // this.dataTable1s.Remove(dataTable);
  643. // break;
  644. // }
  645. // }
  646. // if (bitCeDingDic.ContainsKey((string)gridViewRow.Tag))
  647. // bitCeDingDic.Remove((string)gridViewRow.Tag);
  648. //}
  649. this.dataGridView1.Rows.Clear();
  650. }
  651. //this.checkBox1.Checked = false;
  652. //this.checkBox2.Checked = false;
  653. }
  654. /// <summary>
  655. /// 获取孔隙直径计算类型 1长径 2短径 3平均径 4等效圆直径 5φ值
  656. /// </summary>
  657. /// <returns></returns>
  658. protected override int getHolesType()
  659. {
  660. if (this.radioButton7.Checked)
  661. return 5;
  662. if (this.radioButton6.Checked)
  663. return 1;
  664. if (this.radioButton5.Checked)
  665. return 2;
  666. if (this.radioButton4.Checked)
  667. return 3;
  668. if (this.radioButton3.Checked)
  669. return 4;
  670. return 4;
  671. }
  672. protected override string getTemplateName()
  673. {
  674. return "Template.Manager.item3.PetroleumGeology_SYT6103";
  675. }
  676. protected override string getProjectEngineeringName()
  677. {
  678. return "Menu.DedicatedAnalysis.PetroleumGeology.PetroleumGeologySon.Text";// "Menu.DedicatedAnalysis.NonferrousMetal.CopperAlloy.Text";//######################
  679. }
  680. protected override void SubclassInitialize()
  681. {
  682. InitializeComponent();
  683. InitializeLanguageText();
  684. }
  685. #endregion
  686. private void AllShow()
  687. {
  688. this.dataGridView2.Rows.Clear();
  689. for (int i = 0; i < this.dataTables.Count; i++)
  690. {
  691. DataGridViewRow dgvr = new DataGridViewRow();
  692. dgvr.Tag = this.dataTables[i].TableName;
  693. foreach (DataGridViewColumn Column in this.dataGridView2.Columns)
  694. {
  695. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  696. }
  697. for (int c = 0; c < this.dataTables[i].Columns.Count; c++)
  698. {
  699. //if (c > 2 && c < 4)
  700. // dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[0][c]), Convert.ToInt32(this.numericUpDown1_0.Value)).ToString();
  701. //else
  702. dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString();
  703. }
  704. this.dataGridView2.Rows.Add(dgvr);
  705. }
  706. }
  707. /// <summary>
  708. /// 自动分割
  709. /// </summary>
  710. /// <param name="sender"></param>
  711. /// <param name="e"></param>
  712. private void button2_Click(object sender, EventArgs e)
  713. {
  714. double thresValue;
  715. if (!double.TryParse(this.textBox5.Text.ToString(), out thresValue) || thresValue < 0)
  716. {
  717. MessageBox.Show(PdnResources.GetString("Menu.holdformatinputisincorrectpleasereenter.text"));
  718. return;
  719. }
  720. autoSegmentAction((int)thresValue/*10*/);
  721. }
  722. /// <summary>
  723. /// 显示孔隙编号
  724. /// </summary>
  725. /// <param name="sender"></param>
  726. /// <param name="e"></param>
  727. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  728. {
  729. controlHoleNumberVisible(checkBox1.Checked);
  730. }
  731. private void checkBox2_CheckedChanged(object sender, EventArgs e)
  732. {
  733. this.documentWorkspace.Refresh();
  734. }
  735. private void textBox1_TextChanged(object sender, EventArgs e)
  736. {
  737. float text1Font;
  738. if (float.TryParse(this.textBox1.Text.ToString(), out text1Font))
  739. {
  740. this.documentWorkspace.Refresh();
  741. }
  742. }
  743. private void textBox2_TextChanged(object sender, EventArgs e)
  744. {
  745. float text2Font;
  746. if (float.TryParse(this.textBox2.Text.ToString(), out text2Font))
  747. {
  748. this.documentWorkspace.Refresh();
  749. }
  750. }
  751. private void button3_Click(object sender, EventArgs e)
  752. {
  753. menuSegmentAction((Button)sender);
  754. }
  755. private void panel1_Click(object sender, EventArgs e)
  756. {
  757. this.panelColor_Click(sender, e);
  758. }
  759. private void panel2_Click(object sender, EventArgs e)
  760. {
  761. this.panelColor_Click(sender, e);
  762. }
  763. private void radioButton8_CheckedChanged(object sender, EventArgs e)
  764. {
  765. this.documentWorkspace.Refresh();
  766. if (radioButton7.Checked)
  767. {
  768. this.radioButton6.Enabled = false;
  769. this.radioButton5.Enabled = false;
  770. this.radioButton4.Enabled = false;
  771. this.radioButton3.Enabled = false;
  772. }
  773. else
  774. {
  775. this.radioButton6.Enabled = true;
  776. this.radioButton5.Enabled = true;
  777. this.radioButton4.Enabled = true;
  778. this.radioButton3.Enabled = true;
  779. }
  780. }
  781. private void radioButton7_CheckedChanged(object sender, EventArgs e)
  782. {
  783. this.documentWorkspace.Refresh();
  784. if (radioButton7.Checked)
  785. {
  786. this.radioButton6.Enabled = false;
  787. this.radioButton5.Enabled = false;
  788. this.radioButton4.Enabled = false;
  789. this.radioButton3.Enabled = false;
  790. }
  791. else
  792. {
  793. this.radioButton6.Enabled = true;
  794. this.radioButton5.Enabled = true;
  795. this.radioButton4.Enabled = true;
  796. this.radioButton3.Enabled = true;
  797. }
  798. }
  799. private void radioButton6_CheckedChanged(object sender, EventArgs e)
  800. {
  801. this.documentWorkspace.Refresh();
  802. }
  803. private void radioButton5_CheckedChanged(object sender, EventArgs e)
  804. {
  805. this.documentWorkspace.Refresh();
  806. }
  807. private void radioButton4_CheckedChanged(object sender, EventArgs e)
  808. {
  809. this.documentWorkspace.Refresh();
  810. }
  811. private void radioButton3_CheckedChanged(object sender, EventArgs e)
  812. {
  813. this.documentWorkspace.Refresh();
  814. }
  815. private void MethodADialog_Load(object sender, EventArgs e)
  816. {
  817. }
  818. #region 参数保存及提取
  819. /// <summary>
  820. /// 保存参数的key,value和type
  821. /// </summary>
  822. /// <param name="param_key"></param>
  823. /// <param name="param_value"></param>
  824. /// <param name="param_type"></param>
  825. private void saveParamValue(string param_key, string param_value, int param_type)
  826. {
  827. bool foundItem = false;
  828. foreach (var item in this.analysisModel.ListParam)
  829. {
  830. if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
  831. {
  832. item.param_value = param_value;
  833. item.setValue();
  834. foundItem = true;
  835. break;
  836. }
  837. }
  838. if (!foundItem)
  839. {
  840. GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
  841. analysisItem.menuId = this.menuId;
  842. analysisItem.param_key = param_key;
  843. analysisItem.param_type = param_type;
  844. analysisItem.param_value = param_value;
  845. analysisItem.setValue();
  846. this.analysisModel.ListParam.Add(analysisItem);
  847. }
  848. }
  849. /// <summary>
  850. /// 保存界面中的参数到model
  851. /// </summary>
  852. private void saveDialogParamValues()
  853. {
  854. saveParamValue(ParamKey_Report, checkBox_generateReport_opensetting.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//报告设置
  855. saveParamValue(ParamKey_SortMicron, radioButton8.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//分类微米
  856. saveParamValue(ParamKey_SortDiam, radioButton7.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//分类直径
  857. saveParamValue(ParamKey_LongDiam, radioButton6.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//长径
  858. saveParamValue(ParamKey_ShortDiam, radioButton5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//短径
  859. saveParamValue(ParamKey_AvgDiam, radioButton4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//平均径
  860. saveParamValue(ParamKey_EqualDiam, radioButton3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//等效圆直径
  861. saveParamValue(ParamKey_Threshold, textBox5.Text, (int)Base.Dtryt.ItemString);//喉道阈值
  862. saveParamValue(ParamKey_Number, checkBox1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示孔隙编号
  863. saveParamValue(ParamKey_NumberFontSize, textBox1.Text, (int)Base.Dtryt.ItemString);//编号字体大小
  864. saveParamValue(ParamKey_NumberColour, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//编号颜色
  865. saveParamValue(ParamKey_Diameter, checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示孔隙直径
  866. saveParamValue(ParamKey_DiameterFontSize, textBox2.Text, (int)Base.Dtryt.ItemString);//直径字体大小
  867. saveParamValue(ParamKey_DiameterColour, panel3.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//直径颜色
  868. saveParamValue(ParamKey_DecimalPlace, numericUpDown1_0.Value.ToString(), (int)Base.Dtryt.Decimal);//保留小数位数
  869. }
  870. /// <summary>
  871. /// 获取保存的参数
  872. /// </summary>
  873. private void GetListParamModel()
  874. {
  875. if (this.analysisModel != null)
  876. {
  877. for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
  878. {
  879. switch (this.analysisModel.ListParam[i].param_key)
  880. {
  881. case ParamKey_Report:
  882. checkBox_generateReport_opensetting.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  883. break;
  884. case ParamKey_SortMicron:
  885. radioButton8.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  886. break;
  887. case ParamKey_SortDiam:
  888. radioButton7.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  889. break;
  890. case ParamKey_LongDiam:
  891. radioButton6.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  892. break;
  893. case ParamKey_ShortDiam:
  894. radioButton5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  895. break;
  896. case ParamKey_AvgDiam:
  897. radioButton4.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  898. break;
  899. case ParamKey_EqualDiam:
  900. radioButton3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  901. break;
  902. case ParamKey_Threshold:
  903. textBox5.Text = (string)this.analysisModel.ListParam[i].value;
  904. break;
  905. case ParamKey_Number:
  906. checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  907. break;
  908. case ParamKey_NumberFontSize:
  909. textBox1.Text = (string)this.analysisModel.ListParam[i].value;
  910. break;
  911. case ParamKey_NumberColour:
  912. panel1.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  913. break;
  914. case ParamKey_Diameter:
  915. checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
  916. break;
  917. case ParamKey_DiameterFontSize:
  918. textBox2.Text = (string)this.analysisModel.ListParam[i].value;
  919. break;
  920. case ParamKey_DiameterColour:
  921. panel3.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value);
  922. break;
  923. case ParamKey_DecimalPlace:
  924. numericUpDown1_0.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value);
  925. break;
  926. }
  927. }
  928. }
  929. }
  930. #endregion
  931. private void MethodADialog_FormClosing(object sender, FormClosingEventArgs e)
  932. {
  933. this.saveDialogParamValues();
  934. //xml保存路径
  935. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml";
  936. GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer<GrainSizeAnalysisModel>(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
  937. foreach (var analysisItem in this.analysisModel.ListParam)
  938. {
  939. bool foundItem = false;
  940. foreach (var item in analysisModelXml.ListParam)
  941. {
  942. if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
  943. {
  944. item.param_value = analysisItem.param_value;
  945. foundItem = true;
  946. break;
  947. }
  948. }
  949. if (!foundItem)
  950. analysisModelXml.ListParam.Add(analysisItem.cloneModel());
  951. }
  952. //按路径和名称保存xml文件
  953. string userInfoXml = XmlSerializeHelper.XmlSerialize<GrainSizeAnalysisModel>(analysisModelXml);
  954. //保存xml
  955. FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
  956. }
  957. #region [脚本相关]
  958. private void getValue(string key, object value)
  959. {
  960. switch (key)
  961. {
  962. case "parameter1":
  963. if ((int)value == 0)
  964. {
  965. radioButton8.Checked = true;
  966. }
  967. else {
  968. radioButton7.Checked = true;
  969. }
  970. break;
  971. case "parameter2":
  972. if ((int)value == 0)
  973. {
  974. radioButton6.Checked = true;
  975. }
  976. else if ((int)value == 1) {
  977. radioButton6.Checked = true;
  978. }
  979. else if ((int)value == 2)
  980. {
  981. radioButton4.Checked = true;
  982. }
  983. else
  984. {
  985. radioButton3.Checked = true;
  986. }
  987. break;
  988. case "parameter3":
  989. textBox5.Text = value.ToString();
  990. break;
  991. case "parameter4":
  992. checkBox1.Checked = Convert.ToBoolean(value);
  993. break;
  994. case "parameter5":
  995. textBox1.Text = value.ToString();
  996. break;
  997. case "parameter6":
  998. panel1.BackColor = Color.FromArgb((int)value);
  999. break;
  1000. case "parameter7":
  1001. checkBox2.Checked = Convert.ToBoolean(value);
  1002. break;
  1003. case "parameter8":
  1004. textBox2.Text = value.ToString();
  1005. break;
  1006. case "parameter9":
  1007. panel3.BackColor = Color.FromArgb((int)value);
  1008. break;
  1009. case "OpenWhileExportReport":
  1010. checkBox_generateReport_opensetting.Checked = Convert.ToBoolean(value);
  1011. break;
  1012. case "CalculatorDecimalDigits":
  1013. numericUpDown1_0.Value = Convert.ToDecimal(value);
  1014. break;
  1015. }
  1016. }
  1017. #endregion
  1018. #region [脚本录制]
  1019. protected override void getScriptRecording()
  1020. {
  1021. string className = InvariantData.path_Action + ".Action" + menuId;
  1022. ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
  1023. List<Args> args = param.Lists;
  1024. foreach (var item in args)
  1025. {
  1026. item.value = setScriptRecording(item.key);
  1027. }
  1028. //找出二值相关参数 进行赋值
  1029. List<Args> isNullList = args.Where(m => m.value == null).ToList();
  1030. foreach (var item in isNullList)
  1031. {
  1032. item.value = binaryClass.setScriptRecording(item.key);
  1033. }
  1034. appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
  1035. }
  1036. private object setScriptRecording(string key)
  1037. {
  1038. object value = null;
  1039. switch (key)
  1040. {
  1041. case "parameter1":
  1042. if (radioButton8.Checked)
  1043. {
  1044. value = 0;
  1045. }
  1046. else
  1047. {
  1048. value = 1;
  1049. }
  1050. break;
  1051. case "parameter2":
  1052. if (radioButton6.Checked)
  1053. {
  1054. value = 0;
  1055. }
  1056. else if (radioButton6.Checked)
  1057. {
  1058. value = 1;
  1059. }
  1060. else if (radioButton4.Checked)
  1061. {
  1062. value = 2;
  1063. }
  1064. else
  1065. {
  1066. value = 3;
  1067. }
  1068. break;
  1069. case "parameter3":
  1070. value = textBox5.Text;
  1071. break;
  1072. case "parameter4":
  1073. value = checkBox1.Checked;
  1074. break;
  1075. case "parameter5":
  1076. value = textBox1.Text;
  1077. break;
  1078. case "parameter6":
  1079. value = panel1.BackColor.ToArgb();
  1080. break;
  1081. case "parameter7":
  1082. value = checkBox2.Checked;
  1083. break;
  1084. case "parameter8":
  1085. value = textBox2.Text;
  1086. break;
  1087. case "parameter9":
  1088. value = panel3.BackColor.ToArgb();
  1089. break;
  1090. case "OpenWhileExportReport":
  1091. value = checkBox_generateReport_opensetting.Checked;
  1092. break;
  1093. case "CalculatorDecimalDigits":
  1094. value = numericUpDown1_0.Value;
  1095. break;
  1096. case "ExportResults":
  1097. value = false;
  1098. break;
  1099. case "ExportReports":
  1100. value = false;
  1101. break;
  1102. case "ExportProjects":
  1103. value = false;
  1104. break;
  1105. }
  1106. return value;
  1107. }
  1108. #endregion
  1109. }
  1110. }