18 private Builder _builder;
21#pragma warning disable 649
24 private SpinButton rBox;
26 private SpinButton gBox;
28 private SpinButton bBox;
30 private SpinButton widthBox;
38 private Scale widthBar;
40 private DrawingArea image;
42 private Button cancelBut;
45#pragma warning restore 649
49 #region Constructors / Destructors
59 Builder builder =
new Builder(
new FileStream(System.IO.Path.GetDirectoryName(Environment.ProcessPath) +
"/" +
"Glade/ColorTool.glade", FileMode.Open));
60 return new ColorTool(builder, builder.GetObject(
"colorTool").Handle, color1);
65 protected ColorTool(Builder builder, IntPtr handle,
bool color1) : base(handle)
68 builder.Autoconnect(
this);
71 rBar.Adjustment.Upper = ushort.MaxValue;
72 gBar.Adjustment.Upper = ushort.MaxValue;
73 bBar.Adjustment.Upper = ushort.MaxValue;
74 rBox.Adjustment.Upper = ushort.MaxValue;
75 rBox.Adjustment.StepIncrement = 1;
76 rBox.Adjustment.PageIncrement = 10;
77 gBox.Adjustment.Upper = ushort.MaxValue;
78 gBox.Adjustment.StepIncrement = 1;
79 gBox.Adjustment.PageIncrement = 10;
80 bBox.Adjustment.Upper = ushort.MaxValue;
81 bBox.Adjustment.StepIncrement = 1;
82 bBox.Adjustment.PageIncrement = 10;
83 widthBar.Adjustment.Upper = 100;
84 widthBar.Adjustment.Value =
Tools.StrokeWidth;
85 widthBox.Adjustment.Upper = 100;
86 widthBox.Adjustment.Value =
Tools.StrokeWidth;
89 rBar.Adjustment.Value =
Tools.drawColor.R;
90 gBar.Adjustment.Value =
Tools.drawColor.G;
91 bBar.Adjustment.Value =
Tools.drawColor.B;
95 rBar.Adjustment.Value = Tools.eraseColor.R;
96 gBar.Adjustment.Value = Tools.eraseColor.G;
97 bBar.Adjustment.Value = Tools.eraseColor.B;
100 App.ApplyStyles(
this);
109 rBar.ChangeValue += ChangeValue;
110 gBar.ChangeValue += ChangeValue;
111 bBar.ChangeValue += ChangeValue;
112 widthBar.ChangeValue += ChangeValue;
113 rBox.ChangeValue += Box_ChangeValue;
114 gBox.ChangeValue += Box_ChangeValue;
115 bBox.ChangeValue += Box_ChangeValue;
116 widthBox.ChangeValue += Box_ChangeValue;
117 image.Drawn += Image_Drawn;
118 cancelBut.Clicked += CancelBut_Clicked;
119 okBut.Clicked += OkBut_Clicked;
126 private void OkBut_Clicked(
object sender, EventArgs e)
128 this.DefaultResponse = ResponseType.Ok;
137 private void CancelBut_Clicked(
object sender, EventArgs e)
139 this.DefaultResponse = ResponseType.Cancel;
148 private void Image_Drawn(
object o, DrawnArgs args)
150 args.Cr.SetSourceRGBA(RGBA.Red, RGBA.Green, RGBA.Blue,RGBA.Alpha);
151 args.Cr.Rectangle(
new Cairo.Rectangle(0,0,image.AllocatedWidth,image.AllocatedHeight));
154 image.OverrideBackgroundColor(StateFlags.Normal, RGBA);
163 private void Box_ChangeValue(
object o, ChangeValueArgs args)
165 Gdk.RGBA col =
new Gdk.RGBA();
166 col.Red = (float)rBar.Value / (
float)ushort.MaxValue;
167 col.Green = (float)gBar.Value / (
float)ushort.MaxValue;
168 col.Blue = (float)bBar.Value / (
float)ushort.MaxValue;
169 rBox.Value = rBar.Value;
170 gBox.Value = gBar.Value;
171 bBox.Value = bBar.Value;
172 Tools.StrokeWidth = (int)widthBox.Value;
174 Tools.DrawColor = ColorS;
176 Tools.EraseColor = ColorS;
184 private void ChangeValue(
object o, ChangeValueArgs args)
186 rBox.Value = rBar.Value;
187 gBox.Value = gBar.Value;
188 bBox.Value = bBar.Value;
190 Tools.DrawColor = ColorS;
192 Tools.EraseColor = ColorS;
193 Tools.StrokeWidth = (int)widthBar.Value;
201 return new ColorS((ushort)rBox.Value, (ushort)gBox.Value, (ushort)bBox.Value);
208 RGBA rgb =
new RGBA();
209 rgb.Red = (float)rBox.Value / (
float)ushort.MaxValue;
210 rgb.Green = (float)gBox.Value / (
float)ushort.MaxValue;
211 rgb.Blue = (float)bBox.Value / (
float)ushort.MaxValue;