1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
// XXX - YYY
// Copyright (C) 200X Ian Cowburn
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// $Id$
//
using System;
using System.Drawing;
using System.Windows.Forms;
namespace BitmapFontEd
{
/// <summary>
/// Description of AlphaColourDialog.
/// </summary>
public class AlphaColourDialog : System.Windows.Forms.Form
{
private System.Windows.Forms.Label m_common7;
private System.Windows.Forms.Label m_common4;
private System.Windows.Forms.Label m_common5;
private System.Windows.Forms.Label m_common3;
private System.Windows.Forms.TextBox m_red;
private System.Windows.Forms.TrackBar m_greenSlider;
private System.Windows.Forms.TextBox m_alpha;
private System.Windows.Forms.Label m_preview;
private System.Windows.Forms.ComboBox m_named;
private System.Windows.Forms.TrackBar m_redSlider;
private System.Windows.Forms.TrackBar m_alphaSlider;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox m_green;
private System.Windows.Forms.TrackBar m_blueSlider;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox m_blue;
private System.Windows.Forms.Label m_common8;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label m_common2;
private System.Windows.Forms.Button m_ok;
private System.Windows.Forms.Button m_cancel;
private System.Windows.Forms.Label m_common1;
private System.Windows.Forms.Label m_common6;
private bool m_allowAlpha;
public AlphaColourDialog(string title)
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
Text=title;
foreach (KnownColor col in Enum.GetValues(typeof(KnownColor)))
{
if (Color.FromKnownColor(col).A==255)
{
m_named.Items.Add(col.ToString());
}
}
m_allowAlpha=true;
}
public Color Color
{
get
{
return m_preview.BackColor;
}
set
{
m_redSlider.Value=value.R;
m_greenSlider.Value=value.G;
m_blueSlider.Value=value.B;
if (m_allowAlpha)
{
m_alphaSlider.Value=value.A;
}
else
{
m_alphaSlider.Value=255;
}
SetColour();
}
}
public bool AllowAlpha
{
set
{
m_allowAlpha=value;
m_alphaSlider.Visible=false;
}
}
private void SetColour()
{
m_red.Text=m_redSlider.Value.ToString();
m_green.Text=m_greenSlider.Value.ToString();
m_blue.Text=m_blueSlider.Value.ToString();
m_alpha.Text=m_alphaSlider.Value.ToString();
m_preview.BackColor=Color.FromArgb(m_alphaSlider.Value,
m_redSlider.Value,
m_greenSlider.Value,
m_blueSlider.Value);
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.m_common6 = new System.Windows.Forms.Label();
this.m_common1 = new System.Windows.Forms.Label();
this.m_cancel = new System.Windows.Forms.Button();
this.m_ok = new System.Windows.Forms.Button();
this.m_common2 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.m_common8 = new System.Windows.Forms.Label();
this.m_blue = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.m_blueSlider = new System.Windows.Forms.TrackBar();
this.m_green = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.m_alphaSlider = new System.Windows.Forms.TrackBar();
this.m_redSlider = new System.Windows.Forms.TrackBar();
this.m_named = new System.Windows.Forms.ComboBox();
this.m_preview = new System.Windows.Forms.Label();
this.m_alpha = new System.Windows.Forms.TextBox();
this.m_greenSlider = new System.Windows.Forms.TrackBar();
this.m_red = new System.Windows.Forms.TextBox();
this.m_common3 = new System.Windows.Forms.Label();
this.m_common5 = new System.Windows.Forms.Label();
this.m_common4 = new System.Windows.Forms.Label();
this.m_common7 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.m_blueSlider)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m_alphaSlider)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m_redSlider)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.m_greenSlider)).BeginInit();
this.SuspendLayout();
//
// m_common6
//
this.m_common6.BackColor = System.Drawing.Color.Yellow;
this.m_common6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_common6.Location = new System.Drawing.Point(56, 240);
this.m_common6.Name = "m_common6";
this.m_common6.Size = new System.Drawing.Size(24, 24);
this.m_common6.TabIndex = 21;
this.m_common6.Click += new System.EventHandler(this.OnCommon);
//
// m_common1
//
this.m_common1.BackColor = System.Drawing.Color.Black;
this.m_common1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_common1.Location = new System.Drawing.Point(16, 208);
this.m_common1.Name = "m_common1";
this.m_common1.Size = new System.Drawing.Size(24, 24);
this.m_common1.TabIndex = 16;
this.m_common1.Click += new System.EventHandler(this.OnCommon);
//
// m_cancel
//
this.m_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.m_cancel.Location = new System.Drawing.Point(296, 328);
this.m_cancel.Name = "m_cancel";
this.m_cancel.Size = new System.Drawing.Size(104, 24);
this.m_cancel.TabIndex = 13;
this.m_cancel.Text = "Cancel";
//
// m_ok
//
this.m_ok.Location = new System.Drawing.Point(184, 328);
this.m_ok.Name = "m_ok";
this.m_ok.Size = new System.Drawing.Size(104, 24);
this.m_ok.TabIndex = 12;
this.m_ok.Text = "OK";
this.m_ok.Click += new System.EventHandler(this.OnOK);
//
// m_common2
//
this.m_common2.BackColor = System.Drawing.Color.White;
this.m_common2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_common2.Location = new System.Drawing.Point(56, 208);
this.m_common2.Name = "m_common2";
this.m_common2.Size = new System.Drawing.Size(24, 24);
this.m_common2.TabIndex = 17;
this.m_common2.Click += new System.EventHandler(this.OnCommon);
//
// label4
//
this.label4.Location = new System.Drawing.Point(352, 0);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 24);
this.label4.TabIndex = 7;
this.label4.Text = "Alpha";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 192);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(128, 16);
this.label5.TabIndex = 15;
this.label5.Text = "Primary Colours:";
//
// label6
//
this.label6.Location = new System.Drawing.Point(8, 280);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(128, 16);
this.label6.TabIndex = 24;
this.label6.Text = "Named Colours:";
//
// m_common8
//
this.m_common8.BackColor = System.Drawing.Color.Cyan;
this.m_common8.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_common8.Location = new System.Drawing.Point(136, 240);
this.m_common8.Name = "m_common8";
this.m_common8.Size = new System.Drawing.Size(24, 24);
this.m_common8.TabIndex = 23;
this.m_common8.Click += new System.EventHandler(this.OnCommon);
//
// m_blue
//
this.m_blue.Location = new System.Drawing.Point(304, 296);
this.m_blue.MaxLength = 3;
this.m_blue.Name = "m_blue";
this.m_blue.ReadOnly = true;
this.m_blue.Size = new System.Drawing.Size(40, 20);
this.m_blue.TabIndex = 10;
this.m_blue.Text = "textBox1";
//
// label2
//
this.label2.Location = new System.Drawing.Point(240, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 24);
this.label2.TabIndex = 3;
this.label2.Text = "Green";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Location = new System.Drawing.Point(296, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 24);
this.label3.TabIndex = 5;
this.label3.Text = "Blue";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// m_blueSlider
//
this.m_blueSlider.Location = new System.Drawing.Point(304, 24);
this.m_blueSlider.Maximum = 255;
this.m_blueSlider.Name = "m_blueSlider";
this.m_blueSlider.Orientation = System.Windows.Forms.Orientation.Vertical;
this.m_blueSlider.Size = new System.Drawing.Size(42, 264);
this.m_blueSlider.TabIndex = 4;
this.m_blueSlider.TickFrequency = 5;
this.m_blueSlider.Scroll += new System.EventHandler(this.OnBlue);
//
// m_green
//
this.m_green.Location = new System.Drawing.Point(248, 296);
this.m_green.MaxLength = 3;
this.m_green.Name = "m_green";
this.m_green.ReadOnly = true;
this.m_green.Size = new System.Drawing.Size(40, 20);
this.m_green.TabIndex = 9;
this.m_green.Text = "textBox1";
//
// label1
//
this.label1.Location = new System.Drawing.Point(184, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 24);
this.label1.TabIndex = 1;
this.label1.Text = "Red";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// m_alphaSlider
//
this.m_alphaSlider.Location = new System.Drawing.Point(360, 24);
this.m_alphaSlider.Maximum = 255;
this.m_alphaSlider.Name = "m_alphaSlider";
this.m_alphaSlider.Orientation = System.Windows.Forms.Orientation.Vertical;
this.m_alphaSlider.Size = new System.Drawing.Size(42, 264);
this.m_alphaSlider.TabIndex = 6;
this.m_alphaSlider.TickFrequency = 5;
this.m_alphaSlider.Value = 255;
this.m_alphaSlider.Scroll += new System.EventHandler(this.OnAlpha);
//
// m_redSlider
//
this.m_redSlider.Location = new System.Drawing.Point(192, 24);
this.m_redSlider.Maximum = 255;
this.m_redSlider.Name = "m_redSlider";
this.m_redSlider.Orientation = System.Windows.Forms.Orientation.Vertical;
this.m_redSlider.Size = new System.Drawing.Size(42, 264);
this.m_redSlider.TabIndex = 0;
this.m_redSlider.TickFrequency = 5;
this.m_redSlider.Scroll += new System.EventHandler(this.OnRed);
//
// m_named
//
this.m_named.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.m_named.Location = new System.Drawing.Point(8, 296);
this.m_named.MaxDropDownItems = 20;
this.m_named.Name = "m_named";
this.m_named.Size = new System.Drawing.Size(168, 21);
this.m_named.Sorted = true;
this.m_named.TabIndex = 25;
this.m_named.SelectedIndexChanged += new System.EventHandler(this.OnNamedColour);
//
// m_preview
//
this.m_preview.BackColor = System.Drawing.Color.Black;
this.m_preview.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_preview.Location = new System.Drawing.Point(8, 8);
this.m_preview.Name = "m_preview";
this.m_preview.Size = new System.Drawing.Size(168, 168);
this.m_preview.TabIndex = 14;
//
// m_alpha
//
this.m_alpha.Location = new System.Drawing.Point(360, 296);
this.m_alpha.MaxLength = 3;
this.m_alpha.Name = "m_alpha";
this.m_alpha.ReadOnly = true;
this.m_alpha.Size = new System.Drawing.Size(40, 20);
this.m_alpha.TabIndex = 11;
this.m_alpha.Text = "textBox1";
//
// m_greenSlider
//
this.m_greenSlider.Location = new System.Drawing.Point(248, 24);
this.m_greenSlider.Maximum = 255;
this.m_greenSlider.Name = "m_greenSlider";
this.m_greenSlider.Orientation = System.Windows.Forms.Orientation.Vertical;
this.m_greenSlider.Size = new System.Drawing.Size(42, 264);
this.m_greenSlider.TabIndex = 2;
this.m_greenSlider.TickFrequency = 5;
this.m_greenSlider.Scroll += new System.EventHandler(this.OnGreen);
//
// m_red
//
this.m_red.Location = new System.Drawing.Point(192, 296);
this.m_red.MaxLength = 3;
this.m_red.Name = "m_red";
this.m_red.ReadOnly = true;
this.m_red.Size = new System.Drawing.Size(40, 20);
this.m_red.TabIndex = 8;
this.m_red.Text = "textBox1";
//
// m_common3
//
this.m_common3.BackColor = System.Drawing.Color.Red;
this.m_common3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_common3.Location = new System.Drawing.Point(96, 208);
this.m_common3.Name = "m_common3";
this.m_common3.Size = new System.Drawing.Size(24, 24);
this.m_common3.TabIndex = 18;
this.m_common3.Click += new System.EventHandler(this.OnCommon);
//
// m_common5
//
this.m_common5.BackColor = System.Drawing.Color.Blue;
this.m_common5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_common5.Location = new System.Drawing.Point(16, 240);
this.m_common5.Name = "m_common5";
this.m_common5.Size = new System.Drawing.Size(24, 24);
this.m_common5.TabIndex = 20;
this.m_common5.Click += new System.EventHandler(this.OnCommon);
//
// m_common4
//
this.m_common4.BackColor = System.Drawing.Color.Lime;
this.m_common4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_common4.Location = new System.Drawing.Point(136, 208);
this.m_common4.Name = "m_common4";
this.m_common4.Size = new System.Drawing.Size(24, 24);
this.m_common4.TabIndex = 19;
this.m_common4.Click += new System.EventHandler(this.OnCommon);
//
// m_common7
//
this.m_common7.BackColor = System.Drawing.Color.Fuchsia;
this.m_common7.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.m_common7.Location = new System.Drawing.Point(96, 240);
this.m_common7.Name = "m_common7";
this.m_common7.Size = new System.Drawing.Size(24, 24);
this.m_common7.TabIndex = 22;
this.m_common7.Click += new System.EventHandler(this.OnCommon);
//
// AlphaColourDialog
//
this.AcceptButton = this.m_ok;
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.CancelButton = this.m_cancel;
this.ClientSize = new System.Drawing.Size(410, 362);
this.Controls.Add(this.m_named);
this.Controls.Add(this.label6);
this.Controls.Add(this.m_common8);
this.Controls.Add(this.m_common7);
this.Controls.Add(this.m_common6);
this.Controls.Add(this.m_common5);
this.Controls.Add(this.m_common4);
this.Controls.Add(this.m_common3);
this.Controls.Add(this.m_common2);
this.Controls.Add(this.m_common1);
this.Controls.Add(this.label5);
this.Controls.Add(this.m_preview);
this.Controls.Add(this.m_cancel);
this.Controls.Add(this.m_ok);
this.Controls.Add(this.m_alpha);
this.Controls.Add(this.m_blue);
this.Controls.Add(this.m_green);
this.Controls.Add(this.m_red);
this.Controls.Add(this.label4);
this.Controls.Add(this.m_alphaSlider);
this.Controls.Add(this.label3);
this.Controls.Add(this.m_blueSlider);
this.Controls.Add(this.label2);
this.Controls.Add(this.m_greenSlider);
this.Controls.Add(this.label1);
this.Controls.Add(this.m_redSlider);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "AlphaColourDialog";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "AlphaColourDialog";
((System.ComponentModel.ISupportInitialize)(this.m_blueSlider)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.m_alphaSlider)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.m_redSlider)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.m_greenSlider)).EndInit();
this.ResumeLayout(false);
}
#endregion
void OnRed(object sender, System.EventArgs e)
{
SetColour();
}
void OnGreen(object sender, System.EventArgs e)
{
SetColour();
}
void OnBlue(object sender, System.EventArgs e)
{
SetColour();
}
void OnAlpha(object sender, System.EventArgs e)
{
SetColour();
}
void OnOK(object sender, System.EventArgs e)
{
DialogResult=DialogResult.OK;
Close();
}
void OnCommon(object sender, System.EventArgs e)
{
Label l=(Label)sender;
Color=l.BackColor;
}
void OnNamedColour(object sender, System.EventArgs e)
{
string s=(string)m_named.SelectedItem;
Color=Color.FromKnownColor((KnownColor)Enum.Parse(typeof(KnownColor),s));
}
}
}
|