2008-03-27 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / FontDialog.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2006, Alexander Olk
21 //
22 // Authors:
23 //      Alexander Olk   alex.olk@googlemail.com
24 //
25 //
26
27 // NOT COMPLETE - work in progress
28
29 using System.ComponentModel;
30 using System.Drawing;
31 using System.Text.RegularExpressions;
32 using System;
33 using System.Collections;
34
35 namespace System.Windows.Forms
36 {
37         [DefaultProperty( "Font" )]
38         [DefaultEvent("Apply")]
39         public class FontDialog : CommonDialog
40         {
41                 protected static readonly object EventApply = new object ();
42
43                 private Font font;
44                 private Color color = Color.Black;
45                 private bool allowSimulations = true;
46                 private bool allowVectorFonts = true;
47                 private bool allowVerticalFonts = true;
48                 private bool allowScriptChange = true;
49                 private bool fixedPitchOnly = false;
50                 private int maxSize = 0;
51                 private int minSize = 0;
52                 private bool scriptsOnly = false;
53                 private bool showApply = false;
54                 private bool showColor = false;
55                 private bool showEffects = true;
56                 private bool showHelp = false;
57                 
58                 private bool fontMustExist = false;
59                 
60                 private Panel examplePanel;
61                 
62                 private Button okButton;
63                 private Button cancelButton;
64                 private Button applyButton;
65                 private Button helpButton;
66                 
67                 private TextBox fontTextBox;
68                 private TextBox fontstyleTextBox;
69                 private TextBox fontsizeTextBox;
70                 
71                 private MouseWheelListBox fontListBox;
72                 private MouseWheelListBox fontstyleListBox;
73                 private MouseWheelListBox fontsizeListBox;
74                 
75                 private GroupBox effectsGroupBox;
76                 private CheckBox strikethroughCheckBox;
77                 private CheckBox underlinedCheckBox;
78                 private ComboBox scriptComboBox;
79                 
80                 private Label fontLabel;
81                 private Label fontstyleLabel;
82                 private Label sizeLabel;
83                 private Label scriptLabel;
84                 
85                 private GroupBox exampleGroupBox;
86                 
87                 private ColorComboBox colorComboBox;
88                 
89                 private string currentFontName;
90                 
91                 private float currentSize;
92                 
93                 private FontFamily currentFamily;
94                 
95                 private FontStyle currentFontStyle;
96                 
97                 private bool underlined = false;
98                 private bool strikethrough = false;
99                 
100                 private Hashtable fontHash = new Hashtable();
101                 
102                 private int[] a_sizes = {
103                         6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72
104                 };
105                 
106                 // char set stuff is only here to make me happy :-)
107                 private string [] char_sets_names = {
108                         "Western",
109                         "Symbol",
110                         "Shift Jis",
111                         "Hangul",
112                         "GB2312",
113                         "BIG5",
114                         "Greek",
115                         "Turkish",
116                         "Hebrew",
117                         "Arabic",
118                         "Baltic",
119                         "Vietname",
120                         "Cyrillic",
121                         "East European",
122                         "Thai",
123                         "Johab",
124                         "Mac",
125                         "OEM",
126                         "VISCII",
127                         "TCVN",
128                         "KOI-8",
129                         "ISO-8859-3",
130                         "ISO-8859-4",
131                         "ISO-8859-10",
132                         "Celtic"
133                 };
134                 
135                 private string [] char_sets = {
136                         "AaBbYyZz",
137                         "Symbol",
138                         "Aa" + (char)0x3042 + (char)0x3041 + (char)0x30a2  + (char)0x30a1 + (char)0x4e9c + (char)0x5b87,
139                         (char)0xac00 + (char)0xb098 + (char)0xb2e4 + "AaBYyZz",
140                         new String(new Char [] {(char)0x5fae, (char)0x8f6f, (char)0x4e2d, (char)0x6587, (char)0x8f6f, (char)0x4ef6}),
141                         new String(new Char [] {(char)0x4e2d, (char)0x6587, (char)0x5b57, (char)0x578b, (char)0x7bc4, (char)0x4f8b}),
142                         "AaBb" + (char)0x0391 + (char)0x03b1 + (char)0x0392 + (char)0x03b2,
143                         "AaBb" + (char)0x011e + (char)0x011f + (char)0x015e + (char)0x015f,
144                         "AaBb" + (char)0x05e0 + (char)0x05e1 + (char)0x05e9 + (char)0x05ea,
145                         "AaBb" + (char)0x0627 + (char)0x0628 + (char)0x062c + (char)0x062f + (char)0x0647 + (char)0x0648 + (char)0x0632,
146                         "AaBbYyZz",
147                         "AaBb" + (char)0x01a0 + (char)0x01a1 + (char)0x01af + (char)0x01b0,
148                         "AaBb" + (char)0x0411 + (char)0x0431 + (char)0x0424 + (char)0x0444,
149                         "AaBb" + (char)0xc1 + (char)0xe1 + (char)0xd4 + (char)0xf4,
150                         "AaBb" + (char)0x0e2d + (char)0x0e31 + (char)0x0e01 + (char)0x0e29 + (char)0x0e23 + (char)0x0e44 + (char)0x0e17 +(char)0x0e22,
151                         (char)0xac00 + (char)0xb098 + (char)0xb2e4 + "AaBYyZz",
152                         "AaBbYyZz",
153                         "AaBb" + (char)0xf8 + (char)0xf1 + (char)0xfd,
154                         "",
155                         "",
156                         "",
157                         "",
158                         "",
159                         "",
160                         ""
161                 };
162                 
163                 private string example_panel_text;
164                 
165                 private bool internal_change = false;
166                 
167                 #region Public Constructors
168                 public FontDialog( )
169                 {
170                         form = new DialogForm (this);
171                         example_panel_text = char_sets [0];
172                         
173                         okButton = new Button( );
174                         cancelButton = new Button( );
175                         applyButton = new Button( );
176                         helpButton = new Button( );
177                         
178                         fontTextBox = new TextBox( );
179                         fontstyleTextBox = new TextBox( );
180                         fontsizeTextBox = new TextBox( );
181                         
182                         fontListBox = new MouseWheelListBox ();
183                         fontsizeListBox = new MouseWheelListBox ();
184                         fontstyleListBox = new MouseWheelListBox ();
185                         
186                         fontLabel = new Label( );
187                         fontstyleLabel = new Label( );
188                         sizeLabel = new Label( );
189                         scriptLabel = new Label( );
190                         
191                         exampleGroupBox = new GroupBox( );
192                         
193                         effectsGroupBox = new GroupBox( );
194                         underlinedCheckBox = new CheckBox( );
195                         strikethroughCheckBox = new CheckBox( );
196                         scriptComboBox = new ComboBox( );
197                         
198                         examplePanel = new Panel( );
199                         
200                         colorComboBox = new ColorComboBox( this );
201                         
202                         exampleGroupBox.SuspendLayout( );
203                         effectsGroupBox.SuspendLayout( );
204                         form.SuspendLayout( );
205                         
206                         form.FormBorderStyle = FormBorderStyle.FixedDialog;
207                         form.MaximizeBox = false;
208                         
209                         // fontsizeListBox
210                         fontsizeListBox.Location = new Point( 284, 47 );
211                         fontsizeListBox.Size = new Size( 52, 95 );
212                         fontsizeListBox.TabIndex = 10;
213                         fontListBox.Sorted = true;
214                         // fontTextBox
215                         fontTextBox.Location = new Point( 16, 26 );
216                         fontTextBox.Size = new Size( 140, 21 );
217                         fontTextBox.TabIndex = 5;
218                         fontTextBox.Text = "";
219                         // fontstyleLabel
220                         fontstyleLabel.Location = new Point( 164, 10 );
221                         fontstyleLabel.Size = new Size( 100, 16 );
222                         fontstyleLabel.TabIndex = 1;
223                         fontstyleLabel.Text = "Font Style:";
224                         // typesizeTextBox
225                         fontsizeTextBox.Location = new Point( 284, 26 );
226                         fontsizeTextBox.Size = new Size( 52, 21 );
227                         fontsizeTextBox.TabIndex = 7;
228                         fontsizeTextBox.Text = "";
229                         fontsizeTextBox.MaxLength = 2;
230                         // schriftartListBox
231                         fontListBox.Location = new Point( 16, 47 );
232                         fontListBox.Size = new Size( 140, 95 );
233                         fontListBox.TabIndex = 8;
234                         fontListBox.Sorted = true;
235                         // exampleGroupBox
236                         exampleGroupBox.Controls.Add( examplePanel );
237                         exampleGroupBox.FlatStyle = FlatStyle.System;
238                         exampleGroupBox.Location = new Point( 164, 158 );
239                         exampleGroupBox.Size = new Size( 172, 70 );
240                         exampleGroupBox.TabIndex = 12;
241                         exampleGroupBox.TabStop = false;
242                         exampleGroupBox.Text = "Example";
243                         // fontstyleListBox
244                         fontstyleListBox.Location = new Point( 164, 47 );
245                         fontstyleListBox.Size = new Size( 112, 95 );
246                         fontstyleListBox.TabIndex = 9;
247                         // schriftartLabel
248                         fontLabel.Location = new Point( 16, 10 );
249                         fontLabel.Size = new Size( 88, 16 );
250                         fontLabel.TabIndex = 0;
251                         fontLabel.Text = "Font:";
252                         // effectsGroupBox
253                         effectsGroupBox.Controls.Add( underlinedCheckBox );
254                         effectsGroupBox.Controls.Add( strikethroughCheckBox );
255                         effectsGroupBox.Controls.Add( colorComboBox );
256                         effectsGroupBox.FlatStyle = FlatStyle.System;
257                         effectsGroupBox.Location = new Point( 16, 158 );
258                         effectsGroupBox.Size = new Size( 140, 116 );
259                         effectsGroupBox.TabIndex = 11;
260                         effectsGroupBox.TabStop = false;
261                         effectsGroupBox.Text = "Effects";
262                         // strikethroughCheckBox
263                         strikethroughCheckBox.FlatStyle = FlatStyle.System;
264                         strikethroughCheckBox.Location = new Point( 8, 16 );
265                         strikethroughCheckBox.TabIndex = 0;
266                         strikethroughCheckBox.Text = "Strikethrough";
267                         // colorComboBox
268                         colorComboBox.Location = new Point( 8, 70 );
269                         colorComboBox.Size = new Size( 130, 21 );
270                         // sizeLabel
271                         sizeLabel.Location = new Point( 284, 10 );
272                         sizeLabel.Size = new Size( 100, 16 );
273                         sizeLabel.TabIndex = 2;
274                         sizeLabel.Text = "Size:";
275                         // scriptComboBox
276                         scriptComboBox.Location = new Point( 164, 253 );
277                         scriptComboBox.Size = new Size( 172, 21 );
278                         scriptComboBox.TabIndex = 14;
279                         scriptComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
280                         // okButton
281                         okButton.FlatStyle = FlatStyle.System;
282                         okButton.Location = new Point( 352, 26 );
283                         okButton.Size = new Size( 70, 23 );
284                         okButton.TabIndex = 3;
285                         okButton.Text = "OK";
286                         // cancelButton
287                         cancelButton.FlatStyle = FlatStyle.System;
288                         cancelButton.Location = new Point( 352, 52 );
289                         cancelButton.Size = new Size( 70, 23 );
290                         cancelButton.TabIndex = 4;
291                         cancelButton.Text = "Cancel";
292                         // applyButton
293                         applyButton.FlatStyle = FlatStyle.System;
294                         applyButton.Location = new Point( 352, 78 );
295                         applyButton.Size = new Size( 70, 23 );
296                         applyButton.TabIndex = 5;
297                         applyButton.Text = "Apply";
298                         // helpButton
299                         helpButton.FlatStyle = FlatStyle.System;
300                         helpButton.Location = new Point( 352, 104 );
301                         helpButton.Size = new Size( 70, 23 );
302                         helpButton.TabIndex = 6;
303                         helpButton.Text = "Help";
304                         // underlinedCheckBox
305                         underlinedCheckBox.FlatStyle = FlatStyle.System;
306                         underlinedCheckBox.Location = new Point( 8, 36 );
307                         underlinedCheckBox.TabIndex = 1;
308                         underlinedCheckBox.Text = "Underlined";
309                         // fontstyleTextBox
310                         fontstyleTextBox.Location = new Point( 164, 26 );
311                         fontstyleTextBox.Size = new Size( 112, 21 );
312                         fontstyleTextBox.TabIndex = 6;
313                         fontstyleTextBox.Text = "";
314                         // scriptLabel
315                         scriptLabel.Location = new Point( 164, 236 );
316                         scriptLabel.Size = new Size( 100, 16 );
317                         scriptLabel.TabIndex = 13;
318                         scriptLabel.Text = "Script:";
319                         // examplePanel
320                         examplePanel.Location = new Point( 8, 20 );
321                         examplePanel.TabIndex = 0;
322                         examplePanel.Size = new Size( 156, 40 );
323                         examplePanel.BorderStyle = BorderStyle.Fixed3D;
324                         
325                         form.AcceptButton = okButton;
326                         form.CancelButton = cancelButton;
327                         
328                         form.Controls.Add( scriptComboBox );
329                         form.Controls.Add( scriptLabel );
330                         form.Controls.Add( exampleGroupBox );
331                         form.Controls.Add( effectsGroupBox );
332                         form.Controls.Add( fontsizeListBox );
333                         form.Controls.Add( fontstyleListBox );
334                         form.Controls.Add( fontListBox );
335                         form.Controls.Add( fontsizeTextBox );
336                         form.Controls.Add( fontstyleTextBox );
337                         form.Controls.Add( fontTextBox );
338                         form.Controls.Add( cancelButton );
339                         form.Controls.Add( okButton );
340                         form.Controls.Add( sizeLabel );
341                         form.Controls.Add( fontstyleLabel );
342                         form.Controls.Add( fontLabel );
343                         form.Controls.Add( applyButton );
344                         form.Controls.Add( helpButton );
345                         
346                         exampleGroupBox.ResumeLayout( false );
347                         effectsGroupBox.ResumeLayout( false );
348                         
349                         form.Size = new Size( 430, 318 );
350                         
351                         form.FormBorderStyle = FormBorderStyle.FixedDialog;
352                         form.MaximizeBox = false;
353                         
354                         form.Text = "Font";
355                         
356                         form.ResumeLayout( false );
357                         
358                         scriptComboBox.BeginUpdate ();
359                         scriptComboBox.Items.AddRange (char_sets_names);
360                         scriptComboBox.SelectedIndex = 0;
361                         scriptComboBox.EndUpdate ();
362                         
363                         applyButton.Hide( );
364                         helpButton.Hide( );
365                         colorComboBox.Hide( );
366                         
367                         cancelButton.Click += new EventHandler( OnClickCancelButton );
368                         okButton.Click += new EventHandler( OnClickOkButton );
369                         applyButton.Click += new EventHandler (OnApplyButton);
370                         examplePanel.Paint += new PaintEventHandler( OnPaintExamplePanel );
371                         fontListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedFontListBox );
372                         fontsizeListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedSizeListBox );
373                         fontstyleListBox.SelectedIndexChanged += new EventHandler( OnSelectedIndexChangedFontStyleListBox );
374                         underlinedCheckBox.CheckedChanged += new EventHandler( OnCheckedChangedUnderlinedCheckBox );
375                         strikethroughCheckBox.CheckedChanged += new EventHandler( OnCheckedChangedStrikethroughCheckBox );
376                         scriptComboBox.SelectedIndexChanged += new EventHandler (OnSelectedIndexChangedScriptComboBox);
377                         
378                         fontTextBox.KeyPress += new KeyPressEventHandler (OnFontTextBoxKeyPress);
379                         fontstyleTextBox.KeyPress += new KeyPressEventHandler (OnFontStyleTextBoxKeyPress);
380                         fontsizeTextBox.KeyPress += new KeyPressEventHandler (OnFontSizeTextBoxKeyPress);
381                         
382                         fontTextBox.TextChanged += new EventHandler (OnFontTextBoxTextChanged);
383                         fontstyleTextBox.TextChanged += new EventHandler (OnFontStyleTextTextChanged);
384                         fontsizeTextBox.TextChanged += new EventHandler (OnFontSizeTextBoxTextChanged);
385                         
386                         fontTextBox.KeyDown += new KeyEventHandler (OnFontTextBoxKeyDown);
387                         fontstyleTextBox.KeyDown += new KeyEventHandler (OnFontStyleTextBoxKeyDown);
388                         fontsizeTextBox.KeyDown += new KeyEventHandler (OnFontSizeTextBoxKeyDown);
389                         
390                         fontTextBox.MouseWheel += new MouseEventHandler (OnFontTextBoxMouseWheel);
391                         fontstyleTextBox.MouseWheel += new MouseEventHandler (OnFontStyleTextBoxMouseWheel);
392                         fontsizeTextBox.MouseWheel += new MouseEventHandler (OnFontSizeTextBoxMouseWheel);
393                         
394                         PopulateFontList ();
395                         Font = form.Font;
396                 }
397                 #endregion      // Public Constructors
398                 
399                 #region Public Instance Properties
400                 public Font Font
401                 {
402                         get {
403                                 return font;
404                         }
405                         
406                         set {
407                                 if (value != null) {
408                                         font = new Font(value, value.Style);
409                                         
410                                         currentFontStyle = font.Style;
411                                         currentSize = font.Size;
412                                         currentFontName = font.Name;
413                                         
414                                         strikethroughCheckBox.Checked = font.Strikeout;
415                                         underlinedCheckBox.Checked = font.Underline;
416                                         
417                                         int index = fontListBox.FindString (currentFontName);
418                                         
419                                         if (index != -1) {
420                                                 fontListBox.SelectedIndex = index;
421                                         } else {
422                                                 fontListBox.SelectedIndex = 0;
423                                         }
424                                         
425                                         UpdateFontSizeListBox ();
426                                         UpdateFontStyleListBox ();
427                                         
428                                         fontListBox.TopIndex = fontListBox.SelectedIndex;
429                                 }
430                         }
431                 }
432                 
433                 [DefaultValue(false)]
434                 public bool FontMustExist
435                 {
436                         get {
437                                 return fontMustExist;
438                         }
439                         
440                         set {
441                                 fontMustExist = value;
442                         }
443                 }
444
445 #if NET_2_0
446                 [DefaultValue ("Color [Black]")]
447 #endif
448                 public Color Color
449                 {
450                         set {
451                                 color = value;
452                                 examplePanel.Invalidate( );
453                         }
454                         
455                         get {
456                                 return color;
457                         }
458                 }
459                 
460                 [DefaultValue(true)]
461                 public bool AllowSimulations
462                 {
463                         set {
464                                 allowSimulations = value;
465                         }
466                         
467                         get {
468                                 return allowSimulations;
469                         }
470                 }
471                 
472                 [DefaultValue(true)]
473                 public bool AllowVectorFonts
474                 {
475                         set {
476                                 allowVectorFonts = value;
477                         }
478                         
479                         get {
480                                 return allowVectorFonts;
481                         }
482                 }
483                 
484                 [DefaultValue(true)]
485                 public bool AllowVerticalFonts
486                 {
487                         set {
488                                 allowVerticalFonts = value;
489                         }
490                         
491                         get {
492                                 return allowVerticalFonts;
493                         }
494                 }
495                 
496                 [DefaultValue(true)]
497                 public bool AllowScriptChange
498                 {
499                         set {
500                                 allowScriptChange = value;
501                         }
502                         
503                         get {
504                                 return allowScriptChange;
505                         }
506                 }
507                 
508                 [DefaultValue(false)]
509                 public bool FixedPitchOnly
510                 {
511                         set {
512                                 if (fixedPitchOnly != value) {
513                                         fixedPitchOnly = value;
514                                         PopulateFontList ();
515                                 }
516                         }
517                         
518                         get {
519                                 return fixedPitchOnly;
520                         }
521                 }
522                 
523                 [DefaultValue(0)]
524                 public int MaxSize
525                 {
526                         set {
527                                 maxSize = value;
528                                 
529                                 if (maxSize < 0)
530                                         maxSize = 0;
531                                 
532                                 if (maxSize < minSize)
533                                         minSize = maxSize;
534                                 
535                                 CreateFontSizeListBoxItems ();
536                         }
537                         
538                         get {
539                                 return maxSize;
540                         }
541                 }
542                 
543                 [DefaultValue(0)]
544                 public int MinSize
545                 {
546                         set {
547                                 minSize = value;
548                                 
549                                 if (minSize < 0)
550                                         minSize = 0;
551                                 
552                                 if (minSize > maxSize)
553                                         maxSize = minSize;
554                                 
555                                 CreateFontSizeListBoxItems ();
556                                 
557                                 if (minSize > currentSize)
558                                         if (font != null) {
559                                                 font.Dispose();
560                                                 
561                                                 currentSize = minSize;
562                                                 
563                                                 font = new Font( currentFamily, currentSize, currentFontStyle );
564                                                 
565                                                 UpdateExamplePanel ();
566                                                 
567                                                 fontsizeTextBox.Text = currentSize.ToString ();
568                                         }
569                         }
570                         
571                         get {
572                                 return minSize;
573                         }
574                 }
575                 
576                 [DefaultValue(false)]
577                 public bool ScriptsOnly
578                 {
579                         set {
580                                 scriptsOnly = value;
581                         }
582                         
583                         get {
584                                 return scriptsOnly;
585                         }
586                 }
587                 
588                 [DefaultValue(false)]
589                 public bool ShowApply
590                 {
591                         set {
592                                 if (value != showApply)
593                                 {
594                                         showApply = value;
595                                         if (showApply)
596                                                 applyButton.Show ();
597                                         else
598                                                 applyButton.Hide ();
599                                         
600                                         form.Refresh();
601                                 }
602                                 
603                         }
604                         
605                         get {
606                                 return showApply;
607                         }
608                 }
609                 
610                 [DefaultValue(false)]
611                 public bool ShowColor
612                 {
613                         set {
614                                 if (value != showColor)
615                                 {
616                                         showColor = value;
617                                         if (showColor)
618                                                 colorComboBox.Show ();
619                                         else
620                                                 colorComboBox.Hide ();
621                                         
622                                         form.Refresh();
623                                 }
624                         }
625                         
626                         get {
627                                 return showColor;
628                         }
629                 }
630                 
631                 [DefaultValue(true)]
632                 public bool ShowEffects
633                 {
634                         set {
635                                 if (value != showEffects)
636                                 {
637                                         showEffects = value;
638                                         if (showEffects)
639                                                 effectsGroupBox.Show ();
640                                         else
641                                                 effectsGroupBox.Hide ();
642                                         
643                                         form.Refresh();
644                                 }
645                         }
646                         
647                         get {
648                                 return showEffects;
649                         }
650                 }
651                 
652                 [DefaultValue(false)]
653                 public bool ShowHelp
654                 {
655                         set {
656                                 if (value != showHelp)
657                                 {
658                                         showHelp = value;
659                                         if (showHelp)
660                                                 helpButton.Show ();
661                                         else
662                                                 helpButton.Hide ();
663                                         
664                                         form.Refresh();
665                                 }
666                         }
667                         
668                         get {
669                                 return showHelp;
670                         }
671                 }
672                 
673                 #endregion      // Public Instance Properties
674                 
675                 #region Protected Instance Properties
676                 protected int Options {
677                         get { return 0; }
678                 }
679                 #endregion      // Protected Instance Properties
680                 
681                 #region Public Instance Methods
682                 public override void Reset( )
683                 {
684                         color = Color.Black;
685                         allowSimulations = true;
686                         allowVectorFonts = true;
687                         allowVerticalFonts = true;
688                         allowScriptChange = true;
689                         fixedPitchOnly = false;
690                         
691                         maxSize = 0;
692                         minSize = 0;
693                         CreateFontSizeListBoxItems ();
694                         
695                         scriptsOnly = false;
696                         
697                         showApply = false;
698                         applyButton.Hide ();
699                         
700                         showColor = false;
701                         colorComboBox.Hide ();
702                         
703                         showEffects = true;
704                         effectsGroupBox.Show ();
705                         
706                         showHelp = false;
707                         helpButton.Hide ();
708                         
709                         form.Refresh ();
710                 }
711
712                 public override string ToString ()
713                 {
714                         if (font == null)
715                                 return base.ToString ();
716                         return String.Concat (base.ToString (), ", Font: ", font.ToString ());
717                 }
718                 #endregion      // Public Instance Methods
719                 
720                 #region Protected Instance Methods
721                 protected override IntPtr HookProc (IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
722                 {
723                         return base.HookProc (hWnd, msg, wparam, lparam);
724                 }
725
726                 protected override bool RunDialog( IntPtr hWndOwner )
727                 {
728                         form.Refresh();
729                         
730                         return true;
731                 }
732
733                 internal void OnApplyButton (object sender, EventArgs e)
734                 {
735                         OnApply (e);
736                 }
737
738                 protected virtual void OnApply (EventArgs e)
739                 {
740                         EventHandler apply = (EventHandler) Events [EventApply];
741                         if (apply != null)
742                                 apply (this, e);
743                 }
744                 #endregion      // Protected Instance Methods
745                 
746                 void OnClickCancelButton( object sender, EventArgs e )
747                 {
748                         form.DialogResult = DialogResult.Cancel;
749                 }
750                 
751                 void OnClickOkButton( object sender, EventArgs e )
752                 {
753                         form.DialogResult = DialogResult.OK;
754                 }
755                 
756                 void OnPaintExamplePanel( object sender, PaintEventArgs e )
757                 {
758                         SolidBrush brush = ThemeEngine.Current.ResPool.GetSolidBrush( color );
759                         
760                         e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( SystemColors.Control ), 0, 0, 156, 40 );
761                         
762                         SizeF fontSizeF = e.Graphics.MeasureString( example_panel_text, font );
763                         
764                         int text_width = (int)fontSizeF.Width;
765                         int text_height = (int)fontSizeF.Height;
766                         
767                         int x = ( examplePanel.Width / 2 ) - ( text_width / 2 );
768                         if ( x < 0 ) x = 0;
769                         
770                         int y = ( examplePanel.Height / 2 ) - ( text_height / 2 );
771                         
772                         e.Graphics.DrawString( example_panel_text, font, brush, new Point( x, y ) );
773                 }
774                 
775                 void OnSelectedIndexChangedFontListBox( object sender, EventArgs e )
776                 {
777                         if ( fontListBox.SelectedIndex != -1 )
778                         {
779                                 currentFamily = FindByName( fontListBox.Items[ fontListBox.SelectedIndex ].ToString( ) );
780                                 
781                                 fontTextBox.Text = currentFamily.Name;
782                                 
783                                 internal_change = true;
784                                 
785                                 UpdateFontStyleListBox( );
786                                 
787                                 UpdateFontSizeListBox ();
788                                 
789                                 UpdateExamplePanel ();
790                                 
791                                 form.Select(fontTextBox);
792                                 
793                                 internal_change = false;
794                         }
795                 }
796                 
797                 void OnSelectedIndexChangedSizeListBox( object sender, EventArgs e )
798                 {
799                         if ( fontsizeListBox.SelectedIndex != -1 )
800                         {
801                                 currentSize = (float)System.Convert.ToDouble( fontsizeListBox.Items[ fontsizeListBox.SelectedIndex ] );
802                                 
803                                 fontsizeTextBox.Text = currentSize.ToString( );
804                                 
805                                 UpdateExamplePanel( );
806                                 
807                                 if (!internal_change)
808                                         form.Select(fontsizeTextBox);
809                         }
810                 }
811                 
812                 void OnSelectedIndexChangedFontStyleListBox( object sender, EventArgs e )
813                 {
814                         if ( fontstyleListBox.SelectedIndex != -1 )
815                         {
816                                 switch ( fontstyleListBox.SelectedIndex )
817                                 {
818                                 case 0:
819                                         currentFontStyle = FontStyle.Regular;
820                                         break;
821                                 case 1:
822                                         currentFontStyle = FontStyle.Bold;
823                                         break;
824                                 case 2:
825                                         currentFontStyle = FontStyle.Italic;
826                                         break;
827                                 case 3:
828                                         currentFontStyle = FontStyle.Bold | FontStyle.Italic;
829                                         break;
830                                 default:
831                                         currentFontStyle = FontStyle.Regular;
832                                         break;
833                                 }
834                                 
835                                 if (underlined) 
836                                         currentFontStyle = currentFontStyle | FontStyle.Underline;
837                                 
838                                 if (strikethrough)
839                                         currentFontStyle = currentFontStyle | FontStyle.Strikeout;
840                                 
841                                 fontstyleTextBox.Text = fontstyleListBox.Items[ fontstyleListBox.SelectedIndex ].ToString( );
842                                 
843                                 if (!internal_change) {
844                                         UpdateExamplePanel( );
845                                         
846                                         form.Select(fontstyleTextBox);
847                                 }
848                         }
849                 }
850                 
851                 void OnCheckedChangedUnderlinedCheckBox( object sender, EventArgs e )
852                 {
853                         if ( underlinedCheckBox.Checked ) {
854                                 currentFontStyle = currentFontStyle | FontStyle.Underline;
855                                 underlined = true;
856                         }
857                         else {
858                                 currentFontStyle = currentFontStyle ^ FontStyle.Underline;
859                                 underlined = false;
860                         }
861                         
862                         UpdateExamplePanel( );
863                 }
864                 
865                 void OnCheckedChangedStrikethroughCheckBox( object sender, EventArgs e )
866                 {
867                         if ( strikethroughCheckBox.Checked ) {
868                                 currentFontStyle = currentFontStyle | FontStyle.Strikeout;
869                                 strikethrough = true;
870                         }
871                         else {
872                                 currentFontStyle = currentFontStyle ^ FontStyle.Strikeout;
873                                 strikethrough = false;
874                         }
875                         
876                         UpdateExamplePanel( );
877                 }
878                 
879                 bool internal_textbox_change = false;
880                 
881                 void OnFontTextBoxMouseWheel (object sender, MouseEventArgs e)
882                 {
883                         fontListBox.SendMouseWheelEvent (e);
884                 }
885                 
886                 void OnFontStyleTextBoxMouseWheel (object sender, MouseEventArgs e)
887                 {
888                         fontstyleListBox.SendMouseWheelEvent (e);
889                 }
890                 
891                 void OnFontSizeTextBoxMouseWheel (object sender, MouseEventArgs e)
892                 {
893                         fontsizeListBox.SendMouseWheelEvent (e);
894                 }
895                 
896                 void OnFontTextBoxKeyDown (object sender, KeyEventArgs e)
897                 {
898                         if (e.KeyCode == Keys.Up) {
899                                 int sel_index = fontListBox.SelectedIndex;
900                                 
901                                 sel_index--;
902                                 
903                                 if (sel_index < 0)
904                                         sel_index = 0;
905                                 
906                                 fontListBox.SelectedIndex = sel_index;
907                         } else if (e.KeyCode == Keys.Down) {
908                                 int sel_index = fontListBox.SelectedIndex;
909                                 
910                                 sel_index++;
911                                 
912                                 if (sel_index > fontListBox.Items.Count - 1)
913                                         sel_index = fontListBox.Items.Count - 1;
914                                 
915                                 fontListBox.SelectedIndex = sel_index;
916                         }
917                 }
918                 
919                 void OnFontStyleTextBoxKeyDown (object sender, KeyEventArgs e)
920                 {
921                         if (e.KeyCode == Keys.Up) {
922                                 int sel_index = fontstyleListBox.SelectedIndex;
923                                 
924                                 sel_index--;
925                                 
926                                 if (sel_index < 0)
927                                         sel_index = 0;
928                                 
929                                 fontstyleListBox.SelectedIndex = sel_index;
930                         } else if (e.KeyCode == Keys.Down) {
931                                 int sel_index = fontstyleListBox.SelectedIndex;
932                                 
933                                 sel_index++;
934                                 
935                                 if (sel_index > fontstyleListBox.Items.Count - 1)
936                                         sel_index = fontstyleListBox.Items.Count - 1;
937                                 
938                                 fontstyleListBox.SelectedIndex = sel_index;
939                         }
940                 }
941                 
942                 void OnFontSizeTextBoxKeyDown (object sender, KeyEventArgs e)
943                 {
944                         if (e.KeyCode == Keys.Up) {
945                                 int sel_index = fontsizeListBox.SelectedIndex;
946                                 
947                                 sel_index--;
948                                 
949                                 if (sel_index < 0)
950                                         sel_index = 0;
951                                 
952                                 fontsizeListBox.SelectedIndex = sel_index;
953                         } else if (e.KeyCode == Keys.Down) {
954                                 int sel_index = fontsizeListBox.SelectedIndex;
955                                 
956                                 sel_index++;
957                                 
958                                 if (sel_index > fontsizeListBox.Items.Count - 1)
959                                         sel_index = fontsizeListBox.Items.Count - 1;
960                                 
961                                 fontsizeListBox.SelectedIndex = sel_index;
962                         }
963                 }
964                 
965                 void OnFontTextBoxKeyPress (object sender, KeyPressEventArgs e)
966                 {
967                         internal_textbox_change = true;
968                         
969                         if (fontListBox.SelectedIndex > -1)
970                                 fontListBox.SelectedIndex = -1;
971                 }
972                 
973                 void OnFontStyleTextBoxKeyPress (object sender, KeyPressEventArgs e)
974                 {
975                         internal_textbox_change = true;
976                         
977                         if (fontstyleListBox.SelectedIndex > -1)
978                                 fontstyleListBox.SelectedIndex = -1;
979                 }
980                 
981                 void OnFontSizeTextBoxKeyPress (object sender, KeyPressEventArgs e)
982                 {
983                         if (Char.IsLetter (e.KeyChar) || Char.IsWhiteSpace (e.KeyChar) || Char.IsPunctuation (e.KeyChar) || e.KeyChar == ',') {
984                                 e.Handled = true;
985                                 return; 
986                         }
987                         
988                         internal_textbox_change = true;
989                 }
990                 
991                 void OnFontTextBoxTextChanged (object sender, EventArgs e)
992                 {
993                         if (!internal_textbox_change)
994                                 return;
995                         
996                         internal_textbox_change = false;
997                         
998                         for (int i = 0; i < fontListBox.Items.Count; i++) {
999                                 string name = fontListBox.Items [i] as string;
1000                                 
1001                                 if (name.StartsWith(fontTextBox.Text)) {
1002                                         if (name == fontTextBox.Text)
1003                                                 fontListBox.SelectedIndex = i;
1004                                         else
1005                                                 fontListBox.TopIndex = i;
1006                                         
1007                                         break;
1008                                 }
1009                         }
1010                 }
1011                 
1012                 void OnFontStyleTextTextChanged (object sender, EventArgs e)
1013                 {
1014                         if (!internal_textbox_change)
1015                                 return;
1016                         
1017                         internal_textbox_change = false;
1018                         
1019                         for (int i = 0; i < fontstyleListBox.Items.Count; i++) {
1020                                 string name = fontstyleListBox.Items [i] as string;
1021                                 
1022                                 if (name.StartsWith(fontstyleTextBox.Text)) {
1023                                         if (name == fontstyleTextBox.Text)
1024                                                 fontstyleListBox.SelectedIndex = i;
1025                                         
1026                                         break;
1027                                 }
1028                         }
1029                 }
1030                 
1031                 void OnFontSizeTextBoxTextChanged (object sender, EventArgs e)
1032                 {
1033                         if (!internal_textbox_change)
1034                                 return;
1035                         
1036                         internal_textbox_change = false;
1037                         
1038                         if (fontsizeTextBox.Text.Length == 0)
1039                                 return;
1040                         
1041                         for (int i = 0; i < fontsizeListBox.Items.Count; i++) {
1042                                 string name = fontsizeListBox.Items [i] as string;
1043                                 
1044                                 if (name.StartsWith(fontsizeTextBox.Text)) {
1045                                         if (name == fontsizeTextBox.Text)
1046                                                 fontsizeListBox.SelectedIndex = i;
1047                                         else
1048                                                 fontsizeListBox.TopIndex = i;
1049                                         
1050                                         break;
1051                                 }
1052                         }
1053                 }
1054                 
1055                 void OnSelectedIndexChangedScriptComboBox (object sender, EventArgs e)
1056                 {
1057                         string tmp_str = char_sets [scriptComboBox.SelectedIndex];
1058                         
1059                         if (tmp_str.Length > 0) {
1060                                 example_panel_text = tmp_str;
1061                                 
1062                                 UpdateExamplePanel ();
1063                         }
1064                 }
1065                 
1066                 void UpdateExamplePanel( )
1067                 {
1068                         if (font != null)
1069                                 font.Dispose();
1070                         
1071                         font = new Font( currentFamily, currentSize, currentFontStyle );
1072                         
1073                         examplePanel.Invalidate( );
1074                 }
1075                 
1076                 void UpdateFontSizeListBox ()
1077                 {
1078                         int index = fontsizeListBox.FindString(((int)(currentSize)).ToString());
1079                         
1080                         if (index != -1)
1081                                 fontsizeListBox.SelectedIndex = index;
1082                         else 
1083                                 fontsizeListBox.SelectedIndex = 0;
1084                 }
1085                 
1086                 void UpdateFontStyleListBox( )
1087                 {
1088                         // don't know if that works, IsStyleAvailable returns true for all styles under X
1089                         
1090                         fontstyleListBox.BeginUpdate( );
1091                         
1092                         fontstyleListBox.Items.Clear( );
1093                         
1094                         int index = -1;
1095                         int to_select = 0;
1096                         
1097                         if ( currentFamily.IsStyleAvailable( FontStyle.Regular ) )
1098                         {
1099                                 index = fontstyleListBox.Items.Add( "Regular" );
1100                                 
1101                                 if ((currentFontStyle & FontStyle.Regular) == FontStyle.Regular)
1102                                         to_select = index;
1103                         }
1104                         
1105                         if ( currentFamily.IsStyleAvailable( FontStyle.Bold ) )
1106                         {
1107                                 index = fontstyleListBox.Items.Add( "Bold" );
1108                                 
1109                                 if ((currentFontStyle & FontStyle.Bold) == FontStyle.Bold)
1110                                         to_select = index;
1111                         }
1112                         
1113                         if ( currentFamily.IsStyleAvailable( FontStyle.Italic ) )
1114                         {
1115                                 index = fontstyleListBox.Items.Add( "Italic" );
1116                                 
1117                                 if ((currentFontStyle & FontStyle.Italic) == FontStyle.Italic)
1118                                         to_select = index;
1119                         }
1120                         
1121                         if ( currentFamily.IsStyleAvailable( FontStyle.Bold ) && currentFamily.IsStyleAvailable( FontStyle.Italic ) )
1122                         {
1123                                 index = fontstyleListBox.Items.Add( "Bold Italic" );
1124                                 
1125                                 if ((currentFontStyle & (FontStyle.Bold | FontStyle.Italic)) == (FontStyle.Bold | FontStyle.Italic))
1126                                         to_select = index;
1127                         }
1128                         
1129                         if (fontstyleListBox.Items.Count > 0) {
1130                                 fontstyleListBox.SelectedIndex = to_select;
1131
1132                                 switch ((string)fontstyleListBox.SelectedItem) {
1133                                         case "Regular":
1134                                                 currentFontStyle = FontStyle.Regular;
1135                                                 break;
1136                                         case "Bold":
1137                                                 currentFontStyle = FontStyle.Bold;
1138                                                 break;
1139                                         case "Italic":
1140                                                 currentFontStyle = FontStyle.Italic;
1141                                                 break;
1142                                         case "Bold Italic":
1143                                                 currentFontStyle = FontStyle.Bold | FontStyle.Italic;
1144                                                 break;
1145                                 }
1146                                 
1147                                 if (strikethroughCheckBox.Checked)
1148                                         currentFontStyle |= FontStyle.Strikeout;
1149                                 if (underlinedCheckBox.Checked)
1150                                         currentFontStyle |= FontStyle.Underline;
1151                         }
1152                         
1153                         fontstyleListBox.EndUpdate( );
1154                 }
1155                 
1156                 FontFamily FindByName( string name )
1157                 {
1158                         return fontHash[ name ] as FontFamily;
1159                 }
1160                 
1161                 void CreateFontSizeListBoxItems ()
1162                 {
1163                         fontsizeListBox.BeginUpdate ();
1164                         
1165                         fontsizeListBox.Items.Clear();
1166                         
1167                         if (minSize == 0 && maxSize == 0)
1168                         {
1169                                 foreach (int i in a_sizes)
1170                                         fontsizeListBox.Items.Add (i.ToString());
1171                         } else {
1172                                 foreach (int i in a_sizes) {
1173                                         if (i >= minSize && i <= maxSize)
1174                                                 fontsizeListBox.Items.Add (i.ToString());
1175                                 }
1176                         }
1177                         
1178                         fontsizeListBox.EndUpdate ();
1179                 }
1180
1181                 #region Private Methods
1182                 private void PopulateFontList ()
1183                 {
1184                         fontListBox.Items.Clear ();
1185                         fontHash.Clear ();
1186
1187                         fontListBox.BeginUpdate ();
1188
1189                         foreach (FontFamily ff in FontFamily.Families) {
1190                                 if (!fontHash.ContainsKey (ff.Name)) {
1191                                         if (!fixedPitchOnly || (IsFontFamilyFixedPitch (ff))) {
1192                                                 fontListBox.Items.Add (ff.Name);
1193                                                 fontHash.Add (ff.Name, ff);
1194                                         }
1195                                 }
1196                         }
1197                         
1198                         fontListBox.EndUpdate ();
1199                         CreateFontSizeListBoxItems ();
1200
1201                         if (fixedPitchOnly)
1202                                 this.Font = new Font (FontFamily.GenericMonospace, 8.25f);
1203                         else
1204                                 this.Font = form.Font;  
1205                 }
1206                 
1207                 private bool IsFontFamilyFixedPitch (FontFamily family)
1208                 {
1209                         FontStyle fs;
1210                         
1211                         if (family.IsStyleAvailable (FontStyle.Regular))
1212                                 fs = FontStyle.Regular;
1213                         else if (family.IsStyleAvailable (FontStyle.Bold))
1214                                 fs = FontStyle.Bold;
1215                         else if (family.IsStyleAvailable (FontStyle.Italic))
1216                                 fs = FontStyle.Italic;
1217                         else if (family.IsStyleAvailable (FontStyle.Strikeout))
1218                                 fs = FontStyle.Strikeout;
1219                         else if (family.IsStyleAvailable (FontStyle.Underline))
1220                                 fs = FontStyle.Underline;
1221                         else
1222                                 return false;
1223
1224                         Font f = new Font (family.Name, 10, fs);
1225
1226                         if (TextRenderer.MeasureString ("i", f).Width == TextRenderer.MeasureString ("w", f).Width)
1227                                 return true;
1228                                 
1229                         return false;
1230                 }
1231                 #endregion
1232                 
1233                 internal class ColorComboBox : ComboBox
1234                 {
1235                         internal class ColorComboBoxItem
1236                         {
1237                                 private Color color;
1238                                 private string name;
1239                                 
1240                                 public ColorComboBoxItem( Color color, string name )
1241                                 {
1242                                         this.color = color;
1243                                         this.name = name;
1244                                 }
1245                                 
1246                                 public Color Color
1247                                 {
1248                                         set {
1249                                                 color = value;
1250                                         }
1251                                         
1252                                         get {
1253                                                 return color;
1254                                         }
1255                                 }
1256                                 
1257                                 public string Name
1258                                 {
1259                                         set {
1260                                                 name = value;
1261                                         }
1262                                         
1263                                         get {
1264                                                 return name;
1265                                         }
1266                                 }
1267                         }
1268                         
1269                         private Color selectedColor;
1270                         
1271                         private FontDialog fontDialog;
1272                         
1273                         public ColorComboBox( FontDialog fontDialog )
1274                         {
1275                                 this.fontDialog = fontDialog;
1276                                 
1277                                 DropDownStyle = ComboBoxStyle.DropDownList;
1278                                 DrawMode = DrawMode.OwnerDrawFixed;
1279                                 
1280                                 Items.AddRange( new object[] {
1281                                                        new ColorComboBoxItem( Color.Black, "Black" ),
1282                                                        new ColorComboBoxItem( Color.DarkRed, "Dark-Red" ),
1283                                                        new ColorComboBoxItem( Color.Green, "Green" ),
1284                                                        new ColorComboBoxItem( Color.Olive, "Olive-Green" ), // color not correct
1285                                                        new ColorComboBoxItem( Color.Aquamarine, "Aquamarine" ), // color not correct
1286                                                        new ColorComboBoxItem( Color.Crimson, "Crimson" ),
1287                                                        new ColorComboBoxItem( Color.Cyan, "Cyan" ),
1288                                                        new ColorComboBoxItem( Color.Gray, "Gray" ),
1289                                                        new ColorComboBoxItem( Color.Silver, "Silver" ),
1290                                                        new ColorComboBoxItem( Color.Red, "Red" ),
1291                                                        new ColorComboBoxItem( Color.YellowGreen, "Yellow-Green" ),
1292                                                        new ColorComboBoxItem( Color.Yellow, "Yellow" ),
1293                                                        new ColorComboBoxItem( Color.Blue, "Blue" ),
1294                                                        new ColorComboBoxItem( Color.Purple, "Purple" ),
1295                                                        new ColorComboBoxItem( Color.Aquamarine, "Aquamarine" ),
1296                                                        new ColorComboBoxItem( Color.White, "White" ) }
1297                                                );
1298                                 
1299                                 SelectedIndex = 0;
1300                         }
1301                         
1302                         protected override void OnDrawItem( DrawItemEventArgs e )
1303                         {
1304                                 if ( e.Index == -1 )
1305                                         return;
1306                                 
1307                                 ColorComboBoxItem ccbi = Items[ e.Index ] as ColorComboBoxItem;
1308                                 
1309                                 Rectangle r = e.Bounds;
1310                                 r.X = r.X + 24;
1311                                 
1312                                 if ( ( e.State & DrawItemState.Selected ) == DrawItemState.Selected )
1313                                 {
1314                                         e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( Color.Blue ), e.Bounds ); // bot blue
1315                                         e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( ccbi.Color ), e.Bounds.X + 3, e.Bounds.Y + 3, e.Bounds.X + 16, e.Bounds.Bottom - 3 );
1316                                         e.Graphics.DrawRectangle( ThemeEngine.Current.ResPool.GetPen( Color.Black ), e.Bounds.X + 2, e. Bounds.Y + 2, e.Bounds.X + 17, e.Bounds.Bottom - 3 );
1317                                         e.Graphics.DrawString( ccbi.Name, this.Font, ThemeEngine.Current.ResPool.GetSolidBrush( Color.White ), r );
1318                                 }
1319                                 else
1320                                 {
1321                                         e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( Color.White ), e.Bounds );
1322                                         e.Graphics.FillRectangle( ThemeEngine.Current.ResPool.GetSolidBrush( ccbi.Color ), e.Bounds.X + 3, e.Bounds.Y + 3, e.Bounds.X + 16, e.Bounds.Bottom - 3 );
1323                                         e.Graphics.DrawRectangle( ThemeEngine.Current.ResPool.GetPen( Color.Black ), e.Bounds.X + 2, e. Bounds.Y + 2, e.Bounds.X + 17, e.Bounds.Bottom - 3 );
1324                                         e.Graphics.DrawString( ccbi.Name, this.Font, ThemeEngine.Current.ResPool.GetSolidBrush( Color.Black ), r );
1325                                 }
1326                         }
1327                         
1328                         protected override void OnSelectedIndexChanged( EventArgs e )
1329                         {
1330                                 ColorComboBoxItem ccbi = Items[ SelectedIndex ] as ColorComboBoxItem;
1331                                 selectedColor = ccbi.Color;
1332                                 
1333                                 fontDialog.Color = selectedColor;
1334                         }
1335                 }
1336
1337                 public event EventHandler Apply {
1338                         add { Events.AddHandler (EventApply, value); }
1339                         remove { Events.RemoveHandler (EventApply, value); }
1340                 }
1341         }
1342                 
1343         internal class MouseWheelListBox : ListBox
1344         {
1345                 public void SendMouseWheelEvent(MouseEventArgs e)
1346                 {
1347                         OnMouseWheel (e);
1348                 }
1349         }
1350 }
1351