Author: jpobst
Date: 2007-05-16 20:45:26 -0400 (Wed, 16 May 2007)
New Revision: 77520

Added:
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageKeyConverter.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewImageKeyConverter.cs
   
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageKeyConverterTest.cs
   
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewImageKeyConverterTest.cs
Modified:
   trunk/mcs/class/Managed.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
   trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
Log:
2007-05-16  Jonathan Pobst  <[EMAIL PROTECTED]>

        * ImageKeyConverter.cs: Added.
        * TreeViewImageKeyConverter.cs: Added.

2007-05-16  Jonathan Pobst  <[EMAIL PROTECTED]>

        * System.Windows.Forms.dll.sources: Add ImageKeyConverter.cs,
        TreeViewImageKeyConverter.cs.
        * System.Windows.Forms_test.dll.sources: Add ImageKeyConverterTest.cs,
        TreeViewImageKeyConverterTest.cs.

2007-05-16  Jonathan Pobst  <[EMAIL PROTECTED]>

        * ImageKeyConverterTest.cs: Added.
        * TreeViewImageKeyConverterTest.cs: Added.

Modified: trunk/mcs/class/Managed.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/ChangeLog     2007-05-17 00:20:27 UTC 
(rev 77519)
+++ trunk/mcs/class/Managed.Windows.Forms/ChangeLog     2007-05-17 00:45:26 UTC 
(rev 77520)
@@ -1,3 +1,10 @@
+2007-05-16  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * System.Windows.Forms.dll.sources: Add ImageKeyConverter.cs,
+       TreeViewImageKeyConverter.cs.
+       * System.Windows.Forms_test.dll.sources: Add ImageKeyConverterTest.cs,
+       TreeViewImageKeyConverterTest.cs.
+
 2007-05-16  Olivier Dufour  <[EMAIL PROTECTED]>
 
        * ColumnHeaderConverter: Added

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-05-17 00:20:27 UTC (rev 77519)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-05-17 00:45:26 UTC (rev 77520)
@@ -1,3 +1,8 @@
+2007-05-16  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * ImageKeyConverter.cs: Added.
+       * TreeViewImageKeyConverter.cs: Added.
+
 2007-05-16  Carlos Alberto Cortez <[EMAIL PROTECTED]>
        
        * ToolTips.cs: Update Text if SetToolTip is called for a control

Added: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageKeyConverter.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageKeyConverter.cs 
    2007-05-17 00:20:27 UTC (rev 77519)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageKeyConverter.cs 
    2007-05-17 00:45:26 UTC (rev 77520)
@@ -0,0 +1,98 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+// Authors:
+//   Jonathan Pobst  [EMAIL PROTECTED]
+//
+
+#if NET_2_0
+using System.Drawing;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Globalization;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+       public class ImageKeyConverter : StringConverter
+       {
+               #region Constructors
+               public ImageKeyConverter () { }
+               #endregion Constructors
+
+               #region Protected Properties
+               protected virtual bool IncludeNoneAsStandardValue {
+                       get { return true; }
+               }
+               #endregion Protected Properties
+
+               #region Public Methods
+               public override bool CanConvertFrom (ITypeDescriptorContext 
context, Type sourceType)
+               {
+                       if (sourceType == typeof (string))
+                               return true;
+
+                       return false;
+               }
+               
+               public override object ConvertFrom (ITypeDescriptorContext 
context, CultureInfo culture, object value)
+               {
+                       if (value != null && value is string)
+                               return (string) value;
+                       else
+                               return base.ConvertFrom (context, culture, 
value);
+               }
+
+               public override object ConvertTo (ITypeDescriptorContext 
context, CultureInfo culture,
+                                                 object value, Type 
destinationType)
+               {
+                       if (value == null)
+                               return "(none)";
+                       else if (destinationType == typeof (string)) {
+                               if (value is string && (string) value == 
string.Empty)
+                                       return "(none)";
+                               else
+                                       return value.ToString ();
+                       }
+                       else
+                               return base.ConvertTo (context, culture, value, 
destinationType);
+               }
+
+               public override StandardValuesCollection GetStandardValues 
(ITypeDescriptorContext context)
+               {
+                       string[] stdVal = new string[] { string.Empty };
+                       return new TypeConverter.StandardValuesCollection 
(stdVal);
+               }
+
+               public override bool GetStandardValuesExclusive 
(ITypeDescriptorContext context)
+               {
+                       return true;
+               }
+
+               public override bool GetStandardValuesSupported 
(ITypeDescriptorContext context)
+               {
+                       return true;
+               }
+               #endregion Public Methods
+       }
+}
+#endif
\ No newline at end of file

