Browse Source

2002-06-15 Gonzalo Paniagua Javier <[email protected]>

	* System/System.build: referenced System.Drawing.dll.

	* System/System.ComponentModel/TypeConverter.cs:
	* System/System.ComponentModel/ITypeDescriptorContext.cs:
	* System/System.ComponentModel/TypeDescriptor.cs:
	* System.Drawing/System.Drawing/ColorConverter.cs: implemented minimal
	set of features needed by xsp, which uses ColorConverter.

svn path=/trunk/mcs/; revision=5283
Gonzalo Paniagua Javier 23 years ago
parent
commit
fcb27dc3cd

+ 4 - 0
mcs/class/System.Drawing/System.Drawing/ChangeLog

@@ -1,3 +1,7 @@
+2002-06-15  Gonzalo Paniagua Javier <[email protected]>
+
+	* ColorConverter.cs: implemented minimal set of features needed by xsp.
+
 2002-05-03  Mike Kestner <[email protected]>
 
 	* Bitmap.cs : using System.IO

+ 47 - 0
mcs/class/System.Drawing/System.Drawing/ColorConverter.cs

@@ -0,0 +1,47 @@
+//
+// System.Drawing.ColorConverter
+//
+// Authors:
+//	Gonzalo Paniagua Javier ([email protected])
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+using System;
+using System.ComponentModel;
+using System.Globalization;
+
+namespace System.Drawing {
+
+[MonoTODO]
+public class ColorConverter : TypeConverter
+{
+	[MonoTODO("Only some basic conversion needed by xsp")]
+	public override object ConvertFrom (ITypeDescriptorContext context,
+					    CultureInfo culture,
+					    object value)
+	{
+		string s = value as string;
+		if (s == null)
+			throw new NotImplementedException ();
+
+		if (s == "")
+			return Color.Empty;
+
+		Color c = Color.FromName (s);
+		if (!(c.A == c.R && c.R == c.G && c.G == c.B && c.B == 0))
+			return c;
+		
+		int i;
+		if (s [0] == '#')
+			i = Int32.Parse (s.Substring (1), NumberStyles.HexNumber);
+		else
+			i = Int32.Parse (s, NumberStyles.Integer);
+
+		int A = (int) (i & 0xFF000000) >> 24;
+		if (A == 0)
+			A = 255;
+		return Color.FromArgb (A, (i & 0x00FF0000) >> 16, (i & 0x00FF00) >> 8, (i & 0x0FF));
+	}
+}
+}
+

+ 4 - 0
mcs/class/System/ChangeLog

@@ -1,3 +1,7 @@
+2002-06-15  Gonzalo Paniagua Javier <[email protected]>
+
+	* System.build: referenced System.Drawing.dll.
+
 2002-05-12  Lawrence Pit <[email protected]>
 
 	* System.Security.Cryptography.X509Certificates: directory added

+ 7 - 0
mcs/class/System/System.ComponentModel/ChangeLog

@@ -1,3 +1,10 @@
+2002-06-15  Gonzalo Paniagua Javier <[email protected]>
+
+	* TypeConverter.cs:
+	* ITypeDescriptorContext.cs:
+	* TypeDescriptor.cs: implemented minimal set of features needed by xsp,
+	which uses ColorConverter.
+
 2002-05-12  Daniel Morgan <[email protected]>
 
 	* IComponent.cs

+ 29 - 0
mcs/class/System/System.ComponentModel/ITypeDescriptorContext.cs

@@ -0,0 +1,29 @@
+//
+// System.ComponentModel.ITypeDescriptorContext
+//
+// Authors:
+//	Gonzalo Paniagua Javier ([email protected])
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+
+namespace System.ComponentModel
+{
+
+public interface ITypeDescriptorContext : IServiceProvider
+{
+	IContainer Container { get; }
+
+	object Instance { get; }
+
+	PropertyDescriptor PropertyDescriptor { get; }
+
+	void OnComponentChanged ();
+
+	void OnComponentChanging ();
+}
+
+}
+

+ 31 - 3
mcs/class/System/System.ComponentModel/TypeConverter.cs

@@ -1,8 +1,36 @@
 //
-// Nothing implemented yet
+// System.ComponentModel.TypeConverter
 //
+// Authors:
+//	Gonzalo Paniagua Javier ([email protected])
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Globalization;
+
 namespace System.ComponentModel {
-	
-	public class TypeConverter {
+
+[MonoTODO("Only has the minimal implementation needed to use ColorConverter")]
+public class TypeConverter
+{
+	public object ConvertFrom (object o)
+	{
+		return ConvertFrom (null, null, o);
+	}
+
+	public virtual object ConvertFrom (ITypeDescriptorContext context,
+					   CultureInfo culture,
+					   object value)
+	{
+		throw new NotImplementedException ();
 	}
+
+	public object ConvertFromString (string s)
+	{
+		return ConvertFrom (s);
+	}
+}
 }
+

+ 28 - 0
mcs/class/System/System.ComponentModel/TypeDescriptor.cs

@@ -0,0 +1,28 @@
+//
+// System.ComponentModel.TypeDescriptor
+//
+// Authors:
+//	Gonzalo Paniagua Javier ([email protected])
+//
+// (C) 2002 Ximian, Inc (http://www.ximian.com)
+//
+
+using System;
+using System.Drawing;
+
+namespace System.ComponentModel
+{
+
+[MonoTODO("Only implemented the minimal features needed to use ColorConverter")]
+public sealed class TypeDescriptor
+{
+	public static TypeConverter GetConverter (Type type)
+	{
+		if (type != typeof (System.Drawing.Color))
+			throw new NotImplementedException ("Only System.Drawing.Color is supported by now.");
+
+		return new ColorConverter ();
+	}
+}
+}
+

+ 1 - 0
mcs/class/System/System.build

@@ -17,6 +17,7 @@
 			<!--arg value="/nostdlib"/--> 	<!-- don't reference mscorlib -->
 			<!--arg value="/r:corlib.dll"/-->
 			<arg value="/r:System.Xml.dll"/>
+			<arg value="/r:System.Drawing.dll"/>
 			<sources>
 				<includes name="**/*.cs"/> 
 				<excludes name="Test/**"/>