8 partial class ConfigurationControl
14 private void InitFilterValues()
16 this.checkBoxUseHSLFilter.Checked = this.configuration.Filter.UseHslFilter;
17 this.checkBoxUseHSLFilter.CheckedChanged += this.CheckBoxUseHslFilterOnCheckedChanged;
19 this.numericHueMin.Value = this.configuration.Filter.HueMin;
20 this.numericHueMin.ValueChanged += this.NumericHueMinOnValueChanged;
22 this.numericHueMax.Value = this.configuration.Filter.HueMax;
23 this.numericHueMax.ValueChanged += this.NumericHueMaxOnValueChanged;
25 this.textBoxSaturationMin.Text =
26 this.configuration.Filter.SaturationMin.ToString(CultureInfo.InvariantCulture);
27 this.textBoxSaturationMin.TextChanged += this.TextBoxSaturationMinOnTextChanged;
29 this.textBoxSaturationMax.Text =
30 this.configuration.Filter.SaturationMax.ToString(CultureInfo.InvariantCulture);
31 this.textBoxSaturationMax.TextChanged += this.TextBoxSaturationMaxOnTextChanged;
33 this.textBoxLuminanceMin.Text = this.configuration.Filter.LuminanceMin.ToString(CultureInfo.InvariantCulture);
34 this.textBoxLuminanceMin.TextChanged += this.TextBoxLuminanceMinOnTextChanged;
36 this.textBoxLuminanceMax.Text = this.configuration.Filter.LuminanceMax.ToString(CultureInfo.InvariantCulture);
37 this.textBoxLuminanceMax.TextChanged += this.TextBoxLuminanceMaxOnTextChanged;
39 this.checkBoxUseColorFilter.Checked = this.configuration.Filter.UseColorFilter;
40 this.checkBoxUseColorFilter.CheckedChanged += this.CheckBoxUseColorFilterOnCheckedChanged;
42 this.numericRedMin.Value = this.configuration.Filter.FilterRedMin;
43 this.numericRedMin.ValueChanged += this.NumericRedMinOnValueChanged;
45 this.numericRedMax.Value = this.configuration.Filter.FilterRedMax;
46 this.numericRedMax.ValueChanged += this.NumericRedMaxOnValueChanged;
48 this.numericGreenMin.Value = this.configuration.Filter.FilterGreenMin;
49 this.numericGreenMin.ValueChanged += this.NumericGreenMinOnValueChanged;
51 this.numericGreenMax.Value = this.configuration.Filter.FilterGreenMax;
52 this.numericGreenMax.ValueChanged += this.NumericGreenMaxOnValueChanged;
54 this.numericBlueMin.Value = this.configuration.Filter.FilterBlueMin;
55 this.numericBlueMin.ValueChanged += this.NumericBlueMinOnValueChanged;
57 this.numericBlueMax.Value = this.configuration.Filter.FilterBlueMax;
58 this.numericBlueMax.ValueChanged += this.NumericBlueMaxOnValueChanged;
60 string[] allowedGrayFilters = {
"BT709",
"RMY",
"Y"};
64 foreach (
string grayFilter
in allowedGrayFilters)
66 this.comboBoxGrayFilter.Items.Add(grayFilter);
68 if (this.configuration.Filter.GrayFilter.ToString() == grayFilter)
69 this.comboBoxGrayFilter.SelectedIndex = i;
73 this.comboBoxGrayFilter.SelectedIndexChanged += this.comboBoxGrayFilter_SelectedIndexChanged;
75 this.checkBoxUseThresholdFilter.Checked = this.configuration.Filter.UseThresholdFilter;
76 this.checkBoxUseThresholdFilter.CheckStateChanged += this.CheckBoxUseThresholdFilterOnCheckStateChanged;
78 this.numericThreshold.Value = this.configuration.Filter.Threshold;
79 this.numericThreshold.ValueChanged += this.NumericThresholdOnValueChanged;
81 this.checkBoxUseErosionFilter.Checked = this.configuration.Filter.UseErosionFilter;
82 this.checkBoxUseErosionFilter.CheckedChanged += this.CheckBoxUseErosionFilterOnCheckedChanged;
84 this.checkBoxUseDiletationFilter.Checked = this.configuration.Filter.UseDiletationFilter;
85 this.checkBoxUseDiletationFilter.CheckStateChanged += this.CheckBoxUseDiletationFilterOnCheckStateChanged;
95 private void CheckBoxUseHslFilterOnCheckedChanged(
object sender, EventArgs eventArgs)
97 this.configuration.Filter.UseHslFilter = this.checkBoxUseHSLFilter.Checked;
107 private void NumericHueMinOnValueChanged(
object sender, EventArgs eventArgs)
109 this.configuration.Filter.HueMin = (int) this.numericHueMin.Value;
119 private void NumericHueMaxOnValueChanged(
object sender, EventArgs eventArgs)
121 this.configuration.Filter.HueMax = (int) this.numericHueMax.Value;
131 private void TextBoxSaturationMinOnTextChanged(
object sender, EventArgs e)
133 this.configuration.Filter.SaturationMin =
float.Parse(this.textBoxSaturationMin.Text);
143 private void TextBoxSaturationMaxOnTextChanged(
object sender, EventArgs e)
145 this.configuration.Filter.SaturationMax =
float.Parse(this.textBoxSaturationMax.Text);
155 private void TextBoxLuminanceMinOnTextChanged(
object sender, EventArgs e)
157 this.configuration.Filter.LuminanceMin =
float.Parse(this.textBoxLuminanceMin.Text);
167 private void TextBoxLuminanceMaxOnTextChanged(
object sender, EventArgs eventArgs)
169 this.configuration.Filter.LuminanceMax =
float.Parse(this.textBoxLuminanceMax.Text);
179 private void CheckBoxUseColorFilterOnCheckedChanged(
object sender, EventArgs e)
181 this.configuration.Filter.UseColorFilter = this.checkBoxUseColorFilter.Checked;
191 private void NumericRedMinOnValueChanged(
object sender, EventArgs eventArgs)
193 this.configuration.Filter.FilterRedMin = (int) this.numericRedMin.Value;
203 private void NumericRedMaxOnValueChanged(
object sender, EventArgs eventArgs)
205 this.configuration.Filter.FilterRedMax = (int) this.numericRedMax.Value;
215 private void NumericGreenMinOnValueChanged(
object sender, EventArgs eventArgs)
217 this.configuration.Filter.FilterGreenMin = (int) this.numericGreenMin.Value;
227 private void NumericGreenMaxOnValueChanged(
object sender, EventArgs eventArgs)
229 this.configuration.Filter.FilterGreenMax = (int) this.numericGreenMax.Value;
239 private void NumericBlueMinOnValueChanged(
object sender, EventArgs eventArgs)
241 this.configuration.Filter.FilterBlueMin = (int) this.numericBlueMin.Value;
251 private void NumericBlueMaxOnValueChanged(
object sender, EventArgs eventArgs)
253 this.configuration.Filter.FilterBlueMax = (int) this.numericBlueMax.Value;
263 private void comboBoxGrayFilter_SelectedIndexChanged(
object sender, EventArgs e)
265 this.configuration.Filter.GrayFilter =
EnumHelper.ParseEnum<
GrayFilter>(this.comboBoxGrayFilter.Text);
275 private void CheckBoxUseThresholdFilterOnCheckStateChanged(
object sender, EventArgs eventArgs)
277 this.configuration.Filter.UseThresholdFilter = this.checkBoxUseThresholdFilter.Checked;
287 private void NumericThresholdOnValueChanged(
object sender, EventArgs eventArgs)
289 this.configuration.Filter.Threshold = (int) this.numericThreshold.Value;
299 private void CheckBoxUseErosionFilterOnCheckedChanged(
object sender, EventArgs eventArgs)
301 this.configuration.Filter.UseErosionFilter = this.checkBoxUseErosionFilter.Checked;
311 private void CheckBoxUseDiletationFilterOnCheckStateChanged(
object sender, EventArgs eventArgs)
313 this.configuration.Filter.UseDiletationFilter = this.checkBoxUseDiletationFilter.Checked;
318 private void buttonLoadIDefaults_Click(
object sender, EventArgs e)
320 this.DetachFilterEvents();
321 this.comboBoxGrayFilter.Items.Clear();
323 this.InitFilterValues();
326 private void DetachFilterEvents()
328 this.checkBoxUseHSLFilter.CheckedChanged -= this.CheckBoxUseHslFilterOnCheckedChanged;
329 this.numericHueMin.ValueChanged -= this.NumericHueMinOnValueChanged;
330 this.numericHueMax.ValueChanged -= this.NumericHueMaxOnValueChanged;
331 this.textBoxSaturationMin.TextChanged -= this.TextBoxSaturationMinOnTextChanged;
332 this.textBoxSaturationMax.TextChanged -= this.TextBoxSaturationMaxOnTextChanged;
333 this.textBoxLuminanceMin.TextChanged -= this.TextBoxLuminanceMinOnTextChanged;
334 this.textBoxLuminanceMax.TextChanged -= this.TextBoxLuminanceMaxOnTextChanged;
335 this.checkBoxUseColorFilter.CheckedChanged -= this.CheckBoxUseColorFilterOnCheckedChanged;
336 this.numericRedMin.ValueChanged -= this.NumericRedMinOnValueChanged;
337 this.numericRedMax.ValueChanged -= this.NumericRedMaxOnValueChanged;
338 this.numericGreenMin.ValueChanged -= this.NumericGreenMinOnValueChanged;
339 this.numericGreenMax.ValueChanged -= this.NumericGreenMaxOnValueChanged;
340 this.numericBlueMin.ValueChanged -= this.NumericBlueMinOnValueChanged;
341 this.numericBlueMax.ValueChanged -= this.NumericBlueMaxOnValueChanged;
342 this.comboBoxGrayFilter.SelectedIndexChanged -= this.comboBoxGrayFilter_SelectedIndexChanged;
343 this.checkBoxUseThresholdFilter.CheckStateChanged -= this.CheckBoxUseThresholdFilterOnCheckStateChanged;
344 this.numericThreshold.ValueChanged -= this.NumericThresholdOnValueChanged;
345 this.checkBoxUseErosionFilter.CheckedChanged -= this.CheckBoxUseErosionFilterOnCheckedChanged;
346 this.checkBoxUseDiletationFilter.CheckStateChanged -= this.CheckBoxUseDiletationFilterOnCheckStateChanged;
357 this.imagingControl.StopImaging();
367 this.imagingControl.StartImaging(this.configuration.Camera.Name);
368 this.imagingControl.FilterLaser =
true;
369 this.imagingControl.ShowLaserLine =
true;
void Stop()
Stops this instance.
void Start()
Starts this instance.
static Filter CreateDefaultFilter()
Creates the default filter.
Class for accessing the configuration.