MethodADialog.cs 53 KB

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