選擇專案
加入Windows Form, 名稱可以取有意義的名字:ColorOfInterestForm.cs
加入4個HScrollBar分別為調整BGR數值以及容忍絕對誤差(Tolerence)
加入4個成員變數
加入四個方法Blue, Green, Red, Tolerence
方便外部取得4個內部變數_blue, _green, _red, _tolerence
加入四個HScrollBar Callback 函式
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
label1.Text = hScrollBar1.Value.ToString();
this.Blue = hScrollBar1.Value;
}
private void hScrollBar2_Scroll(object sender, ScrollEventArgs e)
{
label2.Text = hScrollBar2.Value.ToString();
this.Green = hScrollBar2.Value;
}
private void hScrollBar3_Scroll(object sender, ScrollEventArgs e)
{
label3.Text = hScrollBar3.Value.ToString();
this.Red = hScrollBar3.Value;
}
private void hScrollBar4_Scroll(object sender, ScrollEventArgs e)
{
label4.Text = hScrollBar4.Value.ToString();
this.Tolerence = hScrollBar4.Value;
}
private void button1_Click(object sender, EventArgs e)
{
this.Blue = hScrollBar1.Value;
this.Green = hScrollBar2.Value;
this.Red = hScrollBar3.Value;
this.Tolerence = hScrollBar4.Value;
Close();
}
==================================================================
在主視窗部份
this._coiForm.Blue 即可取出_blue
this._coiForm.Green 即可取出_green
this._coiForm.Red 即可取出_red
this._coiForm.TolColorDist 即可取出_tolerence
留言列表