Some formatting and cleanup.
[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 //
11 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32
33 using System;
34 using System.Collections;
35 using System.ComponentModel;
36 using System.Globalization;
37
38 namespace System.Drawing
39 {
40         public class FontConverter : TypeConverter
41         {
42                 public FontConverter ()
43                 {
44                 }
45
46                 public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
47                 {
48                         if (sourceType == typeof (string))
49                                 return true;
50
51                         return base.CanConvertFrom (context, sourceType);
52                 }
53
54                 public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
55                 {
56                         if (destinationType == typeof (String))
57                                 return true;
58
59                         return base.CanConvertTo (context, destinationType);
60                 }
61
62                 public override object ConvertTo (ITypeDescriptorContext context,
63                                                   CultureInfo culture,
64                                                   object value,
65                                                   Type destinationType)
66                 {
67                         if ((destinationType == typeof (string)) && (value is Font))
68                                 return value.ToString ();
69
70                         return base.ConvertTo (context, culture, value, destinationType);
71                 }
72
73                 [MonoTODO]
74                 public override object ConvertFrom (ITypeDescriptorContext context,
75                                                     CultureInfo culture,
76                                                     object value)
77                 {
78                         throw new NotImplementedException ();
79                 }
80
81                 [MonoTODO]
82                 public override object CreateInstance (ITypeDescriptorContext context,
83                                                        IDictionary propertyValues)
84                 {
85                         throw new NotImplementedException ();
86                 }
87
88                 public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
89                 {
90                         return true;
91                 }
92
93                 public override PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context,
94                                                                             object value,
95                                                                             Attribute [] attributes)
96                 {
97                         if (value is Font)
98                                 return TypeDescriptor.GetProperties (value, attributes);
99
100                         return base.GetProperties (context, value, attributes);
101                 }
102
103                 public override bool GetPropertiesSupported (ITypeDescriptorContext context)
104                 {
105                         return true;
106                 }
107
108                 public sealed class FontNameConverter : TypeConverter
109                 {
110                         public FontNameConverter ()
111                         {
112                         }
113
114                         public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
115                         {
116                                 if (sourceType == typeof (string))
117                                         return true;
118
119                                 return base.CanConvertFrom (context, sourceType);
120                         }
121
122                         [MonoTODO]
123                         public override object ConvertFrom (ITypeDescriptorContext context,
124                                                             CultureInfo culture,
125                                                             object value)
126                         {
127                                 throw new NotImplementedException ();
128                         }
129
130                         [MonoTODO]
131                         public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
132                         {
133                                 throw new NotImplementedException ();
134                         }
135
136                         [MonoTODO]
137                         public override bool GetStandardValuesExclusive (ITypeDescriptorContext context)
138                         {
139                                 throw new NotImplementedException ();
140                         }
141
142                         public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
143                         {
144                                 return true;
145                         }
146
147                         [MonoTODO]
148                         ~FontNameConverter ()
149                         {
150                                 throw new NotImplementedException ();
151                         }
152                 }
153
154                 public class FontUnitConverter : EnumConverter
155                 {
156                         public FontUnitConverter () : base (typeof (GraphicsUnit))
157                         {
158                         }
159
160                         [MonoTODO]
161                         public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
162                         {
163                                 throw new NotImplementedException ();
164                         }
165                 }
166         }
167 }