2 // System.Drawing.FontConverter.cs
5 // Dennis Hayes (dennish@Raytek.com)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // Ravindra (rkumar@novell.com)
9 // Copyright (C) 2002,2003 Ximian, Inc. http://www.ximian.com
10 // Copyright (C) 2004 Novell, Inc. http://www.novell.com
14 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
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:
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
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.
37 using System.Collections;
38 using System.ComponentModel;
39 using System.Globalization;
41 namespace System.Drawing
43 public class FontConverter : TypeConverter
45 public FontConverter ()
49 public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
51 if (sourceType == typeof (string))
54 return base.CanConvertFrom (context, sourceType);
57 public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
59 if (destinationType == typeof (String))
62 return base.CanConvertTo (context, destinationType);
65 public override object ConvertTo (ITypeDescriptorContext context,
70 if ((destinationType == typeof (string)) && (value is Font))
71 return value.ToString ();
73 return base.ConvertTo (context, culture, value, destinationType);
77 public override object ConvertFrom (ITypeDescriptorContext context,
81 throw new NotImplementedException ();
85 public override object CreateInstance (ITypeDescriptorContext context,
86 IDictionary propertyValues)
88 throw new NotImplementedException ();
91 public override bool GetCreateInstanceSupported (ITypeDescriptorContext context)
96 public override PropertyDescriptorCollection GetProperties (ITypeDescriptorContext context,
98 Attribute [] attributes)
101 return TypeDescriptor.GetProperties (value, attributes);
103 return base.GetProperties (context, value, attributes);
106 public override bool GetPropertiesSupported (ITypeDescriptorContext context)
111 public sealed class FontNameConverter : TypeConverter
113 public FontNameConverter ()
117 public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
119 if (sourceType == typeof (string))
122 return base.CanConvertFrom (context, sourceType);
126 public override object ConvertFrom (ITypeDescriptorContext context,
130 throw new NotImplementedException ();
134 public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
136 throw new NotImplementedException ();
140 public override bool GetStandardValuesExclusive (ITypeDescriptorContext context)
142 throw new NotImplementedException ();
145 public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
151 ~FontNameConverter ()
153 throw new NotImplementedException ();
157 public class FontUnitConverter : EnumConverter
159 public FontUnitConverter () : base (typeof (GraphicsUnit))
164 public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
166 throw new NotImplementedException ();