Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new thumbnail for <paramref name="tab" /> when the application is initially enabled for AeroPeek or when it is turned on sometime during
        /// execution.
        /// </summary>
        /// <param name="tab">Tab that we are to create the thumbnail for.</param>
        /// <returns>Thumbnail created for <paramref name="tab" />.</returns>
        protected virtual TabbedThumbnail CreateThumbnailPreview(TitleBarTab tab)
        {
            TabbedThumbnail preview = TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(tab.Content);

            if (preview != null)
            {
                TaskbarManager.Instance.TabbedThumbnail.RemoveThumbnailPreview(tab.Content);
            }

            preview = new TabbedThumbnail(Handle, tab.Content)
            {
                Title   = tab.Content.Text,
                Tooltip = tab.Content.Text
            };

            preview.SetWindowIcon((Icon)tab.Content.Icon.Clone());

            preview.TabbedThumbnailActivated       += preview_TabbedThumbnailActivated;
            preview.TabbedThumbnailClosed          += preview_TabbedThumbnailClosed;
            preview.TabbedThumbnailBitmapRequested += preview_TabbedThumbnailBitmapRequested;
            preview.PeekOffset = new Vector(Padding.Left, Padding.Top - 1);

            TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview);

            return(preview);
        }
Ejemplo n.º 2
0
        private void TabItem_Loaded(object sender, RoutedEventArgs e)
        {
            var tabItem = sender as TabItem;

            if (TaskbarManager.IsPlatformSupported)
            {
                var data = (WorkspaceViewModel)((TabItem)sender).DataContext;
                tabItem.Loaded -= TabItem_Loaded;

                var point = tabItem.TranslatePoint(new System.Windows.Point(), this);

                var preview = new TabbedThumbnail(this, tabItem, new Vector(0, point.Y))
                {
                    Title = data.Header
                };
                if (data is QDocument doc && doc.Document != null)
                {
                    preview.Tooltip = doc.Document.Package.Name;
                }

                preview.TabbedThumbnailMinimized       += Preview_TabbedThumbnailMinimized;
                preview.TabbedThumbnailMaximized       += Preview_TabbedThumbnailMaximized;
                preview.TabbedThumbnailActivated       += Preview_TabbedThumbnailActivated;
                preview.TabbedThumbnailClosed          += Preview_TabbedThumbnailClosed;
                preview.TabbedThumbnailBitmapRequested += Preview_TabbedThumbnailBitmapRequested;

                preview.SetWindowIcon(Properties.Resources.Icon.GetHicon());

                TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview);
            }

            tabControl1.SelectedItem = tabItem;
        }
Ejemplo n.º 3
0
        private async void LoadJumplist()
        {
            await System.Threading.Tasks.Task.Delay(5000);

            JumpList jl = JumpList.CreateJumpList();
            JumpListCustomCategory jlc = new JumpListCustomCategory("µVoice Alpha (Private Build)");

            JumpListLink[] jli = new JumpListLink[] { new JumpListLink("report", "Reportar Un Problema"), new JumpListLink("reports", "Decirle a bit que es mierda."), new JumpListLink("update", "Buscar Actualizaciones") };
            jlc.AddJumpListItems(jli);
            jl.AddCustomCategories(jlc);
            jl.Refresh();
            TaskbarManager.Instance.TabbedThumbnail.SetThumbnailClip(new WindowInteropHelper(this).Handle, new System.Drawing.Rectangle(10, 64, Convert.ToInt32(mainpiano.ActualWidth), Convert.ToInt32(mainpiano.ActualHeight)));
            TabbedThumbnail preview = new TabbedThumbnail(this, mainpiano, new System.Windows.Vector(10000, 10000));

            preview.SetWindowIcon(Properties.Resources.icon);
            preview.Title = this.Title;
            try
            {
                TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview);
            }
            catch { }
            RenderTargetBitmap rtb = new RenderTargetBitmap((int)play.ActualWidth, (int)play.ActualHeight, 96, 96, PixelFormats.Pbgra32);

            rtb.Render(play);
            MemoryStream  stream  = new MemoryStream();
            BitmapEncoder encoder = new BmpBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(rtb));
            encoder.Save(stream);
            System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(stream);
            TaskbarManager.Instance.ThumbnailToolBars.AddButtons(mainpiano, new ThumbnailToolBarButton[] { new ThumbnailToolBarButton(System.Drawing.Icon.FromHandle(bmp.GetHicon()), "Play") });
        }
