2007-06-13 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Wed, 13 Jun 2007 19:21:46 +0000 (19:21 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Wed, 13 Jun 2007 19:21:46 +0000 (19:21 -0000)
* Control.cs: corcompare work.
* FlatButtonAppearance.cs, FolderBrowserDialog.cs: Add TypeConverters.

svn path=/trunk/mcs/; revision=79484

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/FlatButtonAppearance.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/FolderBrowserDialog.cs

index 69c9e35a83a1c4cb83af52f6280e34b90c93a24c..0a267ccd485576af941dc057261636173c34a9a3 100644 (file)
@@ -1,3 +1,8 @@
+2007-06-13  Jonathan Pobst  <monkey@jpobst.com>
+
+       * Control.cs: corcompare work.
+       * FlatButtonAppearance.cs, FolderBrowserDialog.cs: Add TypeConverters.
+
 2007-06-13  Jonathan Pobst  <monkey@jpobst.com>
 
        * ControlPaint.cs, Theme.cs, ThemeWin32Classic.cs: Implement
index a20777809e8ea3288e7744f93ef0fb5eb1c85e29..2b25a24011921594af65be2c7749b4cf8a201729 100644 (file)
@@ -3368,6 +3368,7 @@ namespace System.Windows.Forms
                }
 
 #if NET_2_0
+               [EditorBrowsable (EditorBrowsableState.Advanced)]
                protected
 #else
                internal
@@ -4190,7 +4191,8 @@ namespace System.Windows.Forms
                {
                        return auto_size_mode;
                }
-               
+
+               [EditorBrowsable (EditorBrowsableState.Advanced)]
                protected 
 #else
                internal
@@ -4516,6 +4518,7 @@ namespace System.Windows.Forms
                }
 
 #if NET_2_0
+               [EditorBrowsable (EditorBrowsableState.Advanced)]
                protected
 #else
                internal
index ab4fc327530de7b7ddf7682a29813934b4086f67..250987b1d9cc4f12798be3fd583c69d8f4732cf9 100644 (file)
@@ -30,10 +30,12 @@ using System;
 using System.ComponentModel;
 using System.Drawing;
 using System.Windows.Forms;
+using System.Globalization;
 
 namespace System.Windows.Forms
 {
 #if NET_2_0
+       [TypeConverter (typeof (FlatButtonAppearanceConverter))]
        public 
 #endif
        class FlatButtonAppearance
@@ -143,4 +145,42 @@ namespace System.Windows.Forms
                        }
                }
        }
+       
+#if NET_2_0
+       internal class FlatButtonAppearanceConverter : TypeConverter
+       {
+               public override object ConvertTo (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
+               {
+                       if ((value == null) || !(value is FlatButtonAppearance) || (destinationType != typeof (string)))
+                               return base.ConvertTo (context, culture, value, destinationType);
+
+                       if (culture == null)
+                               culture = CultureInfo.CurrentCulture;
+                               
+                       FlatButtonAppearance fba = (FlatButtonAppearance)value;
+                       
+                       return string.Format ("{0}{5} {1}{5} {2}{5} {3}{5} {4}", fba.BorderColor.ToArgb (), fba.BorderSize.ToString (), fba.CheckedBackColor.ToArgb (), fba.MouseDownBackColor.ToArgb (), fba.MouseOverBackColor.ToArgb (), culture.TextInfo.ListSeparator);
+               }
+
+               public override object ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+               {
+                       if ((value == null) || !(value is String))
+                               return base.ConvertFrom (context, culture, value);
+
+                       if (culture == null)
+                               culture = CultureInfo.CurrentCulture;
+
+                       string[] parts = ((string)value).Split (culture.TextInfo.ListSeparator.ToCharArray ());
+
+                       FlatButtonAppearance fba = new FlatButtonAppearance (null);
+                       fba.BorderColor = Color.FromArgb (int.Parse (parts[0].Trim ()));
+                       fba.BorderSize = int.Parse (parts[1].Trim ());
+                       fba.CheckedBackColor = Color.FromArgb (int.Parse (parts[2].Trim ()));
+                       fba.MouseDownBackColor = Color.FromArgb (int.Parse (parts[3].Trim ()));
+                       fba.MouseOverBackColor = Color.FromArgb (int.Parse (parts[4].Trim ()));
+                       
+                       return fba;
+               }
+       }
+#endif
 }
\ No newline at end of file
index 7be9072e3e1d1dbdba1e517f03327026e398e097..103c6ffbf138f16500245f10149b0be752fb338e 100644 (file)
@@ -191,6 +191,9 @@ namespace System.Windows.Forms {
                [Browsable(true)]
                [DefaultValue(Environment.SpecialFolder.Desktop)]
                [Localizable(false)]
+#if NET_2_0
+               [TypeConverter (typeof (SpecialFolderEnumConverter))]
+#endif
                public Environment.SpecialFolder RootFolder {
                        set {
                                int v = (int)value;
@@ -689,4 +692,25 @@ namespace System.Windows.Forms {
                        }
                }
        }
+       
+#if NET_2_0
+       internal class SpecialFolderEnumConverter : TypeConverter
+       {
+               public override object ConvertFrom (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+               {
+                       if ((value == null) || !(value is String))
+                               return base.ConvertFrom (context, culture, value);
+
+                       return Enum.Parse (typeof (Environment.SpecialFolder), (string)value, true);
+               }
+
+               public override object ConvertTo (ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
+               {
+                       if ((value == null) || !(value is Environment.SpecialFolder) || (destinationType != typeof (string)))
+                               return base.ConvertTo (context, culture, value, destinationType);
+                               
+                       return ((Environment.SpecialFolder)value).ToString ();
+               }
+       }
+#endif
 }