BioGTK  6.7.0
A .NET library & program for annotating, editing various microscopy imaging formats using Bioformats supported images. Including whole slide, pyramidal, and series.
Loading...
Searching...
No Matches
Tolerance.cs
1using AForge;
2using Gdk;
3using Gtk;
4using sun.tools.tree;
5using System;
6using System.Collections.Generic;
7using System.IO;
8using System.Linq;
9using System.Text;
10using System.Threading.Tasks;
11
12namespace BioGTK
13{
14 public class Tolerance : Gtk.Dialog
15 {
16 #region Properties
17 private Builder _builder;
18
19#pragma warning disable 649
20
21 [Builder.Object]
22 private SpinButton rBox;
23 [Builder.Object]
24 private SpinButton gBox;
25 [Builder.Object]
26 private SpinButton bBox;
27 [Builder.Object]
28 private Scale rBar;
29 [Builder.Object]
30 private Scale gBar;
31 [Builder.Object]
32 private Scale bBar;
33 [Builder.Object]
34 private DrawingArea image;
35 [Builder.Object]
36 private Button cancelBut;
37 [Builder.Object]
38 private Button okBut;
39#pragma warning restore 649
40
41 #endregion
42
43 #region Constructors / Destructors
44
51 public static Tolerance Create()
52 {
53 Builder builder = new Builder(new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) + "/" + "Glade/Tolerance.glade", FileMode.Open));
54 return new Tolerance(builder, builder.GetObject("tolerance").Handle);
55 }
56
57
58 /* The constructor for the class. */
59 protected Tolerance(Builder builder, IntPtr handle) : base(handle)
60 {
61 _builder = builder;
62 builder.Autoconnect(this);
64 rBar.Adjustment.Upper = ushort.MaxValue;
65 gBar.Adjustment.Upper = ushort.MaxValue;
66 bBar.Adjustment.Upper = ushort.MaxValue;
67 rBox.Adjustment.Upper = ushort.MaxValue;
68 rBox.Adjustment.StepIncrement = 1;
69 rBox.Adjustment.PageIncrement = 10;
70 gBox.Adjustment.Upper = ushort.MaxValue;
71 gBox.Adjustment.StepIncrement = 1;
72 gBox.Adjustment.PageIncrement = 10;
73 bBox.Adjustment.Upper = ushort.MaxValue;
74 bBox.Adjustment.StepIncrement = 1;
75 bBox.Adjustment.PageIncrement = 10;
76 App.ApplyStyles(this);
77 }
78
79 #endregion
80
81 #region Handlers
83 protected void SetupHandlers()
84 {
85 rBar.ChangeValue += ChangeValue;
86 gBar.ChangeValue += ChangeValue;
87 bBar.ChangeValue += ChangeValue;
88 rBox.ChangeValue += Box_ChangeValue;
89 gBox.ChangeValue += Box_ChangeValue;
90 bBox.ChangeValue += Box_ChangeValue;
91 cancelBut.Clicked += CancelBut_Clicked;
92 okBut.Clicked += OkBut_Clicked;
93 }
94
95 private void OkBut_Clicked(object sender, EventArgs e)
96 {
97 this.DefaultResponse = ResponseType.Ok;
98 this.Destroy();
99 }
100
101 private void CancelBut_Clicked(object sender, EventArgs e)
102 {
103 this.DefaultResponse = ResponseType.Cancel;
104 this.Destroy();
105 }
106
112 private void Box_ChangeValue(object o, ChangeValueArgs args)
113 {
114 Gdk.RGBA col = new Gdk.RGBA();
115 col.Red = rBar.Value / ushort.MaxValue;
116 col.Green = gBar.Value / ushort.MaxValue;
117 col.Blue = bBar.Value / ushort.MaxValue;
118 rBox.Value = rBar.Value;
119 gBox.Value = gBar.Value;
120 bBox.Value = bBar.Value;
121 }
122
127 private void ChangeValue(object o, ChangeValueArgs args)
128 {
129 rBox.Value = rBar.Value;
130 gBox.Value = gBar.Value;
131 bBox.Value = bBar.Value;
132 Tools.tolerance = ColorS;
133 }
134
135 /* Returning a new ColorS object with the values of the spin buttons. */
136 public ColorS ColorS
137 {
138 get
139 {
140 return new ColorS((ushort)rBox.Value, (ushort)gBox.Value, (ushort)bBox.Value);
141 }
142 }
143
144 #endregion
145
146 }
147}
static Tolerance Create()
Definition Tolerance.cs:51
void SetupHandlers()
It sets up the event handlers for the sliders and text boxes.
Definition Tolerance.cs:83
Definition ML.cs:17