using System; using System.Drawing; using TaskbarLib.Interop; namespace TaskbarLib.DesktopIntegration { /// /// Represents a taskbar thumbnail button in the thumbnail toolbar. /// public sealed class ThumbButton { private ThumbButtonManager _manager; internal ThumbButton(ThumbButtonManager manager, uint id, Icon icon, string tooltip) { _manager = manager; Id = id; Icon = icon; Tooltip = tooltip; } /// /// The event that occurs when the taskbar thumbnail button /// is clicked. /// public event EventHandler Clicked; /// /// Gets or sets thumbnail button's id. /// public uint Id { get; set; } /// /// Gets or sets the thumbnail button's icon. /// public Icon Icon { get; set; } /// /// Gets or sets the thumbnail button's tooltip. /// public string Tooltip { get; set; } internal THBFLAGS Flags { get; set; } internal THUMBBUTTON Win32ThumbButton { get { THUMBBUTTON win32ThumbButton = new THUMBBUTTON(); win32ThumbButton.iId = Id; win32ThumbButton.szTip = Tooltip; win32ThumbButton.hIcon = Icon.Handle; win32ThumbButton.dwFlags = Flags; win32ThumbButton.dwMask = THBMASK.THB_FLAGS; if (Tooltip != null) win32ThumbButton.dwMask |= THBMASK.THB_TOOLTIP; if (Icon != null) win32ThumbButton.dwMask |= THBMASK.THB_ICON; return win32ThumbButton; } } /// /// Gets or sets the thumbnail button's visibility. /// public bool Visible { get { return (this.Flags & THBFLAGS.THBF_HIDDEN) == 0; } set { if (value) { this.Flags &= ~(THBFLAGS.THBF_HIDDEN); } else { this.Flags |= THBFLAGS.THBF_HIDDEN; } _manager.RefreshThumbButtons(); } } /// /// Gets or sets the thumbnail button's enabled state. /// public bool Enabled { get { return (this.Flags & THBFLAGS.THBF_DISABLED) == 0; } set { if (value) { this.Flags &= ~(THBFLAGS.THBF_DISABLED); } else { this.Flags |= THBFLAGS.THBF_DISABLED; } _manager.RefreshThumbButtons(); } } internal void FireClick() { if (Clicked != null) Clicked(this, EventArgs.Empty); } } }