using OpenCvSharp; using PaintDotNet.Base.Functionodel; using PaintDotNet.CustomControl; using PaintDotNet.GeneralAnalysis.AnalysisResultTemplate; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Windows.Forms; using PaintDotNet.DbOpreate.DbBll; using PaintDotNet.DbOpreate.DbModel; using Point = OpenCvSharp.Point; using PaintDotNet.Base.CommTool; using PaintDotNet.Instrument; using PaintDotNet.Annotation.Enum; using Metis.ParameterSet; using System.IO; using PaintDotNet.Data.Param; using PaintDotNet.Base; namespace PaintDotNet.GeneralAnalysis { /// /// 两相比例 /// internal class TwoPhaseScaleDialog : PdnBaseForm { #region 控件 private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.ListView listView1; private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button button2; private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.GroupBox groupBox_review; private System.Windows.Forms.GroupBox groupBox5; private System.Windows.Forms.GroupBox groupBox6; private System.Windows.Forms.GroupBox groupBox7; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button3; private System.Windows.Forms.ImageList imageList1; private DataGridView dataGridView_results; private Button button_remove; private Button button_all; private Button button5; private GroupBox groupBox8; private Label label6; private Label label5; private Label label7; private Label label8; private TextBox txt_UnSelectArea; private TextBox txt_UnSelectCount; private TextBox txt_SelectCountPersent; private TextBox txt_SelectArea; private TextBox txt_SelectCount; private Label label9; private TextBox txt_UnSelectCountPersent; private Label label10; private IContainer components; private Label label13; private TextBox txt_UnSelectContent; private TextBox txt_SelectContent; private Label label12; private Label label11; private Label label14; private TextBox txt_UnSelectCountFromAll; private TextBox txt_SelectContentFromAll; private Label label15; private Label label16; private TextBox txt_UnSelectDivSelectCount; private TextBox txt_SelectCountDivUnSelect; private ColorsForm oneColorsForm; private ColorsForm twoColorsForm; private NumericUpDown numericUpDown3; #endregion private CommonControlButtons commonControlButtons; /// /// 主空间 /// private AppWorkspace appWorkspace; /// /// 选中图片的mat /// private Mat imageMat; /// /// 选择物相index /// int selectIndex = 0; /// /// 当前选择的图片index /// int selectImageIndex = 0; int decnum = 2; /// /// 分析类型 0 面积 1 面积比 2 长宽比 4 最大卡规直径 /// int workType = 0; TwoPhaseScaleResult selectResults = new TwoPhaseScaleResult(); TwoPhaseScaleResult unSelectResults = new TwoPhaseScaleResult(); PhaseModel onePhase = new PhaseModel(); private DocumentWorkspaceWindow documentWorkspace; private List finalResults = new List(); private List bitList = new List(); private Button button9; private CheckedListBox listBox_analysisResult; private Dictionary> bitDic = new Dictionary>(); private Label label2; private Label label3; private Label label4; private NumericUpDown numericUpDown1; private NumericUpDown numericUpDown2; private ComboBox comboBox1; private Label label17; private Label label18; private TriangleTrackBar trackBar2; private TriangleTrackBar trackBar1; private Label label19; private Label label20; private Panel panel1; private Panel panel2; private GroupBox groupBox2; private Label label21; private int is_all = 0; private int menuId; private string menuName; /// /// 是否脚本运行 /// private Boolean initScriptValues = false; private List points = new List(); /// /// 当前选择的搜索选项 /// int selectSearchIndex = 0; private DataGridViewTextBoxColumn Column12; private DataGridViewTextBoxColumn Column1; private DataGridViewTextBoxColumn Column2; private DataGridViewTextBoxColumn Column3; private DataGridViewTextBoxColumn Column4; private DataGridViewTextBoxColumn Column5; private DataGridViewTextBoxColumn Column6; private DataGridViewTextBoxColumn Column7; private DataGridViewTextBoxColumn Column8; private DataGridViewTextBoxColumn Column9; private DataGridViewTextBoxColumn Column10; private DataGridViewTextBoxColumn Column11; private DataGridViewTextBoxColumn Column13; private int imgIndex = -1; private ComboBox comboBox2; private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel(); private string selectedImg = string.Empty; private Dictionary everyImgData = new Dictionary(); public TwoPhaseScaleDialog() { InitializeComponent(); } private void showImg(object sender, EventArgs e) { listView1.Focus(); //滚动到指定的行位置 if (this.imgIndex != -1) { this.listView1.EnsureVisible(this.imgIndex); this.listView1.Items[imgIndex].Focused = true; this.listView1.Items[imgIndex].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 {//读取上次关闭窗口时保存的参数 getLastData(); } } } /// /// 获取上次操作参数 /// private void getLastData() { string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml"; if (!System.IO.File.Exists(filePath)) { generalAnalysisModel = new GeneralAnalysisModel(); generalAnalysisModel.PolyphaseMutiAreaContentModels = new GeneralAnalysisModel.PolyphaseMutiAreaContentModel(); generalAnalysisModel.PolyphaseCounterAnalysisModels = new GeneralAnalysisModel.PolyphaseCounterAnalysisModel(); generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel(); generalAnalysisModel.PolyphaseContentModels = new GeneralAnalysisModel.PolyphaseContentModel(); generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel(); generalAnalysisModel.DebrisSelectionModels = new GeneralAnalysisModel.DebrisSelectionModel(); generalAnalysisModel.CountNumberAnalysisModels = new GeneralAnalysisModel.CountNumberAnalysisModel(); generalAnalysisModel.PolyphaseMutiAreaContentModels.hasUsed = false; generalAnalysisModel.PolyphaseCounterAnalysisModels.hasUsed = false; generalAnalysisModel.TwoPhaseScaleModels.hasUsed = false; generalAnalysisModel.PolyphaseContentModels.hasUsed = false; generalAnalysisModel.PolyphaseDistanceModels.hasUsed = false; generalAnalysisModel.DebrisSelectionModels.hasUsed = false; generalAnalysisModel.CountNumberAnalysisModels.hasUsed = false; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(generalAnalysisModel); Directory.CreateDirectory(Application.StartupPath + "\\Config\\Default\\ParameterSaving\\"); FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.CreateNew); } else { generalAnalysisModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, FileMode.Open)); if (generalAnalysisModel.TwoPhaseScaleModels == null) { generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel(); } if (generalAnalysisModel.TwoPhaseScaleModels.hasUsed) { if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0) { if (!string.IsNullOrEmpty(generalAnalysisModel.TwoPhaseScaleModels.parameter1)) { comboBox1.SelectedItem = generalAnalysisModel.TwoPhaseScaleModels.parameter1; } if (!string.IsNullOrEmpty(generalAnalysisModel.TwoPhaseScaleModels.parameter2)) { comboBox2.SelectedItem = generalAnalysisModel.TwoPhaseScaleModels.parameter2; } if (numericUpDown1.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter3 || numericUpDown1.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter3) { numericUpDown1.Value = 0; } else { numericUpDown1.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter3; } if (numericUpDown2.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter4 || numericUpDown2.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter4) { numericUpDown2.Value = 0; } else { numericUpDown2.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter4; } if (trackBar1.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter3 || trackBar1.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter3) { trackBar1.Value = 0; } else { trackBar1.Value = (int)generalAnalysisModel.TwoPhaseScaleModels.parameter3; } if (trackBar2.Minimum > generalAnalysisModel.TwoPhaseScaleModels.parameter4 || trackBar2.Maximum < generalAnalysisModel.TwoPhaseScaleModels.parameter4) { trackBar2.Value = 0; } else { trackBar2.Value = (int)generalAnalysisModel.TwoPhaseScaleModels.parameter4; } panel1.BackColor = generalAnalysisModel.TwoPhaseScaleModels.parameter5 == 0 ? Color.Red: Color.FromArgb(generalAnalysisModel.TwoPhaseScaleModels.parameter5); panel2.BackColor = generalAnalysisModel.TwoPhaseScaleModels.parameter6 == 0 ? Color.Yellow:Color.FromArgb(generalAnalysisModel.TwoPhaseScaleModels.parameter6); } numericUpDown3.Value = generalAnalysisModel.TwoPhaseScaleModels.parameter7; checkBox1.Checked = generalAnalysisModel.TwoPhaseScaleModels.parameter8; if (comboBox1.SelectedIndex != -1 && comboBox2.SelectedIndex != -1) { GetAreaBetweenMinToMax(generalAnalysisModel.TwoPhaseScaleModels.parameter3, generalAnalysisModel.TwoPhaseScaleModels.parameter4, this.documentWorkspace.phaseModels[selectIndex].mat); } for (int i = 0; i < listView1.Items.Count; i++) { if (everyImgData.ContainsKey(listView1.Items[i].Name)) { everyImgData[listView1.Items[i].Name] = generalAnalysisModel.TwoPhaseScaleModels; } else { everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.TwoPhaseScaleModels); } } } } } /// /// 保存上次操作参数 /// private void saveLastData(object sender, EventArgs e) { #region [开启脚本录制] if (appWorkspace.startScriptRecording) { getScriptRecording(); } #endregion if (generalAnalysisModel.TwoPhaseScaleModels == null) { generalAnalysisModel.TwoPhaseScaleModels = new GeneralAnalysisModel.TwoPhaseScaleModel(); } generalAnalysisModel.TwoPhaseScaleModels.hasUsed = true; if (this.listView1.FocusedItem != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0) { if (this.listView1.FocusedItem != null && this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0) { if (comboBox1.SelectedIndex != -1) { generalAnalysisModel.TwoPhaseScaleModels.parameter1 = comboBox1.SelectedItem.ToString(); } if (comboBox2.SelectedIndex != -1) { generalAnalysisModel.TwoPhaseScaleModels.parameter2 = comboBox2.SelectedItem.ToString(); } } generalAnalysisModel.TwoPhaseScaleModels.parameter3 = numericUpDown1.Value; generalAnalysisModel.TwoPhaseScaleModels.parameter4 = numericUpDown2.Value; generalAnalysisModel.TwoPhaseScaleModels.parameter5 = panel1.BackColor.ToArgb(); generalAnalysisModel.TwoPhaseScaleModels.parameter6 = panel2.BackColor.ToArgb(); } generalAnalysisModel.TwoPhaseScaleModels.parameter7 = (int)numericUpDown3.Value; generalAnalysisModel.TwoPhaseScaleModels.parameter8 = checkBox1.Checked; string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml"; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(generalAnalysisModel); FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create); } /// /// 初始化图片列表数据 /// 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; String imageName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName(); if (listView1.Items.Find(imageName, false).Count() > 0) { if (imageName.Split('.').Count() > 1) { imageName = imageName.Split('.')[0] + "(" + listView1.Items.Find(imageName, false).Count() + ")." + imageName.Split('.')[1]; } } this.listView1.Items[i].Text = imageName; this.listView1.Items[i].Name = imageName; if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace)) { this.imgIndex = i; } } } public TwoPhaseScaleDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem) { InitializeComponent(); InitializeLanguageText(); this.appWorkspace = appWorkspace; this.menuId = menuItem.MenuId; this.menuName = menuItem.Text; this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace); this.documentWorkspace.Dock = DockStyle.Fill; this.documentWorkspace.HookMouseEvents(); this.documentWorkspace.AuxiliaryLineEnabled = false; this.documentWorkspace.Visible = false; oneColorsForm = new ColorsForm(); this.oneColorsForm.StartPosition = FormStartPosition.CenterScreen; twoColorsForm = new ColorsForm(); this.twoColorsForm.StartPosition = FormStartPosition.CenterParent; this.groupBox_review.Controls.Add(documentWorkspace); this.commonControlButtons = new CommonControlButtons(); this.commonControlButtons.Dock = DockStyle.Top; this.commonControlButtons.Height = 30; this.commonControlButtons.HideZoomToWindowAndActualSize(); this.groupBox_review.Controls.Add(commonControlButtons); InitPicList(); SetAnalyzeModelFromXml("Template.Manager.item2.TwoPhaseScale"); this.listView1.SelectedIndexChanged += new EventHandler(this.ListViewSelectedIndexChanged); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景. SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲 InitCommonButtonEvent(); this.Shown += showImg; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData); } 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) { if (this.imageMat != null) this.documentWorkspace.ZoomIn(); } private void zoomOutButton_Click(object sender, EventArgs e) { if (this.imageMat != null) 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; } private void Init() { //this.trackBar1.Value = 0; //this.trackBar2.Value = 0; //this.numericUpDown1.Value = 0; //this.numericUpDown2.Value = 0; selectResults = new TwoPhaseScaleResult(); unSelectResults = new TwoPhaseScaleResult(); //InitUI(); } /// /// ListView图片选择改变事件 /// /// /// private void ListViewSelectedIndexChanged(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 1) { if (this.listView1.SelectedItems.Count > 0 && this.listView1.FocusedItem != null) { if (!string.IsNullOrEmpty(this.selectedImg)) { #region [保存参数] var model = new GeneralAnalysisModel.TwoPhaseScaleModel(); if (comboBox1.SelectedIndex != -1) { model.parameter1 = comboBox1.SelectedItem.ToString(); } if (comboBox2.SelectedIndex != -1) { model.parameter2 = comboBox2.SelectedItem.ToString(); } model.parameter3 = (int)numericUpDown1.Value; model.parameter4 = (int)numericUpDown2.Value; model.parameter5 = panel1.BackColor.ToArgb(); model.parameter6 = panel2.BackColor.ToArgb(); if (everyImgData.ContainsKey(this.selectedImg)) { everyImgData[this.selectedImg] = model; } else { everyImgData.Add(this.selectedImg, model); } #endregion } this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat(); Document document = Document.FromImageMat(imageMat.Clone()); this.documentWorkspace.Document = document; this.documentWorkspace.Visible = true; this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GraphicsList; this.documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].PhaseModelsForCopy; if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.enophasesavailableforanalysi.text")); //return; } comboBox1.Items.Clear(); comboBox1.Text = ""; comboBox1.SelectedIndex = -1; comboBox2.SelectedIndex = -1; onePhase.mat = null; documentWorkspace.phaseModels.RemoveAll(u => u.name == "one"); for (int i = 0; i < this.documentWorkspace.phaseModels.Count; i++) { comboBox1.Items.Add(this.documentWorkspace.phaseModels[i].name); } #region [设置参数] this.selectedImg = this.listView1.FocusedItem.Name; if (everyImgData.ContainsKey(selectedImg)) { var model = everyImgData[selectedImg]; if (this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].phaseModels.Count != 0) { if (!string.IsNullOrEmpty(model.parameter1)) { comboBox1.SelectedItem = model.parameter1; comboBox1_SelectedIndexChanged(sender, e); } if (!string.IsNullOrEmpty(model.parameter2)) { comboBox2.SelectedItem = model.parameter2; } //numericUpDown1.Value = model.parameter3; //numericUpDown2.Value = model.parameter4; //trackBar1.Value = (int)model.parameter3; //trackBar2.Value = (int)model.parameter4; if (numericUpDown1.Minimum > model.parameter3 || numericUpDown1.Maximum < model.parameter3) { numericUpDown1.Value = 0; } else { numericUpDown1.Value = model.parameter3; } if (numericUpDown2.Minimum > model.parameter4 || numericUpDown2.Maximum < model.parameter4) { numericUpDown2.Value = 0; } else { numericUpDown2.Value = model.parameter4; } if (trackBar1.Minimum > model.parameter3 || trackBar1.Maximum < model.parameter3) { trackBar1.Value = 0; } else { trackBar1.Value = (int)model.parameter3; } if (trackBar2.Minimum > model.parameter4 || trackBar2.Maximum < model.parameter4) { trackBar2.Value = 0; } else { trackBar2.Value = (int)model.parameter4; } panel1.BackColor = model.parameter5 == 0 ? Color.Red : Color.FromArgb(model.parameter5); panel2.BackColor = model.parameter5 == 0 ? Color.Yellow : Color.FromArgb(model.parameter6); } numericUpDown3.Value = model.parameter7; checkBox1.Checked = model.parameter8; if (comboBox1.SelectedIndex != -1 && comboBox2.SelectedIndex != -1) { GetAreaBetweenMinToMax(model.parameter3, model.parameter4, this.documentWorkspace.phaseModels[selectIndex].mat); } UpdateUI(); } else { InitUI(); } #endregion Init(); } } } private void UpdateUI() { //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); this.txt_SelectCount.Text = selectResults.Count.ToString(); this.txt_SelectArea.Text = (AnalysisTools.GetDecNum(selectResults.Area, decnum)).ToString(); this.txt_SelectCountPersent.Text = AnalysisTools.GetDecNum(selectResults.CountPercent, decnum) + " %"; this.txt_SelectContent.Text = AnalysisTools.GetDecNum(selectResults.Content, decnum) + " %"; this.txt_SelectContentFromAll.Text = AnalysisTools.GetDecNum(selectResults.ContentFromAll, decnum) + " %"; this.txt_SelectCountDivUnSelect.Text = AnalysisTools.GetDecNum(selectResults.CountScaleU, decnum) + " %"; this.txt_UnSelectCount.Text = unSelectResults.Count.ToString(); this.txt_UnSelectArea.Text = (AnalysisTools.GetDecNum(unSelectResults.Area, decnum)).ToString(); this.txt_UnSelectCountPersent.Text = AnalysisTools.GetDecNum(unSelectResults.CountPercent, decnum) + " %"; this.txt_UnSelectCountFromAll.Text = AnalysisTools.GetDecNum(unSelectResults.ContentFromAll, decnum) + " %"; this.txt_UnSelectContent.Text = AnalysisTools.GetDecNum(unSelectResults.Content, decnum) + " %"; this.txt_UnSelectDivSelectCount.Text = AnalysisTools.GetDecNum(unSelectResults.CountScaleU, decnum) + " %"; } private void InitUI() { this.txt_SelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_SelectArea.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_SelectCountPersent.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_SelectContent.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_SelectContentFromAll.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_SelectCountDivUnSelect.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_UnSelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_UnSelectArea.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_UnSelectCountPersent.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_UnSelectCountFromAll.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_UnSelectContent.Text = PdnResources.GetString("Menu.Nottochoose.text"); this.txt_UnSelectDivSelectCount.Text = PdnResources.GetString("Menu.Nottochoose.text"); } private void GetAreaBetweenMinToMax(decimal areaMin, decimal areaMax, Mat pMat) { if (onePhase.mat == null) { System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Nooperationalphasefound.text")); return; } List oneContours = new List(); List twoContours = new List(); Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale); HierarchyIndex[] hierarchy; OpenCvSharp.Point[][] contours; Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone); int amount = contours.Length; //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); #region [获取总面积] int allArea = 0; if (this.documentWorkspace.GraphicsList.IsExsitView()) { for (int i = 0; i < this.documentWorkspace.GraphicsList.Count; i++) { switch (this.documentWorkspace.GraphicsList[i].drawToolType) { case DrawToolType.ViewOval: allArea = (int)(Math.PI * this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height); break; case DrawToolType.ViewCircle: allArea = (int)(Math.PI * (this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height * 0.25)); break; case DrawToolType.ViewRectangle: allArea = (int)(this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height); break; case DrawToolType.ViewTriangle: allArea = (int)(0.5 * this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height); break; case DrawToolType.ViewSquare: allArea = (int)(this.documentWorkspace.GraphicsList[i].Rectangle.Width * this.documentWorkspace.GraphicsList[i].Rectangle.Height); break; case DrawToolType.ViewRectangleEx: case DrawToolType.ViewPolygon: case DrawToolType.ViewTriangleEx: for (int k = 0; k < this.documentWorkspace.GraphicsList[i].Rectangle.Height; k++) { for (int j = 0; j < this.documentWorkspace.GraphicsList[i].Rectangle.Width; j++) { allArea += 1; } } break; } } } else { allArea = (int)(mat.Height * mat.Width); } allArea = (int)(allArea * pxPerUnit * pxPerUnit); #endregion int selectCount = 0; double areaAmount = 0; double selectAreaAmount = 0; List areaList = new List(); selectResults = new TwoPhaseScaleResult(); unSelectResults = new TwoPhaseScaleResult(); switch (workType) { case 1://面积过滤 for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if ((decimal)area >= areaMin && (decimal)area <= areaMax) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 2://面积比 Point2f center; for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))); float radius; Cv2.MinEnclosingCircle(contours[i], out center, out radius); double areaPercent = area / (Math.PI * radius * radius); area = (int)(area * pxPerUnit * pxPerUnit); areaAmount += area; if (areaPercent >= Convert.ToSingle(areaMin) && areaPercent <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 3: //周长 for (int i = 0; i < contours.Length; i++) { int p = (int)(contours[i].Length * pxPerUnit); double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (p >= Convert.ToSingle(areaMin) && p <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 4: // 长轴 for (int i = 0; i < contours.Length; i++) { RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]); double width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * pxPerUnit : ellipsemege.Size.Height * pxPerUnit; double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 5: // 短轴 for (int i = 0; i < contours.Length; i++) { RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]); double width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * pxPerUnit : ellipsemege.Size.Height * pxPerUnit; double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 6: // 倾斜角度 for (int i = 0; i < contours.Length; i++) { if (contours[i].Count() < 5) { continue; } RotatedRect ellipsemege = Cv2.FitEllipse(contours[i]); float width = ellipsemege.Angle; double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 7: // 高度 for (int i = 0; i < contours.Length; i++) { Rect ellipsemege = Cv2.BoundingRect(contours[i]); double width = ellipsemege.Size.Height * pxPerUnit; double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 8:// 宽度 for (int i = 0; i < contours.Length; i++) { Rect ellipsemege = Cv2.BoundingRect(contours[i]); double width = ellipsemege.Size.Width * pxPerUnit; double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 9://长宽比 for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; Rect rect = Cv2.BoundingRect(contours[i]); decimal ckb = (decimal)(rect.Width / rect.Height); if (ckb >= areaMin && ckb <= areaMax) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 10: // 长径 for (int i = 0; i < contours.Length; i++) { RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]); double width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 * pxPerUnit : ellipsemege.Size.Height * 0.5 * pxPerUnit; double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 11: // 短径 for (int i = 0; i < contours.Length; i++) { RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]); double width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 * pxPerUnit : ellipsemege.Size.Height * 0.5 * pxPerUnit; double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 12: // 外接圆直径 Point2f point; for (int i = 0; i < contours.Length; i++) { float radius; Cv2.MinEnclosingCircle(contours[i], out point, out radius); double width = radius * 2 * pxPerUnit; double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 13: // 球化率 Point2f pointF; for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))); areaAmount += area; float radius; Cv2.MinEnclosingCircle(contours[i], out pointF, out radius); double width = (area / (Math.PI * radius * radius)); area = (Cv2.ContourArea(contours[i]) * pxPerUnit * pxPerUnit); areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 14: // 等积圆直径 for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; var width = (Math.Sqrt(area / Math.PI) * 2); if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 15://最大卡规直径 for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; List vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points); decimal diam = (decimal)(vs.Max() * pxPerUnit); if (diam >= areaMin && diam <= areaMax) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 16://最小卡规直径 for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; List vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points); decimal diam = (decimal)(vs.Min() * pxPerUnit); if (diam >= areaMin && diam <= areaMax) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 17://平均卡规直径 for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))) * pxPerUnit * pxPerUnit; areaAmount += area; List vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points); decimal diam = (decimal)(vs.Average() * pxPerUnit); if (diam >= areaMin && diam <= areaMax) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; case 18: // 纤维长度 for (int i = 0; i < contours.Length; i++) { double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))); var width = ((contours[i].Length + Math.Sqrt(contours[i].Length * contours[i].Length + 16 * area)) / 4) * pxPerUnit; area = (int)(area * pxPerUnit * pxPerUnit); areaAmount += area; if (width >= Convert.ToSingle(areaMin) && width <= Convert.ToSingle(areaMax)) { selectCount++; selectAreaAmount += area; oneContours.Add(contours[i]); } else { twoContours.Add(contours[i]); } } break; } Cv2.DrawContours(onePhase.mat, oneContours, -1, new Scalar(panel1.BackColor.B, panel1.BackColor.G, panel1.BackColor.R, 255), Cv2.FILLED); Cv2.DrawContours(onePhase.mat, twoContours, -1, new Scalar(panel2.BackColor.B, panel2.BackColor.G, panel2.BackColor.R, 255), Cv2.FILLED); documentWorkspace.Refresh(); if (areaMax == 0) { selectResults.Count = 0; } else { selectResults.Count = selectCount; } unSelectResults.Count = (contours.Length - selectCount); selectResults.Area = selectAreaAmount; unSelectResults.Area = areaAmount - selectAreaAmount; if (unSelectResults.Area < 0) { unSelectResults.Area = 0; } if (contours.Length > 0) { selectResults.CountPercent = ((Single)selectCount / contours.Length) * 100; } else { selectResults.CountPercent = 0; } if (contours.Length > 0) { unSelectResults.CountPercent = ((Single)unSelectResults.Count / contours.Length) * 100; } else { unSelectResults.CountPercent = 0; } if (allArea > 0) { selectResults.Content = ((Single)selectAreaAmount / allArea) * 100; } else { selectResults.Content = 0; } if (allArea > 0) { unSelectResults.Content = ((Single)unSelectResults.Area / allArea) * 100; } else { unSelectResults.Content = 0; } if (contours.Length > 0) { selectResults.ContentFromAll = (float)(((Single)selectAreaAmount / areaAmount) * 100); } else { selectResults.ContentFromAll = 0; } if (contours.Length > 0) { unSelectResults.ContentFromAll = (float)((Single)unSelectResults.Area / areaAmount) * 100; } else { unSelectResults.ContentFromAll = 0; } if ((contours.Length - selectCount) > 0) { selectResults.CountScaleU = ((Single)selectCount / (contours.Length - selectCount)) * 100; } else { selectResults.CountScaleU = 0; } if (unSelectResults.Area > 0) { unSelectResults.CountScaleU = (float)((Single)selectAreaAmount / unSelectResults.Area) * 100; } else { unSelectResults.CountScaleU = 0; } UpdateUI(); } private void InitializeLanguageText() { this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text"); this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.button5.Text = PdnResources.GetString("Menu.File.Close.Text"); this.button2.Text = PdnResources.GetString("Menu.Saveresult.text"); this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text"); this.button1.Text = PdnResources.GetString("Menu.Setting.Text"); this.groupBox2.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Phasesetting.text"); this.label20.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Particle2color.text"); this.label19.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Particle1color.text"); this.label18.Text = PdnResources.GetString("Menu.max.text"); this.label17.Text = PdnResources.GetString("Menu.minimum.text"); this.label4.Text = PdnResources.GetString("Menu.max.text"); this.label3.Text = PdnResources.GetString("Menu.minimum.text"); this.label2.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Selectphase.text"); this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text"); this.groupBox5.Text = PdnResources.GetString("Menu.Analysisresult.text"); this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.button_all.Text = PdnResources.GetString("Menu.Showall.text"); this.Column12.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Twportion.imagename.text"); this.button9.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text"); this.label1.Text = PdnResources.GetString("Menu.Decimal.text"); this.button4.Text = PdnResources.GetString("Menu.Exportresults.text"); this.button3.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text"); this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text"); this.label16.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Lparticle1/parea).text"); this.label15.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Kparticleumber).text"); this.label14.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Jparticle2rticle2)content.text"); this.label13.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.Iparticle1/(ontent.text"); this.label12.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.thecontentofHparticle2.text"); this.label11.Text = PdnResources.GetString("Menu.Gparticle1content.text"); this.label10.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofFparticles2%.text"); this.label9.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofEparticles1%.text"); this.label8.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.theareaofDparticle2.text"); this.label7.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.ColumnAicles2.text"); this.label6.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.theareaofCparticle1.text"); this.label5.Text = PdnResources.GetString("Menu.Generalanalysis.Twportion.NumberofAparticles1.text"); this.Text = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text"); this.label21.Text = PdnResources.GetString("Menu.Binaryoperation.Removedebris.filtermethod.text"); } #region InitializeComponent private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.groupBox4 = 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.button2 = new System.Windows.Forms.Button(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.button1 = new System.Windows.Forms.Button(); this.groupBox_review = new System.Windows.Forms.GroupBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox(); this.button_remove = new System.Windows.Forms.Button(); this.button_all = new System.Windows.Forms.Button(); this.groupBox6 = new System.Windows.Forms.GroupBox(); this.dataGridView_results = new System.Windows.Forms.DataGridView(); this.Column12 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column4 = 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.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column9 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column11 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column13 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.button9 = new System.Windows.Forms.Button(); this.numericUpDown3 = new System.Windows.Forms.NumericUpDown(); this.label1 = new System.Windows.Forms.Label(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.txt_UnSelectDivSelectCount = new System.Windows.Forms.TextBox(); this.txt_SelectCountDivUnSelect = new System.Windows.Forms.TextBox(); this.label16 = new System.Windows.Forms.Label(); this.label15 = new System.Windows.Forms.Label(); this.txt_UnSelectCountFromAll = new System.Windows.Forms.TextBox(); this.txt_SelectContentFromAll = new System.Windows.Forms.TextBox(); this.label14 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label(); this.txt_UnSelectContent = new System.Windows.Forms.TextBox(); this.txt_SelectContent = new System.Windows.Forms.TextBox(); this.label12 = new System.Windows.Forms.Label(); this.label11 = new System.Windows.Forms.Label(); this.txt_UnSelectCountPersent = new System.Windows.Forms.TextBox(); this.label10 = new System.Windows.Forms.Label(); this.txt_UnSelectArea = new System.Windows.Forms.TextBox(); this.txt_UnSelectCount = new System.Windows.Forms.TextBox(); this.txt_SelectCountPersent = new System.Windows.Forms.TextBox(); this.txt_SelectArea = new System.Windows.Forms.TextBox(); this.txt_SelectCount = new System.Windows.Forms.TextBox(); this.label9 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.numericUpDown2 = new System.Windows.Forms.NumericUpDown(); this.comboBox1 = new System.Windows.Forms.ComboBox(); this.label17 = new System.Windows.Forms.Label(); this.label18 = new System.Windows.Forms.Label(); this.trackBar2 = new PaintDotNet.CustomControl.TriangleTrackBar(); this.trackBar1 = new PaintDotNet.CustomControl.TriangleTrackBar(); this.label19 = new System.Windows.Forms.Label(); this.label20 = new System.Windows.Forms.Label(); this.panel1 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel(); this.comboBox2 = new System.Windows.Forms.ComboBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.label21 = new System.Windows.Forms.Label(); this.groupBox4.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox5.SuspendLayout(); this.groupBox6.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).BeginInit(); this.groupBox7.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit(); this.groupBox8.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox4 // this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.groupBox4.Controls.Add(this.listView1); this.groupBox4.Location = new System.Drawing.Point(13, 72); this.groupBox4.Margin = new System.Windows.Forms.Padding(4); this.groupBox4.Name = "groupBox4"; this.groupBox4.Padding = new System.Windows.Forms.Padding(4); this.groupBox4.Size = new System.Drawing.Size(158, 483); this.groupBox4.TabIndex = 9; this.groupBox4.TabStop = false; this.groupBox4.Text = "图像索引"; // // 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(8, 26); this.listView1.Margin = new System.Windows.Forms.Padding(4); this.listView1.MultiSelect = false; this.listView1.Name = "listView1"; this.listView1.Size = new System.Drawing.Size(140, 449); this.listView1.TabIndex = 0; this.listView1.UseCompatibleStateImageBehavior = false; // // 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.button2); this.groupBox1.Controls.Add(this.checkBox1); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(20, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(1145, 53); this.groupBox1.TabIndex = 10; this.groupBox1.TabStop = false; this.groupBox1.Text = "操作"; // // 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(972, 21); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(75, 23); this.button5.TabIndex = 3; this.button5.Text = "关闭"; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.button2.Location = new System.Drawing.Point(1053, 21); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 2; this.button2.Text = "保存结果"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // checkBox1 // this.checkBox1.AutoSize = true; this.checkBox1.Location = new System.Drawing.Point(98, 24); this.checkBox1.Name = "checkBox1"; this.checkBox1.Size = new System.Drawing.Size(132, 16); this.checkBox1.TabIndex = 1; this.checkBox1.Text = "生成报告时打开设置"; this.checkBox1.UseVisualStyleBackColor = true; // // button1 // this.button1.Location = new System.Drawing.Point(6, 24); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.Text = "设置"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // groupBox_review // this.groupBox_review.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.groupBox_review.Location = new System.Drawing.Point(590, 72); this.groupBox_review.Name = "groupBox_review"; this.groupBox_review.Size = new System.Drawing.Size(575, 483); this.groupBox_review.TabIndex = 12; this.groupBox_review.TabStop = false; this.groupBox_review.Text = "预览"; // // groupBox5 // this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.groupBox5.Controls.Add(this.listBox_analysisResult); this.groupBox5.Controls.Add(this.button_remove); this.groupBox5.Controls.Add(this.button_all); this.groupBox5.Location = new System.Drawing.Point(13, 567); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(224, 165); this.groupBox5.TabIndex = 13; this.groupBox5.TabStop = false; this.groupBox5.Text = "分析结果"; // // listBox_analysisResult // this.listBox_analysisResult.CheckOnClick = true; this.listBox_analysisResult.FormattingEnabled = true; this.listBox_analysisResult.HorizontalScrollbar = true; this.listBox_analysisResult.Location = new System.Drawing.Point(11, 53); this.listBox_analysisResult.Name = "listBox_analysisResult"; this.listBox_analysisResult.Size = new System.Drawing.Size(202, 100); this.listBox_analysisResult.TabIndex = 10; this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged); // // button_remove // this.button_remove.Location = new System.Drawing.Point(130, 24); this.button_remove.Name = "button_remove"; this.button_remove.Size = new System.Drawing.Size(75, 23); this.button_remove.TabIndex = 8; this.button_remove.Text = "删除"; this.button_remove.UseVisualStyleBackColor = true; this.button_remove.Click += new System.EventHandler(this.button_remove_Click); // // button_all // this.button_all.Location = new System.Drawing.Point(14, 24); this.button_all.Name = "button_all"; this.button_all.Size = new System.Drawing.Size(75, 23); this.button_all.TabIndex = 1; this.button_all.Text = "全部显示"; this.button_all.UseVisualStyleBackColor = true; this.button_all.Click += new System.EventHandler(this.button_all_Click); // // groupBox6 // this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox6.Controls.Add(this.dataGridView_results); this.groupBox6.Location = new System.Drawing.Point(257, 562); this.groupBox6.Name = "groupBox6"; this.groupBox6.Size = new System.Drawing.Size(678, 165); this.groupBox6.TabIndex = 14; this.groupBox6.TabStop = false; // // dataGridView_results // this.dataGridView_results.AllowUserToAddRows = false; this.dataGridView_results.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dataGridView_results.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_results.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView_results.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column12, this.Column1, this.Column2, this.Column3, this.Column4, this.Column5, this.Column6, this.Column7, this.Column8, this.Column9, this.Column10, this.Column11, this.Column13}); this.dataGridView_results.Location = new System.Drawing.Point(16, 29); this.dataGridView_results.Name = "dataGridView_results"; this.dataGridView_results.RowHeadersVisible = false; this.dataGridView_results.RowHeadersWidth = 51; this.dataGridView_results.RowTemplate.Height = 27; this.dataGridView_results.Size = new System.Drawing.Size(645, 130); this.dataGridView_results.TabIndex = 1; // // Column12 // this.Column12.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column12.HeaderText = "Column12"; this.Column12.Name = "Column12"; // // Column1 // this.Column1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column1.HeaderText = "A"; this.Column1.MinimumWidth = 49; this.Column1.Name = "Column1"; // // Column2 // this.Column2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column2.HeaderText = "B"; this.Column2.MinimumWidth = 50; this.Column2.Name = "Column2"; // // Column3 // this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column3.HeaderText = "C"; this.Column3.MinimumWidth = 49; this.Column3.Name = "Column3"; // // Column4 // this.Column4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column4.HeaderText = "D"; this.Column4.MinimumWidth = 50; this.Column4.Name = "Column4"; // // Column5 // this.Column5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column5.HeaderText = "E"; this.Column5.MinimumWidth = 49; this.Column5.Name = "Column5"; // // Column6 // this.Column6.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column6.HeaderText = "F"; this.Column6.MinimumWidth = 50; this.Column6.Name = "Column6"; // // Column7 // this.Column7.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column7.HeaderText = "G"; this.Column7.MinimumWidth = 49; this.Column7.Name = "Column7"; // // Column8 // this.Column8.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column8.HeaderText = "H"; this.Column8.MinimumWidth = 50; this.Column8.Name = "Column8"; // // Column9 // this.Column9.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column9.HeaderText = "I"; this.Column9.MinimumWidth = 49; this.Column9.Name = "Column9"; // // Column10 // this.Column10.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column10.HeaderText = "J"; this.Column10.MinimumWidth = 50; this.Column10.Name = "Column10"; // // Column11 // this.Column11.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column11.HeaderText = "K"; this.Column11.MinimumWidth = 49; this.Column11.Name = "Column11"; // // Column13 // this.Column13.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column13.HeaderText = "L"; this.Column13.MinimumWidth = 50; this.Column13.Name = "Column13"; // // groupBox7 // this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.groupBox7.Controls.Add(this.button9); this.groupBox7.Controls.Add(this.numericUpDown3); this.groupBox7.Controls.Add(this.label1); this.groupBox7.Controls.Add(this.button4); this.groupBox7.Controls.Add(this.button3); this.groupBox7.Location = new System.Drawing.Point(941, 562); this.groupBox7.Name = "groupBox7"; this.groupBox7.Size = new System.Drawing.Size(224, 165); this.groupBox7.TabIndex = 15; this.groupBox7.TabStop = false; // // button9 // this.button9.Location = new System.Drawing.Point(54, 88); this.button9.Name = "button9"; this.button9.Size = new System.Drawing.Size(117, 23); this.button9.TabIndex = 10; this.button9.Text = "项目工程"; this.button9.UseVisualStyleBackColor = true; this.button9.Click += new System.EventHandler(this.button9_Click); // // numericUpDown3 // this.numericUpDown3.Location = new System.Drawing.Point(87, 124); this.numericUpDown3.Maximum = new decimal(new int[] { 10, 0, 0, 0}); this.numericUpDown3.Name = "numericUpDown3"; this.numericUpDown3.Size = new System.Drawing.Size(84, 21); this.numericUpDown3.TabIndex = 4; this.numericUpDown3.Value = new decimal(new int[] { 2, 0, 0, 0}); this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(52, 126); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 12); this.label1.TabIndex = 3; // // button4 // this.button4.Location = new System.Drawing.Point(54, 54); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(117, 23); this.button4.TabIndex = 1; this.button4.Text = "导出结果"; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); // // button3 // this.button3.Location = new System.Drawing.Point(54, 20); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(117, 23); this.button3.TabIndex = 0; this.button3.Text = "生成报告"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // groupBox8 // this.groupBox8.Controls.Add(this.txt_UnSelectDivSelectCount); this.groupBox8.Controls.Add(this.txt_SelectCountDivUnSelect); this.groupBox8.Controls.Add(this.label16); this.groupBox8.Controls.Add(this.label15); this.groupBox8.Controls.Add(this.txt_UnSelectCountFromAll); this.groupBox8.Controls.Add(this.txt_SelectContentFromAll); this.groupBox8.Controls.Add(this.label14); this.groupBox8.Controls.Add(this.label13); this.groupBox8.Controls.Add(this.txt_UnSelectContent); this.groupBox8.Controls.Add(this.txt_SelectContent); this.groupBox8.Controls.Add(this.label12); this.groupBox8.Controls.Add(this.label11); this.groupBox8.Controls.Add(this.txt_UnSelectCountPersent); this.groupBox8.Controls.Add(this.label10); this.groupBox8.Controls.Add(this.txt_UnSelectArea); this.groupBox8.Controls.Add(this.txt_UnSelectCount); this.groupBox8.Controls.Add(this.txt_SelectCountPersent); this.groupBox8.Controls.Add(this.txt_SelectArea); this.groupBox8.Controls.Add(this.txt_SelectCount); this.groupBox8.Controls.Add(this.label9); this.groupBox8.Controls.Add(this.label8); this.groupBox8.Controls.Add(this.label7); this.groupBox8.Controls.Add(this.label6); this.groupBox8.Controls.Add(this.label5); this.groupBox8.Enabled = false; this.groupBox8.Location = new System.Drawing.Point(178, 313); this.groupBox8.Name = "groupBox8"; this.groupBox8.Size = new System.Drawing.Size(400, 243); this.groupBox8.TabIndex = 17; this.groupBox8.TabStop = false; this.groupBox8.Text = "分析结果"; // // txt_UnSelectDivSelectCount // this.txt_UnSelectDivSelectCount.Location = new System.Drawing.Point(179, 216); this.txt_UnSelectDivSelectCount.Name = "txt_UnSelectDivSelectCount"; this.txt_UnSelectDivSelectCount.Size = new System.Drawing.Size(66, 21); this.txt_UnSelectDivSelectCount.TabIndex = 23; // // txt_SelectCountDivUnSelect // this.txt_SelectCountDivUnSelect.Location = new System.Drawing.Point(179, 192); this.txt_SelectCountDivUnSelect.Name = "txt_SelectCountDivUnSelect"; this.txt_SelectCountDivUnSelect.Size = new System.Drawing.Size(66, 21); this.txt_SelectCountDivUnSelect.TabIndex = 22; // // label16 // this.label16.AutoSize = true; this.label16.Location = new System.Drawing.Point(19, 219); this.label16.Name = "label16"; this.label16.Size = new System.Drawing.Size(113, 12); this.label16.TabIndex = 21; this.label16.Text = "L颗粒1/颗粒2(面积)"; // // label15 // this.label15.AutoSize = true; this.label15.Location = new System.Drawing.Point(19, 195); this.label15.Name = "label15"; this.label15.Size = new System.Drawing.Size(113, 12); this.label15.TabIndex = 20; this.label15.Text = "K颗粒1/颗粒2(个数)"; // // txt_UnSelectCountFromAll // this.txt_UnSelectCountFromAll.Location = new System.Drawing.Point(179, 165); this.txt_UnSelectCountFromAll.Name = "txt_UnSelectCountFromAll"; this.txt_UnSelectCountFromAll.Size = new System.Drawing.Size(66, 21); this.txt_UnSelectCountFromAll.TabIndex = 19; // // txt_SelectContentFromAll // this.txt_SelectContentFromAll.Location = new System.Drawing.Point(179, 141); this.txt_SelectContentFromAll.Name = "txt_SelectContentFromAll"; this.txt_SelectContentFromAll.Size = new System.Drawing.Size(66, 21); this.txt_SelectContentFromAll.TabIndex = 18; // // label14 // this.label14.AutoSize = true; this.label14.Location = new System.Drawing.Point(19, 168); this.label14.Name = "label14"; this.label14.Size = new System.Drawing.Size(155, 12); this.label14.TabIndex = 17; this.label14.Text = "J颗粒2/(颗粒1+颗粒2)含量%"; // // label13 // this.label13.AutoSize = true; this.label13.Location = new System.Drawing.Point(19, 144); this.label13.Name = "label13"; this.label13.Size = new System.Drawing.Size(155, 12); this.label13.TabIndex = 16; this.label13.Text = "I颗粒1/(颗粒1+颗粒2)含量%"; // // txt_UnSelectContent // this.txt_UnSelectContent.Location = new System.Drawing.Point(251, 114); this.txt_UnSelectContent.Name = "txt_UnSelectContent"; this.txt_UnSelectContent.Size = new System.Drawing.Size(66, 21); this.txt_UnSelectContent.TabIndex = 15; // // txt_SelectContent // this.txt_SelectContent.Location = new System.Drawing.Point(95, 114); this.txt_SelectContent.Name = "txt_SelectContent"; this.txt_SelectContent.Size = new System.Drawing.Size(66, 21); this.txt_SelectContent.TabIndex = 14; // // label12 // this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(180, 114); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(71, 12); this.label12.TabIndex = 13; this.label12.Text = "H颗粒2含量%"; // // label11 // this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(19, 114); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(71, 12); this.label11.TabIndex = 12; this.label11.Text = "G颗粒1含量%"; // // txt_UnSelectCountPersent // this.txt_UnSelectCountPersent.Location = new System.Drawing.Point(251, 83); this.txt_UnSelectCountPersent.Name = "txt_UnSelectCountPersent"; this.txt_UnSelectCountPersent.Size = new System.Drawing.Size(66, 21); this.txt_UnSelectCountPersent.TabIndex = 11; // // label10 // this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(180, 85); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(71, 12); this.label10.TabIndex = 10; this.label10.Text = "F颗粒2个数%"; // // txt_UnSelectArea // this.txt_UnSelectArea.Location = new System.Drawing.Point(251, 56); this.txt_UnSelectArea.Name = "txt_UnSelectArea"; this.txt_UnSelectArea.Size = new System.Drawing.Size(66, 21); this.txt_UnSelectArea.TabIndex = 9; // // txt_UnSelectCount // this.txt_UnSelectCount.Location = new System.Drawing.Point(251, 31); this.txt_UnSelectCount.Name = "txt_UnSelectCount"; this.txt_UnSelectCount.Size = new System.Drawing.Size(66, 21); this.txt_UnSelectCount.TabIndex = 8; // // txt_SelectCountPersent // this.txt_SelectCountPersent.Location = new System.Drawing.Point(95, 82); this.txt_SelectCountPersent.Name = "txt_SelectCountPersent"; this.txt_SelectCountPersent.Size = new System.Drawing.Size(66, 21); this.txt_SelectCountPersent.TabIndex = 7; // // txt_SelectArea // this.txt_SelectArea.Location = new System.Drawing.Point(95, 56); this.txt_SelectArea.Name = "txt_SelectArea"; this.txt_SelectArea.Size = new System.Drawing.Size(66, 21); this.txt_SelectArea.TabIndex = 6; // // txt_SelectCount // this.txt_SelectCount.Location = new System.Drawing.Point(95, 31); this.txt_SelectCount.Name = "txt_SelectCount"; this.txt_SelectCount.Size = new System.Drawing.Size(66, 21); this.txt_SelectCount.TabIndex = 5; // // label9 // this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(19, 82); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(71, 12); this.label9.TabIndex = 4; this.label9.Text = "E颗粒1个数%"; // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(180, 59); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(65, 12); this.label8.TabIndex = 3; this.label8.Text = "D颗粒2面积"; // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(180, 34); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(65, 12); this.label7.TabIndex = 2; this.label7.Text = "B颗粒2个数"; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(19, 59); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(65, 12); this.label6.TabIndex = 1; this.label6.Text = "C颗粒1面积"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(19, 34); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(65, 12); this.label5.TabIndex = 0; this.label5.Text = "A颗粒1个数"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(17, 26); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 0; this.label2.Text = "选择物相"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(19, 91); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(29, 12); this.label3.TabIndex = 5; this.label3.Text = "最小"; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(164, 91); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(29, 12); this.label4.TabIndex = 6; this.label4.Text = "最大"; // // numericUpDown1 // this.numericUpDown1.Location = new System.Drawing.Point(54, 89); this.numericUpDown1.Maximum = new decimal(new int[] { 1000000, 0, 0, 0}); this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.Size = new System.Drawing.Size(60, 21); this.numericUpDown1.TabIndex = 7; this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); this.numericUpDown1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDown1_KeyUp); // // numericUpDown2 // this.numericUpDown2.Location = new System.Drawing.Point(199, 89); this.numericUpDown2.Maximum = new decimal(new int[] { 1000000, 0, 0, 0}); this.numericUpDown2.Name = "numericUpDown2"; this.numericUpDown2.Size = new System.Drawing.Size(60, 21); this.numericUpDown2.TabIndex = 8; this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged); this.numericUpDown2.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDown2_KeyUp); // // comboBox1 // this.comboBox1.FormattingEnabled = true; this.comboBox1.Location = new System.Drawing.Point(95, 23); this.comboBox1.Name = "comboBox1"; this.comboBox1.Size = new System.Drawing.Size(141, 20); this.comboBox1.TabIndex = 9; this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); // // label17 // this.label17.AutoSize = true; this.label17.Location = new System.Drawing.Point(19, 121); this.label17.Name = "label17"; this.label17.Size = new System.Drawing.Size(29, 12); this.label17.TabIndex = 12; this.label17.Text = "最小"; // // label18 // this.label18.AutoSize = true; this.label18.Location = new System.Drawing.Point(19, 150); this.label18.Name = "label18"; this.label18.Size = new System.Drawing.Size(29, 12); this.label18.TabIndex = 13; this.label18.Text = "最大"; // // trackBar2 // this.trackBar2.Location = new System.Drawing.Point(59, 150); this.trackBar2.Maximum = 10000; this.trackBar2.Minimum = 0; this.trackBar2.Name = "trackBar2"; this.trackBar2.Size = new System.Drawing.Size(341, 26); this.trackBar2.TabIndex = 14; this.trackBar2.Value = 0; this.trackBar2.TrackBarScroll += new System.EventHandler(this.trackBar2_TrackBarScroll); // // trackBar1 // this.trackBar1.Location = new System.Drawing.Point(59, 116); this.trackBar1.Maximum = 10000; this.trackBar1.Minimum = 0; this.trackBar1.Name = "trackBar1"; this.trackBar1.Size = new System.Drawing.Size(341, 26); this.trackBar1.TabIndex = 18; this.trackBar1.Value = 0; this.trackBar1.TrackBarScroll += new System.EventHandler(this.trackBar1_TrackBarScroll); // // label19 // this.label19.AutoSize = true; this.label19.Location = new System.Drawing.Point(21, 194); this.label19.Name = "label19"; this.label19.Size = new System.Drawing.Size(59, 12); this.label19.TabIndex = 19; this.label19.Text = "颗粒1颜色"; // // label20 // this.label20.AutoSize = true; this.label20.Location = new System.Drawing.Point(193, 194); this.label20.Name = "label20"; this.label20.Size = new System.Drawing.Size(59, 12); this.label20.TabIndex = 20; this.label20.Text = "颗粒2颜色"; // // panel1 // this.panel1.BackColor = System.Drawing.Color.Red; this.panel1.Location = new System.Drawing.Point(87, 190); this.panel1.Name = "panel1"; this.panel1.Size = new System.Drawing.Size(93, 23); this.panel1.TabIndex = 21; this.panel1.Click += new System.EventHandler(this.panel1_Click); // // panel2 // this.panel2.BackColor = System.Drawing.Color.Yellow; this.panel2.Location = new System.Drawing.Point(258, 190); this.panel2.Name = "panel2"; this.panel2.Size = new System.Drawing.Size(93, 23); this.panel2.TabIndex = 22; this.panel2.Click += new System.EventHandler(this.panel2_Click); // // comboBox2 // this.comboBox2.FormattingEnabled = true; this.comboBox2.Items.AddRange(new object[] { "面积", "面积比", "周长", "短轴", "长轴", "倾斜角度", "高度", "宽度", "宽高比", "长径", "短径", "外接圆直径", "球化率", "等积圆直径", "最大卡规直径", "最小卡规直径", "平均卡规直径", "纤维长度"}); this.comboBox2.Location = new System.Drawing.Point(95, 60); this.comboBox2.Name = "comboBox2"; this.comboBox2.Size = new System.Drawing.Size(141, 20); this.comboBox2.TabIndex = 23; this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged); // // groupBox2 // this.groupBox2.Controls.Add(this.label21); this.groupBox2.Controls.Add(this.comboBox2); this.groupBox2.Controls.Add(this.panel2); this.groupBox2.Controls.Add(this.panel1); this.groupBox2.Controls.Add(this.label20); this.groupBox2.Controls.Add(this.label19); this.groupBox2.Controls.Add(this.trackBar1); this.groupBox2.Controls.Add(this.trackBar2); this.groupBox2.Controls.Add(this.label18); this.groupBox2.Controls.Add(this.label17); this.groupBox2.Controls.Add(this.comboBox1); this.groupBox2.Controls.Add(this.numericUpDown2); this.groupBox2.Controls.Add(this.numericUpDown1); this.groupBox2.Controls.Add(this.label4); this.groupBox2.Controls.Add(this.label3); this.groupBox2.Controls.Add(this.label2); this.groupBox2.Location = new System.Drawing.Point(178, 72); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(406, 235); this.groupBox2.TabIndex = 11; this.groupBox2.TabStop = false; this.groupBox2.Text = "物相设置"; // // label21 // this.label21.AutoSize = true; this.label21.Location = new System.Drawing.Point(19, 63); this.label21.Name = "label21"; this.label21.Size = new System.Drawing.Size(53, 12); this.label21.TabIndex = 24; this.label21.Text = "筛选条件"; // // TwoPhaseScaleDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1177, 744); this.Controls.Add(this.groupBox8); this.Controls.Add(this.groupBox7); this.Controls.Add(this.groupBox6); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox_review); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Controls.Add(this.groupBox4); this.Name = "TwoPhaseScaleDialog"; this.Text = "两相比例"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TwoPhaseScaleDialog_FormClosing); this.Load += new System.EventHandler(this.TwoPhaseScaleDialog_Load); this.Controls.SetChildIndex(this.groupBox4, 0); this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox_review, 0); this.Controls.SetChildIndex(this.groupBox5, 0); this.Controls.SetChildIndex(this.groupBox6, 0); this.Controls.SetChildIndex(this.groupBox7, 0); this.Controls.SetChildIndex(this.groupBox8, 0); this.groupBox4.ResumeLayout(false); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox5.ResumeLayout(false); this.groupBox6.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).EndInit(); this.groupBox7.ResumeLayout(false); this.groupBox7.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit(); this.groupBox8.ResumeLayout(false); this.groupBox8.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.ResumeLayout(false); } #endregion private void numericUpDown1_ValueChanged(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } if (workType == 2 || workType == 9 || workType == 13) { trackBar1.Value = (int)(numericUpDown1.Value * 100); } else { trackBar1.Value = (int)numericUpDown1.Value; } GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat); } private void numericUpDown2_ValueChanged(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } if (workType == 2 || workType == 9 || workType == 13) { trackBar2.Value = (int)(numericUpDown2.Value * 100); } else { trackBar2.Value = (int)(numericUpDown2.Value); } GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { selectIndex = comboBox1.SelectedIndex; Mat oldMat = documentWorkspace.phaseModels[selectIndex].mat; onePhase.name = "one"; onePhase.mat = new Mat(new OpenCvSharp.Size(oldMat.Cols, oldMat.Rows), MatType.CV_8UC4, new Scalar(0, 0, 0, 255)); onePhase.color = panel1.BackColor.ToArgb(); onePhase.choise = true; oldMat.CopyTo(onePhase.mat); PhaseModel oneP = documentWorkspace.phaseModels.Find(u => u.name == "one"); if (oneP == null) { documentWorkspace.phaseModels.Add(onePhase); } else { oneP = onePhase; } this.trackBar1.Value = 0; this.trackBar2.Value = 0; this.numericUpDown1.Value = 0; this.numericUpDown2.Value = 0; } private void trackBar2_TrackBarScroll(object sender, EventArgs e) { if (workType == 2 || workType == 9 || workType == 13) { numericUpDown2.Value = (decimal)trackBar2.Value / 100; } else { numericUpDown2.Value = trackBar2.Value; } } private void trackBar1_TrackBarScroll(object sender, EventArgs e) { if (workType == 2 || workType == 9 || workType == 13) { numericUpDown1.Value = (decimal)trackBar1.Value / 100; } else { numericUpDown1.Value = trackBar1.Value; } } private void panel1_Click(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } this.oneColorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel1.BackColor); this.oneColorsForm.setSaveBtn_Click(new System.EventHandler(this.oneColorsChanged)); this.oneColorsForm.ShowDialog(); } private void panel2_Click(object sender, EventArgs e) { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } this.twoColorsForm.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor); this.twoColorsForm.setSaveBtn_Click(new System.EventHandler(this.twoColorsChanged)); this.twoColorsForm.ShowDialog(); } private void twoColorsChanged(object sender, EventArgs e) { Color color = this.twoColorsForm.UserPrimaryColor.ToColor(); //更改背景色,触发事件 this.panel2.BackColor = color; //改变配置文件里面的相颜色 //this.binaryExtractionModel.PhaseColor = color.ToArgb(); //关闭色板 GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat); //this.documentWorkspace.Refresh(); this.twoColorsForm.Close(); } private void oneColorsChanged(object sender, EventArgs e) { Color color = this.oneColorsForm.UserPrimaryColor.ToColor(); //更改背景色,触发事件 this.panel1.BackColor = color; //改变配置文件里面的相颜色 //this.binaryExtractionModel.PhaseColor = color.ToArgb(); //关闭色板 GetAreaBetweenMinToMax(numericUpDown1.Value, numericUpDown2.Value, this.documentWorkspace.phaseModels[selectIndex].mat); //this.documentWorkspace.Refresh(); this.oneColorsForm.Close(); } #region [筛选条件] /// /// 面积 /// private void rb1_CheckedChanged() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxArea = (decimal)Math.Ceiling((getMaxArea(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit * pxPerUnit)); trackBar1.Maximum = (int)((double)maxArea); trackBar2.Maximum = (int)((double)maxArea); numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxArea; numericUpDown2.Maximum = maxArea; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); selectResults = new TwoPhaseScaleResult(); unSelectResults = new TwoPhaseScaleResult(); workType = 1; } /// /// 面积比 /// private void rb2_CheckedChanged() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } trackBar1.Maximum = 100; trackBar2.Maximum = 100; numericUpDown1.DecimalPlaces = 2; numericUpDown1.Increment = 0.01M; numericUpDown2.DecimalPlaces = 2; numericUpDown2.Increment = 0.01M; numericUpDown1.Maximum = 1; numericUpDown2.Maximum = 1; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 2; } /// /// 最大卡规直径 /// private void rb4_CheckedChanged() { //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 2) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 15; } /// /// 长宽比 /// private void rb3_CheckedChanged() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } decimal maxLength = 0; try { maxLength = (decimal)Math.Ceiling(getAspectRatio(this.documentWorkspace.phaseModels[selectIndex].mat)); } catch (Exception) { } trackBar1.Maximum = (int)(maxLength * 100); trackBar2.Maximum = (int)(maxLength * 100); numericUpDown1.DecimalPlaces = 2; numericUpDown1.Increment = 0.01M; numericUpDown2.DecimalPlaces = 2; numericUpDown2.Increment = 0.01M; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 9; } /// /// 最小卡规直径 /// /// /// private void minimumCaliperDiameter() { //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 1) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 16; } /// /// 平均卡规直径 /// private void averageCaliperDiameter() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxLength = (decimal)Math.Ceiling(getContoursMaxLength(this.documentWorkspace.phaseModels[selectIndex].mat, 3) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 17; } /// /// 长轴 /// private void longAxis(int type) { //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } double maxLength = Math.Ceiling(getLongAxis(this.documentWorkspace.phaseModels[selectIndex].mat, type) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = (decimal)maxLength; numericUpDown2.Maximum = (decimal)maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = type == 1 ? 4 : 5; } /// /// 周长 /// private void perimeter() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxLength = (decimal)Math.Ceiling(getMaxPerimeter(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 3; } /// /// 倾斜角度 /// private void slope() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } decimal maxLength = (decimal)getMaxSlope(this.documentWorkspace.phaseModels[selectIndex].mat); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 6; } /// /// 高度 /// private void particulatesHeight() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxLength = (decimal)Math.Ceiling(getHeightOrWidth(this.documentWorkspace.phaseModels[selectIndex].mat, 1) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 7; } /// /// 宽度 /// private void particulatesWidth() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxLength = (decimal)Math.Ceiling(getHeightOrWidth(this.documentWorkspace.phaseModels[selectIndex].mat, 2) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 8; } /// /// 长径或者短径 /// private void trail(int type) { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxLength = (decimal)Math.Ceiling(getTrail(this.documentWorkspace.phaseModels[selectIndex].mat, type) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = type == 1 ? 10 : 11; } /// /// 外接圆直径 /// private void circumscribedCircleDiameter() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxLength = (decimal)Math.Ceiling(getCircumscribedCircleDiameter(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 12; } /// /// 球化率 /// private void spheroidizationRate() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } trackBar1.Maximum = 100; trackBar2.Maximum = 100; numericUpDown1.DecimalPlaces = 2; numericUpDown1.Increment = 0.01M; numericUpDown2.DecimalPlaces = 2; numericUpDown2.Increment = 0.01M; numericUpDown1.Maximum = 1; numericUpDown2.Maximum = 1; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 13; } /// /// 等积圆直径 /// private void equalAreaCircle() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxLength = Math.Ceiling((decimal)(getEqualAreaCircle(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit)); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 14; } /// /// 纤维长度 /// private void fiberLength() { if (this.documentWorkspace.phaseModels.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text") + "!"); return; } //double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron]; double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron); decimal maxLength = (decimal)Math.Ceiling(getFiberLength(this.documentWorkspace.phaseModels[selectIndex].mat) * pxPerUnit); trackBar1.Maximum = (int)maxLength; trackBar2.Maximum = (int)maxLength; numericUpDown1.DecimalPlaces = 0; numericUpDown1.Increment = 1; numericUpDown2.DecimalPlaces = 0; numericUpDown2.Increment = 1; numericUpDown1.Maximum = maxLength; numericUpDown2.Maximum = maxLength; numericUpDown1.Value = 0; numericUpDown2.Value = 0; trackBar1.Value = 0; trackBar2.Value = 0; InitUI(); workType = 18; } #endregion #region [基础方法] /// /// 获取最大面积 /// /// /// private double 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.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))); if (area > maxArea) { maxArea = area; } } return Math.Ceiling(maxArea); } /// /// 获取轮廓的最大卡规直径 /// /// /// private double getContoursMaxLength(Mat pMat, int type) { double maxLength = 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); if (type == 2) { for (int i = 0; i < contours.Count(); i++) { List vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points); int width = vs.Max(); if (width > maxLength) { maxLength = width; } } } else if (type == 1) { for (int i = 0; i < contours.Count(); i++) { List vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points); int width = vs.Min(); if (width > maxLength) { maxLength = width; } } } else { for (int i = 0; i < contours.Count(); i++) { List vs = BasicCalculationHelper.GetCaliperDiameter(contours[i], hierarchy[i], out points); var width = Math.Ceiling(vs.Average()); if (width > maxLength) { maxLength = width; } } } return Math.Ceiling(maxLength); } /// /// 获取轮廓的周长 /// /// /// private double getMaxPerimeter(Mat pMat) { Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale); HierarchyIndex[] hierarchy; OpenCvSharp.Point[][] contours; Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone); return contours.Max(m => m.Length); ; } /// /// 获取轮廓长轴或者短轴 /// /// /// private double getLongAxis(Mat pMat, int type) { double maxLength = 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++) { RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]); float width = 0; if (type == 1) { width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width : ellipsemege.Size.Height; } else { width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width : ellipsemege.Size.Height; } if (width > maxLength) { maxLength = width; } } return Math.Ceiling(maxLength); } /// /// 获取轮廓倾斜角度 /// /// /// private double getMaxSlope(Mat pMat) { double maxLength = 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++) { if (contours[i].Count() < 5) { continue; } RotatedRect ellipsemege = Cv2.FitEllipse(contours[i]); float width = ellipsemege.Angle; if (width > maxLength) { maxLength = width; } } return Math.Ceiling(maxLength); } /// /// 获取轮廓高度或者宽度 /// /// /// private double getHeightOrWidth(Mat pMat, int type) { double maxLength = 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++) { Rect ellipsemege = Cv2.BoundingRect(contours[i]); float width = type == 1 ? ellipsemege.Size.Height : ellipsemege.Size.Width; if (width > maxLength) { maxLength = width; } } return Math.Ceiling(maxLength); } /// /// 获取轮廓长径或者短径 /// /// /// private double getTrail(Mat pMat, int type) { double maxLength = 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++) { RotatedRect ellipsemege = Cv2.MinAreaRect(contours[i]); double width; if (type == 1) { width = ellipsemege.Size.Width > ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 : ellipsemege.Size.Height * 0.5; } else { width = ellipsemege.Size.Width < ellipsemege.Size.Height ? ellipsemege.Size.Width * 0.5 : ellipsemege.Size.Height * 0.5; } if (width > maxLength) { maxLength = width; } } return Math.Ceiling(maxLength); } /// /// 外接圆直径 /// /// /// private double getCircumscribedCircleDiameter(Mat pMat) { double maxLength = 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); Point2f point; for (int i = 0; i < contours.Count(); i++) { float radius; Cv2.MinEnclosingCircle(contours[i], out point, out radius); double width = radius * 2; if (width > maxLength) { maxLength = width; } } return Math.Ceiling(maxLength); } /// /// 等积圆直径 /// /// /// private double getEqualAreaCircle(Mat pMat) { double maxLength = 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.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))); double width = Math.Sqrt(area / Math.PI) * 2; if (width > maxLength) { maxLength = width; } } return Math.Ceiling(maxLength); } /// /// 纤维长度 /// /// /// private double getFiberLength(Mat pMat) { double maxLength = 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.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0))); double width = (contours[i].Length + Math.Sqrt(contours[i].Length * contours[i].Length + 16 * area)) / 4; if (width > maxLength) { maxLength = width; } } return Math.Ceiling(maxLength); } /// /// 长宽比 /// /// private double getAspectRatio(Mat pMat) { double maxLength = 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++) { Rect area = Cv2.BoundingRect(contours[i]); double width = (double)area.Width / (double)area.Height; if (width > maxLength) { maxLength = width; } } return Math.Ceiling(maxLength); } #endregion private void button2_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count == 0) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text")); return; } if (comboBox1.SelectedIndex == -1) { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Selectthephaseyouwanttoanalyze.text") + "!"); comboBox1.Focus(); return; } String tag = listView1.FocusedItem.Text; List tempBit = new List(); if (finalResults.FindAll(u => u.GraphName == listView1.FocusedItem.Text).Count == 0) { TwoPhaseScaleExportResult activeResult = new TwoPhaseScaleExportResult(listView1.FocusedItem.Text, selectResults, unSelectResults); finalResults.Add(activeResult); listBox_analysisResult.Items.Add(listView1.FocusedItem.Text); listBox_analysisResult.SetItemChecked(listBox_analysisResult.Items.Count - 1, true); dataGridView_results.Rows.Add(activeResult.GraphName, activeResult.selectResult.Count.ToString(), activeResult.unSelectResult.Count.ToString(), AnalysisTools.GetDecNum(activeResult.selectResult.Area, decnum).ToString(), AnalysisTools.GetDecNum(activeResult.unSelectResult.Area, decnum).ToString(), AnalysisTools.GetDecNum(activeResult.selectResult.CountPercent, decnum), AnalysisTools.GetDecNum(activeResult.unSelectResult.CountPercent, decnum), AnalysisTools.GetDecNum(activeResult.selectResult.Content, decnum), AnalysisTools.GetDecNum(activeResult.unSelectResult.Content, decnum), AnalysisTools.GetDecNum(activeResult.selectResult.ContentFromAll, decnum), AnalysisTools.GetDecNum(activeResult.unSelectResult.ContentFromAll, decnum), AnalysisTools.GetDecNum(activeResult.selectResult.CountScaleU, decnum), AnalysisTools.GetDecNum(activeResult.unSelectResult.CountScaleU, decnum)); } else { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); if (dr != DialogResult.OK) { return; } finalResults.RemoveAll(u => u.GraphName == listView1.FocusedItem.Text); TwoPhaseScaleExportResult activeResult = new TwoPhaseScaleExportResult(listView1.FocusedItem.Text, selectResults, unSelectResults); finalResults.Add(activeResult); List list = new List(); foreach (var s in this.listBox_analysisResult.Items) { list.Add(s.ToString()); } this.listBox_analysisResult.Items.Clear(); foreach (var s in list) { this.listBox_analysisResult.Items.Add(s); } var thisindex = this.listBox_analysisResult.Items.IndexOf(listView1.FocusedItem.Text); this.dataGridView_results.Rows.Clear(); listBox_analysisResult.SetItemChecked(thisindex, true); dataGridView_results.Rows.Add(activeResult.GraphName, activeResult.selectResult.Count.ToString(), activeResult.unSelectResult.Count.ToString(), AnalysisTools.GetDecNum(activeResult.selectResult.Area, decnum).ToString(), AnalysisTools.GetDecNum(activeResult.unSelectResult.Area, decnum).ToString(), AnalysisTools.GetDecNum(activeResult.selectResult.CountPercent, decnum), AnalysisTools.GetDecNum(activeResult.unSelectResult.CountPercent, decnum), AnalysisTools.GetDecNum(activeResult.selectResult.Content, decnum), AnalysisTools.GetDecNum(activeResult.unSelectResult.Content, decnum), AnalysisTools.GetDecNum(activeResult.selectResult.ContentFromAll, decnum), AnalysisTools.GetDecNum(activeResult.unSelectResult.ContentFromAll, decnum), AnalysisTools.GetDecNum(activeResult.selectResult.CountScaleU, decnum), AnalysisTools.GetDecNum(activeResult.unSelectResult.CountScaleU, decnum)); } double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数 Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap(); originalBit.Tag = pantographRatio; tempBit.Add(originalBit); Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat); Graphics graphics = Graphics.FromImage(newBit); Draw(graphics); newBit.Tag = pantographRatio; tempBit.Add(newBit); if (bitDic.ContainsKey(tag)) { bitDic[tag].Clear(); bitDic[tag] = tempBit; } else { bitDic.Add(tag, tempBit); } } private void Draw(Graphics graphics) { if (this.documentWorkspace.phaseModels.Count > 0) { foreach (PhaseModel model in this.documentWorkspace.phaseModels) { if (model.choise && model.mat != null) { Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat); graphics.DrawImage(map, 0, 0, map.Width, map.Height); } } } } private void button_all_Click(object sender, EventArgs e) { dataGridView_results.Rows.Clear(); if (this.is_all % 2 == 0) { for (int i = 0; i < listBox_analysisResult.Items.Count; i++) { listBox_analysisResult.SetItemChecked(i, false); } } else { for (int i = 0; i < listBox_analysisResult.Items.Count; i++) { listBox_analysisResult.SetItemChecked(i, true); } for (int i = 0; i < finalResults.Count; i++) { dataGridView_results.Rows.Add(finalResults[i].GraphName, finalResults[i].selectResult.Count.ToString(), finalResults[i].unSelectResult.Count.ToString(), AnalysisTools.GetDecNum(finalResults[i].selectResult.Area, decnum), AnalysisTools.GetDecNum(finalResults[i].unSelectResult.Area, decnum), AnalysisTools.GetDecNum(finalResults[i].selectResult.CountPercent, decnum), AnalysisTools.GetDecNum(finalResults[i].unSelectResult.CountPercent, decnum), AnalysisTools.GetDecNum(finalResults[i].selectResult.Content, decnum), AnalysisTools.GetDecNum(finalResults[i].unSelectResult.Count, decnum), AnalysisTools.GetDecNum(finalResults[i].selectResult.ContentFromAll, decnum), AnalysisTools.GetDecNum(finalResults[i].unSelectResult.ContentFromAll, decnum), AnalysisTools.GetDecNum(finalResults[i].selectResult.CountScaleU, decnum), AnalysisTools.GetDecNum(finalResults[i].unSelectResult.CountScaleU, decnum)); } } this.is_all += 1; } private void button_remove_Click(object sender, EventArgs e) { var removeList = new List(); if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.ertodeletetheselectedanalysisres.Text") + "?", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { foreach (var s in listBox_analysisResult.CheckedItems) { for (int i = 0; i < dataGridView_results.Rows.Count; i++) { if (dataGridView_results.Rows[i].Cells[0].Value.ToString() == s.ToString()) { dataGridView_results.Rows.RemoveAt(i); } } finalResults.RemoveAll(u => u.GraphName == s.ToString()); removeList.Add(s.ToString()); } foreach (var m in removeList) { listBox_analysisResult.Items.Remove(m); } } } else { MessageBox.Show(PdnResources.GetString("Menu.cttheanalysisresultsthatyouwanttod.Text") + "!"); } } private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e) { dataGridView_results.Rows.Clear(); if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0) { foreach (var s in listBox_analysisResult.CheckedItems) { List selectItems = finalResults.FindAll(u => u.GraphName == s.ToString()); for (int i = 0; i < selectItems.Count; i++) { dataGridView_results.Rows.Add(selectItems[i].GraphName, selectItems[i].selectResult.Count.ToString(), selectItems[i].unSelectResult.Count.ToString(), AnalysisTools.GetDecNum(selectItems[i].selectResult.Area, decnum).ToString(), AnalysisTools.GetDecNum(selectItems[i].unSelectResult.Area, decnum).ToString(), AnalysisTools.GetDecNum(selectItems[i].selectResult.CountPercent, decnum), AnalysisTools.GetDecNum(selectItems[i].unSelectResult.CountPercent, decnum), AnalysisTools.GetDecNum(selectItems[i].selectResult.Content, decnum), AnalysisTools.GetDecNum(selectItems[i].unSelectResult.Content, decnum), AnalysisTools.GetDecNum(selectItems[i].selectResult.ContentFromAll, decnum), AnalysisTools.GetDecNum(selectItems[i].unSelectResult.ContentFromAll, decnum), AnalysisTools.GetDecNum(selectItems[i].selectResult.CountScaleU, decnum), AnalysisTools.GetDecNum(selectItems[i].unSelectResult.CountScaleU, decnum)); } } } } private void numericUpDown3_ValueChanged(object sender, EventArgs e) { decnum = (int)numericUpDown3.Value; for (int i = 0; i < dataGridView_results.Rows.Count; i++) { TwoPhaseScaleExportResult result = this.finalResults.Find(u => u.GraphName.Equals(dataGridView_results.Rows[i].Cells[0].Value.ToString())); if (result != null) { dataGridView_results.Rows[i].Cells[3].Value = AnalysisTools.GetDecNum(result.selectResult.Area, decnum); dataGridView_results.Rows[i].Cells[4].Value = AnalysisTools.GetDecNum(result.unSelectResult.Area, decnum); dataGridView_results.Rows[i].Cells[5].Value = AnalysisTools.GetDecNum(result.selectResult.CountPercent, decnum); dataGridView_results.Rows[i].Cells[6].Value = AnalysisTools.GetDecNum(result.unSelectResult.CountPercent, decnum); dataGridView_results.Rows[i].Cells[7].Value = AnalysisTools.GetDecNum(result.selectResult.Content, decnum); dataGridView_results.Rows[i].Cells[8].Value = AnalysisTools.GetDecNum(result.unSelectResult.Content, decnum); dataGridView_results.Rows[i].Cells[9].Value = AnalysisTools.GetDecNum(result.selectResult.ContentFromAll, decnum); dataGridView_results.Rows[i].Cells[10].Value = AnalysisTools.GetDecNum(result.unSelectResult.ContentFromAll, decnum); dataGridView_results.Rows[i].Cells[11].Value = AnalysisTools.GetDecNum(result.selectResult.CountScaleU, decnum); dataGridView_results.Rows[i].Cells[12].Value = AnalysisTools.GetDecNum(result.unSelectResult.CountScaleU, decnum); } } } private void button5_Click(object sender, EventArgs e) { this.documentWorkspace.phaseModels.RemoveAll(u => u.name == "one"); this.Close(); } private void button4_Click(object sender, EventArgs e) { if (this.dataGridView_results.Rows.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 = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text") + PdnResources.GetString("Menu.Analysisresult.text") + DateTime.Now.ToString("yyyyMMddhhmmss"); DialogResult dr = exe.ShowDialog(); if (dr == DialogResult.OK) { DataTable dtb = new DataTable(); foreach (DataGridViewColumn c in this.dataGridView_results.Columns) { dtb.Columns.Add(c.HeaderText); } for (int r = 0; r < this.dataGridView_results.Rows.Count; r++) { DataRow dataRow = dtb.NewRow(); for (int c = 0; c < this.dataGridView_results.Rows[r].Cells.Count; c++) { dataRow[this.dataGridView_results.Columns[c].HeaderText] = this.dataGridView_results.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 { System.Windows.Forms.MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text") + "!"); } } private void button1_Click(object sender, EventArgs e) { AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.TwoPhaseScale"); if (recombinationRateSetDialog.hasModule) { recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen; recombinationRateSetDialog.ShowDialog(); } else { recombinationRateSetDialog = null; } } private void button3_Click(object sender, EventArgs e) { bitList.Clear(); if (checkBox1.Checked) { AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.TwoPhaseScale"); 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.dataGridView_results.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dataGridView_results.Columns[0].HeaderText); content1.Add(this.dataGridView_results.Columns[1].HeaderText); content1.Add(this.dataGridView_results.Columns[2].HeaderText); content1.Add(this.dataGridView_results.Columns[3].HeaderText); content1.Add(this.dataGridView_results.Columns[4].HeaderText); content1.Add(this.dataGridView_results.Columns[5].HeaderText); content1.Add(this.dataGridView_results.Columns[6].HeaderText); content1.Add(this.dataGridView_results.Columns[7].HeaderText); content1.Add(this.dataGridView_results.Columns[8].HeaderText); content1.Add(this.dataGridView_results.Columns[9].HeaderText); content1.Add(this.dataGridView_results.Columns[10].HeaderText); content1.Add(this.dataGridView_results.Columns[11].HeaderText); content1.Add(this.dataGridView_results.Columns[12].HeaderText); analysisContent.Add(content1); } content1 = new List(); content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[4].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[5].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[6].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[7].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[8].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[9].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[10].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[11].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[12].Value.ToString()); analysisContent.Add(content1); string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString(); if (bitDic.ContainsKey(tag)) { bitList.Add(bitDic[tag][0]); bitList.Add(bitDic[tag][1]); } } this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos); } else System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!"); } private void numericUpDown1_KeyUp(object sender, KeyEventArgs e) { numericUpDown1.Value = numericUpDown1.Value; } private void numericUpDown2_KeyUp(object sender, KeyEventArgs e) { numericUpDown2.Value = numericUpDown2.Value; } private void TwoPhaseScaleDialog_Load(object sender, EventArgs e) { } private void TwoPhaseScaleDialog_FormClosing(object sender, FormClosingEventArgs e) { this.documentWorkspace.phaseModels.RemoveAll(u => u.name == "one"); } private void button9_Click(object sender, EventArgs e) { if (this.dataGridView_results.Rows.Count == 0) { System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Noresults.text")); return; } if (this.analyzeSettingModel == null) { System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text")); return; } //获取项目工程内的文件夹路径 ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.TwoComparisonCases.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>(); List> inclusionList = new List>(); List exportModel = new List(); List bitImgList = new List(); List titleContent = new List(); for (int i = 0; i < this.dataGridView_results.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dataGridView_results.Columns[0].HeaderText); content1.Add(this.dataGridView_results.Columns[1].HeaderText); content1.Add(this.dataGridView_results.Columns[2].HeaderText); content1.Add(this.dataGridView_results.Columns[3].HeaderText); content1.Add(this.dataGridView_results.Columns[4].HeaderText); content1.Add(this.dataGridView_results.Columns[5].HeaderText); content1.Add(this.dataGridView_results.Columns[6].HeaderText); content1.Add(this.dataGridView_results.Columns[7].HeaderText); content1.Add(this.dataGridView_results.Columns[8].HeaderText); content1.Add(this.dataGridView_results.Columns[9].HeaderText); content1.Add(this.dataGridView_results.Columns[10].HeaderText); content1.Add(this.dataGridView_results.Columns[11].HeaderText); content1.Add(this.dataGridView_results.Columns[12].HeaderText); analysisContent.Add(content1); titleContent.AddRange(content1); } content1 = new List(); content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[4].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[5].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[6].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[7].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[8].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[9].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[10].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[11].Value.ToString()); content1.Add(this.dataGridView_results.Rows[i].Cells[12].Value.ToString()); analysisContent.Add(content1); string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString(); var export = exportModel.Where(m => m.picName == tag).FirstOrDefault(); if (export == null) { ExportProjectModel exportProjectModel = new ExportProjectModel(); exportProjectModel.dataList = new List>(); exportProjectModel.dataList.Add(titleContent); exportProjectModel.dataList.Add(content1); exportProjectModel.picName = tag; exportProjectModel.tagName = PdnResources.GetString("Menu.GeneralAnalysis.TwoComparisonCases.Text"); exportModel.Add(exportProjectModel); } else { exportModel[exportModel.IndexOf(export)].dataList.Add(content1); } if (bitDic.ContainsKey(tag)) { bitImgList.Add(bitDic[tag][0]); bitImgList.Add(bitDic[tag][1]); } } try { this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitImgList, tagInfos, item.path, item.code); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } } else { System.Windows.MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!"); return; } //保存项目信息到数据库 this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item); } } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { if (this.comboBox2.SelectedIndex == -1) { return; } switch (this.comboBox2.SelectedItem.ToString()) { case "面积": this.selectSearchIndex = 1; this.rb1_CheckedChanged(); break; case "面积比": this.selectSearchIndex = 2; this.rb2_CheckedChanged(); break; case "周长": this.selectSearchIndex = 3; this.perimeter(); break; case "长轴": this.selectSearchIndex = 4; this.longAxis(1); break; case "短轴": this.selectSearchIndex = 5; this.longAxis(2); break; case "倾斜角度": this.selectSearchIndex = 6; this.slope(); break; case "高度": this.selectSearchIndex = 7; this.particulatesHeight(); break; case "宽度": this.selectSearchIndex = 8; this.particulatesWidth(); break; case "宽高比": this.selectSearchIndex = 9; this.rb3_CheckedChanged(); break; case "长径": this.selectSearchIndex = 10; this.trail(1); break; case "短径": this.selectSearchIndex = 11; this.trail(2); break; case "外接圆直径": this.selectSearchIndex = 12; this.circumscribedCircleDiameter(); break; case "球化率": this.selectSearchIndex = 13; this.spheroidizationRate(); break; case "等积圆直径": this.selectSearchIndex = 14; this.equalAreaCircle(); break; case "最大卡规直径": this.selectSearchIndex = 15; this.rb4_CheckedChanged(); break; case "最小卡规直径": this.selectSearchIndex = 16; this.minimumCaliperDiameter(); break; case "平均卡规直径": this.selectSearchIndex = 17; this.averageCaliperDiameter(); break; case "纤维长度": this.selectSearchIndex = 18; this.fiberLength(); break; } } /// /// 应用全部 /// /// /// private void button7_Click(object sender, EventArgs e) { //if (this.listView1.FocusedItem == null) //{ // return; //} //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; //} } /// /// 保存全部 /// /// /// private void button6_Click(object sender, EventArgs e) { } private void getValue(string key, Object value) { switch (key) { case "parameter1": comboBox2.SelectedIndex = (int)value - 1; break; case "OpenWhileExportReport": checkBox1.Checked = Convert.ToBoolean(value); break; case "CalculatorDecimalDigits": numericUpDown3.Value = Convert.ToDecimal(value); break; } } #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); } appWorkspace.SetScriptStartRecording(this.menuId, menuName, args); } private object setScriptRecording(string key) { object value = null; switch (key) { case "parameter1": value = comboBox2.SelectedIndex + 1; break; case "OpenWhileExportReport": value = checkBox1.Checked; break; case "CalculatorDecimalDigits": value = numericUpDown3.Value; break; } return value; } #endregion } }