LEADTOOLS Windows Forms (Leadtools.WinForms assembly)
LEAD Technologies, Inc

RasterMagnifyGlass Class

Example 





Members 
Represents a Leadtools MagnifyGlass control for "zooming in" a portion of an image.
Object Model
RasterMagnifyGlass ClassRasterImageViewer Class
Syntax
public class RasterMagnifyGlass 
'Declaration
 
Public Class RasterMagnifyGlass 
'Usage
 
Dim instance As RasterMagnifyGlass
public sealed class RasterMagnifyGlass 
function Leadtools.WinForms.RasterMagnifyGlass()
public ref class RasterMagnifyGlass 
Remarks
The RasterMagnifyGlass is used to "zoom in" a portion of an image displayed in RasterImageViewer control. When a user clicks inside the RasterImageViewer control associated with the RasterMagnifyGlass control, the portion of the image around the mouse cursor will be zoomed in. When a user clicks inside the RasterImageViewer control and moves the mouse, while holding down the button, the zoomed in portion will change according to the mouse pointer position on the bitmap.
Example
 
Private Sub magnifyGlass_CrosshairChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("Crosshair Changed to " & magnifyGlass.Crosshair.ToString())
End Sub
Private Sub magnifyGlass_CrosshairColorChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("CrosshairColor Changed to " & magnifyGlass.CrosshairColor.ToString())
End Sub

Private Sub magnifyGlass_CrosshairWidthChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("CrosshairWidth Changed to " & magnifyGlass.CrosshairWidth.ToString())
End Sub

Private Sub magnifyGlass_Border3DStyleChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("Border3DStyle Changed to " & magnifyGlass.Border3DStyle.ToString())
End Sub

Private Sub magnifyGlass_BorderColorChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("BorderColor Changed to " & magnifyGlass.BorderColor.ToString())
End Sub

Private Sub magnifyGlass_BorderWidthChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("BorderWidth Changed to " & magnifyGlass.BorderWidth.ToString())
End Sub

Private Sub magnifyGlass_ShapeChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("Shape Changed to " & magnifyGlass.Shape.ToString())
End Sub

Private Sub magnifyGlass_SizeChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("Size Changed to " & magnifyGlass.Size.ToString())
End Sub

Private Sub magnifyGlass_ScaleFactorChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("Scale Factor Changed to " & magnifyGlass.ScaleFactor.ToString())
End Sub

Private Sub magnifyGlass_RoundRectangleEllipseSizeChanged(ByVal sender As Object, ByVal e As EventArgs)
   Dim magnifyGlass As RasterMagnifyGlass = CType(IIf(TypeOf sender Is RasterMagnifyGlass, sender, Nothing), RasterMagnifyGlass)
   Console.WriteLine("RoundRectangleEllipseSize Changed to " & magnifyGlass.RoundRectangleEllipseSize.ToString())
End Sub

