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 Size DefaultImageSize = new Size(16, 16);
91 private static readonly Color DefaultTransparentColor = Color.Transparent;
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);
112 class IndexedColorDepths
115 private IndexedColorDepths()
119 internal static readonly ColorPalette Palette4Bit;
120 internal static readonly ColorPalette Palette8Bit;
121 private static readonly int[] squares;
123 static IndexedColorDepths()
128 bitmap = new Bitmap(1, 1, PixelFormat.Format4bppIndexed);
129 Palette4Bit = bitmap.Palette;
132 bitmap = new Bitmap(1, 1, PixelFormat.Format8bppIndexed);
133 Palette8Bit = bitmap.Palette;
136 squares = new int[511];
137 for (index = 0; index < 256; index++)
138 squares[255 + index] = squares[255 - index] = index * index;
141 internal static int GetNearestColor(Color[] palette, int color)
152 count = palette.Length;
153 for (index = 0; index < count; index++)
154 if (palette[index].ToArgb() == color)
157 red = unchecked((int)(unchecked((uint)color) >> 16) & 0xFF);
158 green = unchecked((int)(unchecked((uint)color) >> 8) & 0xFF);
160 nearestColor = AlphaMask;
161 minDistance = int.MaxValue;
163 for (index = 0; index < count; index++)
164 if ((distance = squares[255 + palette[index].R - red] + squares[255 + palette[index].G - green] + squares[255 + palette[index].B - blue]) < minDistance) {
165 nearestColor = palette[index].ToArgb();
166 minDistance = distance;
174 private enum ItemFlags
177 UseTransparentColor = 1,
181 private sealed class ImageListItem
183 internal readonly object Image;
184 internal readonly ItemFlags Flags;
185 internal readonly Color TransparentColor;
186 internal readonly int ImageCount = 1;
188 internal ImageListItem(Icon value)
191 throw new ArgumentNullException("value");
194 this.Image = (Icon)value.Clone();
197 internal ImageListItem(Image value)
200 throw new ArgumentNullException("value");
202 if (!(value is Bitmap))
203 throw new ArgumentException("Image must be a Bitmap.");
205 // Images are not cloned.
209 internal ImageListItem(Image value, Color transparentColor) : this(value)
211 this.Flags = ItemFlags.UseTransparentColor;
212 this.TransparentColor = transparentColor;
215 internal ImageListItem(Image value, int imageCount) : this(value)
217 this.Flags = ItemFlags.ImageStrip;
218 this.ImageCount = imageCount;
222 #region ImageCollection Private Fields
223 private ColorDepth colorDepth = DefaultColorDepth;
224 private Size imageSize = DefaultImageSize;
225 private Color transparentColor = DefaultTransparentColor;
226 private ArrayList list = new ArrayList();
228 private ArrayList keys = new ArrayList();
231 private bool handleCreated;
233 private int lastKeyIndex = -1;
235 private readonly ImageList owner;
236 #endregion // ImageCollection Private Fields
238 #region ImageCollection Internal Constructors
239 // For use in ImageList
240 internal ImageCollection(ImageList owner)
244 #endregion // ImageCollection Internal Constructor
246 #region ImageCollection Internal Instance Properties
247 // For use in ImageList
248 internal ColorDepth ColorDepth {
250 return this.colorDepth;
254 if (!Enum.IsDefined(typeof(ColorDepth), value))
255 throw new InvalidEnumArgumentException("value", (int)value, typeof(ColorDepth));
257 if (this.colorDepth != value) {
258 this.colorDepth = value;
264 // For use in ImageList
265 internal IntPtr Handle {
272 // For use in ImageList
273 internal bool HandleCreated {
275 return this.handleCreated;
279 // For use in ImageList
280 internal Size ImageSize {
282 return this.imageSize;
286 if (value.Width < 1 || value.Width > 256 || value.Height < 1 || value.Height > 256)
287 throw new ArgumentException("ImageSize.Width and Height must be between 1 and 256", "value");
289 if (this.imageSize != value) {
290 this.imageSize = value;
296 // For use in ImageList
297 internal ImageListStreamer ImageStream {
299 return this.Empty ? null : new ImageListStreamer(this);
304 Image[] streamImages;
308 if (this.handleCreated)
314 // Only deserialized ImageListStreamers are used.
315 else if ((streamImages = value.Images) != null) {
316 this.list = new ArrayList(streamImages.Length);
318 this.handleCreated = true;
320 this.keys = new ArrayList(streamImages.Length);
323 for (index = 0; index < streamImages.Length; index++) {
324 list.Add((Image)streamImages[index].Clone());
330 // Invalid ColorDepth values are ignored.
331 if (Enum.IsDefined(typeof(ColorDepth), value.ColorDepth))
332 this.colorDepth = (ColorDepth)value.ColorDepth;
333 this.imageSize = value.ImageSize;
336 // Event is raised even when handle was not created yet.
337 owner.OnRecreateHandle();
343 // For use in ImageList
344 internal Color TransparentColor {
346 return this.transparentColor;
350 this.transparentColor = value;
353 #endregion // ImageCollection Internal Instance Properties
355 #region ImageCollection Public Instance Properties
359 return this.handleCreated ? list.Count : this.count;
365 return this.Count == 0;
369 public bool IsReadOnly {
376 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
377 public Image this[int index] {
379 return (Image)GetImage(index).Clone();
385 if (index < 0 || index >= this.Count)
386 throw new ArgumentOutOfRangeException("index");
389 throw new ArgumentNullException("value");
391 if (!(value is Bitmap))
392 throw new ArgumentException("Image must be a Bitmap.");
394 image = CreateImage(value, this.transparentColor);
401 public Image this[string key] {
405 return (index = IndexOfKey(key)) == -1 ? null : this[index];
409 public StringCollection Keys {
413 StringCollection keyCollection;
415 // Returns all keys even when there are more keys than
416 // images. Null keys are returned as empty strings.
418 keyCollection = new StringCollection();
419 for (index = 0; index < keys.Count; index++)
420 keyCollection.Add(((key = (string)keys[index]) == null || key.Length == 0) ? string.Empty : key);
422 return keyCollection;
426 #endregion // ImageCollection Public Instance Properties
428 #region ImageCollection Private Static Methods
430 private static bool CompareKeys(string key1, string key2)
432 // Keys are case-insensitive and keys with different length
433 // are not equal even when string.Compare treats them equal.
435 if (key1 == null || key2 == null || key1.Length != key2.Length)
438 return string.Compare(key1, key2, true, CultureInfo.InvariantCulture) == 0;
441 #endregion // ImageCollection Private Static Methods
443 #region ImageCollection Private Instance Methods
445 private int AddItem(string key, ImageListItem item)
447 private int AddItem(ImageListItem item)
455 if (this.handleCreated)
456 itemIndex = AddItemInternal(item);
458 // Image strips are counted as a single item in the return
459 // value of Add and AddStrip until handle is created.
461 itemIndex = list.Add(item);
462 this.count += item.ImageCount;
466 if ((item.Flags & ItemFlags.ImageStrip) == 0)
469 for (index = 0; index < item.ImageCount; index++)
476 private int AddItemInternal(ImageListItem item)
478 if (item.Image is Icon) {
484 bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);
485 graphics = Graphics.FromImage(bitmap);
486 graphics.DrawIcon((Icon)item.Image, new Rectangle(0, 0, imageWidth, imageHeight));
489 ReduceColorDepth(bitmap);
490 return list.Add(bitmap);
492 else if ((item.Flags & ItemFlags.ImageStrip) == 0)
493 return list.Add(CreateImage((Image)item.Image, (item.Flags & ItemFlags.UseTransparentColor) == 0 ? this.transparentColor : item.TransparentColor));
504 ImageAttributes imageAttributes;
506 // When ImageSize was changed after adding image strips
507 // Count will return invalid values based on old ImageSize
508 // but when creating handle either ArgumentException will
509 // be thrown or image strip will be added according to the
510 // new ImageSize. This can result in image count
511 // difference that can result in exceptions in methods
512 // that use Count before creating handle. In addition this
513 // can result in the loss of sync with keys. When doing
514 // the same after handle was created there are no problems
515 // as handle will be recreated after changing ImageSize
516 // that results in the loss of images added previously.
518 if ((width = (image = (Image)item.Image).Width) == 0 || (width % (imageWidth = this.imageSize.Width)) != 0)
519 throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value");
521 if (image.Height != (imageHeight = this.imageSize.Height))
522 throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value");
524 imageRect = new Rectangle(0, 0, imageWidth, imageHeight);
525 if (this.transparentColor.A == 0)
526 imageAttributes = null;
528 imageAttributes = new ImageAttributes();
529 imageAttributes.SetColorKey(this.transparentColor, this.transparentColor);
533 for (imageX = 0; imageX < width; imageX += imageWidth) {
534 bitmap = new Bitmap(imageWidth, imageHeight, PixelFormat.Format32bppArgb);
535 graphics = Graphics.FromImage(bitmap);
536 graphics.DrawImage(image, imageRect, imageX, 0, imageWidth, imageHeight, GraphicsUnit.Pixel, imageAttributes);
539 ReduceColorDepth(bitmap);
543 if (imageAttributes != null)
544 imageAttributes.Dispose();
550 private void CreateHandle()
555 if (!this.handleCreated) {
557 this.list = new ArrayList(this.count);
559 this.handleCreated = true;
561 for (index = 0; index < items.Count; index++)
562 AddItemInternal((ImageListItem)items[index]);
566 private Image CreateImage(Image value, Color transparentColor)
572 ImageAttributes imageAttributes;
574 if (transparentColor.A == 0)
575 imageAttributes = null;
577 imageAttributes = new ImageAttributes();
578 imageAttributes.SetColorKey(transparentColor, transparentColor);
581 bitmap = new Bitmap(imageWidth = this.imageSize.Width, imageHeight = this.imageSize.Height, PixelFormat.Format32bppArgb);
582 graphics = Graphics.FromImage(bitmap);
583 graphics.DrawImage(value, new Rectangle(0, 0, imageWidth, imageHeight), 0, 0, value.Width, value.Height, GraphicsUnit.Pixel, imageAttributes);
586 if (imageAttributes != null)
587 imageAttributes.Dispose();
589 ReduceColorDepth(bitmap);
593 private void RecreateHandle()
595 if (this.handleCreated) {
597 this.handleCreated = true;
598 owner.OnRecreateHandle();
602 private unsafe void ReduceColorDepth(Bitmap bitmap)
612 BitmapData bitmapData;
615 if (this.colorDepth < ColorDepth.Depth32Bit) {
616 bitmapData = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
618 linePtr = (byte*)bitmapData.Scan0;
619 height = bitmapData.Height;
620 widthBytes = bitmapData.Width << 2;
621 stride = bitmapData.Stride;
623 if (this.colorDepth < ColorDepth.Depth16Bit) {
624 palette = (this.colorDepth < ColorDepth.Depth8Bit ? IndexedColorDepths.Palette4Bit : IndexedColorDepths.Palette8Bit).Entries;
626 for (line = 0; line < height; line++) {
627 lineEndPtr = linePtr + widthBytes;
628 for (pixelPtr = linePtr; pixelPtr < lineEndPtr; pixelPtr += 4)
629 *(int*)pixelPtr = ((pixel = *(int*)pixelPtr) & AlphaMask) == 0 ? 0x00000000 : IndexedColorDepths.GetNearestColor(palette, pixel | AlphaMask);
633 else if (this.colorDepth < ColorDepth.Depth24Bit) {
634 for (line = 0; line < height; line++) {
635 lineEndPtr = linePtr + widthBytes;
636 for (pixelPtr = linePtr; pixelPtr < lineEndPtr; pixelPtr += 4)
637 *(int*)pixelPtr = ((pixel = *(int*)pixelPtr) & AlphaMask) == 0 ? 0x00000000 : (pixel & 0x00F8F8F8) | AlphaMask;
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 : pixel | AlphaMask;
651 bitmap.UnlockBits(bitmapData);
655 #endregion // ImageCollection Private Instance Methods
657 #region ImageCollection Internal Instance Methods
658 // For use in ImageList
659 internal void DestroyHandle()
661 if (this.handleCreated) {
662 this.list = new ArrayList();
664 this.handleCreated = false;
666 keys = new ArrayList();
671 // For use in ImageList
672 internal Image GetImage(int index)
674 if (index < 0 || index >= this.Count)
675 throw new ArgumentOutOfRangeException("index");
678 return (Image)list[index];
681 // For use in ImageListStreamer
682 internal Image[] ToArray()
686 // Handle is created even when the list is empty.
688 images = new Image[list.Count];
692 #endregion // ImageCollection Internal Instance Methods
694 #region ImageCollection Public Instance Methods
695 public void Add(Icon value)
700 AddItem(new ImageListItem(value));
704 public void Add(Image value)
709 AddItem(new ImageListItem(value));
713 public int Add(Image value, Color transparentColor)
716 return AddItem(null, new ImageListItem(value, transparentColor));
718 return AddItem(new ImageListItem(value, transparentColor));
723 public void Add(string key, Icon icon)
725 // Argument has name icon but exceptions use name value.
726 AddItem(key, new ImageListItem(icon));
729 public void Add(string key, Image image)
731 // Argument has name image but exceptions use name value.
732 AddItem(key, new ImageListItem(image));
735 public void AddRange(Image[] images)
740 throw new ArgumentNullException("images");
742 for (index = 0; index < images.Length; index++)
747 public int AddStrip(Image value)
753 throw new ArgumentNullException("value");
755 if ((width = value.Width) == 0 || (width % (imageWidth = this.imageSize.Width)) != 0)
756 throw new ArgumentException("Width of image strip must be a positive multiple of ImageSize.Width.", "value");
758 if (value.Height != this.imageSize.Height)
759 throw new ArgumentException("Height of image strip must be equal to ImageSize.Height.", "value");
762 return AddItem(null, new ImageListItem(value, width / imageWidth));
764 return AddItem(new ImageListItem(value, width / imageWidth));
771 if (this.handleCreated)
779 [EditorBrowsable(EditorBrowsableState.Never)]
781 public bool Contains(Image image)
783 throw new NotSupportedException();
787 public bool ContainsKey(string key)
789 return IndexOfKey(key) != -1;
793 public IEnumerator GetEnumerator()
795 Image[] images = new Image[this.Count];
798 if (images.Length != 0) {
799 // Handle is created only when there are images.
802 for (index = 0; index < images.Length; index++)
803 images[index] = (Image)((Image)list[index]).Clone();
806 return images.GetEnumerator();
810 [EditorBrowsable(EditorBrowsableState.Never)]
812 public int IndexOf(Image image)
814 throw new NotSupportedException();
818 public int IndexOfKey(string key)
822 if (key != null && key.Length != 0) {
823 // When last IndexOfKey was successful and the same key was
824 // assigned to an image with a lower index than the last
825 // result and the key of the last result equals to key
826 // argument the last result is returned.
828 if (this.lastKeyIndex >= 0 && this.lastKeyIndex < this.Count && CompareKeys((string)keys[this.lastKeyIndex], key))
829 return this.lastKeyIndex;
831 // Duplicate keys are allowed and first match is returned.
832 for (index = 0; index < this.Count; index++)
833 if (CompareKeys((string)keys[index], key))
834 return this.lastKeyIndex = index;
837 return this.lastKeyIndex = -1;
842 [EditorBrowsable(EditorBrowsableState.Never)]
844 public void Remove(Image image)
846 throw new NotSupportedException();
849 public void RemoveAt(int index)
851 if (index < 0 || index >= this.Count)
852 throw new ArgumentOutOfRangeException("index");
855 list.RemoveAt(index);
857 keys.RemoveAt(index);
862 public void RemoveByKey(string key)
866 if ((index = IndexOfKey(key)) != -1)
870 public void SetKeyName(int index, string name)
872 // Only SetKeyName throws IndexOutOfRangeException.
873 if (index < 0 || index >= this.Count)
874 throw new IndexOutOfRangeException();
879 #endregion // ImageCollection Public Instance Methods
881 #region ImageCollection Interface Properties
882 object IList.this[int index] {
888 if (!(value is Image))
889 throw new ArgumentException("value");
891 this[index] = (Image)value;
895 bool IList.IsFixedSize {
901 bool ICollection.IsSynchronized {
907 object ICollection.SyncRoot {
912 #endregion // ImageCollection Interface Properties
914 #region ImageCollection Interface Methods
915 int IList.Add(object value)
919 if (!(value is Image))
920 throw new ArgumentException("value");
923 this.Add((Image)value);
927 bool IList.Contains(object value)
929 return value is Image ? this.Contains((Image)value) : false;
932 int IList.IndexOf(object value)
934 return value is Image ? this.IndexOf((Image)value) : -1;
937 void IList.Insert(int index, object value)
939 throw new NotSupportedException();
942 void IList.Remove(object value)
945 this.Remove((Image)value);
948 void ICollection.CopyTo(Array array, int index)
952 for (imageIndex = 0; imageIndex < this.Count; imageIndex++)
953 array.SetValue(this[index], index++);
955 #endregion // ImageCollection Interface Methods
957 #endregion // Sub-classes
959 #region Public Constructors
962 images = new ImageCollection(this);
965 public ImageList(System.ComponentModel.IContainer container) : this()
969 #endregion // Public Constructors
971 #region Private Instance Methods
972 private void OnRecreateHandle()
974 if (this.recreateHandle != null)
975 this.recreateHandle(this, EventArgs.Empty);
979 // For use in Designers
980 private void ResetColorDepth()
982 this.ColorDepth = DefaultColorDepth;
985 // For use in Designers
986 private void ResetImageSize()
988 this.ImageSize = DefaultImageSize;
991 // For use in Designers
992 private void ResetTransparentColor()
994 this.TransparentColor = DefaultTransparentColor;
997 // For use in Designers
998 private bool ShouldSerializeColorDepth()
1000 // ColorDepth is serialized in ImageStream when non-empty.
1001 // It is serialized even if it has its default value when empty.
1002 return images.Empty;
1005 // For use in Designers
1006 private bool ShouldSerializeImageSize()
1008 // ImageSize is serialized in ImageStream when non-empty.
1009 // It is serialized even if it has its default value when empty.
1010 return images.Empty;
1013 // For use in Designers
1014 private bool ShouldSerializeTransparentColor()
1016 return this.TransparentColor != DefaultTransparentColor;
1019 #endregion // Private Instance Methods
1021 #region Public Instance Properties
1023 [DefaultValue(DefaultColorDepth)]
1025 public ColorDepth ColorDepth {
1027 return images.ColorDepth;
1031 images.ColorDepth = value;
1036 [EditorBrowsable(EditorBrowsableState.Advanced)]
1037 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1038 public IntPtr Handle {
1040 return images.Handle;
1045 [EditorBrowsable(EditorBrowsableState.Advanced)]
1046 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1047 public bool HandleCreated {
1049 return images.HandleCreated;
1053 [DefaultValue(null)]
1054 [MergableProperty(false)]
1055 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1056 public ImageCollection Images {
1063 public Size ImageSize {
1065 return images.ImageSize;
1069 images.ImageSize = value;
1074 [DefaultValue(null)]
1075 [EditorBrowsable(EditorBrowsableState.Advanced)]
1076 public ImageListStreamer ImageStream {
1078 return images.ImageStream;
1082 images.ImageStream = value;
1088 [DefaultValue(null)]
1089 [Localizable(false)]
1090 [TypeConverter(typeof(StringConverter))]
1102 public Color TransparentColor {
1104 return images.TransparentColor;
1108 images.TransparentColor = value;
1111 #endregion // Public Instance Properties
1113 #region Public Instance Methods
1114 public void Draw(Graphics g, Point pt, int index)
1116 this.Draw(g, pt.X, pt.Y, index);
1119 public void Draw(Graphics g, int x, int y, int index)
1121 g.DrawImage(images.GetImage(index), x, y);
1124 public void Draw(Graphics g, int x, int y, int width, int height, int index)
1126 g.DrawImage(images.GetImage(index), x, y, width, height);
1129 public override string ToString()
1131 return base.ToString() + " Images.Count: " + images.Count.ToString() + ", ImageSize: " + this.ImageSize.ToString();
1133 #endregion // Public Instance Methods
1135 #region Protected Instance Methods
1136 protected override void Dispose(bool disposing)
1139 images.DestroyHandle();
1141 base.Dispose(disposing);
1143 #endregion // Protected Instance Methods
1147 [EditorBrowsable(EditorBrowsableState.Advanced)]
1148 public event EventHandler RecreateHandle {
1150 this.recreateHandle += value;
1154 this.recreateHandle -= value;
1157 #endregion // Events