←Select platform

RedirectControl Property

Summary

External control that can be used to re-direct the spy glass render.

Syntax

C#
VB
C++
public Control RedirectControl { get; set; } 
Public Property RedirectControl() As System.Windows.Forms.Control 
   Get 
   Set 
public:  
   property System::Windows::Forms::Control^ RedirectControl 
   { 
      System::Windows::Forms::Control^ get() 
      void set(System::Windows::Forms::Control^ value) 
   } 

Property Value

The external control that can be used to re-direct the spy glass render. Default value is null.

Remarks

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 System.Windows.Forms.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 System.Windows.Forms.PictureBox control is the most efficient since it supports double buffering.

Example

C#
VB
using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using LeadtoolsExamples.Common; 
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; 
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) 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Controls.WinForms Assembly