Public Sub RasterMagnifyGlass_Border3DStyle(ByVal viewer As RasterImageViewer)
   viewer.InteractiveMode = RasterViewerInteractiveMode.MagnifyGlass
   AddHandler viewer.MagnifyGlass.CrosshairChanged, AddressOf magnifyGlass_CrosshairChanged
   AddHandler viewer.MagnifyGlass.CrosshairColorChanged, AddressOf magnifyGlass_CrosshairColorChanged
   AddHandler viewer.MagnifyGlass.CrosshairWidthChanged, AddressOf magnifyGlass_CrosshairWidthChanged
   AddHandler viewer.MagnifyGlass.Border3DStyleChanged, AddressOf magnifyGlass_Border3DStyleChanged
   AddHandler viewer.MagnifyGlass.BorderColorChanged, AddressOf magnifyGlass_BorderColorChanged
   AddHandler viewer.MagnifyGlass.BorderWidthChanged, AddressOf magnifyGlass_BorderWidthChanged
   AddHandler viewer.MagnifyGlass.ShapeChanged, AddressOf magnifyGlass_ShapeChanged
   AddHandler viewer.MagnifyGlass.SizeChanged, AddressOf magnifyGlass_SizeChanged
   AddHandler viewer.MagnifyGlass.ScaleFactorChanged, AddressOf magnifyGlass_ScaleFactorChanged
   AddHandler viewer.MagnifyGlass.RoundRectangleEllipseSizeChanged, AddressOf magnifyGlass_RoundRectangleEllipseSizeChanged

   If viewer.MagnifyGlass.Shape <> RasterMagnifyGlassShape.Border3D Then
      ' Set the crosshair style
      viewer.MagnifyGlass.Shape = RasterMagnifyGlassShape.Border3D
      viewer.MagnifyGlass.Border3DStyle = Border3DStyle.Sunken

      ' Now change to a different shape
      viewer.MagnifyGlass.Shape = RasterMagnifyGlassShape.RoundRectangle
      viewer.MagnifyGlass.RoundRectangleEllipseSize = New Size(15, 15)
      viewer.MagnifyGlass.BorderColor = Color.DarkBlue
      viewer.MagnifyGlass.BorderWidth = 10
      viewer.MagnifyGlass.Crosshair = RasterMagnifyGlassCrosshair.Fine
      viewer.MagnifyGlass.CrosshairColor = Color.Red
      viewer.MagnifyGlass.CrosshairWidth = 5
      viewer.MagnifyGlass.Size = New Size(200, 100)
      viewer.MagnifyGlass.ScaleFactor = 1.5F
   End If

   RemoveHandler viewer.MagnifyGlass.CrosshairChanged, AddressOf magnifyGlass_CrosshairChanged
   RemoveHandler viewer.MagnifyGlass.CrosshairColorChanged, AddressOf magnifyGlass_CrosshairColorChanged
   RemoveHandler viewer.MagnifyGlass.CrosshairWidthChanged, AddressOf magnifyGlass_CrosshairWidthChanged
   RemoveHandler viewer.MagnifyGlass.Border3DStyleChanged, AddressOf magnifyGlass_Border3DStyleChanged
   RemoveHandler viewer.MagnifyGlass.BorderColorChanged, AddressOf magnifyGlass_BorderColorChanged
   RemoveHandler viewer.MagnifyGlass.BorderWidthChanged, AddressOf magnifyGlass_BorderWidthChanged
   RemoveHandler viewer.MagnifyGlass.ShapeChanged, AddressOf magnifyGlass_ShapeChanged
   RemoveHandler viewer.MagnifyGlass.SizeChanged, AddressOf magnifyGlass_SizeChanged
   RemoveHandler viewer.MagnifyGlass.ScaleFactorChanged, AddressOf magnifyGlass_ScaleFactorChanged
   RemoveHandler viewer.MagnifyGlass.RoundRectangleEllipseSizeChanged, AddressOf magnifyGlass_RoundRectangleEllipseSizeChanged

End Sub
private void magnifyGlass_CrosshairChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("Crosshair Changed to " + magnifyGlass.Crosshair.ToString());
}
private void magnifyGlass_CrosshairColorChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("CrosshairColor Changed to " + magnifyGlass.CrosshairColor.ToString());
}

private void magnifyGlass_CrosshairWidthChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("CrosshairWidth Changed to " + magnifyGlass.CrosshairWidth.ToString());
}

private void magnifyGlass_Border3DStyleChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("Border3DStyle Changed to " + magnifyGlass.Border3DStyle.ToString());
}

private void magnifyGlass_BorderColorChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("BorderColor Changed to " + magnifyGlass.BorderColor.ToString());
}

private void magnifyGlass_BorderWidthChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("BorderWidth Changed to " + magnifyGlass.BorderWidth.ToString());
}

private void magnifyGlass_ShapeChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("Shape Changed to " + magnifyGlass.Shape.ToString());
}

private void magnifyGlass_SizeChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("Size Changed to " + magnifyGlass.Size.ToString());
}

private void magnifyGlass_ScaleFactorChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("Scale Factor Changed to " + magnifyGlass.ScaleFactor.ToString());
}