Added: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewImageKeyConverter.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewImageKeyConverter.cs
     2007-05-17 00:20:27 UTC (rev 77519)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeViewImageKeyConverter.cs
     2007-05-17 00:45:26 UTC (rev 77520)
@@ -0,0 +1,52 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+// Authors:
+//   Jonathan Pobst  [EMAIL PROTECTED]
+//
+
+#if NET_2_0
+using System.Drawing;
+using System.ComponentModel;
+using System.Collections;
+using System.Diagnostics;
+using System.Globalization;
+using System.Runtime.InteropServices;
+
+namespace System.Windows.Forms
+{
+       public class TreeViewImageKeyConverter : ImageKeyConverter
+       {
+               #region Constructors
+               public TreeViewImageKeyConverter () { }
+               #endregion Constructors
+
+               #region Public Methods
+               // XXX - Can't find the difference from the base method
+               public override object ConvertTo (ITypeDescriptorContext 
context, CultureInfo culture,
+                                                 object value, Type 
destinationType)
+               {
+                       return base.ConvertTo (context, culture, value, 
destinationType);
+               }
+               #endregion Public Methods
+       }
+}
+#endif
\ No newline at end of file

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources      
2007-05-17 00:20:27 UTC (rev 77519)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources      
2007-05-17 00:45:26 UTC (rev 77520)
@@ -368,6 +368,7 @@
 System.Windows.Forms/IWin32Window.cs
 System.Windows.Forms/IWindowTarget.cs
 System.Windows.Forms/ImageIndexConverter.cs
+System.Windows.Forms/ImageKeyConverter.cs
 System.Windows.Forms/ImageLayout.cs
 System.Windows.Forms/ImageList.cs
 System.Windows.Forms/ImageListConverter.cs
@@ -732,6 +733,7 @@
 System.Windows.Forms/TreeViewHitTestInfo.cs
 System.Windows.Forms/TreeViewHitTestLocations.cs
 System.Windows.Forms/TreeViewImageIndexConverter.cs
+System.Windows.Forms/TreeViewImageKeyConverter.cs
 System.Windows.Forms/TypeValidationEventArgs.cs
 System.Windows.Forms/TypeValidationEventHandler.cs
 System.Windows.Forms/UICues.cs

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources 
2007-05-17 00:20:27 UTC (rev 77519)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources 
2007-05-17 00:45:26 UTC (rev 77520)
@@ -61,6 +61,7 @@
 System.Windows.Forms/GroupBoxTest.cs
 System.Windows.Forms/HelpProviderTest.cs
 System.Windows.Forms/HScrollPropertiesTest.cs
+System.Windows.Forms/ImageKeyConverterTest.cs
 System.Windows.Forms/ImageListTest.cs
 System.Windows.Forms/LabelTest.cs
 System.Windows.Forms/LinkAreaTest.cs
@@ -136,6 +137,7 @@
 System.Windows.Forms/TreeNodeCollectionTest.cs
 System.Windows.Forms/TreeNodeTest.cs
 System.Windows.Forms/TreeViewHitTestInfoTest.cs
+System.Windows.Forms/TreeViewImageKeyConverterTest.cs
 System.Windows.Forms/TreeViewTest.cs
 System.Windows.Forms/UpDownTest.cs
 System.Windows.Forms/UserControlTest.cs

Modified: 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog   
2007-05-17 00:20:27 UTC (rev 77519)
+++ trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog   
2007-05-17 00:45:26 UTC (rev 77520)
@@ -1,3 +1,8 @@
+2007-05-16  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * ImageKeyConverterTest.cs: Added.
+       * TreeViewImageKeyConverterTest.cs: Added.
+
 2007-05-15  Jonathan Pobst  <[EMAIL PROTECTED]>
 
        * TextBoxTest.cs: Add test for IsInputChar method.

Added: 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageKeyConverterTest.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageKeyConverterTest.cs
    2007-05-17 00:20:27 UTC (rev 77519)
+++ 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageKeyConverterTest.cs
    2007-05-17 00:45:26 UTC (rev 77520)
