using OpenCvSharp; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; namespace PaintDotNet.DedicatedAnalysis.GrainSizeStandard.E1181 { internal class MethodAreaDialog : GrainSizeStandardDialog { #region 组件 private GroupBox groupBox_ShowParamSetting; private Button button_ShowRefresh; private CheckBox checkBox_ShowGrainColor; private CheckBox checkBox_ShowGrainNumber; private CheckBox checkBox_ShowGrid; private CheckBox checkBox_ShowGrainBoundry; private DataGridViewTextBoxColumn ColumnTotal1; private DataGridViewTextBoxColumn ColumnTotal2; private DataGridViewTextBoxColumn ColumnTotal3; private DataGridViewTextBoxColumn ColumnTotal4; private DataGridViewTextBoxColumn ColumnTotal5; private DataGridViewTextBoxColumn ColumnTotal6; private DataGridViewTextBoxColumn Colum01; private DataGridViewTextBoxColumn Colum02; private DataGridViewTextBoxColumn Colum03; private DataGridViewTextBoxColumn Colum04; private DataGridViewTextBoxColumn Colum05; private DataGridViewTextBoxColumn Colum06; private GroupBox groupBox7; private Button button10; private Button button3; private Button button8; private RadioButton radioButton5; private RadioButton radioButton4; private RadioButton radioButton3; private Button button2; #endregion 组件 #region 构造函数 public MethodAreaDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) : base(appWorkspace, menuItem, new Base.DedicatedAnalysis.GrainSize.Standard.E1181.MethodArea()) { } #endregion 构造函数 #region 初始化组件和实现组件事件 private void InitializeLanguageText() { this.groupBox_ShowParamSetting.Text = PdnResources.GetString("Menu.Displayparamssettings.text"); this.button_ShowRefresh.Text = PdnResources.GetString("Menu.Refresh.text"); this.checkBox_ShowGrainColor.Text = PdnResources.GetString("Menu.Thegrainsareshownindifferentcolors.text"); this.checkBox_ShowGrainNumber.Text = PdnResources.GetString("Menu.Displaygrainnumber.text"); this.checkBox_ShowGrid.Text = PdnResources.GetString("Menu.displaygrid.text"); this.checkBox_ShowGrainBoundry.Text = PdnResources.GetString("Menu.displaygrainboundaries.text"); this.ColumnTotal3.HeaderText = PdnResources.GetString("Menu.talnumberofgrain.Text"); this.ColumnTotal4.HeaderText = PdnResources.GetString("Menu.Summaryintercept.Text") + "(μm)"; this.ColumnTotal5.HeaderText = PdnResources.GetString("Menu.averageintercept.text") + "(μm)"; this.ColumnTotal6.HeaderText = PdnResources.GetString("Menu.calculatethelevel.Text"); this.ColumnTotal1.HeaderText = PdnResources.GetString("Menu.Averagesize.Text") + "(μm²)"; this.ColumnTotal2.HeaderText = PdnResources.GetString("Menu.culatesthelevels.Text"); this.Colum01.HeaderText = PdnResources.GetString("Menu.picture.Text"); this.Colum02.HeaderText = PdnResources.GetString("Menu.Tools.GridLine.Text"); this.Colum03.HeaderText = PdnResources.GetString("Menu.Grainnumber.Text"); this.Colum04.HeaderText = PdnResources.GetString("Menu.Graisize.Text") + "(μm²)"; this.Colum05.HeaderText = PdnResources.GetString("Menu.Grainintercept.Text") + "(μm)"; this.Colum06.HeaderText = PdnResources.GetString("Menu.Graingrade.Text"); this.button2.Text = PdnResources.GetString("Menu.Setting.Text"); this.Text = "ASTM_E1181_2002(" + PdnResources.GetString("Menu.Areamethod.text") + ")"; } private void InitializeComponent() { this.groupBox_ShowParamSetting = new System.Windows.Forms.GroupBox(); this.button_ShowRefresh = new System.Windows.Forms.Button(); this.checkBox_ShowGrainColor = new System.Windows.Forms.CheckBox(); this.checkBox_ShowGrainNumber = new System.Windows.Forms.CheckBox(); this.checkBox_ShowGrid = new System.Windows.Forms.CheckBox(); this.checkBox_ShowGrainBoundry = new System.Windows.Forms.CheckBox(); this.ColumnTotal1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnTotal2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnTotal3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnTotal4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnTotal5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnTotal6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Colum01 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Colum02 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Colum03 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Colum04 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Colum05 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Colum06 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.button2 = new System.Windows.Forms.Button(); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.button10 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button8 = new System.Windows.Forms.Button(); this.radioButton5 = new System.Windows.Forms.RadioButton(); this.radioButton4 = new System.Windows.Forms.RadioButton(); this.radioButton3 = new System.Windows.Forms.RadioButton(); this.groupBox_img.SuspendLayout(); this.groupBox_analysisResult1.SuspendLayout(); this.groupBox3.SuspendLayout(); this.groupBox_ShowParamSetting.SuspendLayout(); this.groupBox7.SuspendLayout(); this.SuspendLayout(); // // groupBox_ShowParamSetting // this.groupBox_ShowParamSetting.Controls.Add(this.button2); this.groupBox_ShowParamSetting.Controls.Add(this.button_ShowRefresh); this.groupBox_ShowParamSetting.Controls.Add(this.checkBox_ShowGrainColor); this.groupBox_ShowParamSetting.Controls.Add(this.checkBox_ShowGrainNumber); this.groupBox_ShowParamSetting.Controls.Add(this.checkBox_ShowGrid); this.groupBox_ShowParamSetting.Controls.Add(this.checkBox_ShowGrainBoundry); this.groupBox_ShowParamSetting.Location = new System.Drawing.Point(178, 370); this.groupBox_ShowParamSetting.Name = "groupBox_ShowParamSetting"; this.groupBox_ShowParamSetting.Size = new System.Drawing.Size(356, 74); this.groupBox_ShowParamSetting.TabIndex = 38; this.groupBox_ShowParamSetting.TabStop = false; // // button_ShowRefresh // this.button_ShowRefresh.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button_ShowRefresh.Location = new System.Drawing.Point(271, 17); this.button_ShowRefresh.Name = "button_ShowRefresh"; this.button_ShowRefresh.Size = new System.Drawing.Size(75, 22); this.button_ShowRefresh.TabIndex = 18; this.button_ShowRefresh.UseVisualStyleBackColor = true; this.button_ShowRefresh.Click += new System.EventHandler(this.button_ShowRefresh_Click); // // checkBox_ShowGrainColor // this.checkBox_ShowGrainColor.AutoSize = true; this.checkBox_ShowGrainColor.Checked = true; this.checkBox_ShowGrainColor.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox_ShowGrainColor.Location = new System.Drawing.Point(108, 44); this.checkBox_ShowGrainColor.Name = "checkBox_ShowGrainColor"; this.checkBox_ShowGrainColor.Size = new System.Drawing.Size(161, 19); this.checkBox_ShowGrainColor.TabIndex = 3; this.checkBox_ShowGrainColor.UseVisualStyleBackColor = true; this.checkBox_ShowGrainColor.CheckedChanged += new System.EventHandler(this.checkBox_ShowGrainColor_CheckedChanged); // // checkBox_ShowGrainNumber // this.checkBox_ShowGrainNumber.AutoSize = true; this.checkBox_ShowGrainNumber.Checked = true; this.checkBox_ShowGrainNumber.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox_ShowGrainNumber.Location = new System.Drawing.Point(109, 22); this.checkBox_ShowGrainNumber.Name = "checkBox_ShowGrainNumber"; this.checkBox_ShowGrainNumber.Size = new System.Drawing.Size(116, 19); this.checkBox_ShowGrainNumber.TabIndex = 2; this.checkBox_ShowGrainNumber.UseVisualStyleBackColor = true; this.checkBox_ShowGrainNumber.CheckedChanged += new System.EventHandler(this.checkBox_ShowGrainNumber_CheckedChanged); // // checkBox_ShowGrid // this.checkBox_ShowGrid.AutoSize = true; this.checkBox_ShowGrid.Checked = true; this.checkBox_ShowGrid.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox_ShowGrid.Location = new System.Drawing.Point(15, 44); this.checkBox_ShowGrid.Name = "checkBox_ShowGrid"; this.checkBox_ShowGrid.Size = new System.Drawing.Size(86, 19); this.checkBox_ShowGrid.TabIndex = 1; this.checkBox_ShowGrid.UseVisualStyleBackColor = true; this.checkBox_ShowGrid.CheckedChanged += new System.EventHandler(this.checkBox_ShowGrid_CheckedChanged); // // checkBox_ShowGrainBoundry // this.checkBox_ShowGrainBoundry.AutoSize = true; this.checkBox_ShowGrainBoundry.Checked = true; this.checkBox_ShowGrainBoundry.CheckState = System.Windows.Forms.CheckState.Checked; this.checkBox_ShowGrainBoundry.Location = new System.Drawing.Point(15, 22); this.checkBox_ShowGrainBoundry.Name = "checkBox_ShowGrainBoundry"; this.checkBox_ShowGrainBoundry.Size = new System.Drawing.Size(86, 19); this.checkBox_ShowGrainBoundry.TabIndex = 0; this.checkBox_ShowGrainBoundry.UseVisualStyleBackColor = true; this.checkBox_ShowGrainBoundry.CheckedChanged += new System.EventHandler(this.checkBox_ShowGrainBoundry_CheckedChanged); this.dataGridView_Total.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.ColumnTotal3, this.ColumnTotal4, this.ColumnTotal5, this.ColumnTotal6, this.ColumnTotal1, this.ColumnTotal2}); // // ColumnTotal3 // this.ColumnTotal3.Name = "ColumnTotal3"; this.ColumnTotal3.ReadOnly = true; // // ColumnTotal4 // this.ColumnTotal4.Name = "ColumnTotal4"; this.ColumnTotal4.ReadOnly = true; // // ColumnTotal5 // this.ColumnTotal5.Name = "ColumnTotal5"; this.ColumnTotal5.ReadOnly = true; // // ColumnTotal6 // this.ColumnTotal6.Name = "ColumnTotal6"; this.ColumnTotal6.ReadOnly = true; // // ColumnTotal1 // this.ColumnTotal1.Name = "ColumnTotal1"; this.ColumnTotal1.ReadOnly = true; // // ColumnTotal2 // this.ColumnTotal2.Name = "ColumnTotal2"; this.ColumnTotal2.ReadOnly = true; this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Colum01, this.Colum02, this.Colum03, this.Colum04, this.Colum05, this.Colum06}); // // Colum01 // this.Colum01.Name = "Colum01"; this.Colum01.ReadOnly = true; // // Colum02 // this.Colum02.Name = "Colum02"; this.Colum02.ReadOnly = true; // // Colum03 // this.Colum03.Name = "Grainnumber"; this.Colum03.ReadOnly = true; // // Colum04 // this.Colum04.Name = "Graisize"; this.Colum04.ReadOnly = true; // // Colum05 // this.Colum05.Name = "Grainintercept"; this.Colum05.ReadOnly = true; // // Colum06 // this.Colum06.Name = "Graingrade"; this.Colum06.ReadOnly = true; // // button2 // this.button2.Anchor = System.Windows.Forms.AnchorStyles.Right; this.button2.Location = new System.Drawing.Point(271, 41); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 22); this.button2.TabIndex = 19; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // groupBox7 // this.groupBox7.Controls.Add(this.button10); this.groupBox7.Controls.Add(this.button3); this.groupBox7.Controls.Add(this.button8); this.groupBox7.Controls.Add(this.radioButton5); this.groupBox7.Controls.Add(this.radioButton4); this.groupBox7.Controls.Add(this.radioButton3); this.groupBox7.Location = new System.Drawing.Point(178, 450); this.groupBox7.Name = "groupBox7"; this.groupBox7.Size = new System.Drawing.Size(356, 77); this.groupBox7.TabIndex = 41; this.groupBox7.TabStop = false; this.groupBox7.Text = "目标选择"; // // button10 // this.button10.Location = new System.Drawing.Point(60, 21); this.button10.Name = "button10"; this.button10.Size = new System.Drawing.Size(40, 40); this.button10.TabIndex = 5; this.button10.UseVisualStyleBackColor = true; // // button3 // this.button3.Location = new System.Drawing.Point(14, 21); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(40, 40); this.button3.TabIndex = 4; this.button3.UseVisualStyleBackColor = true; // // button8 // this.button8.Location = new System.Drawing.Point(106, 21); this.button8.Name = "button8"; this.button8.Size = new System.Drawing.Size(40, 40); this.button8.TabIndex = 3; this.button8.UseVisualStyleBackColor = true; this.button8.Visible = false; // // radioButton5 // this.radioButton5.AutoSize = true; this.radioButton5.Location = new System.Drawing.Point(238, 55); this.radioButton5.Name = "radioButton5"; this.radioButton5.Size = new System.Drawing.Size(14, 13); this.radioButton5.TabIndex = 2; this.radioButton5.UseVisualStyleBackColor = true; this.radioButton5.Visible = false; // // radioButton4 // this.radioButton4.AutoSize = true; this.radioButton4.Checked = true; this.radioButton4.Location = new System.Drawing.Point(297, 44); this.radioButton4.Name = "radioButton4"; this.radioButton4.Size = new System.Drawing.Size(14, 13); this.radioButton4.TabIndex = 1; this.radioButton4.TabStop = true; this.radioButton4.UseVisualStyleBackColor = true; this.radioButton4.Visible = false; // // radioButton3 // this.radioButton3.AutoSize = true; this.radioButton3.Location = new System.Drawing.Point(279, 21); this.radioButton3.Name = "radioButton3"; this.radioButton3.Size = new System.Drawing.Size(14, 13); this.radioButton3.TabIndex = 0; this.radioButton3.UseVisualStyleBackColor = true; this.radioButton3.Visible = false; // // MethodAreaDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(1127, 810); this.Controls.Add(this.groupBox7); this.Controls.Add(this.groupBox_ShowParamSetting); this.Name = "MethodAreaDialog"; this.Load += new System.EventHandler(this.MethodAreaDialog_Load); this.Controls.SetChildIndex(this.groupBox3, 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.groupBox6groupBox_analysisResult2, 0); this.Controls.SetChildIndex(this.groupBox_report, 0); this.Controls.SetChildIndex(this.groupBox_ShowParamSetting, 0); this.Controls.SetChildIndex(this.groupBox7, 0); this.groupBox_img.ResumeLayout(false); this.groupBox_analysisResult1.ResumeLayout(false); this.groupBox3.ResumeLayout(false); this.groupBox_ShowParamSetting.ResumeLayout(false); this.groupBox_ShowParamSetting.PerformLayout(); this.groupBox7.ResumeLayout(false); this.groupBox7.PerformLayout(); this.ResumeLayout(false); } private void MethodAreaDialog_Load(object sender, EventArgs e) { object ShowGrainBoundry; if (GetParamValue1(ParamKey_displaygrainboundaries, out ShowGrainBoundry))//显示晶界 this.checkBox_ShowGrainBoundry.Checked = (bool)ShowGrainBoundry; if (GetParamValue1(ParamKey_displaygrid, out ShowGrainBoundry))//显示网格 this.checkBox_ShowGrid.Checked = (bool)ShowGrainBoundry; if (GetParamValue1(ParamKey_ShowGrainNumber, out ShowGrainBoundry))//显示晶粒编号 this.checkBox_ShowGrainNumber.Checked = (bool)ShowGrainBoundry; if (GetParamValue1(ParamKey_ShowGrainColor, out ShowGrainBoundry))//用不同颜色显示晶粒 this.checkBox_ShowGrainColor.Checked = (bool)ShowGrainBoundry; this.button3.FlatStyle = FlatStyle.Flat; this.button3.FlatAppearance.BorderSize = 0; this.button3.BackgroundImageLayout = ImageLayout.Zoom; this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference; this.button3.Click += new EventHandler(this.button3_click); this.button10.FlatStyle = FlatStyle.Flat; this.button10.FlatAppearance.BorderSize = 0; this.button10.BackgroundImageLayout = ImageLayout.Zoom; this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference; this.button10.Click += new EventHandler(this.button10_click); this.button8.FlatStyle = FlatStyle.Flat; this.button8.FlatAppearance.BorderSize = 0; this.button8.BackgroundImageLayout = ImageLayout.Zoom; this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference; this.button8.Click += new EventHandler(this.button8_click); getSonData(); } /// /// 获取参数 /// protected override void getSonData() { object ShowGrainBoundry; if (GetParamValue1(ParamKey_TargetSelection, out ShowGrainBoundry))//目标选择 { int value = Convert.ToInt32(ShowGrainBoundry); switch (value) { case 1: this.button8_click(null, null); break; case 2: this.button3_click(null, null); break; case 3: this.button10_click(null, null); break; } } } private void button3_click(object sender, EventArgs e) { this.TargetSelection = 2; this.radioButton4.Checked = true; this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference; this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference; this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference; } private void button10_click(object sender, EventArgs e) { this.TargetSelection = 3; this.radioButton5.Checked = true; this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference; this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference; this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference; } private void button8_click(object sender, EventArgs e) { this.TargetSelection = 1; this.radioButton3.Checked = true; this.button8.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference; this.button3.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference; this.button10.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference; } /// /// 设置晶粒颜色 /// /// /// private void button2_Click(object sender, EventArgs e) { //if (this.matOrg == null) //{ // MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text")); // return; //} ShowGrainColorSettingDialog(); } /// /// 刷新晶粒编号 /// /// /// private void button_ShowRefresh_Click(object sender, EventArgs e) { if (this.matOrg == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text")); return; } GetNumberOfGrains(); } /// /// 显示晶界状态改变 /// /// /// private void checkBox_ShowGrainBoundry_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.PhaseModels[1].choise = (!bcOriginChecked() && getGrainBoundryChecked() && checkBox_ShowGrainBoundry.Checked); this.documentWorkspace.Refresh(); } /// /// 显示网格状态改变 /// /// /// private void checkBox_ShowGrid_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } /// /// 用不同颜色显示晶粒状态改变 /// /// /// private void checkBox_ShowGrainColor_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.PhaseModels[2].choise = (!bcOriginChecked() && checkBox_ShowGrainColor.Checked); this.documentWorkspace.Refresh(); } /// /// 显示晶粒编号状态改变 /// /// /// private void checkBox_ShowGrainNumber_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } #endregion 初始化组件和实现组件事件 #region 需继承方法 ////数据库的name(报告模板) //protected override string getTemplateName() //{ // return "Template.Manager.item3.GrainSizeArea1181Method"; //} //语言包的name(项目工程) protected override string getProjectEngineeringName() { return "Menu.DedicatedAnalysis.BlackMetal.GrainSize.Text"; } ////配置文件名称(辅助线) //protected override string getModelName() //{ // return "GrainSizeGuideAreaMethodModel.xml"; //} //辅助线类型名称 protected override string[] getTypeNames() { return new string[] { PdnResources.GetString("Menu.circular.Text"), PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text")}; } protected override void SubclassInitialize() { InitializeComponent(); DetailListNotDoubleIndex.Add(0); DetailListNotDoubleIndex.Add(1); InitializeLanguageText(); } //切换图片时控制前一张图的信息不遗留显示 protected override void refreshWhileImgChanged() { if (this.grainColorsMatDict.ContainsKey(getCurrentWorkTag())) this.documentWorkspace.PhaseModels[2].mat = this.grainColorsMatDict[getCurrentWorkTag()]; if (this.bitmap != null && this.documentWorkspace.PhaseModels[2].mat != null) { //try //{ // GetNumberOfGrains(); //} //catch (Exception) //{ //} } else { this.documentWorkspace.PhaseModels[2].mat = null;//清空前一张图的信息不遗留显示 GSSClass.standardModel.massLabelPoints.Clear();//1013###19098(切换图片的时候前一张图的信息不遗留显示)} //1013###18808(切换图片的时候前一张图的信息不遗留显示) this.documentWorkspace.Refresh(); } } /// /// 是否用不同颜色显示晶粒 /// /// protected override Boolean ShowGrainColorChecked() { return checkBox_ShowGrainColor.Checked; } //是否绘制编号 protected override bool showGrainNumberChecked() { return this.checkBox_ShowGrainNumber.Checked; } //是否绘制辅助线 protected override bool showGridChecked() { return checkBox_ShowGrid.Checked; } /// /// 是否显示晶界 /// /// protected override Boolean ShowGrainBoundryChecked() { return checkBox_ShowGrainBoundry.Checked; } #endregion } }