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