using OpenCvSharp;
using OpenCvSharp.Extensions;
using PaintDotNet.Base.Functionodel;
using PaintDotNet.CustomControl;
using PaintDotNet.Data.Param;
using PaintDotNet.DbOpreate.DbModel;
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.Base.CommTool;
using PaintDotNet.DbOpreate.DbBll;
using PaintDotNet.GeneralAnalysis.Special;
using System.IO;
using PaintDotNet.Instrument;
using Metis.ParameterSet;
namespace PaintDotNet.GeneralAnalysis
{
///
/// 专项测量-面积含量
///
internal class SpecialMeasureAreaDialog : 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.groupBox4.Text = PdnResources.GetString("Menu.Preview.text");
this.groupBox3.Text = PdnResources.GetString("Menu.Resultspreview.text");
this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.view.text");
this.Column2.HeaderText = PdnResources.GetString("Menu.Phasearea.text");
this.Column3.HeaderText = PdnResources.GetString("Menu.proportion.text");
this.Column4.HeaderText = PdnResources.GetString("Menu.Phasecontent.text");
this.groupBox5.Text = PdnResources.GetString("Menu.Generalanalysis.Specialmeasurement.Averageandlevel.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.label4.Text = PdnResources.GetString("Menu.Correspondinglevel.text") + ":";
this.label3.Text = PdnResources.GetString("Menu.Phasecontent.text") + ":";
this.label2.Text = PdnResources.GetString("Menu.proportion.text") + ":";
this.label1.Text = PdnResources.GetString("Menu.Phasearea.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.label5.Text = PdnResources.GetString("Menu.Decimal.text");
this.btnExport.Text = PdnResources.GetString("Menu.Exportresults.text");
this.pic.HeaderText = PdnResources.GetString("Menu.picture.Text");
this.view.HeaderText = PdnResources.GetString("Menu.view.text");
this.area.HeaderText = PdnResources.GetString("Menu.Phasearea.text");
this.scale.HeaderText = PdnResources.GetString("Menu.proportion.text");
this.has.HeaderText = PdnResources.GetString("Menu.Phasecontent.text");
this.Column1.HeaderText = PdnResources.GetString("Menu.Correspondinglevel.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.Specialmecontent.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.groupBox4 = new System.Windows.Forms.GroupBox();
this.pnlTools = new System.Windows.Forms.Panel();
this.pnlShow = new System.Windows.Forms.Panel();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.lblLevel = new System.Windows.Forms.Label();
this.lblContent = new System.Windows.Forms.Label();
this.lblRate = new System.Windows.Forms.Label();
this.lblArea = 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.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.btnExportProject = new System.Windows.Forms.Button();
this.lstResult = new System.Windows.Forms.ListView();
this.btnResultDel = new System.Windows.Forms.Button();
this.btnAllShow = new System.Windows.Forms.Button();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.btnExport = new System.Windows.Forms.Button();
this.dgvResult = new System.Windows.Forms.DataGridView();
this.pic = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.view = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.area = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.scale = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.has = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.btnCreate = new System.Windows.Forms.Button();
this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvLevelList)).BeginInit();
this.groupBox8.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dgvResult)).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(1241, 73);
this.groupBox1.TabIndex = 1;
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(1122, 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(1018, 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(389, 31);
this.chkOpenSetting.Name = "chkOpenSetting";
this.chkOpenSetting.Size = new System.Drawing.Size(132, 16);
this.chkOpenSetting.TabIndex = 2;
this.chkOpenSetting.Text = "生成报告时打开设置";
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(115, 35);
this.btnMeasure.TabIndex = 1;
this.btnMeasure.Text = "开始测量";
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, 91);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(201, 513);
this.groupBox2.TabIndex = 2;
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, 467);
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;
//
// 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.pnlShow);
this.groupBox4.Location = new System.Drawing.Point(594, 91);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(659, 513);
this.groupBox4.TabIndex = 4;
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;
//
// 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(647, 447);
this.pnlShow.TabIndex = 0;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.dataGridView1);
this.groupBox3.Location = new System.Drawing.Point(219, 91);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(369, 251);
this.groupBox3.TabIndex = 5;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "结果预览";
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.dataGridViewTextBoxColumn1,
this.Column2,
this.Column3,
this.Column4});
this.dataGridView1.Location = new System.Drawing.Point(6, 24);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowHeadersWidth = 51;
this.dataGridView1.RowTemplate.Height = 27;
this.dataGridView1.Size = new System.Drawing.Size(359, 221);
this.dataGridView1.TabIndex = 1;
//
// groupBox5
//
this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox5.Controls.Add(this.lblLevel);
this.groupBox5.Controls.Add(this.lblContent);
this.groupBox5.Controls.Add(this.lblRate);
this.groupBox5.Controls.Add(this.lblArea);
this.groupBox5.Controls.Add(this.dgvLevelList);
this.groupBox5.Controls.Add(this.label4);
this.groupBox5.Controls.Add(this.label3);
this.groupBox5.Controls.Add(this.label2);
this.groupBox5.Controls.Add(this.label1);
this.groupBox5.Location = new System.Drawing.Point(219, 348);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(369, 256);
this.groupBox5.TabIndex = 6;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "平均值及级别";
//
// lblLevel
//
this.lblLevel.AutoSize = true;
this.lblLevel.Location = new System.Drawing.Point(275, 58);
this.lblLevel.Name = "lblLevel";
this.lblLevel.Size = new System.Drawing.Size(11, 12);
this.lblLevel.TabIndex = 8;
this.lblLevel.Text = "0";
//
// lblContent
//
this.lblContent.AutoEllipsis = true;
this.lblContent.Location = new System.Drawing.Point(114, 58);
this.lblContent.Name = "lblContent";
this.lblContent.Size = new System.Drawing.Size(53, 12);
this.lblContent.TabIndex = 7;
this.lblContent.Text = "0";
//
// lblRate
//
this.lblRate.AutoSize = true;
this.lblRate.Location = new System.Drawing.Point(275, 30);
this.lblRate.Name = "lblRate";
this.lblRate.Size = new System.Drawing.Size(11, 12);
this.lblRate.TabIndex = 6;
this.lblRate.Text = "0";
//
// lblArea
//
this.lblArea.AutoEllipsis = true;
this.lblArea.Location = new System.Drawing.Point(114, 30);
this.lblArea.Name = "lblArea";
this.lblArea.Size = new System.Drawing.Size(83, 12);
this.lblArea.TabIndex = 5;
this.lblArea.Text = "0";
//
// 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, 87);
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(357, 163);
this.dgvLevelList.TabIndex = 4;
//
// 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;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(173, 58);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(65, 12);
this.label4.TabIndex = 3;
this.label4.Text = "对应级别:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(26, 58);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 2;
this.label3.Text = "相含量:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(203, 30);
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(26, 30);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 0;
this.label1.Text = "相面积:";
//
// groupBox8
//
this.groupBox8.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox8.Controls.Add(this.btnExportProject);
this.groupBox8.Controls.Add(this.lstResult);
this.groupBox8.Controls.Add(this.btnResultDel);
this.groupBox8.Controls.Add(this.btnAllShow);
this.groupBox8.Controls.Add(this.numericUpDown1);
this.groupBox8.Controls.Add(this.label5);
this.groupBox8.Controls.Add(this.btnExport);
this.groupBox8.Controls.Add(this.dgvResult);
this.groupBox8.Controls.Add(this.btnCreate);
this.groupBox8.Location = new System.Drawing.Point(13, 610);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Size = new System.Drawing.Size(1240, 202);
this.groupBox8.TabIndex = 8;
this.groupBox8.TabStop = false;
this.groupBox8.Text = "分析结果";
//
// 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(1114, 100);
this.btnExportProject.Name = "btnExportProject";
this.btnExportProject.Size = new System.Drawing.Size(115, 32);
this.btnExportProject.TabIndex = 9;
this.btnExportProject.Text = "导出项目";
this.btnExportProject.UseVisualStyleBackColor = true;
this.btnExportProject.Click += new System.EventHandler(this.btnExportProject_Click);
//
// lstResult
//
this.lstResult.HideSelection = false;
this.lstResult.Location = new System.Drawing.Point(17, 57);
this.lstResult.Name = "lstResult";
this.lstResult.Size = new System.Drawing.Size(164, 131);
this.lstResult.TabIndex = 8;
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(120, 19);
this.btnResultDel.Name = "btnResultDel";
this.btnResultDel.Size = new System.Drawing.Size(61, 32);
this.btnResultDel.TabIndex = 7;
this.btnResultDel.Text = "删除";
this.btnResultDel.UseVisualStyleBackColor = true;
this.btnResultDel.Click += new System.EventHandler(this.btnResultDel_Click);
//
// btnAllShow
//
this.btnAllShow.Location = new System.Drawing.Point(17, 19);
this.btnAllShow.Name = "btnAllShow";
this.btnAllShow.Size = new System.Drawing.Size(97, 32);
this.btnAllShow.TabIndex = 0;
this.btnAllShow.Text = "全部显示";
this.btnAllShow.UseVisualStyleBackColor = true;
this.btnAllShow.Click += new System.EventHandler(this.btnAllShow_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(1160, 153);
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 = 6;
this.numericUpDown1.Value = new decimal(new int[] {
2,
0,
0,
0});
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// label5
//
this.label5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(1117, 158);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(41, 12);
this.label5.TabIndex = 5;
this.label5.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(1114, 62);
this.btnExport.Name = "btnExport";
this.btnExport.Size = new System.Drawing.Size(116, 32);
this.btnExport.TabIndex = 1;
this.btnExport.Text = "导出结果";
this.btnExport.UseVisualStyleBackColor = true;
this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
//
// 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.pic,
this.view,
this.area,
this.scale,
this.has,
this.Column1,
this.Column5});
this.dgvResult.Location = new System.Drawing.Point(212, 24);
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(871, 164);
this.dgvResult.TabIndex = 0;
//
// pic
//
this.pic.MinimumWidth = 6;
this.pic.Name = "pic";
this.pic.ReadOnly = true;
//
// view
//
this.view.MinimumWidth = 6;
this.view.Name = "view";
this.view.ReadOnly = true;
//
// area
//
this.area.MinimumWidth = 6;
this.area.Name = "area";
this.area.ReadOnly = true;
//
// scale
//
this.scale.MinimumWidth = 6;
this.scale.Name = "scale";
this.scale.ReadOnly = true;
//
// has
//
this.has.MinimumWidth = 6;
this.has.Name = "has";
this.has.ReadOnly = true;
//
// Column1
//
this.Column1.MinimumWidth = 6;
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
//
// Column5
//
this.Column5.HeaderText = "tag";
this.Column5.MinimumWidth = 6;
this.Column5.Name = "Column5";
this.Column5.ReadOnly = true;
this.Column5.Visible = false;
//
// 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(1114, 24);
this.btnCreate.Name = "btnCreate";
this.btnCreate.Size = new System.Drawing.Size(115, 32);
this.btnCreate.TabIndex = 0;
this.btnCreate.Text = "生成报告";
this.btnCreate.UseVisualStyleBackColor = true;
this.btnCreate.Click += new System.EventHandler(this.btnCreate_Click);
//
// Column4
//
this.Column4.MinimumWidth = 6;
this.Column4.Name = "Column4";
//
// Column3
//
this.Column3.MinimumWidth = 6;
this.Column3.Name = "Column3";
//
// Column2
//
this.Column2.MinimumWidth = 6;
this.Column2.Name = "Column2";
//
// dataGridViewTextBoxColumn1
//
this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
//
// SpecialMeasureAreaDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1265, 824);
this.Controls.Add(this.groupBox8);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "SpecialMeasureAreaDialog";
this.Text = "专项测量 - 面积含量";
this.Controls.SetChildIndex(this.groupBox1, 0);
this.Controls.SetChildIndex(this.groupBox2, 0);
this.Controls.SetChildIndex(this.groupBox4, 0);
this.Controls.SetChildIndex(this.groupBox3, 0);
this.Controls.SetChildIndex(this.groupBox5, 0);
this.Controls.SetChildIndex(this.groupBox8, 0);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvLevelList)).EndInit();
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dgvResult)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Button btnSetting;
private System.Windows.Forms.CheckBox chkOpenSetting;
private System.Windows.Forms.Button btnMeasure;
private System.Windows.Forms.ComboBox cmbSpecial;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ListView lstPic;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.Panel pnlTools;
private System.Windows.Forms.Panel pnlShow;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
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.GroupBox groupBox8;
private System.Windows.Forms.Button btnExport;
private System.Windows.Forms.Button btnCreate;
private System.Windows.Forms.DataGridView dgvResult;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.Label lblArea;
private System.Windows.Forms.Label lblRate;
private System.Windows.Forms.Label lblLevel;
private System.Windows.Forms.Label lblContent;
private System.Windows.Forms.Button btnResultDel;
private System.Windows.Forms.Button btnAllShow;
private System.Windows.Forms.DataGridViewTextBoxColumn pic;
private System.Windows.Forms.DataGridViewTextBoxColumn view;
private System.Windows.Forms.DataGridViewTextBoxColumn area;
private System.Windows.Forms.DataGridViewTextBoxColumn scale;
private System.Windows.Forms.DataGridViewTextBoxColumn has;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
private System.Windows.Forms.ListView lstResult;
private System.Windows.Forms.Button btnExportProject;
#endregion
private AppWorkspace appWorkspace;
private DocumentWorkspaceWindow m_documentWorkspace;
private SQLiteHelper m_sqlHelper;
private DataTable m_specialList;
private DataTable m_levelList;
private SpecialItem m_specialItem = SpecialItem.AREA;
private int m_specialSelectedIndex = 0;
private string m_specialId;
///
/// 原图
///
private Mat imageMat;
///
/// 原图带原相测量等
///
private Bitmap m_originalBit;
private ArtworkControlButtons m_controlButtons;
private List polyphaseAnalysisResults = new List();
private List mainPolyphaseAnalysisResults = new List();
private bool m_isMeasure;
private string m_level;
private bool m_showAll;
// 小数位
int decnum = 2;
private List bitList = new List();
///
/// 储存点击保存结果后的所有原图与分析图
///
private Dictionary> bitDic = new Dictionary>();
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private DataGridViewTextBoxColumn Column2;
private DataGridViewTextBoxColumn Column3;
private DataGridViewTextBoxColumn Column4;
private ToolTip toolTip1;
private int defaultIndex = -1;
///
/// 中间数据
///
private List tempDataModel = new List();
private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
public SpecialMeasureAreaDialog(AppWorkspace workspace)
{
appWorkspace = workspace;
m_sqlHelper = new SQLiteHelper(); //连接数据库
m_sqlHelper.Connect();
InitializeComponent();
InitializeLanguageText();
InitLblText();
InitPicList();
InitSpecialCmb();
InitDocumentView();
SetAnalyzeModelFromXml("Template.Manager.item2.SpecialArea");
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
}
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 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;
}
///
/// 初始化专项数据
///
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 InitLblText()
{
lblArea.Text = "0";
lblRate.Text = "0";
lblContent.Text = "0";
lblLevel.Text = "";
}
///
/// 初始化DocumentView
///
public void InitDocumentView()
{
this.m_documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
this.m_documentWorkspace.AppWorkspaceTop = appWorkspace;
this.m_documentWorkspace.Visible = true;
this.m_documentWorkspace.Dock = DockStyle.Fill;
this.pnlShow.Controls.Add(this.m_documentWorkspace);
this.m_documentWorkspace.ContinuousDrawingMeasure = true;
InitDocumentViewTools();
}
#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
private void lstPic_SelectedIndexChanged(object sender, EventArgs e)
{
this.Measure();
}
private void Measure()
{
if (this.lstPic.FocusedItem != null && this.lstPic.FocusedItem.Selected)
{
InitLblText();
this.imageMat = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
Document document = Document.FromImageMat(imageMat.Clone());
this.m_documentWorkspace.Document = document;
this.m_documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GraphicsList;
this.m_documentWorkspace.phaseModels = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].phaseModels;
// 选择了图片
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);
this.applyButtonImpl();
}
}
///
/// 参数改变时,重新处理图像
///
private void applyButtonImpl()
{
if (this.lstPic.FocusedItem != null)
{
//拼接中间数据
List> dataList = new List>();
List columnName = new List();
columnName.Add(PdnResources.GetString("Menu.Imagement.Measurementlist.ordernumber.text"));
columnName.Add(PdnResources.GetString("Menu.viewname.text"));
columnName.Add(PdnResources.GetString("Menu.area.text"));
dataList.Add(columnName);
string imgName = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GetFriendlyName();
string tag = this.imageList1.Images.Keys[this.lstPic.SelectedItems[0].Index];
dataGridView1.Rows.Clear();
mainPolyphaseAnalysisResults.Clear();
int selectIndex = this.lstPic.FocusedItem.Index;
double unitLength;
//this.appWorkspace.getMeasureInfo().TryGetValue(MeasurementUnit.Micron, out unitLength);
unitLength = this.appWorkspace.DocumentWorkspaces[selectIndex].GetRuler(MeasurementUnit.Micron);
//判断是否存在视场,如果存在视场,则把视场提取出来,进行处理
if (this.appWorkspace.DocumentWorkspaces[selectIndex].GraphicsList.IsExsitView())
{
for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels.Count; i++)
{
PhaseModel pModel = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i];
if (pModel.choise)
{
Color pColor = new Color();
pColor = Color.FromArgb(pModel.color);
Mat front = pModel.mat;
//相总面积
double phaseAmount = AnalysisTools.GetPointsFromMat(front);
//视图中相面积
Bitmap frontTarget = this.m_documentWorkspace.GetFullSizeWithRegion(front.ToBitmap());
//frontTarget.Save("D:\\1-1.bmp");
//获取视图中相的点合计
//int frontAmount = AnalysisTools.GetPointsFromMat(PaintDotNet.Camera.Tools.ToMat(frontTarget));
Mat background = this.imageMat.Clone();
Mat roi = new Mat(background, new Rect(0, 0, background.Width, background.Height));
Mat mask = Mat.FromImageData(front.ToBytes(), ImreadModes.Grayscale);
front.CopyTo(roi, mask);
Bitmap target = this.m_documentWorkspace.GetFullSizeWithRegion(background.ToBitmap());
Mat targetMat = PaintDotNet.Camera.Tools.ToMat(target);
//获取合并后视场内的点合计
int allAmount = AnalysisTools.GetPointsFromMat(targetMat);
int picAmount = AnalysisTools.GetPointsFromMat(background);
double cRate = 0f;
cRate = (double)phaseAmount / allAmount;
//计算面积
double cArea = phaseAmount;
//计算相含量
double fRate = (double)phaseAmount / picAmount;
//dataGridView1.Rows.Add(this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name, cArea, cRate, fRate);
PolyphaseAnalysisResult pResult = new PolyphaseAnalysisResult();
pResult.GraphName = this.lstPic.FocusedItem.Text;
pResult.PolyphaseName = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name;
pResult.PolyphaseArea = cArea * unitLength * unitLength;
pResult.PolyphaseRate = cRate * 100;
pResult.PolyphaseAllRate = fRate * 100;
mainPolyphaseAnalysisResults.Add(pResult);
dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
// 中间数据
List strList = new List();
strList.Add(i.ToString());
strList.Add(pResult.PolyphaseName);
strList.Add(pResult.PolyphaseArea.ToString());
dataList.Add(strList);
}
}
}
else
{
for (int i = 0; i < this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels.Count; i++)
{
PhaseModel pModel = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i];
if (pModel.choise)
{
Color pColor = new Color();
pColor = Color.FromArgb(pModel.color);
double phaseArea = AnalysisTools.GetPointsFromMat(pModel.mat);
Mat sourceMat = this.imageMat.Clone();
int picAmount = AnalysisTools.GetPointsFromMat(sourceMat);
//计算面积
double cRate = (double)phaseArea / picAmount;
PolyphaseAnalysisResult pResult = new PolyphaseAnalysisResult();
pResult.GraphName = this.lstPic.FocusedItem.Text;
pResult.PolyphaseName = this.appWorkspace.DocumentWorkspaces[selectIndex].phaseModels[i].name;
pResult.PolyphaseArea = phaseArea * unitLength * unitLength;
pResult.PolyphaseRate = cRate * 100;
pResult.PolyphaseAllRate = cRate * 100;
mainPolyphaseAnalysisResults.Add(pResult);
dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
// 中间数据
List strList = new List();
strList.Add(i.ToString());
strList.Add(pResult.PolyphaseName);
strList.Add(pResult.PolyphaseArea.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);
}
show_avg();
}
}
private void show_avg()
{
if (lstPic.FocusedItem != null)
{
var results = mainPolyphaseAnalysisResults.Where(p => p.GraphName.Equals(lstPic.FocusedItem.Text));
if (results.Count() > 0)
{
lblArea.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseArea), decnum);
lblRate.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseRate), decnum);
lblContent.Text = AnalysisTools.GetDecNum(results.Average(item => item.PolyphaseAllRate), decnum);
if (m_levelList != null && m_levelList.Rows.Count > 0)
{
m_level = "";
for (int i = 0; i < m_levelList.Rows.Count; ++i)
{
decimal avg = decimal.Parse(lblContent.Text);
decimal minValue = decimal.Parse(m_levelList.Rows[i]["minValue"].ToString());
decimal maxValue = decimal.Parse(m_levelList.Rows[i]["maxValue"].ToString());
if (avg >= minValue && avg < maxValue)
{
m_level = m_levelList.Rows[i]["name"].ToString();
break;
}
}
lblLevel.Text = m_level;
if (m_level.Equals(""))
{
//MessageBox.Show("没有对应的级别信息");
}
}
}
}
}
private void cmbSpecial_SelectedIndexChanged(object sender, EventArgs e)
{
this.InitSpecialLevelList();
this.Measure();
}
///
/// 初始化专项级别列表
///
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 numericUpDown1_ValueChanged(object sender, EventArgs e)
{
decnum = (int)numericUpDown1.Value;
RefreshDataGridView1();
RefreshDgvResult();
show_avg();
}
private void RefreshDataGridView1()
{
dataGridView1.Rows.Clear();
for (int i = 0; i < mainPolyphaseAnalysisResults.Count; i++)
{
PolyphaseAnalysisResult pResult = mainPolyphaseAnalysisResults[i];
dataGridView1.Rows.Add(pResult.PolyphaseName, AnalysisTools.GetDecNum(pResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(pResult.PolyphaseAllRate, decnum));
}
}
private void btnAllShow_Click(object sender, EventArgs e)
{
m_showAll = true;
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.polyphaseAnalysisResults.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 < polyphaseAnalysisResults.Count; i++)
{
MeasureAreaResult aResult = polyphaseAnalysisResults[i];
dgvResult.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum), aResult.Level, aResult.Tag);
}
}
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 = polyphaseAnalysisResults.FindAll(item => item.Tag.Equals(tag));
for (int j = 0; j < findResults.Count; j++)
{
MeasureAreaResult aResult = findResults[j];
dgvResult.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum), aResult.Level, aResult.Tag);
}
}
}
}
}
private void lstResult_SelectedIndexChanged(object sender, EventArgs e)
{
m_showAll = false;
RefreshDgvResult();
}
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;
}
if (this.lstPic.FocusedItem != null && this.lstPic.SelectedItems.Count > 0)
{
string tag = this.imageList1.Images.Keys[this.lstPic.SelectedItems[0].Index];
string imgName = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].GetFriendlyName();
if (mainPolyphaseAnalysisResults.Count <= 0)
{
MessageBox.Show(PdnResources.GetString("Menu.hereisnofieldo.Text"));
return;
}
if (polyphaseAnalysisResults.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;
//保存处理后的图片
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();
originalBit.Tag = pantographRatio;
tempBit.Add(originalBit);
for (int i = 0; i < mainPolyphaseAnalysisResults.Count; i++)
{
PolyphaseAnalysisResult aResult = mainPolyphaseAnalysisResults[i];
dgvResult.Rows.Add(aResult.GraphName, aResult.PolyphaseName, AnalysisTools.GetDecNum(aResult.PolyphaseArea, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseRate, decnum), AnalysisTools.GetDecNum(aResult.PolyphaseAllRate, decnum), m_level, tag);
MeasureAreaResult areaResult = new MeasureAreaResult();
areaResult.GraphName = aResult.GraphName;
areaResult.PolyphaseName = aResult.PolyphaseName;
areaResult.PolyphaseArea = aResult.PolyphaseArea;
areaResult.PolyphaseRate = aResult.PolyphaseRate;
areaResult.PolyphaseAllRate = aResult.PolyphaseAllRate;
areaResult.Level = m_level;
areaResult.Tag = tag;
polyphaseAnalysisResults.Add(areaResult);
PhaseModel pModel = this.appWorkspace.DocumentWorkspaces[this.lstPic.FocusedItem.Index].phaseModels[i];
Bitmap processedBit = BitmapConverter.ToBitmap(pModel.mat);
Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
Graphics graphics = Graphics.FromImage(newBit);
graphics.DrawImage(processedBit, new PointF(0, 0));
//Bitmap newBit = BitmapConverter.ToBitmap(pModel.mat);
newBit.Tag = pantographRatio;
tempBit.Add(newBit);
}
//Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
//Graphics graphics = Graphics.FromImage(newBit);
//Draw(graphics);
//tempBit.Add(newBit);
if (bitDic.ContainsKey(tag))
{
bitDic[tag].Clear();
bitDic[tag] = tempBit;
}
else
{
bitDic.Add(tag, tempBit);
}
}
else
{
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theanalysisreertoreplaceit.text") + "?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
}
//if (m_level == null || m_level.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 btnMeasure_Click(object sender, EventArgs e)
{
if(cmbSpecial.SelectedItem == null || m_levelList == null || m_levelList.Rows.Count <= 0)
{
MessageBox.Show(PdnResources.GetString("Menu.efirstse.Text"));
return;
}
m_isMeasure = !m_isMeasure;
UpdateMeasureUIAndState();
}
private void UpdateMeasureUIAndState()
{
if (m_isMeasure)
{
if(polyphaseAnalysisResults.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.polyphaseAnalysisResults.Clear();
this.bitDic.Clear();
this.dgvResult.Rows.Clear();
}
else
{
m_isMeasure = false;
return;
}
}
}
m_specialSelectedIndex = this.cmbSpecial.SelectedIndex;
btnMeasure.Text = PdnResources.GetString("Menu.Stopmeasure.text");
cmbSpecial.Enabled = false;
}
else
{
btnMeasure.Text = PdnResources.GetString("Menu.Startmeasuring.text");
cmbSpecial.Enabled = true;
}
}
private void chkOpenSetting_CheckedChanged(object sender, EventArgs e)
{
}
private void OpenSettingDialog()
{
AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.SpecialArea");
if (recombinationRateSetDialog.hasModule)
{
recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
recombinationRateSetDialog.ShowDialog();
}
else
{
recombinationRateSetDialog = null;
}
}
private void btnSetting_Click(object sender, EventArgs e)
{
OpenSettingDialog();
}
///
/// 生成报告
///
///
///
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();
}
this.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[0].HeaderText);
content1.Add(this.dgvResult.Columns[1].HeaderText);
content1.Add(this.dgvResult.Columns[2].HeaderText);
content1.Add(this.dgvResult.Columns[3].HeaderText);
content1.Add(this.dgvResult.Columns[4].HeaderText);
content1.Add(this.dgvResult.Columns[5].HeaderText);
analysisContent.Add(content1);
}
content1 = new List();
content1.Add(this.dgvResult.Rows[i].Cells[0].Value.ToString());
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());
content1.Add(this.dgvResult.Rows[i].Cells[4].Value.ToString());
content1.Add(this.dgvResult.Rows[i].Cells[5].Value.ToString());
analysisContent.Add(content1);
//图片
string tag = this.dgvResult.Rows[i].Cells[6].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
{
MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.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.cialsurveyresultsofareacontentsurv.Text") + DateTime.Now.ToString("yyyyMMddhhmmss");
DialogResult dr = exe.ShowDialog();
if (dr == DialogResult.OK)
{
DataTable dtb = new DataTable();
for (int i = 0; i < this.dgvResult.Columns.Count-1; 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 = 0; c < this.dgvResult.Rows[r].Cells.Count - 1; 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 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);
if (item == null)
{
return;
}
bitList.Clear();
//向文件夹内保存图片和报告
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[0].HeaderText);
content1.Add(this.dgvResult.Columns[1].HeaderText);
content1.Add(this.dgvResult.Columns[2].HeaderText);
content1.Add(this.dgvResult.Columns[3].HeaderText);
content1.Add(this.dgvResult.Columns[4].HeaderText);
content1.Add(this.dgvResult.Columns[5].HeaderText);
analysisContent.Add(content1);
}
content1 = new List();
content1.Add(this.dgvResult.Rows[i].Cells[0].Value.ToString());
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());
content1.Add(this.dgvResult.Rows[i].Cells[4].Value.ToString());
content1.Add(this.dgvResult.Rows[i].Cells[5].Value.ToString());
analysisContent.Add(content1);
//图片
string tag = this.dgvResult.Rows[i].Cells[6].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.SpecialMeasureAreaModels == null)
{
generalAnalysisModel.SpecialMeasureAreaModels = new GeneralAnalysisModel.SpecialMeasureAreaModel();
}
if (generalAnalysisModel.SpecialMeasureAreaModels.hasUsed)
{
if (cmbSpecial.Items.Count >= (generalAnalysisModel.SpecialMeasureAreaModels.parameter1 - 1))
{
cmbSpecial.SelectedIndex = generalAnalysisModel.SpecialMeasureAreaModels.parameter1;
}
else
{
cmbSpecial.SelectedIndex = 0;
}
chkOpenSetting.Checked = generalAnalysisModel.SpecialMeasureAreaModels.parameter2;
numericUpDown1.Value = generalAnalysisModel.SpecialMeasureAreaModels.parameter3;
}
}
}
///
/// 保存上次操作参数
///
private void saveLastData(object sender, EventArgs e)
{
if (generalAnalysisModel.SpecialMeasureAreaModels == null)
{
generalAnalysisModel.SpecialMeasureAreaModels = new GeneralAnalysisModel.SpecialMeasureAreaModel();
}
generalAnalysisModel.SpecialMeasureAreaModels.hasUsed = true;
generalAnalysisModel.SpecialMeasureAreaModels.parameter1 = cmbSpecial.SelectedIndex;
generalAnalysisModel.SpecialMeasureAreaModels.parameter2 = chkOpenSetting.Checked;
generalAnalysisModel.SpecialMeasureAreaModels.parameter3 = (int)numericUpDown1.Value;
string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
string porosityInfoXml = XmlSerializeHelper.XmlSerialize(generalAnalysisModel);
FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
}
}
}