using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Drawing; using TaskbarLib; namespace TaskbarLib { /// /// Represents a thumbnail toolbar button. /// public class ThumbnailBarButton : ThumbnailBarButtonBase { private Bitmap icon; private int imageIndex; /// /// Initializes a with a Bitmap icon. /// /// Icon of the button. /// Tooltip of the button. /// Specifies whether button is hidden initially. /// Specifies whether button is disabled initially. /// Specifies whether button is dismissed on click. /// Specifies whether button has background. public ThumbnailBarButton(Bitmap icon, string tooltip, bool isHidden, bool isDisabled, bool isDismissedOnClick, bool hasBackground) : base(tooltip, isHidden, isDisabled, isDismissedOnClick, hasBackground) { this.icon = icon; if (icon != null) { this.IconHandle = new IconHandle(icon.GetHicon()); } } /// /// Initializes a with an icon resides in an . /// /// Index of the image from associated . /// Tooltip of the button. /// Specifies whether button is hidden initially. /// Specifies whether button is disabled initially. /// Specifies whether button is dismissed on click. /// Specifies whether button has background. public ThumbnailBarButton(int imageIndex, string tooltip, bool isHidden, bool isDisabled, bool isDismissedOnClick, bool hasBackground) : base(tooltip, isHidden, isDisabled, isDismissedOnClick, hasBackground) { this.imageIndex = imageIndex; } /// /// A icon for button. /// public Bitmap Icon { get { return this.icon; } set { this.icon = value; if (value != null) { this.IconHandle = new IconHandle(value.GetHicon()); } this.Update(); } } /// /// index of the the image that will be used as button icon. /// public int ImageIndex { get { return this.imageIndex; } set { this.imageIndex = value; this.Update(); } } internal override void BeforeGetUnmanagedButton(ref TaskbarNative.ThumbButton button) { button.BitmapIndex = this.imageIndex; button.Mask |= TaskbarNative.ThumbButtonMask.Bitmap; } protected override void Update() { } } }