using OpenCvSharp;
using PaintDotNet.Annotation;
using PaintDotNet.Annotation.Enum;
using PaintDotNet.Annotation.Label;
using PaintDotNet.Annotation.PhysicalPhaseAction;
using PaintDotNet.Base;
using PaintDotNet.Base.Functionodel;
using PaintDotNet.Base.CommTool;
using PaintDotNet.Data.Param;
using PaintDotNet.GeneralAnalysis.AnalysisResultTemplate;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using static PaintDotNet.Base.SettingModel.LabelStyleModel;
using PaintDotNet.CustomControl;
using System.IO;
using PaintDotNet.DbOpreate.DbBll;
using PaintDotNet.DbOpreate.DbModel;
using PaintDotNet.Instrument;
using Metis.ParameterSet;
namespace PaintDotNet.GeneralAnalysis
{
///
/// 物相间距
///
internal class PolyphaseDistanceDialog : PdnBaseForm
{
#region 控件
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.GroupBox groupBox_review;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.GroupBox groupBox7;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.ImageList imageList1;
private DataGridView dataGridView_results;
private Button button_remove;
private Button button_all;
private Button button5;
private GroupBox groupBox8;
private GroupBox groupBox9;
private GroupBox groupBox10;
private GroupBox groupBox11;
private CheckBox checkBox3;
private Label label3;
private CustomControl.TriangleTrackBar triangleTrackBar1;
private Label label5;
private NumericUpDown numericUpDown1;
private Label label6;
private Panel panel2;
private RadioButton rb_2;
private RadioButton rb_1;
private Panel panel3;
private Label label7;
private RadioButton rb_4;
private RadioButton rb_3;
private Label label8;
private Label label9;
private NumericUpDown numericUpDown2;
private NumericUpDown numericUpDown3;
private Label lbl_line;
private System.Data.SQLite.SQLiteCommand sqLiteCommand1;
private CustomControl.TriangleTrackBar triangleTrackBar2;
private Label label13;
private CheckBox checkBox4;
private CheckBox checkBox5;
private CheckBox checkBox6;
private NumericUpDown numericUpDown5;
private NumericUpDown numericUpDown4;
private Label label11;
private Label label10;
private Panel panel4;
private RadioButton radioButton1;
private RadioButton radioButton2;
private Label lbl_kl_max;
private Label lbl_kl_min;
private int imgIndex = -1;
//二值化集成1
BinaryClass binaryClass;
private int menuId;
private string menuName;
private BinaryControl bc;
private Button button9;
private CheckedListBox listBox_analysisResult;
private DataGridViewTextBoxColumn Column5;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
private Label label2;
private GroupBox groupBox3;
private IContainer components;
private bool isCheck = false;
private Mat original;
#endregion
#region InitializeComponent
private void InitializeLanguageText()
{
//this.checkBox4.Text = PdnResources.GetString("Menu.displaygrainboundaries.text");
this.Text = PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text");
this.label8.Text = PdnResources.GetString("Menu.shape.text");
this.label7.Text = PdnResources.GetString("Menu.style.text");
this.rb_4.Text = PdnResources.GetString("Menu.Hollow.text");
this.rb_3.Text = PdnResources.GetString("Menu.solid.text");
this.rb_2.Text = PdnResources.GetString("Menu.Square.text");
this.rb_1.Text = PdnResources.GetString("Menu.circular.Text");
this.groupBox11.Text = PdnResources.GetString("Menu.Displayparamssettings.text");
this.checkBox6.Text = PdnResources.GetString("Menu.displaysections.text");
this.checkBox5.Text = PdnResources.GetString("Menu.displaygrid.text");
this.button4.Text = PdnResources.GetString("Menu.Exportresults.text");
this.button3.Text = PdnResources.GetString("Menu.Tools.CreateReport.Text");
this.groupBox8.Text = PdnResources.GetString("Menu.Measuringlinesetting.text");
this.label6.Text = PdnResources.GetString("Menu.color.text");
this.label5.Text = PdnResources.GetString("Menu.Linewidth.text");
this.groupBox9.Text = PdnResources.GetString("Menu.operation.text");
this.radioButton2.Text = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.Thenumberofsections.text");
this.radioButton1.Text = PdnResources.GetString("Menu.Measuringline.text");
this.groupBox10.Text = PdnResources.GetString("Menu.Interceptformatting.text");
this.label11.Text = PdnResources.GetString("Menu.error.text");
this.label10.Text = PdnResources.GetString("Menu.color.text");
this.lbl_line.Text = PdnResources.GetString("Menu.Linewidth.text");
this.label9.Text = PdnResources.GetString("Menu.size.text");
this.button_remove.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
this.button_all.Text = PdnResources.GetString("Menu.Showall.text");
this.Column5.HeaderText = PdnResources.GetString("Menu.picture.Text");
this.dataGridViewTextBoxColumn1.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.Averagespacing.text");
this.dataGridViewTextBoxColumn2.HeaderText = PdnResources.GetString("Menu.Generalanalysis.Phasespacing.variance.text");
this.dataGridViewTextBoxColumn3.HeaderText = PdnResources.GetString("Menu.Numberofintercept.text");
this.button9.Text = PdnResources.GetString("Menu.Tools.OpenProject.Text");
this.label1.Text = PdnResources.GetString("Menu.Decimal.text");
this.groupBox1.Text = PdnResources.GetString("Menu.operation.text");
this.button5.Text = PdnResources.GetString("Menu.File.Close.Text");
this.button2.Text = PdnResources.GetString("Menu.Saveresult.text");
this.checkBox1.Text = PdnResources.GetString("Menu.Opensettingsatingreport.text");
this.button1.Text = PdnResources.GetString("Menu.Setting.Text");
this.groupBox2.Text = PdnResources.GetString("Menu.Particlescreening.text");
this.label13.Text = PdnResources.GetString("Menu.max.text");
this.label3.Text = PdnResources.GetString("Menu.minimum.text");
this.checkBox3.Text = PdnResources.GetString("Menu.filter.text");
this.groupBox_review.Text = PdnResources.GetString("Menu.Preview.text");
this.groupBox5.Text = PdnResources.GetString("Menu.Analysisresult.text");
this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
this.label2.Text = PdnResources.GetString("Menu.Decimal.text");
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.listView1 = new System.Windows.Forms.ListView();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.button5 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lbl_kl_max = new System.Windows.Forms.Label();
this.lbl_kl_min = new System.Windows.Forms.Label();
this.triangleTrackBar2 = new PaintDotNet.CustomControl.TriangleTrackBar();
this.label13 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.triangleTrackBar1 = new PaintDotNet.CustomControl.TriangleTrackBar();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.groupBox_review = new System.Windows.Forms.GroupBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.listBox_analysisResult = new System.Windows.Forms.CheckedListBox();
this.button_remove = new System.Windows.Forms.Button();
this.button_all = new System.Windows.Forms.Button();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.dataGridView_results = new System.Windows.Forms.DataGridView();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBox7 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.button9 = new System.Windows.Forms.Button();
this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
this.label1 = new System.Windows.Forms.Label();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.label5 = new System.Windows.Forms.Label();
this.groupBox9 = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
this.label11 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.panel4 = new System.Windows.Forms.Panel();
this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
this.lbl_line = new System.Windows.Forms.Label();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.label7 = new System.Windows.Forms.Label();
this.rb_4 = new System.Windows.Forms.RadioButton();
this.rb_3 = new System.Windows.Forms.RadioButton();
this.rb_2 = new System.Windows.Forms.RadioButton();
this.rb_1 = new System.Windows.Forms.RadioButton();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.checkBox6 = new System.Windows.Forms.CheckBox();
this.checkBox5 = new System.Windows.Forms.CheckBox();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.sqLiteCommand1 = new System.Data.SQLite.SQLiteCommand();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.groupBox4.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox6.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).BeginInit();
this.groupBox7.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
this.groupBox8.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.groupBox9.SuspendLayout();
this.groupBox10.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
this.panel3.SuspendLayout();
this.groupBox11.SuspendLayout();
this.groupBox3.SuspendLayout();
this.SuspendLayout();
//
// groupBox4
//
this.groupBox4.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox4.Controls.Add(this.listView1);
this.groupBox4.Location = new System.Drawing.Point(13, 72);
this.groupBox4.Margin = new System.Windows.Forms.Padding(4);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Padding = new System.Windows.Forms.Padding(4);
this.groupBox4.Size = new System.Drawing.Size(158, 674);
this.groupBox4.TabIndex = 9;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "图像索引";
//
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listView1.HideSelection = false;
this.listView1.LargeImageList = this.imageList1;
this.listView1.Location = new System.Drawing.Point(8, 26);
this.listView1.Margin = new System.Windows.Forms.Padding(4);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(140, 640);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListViewSelectedIndexChanged);
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.button5);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.checkBox1);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Location = new System.Drawing.Point(20, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(1160, 53);
this.groupBox1.TabIndex = 10;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "操作";
//
// button5
//
this.button5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button5.Location = new System.Drawing.Point(971, 20);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(75, 23);
this.button5.TabIndex = 3;
this.button5.Text = "关闭";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.button2.Location = new System.Drawing.Point(1070, 20);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 2;
this.button2.Text = "保存结果";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// checkBox1
//
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(98, 24);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(132, 16);
this.checkBox1.TabIndex = 1;
this.checkBox1.Text = "生成报告时打开设置";
this.checkBox1.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(6, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "设置";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.lbl_kl_max);
this.groupBox2.Controls.Add(this.lbl_kl_min);
this.groupBox2.Controls.Add(this.triangleTrackBar2);
this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Controls.Add(this.label3);
this.groupBox2.Controls.Add(this.triangleTrackBar1);
this.groupBox2.Controls.Add(this.checkBox3);
this.groupBox2.Location = new System.Drawing.Point(6, 20);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(360, 76);
this.groupBox2.TabIndex = 11;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "颗粒筛选";
//
// lbl_kl_max
//
this.lbl_kl_max.AutoSize = true;
this.lbl_kl_max.Location = new System.Drawing.Point(302, 50);
this.lbl_kl_max.Name = "lbl_kl_max";
this.lbl_kl_max.Size = new System.Drawing.Size(11, 12);
this.lbl_kl_max.TabIndex = 8;
this.lbl_kl_max.Text = "0";
//
// lbl_kl_min
//
this.lbl_kl_min.AutoSize = true;
this.lbl_kl_min.Location = new System.Drawing.Point(302, 21);
this.lbl_kl_min.Name = "lbl_kl_min";
this.lbl_kl_min.Size = new System.Drawing.Size(11, 12);
this.lbl_kl_min.TabIndex = 7;
this.lbl_kl_min.Text = "0";
//
// triangleTrackBar2
//
this.triangleTrackBar2.Location = new System.Drawing.Point(116, 44);
this.triangleTrackBar2.Maximum = 10;
this.triangleTrackBar2.Minimum = 0;
this.triangleTrackBar2.Name = "triangleTrackBar2";
this.triangleTrackBar2.Size = new System.Drawing.Size(177, 26);
this.triangleTrackBar2.TabIndex = 6;
this.triangleTrackBar2.Value = 0;
this.triangleTrackBar2.TrackBarScroll += new System.EventHandler(this.triangleTrackBar2_TrackBarScroll);
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(77, 50);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(29, 12);
this.label13.TabIndex = 5;
this.label13.Text = "最大";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(77, 21);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(29, 12);
this.label3.TabIndex = 2;
this.label3.Text = "最小";
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// triangleTrackBar1
//
this.triangleTrackBar1.Location = new System.Drawing.Point(116, 14);
this.triangleTrackBar1.Maximum = 10;
this.triangleTrackBar1.Minimum = 0;
this.triangleTrackBar1.Name = "triangleTrackBar1";
this.triangleTrackBar1.Size = new System.Drawing.Size(177, 26);
this.triangleTrackBar1.TabIndex = 1;
this.triangleTrackBar1.Value = 0;
this.triangleTrackBar1.TrackBarScroll += new System.EventHandler(this.triangleTrackBar1_TrackBarScroll);
//
// checkBox3
//
this.checkBox3.AutoSize = true;
this.checkBox3.Location = new System.Drawing.Point(18, 21);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(48, 16);
this.checkBox3.TabIndex = 0;
this.checkBox3.Text = "筛选";
this.checkBox3.UseVisualStyleBackColor = true;
this.checkBox3.Click += new System.EventHandler(this.checkBox3_BeforeCheckedChanged);
//
// groupBox_review
//
this.groupBox_review.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox_review.Location = new System.Drawing.Point(556, 72);
this.groupBox_review.Name = "groupBox_review";
this.groupBox_review.Size = new System.Drawing.Size(624, 674);
this.groupBox_review.TabIndex = 12;
this.groupBox_review.TabStop = false;
this.groupBox_review.Text = "预览";
//
// groupBox5
//
this.groupBox5.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.groupBox5.Controls.Add(this.listBox_analysisResult);
this.groupBox5.Controls.Add(this.button_remove);
this.groupBox5.Controls.Add(this.button_all);
this.groupBox5.Location = new System.Drawing.Point(13, 753);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(224, 156);
this.groupBox5.TabIndex = 13;
this.groupBox5.TabStop = false;
//
// listBox_analysisResult
//
this.listBox_analysisResult.CheckOnClick = true;
this.listBox_analysisResult.FormattingEnabled = true;
this.listBox_analysisResult.HorizontalScrollbar = true;
this.listBox_analysisResult.Location = new System.Drawing.Point(11, 53);
this.listBox_analysisResult.Name = "listBox_analysisResult";
this.listBox_analysisResult.Size = new System.Drawing.Size(202, 100);
this.listBox_analysisResult.TabIndex = 10;
this.listBox_analysisResult.SelectedIndexChanged += new System.EventHandler(this.listBox_analysisResult_SelectedIndexChanged);
//
// button_remove
//
this.button_remove.Location = new System.Drawing.Point(130, 24);
this.button_remove.Name = "button_remove";
this.button_remove.Size = new System.Drawing.Size(75, 23);
this.button_remove.TabIndex = 8;
this.button_remove.Text = "删除";
this.button_remove.UseVisualStyleBackColor = true;
this.button_remove.Click += new System.EventHandler(this.button_remove_Click);
//
// button_all
//
this.button_all.Location = new System.Drawing.Point(14, 24);
this.button_all.Name = "button_all";
this.button_all.Size = new System.Drawing.Size(75, 23);
this.button_all.TabIndex = 1;
this.button_all.Text = "全部显示";
this.button_all.UseVisualStyleBackColor = true;
this.button_all.Click += new System.EventHandler(this.button_all_Click);
//
// groupBox6
//
this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox6.Controls.Add(this.dataGridView_results);
this.groupBox6.Location = new System.Drawing.Point(243, 753);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(721, 156);
this.groupBox6.TabIndex = 14;
this.groupBox6.TabStop = false;
//
// dataGridView_results
//
this.dataGridView_results.AllowUserToAddRows = false;
this.dataGridView_results.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView_results.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.dataGridView_results.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView_results.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column5,
this.dataGridViewTextBoxColumn1,
this.dataGridViewTextBoxColumn2,
this.dataGridViewTextBoxColumn3});
this.dataGridView_results.Location = new System.Drawing.Point(6, 13);
this.dataGridView_results.Name = "dataGridView_results";
this.dataGridView_results.RowHeadersVisible = false;
this.dataGridView_results.RowHeadersWidth = 51;
this.dataGridView_results.RowTemplate.Height = 27;
this.dataGridView_results.Size = new System.Drawing.Size(709, 139);
this.dataGridView_results.TabIndex = 1;
//
// Column5
//
this.Column5.HeaderText = "Column5";
this.Column5.MinimumWidth = 6;
this.Column5.Name = "Column5";
this.Column5.Width = 150;
//
// dataGridViewTextBoxColumn1
//
this.dataGridViewTextBoxColumn1.HeaderText = "dataGridViewTextBoxColumn1";
this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
this.dataGridViewTextBoxColumn1.Width = 160;
//
// dataGridViewTextBoxColumn2
//
this.dataGridViewTextBoxColumn2.HeaderText = "dataGridViewTextBoxColumn2";
this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
this.dataGridViewTextBoxColumn2.Width = 200;
//
// dataGridViewTextBoxColumn3
//
this.dataGridViewTextBoxColumn3.HeaderText = "dataGridViewTextBoxColumn3";
this.dataGridViewTextBoxColumn3.MinimumWidth = 6;
this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
this.dataGridViewTextBoxColumn3.Width = 200;
//
// groupBox7
//
this.groupBox7.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.groupBox7.Controls.Add(this.label2);
this.groupBox7.Controls.Add(this.button9);
this.groupBox7.Controls.Add(this.numericUpDown5);
this.groupBox7.Controls.Add(this.label1);
this.groupBox7.Controls.Add(this.button4);
this.groupBox7.Controls.Add(this.button3);
this.groupBox7.Location = new System.Drawing.Point(970, 753);
this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(210, 156);
this.groupBox7.TabIndex = 15;
this.groupBox7.TabStop = false;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(57, 126);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 12);
this.label2.TabIndex = 8;
this.label2.Text = "小数";
//
// button9
//
this.button9.Location = new System.Drawing.Point(59, 88);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(107, 23);
this.button9.TabIndex = 7;
this.button9.Text = "项目工程";
this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// numericUpDown5
//
this.numericUpDown5.Location = new System.Drawing.Point(92, 124);
this.numericUpDown5.Maximum = new decimal(new int[] {
10,
0,
0,
0});
this.numericUpDown5.Name = "numericUpDown5";
this.numericUpDown5.Size = new System.Drawing.Size(74, 21);
this.numericUpDown5.TabIndex = 5;
this.numericUpDown5.Value = new decimal(new int[] {
2,
0,
0,
0});
this.numericUpDown5.ValueChanged += new System.EventHandler(this.numericUpDown5_ValueChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(57, 126);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(0, 12);
this.label1.TabIndex = 3;
//
// button4
//
this.button4.Location = new System.Drawing.Point(59, 54);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(107, 23);
this.button4.TabIndex = 1;
this.button4.Text = "导出结果";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(59, 20);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(107, 23);
this.button3.TabIndex = 0;
this.button3.Text = "生成报告";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// groupBox8
//
this.groupBox8.Controls.Add(this.numericUpDown1);
this.groupBox8.Controls.Add(this.label6);
this.groupBox8.Controls.Add(this.panel2);
this.groupBox8.Controls.Add(this.label5);
this.groupBox8.Location = new System.Drawing.Point(6, 102);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Size = new System.Drawing.Size(360, 57);
this.groupBox8.TabIndex = 18;
this.groupBox8.TabStop = false;
this.groupBox8.Text = "测量线设置";
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(64, 18);
this.numericUpDown1.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(74, 21);
this.numericUpDown1.TabIndex = 4;
this.numericUpDown1.Value = new decimal(new int[] {
2,
0,
0,
0});
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(179, 20);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(29, 12);
this.label6.TabIndex = 3;
this.label6.Text = "颜色";
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.Blue;
this.panel2.Location = new System.Drawing.Point(214, 20);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(96, 19);
this.panel2.TabIndex = 2;
this.panel2.Click += new System.EventHandler(this.panel2_Click);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(10, 20);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(29, 12);
this.label5.TabIndex = 0;
this.label5.Text = "线宽";
//
// groupBox9
//
this.groupBox9.Controls.Add(this.radioButton2);
this.groupBox9.Controls.Add(this.radioButton1);
this.groupBox9.Location = new System.Drawing.Point(6, 165);
this.groupBox9.Name = "groupBox9";
this.groupBox9.Size = new System.Drawing.Size(360, 50);
this.groupBox9.TabIndex = 19;
this.groupBox9.TabStop = false;
this.groupBox9.Text = "操作";
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(181, 20);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(47, 16);
this.radioButton2.TabIndex = 4;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "截点";
this.radioButton2.UseVisualStyleBackColor = true;
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(65, 20);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(59, 16);
this.radioButton1.TabIndex = 3;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "测量线";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
//
// groupBox10
//
this.groupBox10.Controls.Add(this.numericUpDown4);
this.groupBox10.Controls.Add(this.label11);
this.groupBox10.Controls.Add(this.label10);
this.groupBox10.Controls.Add(this.panel4);
this.groupBox10.Controls.Add(this.numericUpDown3);
this.groupBox10.Controls.Add(this.lbl_line);
this.groupBox10.Controls.Add(this.numericUpDown2);
this.groupBox10.Controls.Add(this.label9);
this.groupBox10.Controls.Add(this.label8);
this.groupBox10.Controls.Add(this.panel3);
this.groupBox10.Controls.Add(this.rb_2);
this.groupBox10.Controls.Add(this.rb_1);
this.groupBox10.Location = new System.Drawing.Point(6, 221);
this.groupBox10.Name = "groupBox10";
this.groupBox10.Size = new System.Drawing.Size(360, 102);
this.groupBox10.TabIndex = 20;
this.groupBox10.TabStop = false;
this.groupBox10.Text = "截点格式设置";
//
// numericUpDown4
//
this.numericUpDown4.Location = new System.Drawing.Point(212, 72);
this.numericUpDown4.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.numericUpDown4.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown4.Name = "numericUpDown4";
this.numericUpDown4.Size = new System.Drawing.Size(74, 21);
this.numericUpDown4.TabIndex = 24;
this.numericUpDown4.Value = new decimal(new int[] {
30,
0,
0,
0});
this.numericUpDown4.ValueChanged += new System.EventHandler(this.numericUpDown4_ValueChanged);
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(179, 75);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(29, 12);
this.label11.TabIndex = 23;
this.label11.Text = "误差";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(179, 51);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(29, 12);
this.label10.TabIndex = 22;
this.label10.Text = "颜色";
//
// panel4
//
this.panel4.BackColor = System.Drawing.Color.Yellow;
this.panel4.Location = new System.Drawing.Point(212, 48);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(100, 19);
this.panel4.TabIndex = 21;
this.panel4.Click += new System.EventHandler(this.panel4_Click);
//
// numericUpDown3
//
this.numericUpDown3.Location = new System.Drawing.Point(65, 72);
this.numericUpDown3.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown3.Name = "numericUpDown3";
this.numericUpDown3.Size = new System.Drawing.Size(74, 21);
this.numericUpDown3.TabIndex = 14;
this.numericUpDown3.Value = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown3.ValueChanged += new System.EventHandler(this.numericUpDown3_ValueChanged);
//
// lbl_line
//
this.lbl_line.AutoSize = true;
this.lbl_line.Location = new System.Drawing.Point(16, 75);
this.lbl_line.Name = "lbl_line";
this.lbl_line.Size = new System.Drawing.Size(29, 12);
this.lbl_line.TabIndex = 13;
this.lbl_line.Text = "线宽";
//
// numericUpDown2
//
this.numericUpDown2.Location = new System.Drawing.Point(64, 46);
this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(74, 21);
this.numericUpDown2.TabIndex = 10;
this.numericUpDown2.Value = new decimal(new int[] {
20,
0,
0,
0});
this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(16, 51);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(29, 12);
this.label9.TabIndex = 9;
this.label9.Text = "大小";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(16, 24);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(29, 12);
this.label8.TabIndex = 8;
this.label8.Text = "形状";
//
// panel3
//
this.panel3.Controls.Add(this.label7);
this.panel3.Controls.Add(this.rb_4);
this.panel3.Controls.Add(this.rb_3);
this.panel3.Location = new System.Drawing.Point(178, 11);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(176, 34);
this.panel3.TabIndex = 5;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(12, 11);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(29, 12);
this.label7.TabIndex = 7;
this.label7.Text = "样式";
//
// rb_4
//
this.rb_4.AutoSize = true;
this.rb_4.Checked = true;
this.rb_4.Location = new System.Drawing.Point(100, 9);
this.rb_4.Name = "rb_4";
this.rb_4.Size = new System.Drawing.Size(47, 16);
this.rb_4.TabIndex = 6;
this.rb_4.TabStop = true;
this.rb_4.Text = "空心";
this.rb_4.UseVisualStyleBackColor = true;
this.rb_4.CheckedChanged += new System.EventHandler(this.rb_4_CheckedChanged);
//
// rb_3
//
this.rb_3.AutoSize = true;
this.rb_3.Location = new System.Drawing.Point(47, 9);
this.rb_3.Name = "rb_3";
this.rb_3.Size = new System.Drawing.Size(47, 16);
this.rb_3.TabIndex = 5;
this.rb_3.Text = "实心";
this.rb_3.UseVisualStyleBackColor = true;
this.rb_3.CheckedChanged += new System.EventHandler(this.rb_3_CheckedChanged);
//
// rb_2
//
this.rb_2.AutoSize = true;
this.rb_2.Location = new System.Drawing.Point(116, 20);
this.rb_2.Name = "rb_2";
this.rb_2.Size = new System.Drawing.Size(47, 16);
this.rb_2.TabIndex = 1;
this.rb_2.Text = "方形";
this.rb_2.UseVisualStyleBackColor = true;
this.rb_2.CheckedChanged += new System.EventHandler(this.rb_2_CheckedChanged);
//
// rb_1
//
this.rb_1.AutoSize = true;
this.rb_1.Checked = true;
this.rb_1.Location = new System.Drawing.Point(65, 20);
this.rb_1.Name = "rb_1";
this.rb_1.Size = new System.Drawing.Size(47, 16);
this.rb_1.TabIndex = 0;
this.rb_1.TabStop = true;
this.rb_1.Text = "圆形";
this.rb_1.UseVisualStyleBackColor = true;
this.rb_1.CheckedChanged += new System.EventHandler(this.rb_1_CheckedChanged);
//
// groupBox11
//
this.groupBox11.Controls.Add(this.checkBox6);
this.groupBox11.Controls.Add(this.checkBox5);
this.groupBox11.Controls.Add(this.checkBox4);
this.groupBox11.Location = new System.Drawing.Point(6, 329);
this.groupBox11.Name = "groupBox11";
this.groupBox11.Size = new System.Drawing.Size(360, 47);
this.groupBox11.TabIndex = 21;
this.groupBox11.TabStop = false;
//
// checkBox6
//
this.checkBox6.AutoSize = true;
this.checkBox6.Checked = true;
this.checkBox6.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox6.Location = new System.Drawing.Point(245, 20);
this.checkBox6.Name = "checkBox6";
this.checkBox6.Size = new System.Drawing.Size(72, 16);
this.checkBox6.TabIndex = 2;
this.checkBox6.Text = "显示截点";
this.checkBox6.UseVisualStyleBackColor = true;
this.checkBox6.CheckedChanged += new System.EventHandler(this.checkBox6_CheckedChanged);
//
// checkBox5
//
this.checkBox5.AutoSize = true;
this.checkBox5.Checked = true;
this.checkBox5.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox5.Location = new System.Drawing.Point(134, 20);
this.checkBox5.Name = "checkBox5";
this.checkBox5.Size = new System.Drawing.Size(72, 16);
this.checkBox5.TabIndex = 1;
this.checkBox5.Text = "显示网格";
this.checkBox5.UseVisualStyleBackColor = true;
this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
//
// checkBox4
//
this.checkBox4.AutoSize = true;
this.checkBox4.Checked = true;
this.checkBox4.CheckState = System.Windows.Forms.CheckState.Checked;
this.checkBox4.Location = new System.Drawing.Point(12, 20);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(96, 16);
this.checkBox4.TabIndex = 0;
this.checkBox4.Text = "显示二值数据";
this.checkBox4.UseVisualStyleBackColor = true;
this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
//
// sqLiteCommand1
//
this.sqLiteCommand1.CommandText = null;
//
// groupBox3
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBox3.Controls.Add(this.groupBox2);
this.groupBox3.Controls.Add(this.groupBox8);
this.groupBox3.Controls.Add(this.groupBox9);
this.groupBox3.Controls.Add(this.groupBox10);
this.groupBox3.Controls.Add(this.groupBox11);
this.groupBox3.Location = new System.Drawing.Point(178, 365);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(372, 381);
this.groupBox3.TabIndex = 22;
this.groupBox3.TabStop = false;
//
// PolyphaseDistanceDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1192, 921);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox7);
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox_review);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox4);
this.Name = "PolyphaseDistanceDialog";
this.Shown += new System.EventHandler(this.showImg);
this.Resize += new System.EventHandler(this.PolyphaseDistanceDialog_Resize);
this.Controls.SetChildIndex(this.groupBox4, 0);
this.Controls.SetChildIndex(this.groupBox1, 0);
this.Controls.SetChildIndex(this.groupBox_review, 0);
this.Controls.SetChildIndex(this.groupBox6, 0);
this.Controls.SetChildIndex(this.groupBox7, 0);
this.Controls.SetChildIndex(this.groupBox5, 0);
this.Controls.SetChildIndex(this.groupBox3, 0);
this.groupBox4.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView_results)).EndInit();
this.groupBox7.ResumeLayout(false);
this.groupBox7.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
this.groupBox8.ResumeLayout(false);
this.groupBox8.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.groupBox9.ResumeLayout(false);
this.groupBox9.PerformLayout();
this.groupBox10.ResumeLayout(false);
this.groupBox10.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.groupBox11.ResumeLayout(false);
this.groupBox11.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.ResumeLayout(false);
}
private void InitializeComponent2()
{
this.bc = new PaintDotNet.CustomControl.BinaryControl();
//
// bc
//
this.bc.BinaryBackColor = System.Drawing.Color.Red;
this.bc.BinaryChecked = false;
this.bc.BinaryStyle = 1;
this.bc.Location = new System.Drawing.Point(178, 72);
this.bc.Name = "bc";
this.bc.OriginChecked = false;
this.bc.scope1End = 0D;
this.bc.scope1Start = 0D;
this.bc.scope2End = 0D;
this.bc.scope2Start = 0D;
this.bc.scope3End = 0D;
this.bc.scope3Start = 0D;
this.bc.Size = new System.Drawing.Size(360, 292);
this.bc.TabIndex = 3;
//
this.Controls.Add(this.bc);
this.Controls.SetChildIndex(this.bc, 0);
}
#endregion
private CommonControlButtons commonControlButtons;
///
/// 主空间
///
private AppWorkspace appWorkspace;
///
/// 图像面板
///
private DocumentWorkspaceWindow documentWorkspace;
///
/// 选中图片的mat
///
private Mat imageMat;
///
/// 处理程序
///
private ParamObject action = new Data.Action.Action1010();
int decnum = 2;
DrawAnalysisModel lineStyleModel = new DrawAnalysisModel();
DrawAnalysisModel pointStyleModel = new DrawAnalysisModel();
private ColorsForm colorsFormGrid;
private ColorsForm lineColorsFormGrid;
private ColorsForm PointcolorsFormGrid;
List allResults = new List();
private Dictionary>> intermediateDataList = new Dictionary>>();
//0 画线 1 画截点
private int drawaction = 0;
List lineResults = new List();
List drawObjects = new List();
List rmObjects = new List();
private int offsetHalfW = 0;
private int offsetHalfH = 0;
private int m_tolerance = 30;
private int tolerance = 2;
//0 画线 1 删除
private int lineAction = 0;
private decimal maxArea = 0;
private System.Drawing.Point lineStartPos = new System.Drawing.Point();
private DrawMulLineA activeLine = null;
private PhaseModel activePhaseModel = null;
//private List bitList = new List();
private List bitList = new List();
private Dictionary> bitDic = new Dictionary>();
private int is_all = 0;
private GeneralAnalysisModel generalAnalysisModel = new GeneralAnalysisModel();
private int selectPicture = -1;
private Dictionary everyImgData = new Dictionary();
private string selectedImg = string.Empty;
///
/// 是否脚本运行
///
private Boolean initScriptValues = false;
public PolyphaseDistanceDialog()
{
InitializeComponent();
}
#region 公共按钮
private void InitCommonButtonEvent()
{
this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
}
private void zoomInButton_Click(object sender, EventArgs e)
{
if (this.imageMat != null)
this.documentWorkspace.ZoomIn();
}
private void zoomOutButton_Click(object sender, EventArgs e)
{
if (this.imageMat != null)
this.documentWorkspace.ZoomOut();
}
private void zoomToWindowButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
}
private void actualSizeButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
}
private void pointerButton_Click(object sender, EventArgs e)
{
documentWorkspace.panel.MouseMove += Panel_MouseMove;
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
}
private void mobileModeButton_Click(object sender, EventArgs e)
{
documentWorkspace.panel.MouseMove -= Panel_MouseMove;
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
}
#endregion
public PolyphaseDistanceDialog(AppWorkspace appWorkspace, PdnMenuItem menuItem)
{
this.menuId = menuItem.MenuId;
this.menuName = menuItem.Text;
binaryClass = new BinaryClass(menuId);
InitializeComponent();
InitializeComponent2();
InitializeLanguageText();
this.Load += new System.EventHandler(this.GrainSizeDialog_Load);
this.colorsFormGrid = new ColorsForm();
this.colorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
this.lineColorsFormGrid = new ColorsForm();
this.lineColorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
this.PointcolorsFormGrid = new ColorsForm();
this.PointcolorsFormGrid.StartPosition = FormStartPosition.CenterScreen;
this.appWorkspace = appWorkspace;
this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
this.documentWorkspace.Dock = DockStyle.Fill;
this.documentWorkspace.HookMouseEvents();
this.documentWorkspace.AuxiliaryLineEnabled = false;
this.documentWorkspace.Visible = false;
documentWorkspace.ActiveTool = DrawToolType.NullTool;
documentWorkspace.GraphicsList.UnselectAll();
this.groupBox_review.Controls.Add(documentWorkspace);
this.commonControlButtons = new CommonControlButtons();
this.commonControlButtons.Dock = DockStyle.Top;
this.commonControlButtons.Height = 30;
this.commonControlButtons.HideZoomToWindowAndActualSize();
this.groupBox_review.Controls.Add(commonControlButtons);
documentWorkspace.panel.MouseDown += Panel_MouseDown;
documentWorkspace.panel.MouseUp += Panel_MouseUp;
documentWorkspace.panel.Paint += Panel_Paint;
documentWorkspace.panel.MouseMove += Panel_MouseMove;
InitPicList();
SetAnalyzeModelFromXml("Template.Manager.item2.PolyphaseDistance");
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
UpdateStyle();
InitCommonButtonEvent();
//二值化集成2
bc.OriginCheckedChangedAction += new EventHandler(this.bcOriginCheckedChanged);//初始化原图勾选改变事件
binaryClass.createDocumentItems(new string[] { PdnResources.GetString("Menu.BinaryAction.BinaryExtraction.Text") }
, this.bc, this.appWorkspace, this.documentWorkspace, this.listView1);//初始化相的工作结构
binaryClass.BinaryImplFinishAction += new EventHandler(this.bClassBinaryImplFinishAction);//二值化后续处理事件
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.saveLastData);
}
///
/// 获取上次操作参数
///
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.PolyphaseDistanceModels == null)
{
generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
}
if (generalAnalysisModel.PolyphaseDistanceModels.hasUsed)
{
checkBox3.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter1;
if (generalAnalysisModel.PolyphaseDistanceModels.parameter2 <= triangleTrackBar1.Maximum)
{
triangleTrackBar1.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter2;
lbl_kl_min.Text = generalAnalysisModel.PolyphaseDistanceModels.parameter2.ToString();
}
if (generalAnalysisModel.PolyphaseDistanceModels.parameter3 <= triangleTrackBar2.Maximum)
{
triangleTrackBar2.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter3;
lbl_kl_max.Text = generalAnalysisModel.PolyphaseDistanceModels.parameter3.ToString();
}
if (checkBox3.Checked)
{
double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
triangleTrackBar1.Maximum = (int)maxArea;
triangleTrackBar2.Maximum = (int)maxArea;
triangleTrackBar2_TrackBarScroll(null, null);
}
numericUpDown1.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter4;
panel2.BackColor = Color.FromArgb(generalAnalysisModel.PolyphaseDistanceModels.parameter5);
radioButton1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter6 == 1 ? true : false;
radioButton2.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter6 == 1 ? false : true;
rb_1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter7 == 1 ? true : false;
rb_2.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter7 == 1 ? false : true;
rb_3.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter8 == 1 ? true : false;
rb_4.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter8 == 1 ? false : true;
numericUpDown2.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter9;
panel4.BackColor = Color.FromArgb(generalAnalysisModel.PolyphaseDistanceModels.parameter10);
numericUpDown3.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter11;
numericUpDown4.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter12;
checkBox4.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter13;
checkBox5.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter14;
checkBox6.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter15;
numericUpDown5.Value = generalAnalysisModel.PolyphaseDistanceModels.parameter16;
GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
checkBox1.Checked = generalAnalysisModel.PolyphaseDistanceModels.parameter17;
for (int i = 0; i < listView1.Items.Count; i++)
{
if (everyImgData.ContainsKey(listView1.Items[i].Name))
{
everyImgData[listView1.Items[i].Name] = generalAnalysisModel.PolyphaseDistanceModels;
}
else
{
everyImgData.Add(listView1.Items[i].Name, generalAnalysisModel.PolyphaseDistanceModels);
}
}
}
}
}
///
/// 保存上次操作参数
///
private void saveLastData(object sender, EventArgs e)
{
#region [开启脚本录制]
if (appWorkspace.startScriptRecording)
{
getScriptRecording();
}
#endregion
binaryClass.saveParams();
if (generalAnalysisModel.PolyphaseDistanceModels == null)
{
generalAnalysisModel.PolyphaseDistanceModels = new GeneralAnalysisModel.PolyphaseDistanceModel();
}
generalAnalysisModel.PolyphaseDistanceModels.hasUsed = true;
generalAnalysisModel.PolyphaseDistanceModels.parameter1 = checkBox3.Checked;
generalAnalysisModel.PolyphaseDistanceModels.parameter2 = triangleTrackBar1.Value;
generalAnalysisModel.PolyphaseDistanceModels.parameter3 = triangleTrackBar2.Value;
generalAnalysisModel.PolyphaseDistanceModels.parameter4 = (int)numericUpDown1.Value;
generalAnalysisModel.PolyphaseDistanceModels.parameter5 = panel2.BackColor.ToArgb();
generalAnalysisModel.PolyphaseDistanceModels.parameter17 = checkBox1.Checked;
if (radioButton1.Checked)
{
generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 1;
}
else if (radioButton2.Checked)
{
generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 2;
}
else
{
generalAnalysisModel.PolyphaseDistanceModels.parameter6 = 3;
}
if (rb_1.Checked)
{
generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 1;
}
else if (rb_2.Checked)
{
generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 2;
}
else
{
generalAnalysisModel.PolyphaseDistanceModels.parameter7 = 3;
}
if (rb_3.Checked)
{
generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 1;
}
else if (rb_4.Checked)
{
generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 2;
}
else
{
generalAnalysisModel.PolyphaseDistanceModels.parameter8 = 3;
}
generalAnalysisModel.PolyphaseDistanceModels.parameter9 = (int)numericUpDown2.Value;
generalAnalysisModel.PolyphaseDistanceModels.parameter10 = panel4.BackColor.ToArgb();
generalAnalysisModel.PolyphaseDistanceModels.parameter11 = (int)numericUpDown3.Value;
generalAnalysisModel.PolyphaseDistanceModels.parameter12 = (int)numericUpDown4.Value;
generalAnalysisModel.PolyphaseDistanceModels.parameter13 = checkBox4.Checked;
generalAnalysisModel.PolyphaseDistanceModels.parameter14 = checkBox5.Checked;
generalAnalysisModel.PolyphaseDistanceModels.parameter15 = checkBox6.Checked;
generalAnalysisModel.PolyphaseDistanceModels.parameter16 = (int)numericUpDown5.Value;
string filePath = Application.StartupPath + "\\Config\\Default\\ParameterSaving\\ParameterGeneralAnalysis.xml";
string porosityInfoXml = XmlSerializeHelper.XmlSerialize(generalAnalysisModel);
FileOperationHelper.WriteStringToFile(porosityInfoXml, filePath, FileMode.Create);
}
#region [二值化相关方法]
///
/// 添加参数改变的监听
///
///
///
private void GrainSizeDialog_Load(object sender, EventArgs e)
{
this.binaryClass.loadParams();
}
private bool bcBinaryChecked()
{
return bc != null && bc.BinaryChecked;
}
private bool bcOriginChecked()
{
return bc != null && bc.OriginChecked;
}
///
/// 显示原图/原图+二值图
///
///
///
private void bcOriginCheckedChanged(object sender, EventArgs e)
{
if (!bcOriginChecked())
{
if (bcBinaryChecked())
{
if (checkBox4.Checked)
{
this.documentWorkspace.PhaseModels[0].choise = true;
}
else
{
this.documentWorkspace.PhaseModels[0].choise = false;
}
}
}
else
{
this.documentWorkspace.PhaseModels[0].choise = false;
}
this.documentWorkspace.Refresh();
}
///
/// 参数改变时,重新处理图像
///
///
///
private void bClassBinaryImplFinishAction(object sender, EventArgs e)
{
if (!bcOriginChecked())
{
if (bcBinaryChecked())
{
if (checkBox4.Checked)
{
this.documentWorkspace.PhaseModels[0].choise = true;
}
else
{
this.documentWorkspace.PhaseModels[0].choise = false;
}
}
else
{
this.documentWorkspace.PhaseModels[0].choise = false;
}
this.drawObjects.RemoveAll(u => u.drawToolType != DrawToolType.DrawMulLineA);
if (!bcBinaryChecked())
{
this.rmObjects = this.drawObjects.FindAll(u => u.drawToolType != DrawToolType.DrawMulLineA);
}
else
{
this.drawObjects.AddRange(this.rmObjects);
this.rmObjects.Clear();
UpdateLine();
if (checkBox3.Checked)
{
GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
}
}
}
this.documentWorkspace.Refresh();
}
#endregion
private void showImg(object sender, EventArgs e)
{
listView1.Focus();
if (this.imgIndex != -1)
{
//滚动到指定的行位置
this.listView1.EnsureVisible(this.imgIndex);
this.selectPicture = this.imgIndex;
this.listView1.Items[imgIndex].Focused = true;
this.listView1.Items[imgIndex].Selected = true;
}
binaryClass.RefreshHistogramControl1Values();
//如果是脚本执行,将参数带入
if (appWorkspace.ScriptRunning && appWorkspace.ScriptCurrentParam != null)
{
this.initScriptValues = true;//ScriptAutomatic
//Boolean initScriptValues = true;
////在这里反射出对应功能的参数类
string className = InvariantData.path_Action + ".Action" + menuId;
ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
foreach (Args arg in param.Lists)
{
Args param1 = appWorkspace.ScriptCurrentParam.Lists.Find(m => m.Key.Equals(arg.Key));
if (param1.value != null)
arg.Value = param1.value;
getValue(arg.key, arg.Value);
}
appWorkspace.ScriptCurrentParam = null;//阻止第二次进入仍然被赋值参数
}
else
{//读取上次关闭窗口时保存的参数
getLastData();
}
}
private void Init()
{
this.drawObjects.Clear();
this.lineResults.Clear();
//this.documentWorkspace.phaseModels.Clear();
//this.documentWorkspace.GraphicsList.Clear();
}
private void Panel_MouseMove(object sender, MouseEventArgs e)
{
System.Drawing.Point pointscroll = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
if (e.Button == MouseButtons.Left&& documentWorkspace.ActiveTool == DrawToolType.NullTool)
{
if (drawaction == 0)
{
if (activeLine != null)
{
if (activeLine.pointArray.Count == 1)
activeLine.pointArray.Add(pointscroll);
else
activeLine.pointArray[1] = pointscroll;
}
}
this.documentWorkspace.Refresh();
}
}
private void Panel_Paint(object sender, PaintEventArgs e)
{
Rectangle rc = this.documentWorkspace.panel.ClientRectangle;
int width = (int)(this.documentWorkspace.CompositionSurface.Width * this.documentWorkspace.ScaleFactor.Ratio);
int height = (int)(this.documentWorkspace.CompositionSurface.Height * this.documentWorkspace.ScaleFactor.Ratio);
int x = (rc.Width < width) ? this.documentWorkspace.panel.AutoScrollPosition.X + offsetHalfW : (rc.Width - width) / 2;
int y = (rc.Height < height) ? this.documentWorkspace.panel.AutoScrollPosition.Y + offsetHalfH : (rc.Height - height) / 2;
e.Graphics.TranslateTransform(x, y);
e.Graphics.ScaleTransform((float)this.documentWorkspace.ScaleFactor.Ratio, (float)this.documentWorkspace.ScaleFactor.Ratio);
if (drawObjects != null)
{
foreach (DrawObject drobj in drawObjects)
{
drobj.Draw(e.Graphics);
}
}
e.Graphics.ScaleTransform(1 / (float)this.documentWorkspace.ScaleFactor.Ratio, 1 / (float)this.documentWorkspace.ScaleFactor.Ratio);
e.Graphics.TranslateTransform(-x, -y);
}
private void UpdateLine()
{
if (listView1.Items.Count == 0 || listView1.SelectedItems == null)
{
return;
}
List lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
if (mat.Channels() <= 3)
{
mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
}
Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
foreach (var line in lines)
{
if (line == null || line.GetPoints().Count < 2)
{
continue;
}
PointF a = line.GetPoints()[0];
PointF b = line.GetPoints()[1];
List points = new List();
int linkCount = 0;
PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == line.ID);
var ind = lineResults.IndexOf(lineResult);
if (lineResult == null)
{
continue;
}
foreach (int pointid in lineResult.PointIDs.Keys)
{
DrawObject dr = drawObjects.Find(u => u.ID == pointid);
if (dr != null)
{
this.drawObjects.Remove(dr);
}
}
List linePoints = Bresenhamline(a, b);
for (int i = 0; i < linePoints.Count; i++)
{
System.Drawing.Point ploc = linePoints[i];
if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
{
Vec4b targetPoint = mat.At(ploc.Y, ploc.X);
if (targetPoint[0] == color.B && targetPoint[1] == color.G && targetPoint[2] == color.R && targetPoint[3] == 255)
{
linkCount++;
if (linkCount == 1)
{
points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
if (pointStyleModel.DrawType == 0)
{
DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
circleA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(circleA.ID, ploc);
this.drawObjects.Add(circleA);
}
else
{
DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(squareA.ID, ploc);
this.drawObjects.Add(squareA);
}
}
else if ((linkCount % m_tolerance) == 0)
{
if (pointStyleModel.DrawType == 0)
{
DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
circleA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(circleA.ID, ploc);
this.drawObjects.Add(circleA);
}
else
{
DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(squareA.ID, ploc);
this.drawObjects.Add(squareA);
}
}
}
else
{
linkCount = 0;
}
}
}
lineResults[ind] = lineResult;
}
}
private void UpdateStyle()
{
lineStyleModel.lineColor = panel2.BackColor.ToArgb();
lineStyleModel.lineWidth = (int)numericUpDown1.Value;
pointStyleModel.lineWidth = (int)numericUpDown3.Value;
pointStyleModel.size = (int)numericUpDown2.Value;
if (checkBox6.Checked)
{
pointStyleModel.fillColor = panel4.BackColor.ToArgb();
pointStyleModel.lineColor = panel4.BackColor.ToArgb();
}
else
{
pointStyleModel.fillColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
pointStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
}
m_tolerance = (int)numericUpDown4.Value;
if (rb_3.Checked)
{
pointStyleModel.fillType = 1;
}
else if (rb_4.Checked)
{
pointStyleModel.fillType = 0;
}
if (rb_1.Checked)
{
pointStyleModel.DrawType = 0;
List lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
foreach (DrawObject lineObj in lines)
{
PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
Hashtable newPoints = new Hashtable();
if (lineResult == null)
{
continue;
}
foreach (int pointid in lineResult.PointIDs.Keys)
{
DrawObject dr = drawObjects.Find(u => u.ID == pointid);
if (dr != null)
{
this.drawObjects.Remove(dr);
}
System.Drawing.Point linePoint = (System.Drawing.Point)lineResult.PointIDs[pointid];
//lineResult.PointIDs.Remove(pointid);
DrawCircleA squareA = new DrawCircleA(documentWorkspace, linePoint.X, linePoint.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
newPoints.Add(squareA.ID, linePoint);
this.drawObjects.Add(squareA);
}
lineResult.PointIDs = newPoints;
}
}
else if (rb_2.Checked)
{
pointStyleModel.DrawType = 1;
List lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
foreach (DrawObject lineObj in lines)
{
PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
if (lineResult == null)
{
continue;
}
Hashtable newPoints = new Hashtable();
foreach (int pointid in lineResult.PointIDs.Keys)
{
DrawObject dr = drawObjects.Find(u => u.ID == pointid);
if (dr != null)
{
this.drawObjects.Remove(dr);
}
System.Drawing.Point linePoint = (System.Drawing.Point)lineResult.PointIDs[pointid];
//lineResult.PointIDs.Remove(pointid);
DrawSquareA squareA = new DrawSquareA(documentWorkspace, linePoint.X, linePoint.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
newPoints.Add(squareA.ID, linePoint);
this.drawObjects.Add(squareA);
}
lineResult.PointIDs = newPoints;
//drawObjects[i].drawToolType = DrawToolType.DrawCircleA;
//if (pointStyleModel.DrawType == 0)
//{
// DrawCircleA circleA = new DrawCircleA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
// circleA.ISurfaceBox = documentWorkspace;
// lineResult.PointIDs.Add(circleA.ID, linePoint);
// this.drawObjects.Add(circleA);
//}
//else
//{
}
}
decnum = (int)numericUpDown5.Value;
this.documentWorkspace.Refresh();
}
private DrawObject getDrawObjectsByLocation(PointF point, DrawToolType drawToolType)
{
foreach (DrawObject dr in drawObjects)
{
if (dr.drawToolType == drawToolType)
{
if (dr.drawToolType == DrawToolType.DrawMulLineA)
{
//判断线
if (dr.GetPoints().Count > 1)
{
PointF a = dr.GetPoints()[0];
PointF b = dr.GetPoints()[1];
List linePoints = Bresenhamline(a, b);
for (int i = 0; i < linePoints.Count; i++)
{
if (ComparePoint(new System.Drawing.Point((int)point.X, (int)point.Y), linePoints[i], tolerance))
{
return dr;
}
}
}
}
if (dr.drawToolType == drawToolType)
{
System.Drawing.Point pointLocation = new System.Drawing.Point((int)dr.GetPoints()[0].X, (int)dr.GetPoints()[0].Y);
if (ComparePoint(new System.Drawing.Point((int)point.X, (int)point.Y), pointLocation, tolerance))
{
return dr;
}
}
}
}
return null;
}
private bool ComparePoint(System.Drawing.Point source, System.Drawing.Point target, int tolerance)
{
if ((source.X >= (target.X - tolerance)) && (source.X <= (target.X + tolerance)) && (source.Y >= (target.Y - tolerance)) && (source.Y <= (target.Y + tolerance)))
{
return true;
}
else
{
return false;
}
}
private void Panel_MouseDown(object sender, MouseEventArgs e)
{
if (documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text"));
}
if (e.Button == MouseButtons.Left && documentWorkspace.ActiveTool == DrawToolType.NullTool)
{
System.Drawing.Point loc = documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
DrawObject line = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawMulLineA);
//首先判断是否在线上
if (line != null)
{
PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == line.ID);
//List activeLinePoints = (List)linesPoints[line.ID];
if (drawaction == 1)
{
DrawObject circleObject = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawCircleA);
DrawObject squareObject = getDrawObjectsByLocation(new PointF(loc.X, loc.Y), DrawToolType.DrawSquareA);
if (circleObject == null && squareObject == null)
{
//碰撞检测,如未检测到对象则新增。
if (line.GetPoints().Count >= 2)
{
PointF a = line.GetPoints()[0];
PointF b = line.GetPoints()[1];
List linePoints = Bresenhamline(a, b);
System.Drawing.Point linePoint = linePoints.Find(u => ComparePoint(u, loc, tolerance));
if (linePoint != null)
{
if (pointStyleModel.DrawType == 0)
{
DrawCircleA circleA = new DrawCircleA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
circleA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(circleA.ID, linePoint);
this.drawObjects.Add(circleA);
}
else
{
DrawSquareA squareA = new DrawSquareA(documentWorkspace, loc.X, loc.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(squareA.ID, linePoint);
this.drawObjects.Add(squareA);
}
//activeLinePoints.Add(linePoint);
}
}
}
else
{
if (e.Clicks > 1)
{
//如果存在截点,则删除截点
if (circleObject != null)
{
this.drawObjects.Remove(circleObject);
if (lineResult != null)
{
lineResult.PointIDs.Remove(circleObject.ID);
}
}
if (squareObject != null)
{
this.drawObjects.Remove(squareObject);
if (lineResult != null)
{
lineResult.PointIDs.Remove(squareObject.ID);
}
}
}
}
}
else
{
if (e.Clicks > 1)
{
//画线模式,发现线,则删除
if (lineResult != null)
{
foreach (int pointid in lineResult.PointIDs.Keys)
{
DrawObject dr = drawObjects.Find(u => u.ID == pointid);
if (dr != null)
{
this.drawObjects.Remove(dr);
}
}
this.drawObjects.Remove(line);
lineResults.RemoveAll(u => u.LineID == line.ID);
activeLine = null;
}
}
lineAction = 1;
}
}
else
{
lineStartPos = this.documentWorkspace.GetScalePoint(new PointF(e.X, e.Y));
this.documentWorkspace.AnalysisStyleModel = lineStyleModel;
activeLine = new DrawMulLineA(this.documentWorkspace, lineStartPos.X, lineStartPos.Y);
this.drawObjects.Add(activeLine);
lineAction = 0;
}
documentWorkspace.Refresh();
}
}
int XiangSu = 1;
///
/// Bresenham画线算法,给出两个点a,b
///
/// PS:这里XiangSu是光栅的最小距离,因为我是在高分辨率的窗口中模拟低分辨率效果,
/// 所以用这个XiangSu来控制模拟的光栅最小单元格的边的大小,实际运用中XiangSu=1
///
///
List Bresenhamline(System.Drawing.PointF a, System.Drawing.PointF b)
{
List tempP = new List();
int x, y, dx, dy, s1, s2, p, temp, interchange, i;
x = (int)a.X;
y = (int)a.Y;
dx = Math.Abs((int)b.X - (int)a.X);
dy = Math.Abs((int)b.Y - (int)a.Y);
if (b.X > a.X)
s1 = XiangSu;
else
s1 = -XiangSu;
if (b.Y > a.Y)
s2 = XiangSu;
else
s2 = -XiangSu;
if (dy > dx)
{
temp = dx;
dx = dy;
dy = temp;
interchange = 1;
}
else
interchange = 0;
p = 2 * dy - dx;
for (i = 1; i <= dx; i += XiangSu)
{
System.Drawing.Point tempp = new System.Drawing.Point(x, y);
tempp.X = x;
tempp.Y = y;
tempP.Add(tempp);
//Vram[x + y * 600] = true;//把该片内存置为边界标记
if (p >= 0)
{
if (interchange == 0)
y = y + s2;
else
x = x + s1;
p = p - 2 * dx;
}
if (interchange == 0)
x = x + s1;
else
y = y + s2;
p = p + 2 * dy;
}
return tempP;
}
private void Panel_MouseUp(object sender, MouseEventArgs e)
{
//画线
if (drawaction == 0)
{
if (e.Button == MouseButtons.Left && documentWorkspace.ActiveTool == DrawToolType.NullTool)
{
if (lineAction == 0)
{
if (activeLine != null && activeLine.GetPoints().Count > 1)
{
PointF a = activeLine.GetPoints()[0];
PointF b = activeLine.GetPoints()[1];
List points = new List();
Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
if (mat.Channels() <= 3)
{
mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
}
Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
int linkCount = 0;
PolyphaseDistanceLineResult lineResult = new PolyphaseDistanceLineResult();
lineResult.LineID = activeLine.ID;
List linePoints = Bresenhamline(a, b);
for (int i = 0; i < linePoints.Count; i++)
{
System.Drawing.Point ploc = linePoints[i];
if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
{
Vec4b targetPoint = mat.At(ploc.Y, ploc.X);
if (targetPoint[0] == color.B && targetPoint[1] == color.G &&
targetPoint[2] == color.R && targetPoint[3] == 255)
{
linkCount++;
if (linkCount == 1)
{
points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
if (pointStyleModel.DrawType == 0)
{
DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
circleA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(circleA.ID, ploc);
this.drawObjects.Add(circleA);
}
else
{
DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(squareA.ID, ploc);
this.drawObjects.Add(squareA);
}
}
else if ((linkCount % m_tolerance) == 0)
{
if (pointStyleModel.DrawType == 0)
{
DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
circleA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(circleA.ID, ploc);
this.drawObjects.Add(circleA);
}
else
{
DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(squareA.ID, ploc);
this.drawObjects.Add(squareA);
}
}
}
else
{
linkCount = 0;
}
}
}
lineResults.Add(lineResult);
}
}
}
}
documentWorkspace.ActiveTool = DrawToolType.NullTool;
documentWorkspace.Cursor = Cursors.Default;
documentWorkspace.GraphicsList.UnselectAll();
documentWorkspace.Refresh();
}
///
/// 初始化图片列表数据
///
//public void InitPicList()
//{
// //初始化图片列表
// for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
// {
// this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].BinarizationThumbnail);
// this.listView1.Items.Add("", i);
// this.listView1.Items[i].ImageIndex = i;
// this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
// this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
// }
//}
public void InitPicList()
{
//初始化图片列表
for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
{
this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);
this.listView1.Items.Add("", i);
this.listView1.Items[i].ImageIndex = i;
String imageName = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
if (listView1.Items.Find(imageName, false).Count() > 0)
{
if (imageName.Split('.').Count() > 1)
{
imageName = imageName.Split('.')[0] + "(" + listView1.Items.Find(imageName, false).Count() + ")." + imageName.Split('.')[1];
}
}
this.listView1.Items[i].Text = imageName;
this.listView1.Items[i].Name = imageName;
if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
{
this.imgIndex = i;
}
}
}
///
/// ListView图片选择改变事件
///
///
///
private void ListViewSelectedIndexChanged(object sender, EventArgs e)
{
if (this.listView1.FocusedItem != null && this.listView1.FocusedItem.Selected)
{
Init();
if (!string.IsNullOrEmpty(selectedImg))
{
#region [保存参数]
var model = new GeneralAnalysisModel.PolyphaseDistanceModel();
model.parameter1 = checkBox3.Checked;
model.parameter2 = triangleTrackBar1.Value;
model.parameter3 = triangleTrackBar2.Value;
model.parameter4 = (int)numericUpDown1.Value;
model.parameter5 = panel2.BackColor.ToArgb();
model.parameter17 = checkBox1.Checked;
if (radioButton1.Checked)
{
model.parameter6 = 1;
}
else if (radioButton2.Checked)
{
model.parameter6 = 2;
}
else
{
model.parameter6 = 3;
}
if (rb_1.Checked)
{
model.parameter7 = 1;
}
else if (rb_2.Checked)
{
model.parameter7 = 2;
}
else
{
model.parameter7 = 3;
}
if (rb_3.Checked)
{
model.parameter8 = 1;
}
else if (rb_4.Checked)
{
model.parameter8 = 2;
}
else
{
model.parameter8 = 3;
}
model.parameter9 = (int)numericUpDown2.Value;
model.parameter10 = panel4.BackColor.ToArgb();
model.parameter11 = (int)numericUpDown3.Value;
model.parameter12 = (int)numericUpDown4.Value;
model.parameter13 = checkBox4.Checked;
model.parameter14 = checkBox5.Checked;
model.parameter15 = checkBox6.Checked;
model.parameter16 = (int)numericUpDown5.Value;
if (everyImgData.ContainsKey(selectedImg))
{
everyImgData[selectedImg] = model;
}
else
{
everyImgData.Add(selectedImg, model);
}
#endregion
}
this.imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreatedAliasedMat();
Document document = Document.FromImageMat(imageMat.Clone());
this.documentWorkspace.Document = document;
this.documentWorkspace.Visible = true;
if (selectPicture != -1)
{
this.binaryClass.saveMat(this.imageList1.Images.Keys[selectPicture]);
}
selectPicture = this.listView1.FocusedItem.Index;
binaryClass.listView1_SelectedIndexChanged(this.imageMat.Clone(), this.imageList1.Images.Keys[selectPicture]);
if (this.documentWorkspace.phaseModels.Count > 0)
{
double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
triangleTrackBar1.Maximum = (int)maxArea;
triangleTrackBar2.Maximum = (int)maxArea;
}
else
{
triangleTrackBar1.Maximum = 10000;
triangleTrackBar2.Maximum = 10000;
}
if (this.isCheck)
{
checkBox3_BeforeCheckedChanged(sender, e);
triangleTrackBar2.Value = triangleTrackBar2.Maximum;
lbl_kl_max.Text = triangleTrackBar2.Maximum.ToString();
}
#region [设置参数]
this.selectedImg = this.listView1.FocusedItem.Name;
if (everyImgData.ContainsKey(this.selectedImg))
{
var thisModel = everyImgData[this.selectedImg];
checkBox3.Checked = thisModel.parameter1;
if (thisModel.parameter2 <= triangleTrackBar1.Maximum)
{
triangleTrackBar1.Value = thisModel.parameter2;
}
else
{
triangleTrackBar1.Value = 0;
}
if (thisModel.parameter3 <= triangleTrackBar2.Maximum)
{
triangleTrackBar2.Value = thisModel.parameter3;
}
else
{
triangleTrackBar2.Value = 0;
}
lbl_kl_min.Text = thisModel.parameter2.ToString();
lbl_kl_max.Text = thisModel.parameter3.ToString();
numericUpDown1.Value = thisModel.parameter4;
panel2.BackColor = Color.FromArgb(thisModel.parameter5);
radioButton1.Checked = thisModel.parameter6 == 1 ? true : false;
radioButton2.Checked = thisModel.parameter6 == 1 ? false : true;
rb_1.Checked = thisModel.parameter7 == 1 ? true : false;
rb_2.Checked = thisModel.parameter7 == 1 ? false : true;
rb_3.Checked = thisModel.parameter8 == 1 ? true : false;
rb_4.Checked = thisModel.parameter8 == 1 ? false : true;
numericUpDown2.Value = thisModel.parameter9;
panel4.BackColor = Color.FromArgb(thisModel.parameter10);
numericUpDown3.Value = thisModel.parameter11;
numericUpDown4.Value = thisModel.parameter12;
checkBox4.Checked = thisModel.parameter13;
checkBox5.Checked = thisModel.parameter14;
checkBox6.Checked = thisModel.parameter15;
numericUpDown5.Value = thisModel.parameter16;
GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
checkBox1.Checked = thisModel.parameter17;
}
#endregion
if (this.documentWorkspace.phaseModels.Count > 0)
{
if (this.documentWorkspace.phaseModels[0].mat != null)
{
original = this.documentWorkspace.phaseModels[0].mat.Clone();
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
//double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
if (this.appWorkspace.DocumentWorkspaces.Length == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Therearenomeasuringlinesortransversals.Text") + "!");
return;
}
double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
if (listView1.SelectedItems.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.seselecttheimagethatyouwanttoan.Text") + "!");
return;
}
if (lineResults.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Therearenomeasuringlinesortransversals.Text") + "!");
return;
}
String tag = listView1.FocusedItem.Text;
List tempBit = new List();
double avgDistince = 0f;
double distinceSum = 0f;
//计算间距
int distinceCount = 0;
int pointCount = 0;
List> dataList = new List>();
List titleList = new List();
titleList.Add(PdnResources.GetString("Menu.Thetotallength.Text"));
titleList.Add(PdnResources.GetString("Menu.Thenumberofsections.text"));
titleList.Add(PdnResources.GetString("Menu.Theaveragelengthof.Text"));
dataList.Add(titleList);
for (int i = 0; i < lineResults.Count; i++)
{
pointCount += lineResults[i].PointIDs.Count;
System.Drawing.Point[] pointArray = new System.Drawing.Point[lineResults[i].PointIDs.Count];
lineResults[i].PointIDs.Values.CopyTo(pointArray, 0);
pointArray = pointArray.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
for (int j = 0; j < pointArray.Count() - 1; j++)
{
double distince = BasicCalculationHelper.GetDistance(pointArray[j], pointArray[j + 1], 10);
distinceSum += distince * pxPerUnit;
distinceCount++;
}
List newList = new List();
if (distinceSum != 0)
{
newList.Add(distinceSum.ToString());
newList.Add(pointArray.Count().ToString());
newList.Add(Math.Round(distinceSum / (pointArray.Count() / 2), 2).ToString());
dataList.Add(newList);
}
}
if (intermediateDataList.ContainsKey(listView1.FocusedItem.Text.ToString()))
{
intermediateDataList[listView1.FocusedItem.Text.ToString()] = dataList;
}
else
{
intermediateDataList.Add(listView1.FocusedItem.Text.ToString(), dataList);
}
if (distinceCount > 0)
{
avgDistince = distinceSum / distinceCount;
}
//计算方差
double dfSum = 0f;
double fc = 0f;
int fcCount = 0;
for (int i = 0; i < lineResults.Count; i++)
{
System.Drawing.Point[] pointArray = new System.Drawing.Point[lineResults[i].PointIDs.Count];
lineResults[i].PointIDs.Values.CopyTo(pointArray, 0);
pointArray = pointArray.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
for (int j = 0; j < pointArray.Count() - 1; j++)
{
double distince = BasicCalculationHelper.GetDistance(pointArray[j], pointArray[j + 1], 10) * pxPerUnit;
double df = Math.Pow((distince - avgDistince), 2);
dfSum += df;
fcCount++;
}
}
if (fcCount > 0)
{
fc = dfSum / fcCount;
}
PolyphaseDistanceResult result = new PolyphaseDistanceResult(listView1.FocusedItem.Text.ToString(), avgDistince, fc, pointCount);
if (listView1.SelectedItems.Count > 0)
{
List editResults = allResults.FindAll(item => item.GraphName.Equals(listView1.FocusedItem.Text));
if (editResults.Count == 0)
{
listBox_analysisResult.Items.Add(this.listView1.FocusedItem.Text);
allResults.Add(result);
listBox_analysisResult.SetItemChecked(listBox_analysisResult.Items.Count - 1, true);
dataGridView_results.Rows.Add(result.GraphName, AnalysisTools.GetDecNum(result.AvgDistince, decnum), AnalysisTools.GetDecNum(result.Fc, decnum), result.Count, AnalysisTools.GetDecNum(result.medianAvr, decnum));
}
else
{
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Theresuethertoreplace.text") + "?", PdnResources.GetString("Form.OkButton.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
if (dr != DialogResult.OK)
{
return;
}
int index = allResults.FindIndex(item => item.GraphName.Equals(listView1.FocusedItem.Text));
allResults[index] = result;
List list = new List();
foreach (var s in this.listBox_analysisResult.Items)
{
list.Add(s.ToString());
}
this.listBox_analysisResult.Items.Clear();
foreach (var s in list)
{
this.listBox_analysisResult.Items.Add(s);
}
var thisindex = this.listBox_analysisResult.Items.IndexOf(listView1.FocusedItem.Text);
this.dataGridView_results.Rows.Clear();
listBox_analysisResult.SetItemChecked(thisindex, true);
dataGridView_results.Rows.Add(result.GraphName, AnalysisTools.GetDecNum(result.AvgDistince, decnum), AnalysisTools.GetDecNum(result.Fc, decnum), result.Count, AnalysisTools.GetDecNum(result.medianAvr, decnum));
}
double pantographRatio = (double)this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRulerMultiple(MeasurementUnit.Micron);//标尺*放大倍数
Bitmap originalBit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].CompositionSurface.CreateAliasedBitmap();
originalBit.Tag = pantographRatio;
tempBit.Add(originalBit);
Bitmap newBit = originalBit.Clone(new Rectangle(0, 0, originalBit.Width, originalBit.Height), originalBit.PixelFormat);
newBit.Tag = pantographRatio;
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
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
}
}
private void Draw(Graphics graphics)
{
if (this.documentWorkspace.phaseModels.Count > 0)
{
foreach (PhaseModel model in this.documentWorkspace.phaseModels)
{
if (model.choise && model.mat != null)
{
Bitmap map = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(model.mat);
graphics.DrawImage(map, 0, 0, map.Width, map.Height);
}
}
if (drawObjects != null)
{
foreach (DrawObject drobj in drawObjects)
{
drobj.Draw(graphics);
}
}
}
}
private void button8_Click(object sender, EventArgs e)
{
drawaction = 1;
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
UpdateStyle();
}
private void rb_1_CheckedChanged(object sender, EventArgs e)
{
if (rb_1.Checked)
{
UpdateStyle();
}
}
private void rb_2_CheckedChanged(object sender, EventArgs e)
{
if (rb_2.Checked)
{
UpdateStyle();
}
}
private void numericUpDown2_ValueChanged(object sender, EventArgs e)
{
UpdateStyle();
}
private void numericUpDown3_ValueChanged(object sender, EventArgs e)
{
UpdateStyle();
}
private void rb_3_CheckedChanged(object sender, EventArgs e)
{
if (rb_3.Checked)
{
UpdateStyle();
}
}
private void rb_4_CheckedChanged(object sender, EventArgs e)
{
if (rb_4.Checked)
{
UpdateStyle();
}
}
private void panel2_Click(object sender, EventArgs e)
{
this.lineColorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel2.BackColor);
this.lineColorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.lineColorChanged));
this.lineColorsFormGrid.ShowDialog();
}
private void lineColorChanged(object sender, EventArgs e)
{
Color color = this.lineColorsFormGrid.UserPrimaryColor.ToColor();
//更改背景色,触发事件
this.panel2.BackColor = color;
//改变配置文件里面的相颜色
//this.binaryExtractionModel.PhaseColor = color.ToArgb();
//关闭色板
UpdateStyle();
this.lineColorsFormGrid.Close();
}
private void panel4_Click(object sender, EventArgs e)
{
this.PointcolorsFormGrid.UserPrimaryColor = ColorBgra.FromColor(this.panel4.BackColor);
this.PointcolorsFormGrid.setSaveBtn_Click(new System.EventHandler(this.PointColorChanged));
this.PointcolorsFormGrid.ShowDialog();
}
private void PointColorChanged(object sender, EventArgs e)
{
Color color = this.PointcolorsFormGrid.UserPrimaryColor.ToColor();
//更改背景色,触发事件
this.panel4.BackColor = color;
//改变配置文件里面的相颜色
//this.binaryExtractionModel.PhaseColor = color.ToArgb();
//关闭色板
UpdateStyle();
this.PointcolorsFormGrid.Close();
}
private void checkBox6_CheckedChanged(object sender, EventArgs e)
{
if (checkBox6.Checked)
{
pointStyleModel.fillColor = panel4.BackColor.ToArgb();
pointStyleModel.lineColor = panel4.BackColor.ToArgb();
}
else
{
pointStyleModel.fillColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
pointStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
}
documentWorkspace.Refresh();
}
private void checkBox5_CheckedChanged(object sender, EventArgs e)
{
if (checkBox5.Checked)
{
lineStyleModel.lineColor = panel2.BackColor.ToArgb();
}
else
{
lineStyleModel.lineColor = Color.FromArgb(0, 255, 255, 255).ToArgb();
}
documentWorkspace.Refresh();
}
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
if (checkBox4.Checked)
{
if (documentWorkspace.phaseModels.Count > 0)
{
documentWorkspace.phaseModels[0].choise = true;
}
}
else
{
if (documentWorkspace.phaseModels.Count > 0)
{
documentWorkspace.phaseModels[0].choise = false;
}
}
documentWorkspace.Refresh();
}
private void tb_2_Load(object sender, EventArgs e)
{
}
private void triangleTrackBar2_TrackBarScroll(object sender, EventArgs e)
{
//Mat mat = PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.CompositionSurface.CreateAliasedBitmap());
if (this.documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
return;
}
this.documentWorkspace.phaseModels[0].mat = original.Clone();
GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat.Clone());
lbl_kl_max.Text = triangleTrackBar2.Value.ToString();
redrawForTolerance();
this.documentWorkspace.Refresh();
}
private void triangleTrackBar1_TrackBarScroll(object sender, EventArgs e)
{
if (this.documentWorkspace.phaseModels.Count == 0 || !bcBinaryChecked())
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
return;
}
this.documentWorkspace.phaseModels[0].mat = original.Clone();
GetAreaBetweenMinToMax(triangleTrackBar1.Value, triangleTrackBar2.Value, this.documentWorkspace.phaseModels[0].mat);
lbl_kl_min.Text = triangleTrackBar1.Value.ToString();
redrawForTolerance();
this.documentWorkspace.Refresh();
}
private decimal getMaxArea(Mat pMat)
{
if (pMat == null)
{
return 10000;
}
double maxArea = 0;
Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
HierarchyIndex[] hierarchy;
OpenCvSharp.Point[][] contours;
Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
for (int i = 0; i < contours.Count(); i++)
{
double area = Cv2.ContourArea(contours[i]);
if (area > maxArea)
{
maxArea = area;
}
}
return (decimal)maxArea;
}
private void checkBox3_BeforeCheckedChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems == null || listView1.SelectedItems.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text") + "!");
this.checkBox3.Checked = false;
return;
}
checkBox3_CheckedChanged(sender, e);
}
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems == null || listView1.SelectedItems.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicturefirst.text") + "!");
return;
}
this.isCheck = checkBox3.Checked;
if (checkBox3.Checked)
{
if (this.documentWorkspace.phaseModels.Count > 0 && bcBinaryChecked())
{
//double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
//maxArea = (int)Math.Ceiling(Convert.ToDouble(getMaxArea(this.documentWorkspace.phaseModels[0].mat)) * pxPerUnit * pxPerUnit);
//triangleTrackBar1.Maximum = (int)maxArea;
//triangleTrackBar2.Maximum = (int)maxArea;
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseperformbinarizationoperationfirst.text") + "!");
return;
}
}
else
{
triangleTrackBar1.Value = 0;
triangleTrackBar2.Value = 0;
lbl_kl_max.Text = "0";
lbl_kl_min.Text = "0";
//binaryClass.applyButtonImpl();
this.documentWorkspace.Refresh();
}
}
private void GetAreaBetweenMinToMax(decimal areaMin, decimal areaMax, Mat pMat)
{
if (!checkBox3.Checked)
{
return;
}
List selectContours = new List();
List unSelectContours = new List();
Mat mat = Mat.FromImageData(pMat.ToBytes(), ImreadModes.Grayscale);
//double pxPerUnit = Startup.instance.rules[MeasurementUnit.Micron];
double pxPerUnit = this.appWorkspace.DocumentWorkspaces[this.listView1.FocusedItem.Index].GetRuler(MeasurementUnit.Micron);
HierarchyIndex[] hierarchy;
OpenCvSharp.Point[][] contours;
Cv2.FindContours(mat, out contours, out hierarchy, RetrievalModes.External, ContourApproximationModes.ApproxNone);
for (int i = 0; i < contours.Length; i++)
{
double area = (Cv2.FloodFill(mat, contours[i][0], new Scalar(0, 0, 0, 0)) - contours[i].Length / 2.0) * pxPerUnit * pxPerUnit;
if (area < 0)
{
area = 0;
}
if (area >= (double)areaMin && area <= (double)areaMax)
{
selectContours.Add(contours[i]);
}
else
{
unSelectContours.Add(contours[i]);
}
}
Cv2.DrawContours(documentWorkspace.phaseModels[0].mat, selectContours, -1, new Scalar(this.documentWorkspace.phaseModels[0].color), Cv2.FILLED);
documentWorkspace.Refresh();
}
private void numericUpDown4_ValueChanged(object sender, EventArgs e)
{
m_tolerance = (int)numericUpDown4.Value;
redrawForTolerance();
this.documentWorkspace.Refresh();
}
private void redrawForTolerance()
{
if (drawaction == 0)
{
List lines = drawObjects.FindAll(u => u.drawToolType == DrawToolType.DrawMulLineA);
foreach (DrawObject lineObj in lines)
{
PolyphaseDistanceLineResult lineResult = lineResults.Find(u => u.LineID == lineObj.ID);
if (lineResult != null)
{
//删除原有点
foreach (int pointid in lineResult.PointIDs.Keys)
{
DrawObject dr = drawObjects.Find(u => u.ID == pointid);
if (dr != null)
{
this.drawObjects.Remove(dr);
}
}
lineResult.PointIDs.Clear();
//画新点
if (lineObj != null && lineObj.GetPoints().Count > 1)
{
PointF a = lineObj.GetPoints()[0];
PointF b = lineObj.GetPoints()[1];
List points = new List();
Mat mat = documentWorkspace.phaseModels[0].mat.Clone();
if (mat.Channels() <= 3)
{
mat = mat.CvtColor(ColorConversionCodes.BGR2BGRA);
}
Color color = Color.FromArgb(documentWorkspace.phaseModels[0].color);
int linkCount = 0;
lineResult.LineID = lineObj.ID;
List linePoints = Bresenhamline(a, b);
for (int i = 0; i < linePoints.Count; i++)
{
System.Drawing.Point ploc = linePoints[i];
if (ploc.X < mat.Cols && ploc.Y < mat.Rows && ploc.X >= 0 && ploc.Y >= 0)
{
Vec4b targetPoint = mat.At(ploc.Y, ploc.X);
if (targetPoint[0] == color.B && targetPoint[1] == color.G && targetPoint[2] == color.R && targetPoint[3] == 255)
{
linkCount++;
if (linkCount == 1)
{
points.Add(new System.Drawing.Point(ploc.X, ploc.Y));
if (pointStyleModel.DrawType == 0)
{
DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
circleA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(circleA.ID, ploc);
this.drawObjects.Add(circleA);
}
else
{
DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(squareA.ID, ploc);
this.drawObjects.Add(squareA);
}
}
else if ((linkCount % m_tolerance) == 0)
{
if (pointStyleModel.DrawType == 0)
{
DrawCircleA circleA = new DrawCircleA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
circleA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(circleA.ID, ploc);
this.drawObjects.Add(circleA);
}
else
{
DrawSquareA squareA = new DrawSquareA(documentWorkspace, ploc.X, ploc.Y, 1, 1, pointStyleModel);
squareA.ISurfaceBox = documentWorkspace;
lineResult.PointIDs.Add(squareA.ID, ploc);
this.drawObjects.Add(squareA);
}
}
}
else
{
linkCount = 0;
}
}
}//end for
}//end if
}//end if
}// end foreach
}//end for if
}
private void button_all_Click(object sender, EventArgs e)
{
dataGridView_results.Rows.Clear();
if (this.is_all % 2 == 0)
{
for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
{
listBox_analysisResult.SetItemChecked(i, false);
}
}
else
{
for (int i = 0; i < listBox_analysisResult.Items.Count; i++)
{
listBox_analysisResult.SetItemChecked(i, true);
}
for (int i = 0; i < allResults.Count; i++)
{
PolyphaseDistanceResult editResult = allResults[i];
dataGridView_results.Rows.Add(editResult.GraphName, AnalysisTools.GetDecNum(editResult.AvgDistince, decnum), AnalysisTools.GetDecNum(editResult.Fc, decnum), editResult.Count);
}
}
this.is_all += 1;
}
private void listBox_analysisResult_SelectedIndexChanged(object sender, EventArgs e)
{
dataGridView_results.Rows.Clear();
if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
{
foreach (var s in listBox_analysisResult.CheckedItems)
{
List editResults = allResults.FindAll(u => u.GraphName == s.ToString());
for (int i = 0; i < editResults.Count; i++)
{
PolyphaseDistanceResult editResult = editResults[i];
dataGridView_results.Rows.Add(editResult.GraphName, AnalysisTools.GetDecNum(editResult.AvgDistince, decnum), AnalysisTools.GetDecNum(editResult.Fc, decnum), editResult.Count, AnalysisTools.GetDecNum(editResult.medianAvr, decnum));
}
}
}
}
private void button_remove_Click(object sender, EventArgs e)
{
var removeList = new List();
if (listBox_analysisResult.CheckedItems != null && listBox_analysisResult.CheckedItems.Count > 0)
{
DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.ertodeletetheselectedanalysisres.Text") + "?", PdnResources.GetString("Menu.Edit.Delete.Text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
foreach (var s in listBox_analysisResult.CheckedItems)
{
for (int i = 0; i < dataGridView_results.Rows.Count; i++)
{
if (dataGridView_results.Rows[i].Cells[0].Value.ToString() == s.ToString())
{
dataGridView_results.Rows.RemoveAt(i);
}
}
allResults.RemoveAll(u => u.GraphName == s.ToString());
removeList.Add(s.ToString());
}
foreach (var m in removeList)
{
listBox_analysisResult.Items.Remove(m);
}
}
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.cttheanalysisresultsthatyouwanttod.Text") + "!");
}
}
private void numericUpDown5_ValueChanged(object sender, EventArgs e)
{
decnum = (int)numericUpDown5.Value;
for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
{
PolyphaseDistanceResult result = allResults.Find(u => u.GraphName == dataGridView_results.Rows[i].Cells[0].Value);
if (result != null)
{
dataGridView_results.Rows[i].Cells[1].Value = AnalysisTools.GetDecNum(result.AvgDistince, decnum);
dataGridView_results.Rows[i].Cells[2].Value = AnalysisTools.GetDecNum(result.Fc, decnum);
}
}
}
private void button5_Click(object sender, EventArgs e)
{
this.Close();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
drawaction = 0;
}
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
if (radioButton2.Checked)
{
drawaction = 1;
}
}
private void tb_1_Load(object sender, EventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
if (this.dataGridView_results.Rows.Count > 0)
{
SaveFileDialog exe = new SaveFileDialog();
exe.Filter = "Execl files (*.xlsx)|*.xlsx";
exe.FilterIndex = 0;
exe.RestoreDirectory = true;
exe.Title = "Export Excel File";
exe.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
exe.FileName = DateTime.Now.ToString("yyyyMMddhhmmss") + PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text") + PdnResources.GetString("Menu.Analysisresult.text");
DialogResult dr = exe.ShowDialog();
if (dr == DialogResult.OK)
{
DataTable dtb = new DataTable();
foreach (DataGridViewColumn c in this.dataGridView_results.Columns)
{
dtb.Columns.Add(c.HeaderText);
}
for (int r = 0; r < this.dataGridView_results.Rows.Count; r++)
{
DataRow dataRow = dtb.NewRow();
for (int c = 0; c < this.dataGridView_results.Rows[r].Cells.Count; c++)
{
dataRow[this.dataGridView_results.Columns[c].HeaderText] = this.dataGridView_results.Rows[r].Cells[c].Value;
}
dtb.Rows.Add(dataRow);
}
List list = new List();
list.Add(dtb);
this.appWorkspace.ExportDataToExcelWithProgress(list, exe.FileName, true, false, true);
}
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Noanalysisresults.text") + "!");
}
}
private void button1_Click(object sender, EventArgs e)
{
AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseDistance");
if (recombinationRateSetDialog.hasModule)
{
recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
recombinationRateSetDialog.ShowDialog();
}
else
{
recombinationRateSetDialog = null;
}
}
private void button3_Click(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
AnalyzeSettingDialog recombinationRateSetDialog = new AnalyzeSettingDialog(this, "Template.Manager.item2.PolyphaseDistance");
if (recombinationRateSetDialog.hasModule)
{
recombinationRateSetDialog.StartPosition = FormStartPosition.CenterScreen;
recombinationRateSetDialog.ShowDialog();
}
else
{
recombinationRateSetDialog = null;
}
}
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.dataGridView_results.Rows.Count; i++)
{
List content1 = new List();
if (i == 0)
{
content1.Add(this.dataGridView_results.Columns[0].HeaderText);
content1.Add(this.dataGridView_results.Columns[1].HeaderText);
content1.Add(this.dataGridView_results.Columns[2].HeaderText);
content1.Add(this.dataGridView_results.Columns[3].HeaderText);
analysisContent.Add(content1);
}
content1 = new List();
content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
analysisContent.Add(content1);
string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
if (bitDic.ContainsKey(tag))
{
bitList.Add(bitDic[tag][0]);
bitList.Add(bitDic[tag][1]);
}
}
this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, bitList, tagInfos);
}
else
MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
}
private void button9_Click(object sender, EventArgs e)
{
if (this.dataGridView_results.Rows.Count == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Noresults.text"));
return;
}
if (this.analyzeSettingModel == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleasesetiirst.Text"));
return;
}
//获取项目工程内的文件夹路径
ProjectEngineering.NodeItem item = this.appWorkspace.GetInsertProjectPath(2, "Menu.GeneralAnalysis.PhaseSpacing.Text", this.analyzeSettingModel.savePath);
if (item != null)
{
//向文件夹内保存图片和报告
if (!string.IsNullOrEmpty(this.analyzeSettingModel.analyzeClassify))
{
//获取word书签与excel单元格的关系,以字典方式存储
List mic_module_infos = mic_module_infos_BLL.FindAll().FindAll(a => a.analyze_classify == this.analyzeSettingModel.analyzeClassify);
Dictionary tagInfos = new Dictionary();
if (mic_module_infos != null && mic_module_infos.Count > 0)
{
foreach (mic_module_infos info in mic_module_infos)
{
tagInfos.Add(info.tag_name, info.cell_position);
}
}
List> analysisContent = new List>();
List> inclusionList = new List>();
List exportModel = new List();
List bitImgList = new List();
for (int i = 0; i < this.dataGridView_results.Rows.Count; i++)
{
List content1 = new List();
if (i == 0)
{
content1.Add(this.dataGridView_results.Columns[0].HeaderText);
content1.Add(this.dataGridView_results.Columns[1].HeaderText);
content1.Add(this.dataGridView_results.Columns[2].HeaderText);
content1.Add(this.dataGridView_results.Columns[3].HeaderText);
analysisContent.Add(content1);
}
content1 = new List();
content1.Add(this.dataGridView_results.Rows[i].Cells[0].Value.ToString());
content1.Add(this.dataGridView_results.Rows[i].Cells[1].Value.ToString());
content1.Add(this.dataGridView_results.Rows[i].Cells[2].Value.ToString());
content1.Add(this.dataGridView_results.Rows[i].Cells[3].Value.ToString());
analysisContent.Add(content1);
string tag = this.dataGridView_results.Rows[i].Cells[0].Value.ToString();
if (intermediateDataList.ContainsKey(tag))
{
ExportProjectModel exportProjectModel = new ExportProjectModel();
exportProjectModel.dataList = intermediateDataList[tag];
exportProjectModel.picName = tag;
exportProjectModel.tagName = PdnResources.GetString("Menu.GeneralAnalysis.PhaseSpacing.Text");
exportModel.Add(exportProjectModel);
}
if (bitDic.ContainsKey(tag))
{
bitImgList.Add(bitDic[tag][0]);
bitImgList.Add(bitDic[tag][1]);
}
}
try
{
this.appWorkspace.CreateAnalysisReport(this.analyzeSettingModel, analysisContent, exportModel, bitImgList, tagInfos, item.path, item.code);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Pleasesettheanalysisreportfirst.text") + "!");
return;
}
//保存项目信息到数据库
this.appWorkspace.InsertIntoDB(this.analyzeSettingModel, item);
}
}
private void PolyphaseDistanceDialog_Resize(object sender, EventArgs e)
{
if (dataGridView_results != null)
{
AutoSizeColumn(dataGridView_results, 10);
}
}
private void getValue(string key, Object value)
{
switch (key)
{
case "parameter11":
numericUpDown1.Value = Convert.ToDecimal(value);
break;
case "parameter12":
panel2.BackColor = Color.FromArgb(Convert.ToInt32(value));
break;
case "parameter13":
radioButton1.Checked = (int)value == 1 ? true : false;
radioButton2.Checked = (int)value == 1 ? false : true;
break;
case "parameter14":
rb_1.Checked = (int)value == 1 ? true : false;
rb_2.Checked = (int)value == 1 ? false : true;
break;
case "parameter15":
rb_3.Checked = (int)value == 1 ? true : false;
rb_4.Checked = (int)value == 1 ? false : true;
break;
case "parameter16":
numericUpDown2.Value = Convert.ToDecimal(value);
break;
case "parameter17":
numericUpDown3.Value = Convert.ToDecimal(value);
break;
case "parameter18":
numericUpDown4.Value = Convert.ToDecimal(value);
break;
case "parameter19":
checkBox4.Checked = Convert.ToBoolean(value);
break;
case "parameter20":
checkBox5.Checked = Convert.ToBoolean(value);
break;
case "parameter21":
checkBox6.Checked = Convert.ToBoolean(value);
break;
case "parameter22":
panel4.BackColor = Color.FromArgb(Convert.ToInt32(value));
break;
case "OpenWhileExportReport":
checkBox1.Checked = Convert.ToBoolean(value);
break;
case "CalculatorDecimalDigits":
numericUpDown5.Value = Convert.ToDecimal(value);
break;
}
}
#region [脚本录制]
private void getScriptRecording()
{
string className = InvariantData.path_Action + ".Action" + menuId;
ParamObject param = (ParamObject)System.Reflection.Assembly.Load(InvariantData.assembly_Data).CreateInstance(className);
List args = param.Lists;
foreach (var item in args)
{
item.value = setScriptRecording(item.key);
}
//找出二值相关参数 进行赋值
List isNullList = args.Where(m => m.value == null).ToList();
foreach (var item in isNullList)
{
item.value = binaryClass.setScriptRecording(item.key);
}
appWorkspace.SetScriptStartRecording(this.menuId, menuName, args);
}
private object setScriptRecording(string key)
{
object value = null;
switch (key)
{
case "parameter11":
value = numericUpDown1.Value;
break;
case "parameter12":
value = panel2.BackColor.ToArgb();
break;
case "parameter13":
value = radioButton1.Checked ? 1 : 2;
break;
case "parameter14":
value = rb_1.Checked ? 1 : 2;
break;
case "parameter15":
value = rb_3.Checked ? 1 : 2;
break;
case "parameter16":
value = numericUpDown2.Value;
break;
case "parameter17":
value = numericUpDown3.Value;
break;
case "parameter18":
value = numericUpDown4.Value;
break;
case "parameter19":
value = checkBox4.Checked;
break;
case "parameter20":
value = checkBox5.Checked;
break;
case "parameter21":
value = checkBox6.Checked;
break;
case "parameter22":
value = panel4.BackColor.ToArgb();
break;
case "OpenWhileExportReport":
value = checkBox1.Checked;
break;
case "CalculatorDecimalDigits":
value = numericUpDown5.Value;
break;
case "ExportResults":
value = false;
break;
case "ExportReports":
value = false;
break;
case "ExportProjects":
value = false;
break;
}
return value;
}
#endregion
}
}