ImageList.cs: AddStrip: Throw ArgumentException when Image is not a Bitmap.
authorKornél Pál <kornelpal@gmail.com>
Wed, 28 Sep 2005 16:36:03 +0000 (16:36 -0000)
committerKornél Pál <kornelpal@gmail.com>
Wed, 28 Sep 2005 16:36:03 +0000 (16:36 -0000)
svn path=/trunk/mcs/; revision=50953

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs

index ee37191a421a856c88f82a29891a0ef8e1b4ecea..c246904e445c65e24ab58a56987ba252e95a7ff1 100644 (file)
@@ -1,3 +1,7 @@
+2005-09-28  Kornél Pál  <kornelpal@hotmail.com>
+
+       * ImageList.cs: AddStrip: Throw ArgumentException when Image is not a Bitmap.
+
 2005-09-28  Jordi Mas i Hernandez <jordi@ximian.com>
         
        * ListBox.cs: Fixes bug 76253
index 18a4c1c7683cbd7e84346082906aeebde0da9d51..2871adf19f423b7638bf02b790cf53c0683c23a3 100644 (file)
@@ -447,13 +447,15 @@ namespace System.Windows.Forms
                                if (value == null)
                                        throw new ArgumentNullException("value");
 
-                               if (value.Width == 0 || (value.Width % (width = this.imageSize.Width)) != 0)
+                               if ((imageWidth = value.Width) == 0 || (imageWidth % (width = this.imageSize.Width)) != 0)
                                        throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value");
 
                                if (value.Height != (height = this.imageSize.Height))
                                        throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value");
 
-                               imageWidth = value.Width;
+                               if (!(value is Bitmap))
+                                       throw new ArgumentException("Image must be a Bitmap.");
+
                                imageRect = new Rectangle(0, 0, width, height);
                                if (this.transparentColor.A == 0)
                                        imageAttributes = null;