* Mono.Cairo/Cairo.cs (cairo_set_target_drawable): Not available anymore, removed.
[mono.git] / mcs / class / System.Drawing.Design / System.Drawing.Design / FontEditor.cs
1 //
2 // System.Drawing.Design.FontEditor.cs
3 // 
4 // Authors:
5 //  Martin Willemoes Hansen (mwh@sysrq.dk)
6 //  Andreas Nahr (ClassDevelopment@A-SoftTech.com)
7 // 
8 // (C) 2003 Martin Willemoes Hansen
9 // (C) 2003 Andreas Nahr
10 // 
11 using System;
12 using System.Drawing;
13 using System.ComponentModel;using System.Windows.Forms;
14 namespace System.Drawing.Design
15 {
16         public class FontEditor : UITypeEditor
17         {
18
19                 private FontDialog fontEdit;
20
21                 public FontEditor()
22                 {
23                 }
24
25                 public override object EditValue (ITypeDescriptorContext context,
26                         IServiceProvider provider, object value)
27                 {
28                         fontEdit = new FontDialog ();
29                         if (value is Font)
30                                 fontEdit.Font = (Font) value;
31                         else
32                                 // Set default
33                                 fontEdit.Font = new Drawing.Font (FontFamily.GenericSansSerif, 12);
34
35                         fontEdit.FontMustExist = true;
36                         DialogResult result = fontEdit.ShowDialog();
37
38                         if (result == DialogResult.OK)
39                                 return fontEdit.Font;
40                         else
41                                 return value;
42                 }
43
44                 public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)
45                 {
46                         return UITypeEditorEditStyle.Modal;
47                 }
48         }
49 }