فهرست منبع

2005-01-27 Lluis Sanchez Gual <[email protected]>

	* MarginsConverter.cs: Implemented support for InstanceDescriptor.  

svn path=/trunk/mcs/; revision=39661
Lluis Sanchez 21 سال پیش
والد
کامیت
70d92ded96

+ 3 - 0
mcs/class/System.Drawing/System.Drawing.Printing/ChangeLog

@@ -0,0 +1,3 @@
+2005-01-27  Lluis Sanchez Gual  <[email protected]>
+
+	* MarginsConverter.cs: Implemented support for InstanceDescriptor.  

+ 13 - 2
mcs/class/System.Drawing/System.Drawing.Printing/MarginsConverter.cs

@@ -34,6 +34,8 @@ using System;
 using System.ComponentModel;
 using System.Globalization;
 using System.Text.RegularExpressions;
+using System.ComponentModel.Design.Serialization;
+using System.Reflection;
 
 namespace System.Drawing.Printing {
 	/// <summary>
@@ -54,6 +56,9 @@ namespace System.Drawing.Printing {
 			if (destinationType == typeof(string))
 				return true;
 			
+			if (destinationType == typeof (InstanceDescriptor))
+				return true;
+
 			return base.CanConvertTo(context, destinationType);
 		}
 		
@@ -95,8 +100,14 @@ namespace System.Drawing.Printing {
 				Margins source = value as Margins;
 				string ret = "{0}; {1}; {2}; {3}";
 				return String.Format(ret, source.Left, source.Right, source.Top, source.Bottom);
-			} else
-				return base.ConvertTo(context, culture, value, destinationType);
+			}
+			if (destinationType == typeof (InstanceDescriptor) && value is Margins) {
+				Margins c = (Margins) value;
+				ConstructorInfo ctor = typeof(Margins).GetConstructor (new Type[] {typeof(int), typeof(int), typeof(int), typeof(int)} );
+				return new InstanceDescriptor (ctor, new object[] {c.Left, c.Right, c.Top, c.Bottom});
+			}
+
+			return base.ConvertTo(context, culture, value, destinationType);
 		}
 		
 		public override bool GetCreateInstanceSupported(ITypeDescriptorContext context)