using Metis.ParameterSet; using OpenCvSharp; using PaintDotNet.Base; using PaintDotNet.Base.CommTool; using PaintDotNet.Data.Param; using System; using System.Collections.Generic; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Windows.Forms; //using OpenCvSharp.Extensions; namespace PaintDotNet.DedicatedAnalysis.PetroleumGeology.SYT6103 { internal class MethodADialog : PetroleumGeologyStandardDialog { /// /// 测定结果暂存 /// private List dataTable1s = new List(); /// /// 储存点击保存结果后的所有原图与分析图 /// private Dictionary> bitCeDingDic = new Dictionary>(); // /// 保存窗口参数 range /// private GrainSizeAnalysisModel analysisModel; private const string ParamKey_Report = "report";//报告设置 private const string ParamKey_SortMicron = "sortMicron";//分类微米 private const string ParamKey_SortDiam = "sortDiam";//分类直径 private const string ParamKey_LongDiam = "longDiam";//长径 private const string ParamKey_ShortDiam = "shortDiam";//短径 private const string ParamKey_AvgDiam = "avgDiam";//平均径 private const string ParamKey_EqualDiam = "equalDiam";//等效圆直径 private const string ParamKey_Threshold = "threshold";//喉道阈值 private const string ParamKey_Number = "number";//显示孔隙编号 private const string ParamKey_NumberFontSize = "numberFontSize";//编号字体大小 private const string ParamKey_NumberColour = "numberColour";//编号颜色 private const string ParamKey_Diameter = "diameter";//显示孔隙直径 private const string ParamKey_DiameterFontSize = "diameterFontSize";//直径字体大小 private const string ParamKey_DiameterColour = "diameterColour";//直径颜色 private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数 #region 组件 private DataGridViewTextBoxColumn Column11; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; private GroupBox groupBox1; private GroupBox groupBox2; private Label label1; private Label label8; private RadioButton radioButton5; private RadioButton radioButton6; private RadioButton radioButton3; private RadioButton radioButton4; private RadioButton radioButton7; private RadioButton radioButton8; private Label label3; private Label label4; private TextBox textBox5; private Button button2; private DataGridView dataGridView1; private GroupBox groupBox3; private TextBox textBox1; private CheckBox checkBox2; private Label label5; private CheckBox checkBox1; private Label label7; private Panel panel3; private TextBox textBox2; private Label label9; private Label label6; private Panel panel1; private GroupBox groupBox5; private GroupBox groupBox4; private Button button3; /// /// 是否脚本运行 /// private Boolean initScriptValues = false; #endregion 组件 /// /// 构造函数 /// /// /// public MethodADialog(AppWorkspace appWorkspace, string dialogText, PdnMenuItem menuItem) : base(appWorkspace, dialogText, false, menuItem) { string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml"; GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open)); this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId); foreach (var item in this.analysisModel.ListParam) item.setValue(); //如果是脚本执行,将参数带入 if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null) { this.initScriptValues = true;//ScriptAutomatic //Boolean initScriptValues = true; ////在这里反射出对应功能的参数类 string className = InvariantData.path_Action + ".Action" + menuId; ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className); foreach (Args arg in param.Lists) { Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key)); if (param1.value != null) arg.Value = param1.value; getValue(arg.key, arg.Value); } appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数 } else {//读取上次关闭窗口时保存的参数 GetListParamModel(); } } #region 初始化组件 private void InitializeLanguageText() { this.checkBox1.Text = PdnResources.GetString("Menu.Displaypmeter.text"); this.label5.Text = PdnResources.GetString("Menu.Fontsize.text") + ":"; this.checkBox2.Text = PdnResources.GetString("Menu.Displayporediameter.text"); this.label6.Text = PdnResources.GetString("Menu.color.text") + ":"; this.label9.Text = PdnResources.GetString("Menu.Fontsize.text") + ":"; this.label7.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox3.Text = PdnResources.GetString("Menu.Displayparamssettings.text"); this.label3.Text = PdnResources.GetString("Menu.Throatthreshold.text") + ":"; this.button3.Text = PdnResources.GetString("Menu.Manualsegmentation.text"); this.button2.Text = PdnResources.GetString("Menu.Automaticsegmentation.text"); this.groupBox2.Text = PdnResources.GetString("Menu.Throatsegmentation.text"); this.label8.Text = PdnResources.GetString("Menu.Classificationmethod.text") + ":"; this.radioButton7.Text = PdnResources.GetString("Menu.Accordingtotheonofmicrons.text"); this.radioButton8.Text = PdnResources.GetString("Menu.Accordingtotheclassificationofmicrons.text"); this.label1.Text = PdnResources.GetString("Menu.Classificationofdiameter.text") + ":"; this.radioButton3.Text = PdnResources.GetString("Menu.Equivalentcirculardiameter.text"); this.radioButton6.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.majoraxis.text"); this.radioButton4.Text = PdnResources.GetString("Menu.Theaveragediameter.text"); this.radioButton5.Text = PdnResources.GetString("Menu.Generalanalysis.Particlestatistics.short trail.text"); this.groupBox1.Text = PdnResources.GetString("Menu.paramssettings.text"); this.dataGridViewTextBoxColumn4.HeaderText = PdnResources.GetString("Menu.Gradeclassification.text"); this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Apparentdiameterofparticle.text"); this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Thethroatwidth.text"); this.Column11.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.holearea.text"); } private void InitializeComponent() { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.radioButton5 = new System.Windows.Forms.RadioButton(); this.radioButton4 = new System.Windows.Forms.RadioButton(); this.radioButton6 = new System.Windows.Forms.RadioButton(); this.radioButton3 = new System.Windows.Forms.RadioButton(); this.label1 = new System.Windows.Forms.Label(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.radioButton8 = new System.Windows.Forms.RadioButton(); this.radioButton7 = new System.Windows.Forms.RadioButton(); this.label8 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.button2 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.label4 = new System.Windows.Forms.Label(); this.textBox5 = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.label7 = new System.Windows.Forms.Label(); this.panel3 = new System.Windows.Forms.Panel(); this.textBox2 = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); this.textBox1 = new System.Windows.Forms.TextBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.label5 = new System.Windows.Forms.Label(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.groupBox_report.SuspendLayout(); this.groupBox_analysisResult1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.groupBox1.SuspendLayout(); this.groupBox5.SuspendLayout(); this.groupBox4.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); this.SuspendLayout(); // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column11, this.dataGridViewTextBoxColumn1, this.dataGridViewTextBoxColumn2, this.dataGridViewTextBoxColumn4}); this.dataGridView1.Location = new System.Drawing.Point(6, 36); this.dataGridView1.MultiSelect = false; this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.ReadOnly = true; this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.RowTemplate.Height = 23; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView1.Size = new System.Drawing.Size(341, 103); this.dataGridView1.TabIndex = 29; // // Column11 // dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column11.DefaultCellStyle = dataGridViewCellStyle2; this.Column11.Name = "Column11"; this.Column11.ReadOnly = true; this.Column11.Width = 66; // // dataGridViewTextBoxColumn1 // dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.dataGridViewTextBoxColumn1.DefaultCellStyle = dataGridViewCellStyle3; this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; this.dataGridViewTextBoxColumn1.ReadOnly = true; // // dataGridViewTextBoxColumn2 // dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; this.dataGridViewTextBoxColumn2.ReadOnly = true; // // dataGridViewTextBoxColumn4 // dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle5; this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4"; this.dataGridViewTextBoxColumn4.ReadOnly = true; this.dataGridViewTextBoxColumn4.Width = 72; // // groupBox1 // this.groupBox1.Controls.Add(this.groupBox5); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.groupBox4); this.groupBox1.Controls.Add(this.label8); this.groupBox1.Location = new System.Drawing.Point(179, 365); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(360, 96); this.groupBox1.TabIndex = 41; this.groupBox1.TabStop = false; // // groupBox5 // this.groupBox5.Controls.Add(this.radioButton5); this.groupBox5.Controls.Add(this.radioButton4); this.groupBox5.Controls.Add(this.radioButton6); this.groupBox5.Controls.Add(this.radioButton3); this.groupBox5.Location = new System.Drawing.Point(79, 50); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(269, 40); this.groupBox5.TabIndex = 26; this.groupBox5.TabStop = false; // // radioButton5 // this.radioButton5.AutoSize = true; this.radioButton5.Location = new System.Drawing.Point(65, 14); this.radioButton5.Name = "radioButton5"; this.radioButton5.Size = new System.Drawing.Size(14, 13); this.radioButton5.TabIndex = 29; this.radioButton5.UseVisualStyleBackColor = true; this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged); // // radioButton4 // this.radioButton4.AutoSize = true; this.radioButton4.Location = new System.Drawing.Point(118, 14); this.radioButton4.Name = "radioButton4"; this.radioButton4.Size = new System.Drawing.Size(14, 13); this.radioButton4.TabIndex = 26; this.radioButton4.UseVisualStyleBackColor = true; this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged); // // radioButton6 // this.radioButton6.AutoSize = true; this.radioButton6.Checked = true; this.radioButton6.Location = new System.Drawing.Point(9, 14); this.radioButton6.Name = "radioButton6"; this.radioButton6.Size = new System.Drawing.Size(14, 13); this.radioButton6.TabIndex = 28; this.radioButton6.TabStop = true; this.radioButton6.UseVisualStyleBackColor = true; this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged); // // radioButton3 // this.radioButton3.AutoSize = true; this.radioButton3.Location = new System.Drawing.Point(183, 14); this.radioButton3.Name = "radioButton3"; this.radioButton3.Size = new System.Drawing.Size(14, 13); this.radioButton3.TabIndex = 27; this.radioButton3.UseVisualStyleBackColor = true; this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(6, 66); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 23; // // groupBox4 // this.groupBox4.Controls.Add(this.radioButton8); this.groupBox4.Controls.Add(this.radioButton7); this.groupBox4.Location = new System.Drawing.Point(79, 10); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(179, 40); this.groupBox4.TabIndex = 0; this.groupBox4.TabStop = false; // // radioButton8 // this.radioButton8.AutoSize = true; this.radioButton8.Checked = true; this.radioButton8.Location = new System.Drawing.Point(6, 15); this.radioButton8.Name = "radioButton8"; this.radioButton8.Size = new System.Drawing.Size(14, 13); this.radioButton8.TabIndex = 24; this.radioButton8.TabStop = true; this.radioButton8.UseVisualStyleBackColor = true; this.radioButton8.CheckedChanged += new System.EventHandler(this.radioButton8_CheckedChanged); // // radioButton7 // this.radioButton7.AutoSize = true; this.radioButton7.Location = new System.Drawing.Point(89, 15); this.radioButton7.Name = "radioButton7"; this.radioButton7.Size = new System.Drawing.Size(14, 13); this.radioButton7.TabIndex = 25; this.radioButton7.UseVisualStyleBackColor = true; this.radioButton7.CheckedChanged += new System.EventHandler(this.radioButton7_CheckedChanged); // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(6, 30); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(0, 12); this.label8.TabIndex = 22; // // groupBox2 // this.groupBox2.Controls.Add(this.button2); this.groupBox2.Controls.Add(this.button3); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.textBox5); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Location = new System.Drawing.Point(179, 467); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(360, 53); this.groupBox2.TabIndex = 42; this.groupBox2.TabStop = false; // // button2 // this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button2.Location = new System.Drawing.Point(183, 19); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 36; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // button3 // this.button3.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button3.Location = new System.Drawing.Point(271, 19); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(75, 23); this.button3.TabIndex = 35; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(114, 25); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(23, 12); this.label4.TabIndex = 30; this.label4.Text = "μm"; // // textBox5 // this.textBox5.Location = new System.Drawing.Point(77, 21); this.textBox5.Name = "textBox5"; this.textBox5.Size = new System.Drawing.Size(31, 21); this.textBox5.TabIndex = 34; this.textBox5.Text = "10"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(6, 25); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(0, 12); this.label3.TabIndex = 30; // // groupBox3 // this.groupBox3.Controls.Add(this.label7); this.groupBox3.Controls.Add(this.panel3); this.groupBox3.Controls.Add(this.textBox2); this.groupBox3.Controls.Add(this.label9); this.groupBox3.Controls.Add(this.label6); this.groupBox3.Controls.Add(this.panel1); this.groupBox3.Controls.Add(this.textBox1); this.groupBox3.Controls.Add(this.checkBox2); this.groupBox3.Controls.Add(this.label5); this.groupBox3.Controls.Add(this.checkBox1); this.groupBox3.Location = new System.Drawing.Point(179, 524); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(360, 82); this.groupBox3.TabIndex = 42; this.groupBox3.TabStop = false; // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(227, 54); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(0, 12); this.label7.TabIndex = 44; // // panel3 // this.panel3.BackColor = System.Drawing.Color.Gray; this.panel3.Location = new System.Drawing.Point(274, 49); this.panel3.Name = "panel3"; this.panel3.Size = new System.Drawing.Size(72, 21); this.panel3.TabIndex = 43; this.panel3.Click += new System.EventHandler(this.panel2_Click); // // textBox2 // this.textBox2.Location = new System.Drawing.Point(166, 49); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(47, 21); this.textBox2.TabIndex = 42; this.textBox2.Text = "6"; this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); // // label9 // this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(119, 54); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(0, 12); this.label9.TabIndex = 41; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(227, 28); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(0, 12); this.label6.TabIndex = 40; // // panel1 // this.panel1.BackColor = System.Drawing.Color.Black; this.panel1.Location = new System.Drawing.Point(274, 23); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(72, 21); this.panel1.TabIndex = 39; this.panel1.Click += new System.EventHandler(this.panel1_Click); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(166, 23); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(47, 21); this.textBox1.TabIndex = 38; this.textBox1.Text = "6"; this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); // // checkBox2 // this.checkBox2.Anchor = System.Windows.Forms.AnchorStyles.Right; this.checkBox2.AutoSize = true; this.checkBox2.Location = new System.Drawing.Point(95, 52); this.checkBox2.Name = "checkBox2"; this.checkBox2.Size = new System.Drawing.Size(15, 14); this.checkBox2.TabIndex = 25; this.checkBox2.UseVisualStyleBackColor = true; this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged); // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(119, 28); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(0, 12); this.label5.TabIndex = 37; // // checkBox1 // this.checkBox1.Anchor = System.Windows.Forms.AnchorStyles.Right; this.checkBox1.AutoSize = true; this.checkBox1.Location = new System.Drawing.Point(95, 27); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(15, 14); this.checkBox1.TabIndex = 24; this.checkBox1.UseVisualStyleBackColor = true; this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); // // MethodADialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(1127, 830); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Name = "MethodADialog"; this.Text = "SYT6103-2004"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MethodADialog_FormClosing); this.Load += new System.EventHandler(this.MethodADialog_Load); this.Controls.SetChildIndex(this.groupBox6groupBox_analysisResult2, 0); this.Controls.SetChildIndex(this.groupBox_img, 0); this.Controls.SetChildIndex(this.groupBox_review, 0); this.Controls.SetChildIndex(this.groupBox_analysisResult1, 0); this.Controls.SetChildIndex(this.groupBox_report, 0); this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox3, 0); this.groupBox_report.ResumeLayout(false); this.groupBox_report.PerformLayout(); this.groupBox_analysisResult1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1_0)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox5.ResumeLayout(false); this.groupBox5.PerformLayout(); this.groupBox4.ResumeLayout(false); this.groupBox4.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); this.ResumeLayout(false); } #endregion 初始化组件 #region 需继承方法 protected override void drawSubclass(Graphics graphics) { if (showOrimat()) return; //if (matGeology != null && matGeology.Width > 0 && matGeology.Height > 0) //{ // graphics.DrawImage(OpenCvSharp.Extensions.BitmapConverter.ToBitmap(matGeology), 0, 0); //} base.drawSubclass(graphics); if (lstAttribute.Count > 0/* && holeNumberVisible*/) { float text1Font; if (float.TryParse(this.textBox1.Text.ToString(), out text1Font)) { } else { text1Font = 6; } float text2Font; if (float.TryParse(this.textBox2.Text.ToString(), out text2Font)) { } else { text2Font = 6; } //foreach (var attribute in lstAttribute) //{ // if (attribute[7] == 27) // { // graphics.DrawString(/*attribute[0] + */"" + attribute[7], myFont, new SolidBrush(/*this.panel1.BackColor*/Color.Green), (float)attribute[1] - 3, (float)attribute[2] - 3); // } // else // graphics.DrawString(/*attribute[0] + */"" + attribute[7], myFont, bush, (float)attribute[1] - 3, (float)attribute[2] - 3); //} if (this.checkBox1.Checked && this.checkBox2.Checked) { foreach (var attribute in lstAttribute) { graphics.DrawString("" + attribute[7] + ":", new Font("宋体", text1Font), new SolidBrush(this.panel1.BackColor), new PointF((float)attribute[1] - 3, (float)attribute[2] - 3)); SizeF sizeF = graphics.MeasureString("" + attribute[7] + ":", new Font("宋体", text1Font)); 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)); } } else if (!this.checkBox1.Checked && this.checkBox2.Checked) { foreach (var attribute in lstAttribute) { 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)); } } else if (this.checkBox1.Checked && !this.checkBox2.Checked) { foreach (var attribute in lstAttribute) { graphics.DrawString("" + attribute[7] + "", new Font("宋体", text1Font), new SolidBrush(this.panel1.BackColor), new PointF((float)attribute[1] - 3, (float)attribute[2] - 3)); } } } } protected override void refreshWhileImgChanged() { if (this.dataGridView1.Rows.Count > 0) { //foreach (DataGridViewRow gridViewRow in this.dataGridView1.Rows) //{ // foreach (var dataTable in this.dataTable1s) // { // if (dataTable.TableName.Equals(gridViewRow.Tag)) // { // this.dataTable1s.Remove(dataTable); // break; // } // } // if (bitCeDingDic.ContainsKey((string)gridViewRow.Tag)) // bitCeDingDic.Remove((string)gridViewRow.Tag); //} this.dataGridView1.Rows.Clear(); } //this.checkBox1.Checked = false; //this.checkBox2.Checked = false; } /// /// 获取孔隙直径计算类型 1长径 2短径 3平均径 4等效圆直径 5φ值 /// /// protected override int getHolesType() { if (this.radioButton7.Checked) return 5; if (this.radioButton6.Checked) return 1; if (this.radioButton5.Checked) return 2; if (this.radioButton4.Checked) return 3; if (this.radioButton3.Checked) return 4; return 4; } protected override string getTemplateName() { return "Template.Manager.item3.PetroleumGeology_SYT6103"; } protected override string getProjectEngineeringName() { return "Menu.DedicatedAnalysis.PetroleumGeology.PetroleumGeologySon.Text";// "Menu.DedicatedAnalysis.NonferrousMetal.CopperAlloy.Text";//###################### } protected override void SubclassInitialize() { InitializeComponent(); InitializeLanguageText(); } #endregion private void AllShow() { this.dataGridView2.Rows.Clear(); for (int i = 0; i < this.dataTables.Count; i++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = this.dataTables[i].TableName; foreach (DataGridViewColumn Column in this.dataGridView2.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < this.dataTables[i].Columns.Count; c++) { //if (c > 2 && c < 4) // dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[0][c]), Convert.ToInt32(this.numericUpDown1_0.Value)).ToString(); //else dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString(); } this.dataGridView2.Rows.Add(dgvr); } } /// /// 自动分割 /// /// /// private void button2_Click(object sender, EventArgs e) { double thresValue; if (!double.TryParse(this.textBox5.Text.ToString(), out thresValue) || thresValue < 0) { MessageBox.Show(PdnResources.GetString("Menu.holdformatinputisincorrectpleasereenter.text")); return; } autoSegmentAction((int)thresValue/*10*/); } /// /// 显示孔隙编号 /// /// /// private void checkBox1_CheckedChanged(object sender, EventArgs e) { controlHoleNumberVisible(checkBox1.Checked); } private void checkBox2_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } private void textBox1_TextChanged(object sender, EventArgs e) { float text1Font; if (float.TryParse(this.textBox1.Text.ToString(), out text1Font)) { this.documentWorkspace.Refresh(); } } private void textBox2_TextChanged(object sender, EventArgs e) { float text2Font; if (float.TryParse(this.textBox2.Text.ToString(), out text2Font)) { this.documentWorkspace.Refresh(); } } private void button3_Click(object sender, EventArgs e) { menuSegmentAction((Button)sender); } private void panel1_Click(object sender, EventArgs e) { this.panelColor_Click(sender, e); } private void panel2_Click(object sender, EventArgs e) { this.panelColor_Click(sender, e); } private void radioButton8_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); if (radioButton7.Checked) { this.radioButton6.Enabled = false; this.radioButton5.Enabled = false; this.radioButton4.Enabled = false; this.radioButton3.Enabled = false; } else { this.radioButton6.Enabled = true; this.radioButton5.Enabled = true; this.radioButton4.Enabled = true; this.radioButton3.Enabled = true; } } private void radioButton7_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); if (radioButton7.Checked) { this.radioButton6.Enabled = false; this.radioButton5.Enabled = false; this.radioButton4.Enabled = false; this.radioButton3.Enabled = false; } else { this.radioButton6.Enabled = true; this.radioButton5.Enabled = true; this.radioButton4.Enabled = true; this.radioButton3.Enabled = true; } } private void radioButton6_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } private void radioButton5_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } private void radioButton4_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } private void radioButton3_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } private void MethodADialog_Load(object sender, EventArgs e) { } #region 参数保存及提取 /// /// 保存参数的key,value和type /// /// /// /// private void saveParamValue(string param_key, string param_value, int param_type) { bool foundItem = false; foreach (var item in this.analysisModel.ListParam) { if (item.param_key.Equals(param_key) && item.menuId == this.menuId) { item.param_value = param_value; item.setValue(); foundItem = true; break; } } if (!foundItem) { GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel(); analysisItem.menuId = this.menuId; analysisItem.param_key = param_key; analysisItem.param_type = param_type; analysisItem.param_value = param_value; analysisItem.setValue(); this.analysisModel.ListParam.Add(analysisItem); } } /// /// 保存界面中的参数到model /// private void saveDialogParamValues() { saveParamValue(ParamKey_Report, checkBox_generateReport_opensetting.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//报告设置 saveParamValue(ParamKey_SortMicron, radioButton8.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//分类微米 saveParamValue(ParamKey_SortDiam, radioButton7.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//分类直径 saveParamValue(ParamKey_LongDiam, radioButton6.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//长径 saveParamValue(ParamKey_ShortDiam, radioButton5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//短径 saveParamValue(ParamKey_AvgDiam, radioButton4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//平均径 saveParamValue(ParamKey_EqualDiam, radioButton3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//等效圆直径 saveParamValue(ParamKey_Threshold, textBox5.Text, (int)Base.Dtryt.ItemString);//喉道阈值 saveParamValue(ParamKey_Number, checkBox1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示孔隙编号 saveParamValue(ParamKey_NumberFontSize, textBox1.Text, (int)Base.Dtryt.ItemString);//编号字体大小 saveParamValue(ParamKey_NumberColour, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//编号颜色 saveParamValue(ParamKey_Diameter, checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示孔隙直径 saveParamValue(ParamKey_DiameterFontSize, textBox2.Text, (int)Base.Dtryt.ItemString);//直径字体大小 saveParamValue(ParamKey_DiameterColour, panel3.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//直径颜色 saveParamValue(ParamKey_DecimalPlace, numericUpDown1_0.Value.ToString(), (int)Base.Dtryt.Decimal);//保留小数位数 } /// /// 获取保存的参数 /// private void GetListParamModel() { if (this.analysisModel != null) { for (int i = 0; i < this.analysisModel.ListParam.Count; i++) { switch (this.analysisModel.ListParam[i].param_key) { case ParamKey_Report: checkBox_generateReport_opensetting.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_SortMicron: radioButton8.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_SortDiam: radioButton7.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_LongDiam: radioButton6.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_ShortDiam: radioButton5.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_AvgDiam: radioButton4.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_EqualDiam: radioButton3.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_Threshold: textBox5.Text = (string)this.analysisModel.ListParam[i].value; break; case ParamKey_Number: checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_NumberFontSize: textBox1.Text = (string)this.analysisModel.ListParam[i].value; break; case ParamKey_NumberColour: panel1.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value); break; case ParamKey_Diameter: checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value; break; case ParamKey_DiameterFontSize: textBox2.Text = (string)this.analysisModel.ListParam[i].value; break; case ParamKey_DiameterColour: panel3.BackColor = Color.FromArgb((int)this.analysisModel.ListParam[i].value); break; case ParamKey_DecimalPlace: numericUpDown1_0.Value = decimal.Parse(this.analysisModel.ListParam[i].param_value); break; } } } } #endregion private void MethodADialog_FormClosing(object sender, FormClosingEventArgs e) { this.saveDialogParamValues(); //xml保存路径 string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml"; GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open)); foreach (var analysisItem in this.analysisModel.ListParam) { bool foundItem = false; foreach (var item in analysisModelXml.ListParam) { if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId) { item.param_value = analysisItem.param_value; foundItem = true; break; } } if (!foundItem) analysisModelXml.ListParam.Add(analysisItem.cloneModel()); } //按路径和名称保存xml文件 string userInfoXml = XmlSerializeHelper.XmlSerialize(analysisModelXml); //保存xml FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create); } #region [脚本相关] private void getValue(string key, object value) { switch (key) { case "parameter1": if ((int)value == 0) { radioButton8.Checked = true; } else { radioButton7.Checked = true; } break; case "parameter2": if ((int)value == 0) { radioButton6.Checked = true; } else if ((int)value == 1) { radioButton6.Checked = true; } else if ((int)value == 2) { radioButton4.Checked = true; } else { radioButton3.Checked = true; } break; case "parameter3": textBox5.Text = value.ToString(); break; case "parameter4": checkBox1.Checked = Convert.ToBoolean(value); break; case "parameter5": textBox1.Text = value.ToString(); break; case "parameter6": panel1.BackColor = Color.FromArgb((int)value); break; case "parameter7": checkBox2.Checked = Convert.ToBoolean(value); break; case "parameter8": textBox2.Text = value.ToString(); break; case "parameter9": panel3.BackColor = Color.FromArgb((int)value); break; case "OpenWhileExportReport": checkBox_generateReport_opensetting.Checked = Convert.ToBoolean(value); break; case "CalculatorDecimalDigits": numericUpDown1_0.Value = Convert.ToDecimal(value); break; } } #endregion #region [脚本录制] protected override void getScriptRecording() { string className = InvariantData.path_Action + ".Action" + menuId; ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className); List args = param.Lists; foreach (var item in args) { item.value = setScriptRecording(item.key); } //找出二值相关参数 进行赋值 List isNullList = args.Where(m => m.value == null).ToList(); foreach (var item in isNullList) { item.value = binaryClass.setScriptRecording(item.key); } appWorkspace.SetScriptStartRecording(this.menuId, menuName, args); } private object setScriptRecording(string key) { object value = null; switch (key) { case "parameter1": if (radioButton8.Checked) { value = 0; } else { value = 1; } break; case "parameter2": if (radioButton6.Checked) { value = 0; } else if (radioButton6.Checked) { value = 1; } else if (radioButton4.Checked) { value = 2; } else { value = 3; } break; case "parameter3": value = textBox5.Text; break; case "parameter4": value = checkBox1.Checked; break; case "parameter5": value = textBox1.Text; break; case "parameter6": value = panel1.BackColor.ToArgb(); break; case "parameter7": value = checkBox2.Checked; break; case "parameter8": value = textBox2.Text; break; case "parameter9": value = panel3.BackColor.ToArgb(); break; case "OpenWhileExportReport": value = checkBox_generateReport_opensetting.Checked; break; case "CalculatorDecimalDigits": value = numericUpDown1_0.Value; break; case "ExportResults": value = false; break; case "ExportReports": value = false; break; case "ExportProjects": value = false; break; } return value; } #endregion } }