Ejemplo n.º 4
0
        private static void SetThumbnailTitleAndIcon(UIElement content, IControlView activeView)
        {
            if (!_initialized)
            {
                throw new Exception("Not initialized");
            }
            TabbedThumbnail thumbnail = TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(content);

            if (thumbnail != null && activeView != null)
            {
                if (thumbnail.Title != activeView.Header)  //Title is not set yet or sth has changed
                {
                    thumbnail.Title   = activeView.Header;
                    thumbnail.Tooltip = activeView.HeaderToolTip;
                    var streamResourceInfo = Application.GetResourceStream(activeView.HeaderIcon);
                    if (streamResourceInfo != null)
                    {
                        Stream iconStream = streamResourceInfo.Stream;
                        var    bitmap     = new Bitmap(iconStream);
                        var    iconHandle = bitmap.GetHicon();
                        var    icon       = Icon.FromHandle(iconHandle);
                        thumbnail.SetWindowIcon(icon);
                    }
                    RefreshPreview((Frame)content);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// When a child tab updates its <see cref="Form.Icon"/> property, it should call this method to update the icon in the AeroPeek preview.
        /// </summary>
        /// <param name="tab">Tab whose icon was updated.</param>
        /// <param name="icon">The new icon to use.  If this is left as null, we use <see cref="Form.Icon"/> on <paramref name="tab"/>.</param>
        public virtual void UpdateThumbnailPreviewIcon(TitleBarTab tab, Icon icon = null)
        {
            if (!AeroPeekEnabled)
            {
                return;
            }

            TabbedThumbnail preview = TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(tab.Content);

            if (preview == null)
            {
                return;
            }

            if (icon == null)
            {
                icon = tab.Content.Icon;
            }

            preview.SetWindowIcon((Icon)icon.Clone());
        }
Ejemplo n.º 6
0
        internal void SetupThumbAndButtons()
        {
            _thumbForm = new ThumbForm(this);

            _thumb       = new TabbedThumbnail(this.Handle, _thumbForm);
            _thumb.Title = _gmailClient.Username;
            _thumb.SetWindowIcon((Icon)this.Icon.Clone());

            _thumb.TabbedThumbnailClosed += (sender, e) =>
            {
                //ideally what i would like to here is cancel the close event
                //unfortunately it appears there is a bug in the WindowsAPICodePack which is not receiving any attention from Microsoft
                //the next best alternative is just to close the entire application, otherwise it will crash next time we try to update the thumbnail preview
                Close();
            };

            _thumbForm.Show();
            _thumbForm.Render();

            _prevButton = new ThumbnailToolBarButton(Properties.Resources.Previous, "Previous")
            {
                Enabled = false
            };
            _openButton = new ThumbnailToolBarButton(Properties.Resources.Open, "Open")
            {
                Enabled = false
            };
            _nextButton = new ThumbnailToolBarButton(Properties.Resources.Next, "Next")
            {
                Enabled = false
            };

            _prevButton.Click += new EventHandler <ThumbnailButtonClickedEventArgs>(PrevButtonClicked);
            _openButton.Click += new EventHandler <ThumbnailButtonClickedEventArgs>(OpenButtonClicked);
            _nextButton.Click += new EventHandler <ThumbnailButtonClickedEventArgs>(NextButtonClicked);

            TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(_thumb);

            TaskbarManager.Instance.ThumbnailToolBars.AddButtons(_thumbForm.Handle, _prevButton, _openButton, _nextButton);
        }
Ejemplo n.º 7
0
        private void CreateInstances()
        {
            for (int i = 0; i < _config.Accounts.Count; i++)
            {
                Account account = _config.Accounts[i];

                if (_instances.ContainsKey(account.FullAddress))
                {
                    continue;
                }

                Notifier notifier = new Notifier(i);
                notifier.FormClosed        += _Notifier_FormClosed;
                notifier.CheckMailFinished += _Notifier_CheckFinished;

                _instances.Add(account.FullAddress, notifier);

                notifier.Show(this);

                TabbedThumbnail preview = new TabbedThumbnail(base.Handle, notifier.Handle);
                preview.TabbedThumbnailClosed += _Preview_TabbedThumbnailClosed;
                preview.SetWindowIcon(Utilities.ResourceHelper.GetIcon("gmail-classic.ico"));
                preview.Tooltip = String.Empty;
                preview.Title   = account.FullAddress;

                notifier.PreviewThumbnail = preview;

                _taskbarManager.TabbedThumbnail.AddThumbnailPreview(preview);
            }

            if (_config.Accounts.Count > 0)
            {
                Account account = _config.Accounts[0];
                _taskbarManager.TabbedThumbnail.SetActiveTab(_instances[account.FullAddress].Handle);
            }
        }