Exemplo n.º 1
0
        /// <summary>
        /// Creates a JumpList for the given application instance.
        /// It also adds thumbnail toolbars, which are a set of up to seven buttons at the bottom of the taskbar’s icon thumbnail preview.
        /// </summary>
        /// <param name="windowHandle">The application instance's main window handle.</param>
        /// <param name="buttons">The thumbnail toolbar buttons to be added.</param>
        public void CreateJumpList(IntPtr windowHandle, WindowsThumbnailToolbarButtons buttons)
        {
            if (ToolbarButtonsCreated || !IsSupported || windowHandle == IntPtr.Zero)
            {
                return;
            }

            SafeInvoke(() =>
            {
                // One ApplicationId, so all windows must share the same jumplist
                var jumpList = JumpList.CreateJumpList();
                jumpList.ClearAllUserTasks();
                jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
                jumpList.Refresh();

                CreateTaskbarButtons(windowHandle, buttons);
            }, nameof(CreateJumpList));

            return;

            void CreateTaskbarButtons(IntPtr handle, WindowsThumbnailToolbarButtons thumbButtons)
            {
                _commitButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Commit.Image, 48, true), thumbButtons.Commit.Text);
                _commitButton.Click += thumbButtons.Commit.Click;

                _pushButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Push.Image, 48, true), thumbButtons.Push.Text);
                _pushButton.Click += thumbButtons.Push.Click;

                _pullButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Pull.Image, 48, true), thumbButtons.Pull.Text);
                _pullButton.Click += thumbButtons.Pull.Click;

                // Call this method using reflection.  This is a workaround to *not* reference WPF libraries, becuase of how the WindowsAPICodePack was implimented.
                TaskbarManager.Instance.ThumbnailToolBars.AddButtons(handle, _commitButton, _pullButton, _pushButton);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a JumpList for the given application instance.
        /// It also adds thumbnail toolbars, which are a set of up to seven buttons at the bottom of the taskbar’s icon thumbnail preview.
        /// </summary>
        /// <param name="windowHandle">The application instance's main window handle.</param>
        /// <param name="buttons">The thumbnail toolbar buttons to be added.</param>
        public void CreateJumpList(IntPtr windowHandle, WindowsThumbnailToolbarButtons buttons)
        {
            if (!IsSupported)
            {
                return;
            }

            CreateJumpList();

            CreateTaskbarButtons(windowHandle, buttons);

            return;

            void CreateJumpList()
            {
                try
                {
                    var jumpList = JumpList.CreateJumpListForIndividualWindow(TaskbarManager.Instance.ApplicationId, windowHandle);
                    jumpList.ClearAllUserTasks();
                    jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
                    jumpList.Refresh();
                }
                catch
                {
                    // have seen a COM exception here that caused the UI to stop loading
                }
            }

            void CreateTaskbarButtons(IntPtr handle, WindowsThumbnailToolbarButtons thumbButtons)
            {
                if (!_toolbarButtonsCreated)
                {
                    _commitButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Commit.Image, 48, true), thumbButtons.Commit.Text);
                    _commitButton.Click += thumbButtons.Commit.Click;

                    _pushButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Push.Image, 48, true), thumbButtons.Push.Text);
                    _pushButton.Click += thumbButtons.Push.Click;

                    _pullButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Pull.Image, 48, true), thumbButtons.Pull.Text);
                    _pullButton.Click += thumbButtons.Pull.Click;

                    _toolbarButtonsCreated = true;

                    // Call this method using reflection.  This is a workaround to *not* reference WPF libraries, becuase of how the WindowsAPICodePack was implimented.
                    TaskbarManager.Instance.ThumbnailToolBars.AddButtons(handle, _commitButton, _pullButton, _pushButton);
                    TaskbarManager.Instance.ApplicationId = "GitExtensions";
                }

                _commitButton.Enabled = true;
                _pushButton.Enabled   = true;
                _pullButton.Enabled   = true;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a JumpList for the given application instance.
        /// It also adds thumbnail toolbars, which are a set of up to seven buttons at the bottom of the taskbar’s icon thumbnail preview.
        /// </summary>
        /// <param name="windowHandle">The application instance's main window handle.</param>
        /// <param name="buttons">The thumbnail toolbar buttons to be added.</param>
        public void CreateJumpList(IntPtr windowHandle, WindowsThumbnailToolbarButtons buttons)
        {
            if (!IsSupported)
            {
                return;
            }

            var jumpList = JumpList.CreateJumpListForIndividualWindow(TaskbarManager.Instance.ApplicationId, windowHandle);

            jumpList.ClearAllUserTasks();
            jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
            jumpList.Refresh();

            CreateTaskbarButtons(windowHandle, buttons);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a JumpList for the given application instance.
        /// It also adds thumbnail toolbars, which are a set of up to seven buttons at the bottom of the taskbar’s icon thumbnail preview.
        /// </summary>
        /// <param name="windowHandle">The application instance's main window handle.</param>
        /// <param name="buttons">The thumbnail toolbar buttons to be added.</param>
        public void CreateJumpList(IntPtr windowHandle, WindowsThumbnailToolbarButtons buttons)
        {
            if (ToolbarButtonsCreated || !IsSupported || windowHandle == IntPtr.Zero)
            {
                return;
            }

            CreateJumpList();

            CreateTaskbarButtons(windowHandle, buttons);

            return;

            void CreateJumpList()
            {
                try
                {
                    // One ApplicationId, so all windows must share the same jumplist
                    var jumpList = JumpList.CreateJumpList();
                    jumpList.ClearAllUserTasks();
                    jumpList.KnownCategoryToDisplay = JumpListKnownCategoryType.Recent;
                    jumpList.Refresh();
                }
                catch (Exception ex)
                {
                    // have seen a COM exception here that caused the UI to stop loading
                    Trace.WriteLine(ex.Message, "CreateJumpList");
                }
            }

            void CreateTaskbarButtons(IntPtr handle, WindowsThumbnailToolbarButtons thumbButtons)
            {
                _commitButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Commit.Image, 48, true), thumbButtons.Commit.Text);
                _commitButton.Click += thumbButtons.Commit.Click;

                _pushButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Push.Image, 48, true), thumbButtons.Push.Text);
                _pushButton.Click += thumbButtons.Push.Click;

                _pullButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Pull.Image, 48, true), thumbButtons.Pull.Text);
                _pullButton.Click += thumbButtons.Pull.Click;

                // Call this method using reflection.  This is a workaround to *not* reference WPF libraries, becuase of how the WindowsAPICodePack was implimented.
                TaskbarManager.Instance.ThumbnailToolBars.AddButtons(handle, _commitButton, _pullButton, _pushButton);
            }
        }
Exemplo n.º 5
0
        private void CreateTaskbarButtons(IntPtr handle, WindowsThumbnailToolbarButtons thumbButtons)
        {
            if (!_toolbarButtonsCreated)
            {
                _commitButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Commit.Image, 48, true), thumbButtons.Commit.Text);
                _commitButton.Click += thumbButtons.Commit.Click;

                _pushButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Push.Image, 48, true), thumbButtons.Push.Text);
                _pushButton.Click += thumbButtons.Push.Click;

                _pullButton        = new ThumbnailToolBarButton(MakeIcon(thumbButtons.Pull.Image, 48, true), thumbButtons.Pull.Text);
                _pullButton.Click += thumbButtons.Pull.Click;

                _toolbarButtonsCreated = true;

                // Call this method using reflection.  This is a workaround to *not* reference WPF libraries, becuase of how the WindowsAPICodePack was implimented.
                TaskbarManager.Instance.ThumbnailToolBars.AddButtons(handle, _commitButton, _pullButton, _pushButton);
                TaskbarManager.Instance.ApplicationId = "GitExtensions";
            }

            _commitButton.Enabled = true;
            _pushButton.Enabled   = true;
            _pullButton.Enabled   = true;
        }