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();
 }
        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 current     = enumerator.Current;
                        THUMBBUTTON     tHUMBBUTTON = new THUMBBUTTON
                        {
                            iId    = num,
                            dwMask = THB.ICON | THB.TOOLTIP | THB.FLAGS
                        };
                        switch (current.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 = (current.Description ?? "");
                        tHUMBBUTTON.hIcon = this._GetHICONFromImageSource(current.ImageSource, this._overlaySize);
                        if (!current.IsBackgroundVisible)
                        {
                            tHUMBBUTTON.dwFlags |= THBF.NOBACKGROUND;
                        }
                        if (!current.IsEnabled)
                        {
                            tHUMBBUTTON.dwFlags |= THBF.DISABLED;
                        }
                        else
                        {
                            tHUMBBUTTON.dwFlags = tHUMBBUTTON.dwFlags;
                        }
                        if (!current.IsInteractive)
                        {
                            tHUMBBUTTON.dwFlags |= THBF.NONINTERACTIVE;
                        }
                        if (current.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
            {
                THUMBBUTTON[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    THUMBBUTTON tHUMBBUTTON2 = array2[i];
                    IntPtr      hIcon        = tHUMBBUTTON2.hIcon;
                    if (IntPtr.Zero != hIcon)
                    {
                        Utility.SafeDestroyIcon(ref hIcon);
                    }
                }
            }
            return(result2);
        }