using Metis.ParameterSet;
using OpenCvSharp;
using PaintDotNet.Adjust.BaseImage;
using PaintDotNet.Annotation.Enum;
using PaintDotNet.Base;
using PaintDotNet.Base.CommTool;
using PaintDotNet.Base.Enum;
using PaintDotNet.Base.Functionodel;
using PaintDotNet.CustomControl;
using PaintDotNet.Data.Param;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
namespace PaintDotNet.Binarization
{
///
/// 物相提取
///
internal class PhaseExtractDialog : PdnBaseForm
{
#region 控件
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.CheckBox checkBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.ImageList imageList1;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.NumericUpDown numericUpDown2;
private System.Windows.Forms.NumericUpDown numericUpDown1;
private System.Windows.Forms.CheckBox checkBox4;
private System.Windows.Forms.CheckBox checkBox3;
private System.Windows.Forms.CheckBox checkBox2;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.GroupBox groupBox7;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.GroupBox groupBox8;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.RadioButton radioButton3;
private System.Windows.Forms.RadioButton radioButton4;
private System.Windows.Forms.GroupBox groupBox9;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RadioButton radioButton5;
private System.Windows.Forms.RadioButton radioButton6;
private System.Windows.Forms.GroupBox groupBox10;
private System.Windows.Forms.RadioButton radioButton9;
private System.Windows.Forms.RadioButton radioButton7;
private System.Windows.Forms.RadioButton radioButton8;
private System.Windows.Forms.GroupBox groupBox11;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.RadioButton radioButton10;
private System.Windows.Forms.RadioButton radioButton11;
private System.Windows.Forms.NumericUpDown numericUpDown7;
private System.Windows.Forms.NumericUpDown numericUpDown8;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.NumericUpDown numericUpDown5;
private System.Windows.Forms.NumericUpDown numericUpDown6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.NumericUpDown numericUpDown3;
private System.Windows.Forms.NumericUpDown numericUpDown4;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.RadioButton radioButton12;
private System.Windows.Forms.RadioButton radioButton13;
private System.Windows.Forms.NumericUpDown userTextBox2;
private System.Windows.Forms.NumericUpDown userTextBox1;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.GroupBox groupBox12;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.GroupBox groupBox13;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button11;
private System.Windows.Forms.Button button12;
private NumericUpDown numericUpDown9;
private Panel panel1;
private RadioButton radioButton14;
private RadioButton radioButton15;
private Button button13;
private Button button15;
private Button button14;
private CustomControl.HistogramControl histogramControl1;
private Button button16;
private Button button17;
private Button button18;
private CheckBox checkBox5;
private RadioButton radioButton16;
private void InitializeLanguageText()
{
this.groupBox2.Text = PdnResources.GetString("Menu.operation.text");
this.label7.Text = PdnResources.GetString("Menu.Phasecolor.text") + ":";
this.button10.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Previous.text");
this.button9.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.next.text");
this.button4.Text = PdnResources.GetString("Menu.Add.text");
this.button3.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
this.button5.Text = PdnResources.GetString("Menu.Edit.Text");
this.checkBox1.Text = PdnResources.GetString("Menu.Createnewgraph.text");
this.button1.Text = PdnResources.GetString("Menu.ensure.text");
this.groupBox4.Text = PdnResources.GetString("Menu.Tools.ImageIndex.Text");
this.groupBox5.Text = PdnResources.GetString("Menu.Processingdetails.text");
this.checkBox4.Text = PdnResources.GetString("Menu.Clasticdelete.text");
this.checkBox3.Text = PdnResources.GetString("Menu.BinaryAction.HoleFilling.Text");
this.checkBox2.Text = PdnResources.GetString("Menu.Binaryoperation.Binaryextraction.Deleteboundaryobject.text");
this.groupBox6.Text = PdnResources.GetString("Menu.Binarystyle.text");
this.radioButton2.Text = PdnResources.GetString("Menu.Sideline.text");
this.radioButton1.Text = PdnResources.GetString("Menu.solid.text");
this.groupBox7.Text = PdnResources.GetString("Menu.Setting.Text");
this.groupBox1.Text = PdnResources.GetString("Menu.Preview.text");
this.groupBox12.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.click.text");
this.label9.Text = PdnResources.GetString("Menu.deviation.Text") + ":";
this.groupBox8.Text = PdnResources.GetString("Menu.Tools.Histogram.Text");
this.groupBox3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Extractionmode.text");
this.radioButton3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Singletarget.text");
this.radioButton4.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Wholeimage.text");
this.groupBox9.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Definetheobject.text");
this.radioButton16.Text = PdnResources.GetString("Menu.LabelAction.DrawEllipse.Text");
this.radioButton15.Text = PdnResources.GetString("Menu.LabelAction.DrawRectangle.Text");
this.radioButton14.Text = PdnResources.GetString("Menu.LabelAction.DrawPolygon.Text");
this.label4.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Rangesize.text") + ":";
this.label3.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.admissiblevalue.text") + ":";
this.radioButton5.Text = PdnResources.GetString("Menu.contour.text");
this.radioButton6.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.click.text");
this.groupBox10.Text = PdnResources.GetString("Menu.Targetselection.text");
this.radioButton9.Text = PdnResources.GetString("Menu.style.text") + "3";
this.radioButton7.Text = PdnResources.GetString("Menu.style.text") + "2";
this.radioButton8.Text = PdnResources.GetString("Menu.style.text") + "1";
this.groupBox11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Targetprocessing.text");
this.button8.Text = PdnResources.GetString("Menu.reinformation.text");
this.button7.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Redo.text");
this.button6.Text = PdnResources.GetString("Menu.Edit.Undo.Text");
this.radioButton10.Text = PdnResources.GetString("Menu.Edit.Delete.Text");
this.radioButton11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.append.text");
this.groupBox13.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Targetprocessing.text");
this.button2.Text = PdnResources.GetString("Menu.reinformation.text");
this.button11.Text = PdnResources.GetString("Menu.Binaryoperation.Phaseextraction.Redo.text");
this.button12.Text = PdnResources.GetString("Menu.Edit.Undo.Text");
this.checkBox5.Text = PdnResources.GetString("Menu.allShow.Text");
this.Text = "PhaseExtractDialog";
}
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.checkBox5 = new System.Windows.Forms.CheckBox();
this.label7 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.button10 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.checkBox1 = new System.Windows.Forms.CheckBox();
this.button1 = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.listView1 = new System.Windows.Forms.ListView();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.numericUpDown2 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.checkBox4 = new System.Windows.Forms.CheckBox();
this.checkBox3 = new System.Windows.Forms.CheckBox();
this.checkBox2 = new System.Windows.Forms.CheckBox();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.groupBox7 = new System.Windows.Forms.GroupBox();
this.button15 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.numericUpDown7 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown8 = new System.Windows.Forms.NumericUpDown();
this.label6 = new System.Windows.Forms.Label();
this.numericUpDown5 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown6 = new System.Windows.Forms.NumericUpDown();
this.label5 = new System.Windows.Forms.Label();
this.numericUpDown3 = new System.Windows.Forms.NumericUpDown();
this.numericUpDown4 = new System.Windows.Forms.NumericUpDown();
this.label2 = new System.Windows.Forms.Label();
this.radioButton12 = new System.Windows.Forms.RadioButton();
this.radioButton13 = new System.Windows.Forms.RadioButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.groupBox12 = new System.Windows.Forms.GroupBox();
this.numericUpDown9 = new System.Windows.Forms.NumericUpDown();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.label9 = new System.Windows.Forms.Label();
this.groupBox8 = new System.Windows.Forms.GroupBox();
this.histogramControl1 = new PaintDotNet.CustomControl.HistogramControl();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.radioButton3 = new System.Windows.Forms.RadioButton();
this.radioButton4 = new System.Windows.Forms.RadioButton();
this.groupBox9 = new System.Windows.Forms.GroupBox();
this.panel1 = new System.Windows.Forms.Panel();
this.radioButton16 = new System.Windows.Forms.RadioButton();
this.radioButton15 = new System.Windows.Forms.RadioButton();
this.radioButton14 = new System.Windows.Forms.RadioButton();
this.userTextBox2 = new System.Windows.Forms.NumericUpDown();
this.userTextBox1 = new System.Windows.Forms.NumericUpDown();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.radioButton5 = new System.Windows.Forms.RadioButton();
this.radioButton6 = new System.Windows.Forms.RadioButton();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.button18 = new System.Windows.Forms.Button();
this.button17 = new System.Windows.Forms.Button();
this.button16 = new System.Windows.Forms.Button();
this.radioButton9 = new System.Windows.Forms.RadioButton();
this.radioButton7 = new System.Windows.Forms.RadioButton();
this.radioButton8 = new System.Windows.Forms.RadioButton();
this.groupBox11 = new System.Windows.Forms.GroupBox();
this.button8 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.button6 = new System.Windows.Forms.Button();
this.radioButton10 = new System.Windows.Forms.RadioButton();
this.radioButton11 = new System.Windows.Forms.RadioButton();
this.groupBox13 = new System.Windows.Forms.GroupBox();
this.button2 = new System.Windows.Forms.Button();
this.button11 = new System.Windows.Forms.Button();
this.button12 = new System.Windows.Forms.Button();
this.groupBox2.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).BeginInit();
this.groupBox6.SuspendLayout();
this.groupBox7.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown7)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown8)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).BeginInit();
this.groupBox12.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown9)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.groupBox8.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox9.SuspendLayout();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.userTextBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.userTextBox1)).BeginInit();
this.groupBox10.SuspendLayout();
this.groupBox11.SuspendLayout();
this.groupBox13.SuspendLayout();
this.SuspendLayout();
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.checkBox5);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.panel2);
this.groupBox2.Controls.Add(this.button10);
this.groupBox2.Controls.Add(this.button9);
this.groupBox2.Controls.Add(this.button4);
this.groupBox2.Controls.Add(this.button3);
this.groupBox2.Controls.Add(this.button5);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.checkBox1);
this.groupBox2.Controls.Add(this.button1);
this.groupBox2.Location = new System.Drawing.Point(13, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(1261, 52);
this.groupBox2.TabIndex = 7;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "操作";
//
// checkBox5
//
this.checkBox5.AutoSize = true;
this.checkBox5.Location = new System.Drawing.Point(555, 23);
this.checkBox5.Name = "checkBox5";
this.checkBox5.Size = new System.Drawing.Size(72, 16);
this.checkBox5.TabIndex = 23;
this.checkBox5.Text = "显示全部";
this.checkBox5.UseVisualStyleBackColor = true;
this.checkBox5.CheckedChanged += new System.EventHandler(this.checkBox5_CheckedChanged);
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(421, 26);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(53, 12);
this.label7.TabIndex = 22;
this.label7.Text = "相颜色:";
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.Transparent;
this.panel2.Location = new System.Drawing.Point(476, 21);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(72, 21);
this.panel2.TabIndex = 21;
//
// button10
//
this.button10.Location = new System.Drawing.Point(7, 21);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(75, 23);
this.button10.TabIndex = 14;
this.button10.Text = "上一个";
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// button9
//
this.button9.Location = new System.Drawing.Point(138, 21);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(75, 23);
this.button9.TabIndex = 13;
this.button9.Text = "下一个";
this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// button4
//
this.button4.Location = new System.Drawing.Point(219, 21);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(60, 23);
this.button4.TabIndex = 12;
this.button4.Text = "新增";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(285, 21);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(60, 23);
this.button3.TabIndex = 11;
this.button3.Text = "删除";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button5
//
this.button5.Location = new System.Drawing.Point(351, 21);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(60, 23);
this.button5.TabIndex = 10;
this.button5.Text = "编辑";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(97, 26);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(23, 12);
this.label1.TabIndex = 6;
this.label1.Text = "0/0";
//
// checkBox1
//
this.checkBox1.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.checkBox1.AutoSize = true;
this.checkBox1.Location = new System.Drawing.Point(1104, 24);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(72, 16);
this.checkBox1.TabIndex = 5;
this.checkBox1.Text = "创建新图";
this.checkBox1.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.button1.Location = new System.Drawing.Point(1182, 20);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 3;
this.button1.Text = "确定";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// 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, 71);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(139, 744);
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(7, 21);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(126, 717);
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList1.ImageSize = new System.Drawing.Size(64, 64);
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// groupBox5
//
this.groupBox5.Controls.Add(this.numericUpDown2);
this.groupBox5.Controls.Add(this.numericUpDown1);
this.groupBox5.Controls.Add(this.checkBox4);
this.groupBox5.Controls.Add(this.checkBox3);
this.groupBox5.Controls.Add(this.checkBox2);
this.groupBox5.Location = new System.Drawing.Point(158, 443);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(200, 74);
this.groupBox5.TabIndex = 11;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "处理细节";
//
// numericUpDown2
//
this.numericUpDown2.Location = new System.Drawing.Point(129, 41);
this.numericUpDown2.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.numericUpDown2.Name = "numericUpDown2";
this.numericUpDown2.Size = new System.Drawing.Size(40, 21);
this.numericUpDown2.TabIndex = 6;
this.numericUpDown2.Tag = "max";
this.numericUpDown2.ValueChanged += new System.EventHandler(this.numericUpDown2_ValueChanged);
//
// numericUpDown1
//
this.numericUpDown1.Location = new System.Drawing.Point(84, 41);
this.numericUpDown1.Maximum = new decimal(new int[] {
2147483647,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(40, 21);
this.numericUpDown1.TabIndex = 5;
this.numericUpDown1.Tag = "min";
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
//
// checkBox4
//
this.checkBox4.AutoSize = true;
this.checkBox4.Location = new System.Drawing.Point(7, 44);
this.checkBox4.Name = "checkBox4";
this.checkBox4.Size = new System.Drawing.Size(72, 16);
this.checkBox4.TabIndex = 2;
this.checkBox4.Text = "碎屑删除";
this.checkBox4.UseVisualStyleBackColor = true;
//
// checkBox3
//
this.checkBox3.AutoSize = true;
this.checkBox3.Location = new System.Drawing.Point(119, 20);
this.checkBox3.Name = "checkBox3";
this.checkBox3.Size = new System.Drawing.Size(72, 16);
this.checkBox3.TabIndex = 1;
this.checkBox3.Text = "孔洞填充";
this.checkBox3.UseVisualStyleBackColor = true;
//
// checkBox2
//
this.checkBox2.AutoSize = true;
this.checkBox2.Location = new System.Drawing.Point(7, 20);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(96, 16);
this.checkBox2.TabIndex = 0;
this.checkBox2.Text = "删除边界对象";
this.checkBox2.UseVisualStyleBackColor = true;
//
// groupBox6
//
this.groupBox6.Controls.Add(this.radioButton2);
this.groupBox6.Controls.Add(this.radioButton1);
this.groupBox6.Location = new System.Drawing.Point(158, 225);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(200, 46);
this.groupBox6.TabIndex = 12;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "二值样式";
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(70, 20);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(47, 16);
this.radioButton2.TabIndex = 1;
this.radioButton2.Text = "边线";
this.radioButton2.UseVisualStyleBackColor = true;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(7, 20);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(47, 16);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "实心";
this.radioButton1.UseVisualStyleBackColor = true;
//
// groupBox7
//
this.groupBox7.Controls.Add(this.button15);
this.groupBox7.Controls.Add(this.button14);
this.groupBox7.Controls.Add(this.button13);
this.groupBox7.Controls.Add(this.numericUpDown7);
this.groupBox7.Controls.Add(this.numericUpDown8);
this.groupBox7.Controls.Add(this.label6);
this.groupBox7.Controls.Add(this.numericUpDown5);
this.groupBox7.Controls.Add(this.numericUpDown6);
this.groupBox7.Controls.Add(this.label5);
this.groupBox7.Controls.Add(this.numericUpDown3);
this.groupBox7.Controls.Add(this.numericUpDown4);
this.groupBox7.Controls.Add(this.label2);
this.groupBox7.Controls.Add(this.radioButton12);
this.groupBox7.Controls.Add(this.radioButton13);
this.groupBox7.Location = new System.Drawing.Point(158, 685);
this.groupBox7.Name = "groupBox7";
this.groupBox7.Size = new System.Drawing.Size(200, 130);
this.groupBox7.TabIndex = 13;
this.groupBox7.TabStop = false;
this.groupBox7.Text = "设置";
//
// button15
//
this.button15.Location = new System.Drawing.Point(134, 99);
this.button15.Name = "button15";
this.button15.Size = new System.Drawing.Size(34, 21);
this.button15.TabIndex = 34;
this.button15.Text = "B";
this.button15.UseVisualStyleBackColor = true;
this.button15.Click += new System.EventHandler(this.button15_Click);
//
// button14
//
this.button14.Location = new System.Drawing.Point(134, 72);
this.button14.Name = "button14";
this.button14.Size = new System.Drawing.Size(34, 21);
this.button14.TabIndex = 33;
this.button14.Text = "G";
this.button14.UseVisualStyleBackColor = true;
this.button14.Click += new System.EventHandler(this.button14_Click);
//
// button13
//
this.button13.BackColor = System.Drawing.SystemColors.Control;
this.button13.Location = new System.Drawing.Point(134, 45);
this.button13.Margin = new System.Windows.Forms.Padding(0);
this.button13.Name = "button13";
this.button13.Size = new System.Drawing.Size(34, 21);
this.button13.TabIndex = 32;
this.button13.Text = "R";
this.button13.UseVisualStyleBackColor = true;
this.button13.Click += new System.EventHandler(this.button13_Click);
//
// numericUpDown7
//
this.numericUpDown7.Location = new System.Drawing.Point(82, 99);
this.numericUpDown7.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown7.Name = "numericUpDown7";
this.numericUpDown7.Size = new System.Drawing.Size(40, 21);
this.numericUpDown7.TabIndex = 30;
this.numericUpDown7.Tag = "max";
this.numericUpDown7.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
//
// numericUpDown8
//
this.numericUpDown8.Location = new System.Drawing.Point(37, 99);
this.numericUpDown8.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown8.Name = "numericUpDown8";
this.numericUpDown8.Size = new System.Drawing.Size(40, 21);
this.numericUpDown8.TabIndex = 29;
this.numericUpDown8.Tag = "min";
this.numericUpDown8.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(10, 103);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(23, 12);
this.label6.TabIndex = 31;
this.label6.Text = "B:";
//
// numericUpDown5
//
this.numericUpDown5.Location = new System.Drawing.Point(82, 72);
this.numericUpDown5.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown5.Name = "numericUpDown5";
this.numericUpDown5.Size = new System.Drawing.Size(40, 21);
this.numericUpDown5.TabIndex = 27;
this.numericUpDown5.Tag = "max";
this.numericUpDown5.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
//
// numericUpDown6
//
this.numericUpDown6.Location = new System.Drawing.Point(37, 72);
this.numericUpDown6.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown6.Name = "numericUpDown6";
this.numericUpDown6.Size = new System.Drawing.Size(40, 21);
this.numericUpDown6.TabIndex = 26;
this.numericUpDown6.Tag = "min";
this.numericUpDown6.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(10, 76);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(23, 12);
this.label5.TabIndex = 28;
this.label5.Text = "G:";
//
// numericUpDown3
//
this.numericUpDown3.Location = new System.Drawing.Point(82, 45);
this.numericUpDown3.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown3.Name = "numericUpDown3";
this.numericUpDown3.Size = new System.Drawing.Size(40, 21);
this.numericUpDown3.TabIndex = 8;
this.numericUpDown3.Tag = "max";
this.numericUpDown3.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
//
// numericUpDown4
//
this.numericUpDown4.Location = new System.Drawing.Point(37, 45);
this.numericUpDown4.Maximum = new decimal(new int[] {
255,
0,
0,
0});
this.numericUpDown4.Name = "numericUpDown4";
this.numericUpDown4.Size = new System.Drawing.Size(40, 21);
this.numericUpDown4.TabIndex = 7;
this.numericUpDown4.Tag = "min";
this.numericUpDown4.ValueChanged += new System.EventHandler(this.RGBoRHLSValue_Changed);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(10, 49);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(23, 12);
this.label2.TabIndex = 25;
this.label2.Text = "R:";
//
// radioButton12
//
this.radioButton12.AutoSize = true;
this.radioButton12.Location = new System.Drawing.Point(66, 20);
this.radioButton12.Name = "radioButton12";
this.radioButton12.Size = new System.Drawing.Size(41, 16);
this.radioButton12.TabIndex = 4;
this.radioButton12.Text = "HLS";
this.radioButton12.UseVisualStyleBackColor = true;
this.radioButton12.CheckedChanged += new System.EventHandler(this.radioButton12_CheckedChanged);
//
// radioButton13
//
this.radioButton13.AutoSize = true;
this.radioButton13.Checked = true;
this.radioButton13.Location = new System.Drawing.Point(7, 20);
this.radioButton13.Name = "radioButton13";
this.radioButton13.Size = new System.Drawing.Size(41, 16);
this.radioButton13.TabIndex = 3;
this.radioButton13.TabStop = true;
this.radioButton13.Text = "RGB";
this.radioButton13.UseVisualStyleBackColor = true;
this.radioButton13.CheckedChanged += new System.EventHandler(this.radioButton13_CheckedChanged);
//
// groupBox1
//
this.groupBox1.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.groupBox1.Location = new System.Drawing.Point(364, 70);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(910, 745);
this.groupBox1.TabIndex = 14;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "预览";
//
// groupBox12
//
this.groupBox12.Controls.Add(this.numericUpDown9);
this.groupBox12.Controls.Add(this.trackBar1);
this.groupBox12.Controls.Add(this.label9);
this.groupBox12.Location = new System.Drawing.Point(158, 120);
this.groupBox12.Name = "groupBox12";
this.groupBox12.Size = new System.Drawing.Size(200, 96);
this.groupBox12.TabIndex = 25;
this.groupBox12.TabStop = false;
this.groupBox12.Text = "定义物体";
this.groupBox12.Visible = false;
//
// numericUpDown9
//
this.numericUpDown9.Location = new System.Drawing.Point(53, 27);
this.numericUpDown9.Name = "numericUpDown9";
this.numericUpDown9.Size = new System.Drawing.Size(127, 21);
this.numericUpDown9.TabIndex = 26;
//
// trackBar1
//
this.trackBar1.AutoSize = false;
this.trackBar1.Location = new System.Drawing.Point(1, 58);
this.trackBar1.Maximum = 100;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(188, 25);
this.trackBar1.TabIndex = 25;
this.trackBar1.TickStyle = System.Windows.Forms.TickStyle.None;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(6, 32);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(0, 12);
this.label9.TabIndex = 21;
//
// groupBox8
//
this.groupBox8.Controls.Add(this.histogramControl1);
this.groupBox8.Location = new System.Drawing.Point(158, 523);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Size = new System.Drawing.Size(200, 156);
this.groupBox8.TabIndex = 14;
this.groupBox8.TabStop = false;
this.groupBox8.Text = "直方图";
//
// histogramControl1
//
this.histogramControl1.Flag = 1;
this.histogramControl1.Location = new System.Drawing.Point(6, 21);
this.histogramControl1.Name = "histogramControl1";
this.histogramControl1.Size = new System.Drawing.Size(188, 129);
this.histogramControl1.TabIndex = 0;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.radioButton3);
this.groupBox3.Controls.Add(this.radioButton4);
this.groupBox3.Location = new System.Drawing.Point(158, 71);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(200, 46);
this.groupBox3.TabIndex = 21;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "提取模式";
//
// radioButton3
//
this.radioButton3.AutoSize = true;
this.radioButton3.Location = new System.Drawing.Point(84, 20);
this.radioButton3.Name = "radioButton3";
this.radioButton3.Size = new System.Drawing.Size(71, 16);
this.radioButton3.TabIndex = 1;
this.radioButton3.Text = "单个目标";
this.radioButton3.UseVisualStyleBackColor = true;
//
// radioButton4
//
this.radioButton4.AutoSize = true;
this.radioButton4.Checked = true;
this.radioButton4.Location = new System.Drawing.Point(7, 20);
this.radioButton4.Name = "radioButton4";
this.radioButton4.Size = new System.Drawing.Size(71, 16);
this.radioButton4.TabIndex = 0;
this.radioButton4.TabStop = true;
this.radioButton4.Text = "整个图像";
this.radioButton4.UseVisualStyleBackColor = true;
//
// groupBox9
//
this.groupBox9.Controls.Add(this.panel1);
this.groupBox9.Controls.Add(this.userTextBox2);
this.groupBox9.Controls.Add(this.userTextBox1);
this.groupBox9.Controls.Add(this.label4);
this.groupBox9.Controls.Add(this.label3);
this.groupBox9.Controls.Add(this.radioButton5);
this.groupBox9.Controls.Add(this.radioButton6);
this.groupBox9.Location = new System.Drawing.Point(158, 123);
this.groupBox9.Name = "groupBox9";
this.groupBox9.Size = new System.Drawing.Size(200, 96);
this.groupBox9.TabIndex = 22;
this.groupBox9.TabStop = false;
//
// panel1
//
this.panel1.Controls.Add(this.radioButton16);
this.panel1.Controls.Add(this.radioButton15);
this.panel1.Controls.Add(this.radioButton14);
this.panel1.Location = new System.Drawing.Point(6, 41);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(174, 47);
this.panel1.TabIndex = 25;
this.panel1.Visible = false;
//
// radioButton16
//
this.radioButton16.AutoSize = true;
this.radioButton16.Location = new System.Drawing.Point(115, 16);
this.radioButton16.Name = "radioButton16";
this.radioButton16.Size = new System.Drawing.Size(14, 13);
this.radioButton16.TabIndex = 2;
this.radioButton16.TabStop = true;
this.radioButton16.UseVisualStyleBackColor = true;
//
// radioButton15
//
this.radioButton15.AutoSize = true;
this.radioButton15.Location = new System.Drawing.Point(66, 16);
this.radioButton15.Name = "radioButton15";
this.radioButton15.Size = new System.Drawing.Size(14, 13);
this.radioButton15.TabIndex = 1;
this.radioButton15.TabStop = true;
this.radioButton15.UseVisualStyleBackColor = true;
//
// radioButton14
//
this.radioButton14.AutoSize = true;
this.radioButton14.Checked = true;
this.radioButton14.Location = new System.Drawing.Point(5, 16);
this.radioButton14.Name = "radioButton14";
this.radioButton14.Size = new System.Drawing.Size(14, 13);
this.radioButton14.TabIndex = 0;
this.radioButton14.TabStop = true;
this.radioButton14.UseVisualStyleBackColor = true;
//
// userTextBox2
//
this.userTextBox2.Location = new System.Drawing.Point(78, 41);
this.userTextBox2.Name = "userTextBox2";
this.userTextBox2.Size = new System.Drawing.Size(100, 21);
this.userTextBox2.TabIndex = 24;
this.userTextBox2.ValueChanged += new System.EventHandler(this.userTextBox2Change);
//
// userTextBox1
//
this.userTextBox1.Location = new System.Drawing.Point(78, 67);
this.userTextBox1.Name = "userTextBox1";
this.userTextBox1.Size = new System.Drawing.Size(100, 21);
this.userTextBox1.TabIndex = 23;
this.userTextBox1.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(6, 72);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(0, 12);
this.label4.TabIndex = 22;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 46);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(0, 12);
this.label3.TabIndex = 21;
//
// radioButton5
//
this.radioButton5.AutoSize = true;
this.radioButton5.Location = new System.Drawing.Point(60, 20);
this.radioButton5.Name = "radioButton5";
this.radioButton5.Size = new System.Drawing.Size(14, 13);
this.radioButton5.TabIndex = 1;
this.radioButton5.UseVisualStyleBackColor = true;
//
// radioButton6
//
this.radioButton6.AutoSize = true;
this.radioButton6.Checked = true;
this.radioButton6.Location = new System.Drawing.Point(7, 20);
this.radioButton6.Name = "radioButton6";
this.radioButton6.Size = new System.Drawing.Size(14, 13);
this.radioButton6.TabIndex = 0;
this.radioButton6.TabStop = true;
this.radioButton6.UseVisualStyleBackColor = true;
//
// groupBox10
//
this.groupBox10.Controls.Add(this.button18);
this.groupBox10.Controls.Add(this.button17);
this.groupBox10.Controls.Add(this.button16);
this.groupBox10.Controls.Add(this.radioButton9);
this.groupBox10.Controls.Add(this.radioButton7);
this.groupBox10.Controls.Add(this.radioButton8);
this.groupBox10.Location = new System.Drawing.Point(158, 357);
this.groupBox10.Name = "groupBox10";
this.groupBox10.Size = new System.Drawing.Size(200, 80);
this.groupBox10.TabIndex = 13;
this.groupBox10.TabStop = false;
this.groupBox10.Text = "目标选择";
//
// button18
//
this.button18.Location = new System.Drawing.Point(99, 24);
this.button18.Name = "button18";
this.button18.Size = new System.Drawing.Size(40, 40);
this.button18.TabIndex = 5;
this.button18.UseVisualStyleBackColor = true;
//
// button17
//
this.button17.Location = new System.Drawing.Point(53, 24);
this.button17.Name = "button17";
this.button17.Size = new System.Drawing.Size(40, 40);
this.button17.TabIndex = 4;
this.button17.UseVisualStyleBackColor = true;
//
// button16
//
this.button16.Location = new System.Drawing.Point(8, 24);
this.button16.Name = "button16";
this.button16.Size = new System.Drawing.Size(40, 40);
this.button16.TabIndex = 3;
this.button16.UseVisualStyleBackColor = true;
//
// radioButton9
//
this.radioButton9.AutoSize = true;
this.radioButton9.Location = new System.Drawing.Point(141, 58);
this.radioButton9.Name = "radioButton9";
this.radioButton9.Size = new System.Drawing.Size(14, 13);
this.radioButton9.TabIndex = 2;
this.radioButton9.UseVisualStyleBackColor = true;
this.radioButton9.Visible = false;
//
// radioButton7
//
this.radioButton7.AutoSize = true;
this.radioButton7.Location = new System.Drawing.Point(141, 36);
this.radioButton7.Name = "radioButton7";
this.radioButton7.Size = new System.Drawing.Size(14, 13);
this.radioButton7.TabIndex = 1;
this.radioButton7.UseVisualStyleBackColor = true;
this.radioButton7.Visible = false;
//
// radioButton8
//
this.radioButton8.AutoSize = true;
this.radioButton8.Checked = true;
this.radioButton8.Location = new System.Drawing.Point(141, 14);
this.radioButton8.Name = "radioButton8";
this.radioButton8.Size = new System.Drawing.Size(14, 13);
this.radioButton8.TabIndex = 0;
this.radioButton8.TabStop = true;
this.radioButton8.UseVisualStyleBackColor = true;
this.radioButton8.Visible = false;
//
// groupBox11
//
this.groupBox11.Controls.Add(this.button8);
this.groupBox11.Controls.Add(this.button7);
this.groupBox11.Controls.Add(this.button6);
this.groupBox11.Controls.Add(this.radioButton10);
this.groupBox11.Controls.Add(this.radioButton11);
this.groupBox11.Location = new System.Drawing.Point(158, 277);
this.groupBox11.Name = "groupBox11";
this.groupBox11.Size = new System.Drawing.Size(200, 74);
this.groupBox11.TabIndex = 13;
this.groupBox11.TabStop = false;
//
// button8
//
this.button8.Location = new System.Drawing.Point(124, 40);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(52, 23);
this.button8.TabIndex = 13;
this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button7
//
this.button7.Location = new System.Drawing.Point(66, 40);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(52, 23);
this.button7.TabIndex = 12;
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.button11_Click);
//
// button6
//
this.button6.Location = new System.Drawing.Point(8, 40);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(52, 23);
this.button6.TabIndex = 11;
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button12_Click);
//
// radioButton10
//
this.radioButton10.AutoSize = true;
this.radioButton10.Location = new System.Drawing.Point(70, 20);
this.radioButton10.Name = "radioButton10";
this.radioButton10.Size = new System.Drawing.Size(14, 13);
this.radioButton10.TabIndex = 1;
this.radioButton10.UseVisualStyleBackColor = true;
//
// radioButton11
//
this.radioButton11.AutoSize = true;
this.radioButton11.Checked = true;
this.radioButton11.Location = new System.Drawing.Point(7, 20);
this.radioButton11.Name = "radioButton11";
this.radioButton11.Size = new System.Drawing.Size(14, 13);
this.radioButton11.TabIndex = 0;
this.radioButton11.TabStop = true;
this.radioButton11.UseVisualStyleBackColor = true;
//
// groupBox13
//
this.groupBox13.Controls.Add(this.button2);
this.groupBox13.Controls.Add(this.button11);
this.groupBox13.Controls.Add(this.button12);
this.groupBox13.Location = new System.Drawing.Point(158, 277);
this.groupBox13.Name = "groupBox13";
this.groupBox13.Size = new System.Drawing.Size(200, 74);
this.groupBox13.TabIndex = 14;
this.groupBox13.TabStop = false;
this.groupBox13.Text = "目标处理";
this.groupBox13.Visible = false;
//
// button2
//
this.button2.Location = new System.Drawing.Point(124, 35);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(52, 23);
this.button2.TabIndex = 13;
this.button2.Text = "重置";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button8_Click);
//
// button11
//
this.button11.Location = new System.Drawing.Point(66, 35);
this.button11.Name = "button11";
this.button11.Size = new System.Drawing.Size(52, 23);
this.button11.TabIndex = 12;
this.button11.Text = "重做";
this.button11.UseVisualStyleBackColor = true;
this.button11.Click += new System.EventHandler(this.button11_Click);
//
// button12
//
this.button12.Location = new System.Drawing.Point(8, 35);
this.button12.Name = "button12";
this.button12.Size = new System.Drawing.Size(52, 23);
this.button12.TabIndex = 11;
this.button12.Text = "撤销";
this.button12.UseVisualStyleBackColor = true;
this.button12.Click += new System.EventHandler(this.button12_Click);
//
// PhaseExtractDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1286, 827);
this.Controls.Add(this.groupBox12);
this.Controls.Add(this.groupBox13);
this.Controls.Add(this.groupBox11);
this.Controls.Add(this.groupBox10);
this.Controls.Add(this.groupBox9);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox8);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.groupBox7);
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox2);
this.Name = "PhaseExtractDialog";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "物相提取";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.PhaseExtractDialog_FormClosing);
this.Load += new System.EventHandler(this.PhaseExtractDialog_Load);
this.Controls.SetChildIndex(this.groupBox2, 0);
this.Controls.SetChildIndex(this.groupBox4, 0);
this.Controls.SetChildIndex(this.groupBox5, 0);
this.Controls.SetChildIndex(this.groupBox6, 0);
this.Controls.SetChildIndex(this.groupBox7, 0);
this.Controls.SetChildIndex(this.groupBox1, 0);
this.Controls.SetChildIndex(this.groupBox8, 0);
this.Controls.SetChildIndex(this.groupBox3, 0);
this.Controls.SetChildIndex(this.groupBox9, 0);
this.Controls.SetChildIndex(this.groupBox10, 0);
this.Controls.SetChildIndex(this.groupBox11, 0);
this.Controls.SetChildIndex(this.groupBox13, 0);
this.Controls.SetChildIndex(this.groupBox12, 0);
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.groupBox7.ResumeLayout(false);
this.groupBox7.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown7)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown8)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown5)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown6)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown4)).EndInit();
this.groupBox12.ResumeLayout(false);
this.groupBox12.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown9)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.groupBox8.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox9.ResumeLayout(false);
this.groupBox9.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.userTextBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.userTextBox1)).EndInit();
this.groupBox10.ResumeLayout(false);
this.groupBox10.PerformLayout();
this.groupBox11.ResumeLayout(false);
this.groupBox11.PerformLayout();
this.groupBox13.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
///
/// 主控件
///
private AppWorkspace appWorkspace;
///
/// 公共按钮
///
private CommonControlButtons commonControlButtons;
///
/// 图像面板
///
private DocumentWorkspaceWindow documentWorkspace;
///
/// 步长 初始值1,依次增加
///
string stepLength = "001";
///
/// 参数类
///
private ParamObject action = new Data.Action.Action902();
///
/// 当前选择的相颜色
///
private int color = 0;
///
/// 当前选择的图片
///
private Mat mat;
private Mat mat1;
///
/// 当前选择的图片
///
private Mat imageMat;
///
/// 鼠标移动最后一次的坐标,换算后的
///
private int x, y;
///
/// 传递给计算函数的坐标
///
private int xn, yn;
///
/// 最后一次坐标,换算前的
///
private int ox, oy;
///
/// 当前相model
///
private PhaseModel model;
///
/// 当前相
///
private int currentPhase = 0;
///
/// 相个数
///
private int countPhase = 0;
///
/// 第一次双击的标记
///
private bool firstFlag = false;
///
/// 存在视场标记
///
private bool existViewFlag = false;
///
/// 循环时用来计算的
///
private byte maxB = 0, maxG = 0, maxR = 0;
///
/// 循环时用来计算的
///
private byte minB = 255, minG = 255, minR = 255;
///
/// 相颜色
///
private Vec4b b4;
///
/// 鼠标点击标记
///
private bool _mouseClick = false;
///
/// 当前使用轮廓的形状
///
private ContourParameters contourParameters;
///
/// 矩形或椭圆的外接矩形
///
private RectangleF rectangleF;
///
/// 多边形的点集合
///
private List points;
///
/// 容许值
///
private int tolerance = 0;
///
/// RGB/HLS 选中那个按钮,默认1=R/H 2=G/L 2=B/S
///
private int HistogramRGBSelect = 1;
///
/// 用于撤销恢复
///
private List steps = new List();
///
/// 用于记录当前的撤销恢复步骤
///
private int currentPosition = -1;
///
/// 用于标记是撤销重做,以免再次加入集合
///
private bool doOrRedo = false;
///
/// 选中的左侧list的下标
///
private int index = 0;
private int menuId;
#region 保存参数的model和key
private GrainSizeAnalysisModel analysisModel;
private const string ParamKey_ShowAll = "showAll";//显示全部
private const string ParamKey_NewPic = "newPic";//创建新图
private const string ParamKey_WholePic = "wholePic";//整个图像
private const string ParamKey_Click = "click";//点击
private const string ParamKey_CkValue = "ckValue";//点击容许值
private const string ParamKey_CkRange = "ckRange";//点击范围大小
private const string ParamKey_Outline = "outline";//轮廓
private const string ParamKey_OPolygon = "oPolygon";//轮廓多边形
private const string ParamKey_ORectangle = "oRectangle";//轮廓矩形
private const string ParamKey_OEllipse = "oEllipse";//轮廓椭圆
private const string ParamKey_Solid = "solid";//二值实心
private const string ParamKey_Outer = "outer";//二值边线
private const string ParamKey_Target1 = "target1";//目标选择1
private const string ParamKey_Target2 = "target2";//目标选择2
private const string ParamKey_Target3 = "target3";//目标选择3
private const string ParamKey_Boundary = "boundary";//处理细节-删除边界对象
private const string ParamKey_Holes = "holes";//处理细节-孔洞填充
private const string ParamKey_Detritus = "detritus";//处理细节-碎屑删除
private const string ParamKey_Single = "single";//单个目标
private const string ParamKey_SDeviation = "sDeviation";//单个目标-偏差
#endregion
///
/// 构造函数
///
/// 主空间
/// 标题
public PhaseExtractDialog(AppWorkspace appWorkspace, string dialogText, int menuId)
{
this.menuId = menuId;
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
this.analysisModel = analysisModelXml.cloneListParamModel(this.menuId);
foreach (var item in this.analysisModel.ListParam)
item.setValue();
InitializeComponent();
InitializeLanguageText();
//
// 设置Dialog属性
//
this.appWorkspace = appWorkspace;
this.Text = dialogText;
this.Icon = PdnInfo.AppIcon;
//
// 初始化目标选择的背景图
//
this.InitButtonBackgroundImage();
//
//初始化图像控件
//
this.documentWorkspace = new DocumentWorkspaceWindow(appWorkspace);
this.documentWorkspace.Dock = DockStyle.Fill;
this.documentWorkspace.HookMouseEvents();
this.documentWorkspace.AuxiliaryLineEnabled = false;
//移除所有事件
//this.documentWorkspace.SurfaceBox.RemoveMouseEvent();
documentWorkspace.panel.MouseDown += (s, e) => { _timeMD = DateTime.Now; };
this.documentWorkspace.panel.MouseMove += new MouseEventHandler(this.pictureBox1_MouseMove);
this.documentWorkspace.panel.Click += new EventHandler(this.pictureBox1_Click);
this.documentWorkspace.panel.Paint += new PaintEventHandler(this.pictureBox1_Paint);
this.documentWorkspace.PPhaseActionFinish += new EventHandler>>(this.defineProfile_Change);
//this.documentWorkspace.panel.MouseEnter += new EventHandler(this.pictureBox1_MouseEnter);
this.documentWorkspace.Visible = false;
this.groupBox1.Controls.Add(documentWorkspace);
//
//初始化操作按钮
//
this.commonControlButtons = new CommonControlButtons();
this.commonControlButtons.Dock = DockStyle.Top;
this.commonControlButtons.Height = 30;
this.commonControlButtons.HideZoomToWindowAndActualSize();
this.groupBox1.Controls.Add(commonControlButtons);
//
// 设置listview事件
//
this.listView1.SelectedIndexChanged += new EventHandler(this.ListViewSelectedIndexChanged);
InitData();
this.tolerance = (int)this.userTextBox2.Value;
this.button13.FlatStyle = FlatStyle.Flat;
this.button13.BackColor = Color.FromArgb(225, 225, 225);
this.button13.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
this.button13.FlatAppearance.BorderSize = 2;
InitHistogramDragEvent();
InitCommonButtonEvent();
/*
//初始化一个相
AddPhase("默认相", Color.Red.ToArgb());*/
this.Shown += new EventHandler(this.ShownChoiseItemAndInitData);
}
private void ShownChoiseItemAndInitData(object sender, EventArgs e)
{
//滚动到指定的行位置
this.listView1.EnsureVisible(index);
//初始化数据
this.imageMat = this.appWorkspace.DocumentWorkspaces[index].CompositionSurface.CreatedAliasedMat();
Document document = Document.FromImageMat(imageMat.Clone());
this.documentWorkspace.Document = document;
this.documentWorkspace.Visible = true;
this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[index].GraphicsList;
}
private void InitButtonBackgroundImage()
{
this.button16.FlatStyle = FlatStyle.Flat;
this.button16.FlatAppearance.BorderSize = 0;
this.button16.BackgroundImageLayout = ImageLayout.Zoom;
this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
this.button16.Click += new EventHandler(this.button16_click);
this.button17.FlatStyle = FlatStyle.Flat;
this.button17.FlatAppearance.BorderSize = 0;
this.button17.BackgroundImageLayout = ImageLayout.Zoom;
this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
this.button17.Click += new EventHandler(this.button17_click);
this.button18.FlatStyle = FlatStyle.Flat;
this.button18.FlatAppearance.BorderSize = 0;
this.button18.BackgroundImageLayout = ImageLayout.Zoom;
this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
this.button18.Click += new EventHandler(this.button18_click);
}
private void button16_click(object sender, EventArgs e)
{
this.radioButton8.Checked = true;
this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
}
private void button17_click(object sender, EventArgs e)
{
this.radioButton7.Checked = true;
this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
}
private void button18_click(object sender, EventArgs e)
{
this.radioButton9.Checked = true;
this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference;
this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
}
private void InitCommonButtonEvent()
{
this.commonControlButtons.zoomInButton.Click += new EventHandler(zoomInButton_Click);
this.commonControlButtons.zoomOutButton.Click += new EventHandler(zoomOutButton_Click);
this.commonControlButtons.zoomToWindowButton.Click += new EventHandler(zoomToWindowButton_Click);
this.commonControlButtons.actualSizeButton.Click += new EventHandler(actualSizeButton_Click);
this.commonControlButtons.pointerButton.Click += new EventHandler(pointerButton_Click);
this.commonControlButtons.mobileModeButton.Click += new EventHandler(mobileModeButton_Click);
}
private void zoomInButton_Click(object sender, EventArgs e)
{
if (this.imageMat != null)
this.documentWorkspace.ZoomIn();
}
private void zoomOutButton_Click(object sender, EventArgs e)
{
if (this.imageMat != null)
this.documentWorkspace.ZoomOut();
}
private void zoomToWindowButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ZoomBasis = ZoomBasis.FitToWindow;
}
private void actualSizeButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ZoomBasis = ZoomBasis.ScaleFactor;
this.documentWorkspace.ScaleFactor = ScaleFactor.OneToOne;
}
private void pointerButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.Pointer;
}
private void mobileModeButton_Click(object sender, EventArgs e)
{
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.MoveMode;
}
///
/// 直方图区间拖动事件
///
private void InitHistogramDragEvent()
{
this.histogramControl1.DragOneEventActionFinish += new EventHandler>(this.DragOneEvent);
this.histogramControl1.DragTwoEventActionFinish += new EventHandler>(this.DragTwoEvent);
this.histogramControl1.DragFiveEventActionFinish += new EventHandler>(this.DragFiveEvent);
}
///
/// 颜色区间1 截止值变化
///
///
///
private void DragTwoEvent(object sender, EventArgs e)
{
if (this.HistogramRGBSelect == 1)
{
this.numericUpDown3.Value = e.Data;
}
if (this.HistogramRGBSelect == 2)
{
this.numericUpDown5.Value = e.Data;
}
if (this.HistogramRGBSelect == 3)
{
this.numericUpDown7.Value = e.Data;
}
}
///
/// 颜色区间1 起始值变化
///
///
///
private void DragOneEvent(object sender, EventArgs e)
{
if (this.HistogramRGBSelect == 1)
{
this.numericUpDown4.Value = e.Data;
}
if (this.HistogramRGBSelect == 2)
{
this.numericUpDown6.Value = e.Data;
}
if (this.HistogramRGBSelect == 3)
{
this.numericUpDown8.Value = e.Data;
}
}
///
/// 拖拽直方图
///
///
///
private void DragFiveEvent(object sender, EventArgs e)
{
if (this.HistogramRGBSelect == 1)
{
this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown4.Value = e.Data[1];
this.numericUpDown3.Value = e.Data[0];
this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
}
if (this.HistogramRGBSelect == 2)
{
this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown6.Value = e.Data[1];
this.numericUpDown5.Value = e.Data[0];
this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
}
if (this.HistogramRGBSelect == 3)
{
this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown8.Value = e.Data[1];
this.numericUpDown7.Value = e.Data[0];
this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
}
this.RGBoRHLSValue_Changed(null, null);
}
///
/// 定义轮廓属性的改变事件
///
///
///
private void defineProfile_Change(object sender, EventArgs> e)
{
switch ((ContourParameters)Enum.Parse(typeof(ContourParameters), e.Data[0].ToString()))
{
case ContourParameters.Rectangle:
contourParameters = ContourParameters.Rectangle;
rectangleF = (RectangleF)e.Data[1];
defineProfile_Calc();
break;
case ContourParameters.Oval:
contourParameters = ContourParameters.Oval;
rectangleF = (RectangleF)e.Data[1];
defineProfile_Calc();
break;
case ContourParameters.Polygon:
contourParameters = ContourParameters.Polygon;
points = (List)e.Data[1];
defineProfile_Calc();
break;
}
}
///
/// 计算划取得区域的RGB最大最小值,并进行处理
///
private unsafe void defineProfile_Calc()
{
Mat mat = imageMat.Clone();
//获取最大最小值
mat.ForEachAsVec4b(DefineProfileForEachAsVec4b);
//对于存在视场,不存在进行不同操作
if (existViewFlag)
{
ImageActionWithView();
}
else
{
ImageActionNoView();
}
//添加到步骤中
SetPhaseModelRGBOrHLS();
}
private unsafe void DefineProfileForEachAsVec4b(Vec4b* value, int* position)
{
int y = position[0];
int x = position[1];
switch (contourParameters)
{
case ContourParameters.Rectangle:
if (rectangleF.Contains(x, y))
{
CalcMaxAndMin(value);
}
break;
case ContourParameters.Oval:
if (BaseTools.isPointInOval(new System.Drawing.Point(x, y),
new System.Drawing.PointF(rectangleF.X + rectangleF.Width / 2,
rectangleF.Y + rectangleF.Height / 2),
rectangleF.Width / 2,
rectangleF.Height / 2)
)
{
CalcMaxAndMin(value);
}
break;
case ContourParameters.Polygon:
contourParameters = ContourParameters.Polygon;
if (BaseTools.isPointInPolygon(new System.Drawing.Point(x, y), points))
{
CalcMaxAndMin(value);
}
break;
}
}
private unsafe void CalcMaxAndMin(Vec4b* value)
{
byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
byte vB = value->Item0;
byte vG = value->Item1;
byte vR = value->Item2;
int minb = (int)(vB - relativeValue);
int ming = (int)(vG - relativeValue);
int minr = (int)(vR - relativeValue);
int maxb = (int)(vB + relativeValue);
int maxg = (int)(vG + relativeValue);
int maxr = (int)(vR + relativeValue);
byte vBmin = (minb < 0) ? (byte)'\0' : (byte)minb;
byte vBmax = (maxb > 255) ? (byte)255 : (byte)maxb;
byte vGmin = (ming < 0) ? (byte)'\0' : (byte)ming;
byte vGmax = (maxg > 255) ? (byte)255 : (byte)maxg;
byte vRmin = (minr < 0) ? (byte)'\0' : (byte)minr;
byte vRmax = (maxr > 255) ? (byte)255 : (byte)maxr;
if (vBmax > maxB) maxB = vBmax;
if (vBmin < minB) minB = vBmin;
if (vGmax > maxG) maxG = vGmax;
if (vGmin < minG) minG = vGmin;
if (vRmax > maxR) maxR = vRmax;
if (vRmin < minR) minR = vRmin;
//if (tolerance > 0)
//{
// //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //minB = (minB < 0) ? (byte)'\0' : minB;
// //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //maxB = (maxB > 255) ? (byte)255 : maxB;
// //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //minG = (minG < 0) ? (byte)'\0' : minG;
// //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //maxG = (maxG > 255) ? (byte)255 : maxG;
// //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //minR = (minR < 0) ? (byte)'\0' : minR;
// //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //maxR = (maxR > 255) ? (byte)255 : maxR;
// //byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// int minb = (int)(minB - relativeValue);
// int ming = (int)(minG - relativeValue);
// int minr = (int)(minR - relativeValue);
// int maxb = (int)(maxB + relativeValue);
// int maxg = (int)(maxG + relativeValue);
// int maxr = (int)(maxR + relativeValue);
// //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// minB = (minb < 0) ? (byte)'\0' : (byte)minb;
// //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// maxB = (maxb > 255) ? (byte)255 : (byte)maxb;
// //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// minG = (ming < 0) ? (byte)'\0' : (byte)ming;
// //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// maxG = (maxg > 255) ? (byte)255 : (byte)maxg;
// //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// minR = (minr < 0) ? (byte)'\0' : (byte)minr;
// //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// maxR = (maxr > 255) ? (byte)255 : (byte)maxr;
//}
//byte vB = value->Item0;
//byte vG = value->Item1;
//byte vR = value->Item2;
//if (vB > maxB) maxB = vB;
//if (vB < minB) minB = vB;
//if (vG > maxG) maxG = vG;
//if (vG < minG) minG = vG;
//if (vR > maxR) maxR = vR;
//if (vR < minR) minR = vR;
//if (tolerance > 0)
//{
// //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //minB = (minB < 0) ? (byte)'\0' : minB;
// //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //maxB = (maxB > 255) ? (byte)255 : maxB;
// //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //minG = (minG < 0) ? (byte)'\0' : minG;
// //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //maxG = (maxG > 255) ? (byte)255 : maxG;
// //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //minR = (minR < 0) ? (byte)'\0' : minR;
// //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// //maxR = (maxR > 255) ? (byte)255 : maxR;
// byte relativeValue = (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// int minb = (int)(minB - relativeValue);
// int ming = (int)(minG - relativeValue);
// int minr = (int)(minR - relativeValue);
// int maxb = (int)(maxB + relativeValue);
// int maxg = (int)(maxG + relativeValue);
// int maxr = (int)(maxR + relativeValue);
// //minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// minB = (minb < 0) ? (byte)'\0' : (byte)minb;
// //maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// maxB = (maxb > 255) ? (byte)255 : (byte)maxb;
// //minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// minG = (ming < 0) ? (byte)'\0' : (byte)ming;
// //maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// maxG = (maxg > 255) ? (byte)255 : (byte)maxg;
// //minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// minR = (minr < 0) ? (byte)'\0' : (byte)minr;
// //maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
// maxR = (maxr > 255) ? (byte)255 : (byte)maxr;
//}
}
///
/// Load事件,初始化参数事件
///
///
///
private void PhaseExtractDialog_Load(object sender, EventArgs e)
{
//提取模式
this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
//定义物体
this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
this.radioButton6.CheckedChanged += new System.EventHandler(this.radioButton6_CheckedChanged);
//定义物体->点击->容许值
this.userTextBox2.ValueChanged += ((IntegerNumber)(this.action.Lists[0].choiseList[0].Lists[0].choiseList[0].Lists[0])).numberParam_ValueChanged;
//定义物体->点击->范围大小
this.userTextBox1.ValueChanged += ((IntegerNumber)(this.action.Lists[0].choiseList[0].Lists[0].choiseList[0].Lists[1])).numberParam_ValueChanged;
//定义物体->轮廓
this.radioButton14.CheckedChanged += new System.EventHandler(this.radioButton14_CheckedChanged);
this.radioButton15.CheckedChanged += new System.EventHandler(this.radioButton15_CheckedChanged);
this.radioButton16.CheckedChanged += new System.EventHandler(this.radioButton16_CheckedChanged);
//二值样式
this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
//目标处理
this.radioButton10.CheckedChanged += new System.EventHandler(this.radioButton10_CheckedChanged);
this.radioButton11.CheckedChanged += new System.EventHandler(this.radioButton11_CheckedChanged);
//目标选择
this.radioButton7.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
this.radioButton8.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
this.radioButton9.CheckedChanged += new System.EventHandler(this.objectSelect_CheckChanged);
////处理细节
//删除边界对象
this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
//孔洞填充
this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
//碎屑删除
this.checkBox4.CheckedChanged += new System.EventHandler(this.checkBox4_CheckedChanged);
//碎屑删除,面积范围
this.numericUpDown2.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[6]).numberScope_ValueChanged;
this.numericUpDown2.ValueChanged += this.applyButtonImpl;
this.numericUpDown1.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[6]).numberScope_ValueChanged;
this.numericUpDown1.ValueChanged += this.applyButtonImpl;
//RGB/HLS的值
this.numericUpDown4.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[0]).numberScope_ValueChanged;
this.numericUpDown3.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[0]).numberScope_ValueChanged;
this.numericUpDown6.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[1]).numberScope_ValueChanged;
this.numericUpDown5.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[1]).numberScope_ValueChanged;
this.numericUpDown8.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[2]).numberScope_ValueChanged;
this.numericUpDown7.ValueChanged += ((DecimalScope)this.action.Lists[0].choiseList[0].Lists[7].choiseList[0].Lists[2]).numberScope_ValueChanged;
//单个目标->容许值
this.numericUpDown9.ValueChanged += new System.EventHandler(this.numericUpDown9_ValueChanged);
this.trackBar1.ValueChanged += new System.EventHandler(this.trackBar1_ValueChanged);
GetListParamModel();
}
///
/// listView选择改变事件
///
///
///
private void ListViewSelectedIndexChanged(object sender, EventArgs e)
{
if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
{
this.appWorkspace.ActiveDocumentWorkspace = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index];
//清空相
this.documentWorkspace.PhaseModels.Clear();
this.currentPhase = 0;
this.countPhase = 0;
this.model = null;
this.panel2.BackColor = Color.Transparent;
this.label1.Text = this.currentPhase + "/" + this.countPhase;
this.documentWorkspace.Refresh();
//修改标记
this.firstFlag = false;
existViewFlag = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GraphicsList.IsExsitView();
imageMat = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].CompositionSurface.CreatedAliasedMat();
if (!existViewFlag)
mat = imageMat.Clone();
else
mat = PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion());
//如果是hls被选中
if (this.radioButton12.Checked)
{
mat = mat.CvtColor(ColorConversionCodes.BGR2HLS_FULL);
}
//创建新Document
Document document = Document.FromImageMat(imageMat.Clone());
this.documentWorkspace.Document = document;
this.documentWorkspace.Visible = true;
// TODO ZYH 这里需要根据业务判断,是否要copylist还是直接用?
this.documentWorkspace.GraphicsList = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GraphicsList;
//this.pictureBox1.BackgroundImage = map;
//this.applyButtonImpl(sender, e);
//清空所有相
this.documentWorkspace.PhaseModels.Clear();
//显示直方图
this.histogramControl1.CreateHistogram(this.imageMat, false, 187, 129, HistogramRGBSelect);
//添加一个默认相
//初始化一个相
AddPhase("默认相", Color.Red.ToArgb());
}
}
///
/// 初始化图片列表数据
///
public void InitData()
{
for (int i = 0; i < this.appWorkspace.DocumentWorkspaces.Length; i++)
{
this.imageList1.Images.Add("img" + i, this.appWorkspace.DocumentWorkspaces[i].CompositionSurface.Thumbnail);//.CreateAliasedBitmap()
this.listView1.Items.Add("", i);
this.listView1.Items[i].ImageIndex = i;
this.listView1.Items[i].Text = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
this.listView1.Items[i].Name = this.appWorkspace.DocumentWorkspaces[i].GetFriendlyName();
if (this.appWorkspace.DocumentWorkspaces[i].Equals(this.appWorkspace.ActiveDocumentWorkspace))
{
index = i;
}
}
//
// 初始化选中的数据
//
this.listView1.Items[index].Selected = true; //选中行
}
///
/// 创建新图片
///
///
private void OpenFileImpl()
{
if (imageMat != null)
{
DocumentWorkspace dw = this.appWorkspace.AddNewDocumentWorkspace();
dw.Document = Document.FromImageMat(imageMat.Clone());
// TODO ZYH 这里的图像名称,需要走系统的配置
dw.fileText = this.Text + "-00" + Startup.instance.step_length;
//获取图像对应标尺
dw.xmlSaveModel = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].xmlSaveModel;
dw.rules = this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].rules;
this.appWorkspace.ActiveDocumentWorkspace = dw;
//this.appWorkspace.ActiveDocumentWorkspace.PanelBottom.documentStrip.ShowPictures = false;
this.appWorkspace.ActiveDocumentWorkspace.PhaseModels = this.documentWorkspace.PhaseModels;
Startup.instance.step_length += 1;
this.appWorkspace.ActiveDocumentWorkspace.Refresh();
}
}
///
/// 应用
///
///
///
private void applyButtonImpl(object sender, EventArgs e)
{
if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
{
if (model != null && model.mat != null)
{
if (existViewFlag)
{
ImageActionWithView();
}
else
{
ImageActionNoView();
}
}
}
}
///
/// 实心
///
///
///
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
StringArray arr = (StringArray)action.Lists[0].choiseList[0].Lists[1];
arr.Value = StyleParameters.Solid;
this.applyButtonImpl(sender, e);
}
///
/// 边线
///
///
///
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
StringArray arr = (StringArray)action.Lists[0].choiseList[0].Lists[1];
arr.Value = StyleParameters.Sideline;
this.applyButtonImpl(sender, e);
}
///
/// 整个图像
///
///
///
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton4.Checked)
{
BooleanObject booleanObject0 = (BooleanObject)action.Lists[0].choiseList[0];
booleanObject0.Value = true;
BooleanObject booleanObject1 = (BooleanObject)action.Lists[0].choiseList[1];
booleanObject1.Value = false;
this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
this.groupBox12.Visible = false;
this.groupBox13.Visible = false;
this.groupBox5.Visible = true;
this.groupBox7.Visible = true;
this.groupBox8.Visible = true;
this.groupBox9.Visible = true;
this.groupBox11.Visible = true;
}
}
///
/// 容许值
///
///
///
private void userTextBox2Change(object sender, EventArgs e)
{
tolerance = (int)this.userTextBox2.Value;
}
///
/// 单个目标
///
///
///
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton3.Checked)
{
BooleanObject booleanObject0 = (BooleanObject)action.Lists[0].choiseList[0];
booleanObject0.Value = false;
BooleanObject booleanObject1 = (BooleanObject)action.Lists[0].choiseList[1];
booleanObject1.Value = true;
this.documentWorkspace.ActiveTool = DrawToolType.ColorPicker;
this.documentWorkspace.panel.Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.ColorPickerToolCursor.cur"));
this.groupBox5.Visible = false;
this.groupBox7.Visible = false;
this.groupBox8.Visible = false;
this.groupBox9.Visible = false;
this.groupBox11.Visible = false;
this.groupBox12.Visible = true;
this.groupBox13.Visible = true;
}
if (this.radioButton4.Checked)
{
this.documentWorkspace.panel.Cursor = Cursors.Default;
}
}
///
/// 上一个
///
///
///
private void button10_Click(object sender, EventArgs e)
{
if (this.currentPhase > 1)
{
this.checkBox5.Checked = false;
this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
this.currentPhase--;
this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
this.documentWorkspace.Refresh();
this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
this.label1.Text = this.currentPhase + "/" + this.countPhase;
this.SetRGBOrHLSNumericValue();
}
}
///
/// 下一个
///
///
///
private void button9_Click(object sender, EventArgs e)
{
if (this.currentPhase < this.countPhase)
{
this.checkBox5.Checked = false;
this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
this.currentPhase++;
this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
this.documentWorkspace.Refresh();
this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
this.label1.Text = this.currentPhase + "/" + this.countPhase;
this.SetRGBOrHLSNumericValue();
}
}
///
/// 切换上一个下一个的时候设置RGB/HLS区间的值
///
private void SetRGBOrHLSNumericValue()
{
this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
if (this.model.rgborhls == 1)
{
this.radioButton13.Checked = true;
this.numericUpDown4.Value = this.model.minB;
this.numericUpDown3.Value = this.model.maxB;
this.numericUpDown6.Value = this.model.minG;
this.numericUpDown5.Value = this.model.maxG;
this.numericUpDown8.Value = this.model.minR;
this.numericUpDown7.Value = this.model.maxR;
}
else if (this.model.rgborhls == 2)
{
this.radioButton12.Checked = true;
this.numericUpDown4.Value = this.model.minH;
this.numericUpDown3.Value = this.model.maxH;
this.numericUpDown6.Value = this.model.minL;
this.numericUpDown5.Value = this.model.maxL;
this.numericUpDown8.Value = this.model.minS;
this.numericUpDown7.Value = this.model.maxS;
}
switch (this.HistogramRGBSelect)
{
case 1:
//处理直方图
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
break;
case 2:
//处理直方图
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
break;
case 3:
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
break;
}
this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
}
///
/// 新增
///
///
///
private void button4_Click(object sender, EventArgs e)
{
if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
{
Color color = (this.documentWorkspace.phaseModels.Count > 0) ? BaseTools.GetRandomColor(Color.FromArgb(this.documentWorkspace.phaseModels[this.documentWorkspace.phaseModels.Count - 1].color)) : Color.Red;
using (AddPhaseDialog addPhaseDialog = new AddPhaseDialog(this, "相" + (this.documentWorkspace.phaseModels.Count + 1), color, false))
{
addPhaseDialog.StartPosition = FormStartPosition.CenterScreen;
addPhaseDialog.ShowDialog();
}
}
else
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text") + "!");
}
}
///
/// 删除
///
///
///
private void button3_Click(object sender, EventArgs e)
{
if (model != null)
{
if (MessageBox.Show(PdnResources.GetString("Menu.Confirmtodeletecurrentphase.text") + "?", PdnResources.GetString("Menu.Unrecoverableafterdeletion.text"), MessageBoxButtons.YesNo) == DialogResult.Yes)
{
//删除相
this.documentWorkspace.PhaseModels.Remove(model);
if (this.documentWorkspace.PhaseModels.Count > 0)
{
this.currentPhase--;
//如果当前的相不是第一个,就--
if (this.currentPhase == 0)
this.currentPhase++;
this.countPhase = this.documentWorkspace.PhaseModels.Count;
this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
}
else
{
this.currentPhase = 0;
this.countPhase = 0;
this.model = null;
}
if (this.currentPhase == 0)
this.panel2.BackColor = Color.Transparent;
else
this.panel2.BackColor = Color.FromArgb(this.model.color);
this.label1.Text = this.currentPhase + "/" + this.countPhase;
this.documentWorkspace.Refresh();
}
}
}
///
/// 编辑
///
///
///
private void button5_Click(object sender, EventArgs e)
{
if (model != null)
{
using (AddPhaseDialog addPhaseDialog = new AddPhaseDialog(this, model.name, Color.FromArgb(model.color), true))
{
addPhaseDialog.StartPosition = FormStartPosition.CenterScreen;
addPhaseDialog.ShowDialog();
}
}
}
///
/// 点击确定
///
///
///
private void button1_Click(object sender, EventArgs e)
{
if (this.listView1.SelectedItems != null && this.listView1.SelectedItems.Count > 0)
{
//生成新图-是
if (this.checkBox1.Checked)
{
this.OpenFileImpl();
}
else
{
if (this.documentWorkspace.PhaseModels.Count > 0)
{
List models = new List();
foreach (PhaseModel temp in this.documentWorkspace.PhaseModels)
{
PhaseModel model = new PhaseModel();
model.choise = temp.choise;
model.color = temp.color;
model.mat = temp.mat;
model.name = temp.name;
model.position = temp.position;
models.Add(model);
}
this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].PhaseModels = models;
this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].Refresh();
}
}
}
//this.Close();
}
///
/// RGB radio改变事件
///
///
///
private void radioButton13_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton13.Checked)
{
((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[0].Value = true;
((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[1].Value = false;
this.label2.Text = "R";
this.label5.Text = "G";
this.label6.Text = "B";
this.button13.Text = "R";
this.button14.Text = "G";
this.button15.Text = "B";
this.firstFlag = false;
this.numericUpDown3.Value = 0;
this.numericUpDown4.Value = 0;
this.numericUpDown5.Value = 0;
this.numericUpDown6.Value = 0;
this.numericUpDown7.Value = 0;
this.numericUpDown8.Value = 0;
this.mat = this.mat != null ? this.imageMat.Clone() : null;
//清空所有相,应该是清空相的内容
if (this.model != null)
{
this.model.mat = null;
this.model.rgborhls = 1;
}
this.documentWorkspace.Refresh();
//更新直方图
if (this.imageMat != null)
this.histogramControl1.CreateHistogram(this.imageMat, false, 187, 129, HistogramRGBSelect);
//this.documentWorkspace.PhaseModels.Clear();
}
}
///
/// HLS radio改变事件
///
///
///
private void radioButton12_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton12.Checked)
{
((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[0].Value = false;
((ChoiseArray)action.Lists[0].choiseList[0].Lists[7]).choiseList[1].Value = true;
this.label2.Text = "H";
this.label5.Text = "L";
this.label6.Text = "S";
this.button13.Text = "H";
this.button14.Text = "L";
this.button15.Text = "S";
this.firstFlag = false;
this.numericUpDown3.Value = 0;
this.numericUpDown4.Value = 0;
this.numericUpDown5.Value = 0;
this.numericUpDown6.Value = 0;
this.numericUpDown7.Value = 0;
this.numericUpDown8.Value = 0;
this.mat = this.mat != null ? this.mat.CvtColor(ColorConversionCodes.BGR2HLS_FULL) : null;
//清空所有相,应该是清空相的内容
if (this.model != null)
{
this.model.mat = null;
this.model.rgborhls = 2;
}
this.documentWorkspace.Refresh();
//更新直方图
if (this.mat != null)
{
this.histogramControl1.CreateHistogram(this.mat, false, 187, 129, HistogramRGBSelect);//###
}
}
}
///
/// 绘制
///
///
///
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if (this.mat != null)
{
if (x >= 0 && y >= 0 && x < this.documentWorkspace.CompositionSurface.Width && y < this.documentWorkspace.CompositionSurface.Height)
{
Vec3b a = mat.At(y, x);
string b = x + "," + y;
b += "\r\n" + "R:" + a.Item2;
b += "\r\n" + "G:" + a.Item1;
b += "\r\n" + "B:" + a.Item0;
e.Graphics.DrawString(b, new Font("宋体", 12), new SolidBrush(Color.Red), ox + 5, oy + 5);
}
}
}
///
/// surfaceBox双击事件
/// 目前是参考AxioVision
/// 应该是把每次选的点都取最高和最低的BGR
///
///
///
private unsafe void pictureBox1_Click(object sender, EventArgs e)
{
try
{
if (this.documentWorkspace.ActiveTool == DrawToolType.MoveMode)
return;
if (!this.radioButton3.Checked && !this.radioButton6.Checked)
{
return;
}
if (color == 0)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaphase.text"));
return;
}
if (mat == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectapicture.text"));
return;
}
//判断点击位置,是否是图片上
if (x >= 0 && y >= 0 && x < this.documentWorkspace.CompositionSurface.Width && y < this.documentWorkspace.CompositionSurface.Height)
{
//删除
if (this.radioButton10.Checked)
{
if (this.model.mat != null)
{
//当前相颜色
Color currentColor = Color.FromArgb(color);
b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
//如果存在视场 需要判断是否在视场内
if (existViewFlag)
{
if (!this.documentWorkspace.GetRegion().IsVisible(new System.Drawing.Point(x, y)))
{
return;
}
/*else
{
Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.GetFullSizeWithRegion();
mat = PaintDotNet.Camera.Tools.ToMat(bitmap);
}*/
}
//获取当前点击的点的rgb值或hls的值,根据容许值、范围大小取周围最大最小的值
//vec3b = mat.At(y, x);
//容许值
tolerance = (int)this.userTextBox2.Value;
//范围大小
int range = (int)this.userTextBox1.Value;
//对每个像素点的操作
byte* pixels = (byte*)mat.Data;
//循环范围大小内的所有点
//maxB = 0; minB = 255; maxG = 0; minG = 255; maxR = 0; minR = 255;
int y1 = (y - range) < 0 ? 0 : (y - range);
int x1 = (x - range) < 0 ? 0 : (x - range);
int hw = range * 2 + 1;
int nh = (y1 + hw) > this.documentWorkspace.CompositionSurface.Height ? this.documentWorkspace.CompositionSurface.Height : (y1 + hw);
int nw = (x1 + hw) > this.documentWorkspace.CompositionSurface.Width ? this.documentWorkspace.CompositionSurface.Width : (x1 + hw);
this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
Vec3b vec3B = mat.At(y, x);
byte b = vec3B.Item0;
byte g = vec3B.Item1;
byte r = vec3B.Item2;
if (b > this.numericUpDown8.Value && b < this.numericUpDown7.Value)
{
int b2 = (int)(-this.numericUpDown8.Value + this.numericUpDown7.Value) / 2;
if (b > b2)
{
maxB = b;
this.numericUpDown7.Value = maxB;
}
else
{
minB = b;
this.numericUpDown8.Value = minB;
}
}
if (g > this.numericUpDown6.Value && g < this.numericUpDown5.Value)
{
int g2 = (int)(-this.numericUpDown6.Value + this.numericUpDown5.Value) / 2;
if (g > g2)
{
maxG = g;
this.numericUpDown5.Value = maxG;
}
else
{
minG = g;
this.numericUpDown6.Value = minG;
}
}
if (r > this.numericUpDown4.Value && r < this.numericUpDown3.Value)
{
int r2 = (int)(-this.numericUpDown4.Value + this.numericUpDown3.Value) / 2;
if (r > r2)
{
maxR = r;
this.numericUpDown3.Value = maxR;
}
else
{
minR = r;
this.numericUpDown4.Value = minR;
}
}
if (tolerance > 0)
{
if (minB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
minB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
minB = 0;
if (255 - maxB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
maxB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
maxB = 255;
if (minG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
minG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
minG = 0;
if (255 - maxG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
maxG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
maxG = 255;
if (minR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
minR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
minR = 0;
if (255 - maxR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
maxR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
maxR = 255;
}
this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
xn = x;
yn = y;
//对于存在视场,不存在进行不同操作
if (existViewFlag)
{
ImageActionWithViewForDelete();
}
else
{
ImageActionNoViewForDelete();
}
if (this.radioButton4.Checked)
{
this.SetPhaseModelRGBOrHLS();
}
else if (this.radioButton3.Checked)
{
this.AddDictStepByClick();
}
this.UpdateHistogramStartAndEnd();
}
}
else
{
//当前相颜色
Color currentColor = Color.FromArgb(color);
b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
//如果存在视场 需要判断是否在视场内
if (existViewFlag)
{
if (!this.documentWorkspace.GetRegion().IsVisible(new System.Drawing.Point(x, y)))
{
return;
}
/*else
{
Bitmap bitmap = this.appWorkspace.ActiveDocumentWorkspace.GetFullSizeWithRegion();
mat = PaintDotNet.Camera.Tools.ToMat(bitmap);
}*/
}
//获取当前点击的点的rgb值或hls的值,根据容许值、范围大小取周围最大最小的值
//vec3b = mat.At(y, x);
//容许值
tolerance = (int)this.userTextBox2.Value;
//范围大小
int range = (int)this.userTextBox1.Value;
//对每个像素点的操作
byte* pixels = (byte*)mat.Data;
//循环范围大小内的所有点
maxB = 0; minB = 255; maxG = 0; minG = 255; maxR = 0; minR = 255;
int y1 = (y - range) < 0 ? 0 : (y - range);
int x1 = (x - range) < 0 ? 0 : (x - range);
int hw = range * 2 + 1;
int nh = (y1 + hw) > this.documentWorkspace.CompositionSurface.Height ? this.documentWorkspace.CompositionSurface.Height : (y1 + hw);
int nw = (x1 + hw) > this.documentWorkspace.CompositionSurface.Width ? this.documentWorkspace.CompositionSurface.Width : (x1 + hw);
for (int m = y1; m < nh; m++)
{
int offsetRow = m * this.documentWorkspace.CompositionSurface.Width;
for (int n = x1; n < nw; n++)
{
int offset = (offsetRow + n) * this.mat.Channels();
byte vB = pixels[offset];
byte vG = pixels[offset + 1];
byte vR = pixels[offset + 2];
if (vB > maxB) maxB = vB;
if (vB < minB) minB = vB;
if (vG > maxG) maxG = vG;
if (vG < minG) minG = vG;
if (vR > maxR) maxR = vR;
if (vR < minR) minR = vR;
}
}
if (tolerance > 0)
{
if (minB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
minB -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
minB = 0;
if (255 - maxB >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
maxB += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
maxB = 255;
if (minG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
minG -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
minG = 0;
if (255 - maxG >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
maxG += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
maxG = 255;
if (minR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
minR -= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
minR = 0;
if (255 - maxR >= (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2)))
maxR += (byte)((tolerance * 2) + Math.Round(tolerance * 1f / 2));
else
maxR = 255;
}
xn = x;
yn = y;
//对于存在视场,不存在进行不同操作
if (existViewFlag)
{
ImageActionWithView();
}
else
{
ImageActionNoView();
}
if (this.radioButton4.Checked)
{
this.SetPhaseModelRGBOrHLS();
}
else if (this.radioButton3.Checked)
{
this.AddDictStepByClick();
}
this.UpdateHistogramStartAndEnd();
}
}
}
catch (Exception e1)
{
System.Console.WriteLine(e1.ToString());
}
finally
{
if (mat1 != null && mat1.IsDisposed) mat1.Dispose();
}
}
private unsafe void DelForEachAsVec3b(Vec3b* value, int* position)
{
if (value->Item0 == 0 && value->Item1 == 0 && value->Item2 == 0)
{
this.model.mat.Set(position[0], position[1], new Vec4b(0, 0, 0, 0));
}
}
bool _working = false;
//鼠标按下时间
private DateTime _timeMD = DateTime.MaxValue;
///
/// 有视场的图像处理
///
private void ImageActionWithView()
{
if ((DateTime.Now - _timeMD).TotalMilliseconds > 150)
return;
if (_working) return;
_working = true;
//如果是整个图像
if (this.radioButton4.Checked && !this.doOrRedo)
this.CalcRGBOrHLSValue();
TransferProgressDialog.ShowDialog(
"物相提取", "正在进行物相提取,该过程可能执行较长时间请耐心等待......",
() =>
{
ImageActionWithView1();
_working = false;
});
}
private void ImageActionWithView1()
{
if (model == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
return;
}
//如果是整个图像
if (this.radioButton4.Checked)
{
//获取颜色区间
_mouseClick = true;
if (radioButton12.Checked) //hls
{
mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
this.imageMat.Clone(),
model, new System.Drawing.Point());
}
else
{
mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()), this.imageMat.Clone(), model, new System.Drawing.Point());
}
_mouseClick = false;
}
//如果是单个目标,参考单个提取
else if (this.radioButton3.Checked)
{
if (radioButton12.Checked) //hls
{
mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion()),
this.imageMat.Clone(),
model, new System.Drawing.Point(xn, yn));
}
else
{
mat1 = this.action.PerformProcess(mat, imageMat.Clone(), model, new System.Drawing.Point(xn, yn));
}
}
this.Invoke(new Action(() =>
{
Mat temp = new Mat();
mat1.CopyTo(temp);
model.mat = temp;
this.documentWorkspace.Refresh();
firstFlag = true;
}));
}
///
/// 无视场的图像处理
///
private void ImageActionNoView()
{
if (model == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
return;
}
//如果是整个图像
if (this.radioButton4.Checked)
{
//获取颜色区间
_mouseClick = true;
if (!this.doOrRedo)
this.CalcRGBOrHLSValue();
mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
_mouseClick = false;
}
//如果是单个目标,参考单个提取
else if (this.radioButton3.Checked)
{
mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(xn, yn));
}
Mat temp = new Mat();
mat1.CopyTo(temp);
model.mat = temp;
this.documentWorkspace.Refresh();
firstFlag = true;
}
private void ImageActionWithViewForDelete()
{
if (model == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
return;
}
//如果是整个图像
if (this.radioButton4.Checked)
{
//获取颜色区间
_mouseClick = true;
if (!this.doOrRedo)
//this.CalcRGBOrHLSValue();
if (radioButton12.Checked) //hls
{
mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()),
this.imageMat.Clone(),
model, new System.Drawing.Point());
}
else
{
mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.documentWorkspace.GetFullSizeWithRegion()), this.imageMat.Clone(), model, new System.Drawing.Point());
}
_mouseClick = false;
}
//如果是单个目标,参考单个提取
else if (this.radioButton3.Checked)
{
if (radioButton12.Checked) //hls
{
mat1 = this.action.PerformProcess(mat, PaintDotNet.Camera.Tools.ToMat(this.appWorkspace.DocumentWorkspaces[this.listView1.SelectedItems[0].Index].GetFullSizeWithRegion()),
this.imageMat.Clone(),
model, new System.Drawing.Point(xn, yn));
}
else
{
mat1 = this.action.PerformProcess(mat, imageMat.Clone(), model, new System.Drawing.Point(xn, yn));
}
}
Mat temp = new Mat();
mat1.CopyTo(temp);
model.mat = temp;
this.documentWorkspace.Refresh();
firstFlag = true;
}
private void ImageActionNoViewForDelete()
{
if (model == null)
{
MessageBox.Show(PdnResources.GetString("Menu.Pleasecreateaphasefirst.text"));
return;
}
//如果是整个图像
if (this.radioButton4.Checked)
{
//获取颜色区间
_mouseClick = true;
if (!this.doOrRedo)
//this.CalcRGBOrHLSValueForDelete();
mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
_mouseClick = false;
}
//如果是单个目标,参考单个提取
else if (this.radioButton3.Checked)
{
mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(xn, yn));
}
Mat temp = new Mat();
mat1.CopyTo(temp);
model.mat = temp;
this.documentWorkspace.Refresh();
firstFlag = true;
}
///
/// 鼠标进入pictureBox
///
///
///
private void pictureBox1_MouseEnter(object sender, EventArgs e)
{
this.documentWorkspace.panel.Cursor = new Cursor(PdnResources.GetResourceStream("Cursors.ColorPickerToolCursor.cur"));
}
private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
this.Cursor = Cursors.Default;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
ox = e.X;
oy = e.Y;
System.Drawing.Point point = this.documentWorkspace.GetScalePoint(new System.Drawing.Point(e.X, e.Y));
y = point.Y;
x = point.X;
this.documentWorkspace.Refresh();
}
///
/// 更新相
///
///
///
public void UpdatePhase(string name, int color)
{
this.model.name = name;
this.model.color = color;
Color currentColor = Color.FromArgb(color);
this.b4 = new Vec4b(currentColor.B, currentColor.G, currentColor.R, 255);
this.panel2.BackColor = currentColor;
//如果是整个图像
if (this.radioButton4.Checked)
{
this.mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
}
else
{
this.mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point(x, y));
}
Mat temp = new Mat();
this.mat1.CopyTo(temp);
this.model.mat = temp;
this.documentWorkspace.Refresh();
}
///
/// 新增相
///
///
///
public void AddPhase(string name, int color)
{
//设置之前的相都不绘制
if (!this.checkBox5.Checked)
{
for (int i = 0; i < this.documentWorkspace.PhaseModels.Count; i++)
{
this.documentWorkspace.PhaseModels[i].choise = false;
}
this.documentWorkspace.Refresh();
}
//标记初始化
this.firstFlag = false;
//创建并添加相
this.model = new PhaseModel();
this.model.choise = true;
this.model.mat = null;
this.model.color = color;
this.model.position = this.documentWorkspace.PhaseModels.Count + 1;
this.model.name = name;
this.documentWorkspace.PhaseModels.Add(model);
this.color = color;
this.panel2.BackColor = Color.FromArgb(color);
this.countPhase++;
this.currentPhase = this.countPhase;
this.label1.Text = this.countPhase + "/" + this.countPhase;
//处理rgb/hls界面
this.radioButton13.Checked = true;
this.numericUpDown4.Value = 0;
this.numericUpDown3.Value = 0;
this.numericUpDown6.Value = 0;
this.numericUpDown5.Value = 0;
this.numericUpDown8.Value = 0;
this.numericUpDown7.Value = 0;
//添加到步骤
MultiPhaseStepModel temp = new MultiPhaseStepModel();
temp.currentPhase = this.currentPhase;
this.steps.Add(temp);
this.currentPosition++;
}
///
/// 撤销
///
///
///
private void button12_Click(object sender, EventArgs e)
{
if (this.currentPosition <= 0)
return;
this.doOrRedo = true;
this.currentPosition--;
MultiPhaseStepModel temp = this.steps[this.currentPosition];
//判断相是否变化,相变化则进行切换
if (temp.currentPhase != this.currentPhase)
{
this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = false;
this.currentPhase = temp.currentPhase;
this.documentWorkspace.PhaseModels[this.currentPhase - 1].choise = true;
this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
this.documentWorkspace.Refresh();
this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
this.label1.Text = this.currentPhase + "/" + this.countPhase;
if (this.radioButton4.Checked)
this.SetRGBOrHLSNumericValue();
}
else
{
this.model.rgborhls = temp.rgborhls;
this.model.minR = temp.minR;
this.model.maxR = temp.maxR;
this.model.minG = temp.minG;
this.model.maxG = temp.maxG;
this.model.minB = temp.minB;
this.model.maxB = temp.maxB;
this.model.minH = temp.minH;
this.model.maxH = temp.maxH;
this.model.minL = temp.minL;
this.model.maxL = temp.maxL;
this.model.minS = temp.minS;
this.model.maxS = temp.maxS;
if (this.radioButton4.Checked)
this.SetRGBOrHLSNumericValue();
}
this.applyButtonImpl(null, null);
this.doOrRedo = false;
}
///
/// 重做
///
///
///
private void button11_Click(object sender, EventArgs e)
{
if (this.currentPosition >= this.steps.Count - 1)
return;
this.doOrRedo = true;
this.currentPosition++;
MultiPhaseStepModel temp = this.steps[this.currentPosition];
//判断相是否变化,相变化则进行切换
if (temp.currentPhase != this.currentPhase)
{
this.documentWorkspace.PhaseModels[this.currentPhase + 1].choise = false;
this.currentPhase = temp.currentPhase;
this.documentWorkspace.PhaseModels[this.currentPhase + 1].choise = true;
this.model = this.documentWorkspace.PhaseModels[this.currentPhase - 1];
this.documentWorkspace.Refresh();
this.panel2.BackColor = Color.FromArgb(this.documentWorkspace.PhaseModels[this.currentPhase - 1].color);
this.label1.Text = this.currentPhase + "/" + this.countPhase;
if (this.radioButton4.Checked)
this.SetRGBOrHLSNumericValue();
}
else
{
this.model.rgborhls = temp.rgborhls;
this.model.minR = temp.minR;
this.model.maxR = temp.maxR;
this.model.minG = temp.minG;
this.model.maxG = temp.maxG;
this.model.minB = temp.minB;
this.model.maxB = temp.maxB;
this.model.minH = temp.minH;
this.model.maxH = temp.maxH;
this.model.minL = temp.minL;
this.model.maxL = temp.maxL;
this.model.minS = temp.minS;
this.model.maxS = temp.maxS;
if (this.radioButton4.Checked)
this.SetRGBOrHLSNumericValue();
}
this.applyButtonImpl(null, null);
this.doOrRedo = false;
}
///
/// 重置
///
///
///
private void button8_Click(object sender, EventArgs e)
{
if (this.documentWorkspace.PhaseModels != null
&& this.currentPhase > 0)
{
this.documentWorkspace.PhaseModels[this.currentPhase - 1].mat = null;
this.numericUpDown4.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown3.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown6.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown5.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown8.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown7.ValueChanged -= this.RGBoRHLSValue_Changed;
this.numericUpDown8.Value = 0;
this.numericUpDown7.Value = 0;
this.numericUpDown6.Value = 0;
this.numericUpDown5.Value = 0;
this.numericUpDown4.Value = 0;
this.numericUpDown3.Value = 0;
//this.numericUpDown9.Value = 0;
this.maxB = 0;
this.minB = 255;
this.maxG = 0;
this.minG = 255;
this.maxR = 0;
this.minR = 255;
this.firstFlag = false;
this.numericUpDown4.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown3.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown6.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown5.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown8.ValueChanged += this.RGBoRHLSValue_Changed;
this.numericUpDown7.ValueChanged += this.RGBoRHLSValue_Changed;
this.documentWorkspace.Refresh();
}
//清空所有步骤
this.steps.Clear();
//设置当前步骤为-1
this.currentPosition = -1;
}
///
/// 删除边界对象
///
///
///
private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
BooleanObject choiseArray = (BooleanObject)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("deleteRect"));
choiseArray.Value = this.checkBox2.Checked;
this.applyButtonImpl(sender, e);
}
///
/// 孔洞填充
///
///
///
private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
action.Lists[0].choiseList[0].lists[4].Value = this.checkBox3.Checked;
this.applyButtonImpl(sender, e);
}
///
/// 碎屑删除
///
///
///
private void checkBox4_CheckedChanged(object sender, EventArgs e)
{
action.Lists[0].choiseList[0].lists[5].Value = this.checkBox4.Checked;
this.applyButtonImpl(sender, e);
}
///
/// 单个目标->偏差
///
///
///
private void numericUpDown9_ValueChanged(object sender, EventArgs e)
{
this.action.Lists[0].choiseList[1].Lists[0].Value = this.numericUpDown9.Value;
this.trackBar1.Value = (int)(this.numericUpDown9.Value);
}
///
/// 单个目标->偏差
///
///
///
private void trackBar1_ValueChanged(object sender, EventArgs e)
{
this.numericUpDown9.Value = this.trackBar1.Value;
this.action.Lists[0].choiseList[1].Lists[0].Value = this.trackBar1.Value;
//this.applyButtonImpl(sender, e);
}
///
/// 定义物体 - 轮廓
///
///
///
private void radioButton5_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton5.Checked)
{
ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
BooleanObject booleanObject1 = (BooleanObject)choiseArray.choiseList[1];
booleanObject1.Value = true;
BooleanObject booleanObject0 = (BooleanObject)choiseArray.choiseList[0];
booleanObject0.Value = false;
this.panel1.Visible = true;
this.radioButton14_CheckedChanged(null, null);
}
}
///
/// RGB/HLS的Button的R/H点击事件
///
///
///
private void button13_Click(object sender, EventArgs e)
{
this.HistogramRGBSelect = 1;
this.button13.FlatStyle = FlatStyle.Flat;
this.button13.BackColor = Color.FromArgb(225, 225, 225);
this.button13.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
this.button13.FlatAppearance.BorderSize = 1;
this.button14.FlatStyle = FlatStyle.Standard;
this.button14.BackColor = Control.DefaultBackColor;
this.button14.FlatAppearance.BorderColor = Control.DefaultBackColor;
this.button15.FlatStyle = FlatStyle.Standard;
this.button15.BackColor = Control.DefaultBackColor;
this.button15.FlatAppearance.BorderColor = Control.DefaultBackColor;
//处理直方图
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
}
///
/// RGB/HLS的Button的G/L点击事件
///
///
///
private void button14_Click(object sender, EventArgs e)
{
this.HistogramRGBSelect = 2;
this.button13.FlatStyle = FlatStyle.Standard;
this.button13.BackColor = Control.DefaultBackColor;
this.button13.FlatAppearance.BorderColor = Control.DefaultBackColor;
this.button14.FlatStyle = FlatStyle.Flat;
this.button14.BackColor = Color.FromArgb(225, 225, 225);
this.button14.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
this.button14.FlatAppearance.BorderSize = 1;
this.button15.FlatStyle = FlatStyle.Standard;
this.button15.BackColor = Control.DefaultBackColor;
this.button15.FlatAppearance.BorderColor = Control.DefaultBackColor;
//处理直方图
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
//this.histogramControl1.CreateHistogram(this.bitmap, false, 188, 129, HistogramRGBSelect);
}
///
/// RGB/HLS的Button的B/S点击事件
///
///
///
private void button15_Click(object sender, EventArgs e)
{
this.HistogramRGBSelect = 3;
this.button13.FlatStyle = FlatStyle.Standard;
this.button13.BackColor = Control.DefaultBackColor;
this.button13.FlatAppearance.BorderColor = Control.DefaultBackColor;
this.button14.FlatStyle = FlatStyle.Standard;
this.button14.BackColor = Control.DefaultBackColor;
this.button14.FlatAppearance.BorderColor = Control.DefaultBackColor;
this.button15.FlatStyle = FlatStyle.Flat;
this.button15.BackColor = Color.FromArgb(225, 225, 225);
this.button15.FlatAppearance.BorderColor = Color.FromArgb(0, 120, 215);
this.button15.FlatAppearance.BorderSize = 1;
//处理直方图
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
//this.histogramControl1.CreateHistogram(this.bitmap, false, 188, 129, HistogramRGBSelect);
}
///
/// 定义物体 - 点击
///
///
///
private void radioButton6_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton6.Checked)
{
ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
BooleanObject booleanObject1 = (BooleanObject)choiseArray.choiseList[1];
booleanObject1.Value = false;
BooleanObject booleanObject0 = (BooleanObject)choiseArray.choiseList[0];
booleanObject0.Value = true;
this.panel1.Visible = false;
this.documentWorkspace.ActiveTool = DrawToolType.Pointer;
}
}
///
/// 移除未完成的定义物体的轮廓的对象
///
///
///
private void PhaseExtractDialog_FormClosing(object sender, FormClosingEventArgs e)
{
this.documentWorkspace.GraphicsList.DeleteDrawClass(DrawClass.PhaseExtraction);
SaveDialogParam();
}
///
/// 定义物体 - 轮廓 - 多边形
///
///
///
private void radioButton14_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton5.Checked && this.radioButton14.Checked)
{
ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
choiseArray1.Value = ContourParameters.Polygon;
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.PPhasePolygon;
}
}
///
/// 定义物体 - 轮廓 - 矩形
///
///
///
private void radioButton15_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton5.Checked && this.radioButton15.Checked)
{
ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
choiseArray1.Value = ContourParameters.Rectangle;
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.PPhaseRectangle;
}
}
///
/// 定义物体 - 轮廓 - 椭圆
///
///
///
private void radioButton16_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton5.Checked && this.radioButton16.Checked)
{
ChoiseArray choiseArray = (ChoiseArray)action.Lists[0].choiseList[0].lists.Find(a => a.Key.Equals("defineObject"));
StringArray choiseArray1 = (StringArray)choiseArray.choiseList[1].lists[0];
choiseArray1.Value = ContourParameters.Oval;
this.documentWorkspace.ActiveTool = Annotation.Enum.DrawToolType.PPhaseOval;
}
}
///
/// RGB或HLS值变化
///
///
///
private void RGBoRHLSValue_Changed(object sender, EventArgs e)
{
if (!_mouseClick)
{
if (color == 0)
{
return;
}
if (mat == null)
{
return;
}
//处理直方图相关
this.UpdateHistogramStartAndEnd();
//修改当前model的rgb或hls
this.SetPhaseModelRGBOrHLS((NumericUpDown)sender);
this.applyButtonImpl(null, null);
/*mat1 = this.action.PerformProcess(mat, model, new System.Drawing.Point());
Mat temp = new Mat();
mat1.CopyTo(temp);
model.mat = temp;
this.documentWorkspace.Refresh();*/
}
}
///
/// 修改当前model的rgb或hls
///
private void SetPhaseModelRGBOrHLS(NumericUpDown numericUpDown = null)
{
if (this.model == null)
return;
if (this.radioButton13.Checked)
{
//修改当前model的值
this.model.minB = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown4")) ? (int)numericUpDown.Value : (int)this.numericUpDown4.Value;
this.model.maxB = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown3")) ? (int)numericUpDown.Value : (int)this.numericUpDown3.Value;
this.model.minG = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown6")) ? (int)numericUpDown.Value : (int)this.numericUpDown6.Value;
this.model.maxG = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown5")) ? (int)numericUpDown.Value : (int)this.numericUpDown5.Value;
this.model.minR = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown8")) ? (int)numericUpDown.Value : (int)this.numericUpDown8.Value;
this.model.maxR = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown7")) ? (int)numericUpDown.Value : (int)this.numericUpDown7.Value;
this.AddDictStep(1);
}
else if (this.radioButton12.Checked)
{
//修改当前model的值
this.model.minH = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown4")) ? (int)numericUpDown.Value : (int)this.numericUpDown4.Value;
this.model.maxH = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown3")) ? (int)numericUpDown.Value : (int)this.numericUpDown3.Value;
this.model.minL = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown6")) ? (int)numericUpDown.Value : (int)this.numericUpDown6.Value;
this.model.maxL = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown5")) ? (int)numericUpDown.Value : (int)this.numericUpDown5.Value;
this.model.minS = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown8")) ? (int)numericUpDown.Value : (int)this.numericUpDown8.Value;
this.model.maxS = (numericUpDown != null && numericUpDown.Name.Equals("numericUpDown7")) ? (int)numericUpDown.Value : (int)this.numericUpDown7.Value;
this.AddDictStep(2);
}
}
private void AddDictStepByClick()
{
MultiPhaseStepModel temp = new MultiPhaseStepModel();
temp.currentPhase = currentPhase;
temp.wholeorsingle = 2;
temp.point = new System.Drawing.Point(xn, yn);
this.steps.Add(temp);
this.currentPosition++;
}
///
/// 向字典内添加步骤
///
///
private void AddDictStep(int type)
{
if (this.doOrRedo)
return;
MultiPhaseStepModel temp = new MultiPhaseStepModel();
temp.currentPhase = currentPhase;
temp.rgborhls = type;
if (temp.rgborhls == 1)
{
temp.minR = this.model.minR;
temp.maxR = this.model.maxR;
temp.minG = this.model.minG;
temp.maxG = this.model.maxG;
temp.minB = this.model.minB;
temp.maxB = this.model.maxB;
}
else if (temp.rgborhls == 2)
{
temp.minH = this.model.minH;
temp.maxH = this.model.maxH;
temp.minL = this.model.minL;
temp.maxL = this.model.maxL;
temp.minS = this.model.minS;
temp.maxS = this.model.maxS;
}
this.steps.Add(temp);
this.currentPosition++;
}
///
/// 显示全部
///
///
///
private void checkBox5_CheckedChanged(object sender, EventArgs e)
{
if (this.checkBox5.Checked)
{
foreach (PhaseModel model in this.documentWorkspace.PhaseModels)
{
model.choise = true;
}
this.documentWorkspace.Refresh();
}
else
{
foreach (PhaseModel model in this.documentWorkspace.PhaseModels)
{
model.choise = false;
}
this.model.choise = true;
this.documentWorkspace.Refresh();
}
}
private void UpdateHistogramStartAndEnd()
{
if (this.HistogramRGBSelect == 1)
{
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown4.Value, (int)this.numericUpDown3.Value);
}
if (this.HistogramRGBSelect == 2)
{
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown6.Value, (int)this.numericUpDown5.Value);
}
if (this.HistogramRGBSelect == 3)
{
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
this.histogramControl1.UpdateVerticalBarWithOneScope((int)this.numericUpDown8.Value, (int)this.numericUpDown7.Value);
}
}
///
/// 鼠标点击的时候调用
///
private void CalcRGBOrHLSValue()
{
int rl = (int)this.numericUpDown4.Value; //r起
int rr = (int)this.numericUpDown3.Value; //r止
if (firstFlag)
{
this.numericUpDown4.Value = minR < rl ? minR : rl;
this.numericUpDown3.Value = rr > maxR ? rr : maxR;
}
else
{
this.numericUpDown4.Value = minR;
this.numericUpDown3.Value = maxR;
}
int gl = (int)this.numericUpDown6.Value; //g起
int gr = (int)this.numericUpDown5.Value; //g止
if (firstFlag)
{
this.numericUpDown6.Value = minG < gl ? minG : gl;
this.numericUpDown5.Value = gr > maxG ? gr : maxG;
}
else
{
this.numericUpDown6.Value = minG;
this.numericUpDown5.Value = maxG;
}
int bl = (int)this.numericUpDown8.Value; //b起
int br = (int)this.numericUpDown7.Value; //b止
if (firstFlag)
{
this.numericUpDown8.Value = minB < bl ? minB : bl;
this.numericUpDown7.Value = br > maxB ? br : maxB;
}
else
{
this.numericUpDown8.Value = minB;
this.numericUpDown7.Value = maxB;
}
}
private void CalcRGBOrHLSValueForDelete()
{
int rl = (int)this.numericUpDown4.Value; //r起
int rr = (int)this.numericUpDown3.Value; //r止
if (firstFlag)
{
this.numericUpDown4.Value = minR > rl ? minR : rl;
this.numericUpDown3.Value = rr < maxR ? rr : maxR;
}
else
{
this.numericUpDown4.Value = minR;
this.numericUpDown3.Value = maxR;
}
int gl = (int)this.numericUpDown6.Value; //g起
int gr = (int)this.numericUpDown5.Value; //g止
if (firstFlag)
{
this.numericUpDown6.Value = minG > gl ? minG : gl;
this.numericUpDown5.Value = gr < maxG ? gr : maxG;
}
else
{
this.numericUpDown6.Value = minG;
this.numericUpDown5.Value = maxG;
}
int bl = (int)this.numericUpDown8.Value; //b起
int br = (int)this.numericUpDown7.Value; //b止
if (firstFlag)
{
this.numericUpDown8.Value = minB > bl ? minB : bl;
this.numericUpDown7.Value = br < maxB ? br : maxB;
}
else
{
this.numericUpDown8.Value = minB;
this.numericUpDown7.Value = maxB;
}
}
///
/// 删除
///
///
///
private void radioButton10_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton10.Checked)
{
this.action.Lists[0].choiseList[0].lists[2].Value = ProcessingParameters.Delete;
}
}
///
/// 追加
///
///
///
private void radioButton11_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton11.Checked)
{
this.action.Lists[0].choiseList[0].lists[2].Value = ProcessingParameters.Add;
}
}
///
/// 目标选择
///
///
///
private void objectSelect_CheckChanged(object sender, EventArgs e)
{
if (this.radioButton8.Checked)
{
StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
choiseArray.Value = FieldOfViewParameters.One;
}
else if (this.radioButton7.Checked)
{
StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
choiseArray.Value = FieldOfViewParameters.Two;
}
else if (this.radioButton9.Checked)
{
StringArray choiseArray = (StringArray)action.Lists[0].choiseList[2];
choiseArray.Value = FieldOfViewParameters.Three;
}
this.applyButtonImpl(sender, e);
}
///
/// 碎屑删除 范围参数1
///
///
///
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
numericUpDown2.Value = Math.Max(numericUpDown2.Value, numericUpDown1.Value);
//参数改变
foreach (Args args in action.Lists)
{
if (args.Key == "scope4")
{
((List)args.Value)[0] = (double)numericUpDown1.Value;
((List)args.Value)[1] = (double)numericUpDown2.Value;
break;
}
}
}
///
/// 碎屑删除 范围参数2
///
///
///
private void numericUpDown2_ValueChanged(object sender, EventArgs e)
{
numericUpDown1.Value = Math.Min(numericUpDown1.Value, numericUpDown2.Value);
//参数改变
foreach (Args args in action.Lists)
{
if (args.Key == "scope4")
{
((List)args.Value)[0] = (double)numericUpDown1.Value;
((List)args.Value)[1] = (double)numericUpDown2.Value;
break;
}
}
}
#region 参数保存及提取
///
/// 保存参数的key,value和type
///
///
///
///
private void saveParamValue(string param_key, string param_value, int param_type)
{
bool foundItem = false;
foreach (var item in this.analysisModel.ListParam)
{
if (item.param_key.Equals(param_key) && item.menuId == this.menuId)
{
item.param_value = param_value;
item.setValue();
foundItem = true;
break;
}
}
if (!foundItem)
{
GrainSizeAnalysisModel analysisItem = new GrainSizeAnalysisModel();
analysisItem.menuId = this.menuId;
analysisItem.param_key = param_key;
analysisItem.param_type = param_type;
analysisItem.param_value = param_value;
analysisItem.setValue();
this.analysisModel.ListParam.Add(analysisItem);
}
}
///
/// 保存界面中的参数到model
///
private void saveDialogParamValues()
{
saveParamValue(ParamKey_ShowAll, this.checkBox5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//显示全部
saveParamValue(ParamKey_NewPic, this.checkBox1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//创建新图
saveParamValue(ParamKey_WholePic, this.radioButton4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//整个图像
saveParamValue(ParamKey_Click, this.radioButton6.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//整个图像
saveParamValue(ParamKey_CkValue, this.userTextBox2.Value.ToString(), (int)Base.Dtryt.Decimal);//单个目标
saveParamValue(ParamKey_CkRange, this.userTextBox1.Value.ToString(), (int)Base.Dtryt.Decimal);//整个图像
saveParamValue(ParamKey_Outline, this.radioButton5.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//轮廓
saveParamValue(ParamKey_OPolygon, this.radioButton14.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//多边形
saveParamValue(ParamKey_ORectangle, this.radioButton15.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//矩形
saveParamValue(ParamKey_OEllipse, this.radioButton16.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//椭圆
saveParamValue(ParamKey_Solid, this.radioButton1.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//二值实心
saveParamValue(ParamKey_Outer, this.radioButton2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//二值边线
saveParamValue(ParamKey_Target1, this.radioButton8.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择1
saveParamValue(ParamKey_Target2, this.radioButton7.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择2
saveParamValue(ParamKey_Target3, this.radioButton9.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//目标选择3
saveParamValue(ParamKey_Boundary, this.checkBox2.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-删除边界对象
saveParamValue(ParamKey_Holes, this.checkBox3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-孔洞填充
saveParamValue(ParamKey_Detritus, this.checkBox4.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//处理细节-碎屑删除
saveParamValue(ParamKey_Single, this.radioButton3.Checked ? "0" : "1", (int)Base.Dtryt.Boolean);//单个目标
saveParamValue(ParamKey_SDeviation, this.numericUpDown9.Value.ToString(), (int)Base.Dtryt.Decimal);//单个目标-偏差
}
///
/// 获取保存的参数
///
private void GetListParamModel()
{
if (this.analysisModel != null)
{
for (int i = 0; i < this.analysisModel.ListParam.Count; i++)
{
switch (this.analysisModel.ListParam[i].param_key)
{
case ParamKey_ShowAll:
this.checkBox5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
break;
case ParamKey_NewPic:
this.checkBox1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
break;
case ParamKey_WholePic:
this.radioButton4.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton4_CheckedChanged(null, null);
break;
//点击
case ParamKey_Click:
this.radioButton6.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton6_CheckedChanged(null, null);
break;
case ParamKey_CkValue:
this.userTextBox2.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
break;
case ParamKey_CkRange:
this.userTextBox1.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
break;
//轮廓
case ParamKey_Outline:
this.radioButton5.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton5_CheckedChanged(null,null);
break;
case ParamKey_OPolygon:
this.radioButton14.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//if(this.radioButton5.Checked && this.radioButton14.Checked)
// radioButton14_CheckedChanged(null, null);
break;
case ParamKey_ORectangle:
this.radioButton15.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//if (this.radioButton5.Checked && this.radioButton15.Checked)
//radioButton15_CheckedChanged(null, null);
break;
case ParamKey_OEllipse:
this.radioButton16.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//if (this.radioButton5.Checked && this.radioButton16.Checked)
//radioButton16_CheckedChanged(null, null);
break;
//二值样式和目标选择
case ParamKey_Solid:
this.radioButton1.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton1_CheckedChanged(null, null);
break;
case ParamKey_Outer:
this.radioButton2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton2_CheckedChanged(null, null);
break;
case ParamKey_Target1:
this.radioButton8.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton8_CheckedChanged(null, null);
break;
case ParamKey_Target2:
this.radioButton7.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton7_CheckedChanged(null, null);
break;
case ParamKey_Target3:
this.radioButton9.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton9_CheckedChanged(null, null);
break;
//处理细节
case ParamKey_Boundary:
this.checkBox2.Checked = (Boolean)this.analysisModel.ListParam[i].value;
break;
case ParamKey_Holes:
this.checkBox3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
break;
case ParamKey_Detritus:
this.checkBox4.Checked = (Boolean)this.analysisModel.ListParam[i].value;
break;
//单个处理
case ParamKey_Single:
this.radioButton3.Checked = (Boolean)this.analysisModel.ListParam[i].value;
//radioButton3_CheckedChanged(null, null);
break;
case ParamKey_SDeviation:
this.numericUpDown9.Value = decimal.Parse(this.analysisModel.ListParam[i].value.ToString());
//numericUpDown9_ValueChanged(null, null);
break;
}
}
BackgroundImageSwitch();
}
}
//目标切换
private void BackgroundImageSwitch()
{
if (this.radioButton8.Checked)
{
this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle1.png").Reference;
this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
}
if (this.radioButton7.Checked)
{
this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle2.png").Reference;
this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray3.png").Reference;
}
if (this.radioButton9.Checked)
{
this.button18.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyle3.png").Reference;
this.button16.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray1.png").Reference;
this.button17.BackgroundImage = PdnResources.GetImageResource("Images.BinaryExtractChoiseStyleGray2.png").Reference;
}
}
private void SaveDialogParam()
{
this.saveDialogParamValues();
//xml保存路径
string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\BinaryActionSaving\\ParameterSaving.xml";
GrainSizeAnalysisModel analysisModelXml = XmlSerializeHelper.DESerializer(FileOperationHelper.ReadStringFromFile(filePath, System.IO.FileMode.Open));
foreach (var analysisItem in this.analysisModel.ListParam)
{
bool foundItem = false;
foreach (var item in analysisModelXml.ListParam)
{
if (item.param_key.Equals(analysisItem.param_key) && item.menuId == analysisItem.menuId)
{
item.param_value = analysisItem.param_value;
foundItem = true;
break;
}
}
if (!foundItem)
analysisModelXml.ListParam.Add(analysisItem.cloneModel());
}
//按路径和名称保存xml文件
string userInfoXml = XmlSerializeHelper.XmlSerialize(analysisModelXml);
//保存xml
FileOperationHelper.WriteStringToFile(userInfoXml, filePath, System.IO.FileMode.Create);
}
#endregion
}
}