private void magnifyGlass_RoundRectangleEllipseSizeChanged(object sender, EventArgs e)
{
   RasterMagnifyGlass magnifyGlass = sender as RasterMagnifyGlass;
   Console.WriteLine("RoundRectangleEllipseSize Changed to " + magnifyGlass.RoundRectangleEllipseSize.ToString());
}

public void RasterMagnifyGlass_Border3DStyle(RasterImageViewer viewer)
{
   viewer.InteractiveMode = RasterViewerInteractiveMode.MagnifyGlass;
   viewer.MagnifyGlass.CrosshairChanged += new EventHandler(magnifyGlass_CrosshairChanged);
   viewer.MagnifyGlass.CrosshairColorChanged += new EventHandler(magnifyGlass_CrosshairColorChanged);
   viewer.MagnifyGlass.CrosshairWidthChanged += new EventHandler(magnifyGlass_CrosshairWidthChanged);
   viewer.MagnifyGlass.Border3DStyleChanged += new EventHandler(magnifyGlass_Border3DStyleChanged);
   viewer.MagnifyGlass.BorderColorChanged += new EventHandler(magnifyGlass_BorderColorChanged);
   viewer.MagnifyGlass.BorderWidthChanged += new EventHandler(magnifyGlass_BorderWidthChanged);
   viewer.MagnifyGlass.ShapeChanged += new EventHandler(magnifyGlass_ShapeChanged);
   viewer.MagnifyGlass.SizeChanged += new EventHandler(magnifyGlass_SizeChanged);
   viewer.MagnifyGlass.ScaleFactorChanged += new EventHandler(magnifyGlass_ScaleFactorChanged);
   viewer.MagnifyGlass.RoundRectangleEllipseSizeChanged += new EventHandler(magnifyGlass_RoundRectangleEllipseSizeChanged);

   if (viewer.MagnifyGlass.Shape != RasterMagnifyGlassShape.Border3D)
   {
      // Set the crosshair style
      viewer.MagnifyGlass.Shape = RasterMagnifyGlassShape.Border3D;
      viewer.MagnifyGlass.Border3DStyle = Border3DStyle.Sunken;

      // Now change to a different shape
      viewer.MagnifyGlass.Shape = RasterMagnifyGlassShape.RoundRectangle;
      viewer.MagnifyGlass.RoundRectangleEllipseSize = new Size(15, 15);
      viewer.MagnifyGlass.BorderColor = Color.DarkBlue;
      viewer.MagnifyGlass.BorderWidth = 10;
      viewer.MagnifyGlass.Crosshair = RasterMagnifyGlassCrosshair.Fine;
      viewer.MagnifyGlass.CrosshairColor = Color.Red;
      viewer.MagnifyGlass.CrosshairWidth = 5;
      viewer.MagnifyGlass.Size = new Size(200, 100);
      viewer.MagnifyGlass.ScaleFactor = 1.5f;
   }

   viewer.MagnifyGlass.CrosshairChanged -= new EventHandler(magnifyGlass_CrosshairChanged);
   viewer.MagnifyGlass.CrosshairColorChanged -= new EventHandler(magnifyGlass_CrosshairColorChanged);
   viewer.MagnifyGlass.CrosshairWidthChanged -= new EventHandler(magnifyGlass_CrosshairWidthChanged);
   viewer.MagnifyGlass.Border3DStyleChanged -= new EventHandler(magnifyGlass_Border3DStyleChanged);
   viewer.MagnifyGlass.BorderColorChanged -= new EventHandler(magnifyGlass_BorderColorChanged);
   viewer.MagnifyGlass.BorderWidthChanged -= new EventHandler(magnifyGlass_BorderWidthChanged);
   viewer.MagnifyGlass.ShapeChanged -= new EventHandler(magnifyGlass_ShapeChanged);
   viewer.MagnifyGlass.SizeChanged -= new EventHandler(magnifyGlass_SizeChanged);
   viewer.MagnifyGlass.ScaleFactorChanged -= new EventHandler(magnifyGlass_ScaleFactorChanged);
   viewer.MagnifyGlass.RoundRectangleEllipseSizeChanged -= new EventHandler(magnifyGlass_RoundRectangleEllipseSizeChanged);

}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterMagnifyGlass Members
Leadtools.WinForms Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.