public TaskbarItemInfo()
 {
     if (!DesignerProperties.GetIsInDesignMode(this))
     {
         ITaskbarList taskbarList = null;
         try
         {
             taskbarList = CLSID.CoCreateInstance <ITaskbarList>("56FDF344-FD6D-11d0-958A-006097C9A090");
             taskbarList.HrInit();
             this._taskbarList = (taskbarList as ITaskbarList3);
             taskbarList       = null;
         }
         finally
         {
             Utility.SafeRelease <ITaskbarList>(ref taskbarList);
         }
         this._overlaySize = new Size((double)NativeMethods.GetSystemMetrics(SM.CXSMICON), (double)NativeMethods.GetSystemMetrics(SM.CYSMICON));
     }
     this.ThumbButtonInfos = new ThumbButtonInfoCollection();
 }
 public TaskbarThumbButtonInfoCollection(ThumbButtonInfoCollection collection)
 {
     GuardHelper.ArgumentNotNull(collection, "collection");
     this.InternalCollection = collection;
 }
        public TaskbarItemInfo()
        {
            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                ITaskbarList taskbarList = null;
                try
                {
                    taskbarList = CLSID.CoCreateInstance<ITaskbarList>(CLSID.TaskbarList);
                    taskbarList.HrInit();

                    // This QI will only work on Win7.
                    _taskbarList = taskbarList as ITaskbarList3;

                    taskbarList = null;
                }
                finally
                {
                    Utility.SafeRelease(ref taskbarList);
                }

                _overlaySize = new Size(
                    NativeMethods.GetSystemMetrics(SM.CXSMICON),
                    NativeMethods.GetSystemMetrics(SM.CYSMICON));
            }

            // Set ThumbButtons to an empty list so callers can just use the property.
            ThumbButtonInfos = new ThumbButtonInfoCollection();
        }
    private HRESULT _UpdateThumbButtons(bool attached)
    {
        THUMBBUTTON[] array  = new THUMBBUTTON[7];
        HRESULT       result = this._RegisterThumbButtons();

        if (result.Failed)
        {
            return(result);
        }
        ThumbButtonInfoCollection thumbButtonInfos = this.ThumbButtonInfos;
        HRESULT result2;

        try
        {
            uint num = 0u;
            if (!attached || thumbButtonInfos == null)
            {
                goto IL_1AE;
            }
            using (FreezableCollection <ThumbButtonInfo> .Enumerator enumerator = thumbButtonInfos.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ThumbButtonInfo thumbButtonInfo = enumerator.Current;
                    THUMBBUTTON     thumbbutton     = new THUMBBUTTON
                    {
                        iId    = num,
                        dwMask = (THB.ICON | THB.TOOLTIP | THB.FLAGS)
                    };
                    switch (thumbButtonInfo.Visibility)
                    {
                    case Visibility.Visible:
                        goto IL_A5;

                    case Visibility.Hidden:
                        thumbbutton.dwFlags = (THBF.DISABLED | THBF.NOBACKGROUND);
                        thumbbutton.hIcon   = IntPtr.Zero;
                        break;

                    case Visibility.Collapsed:
                        thumbbutton.dwFlags = THBF.HIDDEN;
                        break;

                    default:
                        goto IL_A5;
                    }
IL_146:
                    array[(int)((UIntPtr)num)] = thumbbutton;
                    num += 1u;
                    if (num != 7u)
                    {
                        continue;
                    }
                    break;
IL_A5:
                    thumbbutton.szTip = (thumbButtonInfo.Description ?? "");
                    thumbbutton.hIcon = this._GetHICONFromImageSource(thumbButtonInfo.ImageSource, this._overlaySize);
                    if (!thumbButtonInfo.IsBackgroundVisible)
                    {
                        thumbbutton.dwFlags |= THBF.NOBACKGROUND;
                    }
                    if (!thumbButtonInfo.IsEnabled)
                    {
                        thumbbutton.dwFlags |= THBF.DISABLED;
                    }
                    else
                    {
                        thumbbutton.dwFlags = thumbbutton.dwFlags;
                    }
                    if (!thumbButtonInfo.IsInteractive)
                    {
                        thumbbutton.dwFlags |= THBF.NONINTERACTIVE;
                    }
                    if (thumbButtonInfo.DismissWhenClicked)
                    {
                        thumbbutton.dwFlags |= THBF.DISMISSONCLICK;
                        goto IL_146;
                    }
                    goto IL_146;
                }
                goto IL_1AE;
            }
IL_179:
            array[(int)((UIntPtr)num)] = new THUMBBUTTON
            {
                iId     = num,
                dwFlags = (THBF.DISABLED | THBF.NOBACKGROUND | THBF.HIDDEN),
                dwMask  = (THB.ICON | THB.TOOLTIP | THB.FLAGS)
            };
            num += 1u;
IL_1AE:
            if (num < 7u)
            {
                goto IL_179;
            }
            result2 = this._taskbarList.ThumbBarUpdateButtons(this._hwndSource.Handle, (uint)array.Length, array);
        }
        finally
        {
            foreach (THUMBBUTTON thumbbutton2 in array)
            {
                IntPtr hIcon = thumbbutton2.hIcon;
                if (IntPtr.Zero != hIcon)
                {
                    Utility.SafeDestroyIcon(ref hIcon);
                }
            }
        }
        return(result2);
    }