2 // System.Windows.Forms.ImageList.cs
5 // Peter Bartok <pbartok@novell.com>
6 // Kornél Pál <http://www.kornelpal.hu/>
8 // Copyright (C) 2004-2005 Novell, Inc.
9 // Copyright (C) 2005 Kornél Pál
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 // Differences between MS.NET ImageList and this implementation:
38 // This is a fully managed image list implementation.
40 // Images are stored as Format32bppArgb internally but ColorDepth is applied
41 // to the colors of images. Images[index] returns a Format32bppArgb copy of
42 // the image so this difference is only internal.
44 // MS.NET has no alpha channel support (except for icons in 32-bit mode with
45 // comctl32.dll version 6.0) but this implementation has full alpha channel
46 // support in 32-bit mode.
48 // Handle should be an HIMAGELIST returned by ImageList_Create. This
49 // implementation uses (IntPtr)(-1) that is a non-zero but invalid handle.
51 // MS.NET destroys handles using the garbage collector this implementation
52 // does the same with Image objects stored in an ArrayList.
54 // MS.NET 1.x shares the same HIMAGELIST between ImageLists that were
55 // initialized from the same ImageListStreamer and doesn't update ImageSize
56 // and ColorDepth that are treated as bugs and MS.NET 2.0 behavior is
59 // MS.NET 2.0 initializes TransparentColor to Color.Transparent in
60 // constructors but ResetTransparentColor and ShouldSerializeTransparentColor
61 // default to Color.LightGray that is treated as a bug.
63 // MS.NET 2.0 does not clear keys when handle is destroyed that is treated as
67 using System.Collections;
68 using System.Collections.Specialized;
69 using System.ComponentModel;
70 using System.ComponentModel.Design.Serialization;
72 using System.Drawing.Design;
73 using System.Drawing.Imaging;
74 using System.Globalization;
75 using System.Runtime.InteropServices;
77 namespace System.Windows.Forms
79 [DefaultProperty("Images")]
80 [Designer("System.Windows.Forms.Design.ImageListDesigner, " + Consts.AssemblySystem_Design)]
82 [DesignerSerializer("System.Windows.Forms.Design.ImageListCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
84 [ToolboxItemFilter("System.Windows.Forms")]
85 [TypeConverter(typeof(ImageListConverter))]
86 public sealed class ImageList : System.ComponentModel.Component
88 #region Private Fields
89 private const ColorDepth DefaultColorDepth = ColorDepth.Depth8Bit;
90 private static readonly Color DefaultTransparentColor = Color.Transparent;
91 private static readonly Size DefaultImageSize = new Size(16, 16);
96 private EventHandler recreateHandle;
97 private readonly ImageCollection images;
98 #endregion // Private Fields
101 [Editor("System.Windows.Forms.Design.ImageCollectionEditor, " + Consts.AssemblySystem_Design, typeof(UITypeEditor))]
102 public sealed class ImageCollection : IList, ICollection, IEnumerable
104 private const int AlphaMask = unchecked((int)0xFF000000);
106 [StructLayout(LayoutKind.Explicit)]
107 private struct ArgbColor
127 class IndexedColorDepths
130 private IndexedColorDepths()
134 internal static readonly ArgbColor[] Palette4Bit;
135 internal static readonly ArgbColor[] Palette8Bit;
136 private static readonly int[] squares;
138 static IndexedColorDepths()
145 bitmap = new Bitmap(1, 1, PixelFormat.Format4bppIndexed);
146 palette = bitmap.Palette.Entries;
149 Palette4Bit = new ArgbColor[count = palette.Length];
150 for (index = 0; index < count; index++)
151 Palette4Bit[index].Argb = palette[index].ToArgb();
153 bitmap = new Bitmap(1, 1, PixelFormat.Format8bppIndexed);
154 palette = bitmap.Palette.Entries;
157 Palette8Bit = new ArgbColor[count = palette.Length];
158 for (index = 0; index < count; index++)
159 Palette8Bit[index].Argb = palette[index].ToArgb();
161 squares = new int[511];
162 for (index = 0; index < 256; index++)
163 squares[255 + index] = squares[255 - index] = index * index;
166 internal static int GetNearestColor(ArgbColor[] palette, int color)
177 count = palette.Length;
178 for (index = 0; index < count; index++)
179 if (palette[index].Argb == color)
182 red = unchecked((int)(unchecked((uint)color) >> 16) & 0xFF);
183 green = unchecked((int)(unchecked((uint)color) >> 8) & 0xFF);
185 nearestColor = AlphaMask;
186 minDistance = int.MaxValue;
188 for (index = 0; index < count; index++)
189 if ((distance = squares[255 + palette[index].Red - red] + squares[255 + palette[index].Green - green] + squares[255 + palette[index].Blue - blue]) < minDistance) {
190 nearestColor = palette[index].Argb;
191 minDistance = distance;
199 private enum ItemFlags
202 UseTransparentColor = 1,
206 private sealed class ImageListItem
208 internal readonly object Image;
209 internal readonly ItemFlags Flags;
210 internal readonly Color TransparentColor;
211 internal readonly int ImageCount = 1;
213 internal ImageListItem(Icon value)
216 throw new ArgumentNullException("value");
219 this.Image = (Icon)value.Clone();
222 internal ImageListItem(Image value)
225 throw new ArgumentNullException("value");
227 if (!(value is Bitmap))
228 throw new ArgumentException("Image must be a Bitmap.");
230 // Images are not cloned.
234 internal ImageListItem(Image value, Color transparentColor) : this(value)
236 this.Flags = ItemFlags.UseTransparentColor;
237 this.TransparentColor = transparentColor;
240 internal ImageListItem(Image value, int imageCount) : this(value)
242 this.Flags = ItemFlags.ImageStrip;
243 this.ImageCount = imageCount;
247 #region ImageCollection Private Fields
248 private ColorDepth colorDepth = DefaultColorDepth;
249 private Color transparentColor = DefaultTransparentColor;
250 private Size imageSize = DefaultImageSize;
251 private ArrayList list = new ArrayList();
253 private ArrayList keys = new ArrayList();
256 private bool handleCreated;
258 private int lastKeyIndex = -1;
260 private readonly ImageList owner;
261 #endregion // ImageCollection Private Fields
263 #region ImageCollection Internal Constructors
264 // For use in ImageList
265 internal ImageCollection(ImageList owner)
269 #endregion // ImageCollection Internal Constructor
271 #region ImageCollection Internal Instance Properties
272 // For use in ImageList
273 internal ColorDepth ColorDepth {
275 return this.colorDepth;
279 if (!Enum.IsDefined(typeof(ColorDepth), value))
280 throw new InvalidEnumArgumentException("value", (int)value, typeof(ColorDepth));
282 if (this.colorDepth != value) {
283 this.colorDepth = value;
289 // For use in ImageList
290 internal IntPtr Handle {
297 // For use in ImageList
298 internal bool HandleCreated {
300 return this.handleCreated;
304 // For use in ImageList
305 internal Size ImageSize {
307 return this.imageSize;
311 if (value.Width < 1 || value.Width > 256 || value.Height < 1 || value.Height > 256)
312 throw new ArgumentException("ImageSize.Width and Height must be between 1 and 256", "value");
314 if (this.imageSize != value) {
315 this.imageSize = value;
321 // For use in ImageList
322 internal ImageListStreamer ImageStream {
324 return this.Empty ? null : new ImageListStreamer(this);
329 Image[] streamImages;
333 if (this.handleCreated)
339 // Only deserialized ImageListStreamers are used.
340 else if ((streamImages = value.Images) != null) {
341 this.list = new ArrayList(streamImages.Length);
343 this.handleCreated = true;
345 this.keys = new ArrayList(streamImages.Length);
348 for (index = 0; index < streamImages.Length; index++) {
349 list.Add((Image)streamImages[index].Clone());
355 this.imageSize = value.ImageSize;
356 this.colorDepth = value.ColorDepth;
359 // Event is raised even when handle was not created yet.
360 owner.OnRecreateHandle();
366 // For use in ImageList
367 internal Color TransparentColor {
369 return this.transparentColor;
373 this.transparentColor = value;
376 #endregion // ImageCollection Internal Instance Properties
378 #region ImageCollection Public Instance Properties
382 return this.handleCreated ? list.Count : this.count;
388 return this.Count == 0;
392 public bool IsReadOnly {
399 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
400 public Image this[int index] {
402 return (Image)GetImage(index).Clone();
408 if (index < 0 || index >= this.Count)
409 throw new ArgumentOutOfRangeException("index");
412 throw new ArgumentNullException("value");
414 if (!(value is Bitmap))
415 throw new ArgumentException("Image must be a Bitmap.");
417 image = CreateImage(value, this.transparentColor);
424 public Image this[string key] {
428 return (index = IndexOfKey(key)) == -1 ? null : this[index];
432 public StringCollection Keys {
436 StringCollection keyCollection;
438 // Returns all keys even when there are more keys than
439 // images. Null keys are returned as empty strings.
441 keyCollection = new StringCollection();
442 for (index = 0; index < keys.Count; index++)
443 keyCollection.Add(((key = (string)keys[index]) == null || key.Length == 0) ? string.Empty : key);
445 return keyCollection;
449 #endregion // ImageCollection Public Instance Properties
451 #region ImageCollection Private Static Methods
453 private static bool CompareKeys(string key1, string key2)
455 // Keys are case-insensitive and keys with different length
456 // are not equal even when string.Compare treats them equal.
458 if (key1 == null || key2 == null || key1.Length != key2.Length)
461 return string.Compare(key1, key2, true, CultureInfo.InvariantCulture) == 0;
464 #endregion // ImageCollection Private Static Methods
466 #region ImageCollection Private Instance Methods
468 private int AddItem(string key, ImageListItem item)
470 private int AddItem(ImageListItem item)
478 if (this.handleCreated)
479 itemIndex = AddItemInternal(item);
481 // Image strips are counted as a single item in the return
482 // value of Add and AddStrip until handle is created.
484 itemIndex = list.Add(item);
485 this.count += item.ImageCount;
489 if ((item.Flags & ItemFlags.ImageStrip) == 0)
492 for (index = 0; index < item.ImageCount; index++)
499 private int AddItemInternal(ImageListItem item)
501 if (item.Image is Icon) {
507 bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);
508 graphics = Graphics.FromImage(bitmap);
509 graphics.DrawIcon((Icon)item.Image, new Rectangle(0, 0, imageWidth, imageHeight));
512 ReduceColorDepth(bitmap);
513 return list.Add(bitmap);
515 else if ((item.Flags & ItemFlags.ImageStrip) == 0)
516 return list.Add(CreateImage((Image)item.Image, (item.Flags & ItemFlags.UseTransparentColor) == 0 ? this.transparentColor : item.TransparentColor));
527 ImageAttributes imageAttributes;
529 // When ImageSize was changed after adding image strips
530 // Count will return invalid values based on old ImageSize
531 // but when creating handle either ArgumentException will
532 // be thrown or image strip will be added according to the
533 // new ImageSize. This can result in image count
534 // difference that can result in exceptions in methods
535 // that use Count before creating handle. In addition this
536 // can result in the loss of sync with keys. When doing
537 // the same after handle was created there are no problems
538 // as handle will be recreated after changing ImageSize
539 // that results in the loss of images added previously.
541 if ((width = (image = (Image)item.Image).Width) == 0 || (width % (imageWidth = this.imageSize.Width)) != 0)
542 throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value");
544 if (image.Height != (imageHeight = this.imageSize.Height))
545 throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value");
547 imageRect = new Rectangle(0, 0, imageWidth, imageHeight);
548 if (this.transparentColor.A == 0)
549 imageAttributes = null;
551 imageAttributes = new ImageAttributes();
552 imageAttributes.SetColorKey(this.transparentColor, this.transparentColor);
556 for (imageX = 0; imageX < width; imageX += imageWidth) {
557 bitmap = new Bitmap(imageWidth, imageHeight, PixelFormat.Format32bppArgb);
558 graphics = Graphics.FromImage(bitmap);
559 graphics.DrawImage(image, imageRect, imageX, 0, imageWidth, imageHeight, GraphicsUnit.Pixel, imageAttributes);
562 ReduceColorDepth(bitmap);
569 private void CreateHandle()
574 if (!this.handleCreated) {
576 this.list = new ArrayList(this.count);
578 this.handleCreated = true;
580 for (index = 0; index < items.Count; index++)
581 AddItemInternal((ImageListItem)items[index]);
585 private Image CreateImage(Image value, Color transparentColor)
591 ImageAttributes imageAttributes;
593 if (transparentColor.A == 0)
594 imageAttributes = null;
596 imageAttributes = new ImageAttributes();
597 imageAttributes.SetColorKey(transparentColor, transparentColor);
600 bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);
601 graphics = Graphics.FromImage(bitmap);
602 graphics.DrawImage(value, new Rectangle(0, 0, imageWidth, imageHeight), 0, 0, value.Width, value.Height, GraphicsUnit.Pixel, imageAttributes);
605 ReduceColorDepth(bitmap);
609 private void RecreateHandle()
611 if (this.handleCreated) {
613 this.handleCreated = true;
614 owner.OnRecreateHandle();
618 private unsafe void ReduceColorDepth(Bitmap bitmap)
628 BitmapData bitmapData;
631 if (this.colorDepth < ColorDepth.Depth32Bit) {
632 bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
634 linePtr = (byte*)bitmapData.Scan0;
635 height = bitmapData.Height;
636 widthBytes = bitmapData.Width << 2;
637 stride = bitmapData.Stride;
639 if (this.colorDepth < ColorDepth.Depth16Bit) {
640 palette = this.colorDepth < ColorDepth.Depth8Bit ? IndexedColorDepths.Palette4Bit : IndexedColorDepths.Palette8Bit;
642 for (line = 0; line < height; line++) {
643 lineEndPtr = linePtr + widthBytes;
644 for (pixelPtr = linePtr; pixelPtr < lineEndPtr; pixelPtr += 4)
645 *(int*)pixelPtr = ((pixel = *(int*)pixelPtr) & AlphaMask) == 0 ? 0x00000000 : IndexedColorDepths.GetNearestColor(palette, pixel | AlphaMask);
649 else if (this.colorDepth < ColorDepth.Depth24Bit) {
650 for (line = 0; line < height; line++) {
651 lineEndPtr = linePtr + widthBytes;
652 for (pixelPtr = linePtr; pixelPtr < lineEndPtr; pixelPtr += 4)
653 *(int*)pixelPtr = ((pixel = *(int*)pixelPtr) & AlphaMask) == 0 ? 0x00000000 : (pixel & 0x00F8F8F8) | AlphaMask;
658 for (line = 0; line < height; line++) {
659 lineEndPtr = linePtr + widthBytes;
660 for (pixelPtr = linePtr; pixelPtr < lineEndPtr; pixelPtr += 4)
661 *(int*)pixelPtr = ((pixel = *(int*)pixelPtr) & AlphaMask) == 0 ? 0x00000000 : pixel | AlphaMask;
667 bitmap.UnlockBits(bitmapData);
671 #endregion // ImageCollection Private Instance Methods
673 #region ImageCollection Internal Instance Methods
674 // For use in ImageList
675 internal void DestroyHandle()
677 if (this.handleCreated) {
678 this.list = new ArrayList();
680 this.handleCreated = false;
682 keys = new ArrayList();
687 // For use in ImageList
688 internal Image GetImage(int index)
690 if (index < 0 || index >= this.Count)
691 throw new ArgumentOutOfRangeException("index");
694 return (Image)list[index];
697 // For use in ImageListStreamer
698 internal Image[] ToArray()
702 // Handle is created even when the list is empty.
704 images = new Image[list.Count];
708 #endregion // ImageCollection Internal Instance Methods
710 #region ImageCollection Public Instance Methods
711 public void Add(Icon value)
716 AddItem(new ImageListItem(value));
720 public void Add(Image value)
725 AddItem(new ImageListItem(value));
729 public int Add(Image value, Color transparentColor)
732 return AddItem(null, new ImageListItem(value, transparentColor));
734 return AddItem(new ImageListItem(value, transparentColor));
739 public void Add(string key, Icon icon)
741 // Argument has name icon but exceptions use name value.
742 AddItem(key, new ImageListItem(icon));
745 public void Add(string key, Image image)
747 // Argument has name image but exceptions use name value.
748 AddItem(key, new ImageListItem(image));
751 public void AddRange(Image[] images)
756 throw new ArgumentNullException("images");
758 for (index = 0; index < images.Length; index++)
763 public int AddStrip(Image value)
769 throw new ArgumentNullException("value");
771 if ((width = value.Width) == 0 || (width % (imageWidth = this.imageSize.Width)) != 0)
772 throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value");
774 if (value.Height != this.imageSize.Height)
775 throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value");
778 return AddItem(null, new ImageListItem(value, width / imageWidth));
780 return AddItem(new ImageListItem(value, width / imageWidth));
787 if (this.handleCreated)
795 [EditorBrowsable(EditorBrowsableState.Never)]
797 public bool Contains(Image image)
799 throw new NotSupportedException();
803 public bool ContainsKey(string key)
805 return IndexOfKey(key) != -1;
809 public IEnumerator GetEnumerator()
811 Image[] images = new Image[this.Count];
814 if (images.Length != 0) {
815 // Handle is created only when there are images.
818 for (index = 0; index < images.Length; index++)
819 images[index] = (Image)((Image)list[index]).Clone();
822 return images.GetEnumerator();
826 [EditorBrowsable(EditorBrowsableState.Never)]
828 public int IndexOf(Image image)
830 throw new NotSupportedException();
834 public int IndexOfKey(string key)
838 if (key != null && key.Length != 0) {
839 // When last IndexOfKey was successful and the same key was
840 // assigned to an image with a lower index than the last
841 // result and the key of the last result equals to key
842 // argument the last result is returned.
844 if (this.lastKeyIndex >= 0 && this.lastKeyIndex < this.Count && CompareKeys((string)keys[this.lastKeyIndex], key))
845 return this.lastKeyIndex;
847 // Duplicate keys are allowed and first match is returned.
848 for (index = 0; index < this.Count; index++)
849 if (CompareKeys((string)keys[index], key))
850 return this.lastKeyIndex = index;
853 return this.lastKeyIndex = -1;
858 [EditorBrowsable(EditorBrowsableState.Never)]
860 public void Remove(Image image)
862 throw new NotSupportedException();
865 public void RemoveAt(int index)
867 if (index < 0 || index >= this.Count)
868 throw new ArgumentOutOfRangeException("index");
871 list.RemoveAt(index);
873 keys.RemoveAt(index);
878 public void RemoveByKey(string key)
882 if ((index = IndexOfKey(key)) != -1)
886 public void SetKeyName(int index, string name)
888 // Only SetKeyName throws IndexOutOfRangeException.
889 if (index < 0 || index >= this.Count)
890 throw new IndexOutOfRangeException();
895 #endregion // ImageCollection Public Instance Methods
897 #region ImageCollection Interface Properties
898 object IList.this[int index] {
904 if (!(value is Image))
905 throw new ArgumentException("value");
907 this[index] = (Image)value;
911 bool IList.IsFixedSize {
917 bool ICollection.IsSynchronized {
923 object ICollection.SyncRoot {
928 #endregion // ImageCollection Interface Properties
930 #region ImageCollection Interface Methods
931 int IList.Add(object value)
935 if (!(value is Image))
936 throw new ArgumentException("value");
939 this.Add((Image)value);
943 bool IList.Contains(object value)
945 return value is Image ? this.Contains((Image)value) : false;
948 int IList.IndexOf(object value)
950 return value is Image ? this.IndexOf((Image)value) : -1;
953 void IList.Insert(int index, object value)
955 throw new NotSupportedException();
958 void IList.Remove(object value)
961 this.Remove((Image)value);
964 void ICollection.CopyTo(Array array, int index)
968 for (imageIndex = 0; imageIndex < this.Count; imageIndex++)
969 array.SetValue(this[index], index++);
971 #endregion // ImageCollection Interface Methods
973 #endregion // Sub-classes
975 #region Public Constructors
978 images = new ImageCollection(this);
981 public ImageList(System.ComponentModel.IContainer container) : this()
985 #endregion // Public Constructors
987 #region Private Instance Methods
988 private void OnRecreateHandle()
990 if (recreateHandle != null)
991 recreateHandle(this, EventArgs.Empty);
995 // For use in Designers
996 private void ResetColorDepth()
998 this.ColorDepth = DefaultColorDepth;
1001 // For use in Designers
1002 private void ResetImageSize()
1004 this.ImageSize = DefaultImageSize;
1007 // For use in Designers
1008 private void ResetTransparentColor()
1010 this.TransparentColor = DefaultTransparentColor;
1013 // For use in Designers
1014 private bool ShouldSerializeColorDepth()
1016 // ColorDepth is serialized in ImageStream when non-empty.
1017 // It is serialized even if it has its default value when empty.
1018 return images.Empty;
1021 // For use in Designers
1022 private bool ShouldSerializeImageSize()
1024 // ImageSize is serialized in ImageStream when non-empty.
1025 // It is serialized even if it has its default value when empty.
1026 return images.Empty;
1029 // For use in Designers
1030 private bool ShouldSerializeTransparentColor()
1032 return this.TransparentColor != DefaultTransparentColor;
1035 #endregion // Private Instance Methods
1037 #region Public Instance Properties
1039 [DefaultValue(DefaultColorDepth)]
1041 public ColorDepth ColorDepth {
1043 return images.ColorDepth;
1047 images.ColorDepth = value;
1052 [EditorBrowsable(EditorBrowsableState.Advanced)]
1053 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1054 public IntPtr Handle {
1056 return images.Handle;
1061 [EditorBrowsable(EditorBrowsableState.Advanced)]
1062 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1063 public bool HandleCreated {
1065 return images.HandleCreated;
1069 [DefaultValue(null)]
1070 [MergableProperty(false)]
1071 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1072 public ImageCollection Images {
1079 public Size ImageSize {
1081 return images.ImageSize;
1085 images.ImageSize = value;
1090 [DefaultValue(null)]
1091 [EditorBrowsable(EditorBrowsableState.Advanced)]
1092 public ImageListStreamer ImageStream {
1094 return images.ImageStream;
1098 images.ImageStream = value;
1104 [DefaultValue(null)]
1105 [Localizable(false)]
1106 [TypeConverter(typeof(StringConverter))]
1118 public Color TransparentColor {
1120 return images.TransparentColor;
1124 images.TransparentColor = value;
1127 #endregion // Public Instance Properties
1129 #region Public Instance Methods
1130 public void Draw(Graphics g, Point pt, int index)
1132 this.Draw(g, pt.X, pt.Y, index);
1135 public void Draw(Graphics g, int x, int y, int index)
1137 g.DrawImage(images.GetImage(index), x, y);
1140 public void Draw(Graphics g, int x, int y, int width, int height, int index)
1142 g.DrawImage(images.GetImage(index), x, y, width, height);
1145 public override string ToString()
1147 return base.ToString() + " Images.Count: " + images.Count.ToString() + ", ImageSize: " + images.ImageSize.ToString();
1149 #endregion // Public Instance Methods
1151 #region Protected Instance Methods
1152 protected override void Dispose(bool disposing)
1155 images.DestroyHandle();
1157 base.Dispose(disposing);
1159 #endregion // Protected Instance Methods
1163 [EditorBrowsable(EditorBrowsableState.Advanced)]
1164 public event EventHandler RecreateHandle {
1166 recreateHandle += value;
1170 recreateHandle -= value;
1173 #endregion // Events