using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.SQLite; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using PaintDotNet.Annotation.Enum; using PaintDotNet.Annotation.Measure; using PaintDotNet.Base.CommTool; using PaintDotNet.Base.SettingModel; using PaintDotNet.CustomControl; using PaintDotNet.GeneralAnalysis.Special; using PaintDotNet.DbOpreate.DbModel; using PaintDotNet.DbOpreate.DbBll; using System.IO; using PaintDotNet.Base.Functionodel; using PaintDotNet.Annotation; using PaintDotNet.Instrument; using Metis.ParameterSet; namespace PaintDotNet.GeneralAnalysis { /// /// 专项测量 - 长度 /// internal class SpecialMeasureLengthDialog : PdnBaseForm { #region /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code private void InitializeLanguageText() { this.groupBox1.Text = PdnResources.GetString("Menu.operation.text"); this.btnSave.Text = PdnResources.GetString("Menu.Saveresult.text"); this.btnSetting.Text = PdnResources.GetString("Menu.Setting.Text"); this.chkOpenSetting.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text"); this.btnMeasure.Text = PdnResources.GetString("Menu.Startmeasuring.text"); this.groupBox2.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text"); this.groupBox3.Text = PdnResources.GetString("Menu.LabelAction.DrawLine.Text"); this.btnStraightLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); this.label3.Text = PdnResources.GetString("Menu.Linewidth.text") + ":"; this.label2.Text = PdnResources.GetString("Menu.style.text") + ":"; this.label1.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox4.Text = PdnResources.GetString("Menu.Preview.text"); this.btnDelete.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.groupBox5.Text = PdnResources.GetString("Menu.MeasureAction.MeasureLength.Text"); this.btnLengthLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); this.label4.Text = PdnResources.GetString("Menu.Linewidth.text") + ":"; this.label5.Text = PdnResources.GetString("Menu.style.text") + ":"; this.label6.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox6.Text = PdnResources.GetString("Menu.MeasureAction.MeasureParallelLine.Text"); this.btnParallelLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); this.label7.Text = PdnResources.GetString("Menu.Linewidth.text") + ":"; this.label8.Text = PdnResources.GetString("Menu.style.text") + ":"; this.label9.Text = PdnResources.GetString("Menu.color.text") + ":"; this.groupBox7.Text = PdnResources.GetString("Menu.Resultspreview.text"); this.label12.Text = PdnResources.GetString("Menu.Correspondinglevel.text") + ":"; this.label10.Text = PdnResources.GetString("Menu.averagevalue.text") + ":"; this.name.HeaderText = PdnResources.GetString("Menu.Levelname.text"); this.minValue.HeaderText = PdnResources.GetString("Menu.Begintovalue.Text"); this.maxValue.HeaderText = PdnResources.GetString("Menu.Theendvalu.Text"); this.groupBox8.Text = PdnResources.GetString("Menu.Analysisresult.text"); this.btnResultDel.Text = PdnResources.GetString("Menu.Edit.Delete.Text"); this.btnAllShow.Text = PdnResources.GetString("Menu.Showall.text"); this.picName.HeaderText = PdnResources.GetString("Menu.picture.Text"); this.level.HeaderText = PdnResources.GetString("Menu.Levelname.text"); this.avg.HeaderText = PdnResources.GetString("Menu.averagevalue.text"); this.label11.Text = PdnResources.GetString("Menu.Decimal.text"); this.btnExport.Text = PdnResources.GetString("Menu.Exportresults.text"); this.btnCreate.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text"); this.btnExportProject.Text = PdnResources.GetString("Menu.Exportproject.text"); this.Text = PdnResources.GetString("Menu.Generalanalysis.Specialmeasurement.Specialmeth.text"); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.btnSave = new System.Windows.Forms.Button(); this.btnSetting = new System.Windows.Forms.Button(); this.chkOpenSetting = new System.Windows.Forms.CheckBox(); this.btnMeasure = new System.Windows.Forms.Button(); this.cmbSpecial = new System.Windows.Forms.ComboBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.lstPic = new System.Windows.Forms.ListView(); this.imageList1 = new System.Windows.Forms.ImageList(this.components); this.groupBox3 = new System.Windows.Forms.GroupBox(); this.btnStraightLineMeasure = new System.Windows.Forms.Button(); this.cmbStraightLine = new System.Windows.Forms.ComboBox(); this.pnlStraightLineColor = new System.Windows.Forms.Panel(); this.nudStraightLineWidth = new System.Windows.Forms.NumericUpDown(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.groupBox4 = new System.Windows.Forms.GroupBox(); this.pnlTools = new System.Windows.Forms.Panel(); this.btnDelete = new System.Windows.Forms.Button(); this.pnlShow = new System.Windows.Forms.Panel(); this.groupBox5 = new System.Windows.Forms.GroupBox(); this.btnLengthLineMeasure = new System.Windows.Forms.Button(); this.cmbLengthLine = new System.Windows.Forms.ComboBox(); this.pnlLengthLineColor = new System.Windows.Forms.Panel(); this.nudLengthLineWidth = new System.Windows.Forms.NumericUpDown(); this.label4 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.groupBox6 = new System.Windows.Forms.GroupBox(); this.btnParallelLineMeasure = new System.Windows.Forms.Button(); this.cmbParallelLine = new System.Windows.Forms.ComboBox(); this.pnlParallelLineColor = new System.Windows.Forms.Panel(); this.nudParallelLineWidth = new System.Windows.Forms.NumericUpDown(); this.label7 = new System.Windows.Forms.Label(); this.label8 = new System.Windows.Forms.Label(); this.label9 = new System.Windows.Forms.Label(); this.groupBox7 = new System.Windows.Forms.GroupBox(); this.lblLevel = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.lblAvg = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.dgvLevelList = new System.Windows.Forms.DataGridView(); this.name = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.minValue = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.maxValue = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.lstResult = new System.Windows.Forms.ListView(); this.btnResultDel = new System.Windows.Forms.Button(); this.btnAllShow = new System.Windows.Forms.Button(); this.groupBox9 = new System.Windows.Forms.GroupBox(); this.dgvResult = new System.Windows.Forms.DataGridView(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.picName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.level = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.avg = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.groupBox10 = new System.Windows.Forms.GroupBox(); this.btnExportProject = new System.Windows.Forms.Button(); this.numericUpDown1 = new System.Windows.Forms.NumericUpDown(); this.label11 = new System.Windows.Forms.Label(); this.btnExport = new System.Windows.Forms.Button(); this.btnCreate = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.groupBox3.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudStraightLineWidth)).BeginInit(); this.groupBox4.SuspendLayout(); this.groupBox5.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudLengthLineWidth)).BeginInit(); this.groupBox6.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudParallelLineWidth)).BeginInit(); this.groupBox7.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvLevelList)).BeginInit(); this.groupBox8.SuspendLayout(); this.groupBox9.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).BeginInit(); this.groupBox10.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit(); this.SuspendLayout(); // // 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.btnSave); this.groupBox1.Controls.Add(this.btnSetting); this.groupBox1.Controls.Add(this.chkOpenSetting); this.groupBox1.Controls.Add(this.btnMeasure); this.groupBox1.Controls.Add(this.cmbSpecial); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(1210, 73); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "操作"; // // btnSave // this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnSave.Location = new System.Drawing.Point(1091, 24); this.btnSave.Name = "btnSave"; this.btnSave.Size = new System.Drawing.Size(101, 35); this.btnSave.TabIndex = 4; this.btnSave.Text = "保存结果"; this.btnSave.UseVisualStyleBackColor = true; this.btnSave.Click += new System.EventHandler(this.btnSave_Click); // // btnSetting // this.btnSetting.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnSetting.Location = new System.Drawing.Point(987, 24); this.btnSetting.Name = "btnSetting"; this.btnSetting.Size = new System.Drawing.Size(85, 35); this.btnSetting.TabIndex = 3; this.btnSetting.Text = "设置"; this.btnSetting.UseVisualStyleBackColor = true; this.btnSetting.Click += new System.EventHandler(this.btnSetting_Click); // // chkOpenSetting // this.chkOpenSetting.AutoSize = true; this.chkOpenSetting.Checked = true; this.chkOpenSetting.CheckState = System.Windows.Forms.CheckState.Checked; this.chkOpenSetting.Location = new System.Drawing.Point(433, 31); this.chkOpenSetting.Name = "chkOpenSetting"; this.chkOpenSetting.Size = new System.Drawing.Size(15, 14); this.chkOpenSetting.TabIndex = 2; this.chkOpenSetting.UseVisualStyleBackColor = true; this.chkOpenSetting.CheckedChanged += new System.EventHandler(this.chkOpenSetting_CheckedChanged); // // btnMeasure // this.btnMeasure.Location = new System.Drawing.Point(268, 24); this.btnMeasure.Name = "btnMeasure"; this.btnMeasure.Size = new System.Drawing.Size(137, 35); this.btnMeasure.TabIndex = 1; this.btnMeasure.UseVisualStyleBackColor = true; this.btnMeasure.Click += new System.EventHandler(this.btnMeasure_Click); // // cmbSpecial // this.cmbSpecial.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbSpecial.FormattingEnabled = true; this.cmbSpecial.Location = new System.Drawing.Point(17, 29); this.cmbSpecial.Name = "cmbSpecial"; this.cmbSpecial.Size = new System.Drawing.Size(231, 20); this.cmbSpecial.TabIndex = 0; this.cmbSpecial.SelectedIndexChanged += new System.EventHandler(this.cmbSpecial_SelectedIndexChanged); // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.groupBox2.Controls.Add(this.lstPic); this.groupBox2.Location = new System.Drawing.Point(12, 88); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(200, 500); this.groupBox2.TabIndex = 1; this.groupBox2.TabStop = false; this.groupBox2.Text = "图像索引"; // // lstPic // this.lstPic.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.lstPic.HideSelection = false; this.lstPic.LargeImageList = this.imageList1; this.lstPic.Location = new System.Drawing.Point(17, 27); this.lstPic.MultiSelect = false; this.lstPic.Name = "lstPic"; this.lstPic.Size = new System.Drawing.Size(166, 460); this.lstPic.TabIndex = 0; this.lstPic.UseCompatibleStateImageBehavior = false; this.lstPic.SelectedIndexChanged += new System.EventHandler(this.lstPic_SelectedIndexChanged); // // 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; // // groupBox3 // this.groupBox3.Controls.Add(this.btnStraightLineMeasure); this.groupBox3.Controls.Add(this.cmbStraightLine); this.groupBox3.Controls.Add(this.pnlStraightLineColor); this.groupBox3.Controls.Add(this.nudStraightLineWidth); this.groupBox3.Controls.Add(this.label3); this.groupBox3.Controls.Add(this.label2); this.groupBox3.Controls.Add(this.label1); this.groupBox3.Location = new System.Drawing.Point(218, 91); this.groupBox3.Name = "groupBox3"; this.groupBox3.Size = new System.Drawing.Size(360, 100); this.groupBox3.TabIndex = 2; this.groupBox3.TabStop = false; this.groupBox3.Text = "直线"; // // btnStraightLineMeasure // this.btnStraightLineMeasure.Enabled = false; this.btnStraightLineMeasure.Location = new System.Drawing.Point(263, 60); this.btnStraightLineMeasure.Name = "btnStraightLineMeasure"; this.btnStraightLineMeasure.Size = new System.Drawing.Size(75, 25); this.btnStraightLineMeasure.TabIndex = 6; this.btnStraightLineMeasure.Text = "测量"; this.btnStraightLineMeasure.UseVisualStyleBackColor = true; this.btnStraightLineMeasure.Click += new System.EventHandler(this.btnStraightLineMeasure_Click); // // cmbStraightLine // this.cmbStraightLine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbStraightLine.FormattingEnabled = true; this.cmbStraightLine.Location = new System.Drawing.Point(62, 60); this.cmbStraightLine.Name = "cmbStraightLine"; this.cmbStraightLine.Size = new System.Drawing.Size(190, 20); this.cmbStraightLine.TabIndex = 5; this.cmbStraightLine.SelectedIndexChanged += new System.EventHandler(this.cmbStraightLine_SelectedIndexChanged); // // pnlStraightLineColor // this.pnlStraightLineColor.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(128)))), ((int)(((byte)(255))))); this.pnlStraightLineColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pnlStraightLineColor.Location = new System.Drawing.Point(62, 24); this.pnlStraightLineColor.Name = "pnlStraightLineColor"; this.pnlStraightLineColor.Size = new System.Drawing.Size(91, 25); this.pnlStraightLineColor.TabIndex = 4; this.pnlStraightLineColor.BackColorChanged += new System.EventHandler(this.pnlStraightLineColor_BackColorChanged); this.pnlStraightLineColor.Click += new System.EventHandler(this.pnlStraightLineColor_Click); // // nudStraightLineWidth // this.nudStraightLineWidth.Location = new System.Drawing.Point(263, 24); this.nudStraightLineWidth.Maximum = new decimal(new int[] { 5, 0, 0, 0}); this.nudStraightLineWidth.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.nudStraightLineWidth.Name = "nudStraightLineWidth"; this.nudStraightLineWidth.Size = new System.Drawing.Size(78, 21); this.nudStraightLineWidth.TabIndex = 3; this.nudStraightLineWidth.Value = new decimal(new int[] { 1, 0, 0, 0}); this.nudStraightLineWidth.ValueChanged += new System.EventHandler(this.nudStraightLineWidth_ValueChanged); this.nudStraightLineWidth.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudStraightLineWidth_KeyUp); // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(205, 30); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(41, 12); this.label3.TabIndex = 2; this.label3.Text = "线宽:"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(16, 68); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(41, 12); this.label2.TabIndex = 1; this.label2.Text = "样式:"; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(16, 30); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(41, 12); this.label1.TabIndex = 0; this.label1.Text = "颜色:"; // // groupBox4 // this.groupBox4.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.groupBox4.Controls.Add(this.pnlTools); this.groupBox4.Controls.Add(this.btnDelete); this.groupBox4.Controls.Add(this.pnlShow); this.groupBox4.Location = new System.Drawing.Point(584, 91); this.groupBox4.Name = "groupBox4"; this.groupBox4.Size = new System.Drawing.Size(638, 497); this.groupBox4.TabIndex = 3; this.groupBox4.TabStop = false; this.groupBox4.Text = "预览"; // // pnlTools // this.pnlTools.Location = new System.Drawing.Point(6, 22); this.pnlTools.Name = "pnlTools"; this.pnlTools.Size = new System.Drawing.Size(305, 32); this.pnlTools.TabIndex = 2; // // btnDelete // this.btnDelete.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.btnDelete.Location = new System.Drawing.Point(519, 22); this.btnDelete.Name = "btnDelete"; this.btnDelete.Size = new System.Drawing.Size(101, 32); this.btnDelete.TabIndex = 1; this.btnDelete.Text = "删除"; this.btnDelete.UseVisualStyleBackColor = true; this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click); // // pnlShow // this.pnlShow.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.pnlShow.Location = new System.Drawing.Point(6, 60); this.pnlShow.Name = "pnlShow"; this.pnlShow.Size = new System.Drawing.Size(626, 431); this.pnlShow.TabIndex = 0; // // groupBox5 // this.groupBox5.Controls.Add(this.btnLengthLineMeasure); this.groupBox5.Controls.Add(this.cmbLengthLine); this.groupBox5.Controls.Add(this.pnlLengthLineColor); this.groupBox5.Controls.Add(this.nudLengthLineWidth); this.groupBox5.Controls.Add(this.label4); this.groupBox5.Controls.Add(this.label5); this.groupBox5.Controls.Add(this.label6); this.groupBox5.Location = new System.Drawing.Point(218, 197); this.groupBox5.Name = "groupBox5"; this.groupBox5.Size = new System.Drawing.Size(360, 100); this.groupBox5.TabIndex = 4; this.groupBox5.TabStop = false; this.groupBox5.Text = "长度"; // // btnLengthLineMeasure // this.btnLengthLineMeasure.Enabled = false; this.btnLengthLineMeasure.Location = new System.Drawing.Point(263, 60); this.btnLengthLineMeasure.Name = "btnLengthLineMeasure"; this.btnLengthLineMeasure.Size = new System.Drawing.Size(75, 25); this.btnLengthLineMeasure.TabIndex = 6; this.btnLengthLineMeasure.Text = "测量"; this.btnLengthLineMeasure.UseVisualStyleBackColor = true; this.btnLengthLineMeasure.Click += new System.EventHandler(this.btnLengthLineMeasure_Click); // // cmbLengthLine // this.cmbLengthLine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbLengthLine.FormattingEnabled = true; this.cmbLengthLine.Location = new System.Drawing.Point(62, 60); this.cmbLengthLine.Name = "cmbLengthLine"; this.cmbLengthLine.Size = new System.Drawing.Size(190, 20); this.cmbLengthLine.TabIndex = 5; this.cmbLengthLine.SelectedIndexChanged += new System.EventHandler(this.cmbLengthLine_SelectedIndexChanged); // // pnlLengthLineColor // this.pnlLengthLineColor.BackColor = System.Drawing.Color.Red; this.pnlLengthLineColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pnlLengthLineColor.Location = new System.Drawing.Point(62, 24); this.pnlLengthLineColor.Name = "pnlLengthLineColor"; this.pnlLengthLineColor.Size = new System.Drawing.Size(91, 25); this.pnlLengthLineColor.TabIndex = 4; this.pnlLengthLineColor.BackColorChanged += new System.EventHandler(this.pnlLengthLineColor_BackColorChanged); this.pnlLengthLineColor.Click += new System.EventHandler(this.pnlLengthLineColor_Click); // // nudLengthLineWidth // this.nudLengthLineWidth.Location = new System.Drawing.Point(263, 28); this.nudLengthLineWidth.Maximum = new decimal(new int[] { 5, 0, 0, 0}); this.nudLengthLineWidth.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.nudLengthLineWidth.Name = "nudLengthLineWidth"; this.nudLengthLineWidth.Size = new System.Drawing.Size(78, 21); this.nudLengthLineWidth.TabIndex = 3; this.nudLengthLineWidth.Value = new decimal(new int[] { 1, 0, 0, 0}); this.nudLengthLineWidth.ValueChanged += new System.EventHandler(this.nudLengthLineWidth_ValueChanged); this.nudLengthLineWidth.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudLengthLineWidth_KeyUp); // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(205, 30); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(41, 12); this.label4.TabIndex = 2; this.label4.Text = "线宽:"; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(16, 68); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(41, 12); this.label5.TabIndex = 1; this.label5.Text = "样式:"; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(16, 30); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(41, 12); this.label6.TabIndex = 0; this.label6.Text = "颜色:"; // // groupBox6 // this.groupBox6.Controls.Add(this.btnParallelLineMeasure); this.groupBox6.Controls.Add(this.cmbParallelLine); this.groupBox6.Controls.Add(this.pnlParallelLineColor); this.groupBox6.Controls.Add(this.nudParallelLineWidth); this.groupBox6.Controls.Add(this.label7); this.groupBox6.Controls.Add(this.label8); this.groupBox6.Controls.Add(this.label9); this.groupBox6.Location = new System.Drawing.Point(218, 303); this.groupBox6.Name = "groupBox6"; this.groupBox6.Size = new System.Drawing.Size(360, 100); this.groupBox6.TabIndex = 5; this.groupBox6.TabStop = false; this.groupBox6.Text = "平行线"; // // btnParallelLineMeasure // this.btnParallelLineMeasure.Enabled = false; this.btnParallelLineMeasure.Location = new System.Drawing.Point(263, 60); this.btnParallelLineMeasure.Name = "btnParallelLineMeasure"; this.btnParallelLineMeasure.Size = new System.Drawing.Size(75, 25); this.btnParallelLineMeasure.TabIndex = 6; this.btnParallelLineMeasure.Text = "测量"; this.btnParallelLineMeasure.UseVisualStyleBackColor = true; this.btnParallelLineMeasure.Click += new System.EventHandler(this.btnParallelLineMeasure_Click); // // cmbParallelLine // this.cmbParallelLine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbParallelLine.FormattingEnabled = true; this.cmbParallelLine.Location = new System.Drawing.Point(62, 60); this.cmbParallelLine.Name = "cmbParallelLine"; this.cmbParallelLine.Size = new System.Drawing.Size(190, 20); this.cmbParallelLine.TabIndex = 5; this.cmbParallelLine.SelectedIndexChanged += new System.EventHandler(this.cmbParallelLine_SelectedIndexChanged); // // pnlParallelLineColor // this.pnlParallelLineColor.BackColor = System.Drawing.Color.Green; this.pnlParallelLineColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.pnlParallelLineColor.Location = new System.Drawing.Point(62, 24); this.pnlParallelLineColor.Name = "pnlParallelLineColor"; this.pnlParallelLineColor.Size = new System.Drawing.Size(91, 25); this.pnlParallelLineColor.TabIndex = 4; this.pnlParallelLineColor.BackColorChanged += new System.EventHandler(this.pnlParallelLineColor_BackColorChanged); this.pnlParallelLineColor.Click += new System.EventHandler(this.pnlParallelLineColor_Click); // // nudParallelLineWidth // this.nudParallelLineWidth.Location = new System.Drawing.Point(263, 24); this.nudParallelLineWidth.Maximum = new decimal(new int[] { 5, 0, 0, 0}); this.nudParallelLineWidth.Minimum = new decimal(new int[] { 1, 0, 0, 0}); this.nudParallelLineWidth.Name = "nudParallelLineWidth"; this.nudParallelLineWidth.Size = new System.Drawing.Size(78, 21); this.nudParallelLineWidth.TabIndex = 3; this.nudParallelLineWidth.Value = new decimal(new int[] { 1, 0, 0, 0}); this.nudParallelLineWidth.ValueChanged += new System.EventHandler(this.nudParallelLineWidth_ValueChanged); this.nudParallelLineWidth.KeyUp += new System.Windows.Forms.KeyEventHandler(this.nudParallelLineWidth_KeyUp); // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(205, 30); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(41, 12); this.label7.TabIndex = 2; this.label7.Text = "线宽:"; // // label8 // this.label8.AutoSize = true; this.label8.Location = new System.Drawing.Point(16, 68); this.label8.Name = "label8"; this.label8.Size = new System.Drawing.Size(41, 12); this.label8.TabIndex = 1; this.label8.Text = "样式:"; // // label9 // this.label9.AutoSize = true; this.label9.Location = new System.Drawing.Point(16, 30); this.label9.Name = "label9"; this.label9.Size = new System.Drawing.Size(41, 12); this.label9.TabIndex = 0; this.label9.Text = "颜色:"; // // groupBox7 // this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.groupBox7.Controls.Add(this.lblLevel); this.groupBox7.Controls.Add(this.label12); this.groupBox7.Controls.Add(this.lblAvg); this.groupBox7.Controls.Add(this.label10); this.groupBox7.Controls.Add(this.dgvLevelList); this.groupBox7.Location = new System.Drawing.Point(218, 406); this.groupBox7.Name = "groupBox7"; this.groupBox7.Size = new System.Drawing.Size(360, 182); this.groupBox7.TabIndex = 6; this.groupBox7.TabStop = false; this.groupBox7.Text = "结果预览"; // // lblLevel // this.lblLevel.AutoSize = true; this.lblLevel.Location = new System.Drawing.Point(255, 25); this.lblLevel.Name = "lblLevel"; this.lblLevel.Size = new System.Drawing.Size(11, 12); this.lblLevel.TabIndex = 4; this.lblLevel.Text = "0"; // // label12 // this.label12.AutoSize = true; this.label12.Location = new System.Drawing.Point(170, 25); this.label12.Name = "label12"; this.label12.Size = new System.Drawing.Size(65, 12); this.label12.TabIndex = 3; this.label12.Text = "对应级别:"; // // lblAvg // this.lblAvg.AutoSize = true; this.lblAvg.Location = new System.Drawing.Point(75, 25); this.lblAvg.Name = "lblAvg"; this.lblAvg.Size = new System.Drawing.Size(11, 12); this.lblAvg.TabIndex = 2; this.lblAvg.Text = "0"; // // label10 // this.label10.AutoSize = true; this.label10.Location = new System.Drawing.Point(6, 25); this.label10.Name = "label10"; this.label10.Size = new System.Drawing.Size(53, 12); this.label10.TabIndex = 1; this.label10.Text = "平均值:"; // // dgvLevelList // this.dgvLevelList.AllowUserToAddRows = false; this.dgvLevelList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.dgvLevelList.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dgvLevelList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvLevelList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.name, this.minValue, this.maxValue}); this.dgvLevelList.Location = new System.Drawing.Point(6, 51); this.dgvLevelList.Name = "dgvLevelList"; this.dgvLevelList.ReadOnly = true; this.dgvLevelList.RowHeadersVisible = false; this.dgvLevelList.RowHeadersWidth = 51; this.dgvLevelList.RowTemplate.Height = 27; this.dgvLevelList.Size = new System.Drawing.Size(348, 125); this.dgvLevelList.TabIndex = 0; // // name // this.name.MinimumWidth = 6; this.name.Name = "name"; this.name.ReadOnly = true; // // minValue // this.minValue.MinimumWidth = 6; this.minValue.Name = "minValue"; this.minValue.ReadOnly = true; // // maxValue // this.maxValue.MinimumWidth = 6; this.maxValue.Name = "maxValue"; this.maxValue.ReadOnly = true; // // groupBox8 // this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.groupBox8.Controls.Add(this.lstResult); this.groupBox8.Controls.Add(this.btnResultDel); this.groupBox8.Controls.Add(this.btnAllShow); this.groupBox8.Location = new System.Drawing.Point(12, 594); this.groupBox8.Name = "groupBox8"; this.groupBox8.Size = new System.Drawing.Size(200, 220); this.groupBox8.TabIndex = 7; this.groupBox8.TabStop = false; this.groupBox8.Text = "分析结果"; // // lstResult // this.lstResult.HideSelection = false; this.lstResult.Location = new System.Drawing.Point(17, 55); this.lstResult.Name = "lstResult"; this.lstResult.Size = new System.Drawing.Size(166, 145); this.lstResult.TabIndex = 11; this.lstResult.UseCompatibleStateImageBehavior = false; this.lstResult.View = System.Windows.Forms.View.Tile; this.lstResult.SelectedIndexChanged += new System.EventHandler(this.lstResult_SelectedIndexChanged); // // btnResultDel // this.btnResultDel.Location = new System.Drawing.Point(108, 26); this.btnResultDel.Name = "btnResultDel"; this.btnResultDel.Size = new System.Drawing.Size(75, 23); this.btnResultDel.TabIndex = 10; this.btnResultDel.Text = "删除"; this.btnResultDel.UseVisualStyleBackColor = true; this.btnResultDel.Click += new System.EventHandler(this.btnResultDel_Click); // // btnAllShow // this.btnAllShow.Location = new System.Drawing.Point(19, 26); this.btnAllShow.Name = "btnAllShow"; this.btnAllShow.Size = new System.Drawing.Size(75, 23); this.btnAllShow.TabIndex = 9; this.btnAllShow.Text = "全部显示"; this.btnAllShow.UseVisualStyleBackColor = true; this.btnAllShow.Click += new System.EventHandler(this.btnAllShow_Click); // // groupBox9 // this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox9.Controls.Add(this.dgvResult); this.groupBox9.Location = new System.Drawing.Point(218, 594); this.groupBox9.Name = "groupBox9"; this.groupBox9.Size = new System.Drawing.Size(816, 220); this.groupBox9.TabIndex = 8; this.groupBox9.TabStop = false; // // dgvResult // this.dgvResult.AllowUserToAddRows = false; this.dgvResult.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.dgvResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dgvResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvResult.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Column1, this.picName, this.level, this.avg}); this.dgvResult.Location = new System.Drawing.Point(8, 16); this.dgvResult.Name = "dgvResult"; this.dgvResult.ReadOnly = true; this.dgvResult.RowHeadersVisible = false; this.dgvResult.RowHeadersWidth = 51; this.dgvResult.RowTemplate.Height = 27; this.dgvResult.Size = new System.Drawing.Size(801, 197); this.dgvResult.TabIndex = 0; // // Column1 // this.Column1.HeaderText = "tag"; this.Column1.MinimumWidth = 6; this.Column1.Name = "Column1"; this.Column1.ReadOnly = true; this.Column1.Visible = false; // // picName // this.picName.MinimumWidth = 6; this.picName.Name = "picName"; this.picName.ReadOnly = true; // // level // this.level.MinimumWidth = 6; this.level.Name = "level"; this.level.ReadOnly = true; // // avg // this.avg.MinimumWidth = 6; this.avg.Name = "avg"; this.avg.ReadOnly = true; // // groupBox10 // this.groupBox10.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.groupBox10.Controls.Add(this.btnExportProject); this.groupBox10.Controls.Add(this.numericUpDown1); this.groupBox10.Controls.Add(this.label11); this.groupBox10.Controls.Add(this.btnExport); this.groupBox10.Controls.Add(this.btnCreate); this.groupBox10.Location = new System.Drawing.Point(1040, 594); this.groupBox10.Name = "groupBox10"; this.groupBox10.Size = new System.Drawing.Size(182, 220); this.groupBox10.TabIndex = 9; this.groupBox10.TabStop = false; // // btnExportProject // this.btnExportProject.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnExportProject.Location = new System.Drawing.Point(28, 100); this.btnExportProject.Name = "btnExportProject"; this.btnExportProject.Size = new System.Drawing.Size(136, 32); this.btnExportProject.TabIndex = 10; this.btnExportProject.Text = "导出项目"; this.btnExportProject.UseVisualStyleBackColor = true; this.btnExportProject.Click += new System.EventHandler(this.btnExportProject_Click); // // numericUpDown1 // this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.numericUpDown1.Location = new System.Drawing.Point(81, 161); this.numericUpDown1.Maximum = new decimal(new int[] { 10, 0, 0, 0}); this.numericUpDown1.Name = "numericUpDown1"; this.numericUpDown1.Size = new System.Drawing.Size(62, 21); this.numericUpDown1.TabIndex = 8; this.numericUpDown1.Value = new decimal(new int[] { 2, 0, 0, 0}); this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged); // // label11 // this.label11.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.label11.AutoSize = true; this.label11.Location = new System.Drawing.Point(38, 166); this.label11.Name = "label11"; this.label11.Size = new System.Drawing.Size(41, 12); this.label11.TabIndex = 7; this.label11.Text = "小数:"; // // btnExport // this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnExport.Location = new System.Drawing.Point(28, 62); this.btnExport.Name = "btnExport"; this.btnExport.Size = new System.Drawing.Size(137, 32); this.btnExport.TabIndex = 1; this.btnExport.Text = "导出结果"; this.btnExport.UseVisualStyleBackColor = true; this.btnExport.Click += new System.EventHandler(this.btnExport_Click); // // btnCreate // this.btnCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnCreate.Location = new System.Drawing.Point(28, 24); this.btnCreate.Name = "btnCreate"; this.btnCreate.Size = new System.Drawing.Size(137, 32); this.btnCreate.TabIndex = 0; this.btnCreate.Text = "生成报告"; this.btnCreate.UseVisualStyleBackColor = true; this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click); // // SpecialMeasureLengthDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1234, 823); this.Controls.Add(this.groupBox10); this.Controls.Add(this.groupBox9); this.Controls.Add(this.groupBox8); this.Controls.Add(this.groupBox7); this.Controls.Add(this.groupBox6); this.Controls.Add(this.groupBox5); this.Controls.Add(this.groupBox4); this.Controls.Add(this.groupBox3); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Name = "SpecialMeasureLengthDialog"; this.Text = "专项测量 - 长度"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.SpecialMeasureLengthDialog_FormClosing); this.Controls.SetChildIndex(this.groupBox1, 0); this.Controls.SetChildIndex(this.groupBox2, 0); this.Controls.SetChildIndex(this.groupBox3, 0); this.Controls.SetChildIndex(this.groupBox4, 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.Controls.SetChildIndex(this.groupBox9, 0); this.Controls.SetChildIndex(this.groupBox10, 0); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox3.ResumeLayout(false); this.groupBox3.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudStraightLineWidth)).EndInit(); this.groupBox4.ResumeLayout(false); this.groupBox5.ResumeLayout(false); this.groupBox5.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudLengthLineWidth)).EndInit(); this.groupBox6.ResumeLayout(false); this.groupBox6.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudParallelLineWidth)).EndInit(); this.groupBox7.ResumeLayout(false); this.groupBox7.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dgvLevelList)).EndInit(); this.groupBox8.ResumeLayout(false); this.groupBox9.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).EndInit(); this.groupBox10.ResumeLayout(false); this.groupBox10.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.CheckBox chkOpenSetting; private System.Windows.Forms.Button btnMeasure; private System.Windows.Forms.ComboBox cmbSpecial; private System.Windows.Forms.Button btnSave; private System.Windows.Forms.Button btnSetting; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.GroupBox groupBox3; private System.Windows.Forms.GroupBox groupBox4; private System.Windows.Forms.Button btnStraightLineMeasure; private System.Windows.Forms.ComboBox cmbStraightLine; private System.Windows.Forms.Panel pnlStraightLineColor; private System.Windows.Forms.NumericUpDown nudStraightLineWidth; private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label1; private System.Windows.Forms.GroupBox groupBox5; private System.Windows.Forms.Button btnLengthLineMeasure; private System.Windows.Forms.ComboBox cmbLengthLine; private System.Windows.Forms.Panel pnlLengthLineColor; private System.Windows.Forms.NumericUpDown nudLengthLineWidth; private System.Windows.Forms.Label label4; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.GroupBox groupBox6; private System.Windows.Forms.Button btnParallelLineMeasure; private System.Windows.Forms.ComboBox cmbParallelLine; private System.Windows.Forms.Panel pnlParallelLineColor; private System.Windows.Forms.NumericUpDown nudParallelLineWidth; private System.Windows.Forms.Label label7; private System.Windows.Forms.Label label8; private System.Windows.Forms.Label label9; private System.Windows.Forms.GroupBox groupBox7; private System.Windows.Forms.DataGridView dgvLevelList; private System.Windows.Forms.DataGridViewTextBoxColumn name; private System.Windows.Forms.DataGridViewTextBoxColumn minValue; private System.Windows.Forms.DataGridViewTextBoxColumn maxValue; private System.Windows.Forms.Label lblAvg; private System.Windows.Forms.Label label10; private System.Windows.Forms.Label lblLevel; private System.Windows.Forms.Label label12; private System.Windows.Forms.GroupBox groupBox8; private System.Windows.Forms.GroupBox groupBox9; private System.Windows.Forms.DataGridView dgvResult; private System.Windows.Forms.GroupBox groupBox10; private System.Windows.Forms.Button btnExport; private System.Windows.Forms.Button btnCreate; private System.Windows.Forms.Panel pnlShow; private System.Windows.Forms.Button btnDelete; private System.Windows.Forms.Panel pnlTools; private System.Windows.Forms.ListView lstPic; private System.Windows.Forms.ImageList imageList1; private System.Windows.Forms.NumericUpDown numericUpDown1; private System.Windows.Forms.Label label11; private System.Windows.Forms.Button btnResultDel; private System.Windows.Forms.Button btnAllShow; private System.Windows.Forms.DataGridViewTextBoxColumn Column1; private System.Windows.Forms.DataGridViewTextBoxColumn picName; private System.Windows.Forms.DataGridViewTextBoxColumn level; private System.Windows.Forms.DataGridViewTextBoxColumn avg; private System.Windows.Forms.ListView lstResult; private System.Windows.Forms.Button btnExportProject; #endregion /// /// 网格调色板 /// private ColorsForm colorsFormGrid; private AppWorkspace appWorkspace; private DocumentWorkspaceWindow m_documentWorkspace; private SQLiteHelper m_sqlHelper; private DataTable m_specialList; private DataTable m_levelList; private SpecialItem m_specialItem = SpecialItem.LENGTH; private int m_specialSelectedIndex = 0; private string m_specialId; /// /// 原图 /// private OpenCvSharp.Mat imageMat; /// /// 原图带原相测量等 /// private Bitmap m_originalBit; private ArtworkControlButtons m_controlButtons; private object m_currentColorPanel; private bool m_isMeasure; private bool m_isOpenSetting; private bool m_isMeasureByStraightLine; private bool m_isMeasureByLengthLine; private bool m_isMeasureByParallelLine; private MeasureStyleModel m_measureStyleModel; private List m_measureResults = new List(); private MeasureLengthResult m_measureCurrent; /// /// 图片名称 /// private string m_graphName; private List m_oldDrawList = new List(); private bool m_showAll; /// /// 中间数据 /// private List tempDataModel = new List(); // 小数位 private int decnum = 2; /// /// 保存用于生成报告的图片 /// private List bitList = new List(); /// /// 储存点击保存结果后的所有原图与分析图 /// private Dictionary> bitDic = new Dictionary>(); // 统一全局设置的线颜色、线宽、样式 private int m_straightLineColor; private int m_straightLineWidth; private int m_straightLineStyle; private int m_lengthLineColor; private int m_lengthLineWidth; private int m_lengthLineStyle; private int m_parallelLineColor; private int m_parallelLineWidth; private int m_parallelLineStyle; private int defaultIndex = -1; private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel(); public SpecialMeasureLengthDialog(AppWorkspace workspace) { appWorkspace = workspace; m_measureStyleModel = appWorkspace.GetMeasureStyleModel(); m_sqlHelper = new SQLiteHelper(); //连接数据库 m_sqlHelper.Connect(); this.colorsFormGrid = new ColorsForm(); this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen; InitializeComponent(); InitializeLanguageText(); InitPicList(); InitSpecialCmb(); InitDocumentView(); InitDocumentViewTools(); InitLineStyles(); InitCurrentMeasure(); GetAttributeFromConfigurationFile(); SetAnalyzeModelFromXml("Template.Manager.item2.SpecialLength"); } private void ShowImgEvent(object sender, EventArgs e) { lstPic.Focus(); if (this.defaultIndex != -1) { this.lstPic.Items[defaultIndex].Focused = true; this.lstPic.Items[defaultIndex].Selected = true; getLastData(); } } /// /// 初始化专项数据 /// public void InitSpecialCmb() { cmbSpecial.Items.Clear(); string select_sql = "select * from mic_special_definition where delete_flag = 0 and special_type = ? "; //查询的SQL语句 SQLiteParameter[] para = new SQLiteParameter[1]; para[0] = new SQLiteParameter("special_type", m_specialItem); m_specialList = m_sqlHelper.ExecuteDataTable(select_sql, para); //执行查询操作,结果存放在dt中 this.cmbSpecial.Items.Clear(); if (m_specialList.Rows.Count > 0) { for (int i = 0; i < m_specialList.Rows.Count; ++i) { this.cmbSpecial.Items.Add(m_specialList.Rows[i]["special_name"].ToString()); } this.cmbSpecial.SelectedIndex = m_specialSelectedIndex; m_specialId = m_specialList.Rows[m_specialSelectedIndex]["id"].ToString(); } } /// /// 初始化当前测量数据 /// public void InitCurrentMeasure() { m_measureCurrent = new MeasureLengthResult(); m_measureCurrent.GraphName = m_graphName; m_measureCurrent.LevelName = ""; m_measureCurrent.MeasureAvg = 0; lblLevel.Text = ""; lblAvg.Text = "0"; } /// /// 初始化图片列表数据 /// 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.lstPic.Items.Add("", i); this.lstPic.Items[i].ImageIndex = i; this.lstPic.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName(); this.lstPic.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName(); if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace)) { defaultIndex = i; } } this.Shown += ShowImgEvent; } /// /// 初始化DocumentView /// public void InitDocumentView() { this.pnlShow.Controls.Clear(); this.m_documentWorkspace = new DocumentWorkspaceWindow(appWorkspace); this.m_documentWorkspace.AppWorkspaceTop = appWorkspace; this.m_documentWorkspace.Visible = true; this.m_documentWorkspace.Dock = DockStyle.Fill; this.m_documentWorkspace.Units = MeasurementUnit.Micron; if (this.lstPic.FocusedItem != null) { this.m_documentWorkspace.xmlSaveModel = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].xmlSaveModel; this.m_documentWorkspace.rules = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].rules; } this.pnlShow.Controls.Add(this.m_documentWorkspace); this.m_documentWorkspace.ContinuousDrawingMeasure = true; } private void GraphicsList_SelectChanged(object sender, EventArgs e) { this.GetDataAndAvg(); } #region 初始化DocumentView工具 public void InitDocumentViewTools() { this.m_controlButtons = new ArtworkControlButtons(); this.m_controlButtons.Dock = DockStyle.Top; this.m_controlButtons.Height = 30; this.m_controlButtons.HideZoomToWindowAndActualSize(); this.m_controlButtons.HideMovingDirection(); this.pnlTools.Controls.Add(m_controlButtons); this.m_controlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click); this.m_controlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click); this.m_controlButtons.pointerButton.Click += new EventHandler(pointerButton_Click); this.m_controlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click); } private void mobileModeButton_Click(object sender, EventArgs e) { this.m_documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode; } private void pointerButton_Click(object sender, EventArgs e) { this.m_documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer; } private void zoomOutButton_Click(object sender, EventArgs e) { if (this.m_documentWorkspace.CompositionSurface != null) this.m_documentWorkspace.ZoomOut(); } private void zoomInButton_Click(object sender, EventArgs e) { if (this.m_documentWorkspace.CompositionSurface != null) this.m_documentWorkspace.ZoomIn(); } #endregion /// /// 初始化线样式 /// public void InitLineStyles() { m_straightLineColor = m_measureStyleModel.measureLine.lineColor; m_straightLineWidth = m_measureStyleModel.measureLine.lineWidth; m_straightLineStyle = m_measureStyleModel.measureLine.lineStyle; m_lengthLineColor = m_measureStyleModel.measureLength.lineColor; m_lengthLineWidth = m_measureStyleModel.measureLength.lineWidth; m_lengthLineStyle = m_measureStyleModel.measureLength.lineStyle; m_parallelLineColor = m_measureStyleModel.measureParallelLine.lineColor; m_parallelLineWidth = m_measureStyleModel.measureParallelLine.lineWidth; m_parallelLineStyle = m_measureStyleModel.measureParallelLine.lineStyle; //绑定线样式数据 this.cmbStraightLine.Items.AddRange(InvariantData.dashStyles); this.cmbStraightLine.SelectedIndex = 0; this.cmbLengthLine.Items.AddRange(InvariantData.dashStyles); this.cmbLengthLine.SelectedIndex = 0; this.cmbParallelLine.Items.AddRange(InvariantData.dashStyles); this.cmbParallelLine.SelectedIndex = 0; } private void btnSetting_Click(object sender, EventArgs e) { OpenSettingDialog(); } private void OpenSettingDialog() { AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.SpecialLength"); if (recombinationRateSetDialog.hasModule) { recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen; recombinationRateSetDialog.ShowDialog(); } else { recombinationRateSetDialog = null; } } private void cmbSpecial_SelectedIndexChanged(object sender, EventArgs e) { //m_specialSelectedIndex = this.cmbSpecial.SelectedIndex; this.InitSpecialLevelList(); } /// /// 初始化专项级别列表 /// public void InitSpecialLevelList() { m_specialId = m_specialList.Rows[this.cmbSpecial.SelectedIndex]["id"].ToString(); dgvLevelList.AutoGenerateColumns = false; dgvLevelList.AllowUserToAddRows = false; dgvLevelList.ReadOnly = true; this.dgvLevelList.Rows.Clear(); string select_sql = "select * from mic_special_definition_info where special_id = '" + m_specialId + "'"; //查询的SQL语句 m_levelList = m_sqlHelper.ExecuteDataTable(select_sql, null); //执行查询操作,结果存放在dt中 if (m_levelList.Rows.Count > 0) { dgvLevelList.Rows.Add(m_levelList.Rows.Count); for (int i = 0; i < m_levelList.Rows.Count; ++i) { dgvLevelList.Rows[i].Cells["name"].Value = m_levelList.Rows[i]["name"].ToString(); dgvLevelList.Rows[i].Cells["minValue"].Value = m_levelList.Rows[i]["minValue"]; dgvLevelList.Rows[i].Cells["maxValue"].Value = m_levelList.Rows[i]["maxValue"]; } } } /// /// 图像索引切换 /// /// /// private void lstPic_SelectedIndexChanged(object sender, EventArgs e) { this.NewGraphicsListClear(); if (this.lstPic.FocusedItem != null && this.lstPic.FocusedItem.Selected) { InitDocumentView(); m_graphName = this.lstPic.FocusedItem.Text; InitCurrentMeasure(); this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].CompositionSurface.CreatedAliasedMat(); Document document = Document.FromImageMat(imageMat.Clone()/* //待测试.Clone()*/); this.m_documentWorkspace.Document = document; this.m_documentWorkspace.Units = MeasurementUnit.Micron; this.m_documentWorkspace.GraphicsList = new GraphicsList(this.m_documentWorkspace); //this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GraphicsList.GetDrawClassList(DrawClass.Measure).ForEach(i => m_oldDrawList.Add(i)); //this.m_documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GraphicsList; this.m_documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].phaseModels; this.m_documentWorkspace.GraphicsList.SelectChanged += GraphicsList_SelectChanged; // 选择了图片 Bitmap m_bitmap = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap(); m_originalBit = m_bitmap.Clone(new Rectangle(0, 0, m_bitmap.Width, m_bitmap.Height), m_bitmap.PixelFormat); Graphics graphics = Graphics.FromImage(m_originalBit); Draw(graphics); ExistenceMeasure(); //this.selectPicture = true; } } #region 线颜色选择 private void ShowColorsForm(object sender) { Panel panel = (Panel)sender; this.colorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(panel.BackColor); this.colorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.gridColorChanged)); this.colorsFormGrid.ShowDialog(); } /// /// 网格Panel的调色板颜色改变 /// /// /// private void gridColorChanged(object sender, EventArgs e) { Panel panel = (Panel)m_currentColorPanel; Color color = this.colorsFormGrid.UserPrimaryColor.ToColor(); panel.BackColor = color; this.colorsFormGrid.Close(); } private void pnlStraightLineColor_Click(object sender, EventArgs e) { m_currentColorPanel = sender; ShowColorsForm(sender); } private void pnlLengthLineColor_Click(object sender, EventArgs e) { m_currentColorPanel = sender; ShowColorsForm(sender); } private void pnlParallelLineColor_Click(object sender, EventArgs e) { m_currentColorPanel = sender; ShowColorsForm(sender); } #endregion private void nudStraightLineWidth_KeyUp(object sender, KeyEventArgs e) { try { nudStraightLineWidth.Value = Convert.ToInt32(this.nudStraightLineWidth.Text); } catch (Exception) { } } private void nudLengthLineWidth_KeyUp(object sender, KeyEventArgs e) { try { nudLengthLineWidth.Value = Convert.ToInt32(this.nudLengthLineWidth.Text); } catch (Exception) { } } private void nudParallelLineWidth_KeyUp(object sender, KeyEventArgs e) { try { nudParallelLineWidth.Value = Convert.ToInt32(this.nudParallelLineWidth.Text); } catch (Exception) { } } /// /// 开启/结束测量 /// /// /// private void btnMeasure_Click(object sender, EventArgs e) { if (cmbSpecial.SelectedItem == null || m_levelList == null || m_levelList.Rows.Count <= 0) { MessageBox.Show(PdnResources.GetString("Menu.Pleasefirstsetthespecialdefinitionlength.Text")); return; } m_isMeasure = !m_isMeasure; UpdateMeasureUIAndState(); } private void UpdateMeasureUIAndState() { if (m_isMeasure) { this.NewGraphicsListClear(); this.InitCurrentMeasure(); if (m_measureResults.Count > 0) { if (m_specialSelectedIndex != this.cmbSpecial.SelectedIndex) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.learthelastmeasuremen.Text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { this.lstResult.Items.Clear(); this.m_measureResults.Clear(); this.bitDic.Clear(); this.dgvResult.Rows.Clear(); } else { m_isMeasure = false; return; } } } btnMeasure.Text = PdnResources.GetString("Menu.Stopmeasure.text"); btnStraightLineMeasure.Enabled = true; btnLengthLineMeasure.Enabled = true; btnParallelLineMeasure.Enabled = true; cmbSpecial.Enabled = false; } else { btnMeasure.Text = PdnResources.GetString("Menu.Pleasestartmeasuring.text"); cmbSpecial.Enabled = true; btnStraightLineMeasure.Enabled = false; btnLengthLineMeasure.Enabled = false; btnParallelLineMeasure.Enabled = false; if (m_isMeasureByStraightLine) { btnStraightLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_isMeasureByStraightLine = false; } if (m_isMeasureByLengthLine) { btnLengthLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_isMeasureByLengthLine = false; } if (m_isMeasureByParallelLine) { btnParallelLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_isMeasureByParallelLine = false; } this.m_documentWorkspace.ActiveTool = DrawToolType.Pointer; } } private void chkOpenSetting_CheckedChanged(object sender, EventArgs e) { m_isOpenSetting = chkOpenSetting.Checked; } private void btnStraightLineMeasure_Click(object sender, EventArgs e) { if (imageMat == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheimagefirst.Text")); return; } m_isMeasureByStraightLine = !m_isMeasureByStraightLine; if (m_isMeasureByStraightLine) { btnStraightLineMeasure.Text = PdnResources.GetString("Menu.stop.text"); m_isMeasureByLengthLine = false; btnLengthLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_isMeasureByParallelLine = false; btnParallelLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_measureStyleModel.measureLine.lineColor = pnlStraightLineColor.BackColor.ToArgb(); m_measureStyleModel.measureLine.lineWidth = (int)nudStraightLineWidth.Value; m_measureStyleModel.measureLine.lineStyle = cmbStraightLine.SelectedIndex; this.m_documentWorkspace.ActiveTool = DrawToolType.MeasureLine; } else { btnStraightLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); this.m_documentWorkspace.ActiveTool = DrawToolType.Pointer; this.GetDataAndAvg(); } UpdateMeasureDecimalPlaces((int)numericUpDown1.Value); } /// /// 是否存在测量,有则选择工具 /// /// public void ExistenceMeasure() { if (PdnResources.GetString("Menu.stop.text").Equals(btnStraightLineMeasure.Text)) this.m_documentWorkspace.ActiveTool = DrawToolType.MeasureLine; if (PdnResources.GetString("Menu.stop.text").Equals(btnLengthLineMeasure.Text)) this.m_documentWorkspace.ActiveTool = DrawToolType.MeasureLength; if (PdnResources.GetString("Menu.stop.text").Equals(btnParallelLineMeasure.Text)) this.m_documentWorkspace.ActiveTool = DrawToolType.MeasureParallelLine; } private void btnLengthLineMeasure_Click(object sender, EventArgs e) { if (imageMat == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheimagefirst.Text")); return; } m_isMeasureByLengthLine = !m_isMeasureByLengthLine; if (m_isMeasureByLengthLine) { btnLengthLineMeasure.Text = PdnResources.GetString("Menu.stop.text"); m_isMeasureByStraightLine = false; btnStraightLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_isMeasureByParallelLine = false; btnParallelLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_measureStyleModel.measureLength.lineColor = pnlLengthLineColor.BackColor.ToArgb(); m_measureStyleModel.measureLength.lineWidth = (int)nudLengthLineWidth.Value; m_measureStyleModel.measureLength.lineStyle = cmbLengthLine.SelectedIndex; this.m_documentWorkspace.ActiveTool = DrawToolType.MeasureLength; } else { btnLengthLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); this.m_documentWorkspace.ActiveTool = DrawToolType.Pointer; this.GetDataAndAvg(); } UpdateMeasureDecimalPlaces((int)numericUpDown1.Value); } private void btnParallelLineMeasure_Click(object sender, EventArgs e) { if (imageMat == null) { MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttheimagefirst.Text")); return; } m_isMeasureByParallelLine = !m_isMeasureByParallelLine; if (m_isMeasureByParallelLine) { btnParallelLineMeasure.Text = PdnResources.GetString("Menu.stop.text"); m_isMeasureByStraightLine = false; btnStraightLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_isMeasureByLengthLine = false; btnLengthLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); m_measureStyleModel.measureParallelLine.lineColor = pnlParallelLineColor.BackColor.ToArgb(); m_measureStyleModel.measureParallelLine.lineWidth = (int)nudParallelLineWidth.Value; m_measureStyleModel.measureParallelLine.lineStyle = cmbParallelLine.SelectedIndex; this.m_documentWorkspace.ActiveTool = DrawToolType.MeasureParallelLine; } else { btnParallelLineMeasure.Text = PdnResources.GetString("Menu.measuring.text"); this.m_documentWorkspace.ActiveTool = DrawToolType.Pointer; this.GetDataAndAvg(); } UpdateMeasureDecimalPlaces((int)numericUpDown1.Value); } private TreeView drawTreeView; /// /// 从配置文件中读取设置信息 /// private void GetAttributeFromConfigurationFile() { MeasureListSetModel measureListSetModel = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(System.Windows.Forms.Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\MeasureListSetModel.xml", FileMode.Open)); drawTreeView = new TreeView(); if (measureListSetModel != null && measureListSetModel.AttributeMapDrawNodes != null) { for (int i = 0; i < measureListSetModel.AttributeMapDrawNodes.Count; i++) { TreeNode firstNode = new TreeNode(); firstNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Name; for (int j = 0; j < measureListSetModel.AttributeMapDrawNodes[i].Attribute.Count; j++) { TreeNode scondNode = new TreeNode(); scondNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Text; scondNode.Name = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Name; for (int k = 0; k < measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute.Count; k++) { if (measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute.Count > 0) { TreeNode thirdNode = new TreeNode(); thirdNode.Text = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute[k].Text; thirdNode.Name = measureListSetModel.AttributeMapDrawNodes[i].Attribute[j].Attribute[k].Name; scondNode.Nodes.Add(thirdNode); } } firstNode.Nodes.Add(scondNode); } drawTreeView.Nodes.Add(firstNode); } } } /// /// 获取计算测量结果 /// private void GetDataAndAvg() { string level = ""; double avg = 0; double sum = 0; int count = this.m_documentWorkspace.GraphicsList.Count; int no = 0; for (int i = 0; i < count; i++) { if (this.m_documentWorkspace.GraphicsList[i].objectType == DrawClass.Measure) { no++; Dictionary data = ((MeasureDrawObject)this.m_documentWorkspace.GraphicsList[i]).GetData(); foreach (var keys in data) { /// /// 像素长度 /// //PixelLength /// /// 物理长度 /// //PhysicalLength object v; InvariantData.measureAttributes.TryGetValue((MeasureAttributes)keys.Key, out v); if (((MeasureAttributes)keys.Key).ToString() == "PhysicalLength") { double length = double.Parse(keys.Value.ToString()); if (length > 0) { sum += length; this.ShowMeasureInfo(i); } else { no--; } break; } } } } if(no > 0) { avg = sum / no; } if (m_levelList != null && m_levelList.Rows.Count > 0) { for (int i = 0; i < m_levelList.Rows.Count; ++i) { double minValue = double.Parse(m_levelList.Rows[i]["minValue"].ToString()); double maxValue = double.Parse(m_levelList.Rows[i]["maxValue"].ToString()); if (avg >= minValue && avg < maxValue) { level = m_levelList.Rows[i]["name"].ToString(); break; } } } lblLevel.Text = level; lblAvg.Text = AnalysisTools.GetDecNum(avg, decnum); ; m_measureCurrent.LevelName = level; m_measureCurrent.MeasureAvg = avg; } private void ShowMeasureInfo(int index) { int i = index; int count1 = drawTreeView.Nodes.Count; ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).drawingProperties.Clear(); ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).pointChangeObject.Clear(); for (int k = 0; k < count1; k++) { int count2 = drawTreeView.Nodes[k].Nodes.Count; for (int j = 0; j < count2; j++) { if (this.m_documentWorkspace.GraphicsList[i].drawToolType == (DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name)) { bool drawb = false; if (drawTreeView.Nodes[k].Nodes[j].Nodes.Count == 0) { ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).drawingProperties.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), new string[] { "nothing" }); if (this.m_documentWorkspace.oldDrawTreeView != null) { if (this.m_documentWorkspace.oldDrawTreeView.Nodes[k].Nodes[j].Nodes.Count != 0) ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true); } else { ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true); } } else { int a = 0; string[] arr = new string[drawTreeView.Nodes[k].Nodes[j].Nodes.Count]; foreach (TreeNode node2 in drawTreeView.Nodes[k].Nodes[j].Nodes) { arr[a] = node2.Name; a++; } ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).drawingProperties.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), arr); if (this.m_documentWorkspace.oldDrawTreeView != null) { if (drawTreeView.Nodes[k].Nodes[j].Nodes.Count != this.m_documentWorkspace.oldDrawTreeView.Nodes[k].Nodes[j].Nodes.Count) { ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true); } else { foreach (TreeNode oldNode in this.m_documentWorkspace.oldDrawTreeView.Nodes[k].Nodes[j].Nodes) { if (!arr.Contains(oldNode.Name)) { drawb = true; } } if (drawb) ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), drawb); } } else { ((MeasureDrawObject)(this.m_documentWorkspace.GraphicsList[i])).pointChangeObject.Add((DrawToolType)Enum.Parse(typeof(DrawToolType), drawTreeView.Nodes[k].Nodes[j].Name), true); } } this.Refresh(); } } } } /// /// 删除测量 /// /// /// private void btnDelete_Click(object sender, EventArgs e) { NewGraphicsListClear(); this.GetDataAndAvg(); } private void SpecialMeasureLengthDialog_FormClosing(object sender, FormClosingEventArgs e) { m_measureStyleModel.measureLine.lineColor = m_straightLineColor; m_measureStyleModel.measureLine.lineWidth = m_straightLineWidth; m_measureStyleModel.measureLine.lineStyle = m_straightLineStyle; m_measureStyleModel.measureLength.lineColor = m_lengthLineColor; m_measureStyleModel.measureLength.lineWidth = m_lengthLineWidth; m_measureStyleModel.measureLength.lineStyle = m_lengthLineStyle; m_measureStyleModel.measureParallelLine.lineColor = m_parallelLineColor; m_measureStyleModel.measureParallelLine.lineWidth = m_parallelLineWidth; m_measureStyleModel.measureParallelLine.lineStyle = m_parallelLineStyle; Startup.instance.measureStyleModel = m_measureStyleModel; saveLastData(); m_sqlHelper.DisConnect(); } private void numericUpDown1_ValueChanged(object sender, EventArgs e) { this.decnum = (int)numericUpDown1.Value; this.UpdateMeasureDecimalPlaces((int)numericUpDown1.Value); this.RefreshDgvResult(); this.GetDataAndAvg(); } /// /// 更新小数位数 /// /// public void UpdateMeasureDecimalPlaces(int praDecimalPlaces) { MeasureDrawObject.decimalPlaces = praDecimalPlaces; this.m_documentWorkspace.Refresh(); } /// /// 全部显示 /// /// /// private void btnAllShow_Click(object sender, EventArgs e) { m_showAll = true; this.RefreshDgvResult(); } /// /// 删除测量结果 /// /// /// private void btnResultDel_Click(object sender, EventArgs e) { if (this.lstResult.SelectedItems != null && this.lstResult.SelectedItems.Count > 0) { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Determineallmeasurementsimage.Text")+"?", PdnResources.GetString("Menu.alert.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { foreach (ListViewItem item in this.lstResult.Items) { if (item.Selected) { this.lstResult.Items.Remove(item); this.m_measureResults.RemoveAll(u => u.Tag == item.Name.ToString()); if (bitDic.ContainsKey(item.Name.ToString())) { bitDic[item.Name.ToString()].Clear(); } } } RefreshDgvResult(); } } } private void RefreshDgvResult() { dgvResult.Rows.Clear(); if (m_showAll) { for (int i = 0; i < m_measureResults.Count; i++) { MeasureLengthResult aResult = m_measureResults[i]; dgvResult.Rows.Add(aResult.Tag, aResult.GraphName, aResult.LevelName, AnalysisTools.GetDecNum(aResult.MeasureAvg, decnum)); } } else { if (this.lstResult.SelectedItems != null && this.lstResult.SelectedItems.Count > 0) { for (int i = 0; i < this.lstResult.SelectedItems.Count; i++) { string tag = this.lstResult.SelectedItems[i].Name.ToString(); List findResults = m_measureResults.FindAll(item => item.Tag.Equals(tag)); for (int j = 0; j < findResults.Count; j++) { MeasureLengthResult aResult = findResults[j]; dgvResult.Rows.Add(aResult.Tag, aResult.GraphName, aResult.LevelName, AnalysisTools.GetDecNum(aResult.MeasureAvg, decnum)); } } } } } /// /// 保存测量结果 /// /// /// private void btnSave_Click(object sender, EventArgs e) { if (!m_isMeasure) { MessageBox.Show(PdnResources.GetString("Menu.tyetmeasured.Text")); return; } if (lstPic.SelectedItems.Count == 0) { MessageBox.Show(PdnResources.GetString("Menu.selectthepictureyoanttomeasure.Text")); return; } // 重新计算一下 this.GetDataAndAvg(); if (lstPic.FocusedItem != null && this.lstPic.SelectedItems.Count > 0) { string imgName = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GetFriendlyName(); string tag = this.imageList1.Images.Keys[this.lstPic.SelectedItems[0].Index]; if (m_measureResults.FindAll(item => item.Tag.Equals(tag)).Count == 0) { ListViewItem listViewItem = new ListViewItem(); listViewItem.Name = tag; listViewItem.SubItems[0].Text = imgName; this.lstResult.Items.Add(listViewItem); this.lstResult.SelectedItems.Clear(); this.lstResult.Items[this.lstResult.Items.Count - 1].Selected = true; MeasureLengthResult aResult = m_measureCurrent; aResult.Tag = tag; dgvResult.Rows.Add(tag, aResult.GraphName, aResult.LevelName, AnalysisTools.GetDecNum(aResult.MeasureAvg, decnum)); m_measureResults.Add(aResult); } else { DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.Cancel) { return; } m_measureCurrent.Tag = tag; m_measureResults.RemoveAll(u => u.Tag == tag); m_measureResults.Add(m_measureCurrent); dgvResult.Rows.Clear(); for (int i = 0; i < m_measureResults.Count; i++) { MeasureLengthResult aResult = m_measureResults[i]; dgvResult.Rows.Add(aResult.Tag, aResult.GraphName, aResult.LevelName, AnalysisTools.GetDecNum(aResult.MeasureAvg, decnum)); } } //保存处理后的图片 double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数 List tempBit = new List(); //Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap(); m_originalBit.Tag = pantographRatio; tempBit.Add(m_originalBit); Bitmap newBit = m_originalBit.Clone(new Rectangle(0, 0, m_originalBit.Width, m_originalBit.Height), m_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); } //拼接中间数据 List> dataList = new List>(); List columnName = new List(); columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text")); columnName.Add(PdnResources.GetString("Menu.hectuallength.Text")); dataList.Add(columnName); int count = this.m_documentWorkspace.GraphicsList.Count; int no = 0; for (int i = 0; i < count; i++) { if (this.m_documentWorkspace.GraphicsList[i].objectType == DrawClass.Measure) { Dictionary data = ((MeasureDrawObject)this.m_documentWorkspace.GraphicsList[i]).GetData(); foreach (var keys in data) { object v; InvariantData.measureAttributes.TryGetValue((MeasureAttributes)keys.Key, out v); if (((MeasureAttributes)keys.Key).ToString() == "PhysicalLength") { double length = double.Parse(keys.Value.ToString()); if (length > 0) { no++; List strList = new List(); strList.Add(no.ToString()); strList.Add(length.ToString()); dataList.Add(strList); } } } } } bool isExist = false;//是否已存在进行替换 int modelIndex = -1;//要替换的下标 for (int j = 0; j < tempDataModel.Count; j++) { if (tempDataModel[j].tagName.Equals(tag)) { isExist = true; modelIndex = j; break; } } if (isExist && modelIndex > -1) tempDataModel[modelIndex].dataList = dataList; else { ExportProjectModel newModel = new ExportProjectModel(); newModel.tagName = tag; newModel.picName = imgName; newModel.dataList = dataList; tempDataModel.Add(newModel); } //if (m_measureCurrent.LevelName.Equals("")) //{ // MessageBox.Show(PdnResources.GetString("Menu.tnocorrespondinglevel.Text")); //} //else //{ // MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")); //} } } private void Draw(Graphics graphics) { if (this.m_documentWorkspace.GraphicsList.Count > 0) { this.m_documentWorkspace.GraphicsList.Draw(graphics); } if (this.m_documentWorkspace.phaseModels.Count > 0) { foreach (PhaseModel model in this.m_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 NewGraphicsListClear() { if (this.m_documentWorkspace != null && this.m_documentWorkspace.GraphicsList.Count > 0) { this.m_documentWorkspace.GraphicsList.Clear(); this.m_documentWorkspace.Refresh(); //List drawList = this.m_documentWorkspace.GraphicsList.GetDrawClassList(DrawClass.Measure); //List lstInfo = drawList.FindAll(delegate (DrawObject lst) { return !m_oldDrawList.Contains(lst); }); //lstInfo.ForEach(i => this.m_documentWorkspace.GraphicsList.RemoveObj(i)); } } private void lstResult_SelectedIndexChanged(object sender, EventArgs e) { this.m_showAll = false; this.RefreshDgvResult(); } /// /// 生成报告 /// /// /// private void btnCreate_Click(object sender, EventArgs e) { if(this.dgvResult.Rows.Count <= 0) { MessageBox.Show(PdnResources.GetString("Menu.nodata.text")); return; } if (chkOpenSetting.Checked) { OpenSettingDialog(); } bitList.Clear(); 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.dgvResult.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dgvResult.Columns[1].HeaderText); content1.Add(this.dgvResult.Columns[2].HeaderText); content1.Add(this.dgvResult.Columns[3].HeaderText); analysisContent.Add(content1); } content1 = new List(); content1.Add(this.dgvResult.Rows[i].Cells[1].Value.ToString()); content1.Add(this.dgvResult.Rows[i].Cells[2].Value.ToString()); content1.Add(this.dgvResult.Rows[i].Cells[3].Value.ToString()); analysisContent.Add(content1); //图片 string tag = this.dgvResult.Rows[i].Cells[0].Value.ToString(); if (bitDic.ContainsKey(tag)) { bitList.Add(bitDic[tag][0]); bitList.Add(bitDic[tag][1]); } } appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos); } else { MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text")+"!"); } } /// /// 导出结果 /// /// /// private void btnExport_Click(object sender, EventArgs e) { if (this.dgvResult.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.Speciasurveyresultsoflengthsurvey.Text") + DateTime.Now.ToString("yyyyMMddhhmmss"); DialogResult dr = exe.ShowDialog(); if (dr == DialogResult.OK) { DataTable dtb = new DataTable(); for(int i = 1; i< this.dgvResult.Columns.Count; i++) { dtb.Columns.Add(this.dgvResult.Columns[i].HeaderText); } for (int r = 0; r < this.dgvResult.Rows.Count; r++) { DataRow dataRow = dtb.NewRow(); for (int c = 1; c < this.dgvResult.Rows[r].Cells.Count; c++) { dataRow[this.dgvResult.Columns[c].HeaderText] = this.dgvResult.Rows[r].Cells[c].Value; } dtb.Rows.Add(dataRow); } List list = new List(); list.Add(dtb); this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true); } } else { MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text")+"!"); } } private void nudStraightLineWidth_ValueChanged(object sender, EventArgs e) { m_measureStyleModel.measureLine.lineWidth = (int)nudStraightLineWidth.Value; m_documentWorkspace.Refresh(); } private void cmbStraightLine_SelectedIndexChanged(object sender, EventArgs e) { m_measureStyleModel.measureLine.lineStyle = cmbStraightLine.SelectedIndex; m_documentWorkspace.Refresh(); } private void pnlStraightLineColor_BackColorChanged(object sender, EventArgs e) { m_measureStyleModel.measureLine.lineColor = pnlStraightLineColor.BackColor.ToArgb(); m_documentWorkspace.Refresh(); } private void nudLengthLineWidth_ValueChanged(object sender, EventArgs e) { m_measureStyleModel.measureLength.lineWidth = (int)nudLengthLineWidth.Value; m_documentWorkspace.Refresh(); } private void cmbLengthLine_SelectedIndexChanged(object sender, EventArgs e) { m_measureStyleModel.measureLength.lineStyle = cmbLengthLine.SelectedIndex; m_documentWorkspace.Refresh(); } private void pnlLengthLineColor_BackColorChanged(object sender, EventArgs e) { m_measureStyleModel.measureLength.lineColor = pnlLengthLineColor.BackColor.ToArgb(); m_documentWorkspace.Refresh(); } private void nudParallelLineWidth_ValueChanged(object sender, EventArgs e) { m_measureStyleModel.measureParallelLine.lineWidth = (int)nudParallelLineWidth.Value; m_documentWorkspace.Refresh(); } private void pnlParallelLineColor_BackColorChanged(object sender, EventArgs e) { m_measureStyleModel.measureParallelLine.lineColor = pnlParallelLineColor.BackColor.ToArgb(); m_documentWorkspace.Refresh(); } private void cmbParallelLine_SelectedIndexChanged(object sender, EventArgs e) { m_measureStyleModel.measureParallelLine.lineStyle = cmbParallelLine.SelectedIndex; m_documentWorkspace.Refresh(); } /// /// 导出项目 /// /// /// private void btnExportProject_Click(object sender, EventArgs e) { try { if (this.analyzeSettingModel == null) { MessageBox.Show(PdnResources.GetString("Menu.Settheexporteitemfirst.Text")); return; } //获取项目工程内的文件夹路径 ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.SpecialMeasure.Text", this.analyzeSettingModel.savePath); bitList.Clear(); 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 dataModel = new List(); List> analysisContent = new List>(); for (int i = 0; i < this.dgvResult.Rows.Count; i++) { List content1 = new List(); if (i == 0) { content1.Add(this.dgvResult.Columns[1].HeaderText); content1.Add(this.dgvResult.Columns[2].HeaderText); content1.Add(this.dgvResult.Columns[3].HeaderText); analysisContent.Add(content1); } content1 = new List(); content1.Add(this.dgvResult.Rows[i].Cells[1].Value.ToString()); content1.Add(this.dgvResult.Rows[i].Cells[2].Value.ToString()); content1.Add(this.dgvResult.Rows[i].Cells[3].Value.ToString()); analysisContent.Add(content1); //图片 string tag = this.dgvResult.Rows[i].Cells[0].Value.ToString(); if (bitDic.ContainsKey(tag)) { bitList.Add(bitDic[tag][0]); bitList.Add(bitDic[tag][1]); } // 中间数据 foreach(ExportProjectModel data in tempDataModel) { if (data.tagName.Equals(tag)) { dataModel.Add(data); } } } this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, dataModel, bitList, tagInfos, item.path, item.code); } else { MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text")+"!"); return; } //保存项目信息到数据库 this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item); } } catch (Exception) { } } /// /// 获取上次操作参数 /// private void 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.SpecialMeasureLengthModels == null) { generalAnalysisModel.SpecialMeasureLengthModels = new GeneralAnalysisModel.SpecialMeasureLengthModel(); } if (generalAnalysisModel.SpecialMeasureLengthModels.hasUsed) { if (cmbSpecial.Items.Count >= (generalAnalysisModel.SpecialMeasureLengthModels.parameter1 - 1)) { cmbSpecial.SelectedIndex = generalAnalysisModel.SpecialMeasureLengthModels.parameter1; } else { cmbSpecial.SelectedIndex = 0; } pnlStraightLineColor.BackColor = Color.FromArgb(generalAnalysisModel.SpecialMeasureLengthModels.parameter2); nudStraightLineWidth.Value = generalAnalysisModel.SpecialMeasureLengthModels.parameter3; cmbStraightLine.SelectedIndex = generalAnalysisModel.SpecialMeasureLengthModels.parameter4; pnlLengthLineColor.BackColor = Color.FromArgb(generalAnalysisModel.SpecialMeasureLengthModels.parameter5); nudLengthLineWidth.Value = generalAnalysisModel.SpecialMeasureLengthModels.parameter6; cmbLengthLine.SelectedIndex = generalAnalysisModel.SpecialMeasureLengthModels.parameter7; pnlParallelLineColor.BackColor = Color.FromArgb(generalAnalysisModel.SpecialMeasureLengthModels.parameter8); nudParallelLineWidth.Value = generalAnalysisModel.SpecialMeasureLengthModels.parameter9; cmbParallelLine.SelectedIndex = generalAnalysisModel.SpecialMeasureLengthModels.parameter10; chkOpenSetting.Checked = generalAnalysisModel.SpecialMeasureLengthModels.parameter11; numericUpDown1.Value = generalAnalysisModel.SpecialMeasureLengthModels.parameter12; } } } /// /// 保存上次操作参数 /// private void saveLastData() { if (generalAnalysisModel.SpecialMeasureLengthModels == null) { generalAnalysisModel.SpecialMeasureLengthModels = new GeneralAnalysisModel.SpecialMeasureLengthModel(); } generalAnalysisModel.SpecialMeasureLengthModels.hasUsed = true; generalAnalysisModel.SpecialMeasureLengthModels.parameter1 = cmbSpecial.SelectedIndex; generalAnalysisModel.SpecialMeasureLengthModels.parameter2 = pnlStraightLineColor.BackColor.ToArgb(); generalAnalysisModel.SpecialMeasureLengthModels.parameter3 = (int)nudStraightLineWidth.Value; generalAnalysisModel.SpecialMeasureLengthModels.parameter4 = cmbStraightLine.SelectedIndex; generalAnalysisModel.SpecialMeasureLengthModels.parameter5 = pnlLengthLineColor.BackColor.ToArgb(); generalAnalysisModel.SpecialMeasureLengthModels.parameter6 = (int)nudLengthLineWidth.Value; generalAnalysisModel.SpecialMeasureLengthModels.parameter7 = cmbLengthLine.SelectedIndex; generalAnalysisModel.SpecialMeasureLengthModels.parameter8 = pnlParallelLineColor.BackColor.ToArgb(); generalAnalysisModel.SpecialMeasureLengthModels.parameter9 = (int)nudParallelLineWidth.Value; generalAnalysisModel.SpecialMeasureLengthModels.parameter10 = cmbParallelLine.SelectedIndex; generalAnalysisModel.SpecialMeasureLengthModels.parameter11 = chkOpenSetting.Checked; generalAnalysisModel.SpecialMeasureLengthModels.parameter12 = (int)numericUpDown1.Value; string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml"; string porosityInfoXml = XmlSerializeHelper.XmlSerialize(generalAnalysisModel); FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create); } } }