BioCore  5.0.0
A Windows .NET microscopy library and application for viewing, editing, and annotating images.
Loading...
Searching...
No Matches
FloodTool.cs
Go to the documentation of this file.
1using AForge;
2using System.ComponentModel;
3namespace BioCore
4{
5 public partial class FloodTool : Form
6 {
7 private Pen pen = new Pen(new ColorS(ushort.MaxValue, ushort.MaxValue, ushort.MaxValue), 1, 16);
8 private int bitsPerPixel = 16;
9 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
10 public Pen Pen
11 {
12 get
13 {
14 return pen;
15 }
16 set
17 {
18 pen = value;
19 }
20 }
21
22 private ColorS tolerance;
23 public ColorS Tolerance
24 {
25 get
26 {
27 return tolerance;
28 }
29 }
30
31 public void UpdateGUI()
32 {
33 pen.color = new ColorS((ushort)redBox.Value, (ushort)greenBox.Value, (ushort)blueBox.Value);
34 colorPanel.BackColor = System.Drawing.Color.FromArgb(pen.color.R,pen.color.G,pen.color.B);
35 if (rBar.Value != redBox.Value)
36 redBox.Value = rBar.Value;
37 if (gBar.Value != greenBox.Value)
38 greenBox.Value = gBar.Value;
39 if (bBar.Value != blueBox.Value)
40 blueBox.Value = bBar.Value;
41 }
42
43 public void SetColor()
44 {
45 rBar.Value = pen.color.R;
46 gBar.Value = pen.color.G;
47 bBar.Value = pen.color.B;
48 }
49 public FloodTool()
50 {
51 InitializeComponent();
52 UpdateGUI();
53 }
54 public FloodTool(Pen p, ColorS tolerance, int bitPerPixel)
55 {
56 InitializeComponent();
57 pen = p;
58 bitsPerPixel = bitPerPixel;
59 if (bitsPerPixel == 8)
60 {
61 rBar.Maximum = 255;
62 gBar.Maximum = 255;
63 bBar.Maximum = 255;
64 redBox.Maximum = 255;
65 greenBox.Maximum = 255;
66 blueBox.Maximum = 255;
67 }
68 if (rBar.Maximum <= p.color.R)
69 rBar.Value = rBar.Maximum;
70 if (gBar.Maximum <= p.color.G)
71 gBar.Value = gBar.Maximum;
72 if (bBar.Maximum <= p.color.B)
73 bBar.Value = bBar.Maximum;
74 this.tolerance = tolerance;
75 tolRBox.Value = (decimal)tolerance.R;
76 tolGBox.Value = (decimal)tolerance.G;
77 tolBBox.Value = (decimal)tolerance.B;
78 SetColor();
79 UpdateGUI();
80 }
81
82 private void redBox_ValueChanged(object sender, EventArgs e)
83 {
84 UpdateGUI();
85 }
86
87 private void greenBox_ValueChanged(object sender, EventArgs e)
88 {
89 UpdateGUI();
90 }
91
92 private void blueBox_ValueChanged(object sender, EventArgs e)
93 {
94 UpdateGUI();
95 }
96
97 private void rEnbaled_CheckedChanged(object sender, EventArgs e)
98 {
99 Tools.rEnabled = rEnbaled.Checked;
100 }
101
102 private void gEnabled_CheckedChanged(object sender, EventArgs e)
103 {
104 Tools.gEnabled = gEnabled.Checked;
105 }
106
107 private void bEnabled_CheckedChanged(object sender, EventArgs e)
108 {
109 Tools.bEnabled = bEnabled.Checked;
110 }
111
112 private void applyButton_Click(object sender, EventArgs e)
113 {
114 DialogResult = DialogResult.OK;
115 this.Close();
116 }
117
118 private void tolRBox_ValueChanged(object sender, EventArgs e)
119 {
120 tolerance.R = (ushort)tolRBox.Value;
121 }
122
123 private void tolGBox_ValueChanged(object sender, EventArgs e)
124 {
125 tolerance.G = (ushort)tolGBox.Value;
126 }
127
128 private void tolBBox_ValueChanged(object sender, EventArgs e)
129 {
130 tolerance.B = (ushort)tolBBox.Value;
131 }
132
133 private void cancelBut_Click(object sender, EventArgs e)
134 {
135 DialogResult = DialogResult.Cancel;
136 }
137
138 private void rBar_ValueChanged(object sender, EventArgs e)
139 {
140 UpdateGUI();
141 }
142 }
143}
System.Drawing.Pen Pen
FloodTool(Pen p, ColorS tolerance, int bitPerPixel)
Definition FloodTool.cs:54
ColorS color
Definition Graphics.cs:6