* RectangleConverter.cs: Implemented GetProperties () method.
[mono.git] / mcs / class / System.Drawing / System.Drawing / FontConverter.cs
1 //
2 // System.Drawing.FontConverter.cs
3 //
4 // Authors:
5 //      Dennis Hayes (dennish@Raytek.com)
6 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 //      Ravindra (rkumar@novell.com)
8 //
9 // Copyright (C) 2002,2003 Ximian, Inc.  http://www.ximian.com
10 // Copyright (C) 2004 Novell, Inc.  http://www.novell.com
11 //
12
13 using System;
14 using System.Collections;
15 using System.ComponentModel;
16 using System.Globalization;
17
18 namespace System.Drawing
19 {
20         public class FontConverter : TypeConverter
21         {
22                 public FontConverter ()
23                 {
24                 }
25
26                 public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
27                 {
28                         if (sourceType == typeof (string))
29                                 return true;
30
31                         return base.CanConvertFrom (context, sourceType);
32                 }
33
34                 public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
35                 {
36                         if (destinationType == typeof (String))
37                                 return true;
38
39                         return base.CanConvertTo (context, destinationType);
40                 }
41
42                 public override object ConvertTo (ITypeDescriptorContext context,
43                                                   CultureInfo culture,
44                                                   object value,
45                                                   Type destinationType)
46                 {
47                         if ((destinationType == typeof (string)) && (value is Font))
48                                 return value.ToString ();
49
50                         return base.ConvertTo (context, culture, value, destinationType);
51                 }
52
53                 [MonoTODO]
54                 public override object ConvertFrom (ITypeDescriptorContext context,
55                                                     CultureInfo culture,
56                                                     object value)
57                 {
58                         throw new NotImplementedException ();
59                 }
60
61                 [MonoTODO]
62                 public override object CreateInstance (ITypeDescriptorContext context,
63                                                        IDictionary propertyValues)
64                 {
65                         throw new NotImplementedException ();
66                 }
67
68                 public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
69                 {
70                         return true;
71                 }
72
73                 public override PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context,
74                                                                             object value,
75                                                                             Attribute [] attributes)
76                 {
77                         if (value is Font)
78                                 return TypeDescriptor.GetProperties (value, attributes);
79
80                         return base.GetProperties (context, value, attributes);
81                 }
82
83                 public override bool GetPropertiesSupported (ITypeDescriptorContext context)
84                 {
85                         return true;
86                 }
87
88                 public sealed class FontNameConverter : TypeConverter
89                 {
90                         public FontNameConverter ()
91                         {
92                         }
93
94                         public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
95                         {
96                                 if (sourceType == typeof (string))
97                                         return true;
98
99                                 return base.CanConvertFrom (context, sourceType);
100                         }
101
102                         [MonoTODO]
103                         public override object ConvertFrom (ITypeDescriptorContext context,
104                                                             CultureInfo culture,
105                                                             object value)
106                         {
107                                 throw new NotImplementedException ();
108                         }
109
110                         [MonoTODO]
111                         public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
112                         {
113                                 throw new NotImplementedException ();
114                         }
115
116                         [MonoTODO]
117                         public override bool GetStandardValuesExclusive (ITypeDescriptorContext context)
118                         {
119                                 throw new NotImplementedException ();
120                         }
121
122                         public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
123                         {
124                                 return true;
125                         }
126
127                         [MonoTODO]
128                         ~FontNameConverter ()
129                         {
130                                 throw new NotImplementedException ();
131                         }
132                 }
133
134                 public sealed class FontUnitConverter : TypeConverter
135                 {
136                         public FontUnitConverter () 
137                         {
138                         }
139
140                         [MonoTODO]
141                         public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
142                         {
143                                 throw new NotImplementedException ();
144                         }
145                 }
146         }
147 }