123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- namespace PaintDotNet.CustomControl
- {
- public partial class BinaryControl : UserControl
- {
- /// <summary>
- /// 画笔
- /// </summary>
- private Pen pen = new Pen(Color.Red);
- public GroupBox groupBox6;
- public Button button4;
- public Label label2;
- public Panel panel2;
- private RadioButton radioButton2;
- private RadioButton radioButton1;
- public GroupBox groupBox9;
- public CheckBox checkBox10;
- private HistogramControl histogramControl1;
- public DecimalScopeControl numberScopeControl3;
- public DecimalScopeControl numberScopeControl2;
- private DecimalScopeControl numberScopeControl1;
- private CheckBox checkBox5;
- public Button button7;
- public Button button6;
- public double scope1Start
- {
- get
- {
- return this.numberScopeControl1.minValue;
- }
- set
- {
- this.numberScopeControl1.minValue = value;
- }
- }
- public double scope1End
- {
- get
- {
- return this.numberScopeControl1.maxValue;
- }
- set
- {
- this.numberScopeControl1.maxValue = value;
- }
- }
- public double scope2Start
- {
- get
- {
- return this.numberScopeControl2.minValue;
- }
- set
- {
- this.numberScopeControl2.minValue = value;
- }
- }
- public double scope2End
- {
- get
- {
- return this.numberScopeControl2.maxValue;
- }
- set
- {
- this.numberScopeControl2.maxValue = value;
- }
- }
- public double scope3Start
- {
- get
- {
- return this.numberScopeControl3.minValue;
- }
- set
- {
- this.numberScopeControl3.minValue = value;
- }
- }
- public double scope3End
- {
- get
- {
- return this.numberScopeControl3.maxValue;
- }
- set
- {
- this.numberScopeControl3.maxValue = value;
- }
- }
- /// <summary>
- /// 是否勾选了二值化
- /// </summary>
- /// <returns></returns>
- public bool BinaryChecked
- {
- get
- {
- return checkBox10.Checked;
- }
- set
- {
- checkBox10.Checked = value;
- }
- }
- /// <summary>
- /// 是否勾选了显示原图
- /// </summary>
- /// <returns></returns>
- public bool OriginChecked
- {
- get
- {
- return checkBox5.Checked;
- }
- set
- {
- checkBox5.Checked = value;
- }
- }
- /// <summary>
- /// 公开的事件,执行读取参数的事件
- /// </summary>
- public event EventHandler BinaryGetParamAction;
- private void OnBinaryGetParamAction(object sender, EventArgs e)
- {
- if (BinaryGetParamAction != null)
- {
- BinaryGetParamAction(sender, e);
- }
- }
- /// <summary>
- /// 公开的事件,执行二值方法的事件
- /// </summary>
- public event EventHandler ApplyButtonImplAction;
- private void OnApplyButtonImplAction(object sender, EventArgs e)
- {
- if (ApplyButtonImplAction != null)
- {
- ApplyButtonImplAction(sender, e);
- }
- }
- /// <summary>
- /// 公开的事件,筛选按钮点击的事件
- /// </summary>
- public event EventHandler BinaryEditClickAction;
- private void OnBinaryEditClickAction()
- {
- if (BinaryEditClickAction != null)
- {
- BinaryEditClickAction(this, new EventArgs());
- }
- }
- /// <summary>
- /// 公开的事件,相颜色点击的事件
- /// </summary>
- public event EventHandler PanelColorClickAction;
- private void OnPanelColorClickAction()
- {
- if (PanelColorClickAction != null)//###20143
- {
- PanelColorClickAction(this, new EventArgs());
- }
- }
- /// <summary>
- /// 公开的事件
- /// </summary>
- public event EventHandler RadioButton1ChangedAction;
- private void OnRadioButton1ChangedAction()
- {
- if (RadioButton1ChangedAction != null)
- {
- RadioButton1ChangedAction(this, new EventArgs());
- }
- }
- public event EventHandler RadioButton2ChangedAction;
- private void OnRadioButton2ChangedAction()
- {
- if (RadioButton2ChangedAction != null)
- {
- RadioButton2ChangedAction(this, new EventArgs());
- }
- }
- public event EventHandler OriginCheckedChangedAction;
- private void OnOriginCheckedChangedAction()
- {
- if (OriginCheckedChangedAction != null)
- {
- OriginCheckedChangedAction(this, new EventArgs());
- }
- }
- public event EventHandler BinaryCheckedChangedAction;
- private void OnBinaryCheckedChangedAction()
- {
- if (BinaryCheckedChangedAction != null)
- {
- BinaryCheckedChangedAction(this, new EventArgs());
- }
- }
- public event EventHandler ScopeValue1ChangedAction;
- private void OnScopeValue1ChangedAction(object sender, EventArgs e)
- {
- if (ScopeValue1ChangedAction != null)
- {
- ScopeValue1ChangedAction(sender, e);
- }
- }
- public event EventHandler ScopeValue2ChangedAction;
- private void OnScopeValue2ChangedAction(object sender, EventArgs e)
- {
- if (ScopeValue2ChangedAction != null)
- {
- ScopeValue2ChangedAction(sender, e);
- }
- }
- public event EventHandler ScopeValue3ChangedAction;
- private void OnScopeValue3ChangedAction(object sender, EventArgs e)
- {
- if (ScopeValue3ChangedAction != null)
- {
- ScopeValue3ChangedAction(sender, e);
- }
- }
- /// <summary>
- /// 公开的事件,自动阈值按钮点击的事件
- /// </summary>
- public event EventHandler AutoThresClickAction;
- private void OnAutoThresClickAction()
- {
- if (AutoThresClickAction != null)
- {
- AutoThresClickAction(this, new EventArgs());
- }
- }
- public Color BinaryBackColor
- {
- get
- {
- return panel2.BackColor;
- }
- set
- {
- panel2.BackColor = value;
- }
- }
- public int BinaryStyle
- {
- get
- {
- return radioButton1.Checked ? 1 : 2;
- }
- set
- {
- if (value == 1) this.radioButton1.Checked = true;
- else if (value == 2) this.radioButton2.Checked = true;
- }
- }
- /// <summary>
- /// 公开的事件,反选按钮点击的事件
- /// </summary>
- public event EventHandler InverseClickAction;
- public int getInverseStyle()
- {
- return numberScopeControl2.Visible ? 2 : 1;
- }
- public void setInverseStyle(int style)
- {
- if (style == 1)
- {
- //隐藏控件
- this.numberScopeControl2.Visible = false;
- this.numberScopeControl3.Visible = false;
- this.button6.Text = PdnResources.GetString("Menu.inverse.text");
- }
- else if (style == 2)
- {
- this.numberScopeControl2.Visible = true;
- this.numberScopeControl3.Visible = true;
- this.button6.Text = PdnResources.GetString("Menu.Uncheck.text");
- }
- }
- public void OnInverseClickAction()
- {
- if (numberScopeControl2.Visible)
- {
- this.numberScopeControl1.minValue = this.numberScopeControl3.maxValue;
- this.numberScopeControl1.maxValue = this.numberScopeControl2.minValue;
- this.numberScopeControl2.Visible = false;
- this.numberScopeControl3.Visible = false;
- this.button6.Text = PdnResources.GetString("Menu.inverse.text");
- this.histogramControl1.Flag = 1;
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)(this.numberScopeControl1.minValue), (int)(this.numberScopeControl1.maxValue));
- }
- else
- {
- this.numberScopeControl3.minValue = 0;
- this.numberScopeControl3.maxValue = this.numberScopeControl1.minValue;
- this.numberScopeControl2.minValue = this.numberScopeControl1.maxValue;
- this.numberScopeControl2.maxValue = 255;
- this.numberScopeControl2.Visible = true;
- this.numberScopeControl3.Visible = true;
- this.button6.Text = PdnResources.GetString("Menu.Uncheck.text");
- this.histogramControl1.Flag = 2;
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithTwoScope(
- (int)(this.numberScopeControl3.minValue),
- (int)(this.numberScopeControl3.maxValue),
- (int)(this.numberScopeControl2.minValue),
- (int)(this.numberScopeControl2.maxValue)
- );
- }
- if (InverseClickAction != null)
- {
- InverseClickAction(this, new EventArgs());
- }
- }
- /// <summary>
- /// 公开的事件,第一条线拖拽的事件
- /// </summary>
- public event EventHandler<EventArgs<int>> DragOneEventActionFinish;
- private void OnDragOneEventActionFinish(int start)
- {
- if (DragOneEventActionFinish != null)
- {
- DragOneEventActionFinish(this, new EventArgs<int>(start));
- }
- }
- public event EventHandler<EventArgs<int>> DragTwoEventActionFinish;
- private void OnDragTwoEventActionFinish(int end)
- {
- if (DragTwoEventActionFinish != null)
- {
- DragTwoEventActionFinish(this, new EventArgs<int>(end));
- }
- }
- public event EventHandler<EventArgs<int>> DragThreeEventActionFinish;
- private void OnDragThreeEventActionFinish(int start1)
- {
- if (DragThreeEventActionFinish != null)
- {
- DragThreeEventActionFinish(this, new EventArgs<int>(start1));
- }
- }
- public event EventHandler<EventArgs<int>> DragFourEventActionFinish;
- private void OnDragFourEventActionFinish(int start1)
- {
- if (DragFourEventActionFinish != null)
- {
- DragFourEventActionFinish(this, new EventArgs<int>(start1));
- }
- }
- public BinaryControl()
- {
- InitializeComponent();
- InitializeLanguageText();
- }
- private void InitializeLanguageText()
- {
- this.groupBox6.Text = PdnResources.GetString("Menu.Binarystyle.text");
- this.button4.Text = PdnResources.GetString("Menu.filter.text");
- this.label2.Text = PdnResources.GetString("Menu.Phasecolor.text") + ":";
- this.radioButton2.Text = PdnResources.GetString("Menu.Sideline.text");
- this.radioButton1.Text = PdnResources.GetString("Menu.solid.text");
- this.groupBox9.Text = PdnResources.GetString("Menu.Tools.Histogram.Text");
- this.checkBox10.Text = PdnResources.GetString("Menu.Binarization.text");
- this.checkBox5.Text = PdnResources.GetString("Menu.Theoriginalcolor.text");
- this.button7.Text = PdnResources.GetString("Menu.Automaticthreshold.text");
- this.button6.Text = PdnResources.GetString("Menu.inverse.text");
- }
- private void InitializeComponent()
- {
- this.groupBox6 = new System.Windows.Forms.GroupBox();
- this.button4 = new System.Windows.Forms.Button();
- this.label2 = new System.Windows.Forms.Label();
- this.panel2 = new System.Windows.Forms.Panel();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.groupBox9 = new System.Windows.Forms.GroupBox();
- this.checkBox10 = new System.Windows.Forms.CheckBox();
- this.checkBox5 = new System.Windows.Forms.CheckBox();
- this.button7 = new System.Windows.Forms.Button();
- this.button6 = new System.Windows.Forms.Button();
- this.histogramControl1 = new PaintDotNet.CustomControl.HistogramControl();
- this.numberScopeControl3 = new PaintDotNet.CustomControl.DecimalScopeControl();
- this.numberScopeControl2 = new PaintDotNet.CustomControl.DecimalScopeControl();
- this.numberScopeControl1 = new PaintDotNet.CustomControl.DecimalScopeControl();
- this.groupBox6.SuspendLayout();
- this.groupBox9.SuspendLayout();
- this.SuspendLayout();
- //
- // groupBox6
- //
- this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox6.Controls.Add(this.button4);
- this.groupBox6.Controls.Add(this.label2);
- this.groupBox6.Controls.Add(this.panel2);
- this.groupBox6.Controls.Add(this.radioButton2);
- this.groupBox6.Controls.Add(this.radioButton1);
- this.groupBox6.Location = new System.Drawing.Point(2, 226);
- this.groupBox6.Margin = new System.Windows.Forms.Padding(0);
- this.groupBox6.Name = "groupBox6";
- this.groupBox6.Size = new System.Drawing.Size(356, 64);
- this.groupBox6.TabIndex = 22;
- this.groupBox6.TabStop = false;
- this.groupBox6.Text = "二值样式";
- //
- // button4
- //
- this.button4.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.button4.Location = new System.Drawing.Point(259, 29);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(75, 23);
- this.button4.TabIndex = 32;
- this.button4.Text = "筛选";
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(132, 34);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(47, 12);
- this.label2.TabIndex = 20;
- this.label2.Text = "相颜色:";
- //
- // panel2
- //
- this.panel2.BackColor = System.Drawing.Color.Red;
- this.panel2.Location = new System.Drawing.Point(182, 29);
- this.panel2.Name = "panel2";
- this.panel2.Size = new System.Drawing.Size(72, 21);
- this.panel2.TabIndex = 19;
- this.panel2.Click += new System.EventHandler(this.panel2_Click);
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(59, 32);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(47, 16);
- this.radioButton2.TabIndex = 1;
- this.radioButton2.Text = "边线";
- this.radioButton2.UseVisualStyleBackColor = true;
- this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Checked = true;
- this.radioButton1.Location = new System.Drawing.Point(7, 32);
- 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;
- this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
- //
- // groupBox9
- //
- this.groupBox9.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.groupBox9.Controls.Add(this.checkBox10);
- this.groupBox9.Controls.Add(this.histogramControl1);
- this.groupBox9.Controls.Add(this.numberScopeControl3);
- this.groupBox9.Controls.Add(this.numberScopeControl2);
- this.groupBox9.Controls.Add(this.numberScopeControl1);
- this.groupBox9.Controls.Add(this.checkBox5);
- this.groupBox9.Controls.Add(this.button7);
- this.groupBox9.Controls.Add(this.button6);
- this.groupBox9.Location = new System.Drawing.Point(2, 2);
- this.groupBox9.Margin = new System.Windows.Forms.Padding(0);
- this.groupBox9.Name = "groupBox9";
- this.groupBox9.Padding = new System.Windows.Forms.Padding(0);
- this.groupBox9.Size = new System.Drawing.Size(356, 218);
- this.groupBox9.TabIndex = 21;
- this.groupBox9.TabStop = false;
- this.groupBox9.Text = "直方图";
- //
- // checkBox10
- //
- this.checkBox10.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.checkBox10.AutoSize = true;
- this.checkBox10.Location = new System.Drawing.Point(208, 195);
- this.checkBox10.Name = "checkBox10";
- this.checkBox10.Size = new System.Drawing.Size(60, 16);
- this.checkBox10.TabIndex = 17;
- this.checkBox10.Text = "二值化";
- this.checkBox10.UseVisualStyleBackColor = true;
- this.checkBox10.CheckedChanged += new System.EventHandler(this.checkBox10_CheckedChanged);
- //
- // checkBox5
- //
- this.checkBox5.Anchor = System.Windows.Forms.AnchorStyles.Right;
- this.checkBox5.AutoSize = true;
- this.checkBox5.Location = new System.Drawing.Point(293, 195);
- this.checkBox5.Name = "checkBox5";
- this.checkBox5.Size = new System.Drawing.Size(48, 16);
- this.checkBox5.TabIndex = 11;
- this.checkBox5.Text = "原图";
- this.checkBox5.UseVisualStyleBackColor = true;
- this.checkBox5.CheckedChanged += new System.EventHandler(this.ShowOrHideOriginPic);
- //
- // button7
- //
- this.button7.Anchor = System.Windows.Forms.AnchorStyles.Left;
- this.button7.Location = new System.Drawing.Point(86, 191);
- this.button7.Name = "button7";
- this.button7.Size = new System.Drawing.Size(75, 23);
- this.button7.TabIndex = 12;
- this.button7.Text = "自动阈值";
- this.button7.UseVisualStyleBackColor = true;
- this.button7.Click += new System.EventHandler(this.button7_Click);
- //
- // button6
- //
- this.button6.Anchor = System.Windows.Forms.AnchorStyles.Left;
- this.button6.Location = new System.Drawing.Point(5, 191);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(75, 23);
- this.button6.TabIndex = 11;
- this.button6.Text = "反选";
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // histogramControl1
- //
- this.histogramControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
- | System.Windows.Forms.AnchorStyles.Right)));
- this.histogramControl1.Flag = 1;
- this.histogramControl1.Location = new System.Drawing.Point(5, 19);
- this.histogramControl1.Name = "histogramControl1";
- this.histogramControl1.Size = new System.Drawing.Size(340, 130);
- this.histogramControl1.TabIndex = 16;
- //
- // numberScopeControl3
- //
- this.numberScopeControl3.DecimalPlaces = 0;
- this.numberScopeControl3.Location = new System.Drawing.Point(8, 158);
- this.numberScopeControl3.Maximum = 255D;
- this.numberScopeControl3.maxValue = 0D;
- this.numberScopeControl3.Minimum = 0D;
- this.numberScopeControl3.minValue = 0D;
- this.numberScopeControl3.Name = "numberScopeControl3";
- this.numberScopeControl3.Size = new System.Drawing.Size(150, 22);
- this.numberScopeControl3.TabIndex = 15;
- this.numberScopeControl3.Visible = false;
- this.numberScopeControl3.ValueChanged += new System.EventHandler(this.OnScopeValue3ChangedAction);
- //
- // numberScopeControl2
- //
- this.numberScopeControl2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
- this.numberScopeControl2.DecimalPlaces = 0;
- this.numberScopeControl2.Location = new System.Drawing.Point(189, 155);
- this.numberScopeControl2.Maximum = 255D;
- this.numberScopeControl2.maxValue = 0D;
- this.numberScopeControl2.Minimum = 0D;
- this.numberScopeControl2.minValue = 0D;
- this.numberScopeControl2.Name = "numberScopeControl2";
- this.numberScopeControl2.Size = new System.Drawing.Size(150, 22);
- this.numberScopeControl2.TabIndex = 14;
- this.numberScopeControl2.Visible = false;
- this.numberScopeControl2.ValueChanged += new System.EventHandler(this.OnScopeValue2ChangedAction);
- //
- // numberScopeControl1
- //
- this.numberScopeControl1.DecimalPlaces = 0;
- this.numberScopeControl1.Location = new System.Drawing.Point(8, 158);
- this.numberScopeControl1.Maximum = 255D;
- this.numberScopeControl1.maxValue = 0D;
- this.numberScopeControl1.Minimum = 0D;
- this.numberScopeControl1.minValue = 0D;
- this.numberScopeControl1.Name = "numberScopeControl1";
- this.numberScopeControl1.Size = new System.Drawing.Size(150, 22);
- this.numberScopeControl1.TabIndex = 13;
- this.numberScopeControl1.Tag = "numberScopeControl1";
- this.numberScopeControl1.ValueChanged += new System.EventHandler(this.OnScopeValue1ChangedAction);
- //
- // BinaryControl
- //
- this.Controls.Add(this.groupBox6);
- this.Controls.Add(this.groupBox9);
- this.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
- this.Name = "BinaryControl";
- this.Size = new System.Drawing.Size(360, 292);
- this.groupBox6.ResumeLayout(false);
- this.groupBox6.PerformLayout();
- this.groupBox9.ResumeLayout(false);
- this.groupBox9.PerformLayout();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 筛选按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void button4_Click(object sender, EventArgs e)
- {
- OnBinaryEditClickAction();
- }
- /// <summary>
- /// 相颜色点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void panel2_Click(object sender, EventArgs e)
- {
- OnPanelColorClickAction();
- }
- /// <summary>
- /// 二值样式 边线选中事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton2_CheckedChanged(object sender, EventArgs e)
- {
- OnRadioButton2ChangedAction();
- }
- /// <summary>
- /// 二值样式 实心选中事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- OnRadioButton1ChangedAction();
- }
- private void ShowOrHideOriginPic(object sender, EventArgs e)
- {
- OnOriginCheckedChangedAction();
- }
- private void checkBox10_CheckedChanged(object sender, EventArgs e)
- {
- OnBinaryCheckedChangedAction();
- }
- public void button7_Click(object sender, EventArgs e)
- {
- OnAutoThresClickAction();
- }
- public void button6_Click(object sender, EventArgs e)
- {
- OnInverseClickAction();
- }
- /// <summary>
- /// 把参数的值设置到控件上
- /// </summary>
- public void InitParameterToControl(int ColorInterval = -1)
- {
- if (ColorInterval != -1 ? ColorInterval == 1 : this.getInverseStyle() == 1)
- {
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)(this.numberScopeControl1.minValue), (int)(this.numberScopeControl1.maxValue));
- }
- else
- {
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithTwoScope(
- (int)(this.numberScopeControl3.minValue),
- (int)(this.numberScopeControl3.maxValue),
- (int)(this.numberScopeControl2.minValue),
- (int)(this.numberScopeControl2.maxValue)
- );
- }
- }
- /// <summary>
- /// 颜色区间2 截止值变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DragFourEvent(object sender, EventArgs<int> e)
- {
- this.numberScopeControl2.maxValue = e.Data;
- }
- /// <summary>
- /// 颜色区间2 起始值变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DragThreeEvent(object sender, EventArgs<int> e)
- {
- this.numberScopeControl2.minValue = e.Data;
- }
- /// <summary>
- /// 颜色区间1 截止值变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DragTwoEvent(object sender, EventArgs<int> e)
- {
- if (this.getInverseStyle() == 1)
- {
- this.numberScopeControl1.maxValue = e.Data;
- }
- else if (this.getInverseStyle() == 2)
- {
- this.numberScopeControl3.maxValue = e.Data;
- }
- }
- /// <summary>
- /// 颜色区间1 起始值变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void DragOneEvent(object sender, EventArgs<int> e)
- {
- if (this.getInverseStyle() == 1)
- {
- this.numberScopeControl1.minValue = e.Data;
- }
- else if (this.getInverseStyle() == 2)
- {
- this.numberScopeControl3.minValue = e.Data;
- }
- }
- private void DragFiveEvent(object sender, EventArgs<int[]> e)
- {
- DeleteEventHandler();
- if (this.getInverseStyle() == 1)
- {
- this.numberScopeControl1.minValue = e.Data[1];
- this.numberScopeControl1.maxValue = e.Data[0];
- }
- else if (this.getInverseStyle() == 2)
- {
- this.numberScopeControl3.minValue = e.Data[1];
- this.numberScopeControl3.maxValue = e.Data[0];
- }
- AddEventHandler();
- this.OnApplyButtonImplAction(null, null);
- }
- private void DragSixEvent(object sender, EventArgs<int[]> e)
- {
- DeleteEventHandler();
- this.numberScopeControl2.minValue = e.Data[1];
- this.numberScopeControl2.maxValue = e.Data[0];
- AddEventHandler();
- this.OnApplyButtonImplAction(null, null);
- }
- public void InitBinaryControlEvent()//InitHistogramDragEvent()
- {
- this.histogramControl1.DragOneEventActionFinish += new EventHandler<EventArgs<int>>(this.DragOneEvent);
- this.histogramControl1.DragTwoEventActionFinish += new EventHandler<EventArgs<int>>(this.DragTwoEvent);
- this.histogramControl1.DragThreeEventActionFinish += new EventHandler<EventArgs<int>>(this.DragThreeEvent);
- this.histogramControl1.DragFourEventActionFinish += new EventHandler<EventArgs<int>>(this.DragFourEvent);
- this.histogramControl1.DragFiveEventActionFinish += new EventHandler<EventArgs<int[]>>(this.DragFiveEvent);
- this.histogramControl1.DragSixEventActionFinish += new EventHandler<EventArgs<int[]>>(this.DragSixEvent);
- }
-
- public void AddEventHandler()
- {
- this.numberScopeControl1.ValueChanged += this.numberScope1_ValueChanged;
- this.numberScopeControl1.numericUpDown1.KeyUp += this.numberScope1_ValueChanged;
- this.numberScopeControl1.numericUpDown2.KeyUp += this.numberScope1_ValueChanged;
- this.numberScopeControl3.numericUpDown2.KeyUp += this.OnApplyButtonImplAction;//###
- this.numberScopeControl2.ValueChanged += this.numberScope2_ValueChanged;
- this.numberScopeControl2.numericUpDown1.KeyUp += this.numberScope2_ValueChanged;
- this.numberScopeControl2.numericUpDown2.KeyUp += this.numberScope2_ValueChanged;
- this.numberScopeControl3.ValueChanged += this.numberScope3_ValueChanged;
- this.numberScopeControl3.numericUpDown1.KeyUp += this.numberScope3_ValueChanged;
- this.numberScopeControl3.numericUpDown2.KeyUp += this.numberScope3_ValueChanged;
- this.numberScopeControl1.ValueChanged += this.OnApplyButtonImplAction;
- this.numberScopeControl2.ValueChanged += this.OnApplyButtonImplAction;
- this.numberScopeControl3.ValueChanged += this.OnApplyButtonImplAction;
- //this.panel2.BackColorChanged += this.OnApplyButtonImplAction;
- this.radioButton1.CheckedChanged += this.OnApplyButtonImplAction;
- this.radioButton2.CheckedChanged += this.OnApplyButtonImplAction;
- }
- public void DeleteEventHandler()
- {
- this.numberScopeControl1.ValueChanged -= this.numberScope1_ValueChanged;
- this.numberScopeControl1.numericUpDown1.KeyUp -= this.numberScope1_ValueChanged;
- this.numberScopeControl1.numericUpDown2.KeyUp -= this.numberScope1_ValueChanged;
- this.numberScopeControl3.numericUpDown2.KeyUp -= this.OnApplyButtonImplAction;//###
- this.numberScopeControl2.ValueChanged -= this.numberScope2_ValueChanged;
- this.numberScopeControl2.numericUpDown1.KeyUp -= this.numberScope2_ValueChanged;
- this.numberScopeControl2.numericUpDown2.KeyUp -= this.numberScope2_ValueChanged;
- this.numberScopeControl3.ValueChanged -= this.numberScope3_ValueChanged;
- this.numberScopeControl3.numericUpDown1.KeyUp -= this.numberScope3_ValueChanged;
- this.numberScopeControl3.numericUpDown2.KeyUp -= this.numberScope3_ValueChanged;
- this.numberScopeControl1.ValueChanged -= this.OnApplyButtonImplAction;
- this.numberScopeControl2.ValueChanged -= this.OnApplyButtonImplAction;
- this.numberScopeControl3.ValueChanged -= this.OnApplyButtonImplAction;
- //this.panel2.BackColorChanged -= this.OnApplyButtonImplAction;
- this.radioButton1.CheckedChanged -= this.OnApplyButtonImplAction;
- this.radioButton2.CheckedChanged -= this.OnApplyButtonImplAction;
- }
- //处理直方图
- public void UpdateVerticalBarWithOneScope(int start, int end)
- {
- this.histogramControl1.UpdateVerticalBarWithOneScope(start, end);
- }
- //绘制直方图
- public void CreateHistogram(OpenCvSharp.Mat imageMat, bool isGray, int width, int height, int channel)
- {
- this.histogramControl1.CreateHistogram(imageMat, isGray, width, height, channel);
- }
- /// <summary>
- /// 一个颜色区间时
- /// 区间值变化的事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numberScope1_ValueChanged(object sender, EventArgs e)
- {
- this.OnBinaryGetParamAction(sender, e);
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithOneScope((int)(this.numberScopeControl1.minValue), (int)(this.numberScopeControl1.maxValue));
- }
- /// <summary>
- /// 二个颜色区间时
- /// 区间1值变化的事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numberScope2_ValueChanged(object sender, EventArgs e)
- {
- this.OnBinaryGetParamAction(sender, e);
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithTwoScope(
- (int)(this.numberScopeControl3.minValue),
- (int)(this.numberScopeControl3.maxValue),
- (int)(this.numberScopeControl2.minValue),
- (int)(this.numberScopeControl2.maxValue)
- );
- }
- /// <summary>
- /// 二个颜色区间时
- /// 区间2值变化的事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void numberScope3_ValueChanged(object sender, EventArgs e)
- {
- this.OnBinaryGetParamAction(sender, e);
- //处理直方图
- this.histogramControl1.UpdateVerticalBarWithTwoScope(
- (int)(this.numberScopeControl3.minValue),
- (int)(this.numberScopeControl3.maxValue),
- (int)(this.numberScopeControl2.minValue),
- (int)(this.numberScopeControl2.maxValue)
- );
- }
- }
- }
|