using OpenCvSharp; using PaintDotNet.Annotation.Enum; using PaintDotNet.Base; using PaintDotNet.Base.Functionodel; using PaintDotNet.CustomControl; using PaintDotNet.Data.Param; 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; using PaintDotNet.DbOpreate.DbBll; using PaintDotNet.DbOpreate.DbModel; using PaintDotNet.Base.CommTool; using PaintDotNet.Instrument; using PaintDotNet.Annotation; using static PaintDotNet.Base.DedicatedAnalysis.Inclusions.MethodOfAssessment; using PaintDotNet.Base.SettingModel; using OpenCvSharp.Extensions; using PaintDotNet.DedicatedAnalysis.DuctileIron.Common; using Metis.ParameterSet; namespace PaintDotNet.DedicatedAnalysis.SpheroidizedStructure.GBT38770 { /// /// 低中碳钢球化组织 /// internal class SpheroidizationGradingDialog : PdnBaseForm { #region 控件 private GroupBox groupBox2; private GroupBox groupBox1; private Button button2; private CheckBox checkBox2; private Button button1; private GroupBox groupBox7; private GroupBox groupBox8; private ListView listView2; private NumericUpDown numericUpDown1; private Button button16; private Label label5; private Button button14; private Button button13; private DataGridView dataGridView4; private Button button12; private Button button11; private ImageList imageList1; private IContainer components; private Button button3; private GroupBox groupBox5; private GroupBox groupBox6; private GroupBox groupBox9; private GroupBox groupBox10; private GroupBox groupBox11; private Label label8; private Panel panel1; private Label label7; private Label label9; private Panel panel2; private Label label10; private RadioButton radioButton3; private RadioButton radioButton2; private RadioButton radioButton1; private CheckBox checkBox4; private DataGridView dataGridView1; private ListView listView1; #endregion private CommonControlButtons commonControlButtons; /// /// 主控件 /// private AppWorkspace appWorkspace; /// /// 初始系统参数配置值 /// private BinaryExtractionModel binaryExtractionModel; /// /// 图像面板 /// private DocumentWorkspaceWindow documentWorkspace; /// /// 选中图片的bitmap /// private Bitmap bitmap; /// /// 保存用于生成报告的图片 /// private List bitList; /// /// 储存点击保存结果后的所有原图与分析图 /// private Dictionary> bitDic = new Dictionary>(); /// /// 处理程序 /// private ParamObject action = new Data.Action.Action1010(); /// /// 标尺 /// private double unitLength; /// /// 分析结果暂存 /// private List dataTables = new List(); /// /// 是否要调用二值化的算法 /// private bool toApplyBinary = true; private decimal maxArea = 0; /// /// 存在视场标记 /// private bool existViewFlag = false; /// /// 全部显示 /// private bool allShow = false; /// /// 当前选择的图片 /// private Mat mat; /// /// 球状碳化物面积 /// private double sphericalArea; /// /// 片状碳化物面积 /// private double flakArea; /// /// 独立碳化物面积 /// private double independentArea; //二值化集成1 BinaryClass binaryClass; private int menuId; private string menuName; /// /// 中间数据 /// private List tempDataModel = new List(); /// /// 轮廓质点 /// private Dictionary keyValuePairs = new Dictionary< Point2d, decimal>(); /// /// 轮廓质点(多视场) /// private List> keyValuePairsList = new List>(); /// /// 切换图片 /// private bool init = true; private string oldValueT1 = "0"; private string oldValueT2 = "0"; /// /// 二值化后的mat /// private Mat binarizationMat; private ColorsForm colorsForm1; private ColorsForm colorsForm2; private TextBox textBox1; private TextBox textBox2; private DataGridViewTextBoxColumn Column11; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4; private DataGridViewTextBoxColumn dataGridViewTextBoxColumn5; private DataGridViewTextBoxColumn Column1; private DataGridViewTextBoxColumn Column2; private DataGridViewTextBoxColumn Column5; private DataGridViewTextBoxColumn Column6; private DataGridViewTextBoxColumn Column7; private Button button4; private ColorsForm colorsForm3; private BinaryControl bc; private AppCommon appCommon; private Label label1; private NumericUpDown numericUpDown2; private int defaultIndex = -1; private bool isExportResults = false; private bool isExportReports = false; private bool isExportProjects = false; /// /// 是否脚本运行 /// private Boolean initScriptValues = false; // /// 保存窗口参数 /// /// /// 各个图片对应数据 /// private Dictionary eachData = new Dictionary(); private const string ParamKey_Report = "report";//报告设置 private const string ParamKey_GlobularColour = "globularColour";//球状颜色 private const string ParamKey_LessThan = "lessThan";//长宽比小于 private const string ParamKey_FlakyColour = "flakyColour";//片状颜色 private const string ParamKey_GreaterThan = "greaterTha";//长宽比大于 private const string ParamKey_LowCarbon = "lowCarbon";//低碳碳素结构 private const string ParamKey_MediumCarbon = "mediumCarbon";//中碳碳素结构 private const string ParamKey_MediumCarbonAlloy = "mediumCarbonAlloy";//中碳合金结构 private const string ParamKey_ShowAspectRatio = "showAspectRatio";//显示长宽比 private const string ParamKey_FontSize = "fontSize";//字号 private Button button5; private Button button6; private const string ParamKey_DecimalPlace = "decimalPlace";//保留小数位数 public SpheroidizationGradingDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) { this.menuId = menuItem.MenuId; this.menuName = menuItem.Text; binaryClass = new BinaryClass(menuId); NullKey(); InitializeComponent(); InitializeLanguageText(); this.button11.Visible = true; this.button16.Visible = false; //调色板 this.colorsForm1 = new ColorsForm(); this.colorsForm1.StartPosition = FormStartPosition.CenterScreen; this.colorsForm1.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); //调色板 this.colorsForm2 = new ColorsForm(); this.colorsForm2.StartPosition = FormStartPosition.CenterScreen; this.colorsForm2.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); //调色板 this.colorsForm3 = new ColorsForm(); this.colorsForm3.StartPosition = FormStartPosition.CenterScreen; this.colorsForm3.UserPrimaryColorChanged += new ColorEventHandler(this.colorsFormUserPrimaryColorChanged); this.appWorkspace = appWorkspace; this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace); this.documentWorkspace.Dock = DockStyle.Fill; this.documentWorkspace.HookMouseEvents(); //this.documentWorkspace.AuxiliaryLineEnabled = false; this.documentWorkspace.Visible = false; this.groupBox7.Controls.Add(documentWorkspace); this.commonControlButtons = new CommonControlButtons(); this.commonControlButtons.Dock = DockStyle.Top; this.commonControlButtons.Height = 30; this.commonControlButtons.HideZoomToWindowAndActualSize(); this.commonControlButtons.Visible = false; this.groupBox7.Controls.Add(commonControlButtons); //初始化头 this.listView2.View = View.Details; ColumnHeader header0 = new ColumnHeader(); header0.Text = ""; header0.Width = 180; this.listView2.Columns.Add(header0); documentWorkspace.panel.Paint += Panel_Paint; // 标尺 //this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength); Init(); InitPicList(); this.listView1.SelectedIndexChanged += new EventHandler(this.ListViewSelectedIndexChanged); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲 InitCommonButtonEvent(); SetAnalyzeModelFromXml("Template.Manager.item3.SpheroidizationGrading"); //二值化集成2 bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件 binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text"), PdnResources.GetString("Menu.Grainboundarytoreproduce.text") } , this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构 binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件 for (int i = 0; i < this.dataGridView1.Columns.Count; i++) { this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } for (int i = 0; i < this.dataGridView4.Columns.Count; i++) { this.dataGridView4.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; } } private void ShowImgEvent(object sender, EventArgs e) { listView1.Focus(); if (this.defaultIndex != -1) { this.listView1.Items[defaultIndex].Focused = true; this.listView1.Items[defaultIndex].Selected = true; //如果是脚本执行,将参数带入 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 {//读取上次关闭窗口时保存的参数 GetXmlParameter(); } if (this.initScriptValues && this.appWorkspace.ScriptAutomatic) this.startScriptAutomaticAction(); } } //二值化集成3 #region 二值化相关方法 private void InclusionsStandardDialog_FormClosing(object sender, FormClosingEventArgs e) { #region [开启脚本录制] if (appWorkspace.startScriptRecording) { getScriptRecording(); } #endregion binaryClass.saveParams(); 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.eachData[GetImgKey()].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); } private void ShownChoiseItemAndInitData(object sender, EventArgs e) { binaryClass.RefreshHistogramControl1Values(); } /// /// 添加参数改变的监听 /// /// /// private void SpheroidizationGradingDialog_Load(object sender, EventArgs e) { this.binaryClass.loadParams(); } private bool bcBinaryChecked() { return bc != null && bc.BinaryChecked; } private bool bcOriginChecked() { return bc != null && bc.OriginChecked; } /// /// 参数改变时,重新处理图像 /// /// /// private void bClassBinaryImplFinishAction(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { binarizationMat = this.documentWorkspace.PhaseModels[0].mat; ScreeningSpheroidizedTissue(this.panel1.BackColor, Convert.ToDecimal(this.textBox1.Text), this.panel2.BackColor, Convert.ToDecimal(this.textBox2.Text)); ResultsDisplay(); } this.documentWorkspace.Refresh(); } /// /// 显示原图/原图+二值图 /// /// /// private void bcOriginCheckedChanged(object sender, EventArgs e) { if (!bcOriginChecked()) { if (bcBinaryChecked()) this.documentWorkspace.PhaseModels[0].choise = true; } else { this.documentWorkspace.PhaseModels[0].choise = false; this.documentWorkspace.PhaseModels[1].choise = false; } this.documentWorkspace.Refresh(); } #endregion /// /// 初始化图片列表数据 /// public void InitPicList() { //初始化图片列表 for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++) { this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail); this.listView1.Items.Add("", i); this.listView1.Items[i].ImageIndex = i; this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName(); this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName(); if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace)) { defaultIndex = i; } } this.Shown += ShowImgEvent; } private void Init() { this.init = false; this.dataGridView1.Rows.Clear(); this.documentWorkspace.phaseModels.Clear(); this.checkBox4.Checked = false; this.textBox1.Text = "5"; this.textBox2.Text = "5"; this.init = true; } #region 初始化 private void InitializeLanguageText() { this.bc = new PaintDotNet.CustomControl.BinaryControl(); // // bc // this.bc.BinaryBackColor = System.Drawing.Color.Red; this.bc.BinaryChecked = false; this.bc.BinaryStyle = 1; this.bc.Location = new System.Drawing.Point(151, 59); this.bc.Name = "bc"; this.bc.OriginChecked = false; this.bc.scope1End = 0D; this.bc.scope1Start = 0D; this.bc.scope2End = 0D; this.bc.scope2Start = 0D; this.bc.scope3End = 0D; this.bc.scope3Start = 0D; this.bc.Size = new System.Drawing.Size(360, 292); this.bc.TabIndex = 20; this.Controls.Add(this.bc); this.Controls.SetChildIndex(this.bc, 0); this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text"); this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.button3.Text = PdnResources.GetString("Menu.Edit.Text"); this.button2.Text = PdnResources.GetString("Menu.Saveresult.text"); this.checkBox2.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text"); this.button1.Text = PdnResources.GetString("Menu.Setting.Text"); this.groupBox7.Text = PdnResources.GetString("Menu.Preview.text"); this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text"); this.button4.Text = PdnResources.GetString("Menu.Exportproject.text"); this.button16.Text = PdnResources.GetString("Menu.Cancelshowall.text"); this.label5.Text = PdnResources.GetString("Menu.Decimal.text") + ":"; this.button14.Text = PdnResources.GetString("Menu.Exportresults.text"); this.button13.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text"); this.Column1.HeaderText = PdnResources.GetString("Menu.picture.Text"); this.Column2.HeaderText = PdnResources.GetString("Menu.view.text"); this.Column5.HeaderText = PdnResources.GetString("Menu.nodularity.text"); this.Column6.HeaderText = PdnResources.GetString("Menu.organizationcharacteristics.text"); this.Column7.HeaderText = PdnResources.GetString("Menu.grade.text"); this.button12.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.button11.Text = PdnResources.GetString("Menu.Showall.text"); this.groupBox5.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Sphericalcarbide.text"); this.label8.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Aspectratioislessthan.text") + ":"; this.label7.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox6.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.lamellarpearlite.text"); this.label9.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Aspectrterthan.text") + ":"; this.label10.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox9.Text = PdnResources.GetString("Menu.Measurementofsteelgrade.text"); this.radioButton3.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Mediumcarbonalloystructure.text"); this.radioButton2.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Mediuructure.text"); this.radioButton1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Lowcarbonresults.text"); this.groupBox10.Text = PdnResources.GetString("Menu.Measurementofsteelgrade.text"); this.checkBox4.Text = PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Displayaspectratio.text"); this.groupBox11.Text = PdnResources.GetString("Menu.Theesultshow.text"); this.Column11.HeaderText = PdnResources.GetString("Menu.view.text"); this.dataGridViewTextBoxColumn3.HeaderText = PdnResources.GetString("Menu.nodularity.text"); this.dataGridViewTextBoxColumn4.HeaderText = PdnResources.GetString("Menu.organizationcharacteristics.text"); this.dataGridViewTextBoxColumn5.HeaderText = PdnResources.GetString("Menu.grade.text"); this.Text = "GBT38770" + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Spherorading.text"); this.label1.Text = PdnResources.GetString("Menu.Font.text") + PdnResources.GetString("Menu.size.text") + ":"; this.button5.Text = PdnResources.GetString("Menu.File.SaveAll.Text"); this.button6.Text = PdnResources.GetString("Menu.Applyall.text"); } private void InitializeComponent() { this.components = new System.ComponentModel.Container(); 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(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.listView1 = new System.Windows.Forms.ListView(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button5 = new System.Windows.Forms.Button(); this.button6 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.checkBox2 = new System.Windows.Forms.CheckBox(); this.button1 = new System.Windows.Forms.Button(); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.button4 = new System.Windows.Forms.Button(); this.listView2 = new System.Windows.Forms.ListView(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.button16 = new System.Windows.Forms.Button(); this.label5 = new System.Windows.Forms.Label(); this.button14 = new System.Windows.Forms.Button(); this.button13 = new System.Windows.Forms.Button(); this.dataGridView4 = new System.Windows.Forms.DataGridView(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.button12 = new System.Windows.Forms.Button(); this.button11 = new System.Windows.Forms.Button(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label8 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); this.label7 = new System.Windows.Forms.Label(); this.groupBox6 = new System.Windows.Forms.GroupBox(); this.textBox2 = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); this.panel2 = new System.Windows.Forms.Panel(); this.label10 = new System.Windows.Forms.Label(); this.groupBox9 = new System.Windows.Forms.GroupBox(); this.radioButton3 = new System.Windows.Forms.RadioButton(); this.radioButton2 = new System.Windows.Forms.RadioButton(); this.radioButton1 = new System.Windows.Forms.RadioButton(); this.groupBox10 = new System.Windows.Forms.GroupBox(); this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); this.label1 = new System.Windows.Forms.Label(); this.checkBox4 = new System.Windows.Forms.CheckBox(); this.groupBox11 = new System.Windows.Forms.GroupBox(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox2.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox8.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).BeginInit(); this.groupBox5.SuspendLayout(); this.groupBox6.SuspendLayout(); this.groupBox9.SuspendLayout(); this.groupBox10.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); this.groupBox11.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // groupBox2 // this.groupBox2.Controls.Add(this.listView1); this.groupBox2.Location = new System.Drawing.Point(14, 59); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(135, 648); this.groupBox2.TabIndex = 4; this.groupBox2.TabStop = false; // // listView1 // this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.listView1.HideSelection = false; this.listView1.LargeImageList = this.imageList1; this.listView1.Location = new System.Drawing.Point(5, 17); this.listView1.MultiSelect = false; this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(124, 625); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; this.listView1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseDown); this.listView1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.listView1_MouseUp); // // imageList1 // this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; this.imageList1.ImageSize = new System.Drawing.Size(64, 64); this.imageList1.TransparentColor = System.Drawing.Color.Transparent; // // groupBox1 // this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox1.Controls.Add(this.button5); this.groupBox1.Controls.Add(this.button6); this.groupBox1.Controls.Add(this.button3); this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.checkBox2); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(19, 3); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(1081, 50); this.groupBox1.TabIndex = 5; this.groupBox1.TabStop = false; // // button5 // this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button5.Location = new System.Drawing.Point(986, 14); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(84, 30); this.button5.TabIndex = 19; this.button5.Text = "保存全部"; this.button5.UseVisualStyleBackColor = false; this.button5.Click += new System.EventHandler(this.button5_Click); // // button6 // this.button6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button6.Location = new System.Drawing.Point(715, 14); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(84, 30); this.button6.TabIndex = 18; this.button6.Text = "应用全部"; this.button6.UseVisualStyleBackColor = false; this.button6.Click += new System.EventHandler(this.button6_Click); // // button3 // this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button3.BackColor = System.Drawing.SystemColors.Control; this.button3.Location = new System.Drawing.Point(805, 14); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(84, 30); this.button3.TabIndex = 4; this.button3.UseVisualStyleBackColor = false; this.button3.Click += new System.EventHandler(this.button3_Click); // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button2.BackColor = System.Drawing.SystemColors.Control; this.button2.Location = new System.Drawing.Point(895, 14); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(84, 30); this.button2.TabIndex = 3; this.button2.UseVisualStyleBackColor = false; this.button2.Click += new System.EventHandler(this.button2_Click); // // checkBox2 // this.checkBox2.AutoSize = true; this.checkBox2.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.checkBox2.Location = new System.Drawing.Point(105, 20); this.checkBox2.Name = "checkBox2"; this.checkBox2.Size = new System.Drawing.Size(15, 14); this.checkBox2.TabIndex = 2; this.checkBox2.UseVisualStyleBackColor = true; // // button1 // this.button1.BackColor = System.Drawing.SystemColors.Control; this.button1.Location = new System.Drawing.Point(15, 14); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(84, 30); this.button1.TabIndex = 0; this.button1.UseVisualStyleBackColor = false; this.button1.Click += new System.EventHandler(this.button1_Click); // // groupBox7 // this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox7.Location = new System.Drawing.Point(520, 59); this.groupBox7.Name = "groupBox7"; this.groupBox7.Size = new System.Drawing.Size(580, 648); this.groupBox7.TabIndex = 14; this.groupBox7.TabStop = false; // // groupBox8 // this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox8.Controls.Add(this.button4); this.groupBox8.Controls.Add(this.listView2); this.groupBox8.Controls.Add(this.numericUpDown1); this.groupBox8.Controls.Add(this.button16); this.groupBox8.Controls.Add(this.label5); this.groupBox8.Controls.Add(this.button14); this.groupBox8.Controls.Add(this.button13); this.groupBox8.Controls.Add(this.dataGridView4); this.groupBox8.Controls.Add(this.button12); this.groupBox8.Controls.Add(this.button11); this.groupBox8.Location = new System.Drawing.Point(19, 713); this.groupBox8.Name = "groupBox8"; this.groupBox8.Size = new System.Drawing.Size(1081, 159); this.groupBox8.TabIndex = 15; this.groupBox8.TabStop = false; // // button4 // this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button4.BackColor = System.Drawing.SystemColors.Control; this.button4.Location = new System.Drawing.Point(941, 92); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(128, 26); this.button4.TabIndex = 23; this.button4.UseVisualStyleBackColor = false; this.button4.Click += new System.EventHandler(this.button4_Click); // // listView2 // this.listView2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.listView2.FullRowSelect = true; this.listView2.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.listView2.HideSelection = false; this.listView2.Location = new System.Drawing.Point(16, 56); this.listView2.Name = "listView2"; this.listView2.Size = new System.Drawing.Size(180, 95); this.listView2.TabIndex = 22; this.listView2.UseCompatibleStateImageBehavior = false; this.listView2.ItemSelectionChanged += new System.Windows.Forms.ListViewItemSelectionChangedEventHandler(this.listView2_ItemSelectionChanged); this.listView2.SelectedIndexChanged += new System.EventHandler(this.listView2_SelectedIndexChanged); // // numericUpDown1 // this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.numericUpDown1.Location = new System.Drawing.Point(997, 128); this.numericUpDown1.Maximum = new decimal(new int[] { 10, 0, 0, 0}); this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.Size = new System.Drawing.Size(56, 21); this.numericUpDown1.TabIndex = 21; this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); // // button16 // this.button16.BackColor = System.Drawing.SystemColors.Control; this.button16.Location = new System.Drawing.Point(15, 20); this.button16.Name = "button16"; this.button16.Size = new System.Drawing.Size(93, 26); this.button16.TabIndex = 20; this.button16.UseVisualStyleBackColor = false; this.button16.Click += new System.EventHandler(this.button16_Click); // // label5 // this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(958, 134); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(0, 12); this.label5.TabIndex = 18; // // button14 // this.button14.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button14.BackColor = System.Drawing.SystemColors.Control; this.button14.Location = new System.Drawing.Point(941, 58); this.button14.Name = "button14"; this.button14.Size = new System.Drawing.Size(128, 26); this.button14.TabIndex = 16; this.button14.UseVisualStyleBackColor = false; this.button14.Click += new System.EventHandler(this.button14_Click); // // button13 // this.button13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button13.BackColor = System.Drawing.SystemColors.Control; this.button13.Location = new System.Drawing.Point(941, 24); this.button13.Name = "button13"; this.button13.Size = new System.Drawing.Size(128, 26); this.button13.TabIndex = 12; this.button13.UseVisualStyleBackColor = false; this.button13.Click += new System.EventHandler(this.button13_Click); // // dataGridView4 // this.dataGridView4.AllowUserToAddRows = false; this.dataGridView4.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView4.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView4.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); 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.dataGridView4.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView4.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView4.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column1, this.Column2, this.Column5, this.Column6, this.Column7}); this.dataGridView4.Location = new System.Drawing.Point(228, 20); this.dataGridView4.Name = "dataGridView4"; this.dataGridView4.ReadOnly = true; this.dataGridView4.RowHeadersVisible = false; this.dataGridView4.RowTemplate.Height = 23; this.dataGridView4.Size = new System.Drawing.Size(693, 131); this.dataGridView4.TabIndex = 15; // // Column1 // dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column1.DefaultCellStyle = dataGridViewCellStyle2; this.Column1.Name = "Column1"; this.Column1.ReadOnly = true; // // Column2 // dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column2.DefaultCellStyle = dataGridViewCellStyle3; this.Column2.Name = "Column2"; this.Column2.ReadOnly = true; // // Column5 // dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; this.Column5.DefaultCellStyle = dataGridViewCellStyle4; this.Column5.Name = "Column5"; this.Column5.ReadOnly = true; // // Column6 // dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column6.DefaultCellStyle = dataGridViewCellStyle5; this.Column6.Name = "Column6"; this.Column6.ReadOnly = true; // // Column7 // dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; this.Column7.DefaultCellStyle = dataGridViewCellStyle6; this.Column7.Name = "Column7"; this.Column7.ReadOnly = true; // // button12 // this.button12.BackColor = System.Drawing.SystemColors.Control; this.button12.Location = new System.Drawing.Point(145, 20); this.button12.Name = "button12"; this.button12.Size = new System.Drawing.Size(52, 26); this.button12.TabIndex = 13; this.button12.UseVisualStyleBackColor = false; this.button12.Click += new System.EventHandler(this.button12_Click); // // button11 // this.button11.BackColor = System.Drawing.SystemColors.Control; this.button11.Location = new System.Drawing.Point(15, 20); this.button11.Name = "button11"; this.button11.Size = new System.Drawing.Size(63, 26); this.button11.TabIndex = 12; this.button11.UseVisualStyleBackColor = false; this.button11.Click += new System.EventHandler(this.button11_Click); // // groupBox5 // this.groupBox5.Controls.Add(this.textBox1); this.groupBox5.Controls.Add(this.label8); this.groupBox5.Controls.Add(this.panel1); this.groupBox5.Controls.Add(this.label7); this.groupBox5.Location = new System.Drawing.Point(155, 357); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(356, 45); this.groupBox5.TabIndex = 17; this.groupBox5.TabStop = false; // // textBox1 // this.textBox1.Location = new System.Drawing.Point(235, 17); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(71, 21); this.textBox1.TabIndex = 3; this.textBox1.Text = "5"; this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress); // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(158, 21); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(0, 12); this.label8.TabIndex = 2; // // panel1 // this.panel1.BackColor = System.Drawing.Color.Blue; this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel1.Location = new System.Drawing.Point(70, 17); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(71, 20); this.panel1.TabIndex = 1; this.panel1.BackColorChanged += new System.EventHandler(this.panel1_BackColorChanged); this.panel1.Click += new System.EventHandler(this.panel1_Click); // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(27, 21); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(0, 12); this.label7.TabIndex = 0; // // groupBox6 // this.groupBox6.Controls.Add(this.textBox2); this.groupBox6.Controls.Add(this.label9); this.groupBox6.Controls.Add(this.panel2); this.groupBox6.Controls.Add(this.label10); this.groupBox6.Location = new System.Drawing.Point(155, 408); this.groupBox6.Name = "groupBox6"; this.groupBox6.Size = new System.Drawing.Size(356, 45); this.groupBox6.TabIndex = 17; this.groupBox6.TabStop = false; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(237, 17); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(71, 21); this.textBox2.TabIndex = 7; this.textBox2.Text = "5"; this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged); this.textBox2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox2_KeyPress); // // label9 // this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(158, 21); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(0, 12); this.label9.TabIndex = 6; // // panel2 // this.panel2.BackColor = System.Drawing.Color.Yellow; this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.panel2.Location = new System.Drawing.Point(70, 17); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(73, 20); this.panel2.TabIndex = 5; this.panel2.BackColorChanged += new System.EventHandler(this.panel2_BackColorChanged); this.panel2.Click += new System.EventHandler(this.panel2_Click); // // label10 // this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(27, 21); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(0, 12); this.label10.TabIndex = 4; // // groupBox9 // this.groupBox9.Controls.Add(this.radioButton3); this.groupBox9.Controls.Add(this.radioButton2); this.groupBox9.Controls.Add(this.radioButton1); this.groupBox9.Location = new System.Drawing.Point(155, 459); this.groupBox9.Name = "groupBox9"; this.groupBox9.Size = new System.Drawing.Size(356, 46); this.groupBox9.TabIndex = 17; this.groupBox9.TabStop = false; // // radioButton3 // this.radioButton3.AutoSize = true; this.radioButton3.Location = new System.Drawing.Point(225, 20); this.radioButton3.Name = "radioButton3"; this.radioButton3.Size = new System.Drawing.Size(14, 13); this.radioButton3.TabIndex = 2; this.radioButton3.TabStop = true; this.radioButton3.UseVisualStyleBackColor = true; this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged); // // radioButton2 // this.radioButton2.AutoSize = true; this.radioButton2.Location = new System.Drawing.Point(123, 20); this.radioButton2.Name = "radioButton2"; this.radioButton2.Size = new System.Drawing.Size(14, 13); this.radioButton2.TabIndex = 1; this.radioButton2.TabStop = true; this.radioButton2.UseVisualStyleBackColor = true; this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged); // // radioButton1 // this.radioButton1.AutoSize = true; this.radioButton1.Checked = true; this.radioButton1.Location = new System.Drawing.Point(8, 20); this.radioButton1.Name = "radioButton1"; this.radioButton1.Size = new System.Drawing.Size(14, 13); this.radioButton1.TabIndex = 0; this.radioButton1.TabStop = true; this.radioButton1.UseVisualStyleBackColor = true; this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged); // // groupBox10 // this.groupBox10.Controls.Add(this.numericUpDown2); this.groupBox10.Controls.Add(this.label1); this.groupBox10.Controls.Add(this.checkBox4); this.groupBox10.Location = new System.Drawing.Point(155, 511); this.groupBox10.Name = "groupBox10"; this.groupBox10.Size = new System.Drawing.Size(356, 44); this.groupBox10.TabIndex = 17; this.groupBox10.TabStop = false; // // numericUpDown2 // this.numericUpDown2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.numericUpDown2.Location = new System.Drawing.Point(208, 16); this.numericUpDown2.Maximum = new decimal(new int[] { 9999, 0, 0, 0}); this.numericUpDown2.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.numericUpDown2.Name = "numericUpDown2"; this.numericUpDown2.Size = new System.Drawing.Size(56, 21); this.numericUpDown2.TabIndex = 22; this.numericUpDown2.Value = new decimal(new int[] { 20, 0, 0, 0}); this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(137, 20); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 1; // // checkBox4 // this.checkBox4.AutoSize = true; this.checkBox4.Location = new System.Drawing.Point(11, 20); this.checkBox4.Name = "checkBox4"; this.checkBox4.Size = new System.Drawing.Size(15, 14); this.checkBox4.TabIndex = 0; this.checkBox4.UseVisualStyleBackColor = true; this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged); // // groupBox11 // this.groupBox11.Controls.Add(this.dataGridView1); this.groupBox11.Location = new System.Drawing.Point(155, 561); this.groupBox11.Name = "groupBox11"; this.groupBox11.Size = new System.Drawing.Size(356, 146); this.groupBox11.TabIndex = 17; this.groupBox11.TabStop = false; // // dataGridView1 // this.dataGridView1.AllowUserToAddRows = false; this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control; dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText; dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column11, this.dataGridViewTextBoxColumn3, this.dataGridViewTextBoxColumn4, this.dataGridViewTextBoxColumn5}); this.dataGridView1.Location = new System.Drawing.Point(8, 20); 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(337, 118); this.dataGridView1.TabIndex = 1; // // Column11 // dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.Column11.DefaultCellStyle = dataGridViewCellStyle8; this.Column11.Name = "Column11"; this.Column11.ReadOnly = true; // // dataGridViewTextBoxColumn3 // dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; this.dataGridViewTextBoxColumn3.DefaultCellStyle = dataGridViewCellStyle9; this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3"; this.dataGridViewTextBoxColumn3.ReadOnly = true; // // dataGridViewTextBoxColumn4 // dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; this.dataGridViewTextBoxColumn4.DefaultCellStyle = dataGridViewCellStyle10; this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4"; this.dataGridViewTextBoxColumn4.ReadOnly = true; // // dataGridViewTextBoxColumn5 // dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight; this.dataGridViewTextBoxColumn5.DefaultCellStyle = dataGridViewCellStyle11; this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5"; this.dataGridViewTextBoxColumn5.ReadOnly = true; // // SpheroidizationGradingDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.ClientSize = new System.Drawing.Size(1107, 881); this.Controls.Add(this.groupBox11); this.Controls.Add(this.groupBox10); this.Controls.Add(this.groupBox9); this.Controls.Add(this.groupBox6); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox8); this.Controls.Add(this.groupBox7); this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox2); this.Name = "SpheroidizationGradingDialog"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.InclusionsStandardDialog_FormClosing); this.Load += new System.EventHandler(this.SpheroidizationGradingDialog_Load); this.Shown += new System.EventHandler(this.ShownChoiseItemAndInitData); this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox7, 0); this.Controls.SetChildIndex(this.groupBox8, 0); this.Controls.SetChildIndex(this.groupBox5, 0); this.Controls.SetChildIndex(this.groupBox6, 0); this.Controls.SetChildIndex(this.groupBox9, 0); this.Controls.SetChildIndex(this.groupBox10, 0); this.Controls.SetChildIndex(this.groupBox11, 0); this.groupBox2.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox8.ResumeLayout(false); this.groupBox8.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView4)).EndInit(); this.groupBox5.ResumeLayout(false); this.groupBox5.PerformLayout(); this.groupBox6.ResumeLayout(false); this.groupBox6.PerformLayout(); this.groupBox9.ResumeLayout(false); this.groupBox9.PerformLayout(); this.groupBox10.ResumeLayout(false); this.groupBox10.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); this.groupBox11.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); } #endregion /// /// ListView图片选择改变事件 /// /// /// private void ListViewSelectedIndexChanged(object sender, EventArgs e) { if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected) { this.unitLength = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); GetListParamModel(); this.commonControlButtons.Visible = true; existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList.IsExsitView(); this.bitmap = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap(); if (!existViewFlag) { mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap); } else { mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFullSizeWithRegion()); } //二值化集成4 binaryClass.listView1_SelectedIndexChangedNoCheckedChanged(this.bitmap, this.imageList1.Images.Keys[this.listView1.FocusedItem.Index]); if (bcOriginChecked()) { this.documentWorkspace.PhaseModels[0].choise = false; this.documentWorkspace.PhaseModels[1].choise = false; this.documentWorkspace.Refresh(); } if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { binarizationMat = this.documentWorkspace.PhaseModels[0].mat; ScreeningSpheroidizedTissue(this.panel1.BackColor, Convert.ToDecimal(this.textBox1.Text), this.panel2.BackColor, Convert.ToDecimal(this.textBox2.Text)); ResultsDisplay(); } } } #region 公共按钮 private void InitCommonButtonEvent() { this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click); this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click); this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click); this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click); this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click); this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click); } private void zoomInButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomIn(); } private void zoomOutButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomOut(); } private void zoomToWindowButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow; } private void actualSizeButton_Click(object sender, EventArgs e) { this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor; this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne; } private void pointerButton_Click(object sender, EventArgs e) { this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer; } private void mobileModeButton_Click(object sender, EventArgs e) { this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode; } #endregion private void colorsFormUserPrimaryColorChanged(object sender, ColorEventArgs ce) { } private void panel1_Click(object sender, EventArgs e) { this.colorsForm1.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor); this.colorsForm1.setSaveBtn_Click(new System.EventHandler(this.panel1Changed)); this.colorsForm1.ShowDialog(); } private void panel1Changed(object sender, EventArgs e) { this.panel1.BackColor = this.colorsForm1.UserPrimaryColor.ToColor(); this.colorsForm1.Close(); } private void panel2_Click(object sender, EventArgs e) { this.colorsForm2.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor); this.colorsForm2.setSaveBtn_Click(new System.EventHandler(this.panel2Changed)); this.colorsForm2.ShowDialog(); } private void panel2Changed(object sender, EventArgs e) { this.panel2.BackColor = this.colorsForm2.UserPrimaryColor.ToColor(); this.colorsForm2.Close(); } private decimal getMaxArea(Mat pMat) { double maxArea = 0; Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale); HierarchyIndex[] hierarchy; OpenCvSharp.Point[][] contours; Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone); for (int i = 0; i < contours.Count(); i++) { double area = Cv2.ContourArea(contours[i]); if (area > maxArea) { maxArea = area; } } return (decimal)maxArea; } /// /// 球状宽高比 /// /// /// private void textBox1_TextChanged(object sender, EventArgs e) { if (!this.init) return; if (string.IsNullOrEmpty(this.textBox1.Text)) this.textBox1.Text = "0"; if (this.textBox1.Text.Equals(".0")) this.textBox1.Text = "0"; if (Convert.ToDecimal(this.textBox1.Text) > Convert.ToDecimal(this.textBox2.Text)) { this.textBox2.Text = this.textBox1.Text; } if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { ScreeningSpheroidizedTissue(this.panel1.BackColor, Convert.ToDecimal(this.textBox1.Text), this.panel2.BackColor, Convert.ToDecimal(this.textBox2.Text)); ResultsDisplay(); } this.oldValueT1 = textBox1.Text; this.documentWorkspace.Refresh(); } /// /// 球状颜色 /// /// /// /// private void panel1_BackColorChanged(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { ScreeningSpheroidizedTissue(this.panel1.BackColor, Convert.ToDecimal(this.textBox1.Text), this.panel2.BackColor, Convert.ToDecimal(this.textBox2.Text)); ResultsDisplay(); } this.documentWorkspace.Refresh(); } /// /// 片状宽高比 /// /// /// private void textBox2_TextChanged(object sender, EventArgs e) { if (!this.init) return; if (string.IsNullOrEmpty(this.textBox2.Text)) this.textBox2.Text = "0"; if (this.textBox2.Text.Equals(".0")) this.textBox2.Text = "0"; if (Convert.ToDecimal(this.textBox1.Text) > Convert.ToDecimal(this.textBox2.Text)) { this.textBox1.Text = this.textBox2.Text; } if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { ScreeningSpheroidizedTissue(this.panel1.BackColor, Convert.ToDecimal(this.textBox1.Text), this.panel2.BackColor, Convert.ToDecimal(this.textBox2.Text)); ResultsDisplay(); } this.oldValueT2 = textBox2.Text; this.documentWorkspace.Refresh(); } /// /// 片状颜色 /// /// /// private void panel2_BackColorChanged(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { ScreeningSpheroidizedTissue(this.panel1.BackColor, Convert.ToDecimal(this.textBox1.Text), this.panel2.BackColor, Convert.ToDecimal(this.textBox2.Text)); ResultsDisplay(); } this.documentWorkspace.Refresh(); } /// /// 筛选球化组织 /// private void ScreeningSpheroidizedTissue(Color globularColor, decimal globulAraspectRatio, Color flakColor, decimal flakAspectRatio) { appCommon = new AppCommon(); if (binarizationMat == null) return; // 多视场 if (this.documentWorkspace.GraphicsList.IsExsitView()) { // 原始轮廓信息 Mat temp = new Mat(); this.documentWorkspace.phaseModels[0].mat.CopyTo(temp); List points = new List();//各石墨轮廓集合 List> lstAttribute = new List>();//各个视场属性集合,索引0-横坐标,1-纵坐标,2-视场宽度,3-视场高度,4-视场面积 int sumFieldl = 0; //视场个数 //调用处理视场方法 appCommon.MultiFieldView(appWorkspace, temp, listView1, documentWorkspace, out points, out lstAttribute, out sumFieldl); int viewCount = 0; int h = 0; foreach (OpenCvSharp.Point[][] contours in points) { h++; keyValuePairsList.Add(new Dictionary()); } } else { // 初始化计算面积 sphericalArea = 0; flakArea = 0; independentArea = 0; // 原始轮廓信息 OpenCvSharp.Point[][] contours; HierarchyIndex[] hierachy; Mat temp = new Mat(); binarizationMat.CopyTo(temp); List> globularPoint = new List>(); List> flakyPoint = new List>(); Cv2.FindContours(BinaryClass.BGRA2GRAY(binarizationMat), out contours, out hierachy, RetrievalModes.External, ContourApproximationModes.ApproxNone); if (hierachy.Length > 0) { // 计算所有轮廓质点 keyValuePairs = new Dictionary(); decimal thisAspectRatio = 0; for (int i = 0; i < hierachy.Length; i++) { double area = Math.Abs(Cv2.ContourArea(contours[i])); if (contours[i].Length < 10) continue; else { OpenCvSharp.RotatedRect rect = OpenCvSharp.Cv2.FitEllipse(contours[i]); if (rect.Size.Width != 0) thisAspectRatio = Convert.ToDecimal(rect.Size.Height / rect.Size.Width); else continue; // 取得所有轮廓质点 OpenCvSharp.Moments moments = new OpenCvSharp.Moments(contours[i], false); keyValuePairs.Add(new Point2d(moments.M10 / moments.M00, moments.M01 / moments.M00), thisAspectRatio); if (thisAspectRatio < globulAraspectRatio) { sphericalArea += area * this.unitLength; globularPoint.Add(contours[i].ToList()); } if (thisAspectRatio > flakAspectRatio) { flakArea += area * this.unitLength; flakyPoint.Add(contours[i].ToList()); } if (thisAspectRatio >= 5) independentArea += area * this.unitLength; } } //填充 if (globularPoint.Count > 0) Cv2.FillPoly(temp, globularPoint, new Scalar(globularColor.B, globularColor.G, globularColor.R, 255)); if (flakyPoint.Count > 0) Cv2.FillPoly(temp, flakyPoint, new Scalar(flakColor.B, flakColor.G, flakColor.R, 255)); documentWorkspace.phaseModels[0].mat = temp; } } } /// /// 球状宽高比值验证 /// /// /// private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46) e.Handled = true; //小数点的处理 if ((int)e.KeyChar == 46) { if (textBox1.Text.Length <= 0) e.Handled = true; //小数点不能在第一位 else { float f; float oldf; bool b1 = false, b2 = false; b1 = float.TryParse(textBox1.Text, out oldf); b2 = float.TryParse(textBox1.Text + e.KeyChar.ToString(), out f); if (b2 == false) { if (b1 == true) e.Handled = true; else e.Handled = false; } } } } /// /// 片状宽高比值验证 /// /// /// private void textBox2_KeyPress(object sender, KeyPressEventArgs e) { if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46) e.Handled = true; //小数点的处理 if ((int)e.KeyChar == 46) { if (textBox2.Text.Length <= 0) e.Handled = true; //小数点不能在第一位 else { float f; float oldf; bool b1 = false, b2 = false; b1 = float.TryParse(textBox2.Text, out oldf); b2 = float.TryParse(textBox2.Text + e.KeyChar.ToString(), out f); if (b2 == false) { if (b1 == true) e.Handled = true; else e.Handled = false; } } } } /// /// 画布绘制 /// /// /// private void Panel_Paint(object sender, PaintEventArgs e) { if (this.documentWorkspace.CompositionSurface != null) { // // 以下是计算绘制图片的位置和大小并绘制图片 // System.Drawing.Rectangle rc = this.documentWorkspace.panel.ClientRectangle; int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio); int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio); int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X : (rc.Width - width) / 2; int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y : (rc.Height - height) / 2; // // 以下是绘制网格、标注、测量、视场等开始 // e.Graphics.TranslateTransform(x, y); e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio); Draw(e.Graphics); e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio); e.Graphics.TranslateTransform(-x, -y); } } /// /// 绘制 /// private void Draw(Graphics graphics) { SolidBrush brush1 = new SolidBrush(Color.Black); Font font = new Font("宋体", Convert.ToInt32(this.numericUpDown2.Value)); if (this.checkBox4.Checked) { foreach (var keyValuePair in keyValuePairs) { graphics.DrawString("" + Math.Round(keyValuePair.Value, Convert.ToInt32(this.numericUpDown1.Value)), font, brush1, new System.Drawing.PointF((float)keyValuePair.Key.X, (float)keyValuePair.Key.Y)); } } } /// /// 是否显示宽高比 /// /// /// private void checkBox4_CheckedChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } private double spheroidizationRate; /// /// 结果展示 /// private void ResultsDisplay() { this.dataGridView1.Rows.Clear(); DataGridViewRow dgvr = new DataGridViewRow(); foreach (DataGridViewColumn Column in this.dataGridView1.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } dgvr.Cells[0].Value = PdnResources.GetString("Menu.view.text")+"1"; spheroidizationRate = this.sphericalArea / (this.sphericalArea + this.independentArea + (0.22 * this.flakArea)); if (this.sphericalArea + this.independentArea + this.flakArea != 0) { dgvr.Cells[1].Value = Math.Round((spheroidizationRate * 100), Convert.ToInt32(this.numericUpDown1.Value)) + "%"; } int grade = 0; if (spheroidizationRate * 100 < 5) grade = 1; if (spheroidizationRate * 100 >= 5 && spheroidizationRate * 100 <= 30) grade = 2; if (spheroidizationRate * 100 > 30 && spheroidizationRate * 100 <= 60) grade = 3; if (spheroidizationRate * 100 > 60 && spheroidizationRate * 100 <= 75) grade = 4; if (spheroidizationRate * 100 > 75 && spheroidizationRate * 100 <= 95) grade = 5; if (spheroidizationRate * 100 > 95) grade = 6; if(this.radioButton1.Checked) { if (grade == 1) dgvr.Cells[2].Value = PdnResources.GetString("Menu.ferrite.Text")+" + "+ PdnResources.GetString("Menu.pearlite.Text"); if (grade == 2) dgvr.Cells[2].Value = PdnResources.GetString("Menu.ferrite.Text")+" + "+ PdnResources.GetString("Menu.llamountofspheroidizedbody.Text"); if (grade == 3) dgvr.Cells[2].Value = PdnResources.GetString("Menu.ferrite.Text")+" + "+ PdnResources.GetString("Menu.Spheroidizeandpearlitic.Text"); if (grade == 4) dgvr.Cells[2].Value = PdnResources.GetString("Menu.ferrite.Text")+" + "+ PdnResources.GetString("Menu.mallamountofpearlite.Text"); if (grade == 5) dgvr.Cells[2].Value = PdnResources.GetString("Menu.ferrite.Text")+" + "+ PdnResources.GetString("Menu.Nodularspheroidsnd.Text"); if (grade == 6) dgvr.Cells[2].Value = PdnResources.GetString("Menu.ferrite.Text")+" + "+ PdnResources.GetString("Menu.Thespheroidizingbody.Text"); } else if(this.radioButton2.Checked) { if (grade == 1) dgvr.Cells[2].Value = PdnResources.GetString("Menu.pearlite.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 2) dgvr.Cells[2].Value = PdnResources.GetString("Menu.llamountofspheroidizedbody.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 3) dgvr.Cells[2].Value = PdnResources.GetString("Menu.Spheroidizeandpearlitic.Text")+" + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 4) dgvr.Cells[2].Value = PdnResources.GetString("Menu.Nodularspheroidsnd.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 5) dgvr.Cells[2].Value = PdnResources.GetString("Menu.Nodularspheroidsnd.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 6) dgvr.Cells[2].Value = PdnResources.GetString("Menu.Uniformlydistributedspheroidizedbodies.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); } else { if (grade == 1) dgvr.Cells[2].Value = PdnResources.GetString("Menu.pearlite.Text")+" + "+ PdnResources.GetString("Menu.ferrite.Text"); if (grade == 2) dgvr.Cells[2].Value = PdnResources.GetString("Menu.llamountofspheroidizedbody.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 3) dgvr.Cells[2].Value = PdnResources.GetString("Menu.Spheroidizeandpearlitic.Text")+" + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 4) dgvr.Cells[2].Value = PdnResources.GetString("Menu.Nodularspheroidsnd.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 5) dgvr.Cells[2].Value = PdnResources.GetString("Menu.Thespheroidizingbody.Text")+" + "+ PdnResources.GetString("Menu.Punctatespheroidizedodies.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); if (grade == 6) dgvr.Cells[2].Value = PdnResources.GetString("Menu.Uniformlydistributedspheroidizedbodies.Text")+ " + " + PdnResources.GetString("Menu.ferrite.Text"); } if (grade != 0) dgvr.Cells[3].Value = grade; for (int i = 0; i < dgvr.Cells.Count; i++) { if (dgvr.Cells[i].Value == null || string.IsNullOrEmpty(dgvr.Cells[i].Value.ToString())) { dgvr.Cells[i].Value = PdnResources.GetString("Menu.ereror.Text"); dgvr.Cells[i].Style.BackColor = Color.Red; } else dgvr.Cells[i].Style.BackColor = SystemColors.ControlLightLight; } this.dataGridView1.Rows.Add(dgvr); } /// /// 低碳 /// /// /// private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { ResultsDisplay(); } } /// /// 中碳 /// /// /// private void radioButton2_CheckedChanged(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { ResultsDisplay(); } } /// /// 合金 /// /// /// private void radioButton3_CheckedChanged(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { ResultsDisplay(); } } /// /// 编辑 /// /// /// private void button3_Click(object sender, EventArgs e) { if(this.documentWorkspace.phaseModels.Count == 0 ||this.documentWorkspace.phaseModels[0].mat == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseperonfirst.text")+"!"); return; } SpheroidizationGradingEditDialog spheroidizationGradingEditDialog = new SpheroidizationGradingEditDialog( this.documentWorkspace, bitmap, Convert.ToDecimal(this.textBox1.Text), Convert.ToDecimal(this.textBox2.Text)); spheroidizationGradingEditDialog.StartPosition = FormStartPosition.CenterScreen; spheroidizationGradingEditDialog.ShowDialog(this); } public void EditPageClose(DocumentWorkspaceWindow documentWorkspace) { this.documentWorkspace = documentWorkspace; this.groupBox7.Controls.Add(documentWorkspace); binarizationMat = documentWorkspace.PhaseModels[0].mat; if (this.documentWorkspace.phaseModels.Count > 0 && this.documentWorkspace.phaseModels[0].mat != null) { ScreeningSpheroidizedTissue(this.panel1.BackColor, Convert.ToDecimal(this.textBox1.Text), this.panel2.BackColor, Convert.ToDecimal(this.textBox2.Text)); ResultsDisplay(); } this.documentWorkspace.Refresh(); } /// /// 保存结果 /// /// /// private void button2_Click(object sender, EventArgs e) { if (this.listView1.SelectedItems.Count == 0) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")+"!"); return; } if (this.dataGridView1.Rows.Count == 0) { MessageBox.Show(PdnResources.GetString("Menu.Noresultdata.text")+"!"); return; } for (int i = 0; i < this.dataGridView1.Rows[0].Cells.Count; i++) { if (PdnResources.GetString("Menu.ereror.Text").Equals(this.dataGridView1.Rows[0].Cells[i].Value.ToString())) { MessageBox.Show(PdnResources.GetString("Menu.Resultdataerror.text")+"!"); return; } } string imgName = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetFriendlyName(); string tag = this.imageList1.Images.Keys[this.listView1.SelectedItems[0].Index]; DataTable dataTable = new DataTable(); bool replace = false; int add = 0; foreach (ListViewItem item in this.listView2.Items) { if (item.Tag.Equals(tag)) { add++; DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { replace = true; this.listView2.Items.Remove(item); } break; } } if (replace || this.listView2.Items.Count == 0 || add == 0) { ListViewItem listViewItem = new ListViewItem(); listViewItem.SubItems[0].Text = imgName; listViewItem.Tag = "" + tag; if (this.listView2.Items.Count == 0) this.listView2.Items.Add(listViewItem); else this.listView2.Items.Insert(0, listViewItem); this.dataGridView4.Rows.Clear(); DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = tag; foreach (DataGridViewColumn c in this.dataGridView4.Columns) { dgvr.Cells.Add(c.CellTemplate.Clone() as DataGridViewCell); } dgvr.Cells[0].Value = imgName; dgvr.Cells[1].Value = this.dataGridView1.Rows[0].Cells[0].Value; dgvr.Cells[2].Value = this.dataGridView1.Rows[0].Cells[1].Value; dgvr.Cells[3].Value = this.dataGridView1.Rows[0].Cells[2].Value; dgvr.Cells[4].Value = this.dataGridView1.Rows[0].Cells[3].Value; this.dataGridView4.Rows.Add(dgvr); dataTable.TableName = tag; foreach (System.Data.DataTable dataTable1 in dataTables) { if (dataTable1.TableName.Equals(dataTable.TableName)) { dataTables.Remove(dataTable1); break; } } foreach (DataGridViewColumn c in this.dataGridView4.Columns) { dataTable.Columns.Add(c.HeaderText); } for (int r = 0; r < this.dataGridView4.Rows.Count; r++) { if(this.dataGridView4.Rows[r].Tag.Equals(dataTable.TableName)) { DataRow dataRow = dataTable.NewRow(); for (int c = 0; c < this.dataGridView4.Rows[r].Cells.Count; c++) { if (c == 2) dataRow[this.dataGridView4.Columns[c].HeaderText] = this.spheroidizationRate * 100; else dataRow[this.dataGridView4.Columns[c].HeaderText] = this.dataGridView4.Rows[r].Cells[c].Value; } dataTable.Rows.Add(dataRow); } } this.dataTables.Add(dataTable); if (this.allShow) AllShow(); this.listView2.Items[0].Selected = true; //RefreshDataGridView4(); if (this.documentWorkspace.PhaseModels[0].mat != null) { //保存处理后的图片 double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数 List tempBit = new List(); Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap(); originalBit.Tag = pantographRatio; tempBit.Add(originalBit); Bitmap processedBit = BitmapConverter.ToBitmap(this.documentWorkspace.PhaseModels[0].mat); Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat); Graphics graphics = Graphics.FromImage(newBit); graphics.DrawImage(processedBit, new PointF(0, 0)); Draw(graphics); newBit.Tag = pantographRatio; tempBit.Add(newBit); if (bitDic.ContainsKey(tag)) bitDic[tag] = tempBit; else bitDic.Add(tag, tempBit); } //拼接中间数据 List> dataList = new List>(); List columnName = new List(); columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text")); columnName.Add(PdnResources.GetString("Menu.Aspectio.Text")); dataList.Add(columnName); int ad = 0; foreach (var keyValuePair in keyValuePairs) { List strList = new List(); strList.Add((ad + 1).ToString()); strList.Add(keyValuePair.Value.ToString()); dataList.Add(strList); ad++; } bool isExist = false;//是否已存在进行替换 int modelIndex = -1;//要替换的下标 for (int j = 0; j < tempDataModel.Count; j++) { if (tempDataModel[j].tagName.Equals(tag)) { isExist = true; modelIndex = j; break; } } if (isExist && modelIndex > -1) tempDataModel[modelIndex].dataList = dataList; else { ExportProjectModel newModel = new ExportProjectModel(); newModel.tagName = tag; newModel.picName = imgName; newModel.dataList = dataList; tempDataModel.Add(newModel); } } //listView2_SelectedIndexChanged(null, null); //RefreshDataGridView4(); } /// /// 取消全部显示 /// /// /// private void button16_Click(object sender, EventArgs e) { this.button11.Visible = true; this.button16.Visible = false; this.button11.Focus(); this.allShow = false; RefreshDataGridView4(); //List dataTables1 = new List(); //foreach (var dataTable in this.dataTables) //{ // if (this.listView2.SelectedItems.Count > 0) // { // foreach (ListViewItem item in this.listView2.SelectedItems) // { // if (item.Tag.Equals(dataTable.TableName)) // dataTables1.Add(dataTable); // } // } // else // { // if (this.listView2.Items[0].Tag.Equals(dataTable.TableName)) // dataTables1.Add(dataTable); // } //} //this.dataGridView4.Rows.Clear(); //foreach (System.Data.DataTable item in dataTables1) //{ // if (dataTables.Count > 0) // { // DataGridViewRow dgvr = new DataGridViewRow(); // dgvr.Tag = item.TableName; // foreach (DataGridViewColumn Column in this.dataGridView4.Columns) // { // dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); // } // for (int c = 0; c < item.Columns.Count; c++) // { // if (c == 2) // dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(item.Rows[0][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString() + "%"; // else // dgvr.Cells[c].Value = item.Rows[0][c].ToString(); // } // this.dataGridView4.Rows.Add(dgvr); // } //} } /// /// 全部显示 /// /// /// private void button11_Click(object sender, EventArgs e) { if (this.listView2.Items.Count > 0) { this.button11.Visible = false; this.button16.Visible = true; this.button16.Focus(); this.allShow = true; AllShow(); } else { MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!"); } } private void AllShow() { this.dataGridView4.Rows.Clear(); for (int i = this.dataTables.Count - 1; i >= 0; i--) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = this.dataTables[i].TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < this.dataTables[i].Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[i].Rows[0][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString() + "%"; else dgvr.Cells[c].Value = this.dataTables[i].Rows[0][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } /// /// 分析结果删除 /// /// /// private void button12_Click(object sender, EventArgs e) { if (this.listView2.Items.Count > 0) { if (this.listView2.SelectedItems.Count > 0) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousuretcteddata.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { List detaleName = new List(); int selectIndex = this.listView2.SelectedItems[0].Index; foreach (ListViewItem item in this.listView2.SelectedItems) { detaleName.Add(item.Tag.ToString()); this.listView2.Items.Remove(item); } foreach (string item in detaleName) { foreach (var dataTable in this.dataTables) { if (dataTable.TableName.Equals(item)) { this.dataTables.Remove(dataTable); break; } } if (bitDic.ContainsKey(item)) bitDic.Remove(item); foreach (ExportProjectModel model in this.tempDataModel) { if (model.tagName.Equals(item)) { this.tempDataModel.Remove(model); break; } } } if (this.listView2.Items.Count == 0) this.dataGridView4.Rows.Clear(); else { if (selectIndex == 0) this.listView2.Items[0].Selected = true; else this.listView2.Items[selectIndex - 1].Selected = true; RefreshDataGridView4(); } } } else { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectthedatatobedeleted.text")+"!"); } } else { MessageBox.Show(PdnResources.GetString("Menu.nodata.text")+"!"); } } /// /// 刷新分析结果数据 /// private void RefreshDataGridView4() { if (!this.allShow) { if (this.listView2.SelectedItems.Count > 0) { List dataTableIndex = new List(); for (int i = 0; i < this.dataTables.Count; i++) { foreach (ListViewItem item in this.listView2.SelectedItems) { if (this.dataTables[i].TableName.Equals(this.listView2.SelectedItems[0].Tag)) if (!dataTableIndex.Exists(x => x == i)) { dataTableIndex.Add(i); } } } if (this.dataTables.Count == 0) return; this.dataGridView4.Rows.Clear(); foreach (int item in dataTableIndex) { if (this.dataTables[item].Rows.Count > 0) { for (int r = 0; r < this.dataTables[item].Rows.Count; r++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = this.dataTables[item].TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < this.dataTables[item].Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[item].Rows[0][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString() + "%"; else dgvr.Cells[c].Value = this.dataTables[item].Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } } } else { this.dataGridView4.Rows.Clear(); DataTable dataTable = new DataTable(); for (int i = this.dataTables.Count - 1; i >= 0; i--) { dataTable = this.dataTables[i]; for (int r = 0; r < dataTable.Rows.Count; r++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = dataTable.TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < dataTable.Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(dataTable.Rows[0][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString() + "%"; else dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } } /// /// 未选择分析结果 /// /// /// private void listView2_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { if (!this.allShow) { if (this.listView2.SelectedItems.Count == 0) this.dataGridView4.Rows.Clear(); } } /// /// 切换分析结果 /// /// /// private void listView2_SelectedIndexChanged(object sender, EventArgs e) { if (this.allShow) return; RefreshDataGridView4(); //if (!this.allShow) //{ // if (this.listView2.SelectedItems.Count > 0) // { // List dataTableIndex = new List(); // for (int i = 0; i < this.dataTables.Count; i++) // { // foreach (ListViewItem item in this.listView2.SelectedItems) // { // if(this.dataTables[i].TableName.Equals(item.Tag)) // dataTableIndex.Add(i); // } // } // if (this.dataTables.Count == 0) // return; // this.dataGridView4.Rows.Clear(); // foreach (int item in dataTableIndex) // { // if (this.dataTables[item].Rows.Count > 0) // { // for (int r = 0; r < this.dataTables[item].Rows.Count; r++) // { // DataGridViewRow dgvr = new DataGridViewRow(); // dgvr.Tag = this.dataTables[item].TableName; // foreach (DataGridViewColumn Column in this.dataGridView4.Columns) // { // dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); // } // for (int c = 0; c < this.dataTables[item].Columns.Count; c++) // { // if (c == 2) // dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[item].Rows[0][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString() + "%"; // else // dgvr.Cells[c].Value = this.dataTables[item].Rows[r][c].ToString(); // } // this.dataGridView4.Rows.Add(dgvr); // } // } // } // } //} } /// /// 导出结果 /// /// /// private void button14_Click(object sender, EventArgs e) { if (this.listView2.Items.Count > 0) { SaveFileDialog exe = new SaveFileDialog(); exe.Filter = "Execl files (*.xlsx)|*.xlsx"; exe.FilterIndex = 0; exe.RestoreDirectory = true; exe.Title = "Export Excel File"; exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.Dedicatedanalysis.blackmetal.Spherorading.text")+ PdnResources.GetString("Menu.Analysisresult.text"); DialogResult dr = exe.ShowDialog(); if (dr != DialogResult.OK) { return; } DataTable dtb = new DataTable(); foreach (DataGridViewColumn c in this.dataGridView4.Columns) { dtb.Columns.Add(c.HeaderText); } for (int r = 0; r < this.dataGridView4.Rows.Count; r++) { DataRow dataRow = dtb.NewRow(); for (int c = 0; c < this.dataGridView4.Rows[r].Cells.Count; c++) { dataRow[this.dataGridView4.Columns[c].HeaderText] = this.dataGridView4.Rows[r].Cells[c].Value; } dtb.Rows.Add(dataRow); } List list = new List(); list.Add(dtb); this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true); } else { MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!"); } } /// /// 设置 /// /// /// private void button1_Click(object sender, EventArgs e) { AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.SpheroidizationGrading"); if (recombinationRateSetDialog.hasModule) { recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen; recombinationRateSetDialog.ShowDialog(); } else { recombinationRateSetDialog = null; } } /// /// 不可点击空白区域 /// /// /// private void listView1_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (listView1.SelectedItems.Count > 0) { } else if (listView1.SelectedItems.Count <= 0)//点击空白区 { if (this.listView1.FocusedItem != null) { ListViewItem item = this.listView1.GetItemAt(e.X, e.Y); if (item == null) { this.listView1.FocusedItem.Selected = true; } } } } } /// /// 生成报告 /// /// /// private void button13_Click(object sender, EventArgs e) { if (this.checkBox2.Checked) { AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item3.SpheroidizationGrading"); if (recombinationRateSetDialog.hasModule) { recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen; recombinationRateSetDialog.ShowDialog(); } else { recombinationRateSetDialog = null; } } if (this.analyzeSettingModel != null && !string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify)) { //获取word书签与excel单元格的关系,以字典方式存储 List mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify); Dictionary tagInfos = new Dictionary(); if (mic_module_infos != null && mic_module_infos.Count > 0) { foreach (mic_module_infos info in mic_module_infos) { tagInfos.Add(info.tag_name, info.cell_position); } } List> analysisContent = new List>(); for (int i = 0; i < this.dataGridView4.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dataGridView4.Columns[0].HeaderText); content1.Add(this.dataGridView4.Columns[1].HeaderText); content1.Add(this.dataGridView4.Columns[2].HeaderText); content1.Add(this.dataGridView4.Columns[3].HeaderText); content1.Add(this.dataGridView4.Columns[4].HeaderText); analysisContent.Add(content1); } content1 = new List(); if(this.dataGridView4.Rows[i].Cells[0].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[0].Value.ToString()); else content1.Add(string.Empty); if (this.dataGridView4.Rows[i].Cells[1].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[1].Value.ToString()); else content1.Add(string.Empty); if (this.dataGridView4.Rows[i].Cells[2].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[2].Value.ToString()); else content1.Add(string.Empty); if (this.dataGridView4.Rows[i].Cells[3].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[3].Value.ToString()); else content1.Add(string.Empty); if (this.dataGridView4.Rows[i].Cells[4].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[4].Value.ToString()); else content1.Add(string.Empty); analysisContent.Add(content1); } bitList = new List(); if (this.allShow) { foreach (KeyValuePair> kv in this.bitDic) { bitList.Add(kv.Value[0]); bitList.Add(kv.Value[1]); } } else { if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { foreach (ListViewItem item in this.listView2.SelectedItems) { if (bitDic.ContainsKey(item.Tag.ToString())) { bitList.Add(bitDic[item.Tag.ToString()][0]); bitList.Add(bitDic[item.Tag.ToString()][1]); } } } } this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos); } else MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!"); } /// /// 小数 /// /// /// private void numericUpDown1_ValueChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); ResultsDisplay(); if (this.listView2.Items.Count == 0) return; if (!this.allShow) { if (this.listView2.SelectedItems.Count == 0) { this.listView2.Items[0].Selected = true; } int dataTableIndex = 0; for (int i = 0; i < this.dataTables.Count; i++) { if (this.dataTables[i].TableName.Equals(this.listView2.SelectedItems[0].Tag)) dataTableIndex = i; } if (this.dataTables[dataTableIndex].Rows.Count > 0) { this.dataGridView4.Rows.Clear(); for (int r = 0; r < this.dataTables[dataTableIndex].Rows.Count; r++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = this.dataTables[dataTableIndex].TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < this.dataTables[dataTableIndex].Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(this.dataTables[dataTableIndex].Rows[0][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString() + "%"; else dgvr.Cells[c].Value = this.dataTables[dataTableIndex].Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } else { this.dataGridView4.Rows.Clear(); DataTable dataTable = new DataTable(); for (int i = this.dataTables.Count - 1; i >= 0; i--) { dataTable = this.dataTables[i]; for (int r = 0; r < dataTable.Rows.Count; r++) { DataGridViewRow dgvr = new DataGridViewRow(); dgvr.Tag = dataTable.TableName; foreach (DataGridViewColumn Column in this.dataGridView4.Columns) { dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell); } for (int c = 0; c < dataTable.Columns.Count; c++) { if (c == 2) dgvr.Cells[c].Value = Math.Round((double)Convert.ToDecimal(dataTable.Rows[0][c]), Convert.ToInt32(this.numericUpDown1.Value)).ToString() + "%"; else dgvr.Cells[c].Value = dataTable.Rows[r][c].ToString(); } this.dataGridView4.Rows.Add(dgvr); } } } } /// /// 导出项目 /// /// /// private void button4_Click(object sender, EventArgs e) { try { if (this.analyzeSettingModel == null) { MessageBox.Show(PdnResources.GetString("Menu.Settheexporteitemfirst.Text")); return; } //获取项目工程内的文件夹路径 ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.DedicatedAnalysis.BlackMetal.SpheroidizedStructure.Text", this.analyzeSettingModel.savePath); if (item != null) { //向文件夹内保存图片和报告 if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify)) { //获取word书签与excel单元格的关系,以字典方式存储 List mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify); Dictionary tagInfos = new Dictionary(); if (mic_module_infos != null && mic_module_infos.Count > 0) { foreach (mic_module_infos info in mic_module_infos) { tagInfos.Add(info.tag_name, info.cell_position); } } //分析结果 List> analysisContent = new List>(); for (int i = 0; i < this.dataGridView4.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dataGridView4.Columns[0].HeaderText); content1.Add(this.dataGridView4.Columns[1].HeaderText); content1.Add(this.dataGridView4.Columns[2].HeaderText); content1.Add(this.dataGridView4.Columns[3].HeaderText); content1.Add(this.dataGridView4.Columns[4].HeaderText); analysisContent.Add(content1); } content1 = new List(); if (this.dataGridView4.Rows[i].Cells[0].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[0].Value.ToString()); else content1.Add(string.Empty); if (this.dataGridView4.Rows[i].Cells[1].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[1].Value.ToString()); else content1.Add(string.Empty); if (this.dataGridView4.Rows[i].Cells[2].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[2].Value.ToString()); else content1.Add(string.Empty); if (this.dataGridView4.Rows[i].Cells[3].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[3].Value.ToString()); else content1.Add(string.Empty); if (this.dataGridView4.Rows[i].Cells[4].Value != null) content1.Add(this.dataGridView4.Rows[i].Cells[4].Value.ToString()); else content1.Add(string.Empty); analysisContent.Add(content1); } bitList = new List(); if (this.allShow) { foreach (KeyValuePair> kv in this.bitDic) { bitList.Add(kv.Value[0]); bitList.Add(kv.Value[1]); } } else { if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { foreach (ListViewItem itemL2 in this.listView2.SelectedItems) { if (bitDic.ContainsKey(itemL2.Tag.ToString())) { bitList.Add(bitDic[itemL2.Tag.ToString()][0]); bitList.Add(bitDic[itemL2.Tag.ToString()][1]); } } } } //中间数据 if (!this.allShow) { if (this.listView2.SelectedItems != null && this.listView2.SelectedItems.Count > 0) { List exportModel = new List(); foreach (ListViewItem rowItem in this.listView2.SelectedItems) { foreach (ExportProjectModel model in this.tempDataModel) { if (model.tagName.Equals(rowItem.Tag)) { ExportProjectModel tempModel = new ExportProjectModel(); tempModel.tagName = model.tagName; tempModel.picName = model.picName; tempModel.dataList = model.dataList; exportModel.Add(tempModel); break; } } } this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitList, tagInfos, item.path, item.code); } } else this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, tempDataModel, bitList, tagInfos, item.path, item.code); } else { MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!"); return; } //保存项目信息到数据库 this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item); } } catch (Exception) { } } /// /// 字体大小 /// /// /// private void numericUpDown2_ValueChanged(object sender, EventArgs e) { this.documentWorkspace.Refresh(); } #region 参数保存及提取 /// /// 保存参数的key,value和type /// /// /// /// private void saveParamValue(string param_key, string param_value, int param_type) { bool foundItem = false; if (!this.eachData.ContainsKey(GetImgKey())) { 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(); analysisItem.ListParam = new List(); analysisItem.ListParam.Add(analysisItem); this.eachData.Add(GetImgKey(), analysisItem); } foreach (var item in this.eachData[GetImgKey()].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.eachData[GetImgKey()].ListParam.Add(analysisItem); } } /// /// 保存界面中的参数到model /// private void saveDialogParamValues() { saveParamValue(ParamKey_Report, checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//报告设置 saveParamValue(ParamKey_GlobularColour, panel1.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//球状颜色 saveParamValue(ParamKey_LessThan, textBox1.Text, (int)Base.Dtryt.ItemString);//长宽比小于 saveParamValue(ParamKey_FlakyColour, panel2.BackColor.ToArgb().ToString(), (int)Base.Dtryt.Color);//片状颜色 saveParamValue(ParamKey_GreaterThan, textBox2.Text, (int)Base.Dtryt.ItemString);//长宽比大于 saveParamValue(ParamKey_LowCarbon, radioButton1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//低碳碳素结构 saveParamValue(ParamKey_MediumCarbon, radioButton2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//中碳碳素结构 saveParamValue(ParamKey_MediumCarbonAlloy, radioButton3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//中碳合金结构 saveParamValue(ParamKey_ShowAspectRatio, checkBox4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示长宽比 saveParamValue(ParamKey_FontSize, numericUpDown2.Value.ToString(), (int)Base.Dtryt.Decimal);//字号 saveParamValue(ParamKey_DecimalPlace, numericUpDown1 != null ? numericUpDown1.Value.ToString() : "", (int)Base.Dtryt.Decimal);//保留小数位数 } /// /// 获取保存的参数 /// private void GetListParamModel() { if (this.eachData.ContainsKey(GetImgKey()) && this.eachData[GetImgKey()] != null) { for (int i = 0; i < this.eachData[GetImgKey()].ListParam.Count; i++) { switch (this.eachData[GetImgKey()].ListParam[i].param_key) { case ParamKey_Report: checkBox2.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value; break; case ParamKey_GlobularColour: panel1.BackColor = Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value); break; case ParamKey_LessThan: textBox1.Text = (string)this.eachData[GetImgKey()].ListParam[i].value; break; case ParamKey_FlakyColour: panel2.BackColor = Color.FromArgb((int)this.eachData[GetImgKey()].ListParam[i].value); break; case ParamKey_GreaterThan: textBox2.Text = (string)this.eachData[GetImgKey()].ListParam[i].value; break; case ParamKey_LowCarbon: radioButton1.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value; break; case ParamKey_MediumCarbon: radioButton2.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value; break; case ParamKey_MediumCarbonAlloy: radioButton3.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value; break; case ParamKey_ShowAspectRatio: checkBox4.Checked = (Boolean)this.eachData[GetImgKey()].ListParam[i].value; break; case ParamKey_FontSize: numericUpDown2.Value = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value); break; case ParamKey_DecimalPlace: numericUpDown1.Value = decimal.Parse(this.eachData[GetImgKey()].ListParam[i].param_value); break; } } } } /// /// 获取XML保存的参数 /// private void GetXmlParameter() { string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\GrainSizeAnalyze\\GrainSizeAnalysisModel.xml"; GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open)); for (int i = 0; i < listView1.Items.Count; i++) { if (this.eachData.ContainsKey(listView1.Items[i].Index.ToString())) { this.eachData[listView1.Items[i].Index.ToString()] = analysisModelXml.cloneListParamModel(this.menuId); } else { this.eachData.Add(listView1.Items[i].Index.ToString(), analysisModelXml.cloneListParamModel(this.menuId)); } } foreach (var item in this.eachData[GetImgKey()].ListParam) item.setValue(); } /// /// 保存参数,防止没有图片 /// private void NullKey() { GrainSizeAnalysisModel grainsizeanalysismodel = new GrainSizeAnalysisModel(); grainsizeanalysismodel.ListParam = new List(); this.eachData.Add("null", grainsizeanalysismodel); } private string GetImgKey() { string key = this.listView1.FocusedItem != null ? this.listView1.FocusedItem.Index.ToString() : "null"; return key; } #endregion private void button6_Click(object sender, EventArgs e) { if (this.listView1.FocusedItem == null) { return; } binaryClass.saveParams(); binaryClass.applyToAll(this.imageList1.Images.Keys, this.imageList1.Images.Keys[int.Parse(GetImgKey())]); saveDialogParamValues(); GrainSizeAnalysisModel data = new GrainSizeAnalysisModel(); if (eachData.ContainsKey(GetImgKey())) { data = eachData[GetImgKey()]; } for (int i = 0; i < listView1.Items.Count; i++) { eachData[i.ToString()] = data.cloneListParamModel(this.menuId); this.listView1.EnsureVisible(i); this.listView1.Items[i].Focused = true; this.listView1.Items[i].Selected = true; } } private void button5_Click(object sender, EventArgs e) { if (this.listView1.FocusedItem == null) { return; } if (eachData.Count - 1 != listView1.Items.Count) { MessageBox.Show("请先点击应用全部!"); return; } saveDialogParamValues(); int current = int.Parse(GetImgKey()); for (int i = 0; i < listView1.Items.Count; i++) { this.listView1.EnsureVisible(i); this.listView1.Items[i].Focused = true; this.listView1.Items[i].Selected = true; this.button2.PerformClick(); } this.listView1.EnsureVisible(current); this.listView1.Items[current].Focused = true; this.listView1.Items[current].Selected = true; } private void listView1_MouseDown(object sender, MouseEventArgs e) { if (this.listView1.FocusedItem != null) saveDialogParamValues(); } #region [脚本相关] private void getValue(string key, object value) { switch (key) { case "parameter1": panel1.BackColor = Color.FromArgb(Convert.ToInt32(value)); break; case "parameter2": textBox1.Text = value.ToString(); break; case "parameter3": panel2.BackColor = Color.FromArgb(Convert.ToInt32(value)); break; case "parameter4": textBox2.Text = value.ToString(); break; case "parameter5": int val1 = (int)value; radioButton1.Checked = val1 == 1 ? true : false; radioButton2.Checked = val1 == 2 ? true : false; radioButton3.Checked = val1 == 3 ? true : false; break; case "parameter6": checkBox4.Checked = Convert.ToBoolean(value); break; case "parameter7": numericUpDown2.Value = Convert.ToDecimal(value); break; case "OpenWhileExportReport": checkBox2.Checked = Convert.ToBoolean(value); break; case "CalculatorDecimalDigits": numericUpDown1.Value = Convert.ToDecimal(value); break; case "ExportResults": isExportResults = Convert.ToBoolean(value); break; case "ExportReports": isExportReports = Convert.ToBoolean(value); break; case "ExportProjects": isExportProjects = Convert.ToBoolean(value); break; } } private void startScriptAutomaticAction() { this.button6.PerformClick(); this.button5.PerformClick(); this.button11.Visible = false; this.button16.Visible = true; this.button16.Focus(); this.allShow = true; AllShow(); if (isExportResults)//导出结果 this.button14.PerformClick(); if (isExportReports)//生成报告 this.button13.PerformClick(); if (isExportProjects)//导出项目 this.button4.PerformClick(); this.appWorkspace.ScriptAutomatic = false; this.Close(); } #endregion #region [脚本录制] private 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": value = panel1.BackColor.ToArgb(); break; case "parameter2": value = textBox1.Text; break; case "parameter3": value = panel2.BackColor.ToArgb(); break; case "parameter4": value = textBox2.Text ; break; case "parameter5": if (radioButton1.Checked) { value = 1; } else if (radioButton2.Checked) { value = 2; } else if (radioButton3.Checked) { value = 3; } break; case "parameter6": value = checkBox4.Checked; break; case "parameter7": value = numericUpDown2.Value; break; case "OpenWhileExportReport": value = checkBox2.Checked; break; case "CalculatorDecimalDigits": value = numericUpDown1.Value; break; case "ExportResults": value = isExportResults; break; case "ExportReports": value = isExportReports; break; case "ExportProjects": value = isExportProjects; break; } return value; } #endregion } }