Beispiel #1
0
 private void btnTogglePreview_Click(object sender, EventArgs args)
 {
     if (_customWindowManager != null)
     {
         _customWindowManager.DisablePreview();
         _customWindowManager = null;
     }
     else
     {
         _customWindowManager = CustomWindowsManager.CreateWindowsManager(Handle);
         _customWindowManager.PeekRequested      += (o, e) => e.UseWindowScreenshot = true;
         _customWindowManager.ThumbnailRequested += (o, e) =>
         {
             int    index      = rtbText.GetFirstCharIndexOfCurrentLine();
             string textAround = rtbText.Text.Substring(index,
                                                        Math.Min(rtbText.Text.Length - index, 200));
             Bitmap bitmap = new Bitmap(e.Width, e.Height);
             using (Graphics g = Graphics.FromImage(bitmap))
             {
                 g.DrawString(textAround,
                              new Font(new FontFamily("Calibri"), 9, FontStyle.Italic),
                              new SolidBrush(Color.Blue), 0, 0);
             }
             e.Bitmap = bitmap;
         };
     }
 }
Beispiel #2
0
        protected override void OnShown(EventArgs args)
        {
            Location = _location;

            _windowsManager = CustomWindowsManager.CreateWindowsManager(
                Handle, MdiParent.Handle);
            _windowsManager.PeekRequested += (o, e) =>
            {
                e.UseWindowScreenshot = true;
            };
            _windowsManager.ThumbnailRequested += (o, e) =>
            {
                Bitmap bmp = new Bitmap(e.Width, e.Height);
                for (int i = 0; i < e.Width; ++i)
                {
                    for (int j = 0; j < e.Height; ++j)
                    {
                        bmp.SetPixel(i, j, Color.Red);
                    }
                }
                e.Bitmap = bmp;
            };

            base.OnShown(args);
        }
        private void button1_Click(object sender, EventArgs args)
        {
            _tabBitmaps.Add(null);

            TabPage newTab = new TabPage("Tab " + _lastTab);

            tabControl1.TabPages.Add(newTab);
            tabControl1.SelectedTab = newTab;

            int copy = _lastTab;

            System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser();
            wb.Dock = DockStyle.Fill;
            wb.DocumentCompleted += delegate
            {
                Bitmap bmp = ScreenCapture.GrabWindowBitmap(newTab.Handle, newTab.Size);
                _tabBitmaps[copy] = bmp;
            };
            wb.Navigate(textBox1.Text);
            textBox1.Text = "www.yahoo.com";
            newTab.Controls.Add(wb);

            //TODO: UseWindowScreenshot=true doesn't work
            //because the tabs are obstructing one another.

            CustomWindowsManager cwm = CustomWindowsManager.CreateWindowsManager(newTab.Handle, Handle);

            cwm.PeekRequested += (o, e) =>
            {
                e.Bitmap            = new Bitmap(_tabBitmaps[copy], e.Width, e.Height);
                e.DoNotMirrorBitmap = true;
            };
            cwm.ThumbnailRequested += (o, e) =>
            {
                e.Bitmap            = new Bitmap(_tabBitmaps[copy], e.Width, e.Height);
                e.DoNotMirrorBitmap = true;
            };
            _windowManagers.Add(cwm);

            _windowManagers.ForEach(wm => wm.InvalidatePreviews());

            ++_lastTab;
        }
Beispiel #4
0
        private void btnTogglePreview_Click(object sender, EventArgs args)
        {
            if (!_customPreviewEnabled)
            {
                _windowsManager = CustomWindowsManager.CreateWindowsManager(Handle, IntPtr.Zero);
                _windowsManager.PeekRequested += (o, e) =>
                {
                    //TODO: This doesn't actually work when
                    //the window is minimized...
                    e.UseWindowScreenshot = true;
                };
                _windowsManager.ThumbnailRequested += (o, e) =>
                {
                    e.UseWindowScreenshot = true;
                };
            }
            else
            {
                this.DisableCustomWindowPreview();
            }

            _customPreviewEnabled = !_customPreviewEnabled;
        }
Beispiel #5
0
        private void btnTogglePreview_Click(object sender, EventArgs args)
        {
            _clipToggled = false;

            _windowsManager = CustomWindowsManager.CreateWindowsManager(Handle, IntPtr.Zero);
            _windowsManager.PeekRequested += (o, e) =>
            {
                e.UseWindowScreenshot = true;
            };
            _windowsManager.ThumbnailRequested += (o, e) =>
            {
                Bitmap bmp = new Bitmap(e.Width, e.Height);
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    int index = rtbText.GetFirstCharIndexOfCurrentLine();

                    g.DrawString(rtbText.Text.Substring(index, Math.Min(150, rtbText.Text.Length - index)),
                                 new Font("Tahoma", 9),
                                 new SolidBrush(Color.Black),
                                 new RectangleF(0, 0, e.Width, e.Height));
                }
                e.Bitmap = bmp;
            };
        }