@@ -0,0 +1,105 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Windows.Forms;
+using System.Windows.Forms.Layout;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+       [TestFixture]
+       public class ImageKeyConverterTest
+       {
+               [Test]
+               public void PropertyIncludeNoneAsStandardValue ()
+               {
+                       PublicImageKeyConverter c = new PublicImageKeyConverter 
();
+                       Assert.AreEqual (true, 
c.PublicIncludeNoneAsStandardValue, "A1");
+               }
+               
+               private class PublicImageKeyConverter : ImageKeyConverter
+               {
+                       public bool PublicIncludeNoneAsStandardValue { get { 
return base.IncludeNoneAsStandardValue; } }
+               }
+               
+               [Test]
+               public void GetStandardValues ()
+               {
+                       ImageKeyConverter c = new ImageKeyConverter ();
+                       Assert.AreEqual (1, c.GetStandardValues (null).Count, 
"B1");
+                       Assert.AreEqual (string.Empty, c.GetStandardValues 
(null)[0].ToString (), "B2");
+               }
+
+               [Test]
+               public void GetStandardValuesExclusive ()
+               {
+                       ImageKeyConverter c = new ImageKeyConverter ();
+                       Assert.AreEqual (true, c.GetStandardValuesExclusive 
(null), "C1");
+               }
+
+               [Test]
+               public void GetStandardValuesSupported ()
+               {
+                       ImageKeyConverter c = new ImageKeyConverter ();
+                       Assert.AreEqual (true, c.GetStandardValuesSupported 
(null), "D1");
+               }
+               
+               [Test]
+               public void CanConvertFrom ()
+               {
+                       ImageKeyConverter c = new ImageKeyConverter ();
+
+                       Assert.IsTrue (c.CanConvertFrom (null, typeof 
(string)), "1");
+                       Assert.IsFalse (c.CanConvertFrom (null, typeof (int)), 
"2");
+                       Assert.IsFalse (c.CanConvertFrom (null, typeof 
(float)), "3");
+                       Assert.IsFalse (c.CanConvertFrom (null, typeof 
(object)), "4");
+               }
+               
+               [Test]
+               public void ConvertFrom ()
+               {
+                       ImageKeyConverter ikc = new ImageKeyConverter ();
+                       Assert.AreEqual (string.Empty, ikc.ConvertFrom (null, 
null, string.Empty), "N1");
+                       Assert.AreEqual (string.Empty, ikc.ConvertFrom (null, 
null, null), "N2");
+                       Assert.AreEqual ("(none)", ikc.ConvertFrom (null, null, 
"(none)"), "N2-1");
+                       Assert.AreEqual ("bob", ikc.ConvertFrom (null, null, 
"bob"), "N3");
+                       Assert.AreEqual ("oSCar", ikc.ConvertFrom (null, null, 
"oSCar"), "N4");
+               }
+
+               [Test]
+               public void ConvertTo ()
+               {
+                       ImageKeyConverter ikc = new ImageKeyConverter ();
+                       Assert.AreEqual ("(none)", ikc.ConvertTo (null, null, 
string.Empty, typeof (string)), "N1");
+                       Assert.AreEqual ("(none)", ikc.ConvertTo (null, null, 
null, typeof (string)), "N2");
+                       Assert.AreEqual ("(none)", ikc.ConvertTo (null, null, 
"(none)", typeof (string)), "N2-1");
+                       Assert.AreEqual ("bob", ikc.ConvertTo (null, null, 
"bob", typeof (string)), "N3");
+                       Assert.AreEqual ("oSCar", ikc.ConvertTo (null, null, 
"oSCar", typeof (string)), "N4");
+               }
+       }
+}
+#endif

Added: 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewImageKeyConverterTest.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewImageKeyConverterTest.cs
    2007-05-17 00:20:27 UTC (rev 77519)
+++ 
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TreeViewImageKeyConverterTest.cs
    2007-05-17 00:45:26 UTC (rev 77520)
@@ -0,0 +1,49 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+// Copyright (c) 2007 Novell, Inc.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Globalization;
+using System.Windows.Forms;
+using System.Windows.Forms.Layout;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Forms
+{
+       [TestFixture]
+       public class TreeViewImageKeyConverterTest
+       {
+               [Test]
+               public void ConvertTo ()
+               {
+                       ImageKeyConverter ikc = new ImageKeyConverter ();
+                       Assert.AreEqual ("(none)", ikc.ConvertTo (null, null, 
string.Empty, typeof (string)), "N1");
+                       Assert.AreEqual ("(none)", ikc.ConvertTo (null, null, 
null, typeof (string)), "N2");
+                       Assert.AreEqual ("(none)", ikc.ConvertTo (null, null, 
"(none)", typeof (string)), "N2-1");
+                       Assert.AreEqual ("bob", ikc.ConvertTo (null, null, 
"bob", typeof (string)), "N3");
+                       Assert.AreEqual ("oSCar", ikc.ConvertTo (null, null, 
"oSCar", typeof (string)), "N4");
+               }
+       }
+}
+#endif

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to