Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.4.3
|
Leadtools.Controls Assembly > Leadtools.Controls Namespace > ImageViewerSpyGlassInteractiveMode Class : RedirectControl Property |
ImageViewerSpyGlassInteractiveMode supports redirecting the render output to an external control instead of the area under the mouse in the viewer. When this value is set to a valid control on the form, the interactive mode will subscribe to the control Paint event and will render the magnifying glass content to the surface of this control. Any Windows Forms will work: however, a custom user control or a PictureBox control is the most efficient since it supports double buffering.
Imports Leadtools Imports Leadtools.Controls Imports Leadtools.Codecs Imports Leadtools.Drawing Imports Leadtools.ImageProcessing Imports Leadtools.ImageProcessing.Color Dim panel As Panel = New Panel() panel.Width = 300 panel.Dock = DockStyle.Right _control.Controls.Add(panel) panel.BringToFront() Dim label As Label = New Label() label.Text = "Double click to switch between viewer and here" label.AutoSize = True label.Dock = DockStyle.Top panel.Controls.Add(label) ' Any control will do, but a PictureBox is perfect since it does double buffering Dim redirectControl As PictureBox = New PictureBox() redirectControl.Dock = DockStyle.Fill redirectControl.BackColor = Color.Gray panel.Controls.Add(redirectControl) redirectControl.BringToFront() redirectControl.Visible = False _imageViewer.BringToFront() Dim mode As ImageViewerMagnifyGlassInteractiveMode = New ImageViewerMagnifyGlassInteractiveMode() AddHandler mode.WorkStarted, Sub(sender, e) If Not mode.RedirectControl Is Nothing Then mode.RedirectControl.Visible = True End If End Sub AddHandler mode.WorkCompleted, Sub(sender, e) If Not mode.RedirectControl Is Nothing Then mode.RedirectControl.Visible = False End If End Sub mode.RedirectControl = redirectControl AddHandler panel.MouseDoubleClick, Sub(sender, e) If mode.RedirectControl Is Nothing Then mode.RedirectControl = redirectControl Else mode.RedirectControl = Nothing End If End Sub _imageViewer.InteractiveModes.BeginUpdate() _imageViewer.InteractiveModes.Add(mode) _imageViewer.InteractiveModes.EndUpdate() For Each shape As ImageViewerSpyGlassShape In System.Enum.GetValues(GetType(ImageViewerSpyGlassShape)) _shapeComboBox.Items.Add(shape) Next shape _shapeComboBox.SelectedItem = mode.Shape AddHandler _shapeComboBox.SelectedIndexChanged, Sub(sender, e) mode.Shape = CType(_shapeComboBox.SelectedItem, ImageViewerSpyGlassShape)
using Leadtools; using Leadtools.Controls; using Leadtools.Codecs; using Leadtools.Drawing; using Leadtools.ImageProcessing; using Leadtools.ImageProcessing.Color; Panel panel = new Panel(); panel.Width = 300; panel.Dock = DockStyle.Right; _control.Controls.Add(panel); panel.BringToFront(); Label label = new Label(); label.Text = "Double click to switch between viewer and here"; label.AutoSize = true; label.Dock = DockStyle.Top; panel.Controls.Add(label); // Any control will do, but a PictureBox is perfect since it does double buffering PictureBox redirectControl = new PictureBox(); redirectControl.Dock = DockStyle.Fill; redirectControl.BackColor = Color.Gray; panel.Controls.Add(redirectControl); redirectControl.BringToFront(); redirectControl.Visible = false; _imageViewer.BringToFront(); ImageViewerMagnifyGlassInteractiveMode mode = new ImageViewerMagnifyGlassInteractiveMode(); mode.WorkStarted += (sender, e) => { if (mode.RedirectControl != null) mode.RedirectControl.Visible = true; }; mode.WorkCompleted += (sender, e) => { if (mode.RedirectControl != null) mode.RedirectControl.Visible = false; }; mode.RedirectControl = redirectControl; panel.MouseDoubleClick += (sender, e) => { if (mode.RedirectControl == null) mode.RedirectControl = redirectControl; else mode.RedirectControl = null; }; _imageViewer.InteractiveModes.BeginUpdate(); _imageViewer.InteractiveModes.Add(mode); _imageViewer.InteractiveModes.EndUpdate(); foreach (var shape in Enum.GetValues(typeof(ImageViewerSpyGlassShape))) _shapeComboBox.Items.Add(shape); _shapeComboBox.SelectedItem = mode.Shape; _shapeComboBox.SelectedIndexChanged += (sender, e) => mode.Shape = (ImageViewerSpyGlassShape)_shapeComboBox.SelectedItem;