using PaintDotNet.Base.CommTool; using PaintDotNet.Base.DedicatedAnalysis.Porosity; using PaintDotNet.Base.DedicatedAnalysis.Porosity.Model; using PaintDotNet.Base.DedicatedAnalysis.Porosity.Standard.TypesOfAssessment; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PaintDotNet.DedicatedAnalysis.Porosity.PV6093 { internal class PV6093Dialog :PorosityStandardDialog { protected PorosityConfig porosityConfig; private GroupBox groupBox2; private CheckBox checkBox4; private CheckBox checkBox3; private CheckBox checkBox2; private CheckBox checkBox1; private DataGridView dataGridView1; private ComboBox comboBox1; private Label label1; private ComboBox comboBox3; private Label label7; private Button button_pickColor; private DataGridViewTextBoxColumn Column11; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; private DataGridViewTextBoxColumn theMostWidespread; private DataGridViewTextBoxColumn largestDiameter; private DataGridViewTextBoxColumn minimumDiameter; private DataGridViewTextBoxColumn level; private GroupBox groupBox1; public PV6093Dialog() { InitializeComponent(); } public PV6093Dialog(AppWorkspace appWorkspace, string dialogText, PdnMenuItem menuItem) : base(appWorkspace, dialogText, menuItem) { InitializeComponent(); InitializeLanguageText(); getData(); } private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.paramssettings.text"); this.button_pickColor.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.moreoptions.text"); this.comboBox1.Items.AddRange(new object[] { PdnResources.GetString("Menu.Maximumcaliperdiameter.text"), PdnResources.GetString("Menu.Diameterofequalareacircle.text")}); this.label1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Diametertype.text"); this.label7.Text = PdnResources.GetString("Menu.Typeofstress.text"); this.groupBox2.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.thelesettings.text"); this.Column11.HeaderText = PdnResources.GetString("Menu.view.text"); this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.holearea.text"); this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.viewarea.text"); this.dataGridViewTextBoxColumn3.HeaderText = PdnResources.GetString("Menu.Porosity.text"); this.dataGridViewTextBoxColumn4.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Numberofholes.text"); this.theMostWidespread.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.Maxarea.text"); this.largestDiameter.HeaderText = PdnResources.GetString("Menu.Themaxdiameter.text"); this.minimumDiameter.HeaderText = PdnResources.GetString("Menu.minimumdiameter.text"); this.level.HeaderText = PdnResources.GetString("Menu.levdel.Text"); this.checkBox4.Text = PdnResources.GetString("Menu.Rough.text") + "Rz"; this.checkBox3.Text = PdnResources.GetString("Menu.minimumdiameter.text") + "U"; this.checkBox2.Text = PdnResources.GetString("Menu.minimumdistance.text") + "A"; this.checkBox1.Text = PdnResources.GetString("Menu.diameter.text") + "φ"; this.Text = "PV6093_2012(" + PdnResources.GetString("Menu.Porosity.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(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button_pickColor = new System.Windows.Forms.Button(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.label1 = new System.Windows.Forms.Label(); this.comboBox3 = new System.Windows.Forms.ComboBox(); this.label7 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); 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.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.theMostWidespread = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.largestDiameter = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.minimumDiameter = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.level = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.checkBox4 = new System.Windows.Forms.CheckBox(); this.checkBox3 = new System.Windows.Forms.CheckBox(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.checkBox1 = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_lwRatioLimit)).BeginInit(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.button_pickColor); this.groupBox1.Controls.Add(this.comboBox1); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.comboBox3); this.groupBox1.Controls.Add(this.label7); this.groupBox1.Location = new System.Drawing.Point(178, 357); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(356, 59); this.groupBox1.TabIndex = 35; this.groupBox1.TabStop = false; // // button_pickColor // this.button_pickColor.Location = new System.Drawing.Point(273, 20); this.button_pickColor.Name = "button_pickColor"; this.button_pickColor.Size = new System.Drawing.Size(75, 23); this.button_pickColor.TabIndex = 37; this.button_pickColor.UseVisualStyleBackColor = true; this.button_pickColor.Click += new System.EventHandler(this.button_pickColor_Click); // // comboBox1 // this.comboBox1.FormattingEnabled = true; this.comboBox1.Location = new System.Drawing.Point(172, 22); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(95, 20); this.comboBox1.TabIndex = 17; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(113, 25); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 16; // // comboBox3 // this.comboBox3.FormattingEnabled = true; this.comboBox3.Items.AddRange(new object[] { "D", "S", "F", "G"}); this.comboBox3.Location = new System.Drawing.Point(64, 22); this.comboBox3.Name = "comboBox3"; this.comboBox3.Size = new System.Drawing.Size(43, 20); this.comboBox3.TabIndex = 15; this.comboBox3.SelectedIndexChanged += new System.EventHandler(this.comboBox3_SelectedIndexChanged); // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(6, 25); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(0, 12); this.label7.TabIndex = 14; // // groupBox2 // this.groupBox2.Controls.Add(this.dataGridView1); this.groupBox2.Controls.Add(this.checkBox4); this.groupBox2.Controls.Add(this.checkBox3); this.groupBox2.Controls.Add(this.checkBox2); this.groupBox2.Controls.Add(this.checkBox1); this.groupBox2.Location = new System.Drawing.Point(178, 422); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(356, 133); this.groupBox2.TabIndex = 36; this.groupBox2.TabStop = false; // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); 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.dataGridViewTextBoxColumn3, this.dataGridViewTextBoxColumn4, this.theMostWidespread, this.largestDiameter, this.minimumDiameter, this.level}); this.dataGridView1.Location = new System.Drawing.Point(0, 42); 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(356, 80); this.dataGridView1.TabIndex = 11; // // Column11 // dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column11.DefaultCellStyle = dataGridViewCellStyle2; this.Column11.Name = "Column11"; this.Column11.ReadOnly = true; this.Column11.Width = 80; // // 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; // // dataGridViewTextBoxColumn3 // dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.dataGridViewTextBoxColumn3.DefaultCellStyle = dataGridViewCellStyle5; this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3"; this.dataGridViewTextBoxColumn3.ReadOnly = true; // // dataGridViewTextBoxColumn4 // dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle6; this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4"; this.dataGridViewTextBoxColumn4.ReadOnly = true; // // theMostWidespread // this.theMostWidespread.Name = "theMostWidespread"; this.theMostWidespread.ReadOnly = true; // // largestDiameter // this.largestDiameter.Name = "largestDiameter"; this.largestDiameter.ReadOnly = true; // // minimumDiameter // this.minimumDiameter.Name = "minimumDiameter"; this.minimumDiameter.ReadOnly = true; // // level // this.level.Name = "level"; this.level.ReadOnly = true; // // checkBox4 // this.checkBox4.AutoSize = true; this.checkBox4.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.checkBox4.Location = new System.Drawing.Point(242, 20); this.checkBox4.Name = "checkBox4"; this.checkBox4.Size = new System.Drawing.Size(15, 14); this.checkBox4.TabIndex = 10; this.checkBox4.UseVisualStyleBackColor = true; this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged); // // checkBox3 // this.checkBox3.AutoSize = true; this.checkBox3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.checkBox3.Location = new System.Drawing.Point(74, 20); this.checkBox3.Name = "checkBox3"; this.checkBox3.Size = new System.Drawing.Size(15, 14); this.checkBox3.TabIndex = 9; this.checkBox3.UseVisualStyleBackColor = true; this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged); // // checkBox2 // this.checkBox2.AutoSize = true; this.checkBox2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.checkBox2.Location = new System.Drawing.Point(158, 20); this.checkBox2.Name = "checkBox2"; this.checkBox2.Size = new System.Drawing.Size(15, 14); this.checkBox2.TabIndex = 8; this.checkBox2.UseVisualStyleBackColor = true; this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged); // // checkBox1 // this.checkBox1.AutoSize = true; this.checkBox1.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.checkBox1.Location = new System.Drawing.Point(8, 20); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(15, 14); this.checkBox1.TabIndex = 7; this.checkBox1.UseVisualStyleBackColor = true; this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); // // PV6093Dialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(1177, 761); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Name = "PV6093Dialog"; this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown_lwRatioLimit)).EndInit(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); } #region [页面事件] /// /// 初始化赋值 /// /// /// private void getData() { string filePath = Application.StartupPath + "\\PorosityConfig\\6093Config.xml"; try { porosityConfig = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open)); } catch (Exception ex) { porosityConfig = new PorosityConfig(); porosityConfig.diameterType = 1; porosityConfig.distanceFactor = 1; porosityConfig.maxDiameter = 1; porosityConfig.maxPorosityNum = 1; porosityConfig.maxPorosityPercent = 1; porosityConfig.minDiameter = 1; porosityConfig.roughSurface = 1; porosityConfig.stressType = "D"; porosityConfig.diameter = false; porosityConfig.minDistanceA = false; porosityConfig.minDiameterU = false; porosityConfig.surfaceRz = false; if (!Directory.Exists(filePath)) { string porosityInfoXml = XmlSerializeHelper.XmlSerialize(porosityConfig); Directory.CreateDirectory(Application.StartupPath + "\\PorosityConfig\\"); FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew); } } this.comboBox3.SelectedItem = this.porosityConfig.stressType; this.comboBox1.SelectedItem = this.porosityConfig.diameterType == 1 ? PdnResources.GetString("Menu.Maximumcaliperdiameter.text") : PdnResources.GetString("Menu.Diameterofequalareacircle.text"); this.checkBox1.Checked = this.porosityConfig.diameter; this.checkBox3.Checked = this.porosityConfig.minDistanceA; this.checkBox2.Checked = this.porosityConfig.minDiameterU; this.checkBox4.Checked = this.porosityConfig.surfaceRz; } /// /// 更多选线展示弹窗 /// /// /// private void button_pickColor_Click(object sender, EventArgs e) { new PorosityMoreChoose(porosityConfig,this,null,null).ShowDialog(); } #endregion #region 需继承方法 protected override void SubclassInitialize() { InitializeComponent(); } protected override MethodOfAssessment getMethodOfAssessment() { return new MethodOfPV6093(this.imgPxPerUnit); } protected override void initColorSetting() { } protected override void initDisplaySetting() { } protected override void getArgsValue() { var key = this.argsKey; var value = this.argsValue; switch (key) { case "parameter1": this.comboBox3.SelectedIndex = (int)value; this.porosityConfig.stressType = this.comboBox3.SelectedItem.ToString(); break; case "parameter2": this.comboBox1.SelectedIndex = (int)value; this.porosityConfig.diameterType = this.comboBox1.SelectedItem == null ? 1 : this.comboBox1.SelectedItem.ToString() == PdnResources.GetString("Menu.Maximumcaliperdiameter.text") ? 1 : 2; break; case "parameter3": this.porosityConfig.maxPorosityPercent = Convert.ToDouble(value); break; case "parameter4": this.porosityConfig.roughSurface = Convert.ToDouble(value); break; case "parameter5": this.porosityConfig.maxDiameter = Convert.ToDouble(value); break; case "parameter6": this.porosityConfig.distanceFactor = Convert.ToDouble(value); break; case "parameter7": this.porosityConfig.maxPorosityNum = Convert.ToDouble(value); break; case "parameter8": this.porosityConfig.minDiameter = Convert.ToDouble(value); break; case "parameter9": this.checkBox1.Checked = Convert.ToBoolean(value); this.porosityConfig.diameter = this.checkBox1.Checked; break; case "parameter10": this.checkBox3.Checked = Convert.ToBoolean(value); this.porosityConfig.minDiameterU = this.checkBox3.Checked; break; case "parameter11": this.checkBox2.Checked = Convert.ToBoolean(value); this.porosityConfig.minDistanceA = this.checkBox2.Checked; break; case "parameter12": this.checkBox4.Checked = Convert.ToBoolean(value); this.porosityConfig.surfaceRz = this.checkBox4.Checked; break; } } protected override void setArgsValue() { var key = this.argsKey; object value = null; switch (key) { case "parameter1": value = this.comboBox3.SelectedIndex; break; case "parameter2": value = this.comboBox1.SelectedIndex; break; case "parameter3": value = this.porosityConfig.maxPorosityPercent; break; case "parameter4": value = this.porosityConfig.roughSurface; break; case "parameter5": value = this.porosityConfig.maxDiameter; break; case "parameter6": value = this.porosityConfig.distanceFactor; break; case "parameter7": value = this.porosityConfig.maxPorosityNum; break; case "parameter8": value = this.porosityConfig.minDiameter; break; case "parameter9": value = this.checkBox1.Checked; break; case "parameter10": value = this.checkBox3.Checked; break; case "parameter11": value = this.checkBox2.Checked; break; case "parameter12": value = this.checkBox4.Checked; break; } this.argsValue = value; } protected override void save_normal_data() { this.porosityConfig.diameterType = this.comboBox1.SelectedItem == null ? 1 : this.comboBox1.SelectedItem.ToString() == PdnResources.GetString("Menu.Maximumcaliperdiameter.text") ? 1 : 2; this.porosityConfig.stressType = this.comboBox3.SelectedItem.ToString(); this.porosityConfig.diameter = this.checkBox1.Checked; this.porosityConfig.minDistanceA = this.checkBox3.Checked; this.porosityConfig.minDiameterU = this.checkBox2.Checked; this.porosityConfig.surfaceRz = this.checkBox4.Checked; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(this.porosityConfig); FileOperationHelper.WriteStringToFile(porosityInfoXml, Application.StartupPath + "\\PorosityConfig\\6093Config.xml", FileMode.Create); } /// /// 列表赋值 /// protected override void list_add_data() { if (this.tempAnalysisResult == null) { return; } dataGridView1.Rows.Clear(); var dataList = this.tempAnalysisResult.resultBody; int num = 2; if (this.domainUpDown_resultPrecision.SelectedIndex != -1) { num = Convert.ToInt32(this.domainUpDown_resultPrecision.Items[this.domainUpDown_resultPrecision.SelectedIndex]); } foreach (var item in dataList) { dataGridView1.Rows.Add(item.Key.name,Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[0]),2)), Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[1]), num)), Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[2]), num)), Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[3]), num)), Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[4]), num)), Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[5]), num)), Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[6]), num)), item.Value[7]); if (this.porosityConfig.maxPorosityPercent <= Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[2]), num))) { dataGridView1[3, dataGridView1.Rows.Count - 1].Style.Font = new Font(DataGridView.DefaultFont, FontStyle.Bold); } else { dataGridView1[3, dataGridView1.Rows.Count - 1].Style.Font = DataGridView.DefaultFont; } if (this.porosityConfig.stressType == "F") { if (this.porosityConfig.maxPorosityNum <= Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[3]), num))) { dataGridView1[4, dataGridView1.Rows.Count - 1].Style.Font = new Font(DataGridView.DefaultFont, FontStyle.Bold); } else { dataGridView1[4, dataGridView1.Rows.Count - 1].Style.Font = DataGridView.DefaultFont; } } else { dataGridView1[4, dataGridView1.Rows.Count - 1].Style.Font = DataGridView.DefaultFont; } if (this.porosityConfig.maxDiameter <= Convert.ToDouble(Math.Round(Convert.ToDecimal(item.Value[5]), num))) { dataGridView1[6, dataGridView1.Rows.Count - 1].Style.Font = new Font(DataGridView.DefaultFont, FontStyle.Bold); } else { dataGridView1[6, dataGridView1.Rows.Count - 1].Style.Font = DataGridView.DefaultFont; } } for (int i = 0; i < this.dataGridView1.Rows.Count; i++) { try { int thisNum = Convert.ToInt32(this.dataGridView1[0, i].Value.ToString().Replace("view", "")); dataGridView1.Rows[i].DefaultCellStyle.BackColor = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[thisNum - 1].Color; } catch (Exception ex) { } } this.dataGridView1.ClearSelection(); } private void checkBox1_CheckedChanged(object sender, EventArgs e) { this.porosityConfig.diameter = this.checkBox1.Checked; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(this.porosityConfig); FileOperationHelper.WriteStringToFile(porosityInfoXml, Application.StartupPath + "\\PorosityConfig\\6093Config.xml", FileMode.Create); clearAllView(); if (this.bcBinaryChecked()) { recalculate(); list_add_data(); } } private void checkBox3_CheckedChanged(object sender, EventArgs e) { this.porosityConfig.minDiameterU = this.checkBox3.Checked; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(this.porosityConfig); FileOperationHelper.WriteStringToFile(porosityInfoXml, Application.StartupPath + "\\PorosityConfig\\6093Config.xml", FileMode.Create); clearAllView(); if (this.bcBinaryChecked()) { recalculate(); list_add_data(); } } private void checkBox2_CheckedChanged(object sender, EventArgs e) { this.porosityConfig.minDistanceA = this.checkBox2.Checked; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(this.porosityConfig); FileOperationHelper.WriteStringToFile(porosityInfoXml, Application.StartupPath + "\\PorosityConfig\\6093Config.xml", FileMode.Create); clearAllView(); if (this.bcBinaryChecked()) { recalculate(); list_add_data(); } } private void checkBox4_CheckedChanged(object sender, EventArgs e) { this.porosityConfig.surfaceRz = this.checkBox4.Checked; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(this.porosityConfig); FileOperationHelper.WriteStringToFile(porosityInfoXml, Application.StartupPath + "\\PorosityConfig\\6093Config.xml", FileMode.Create); clearAllView(); if (this.bcBinaryChecked()) { recalculate(); list_add_data(); } } protected override void clearAllView() { dataGridView1.Rows.Clear(); } protected override void clearOneView() { if (dataGridView1.Rows.Count > 0) { dataGridView1.Rows.RemoveAt(this.delIndex); } } protected override void changeOneViewColor() { if (dataGridView1.Rows.Count > 0) { dataGridView1.Rows[this.delIndex].DefaultCellStyle.BackColor = this.documentItems[this.lstView_img.FocusedItem.Index].drawGraphicsList[this.delIndex].Color; } } protected override void getEveryImgData() { if (this.everyImgData.ContainsKey(this.ImgName)) { PorosityConfig config = this.everyImgData[this.ImgName]; this.comboBox3.SelectedItem = config.stressType; this.comboBox1.SelectedItem = config.diameterType == 1 ? PdnResources.GetString("Menu.Maximumcaliperdiameter.text") : PdnResources.GetString("Menu.Diameterofequalareacircle.text"); this.checkBox1.Checked = config.diameter; this.checkBox3.Checked = config.minDistanceA; this.checkBox2.Checked = config.minDiameterU; this.checkBox4.Checked = config.surfaceRz; } } protected override void saveEveryImgData() { if (this.everyImgData.ContainsKey(this.ImgName)) { PorosityConfig config = this.everyImgData[this.ImgName]; config.diameterType = this.comboBox1.SelectedItem == null ? 1 : this.comboBox1.SelectedItem.ToString() == PdnResources.GetString("Menu.Maximumcaliperdiameter.text") ? 1 : 2; config.stressType = this.comboBox3.SelectedItem.ToString(); config.diameter = this.checkBox1.Checked; config.minDistanceA = this.checkBox3.Checked; config.minDiameterU = this.checkBox2.Checked; config.surfaceRz = this.checkBox4.Checked; this.everyImgData[this.ImgName] = config; } else { PorosityConfig config = new PorosityConfig(); config.diameterType = this.comboBox1.SelectedItem == null ? 1 : this.comboBox1.SelectedItem.ToString() == PdnResources.GetString("Menu.Maximumcaliperdiameter.text") ? 1 : 2; config.stressType = this.comboBox3.SelectedItem.ToString(); config.diameter = this.checkBox1.Checked; config.minDistanceA = this.checkBox3.Checked; config.minDiameterU = this.checkBox2.Checked; config.surfaceRz = this.checkBox4.Checked; this.everyImgData.Add(this.ImgName, config); } } #endregion 需继承方法 private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { this.porosityConfig.stressType = this.comboBox3.SelectedItem.ToString(); string porosityInfoXml = XmlSerializeHelper.XmlSerialize(this.porosityConfig); FileOperationHelper.WriteStringToFile(porosityInfoXml, Application.StartupPath + "\\PorosityConfig\\6093Config.xml", FileMode.Create); clearAllView(); recalculate(); list_add_data(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { this.porosityConfig.diameterType = this.comboBox1.SelectedItem.ToString() == PdnResources.GetString("Menu.Maximumcaliperdiameter.text") ? 1 : 2; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(this.porosityConfig); FileOperationHelper.WriteStringToFile(porosityInfoXml, Application.StartupPath + "\\PorosityConfig\\6093Config.xml", FileMode.Create); clearAllView(); recalculate(); list_add_data(); } public void getChange(PorosityConfig porosityConfig) { this.porosityConfig = porosityConfig; clearAllView(); recalculate(); list_add_data(); } } }