Leadtools.Windows.Controls Send comments on this topic. | Back to Introduction - LEADTOOLS WPF | Help Version 16.5.9.25
Shape Property
See Also  Example
Leadtools.Windows.Controls Namespace > MagnifyGlass Class : Shape Property





Gets or sets the Shape of the Magnifying Glass. This is a dependency property.

Syntax

Visual Basic (Declaration) 
Public Property Shape As MagnifyGlassShape
Visual Basic (Usage)Copy Code
Dim instance As MagnifyGlass
Dim value As MagnifyGlassShape
 
instance.Shape = value
 
value = instance.Shape
C# 
public MagnifyGlassShape Shape {get; set;}
C++/CLI 
public:
property MagnifyGlassShape Shape {
   MagnifyGlassShape get();
   void set (MagnifyGlassShape value);
}
XAML Attributes Usage 

<object Shape=Leadtools.Windows.Controls.MagnifyGlassShape .../>

Dependencies Property Information 

Identifier field

ShapeProperty

Metadata properties set to true

AffectsRender

XAML Attributes Usage 

<object Shape=Leadtools.Windows.Controls.MagnifyGlassShape .../>

Dependencies Property Information 

Identifier field

ShapeProperty

Metadata properties set to true

AffectsRender

Return Value

The shape of the Magnifying Glass.

Example

This example changes various properties of the magnifying glass.

Visual BasicCopy Code
Private Sub magnifyGlass_CrosshairChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of MagnifyGlassCrosshair))
   Dim magnifyGlass As MagnifyGlass = CType(IIf(TypeOf sender Is MagnifyGlass, sender, Nothing), MagnifyGlass)
   Console.WriteLine("Crosshair Changed to " & magnifyGlass.Crosshair.ToString())
End Sub
Private Sub magnifyGlass_CrosshairBrushChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Brush))
   Dim magnifyGlass As MagnifyGlass = CType(IIf(TypeOf sender Is MagnifyGlass, sender, Nothing), MagnifyGlass)
   Console.WriteLine("CrosshairBrush Changed to " & magnifyGlass.CrosshairBrush.ToString())
End Sub

Private Sub magnifyGlass_CrosshairThicknessChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Double))
   Dim magnifyGlass As MagnifyGlass = CType(IIf(TypeOf sender Is MagnifyGlass, sender, Nothing), MagnifyGlass)
   Console.WriteLine("CrosshairThickness Changed to " & magnifyGlass.CrosshairThickness.ToString())
End Sub

Private Sub magnifyGlass_BorderBrushChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Brush))
   Dim magnifyGlass As MagnifyGlass = CType(IIf(TypeOf sender Is MagnifyGlass, sender, Nothing), MagnifyGlass)
   Console.WriteLine("BorderBrush Changed to " & magnifyGlass.BorderBrush.ToString())
End Sub

Private Sub magnifyGlass_BorderThicknessChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Double))
   Dim magnifyGlass As MagnifyGlass = CType(IIf(TypeOf sender Is MagnifyGlass, sender, Nothing), MagnifyGlass)
   Console.WriteLine("BorderThickness Changed to " & magnifyGlass.BorderThickness.ToString())
End Sub

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

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

Private Sub magnifyGlass_RoundRectangleRadiusChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Size))
   Dim magnifyGlass As MagnifyGlass = CType(IIf(TypeOf sender Is MagnifyGlass, sender, Nothing), MagnifyGlass)
   Console.WriteLine("RoundRectangleRadius Changed to " & magnifyGlass.RoundRectangleRadius.ToString())
End Sub

Private Sub magnifyGlass_BackgroundChanged(ByVal sender As Object, ByVal e As RoutedPropertyChangedEventArgs(Of Brush))
   Dim magnifyGlass As MagnifyGlass = CType(IIf(TypeOf sender Is MagnifyGlass, sender, Nothing), MagnifyGlass)
   Console.WriteLine("Background Changed to " & magnifyGlass.Background.ToString())
End Sub

Public Sub MagnifyGlass_Shape(ByVal viewer As BitmapSourceViewer)
   viewer.InteractiveMode = BitmapSourceViewerInteractiveMode.MagnifyGlass
   AddHandler viewer.MagnifyGlass.CrosshairChanged, AddressOf magnifyGlass_CrosshairChanged
   AddHandler viewer.MagnifyGlass.CrosshairBrushChanged, AddressOf magnifyGlass_CrosshairBrushChanged
   AddHandler viewer.MagnifyGlass.CrosshairThicknessChanged, AddressOf magnifyGlass_CrosshairThicknessChanged
   AddHandler viewer.MagnifyGlass.BorderBrushChanged, AddressOf magnifyGlass_BorderBrushChanged
   AddHandler viewer.MagnifyGlass.BorderThicknessChanged, AddressOf magnifyGlass_BorderThicknessChanged
   AddHandler viewer.MagnifyGlass.ShapeChanged, AddressOf magnifyGlass_ShapeChanged
   AddHandler viewer.MagnifyGlass.ScaleFactorChanged, AddressOf magnifyGlass_ScaleFactorChanged
   AddHandler viewer.MagnifyGlass.RoundRectangleRadiusChanged, AddressOf magnifyGlass_RoundRectangleRadiusChanged
   AddHandler viewer.MagnifyGlass.BackgroundChanged, AddressOf magnifyGlass_BackgroundChanged

   If viewer.MagnifyGlass.Shape <> MagnifyGlassShape.Border3D Then
      ' Set the crosshair style
      viewer.MagnifyGlass.Shape = MagnifyGlassShape.Border3D

      ' Now change to a different shape
      viewer.MagnifyGlass.Shape = MagnifyGlassShape.RoundRectangle
      viewer.MagnifyGlass.RoundRectangleRadius = New Size(15, 15)
      viewer.MagnifyGlass.BorderBrush = Brushes.DarkBlue
      viewer.MagnifyGlass.BorderThickness = 10
      viewer.MagnifyGlass.Crosshair = MagnifyGlassCrosshair.Fine
      viewer.MagnifyGlass.CrosshairBrush = Brushes.Red
      viewer.MagnifyGlass.CrosshairThickness = 5
      viewer.MagnifyGlass.Width = 200
      viewer.MagnifyGlass.Height = 100
      viewer.MagnifyGlass.Background = Brushes.DarkGreen

      viewer.MagnifyGlass.ScaleFactor = 1.5
   End If

   RemoveHandler viewer.MagnifyGlass.CrosshairChanged, AddressOf magnifyGlass_CrosshairChanged
   RemoveHandler viewer.MagnifyGlass.CrosshairBrushChanged, AddressOf magnifyGlass_CrosshairBrushChanged
   RemoveHandler viewer.MagnifyGlass.CrosshairThicknessChanged, AddressOf magnifyGlass_CrosshairThicknessChanged
   RemoveHandler viewer.MagnifyGlass.BorderBrushChanged, AddressOf magnifyGlass_BorderBrushChanged
   RemoveHandler viewer.MagnifyGlass.BorderThicknessChanged, AddressOf magnifyGlass_BorderThicknessChanged
   RemoveHandler viewer.MagnifyGlass.ShapeChanged, AddressOf magnifyGlass_ShapeChanged
   RemoveHandler viewer.MagnifyGlass.ScaleFactorChanged, AddressOf magnifyGlass_ScaleFactorChanged
   RemoveHandler viewer.MagnifyGlass.RoundRectangleRadiusChanged, AddressOf magnifyGlass_RoundRectangleRadiusChanged
   RemoveHandler viewer.MagnifyGlass.BackgroundChanged, AddressOf magnifyGlass_BackgroundChanged
End Sub
C#Copy Code
private void magnifyGlass_CrosshairChanged(object sender, RoutedPropertyChangedEventArgs<MagnifyGlassCrosshair> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("Crosshair Changed to " + magnifyGlass.Crosshair.ToString()); 

private void magnifyGlass_CrosshairBrushChanged(object sender, RoutedPropertyChangedEventArgs<Brush> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("CrosshairBrush Changed to " + magnifyGlass.CrosshairBrush.ToString()); 

 
private void magnifyGlass_CrosshairThicknessChanged(object sender, RoutedPropertyChangedEventArgs<double> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("CrosshairThickness Changed to " + magnifyGlass.CrosshairThickness.ToString()); 

 
private void magnifyGlass_BorderBrushChanged(object sender, RoutedPropertyChangedEventArgs<Brush> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("BorderBrush Changed to " + magnifyGlass.BorderBrush.ToString()); 

 
private void magnifyGlass_BorderThicknessChanged(object sender, RoutedPropertyChangedEventArgs<double> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("BorderThickness Changed to " + magnifyGlass.BorderThickness.ToString()); 

 
private void magnifyGlass_ShapeChanged(object sender, RoutedPropertyChangedEventArgs<MagnifyGlassShape> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("Shape Changed to " + magnifyGlass.Shape.ToString()); 

 
private void magnifyGlass_ScaleFactorChanged(object sender, RoutedPropertyChangedEventArgs<double> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("Scale Factor Changed to " + magnifyGlass.ScaleFactor.ToString()); 

 
private void magnifyGlass_RoundRectangleRadiusChanged(object sender, RoutedPropertyChangedEventArgs<Size> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("RoundRectangleRadius Changed to " + magnifyGlass.RoundRectangleRadius.ToString()); 

 
private void magnifyGlass_BackgroundChanged(object sender, RoutedPropertyChangedEventArgs<Brush> e) 

   MagnifyGlass magnifyGlass = sender as MagnifyGlass; 
   Console.WriteLine("Background Changed to " + magnifyGlass.Background.ToString()); 

 
public void MagnifyGlass_Shape(BitmapSourceViewer viewer) 

   viewer.InteractiveMode = BitmapSourceViewerInteractiveMode.MagnifyGlass; 
   viewer.MagnifyGlass.CrosshairChanged +=new RoutedPropertyChangedEventHandler<MagnifyGlassCrosshair>(magnifyGlass_CrosshairChanged); 
   viewer.MagnifyGlass.CrosshairBrushChanged +=new RoutedPropertyChangedEventHandler<Brush>(magnifyGlass_CrosshairBrushChanged); 
   viewer.MagnifyGlass.CrosshairThicknessChanged +=new RoutedPropertyChangedEventHandler<double>(magnifyGlass_CrosshairThicknessChanged); 
   viewer.MagnifyGlass.BorderBrushChanged +=new RoutedPropertyChangedEventHandler<Brush>(magnifyGlass_BorderBrushChanged); 
   viewer.MagnifyGlass.BorderThicknessChanged +=new RoutedPropertyChangedEventHandler<double>(magnifyGlass_BorderThicknessChanged); 
   viewer.MagnifyGlass.ShapeChanged +=new RoutedPropertyChangedEventHandler<MagnifyGlassShape>(magnifyGlass_ShapeChanged); 
   viewer.MagnifyGlass.ScaleFactorChanged +=new RoutedPropertyChangedEventHandler<double>(magnifyGlass_ScaleFactorChanged); 
   viewer.MagnifyGlass.RoundRectangleRadiusChanged +=new RoutedPropertyChangedEventHandler<Size>(magnifyGlass_RoundRectangleRadiusChanged); 
   viewer.MagnifyGlass.BackgroundChanged +=new RoutedPropertyChangedEventHandler<Brush>(magnifyGlass_BackgroundChanged); 
 
   if(viewer.MagnifyGlass.Shape != MagnifyGlassShape.Border3D) 
   { 
      // Set the crosshair style 
      viewer.MagnifyGlass.Shape = MagnifyGlassShape.Border3D; 
 
      // Now change to a different shape 
      viewer.MagnifyGlass.Shape = MagnifyGlassShape.RoundRectangle; 
      viewer.MagnifyGlass.RoundRectangleRadius = new Size(15, 15); 
      viewer.MagnifyGlass.BorderBrush = Brushes.DarkBlue; 
      viewer.MagnifyGlass.BorderThickness = 10; 
      viewer.MagnifyGlass.Crosshair = MagnifyGlassCrosshair.Fine; 
      viewer.MagnifyGlass.CrosshairBrush = Brushes.Red; 
      viewer.MagnifyGlass.CrosshairThickness = 5; 
      viewer.MagnifyGlass.Width = 200; 
      viewer.MagnifyGlass.Height= 100; 
      viewer.MagnifyGlass.Background = Brushes.DarkGreen; 
 
      viewer.MagnifyGlass.ScaleFactor = 1.5f; 
   } 
 
   viewer.MagnifyGlass.CrosshairChanged -= new RoutedPropertyChangedEventHandler<MagnifyGlassCrosshair>(magnifyGlass_CrosshairChanged); 
   viewer.MagnifyGlass.CrosshairBrushChanged -= new RoutedPropertyChangedEventHandler<Brush>(magnifyGlass_CrosshairBrushChanged); 
   viewer.MagnifyGlass.CrosshairThicknessChanged -= new RoutedPropertyChangedEventHandler<double>(magnifyGlass_CrosshairThicknessChanged); 
   viewer.MagnifyGlass.BorderBrushChanged -= new RoutedPropertyChangedEventHandler<Brush>(magnifyGlass_BorderBrushChanged); 
   viewer.MagnifyGlass.BorderThicknessChanged -= new RoutedPropertyChangedEventHandler<double>(magnifyGlass_BorderThicknessChanged); 
   viewer.MagnifyGlass.ShapeChanged -= new RoutedPropertyChangedEventHandler<MagnifyGlassShape>(magnifyGlass_ShapeChanged); 
   viewer.MagnifyGlass.ScaleFactorChanged -= new RoutedPropertyChangedEventHandler<double>(magnifyGlass_ScaleFactorChanged); 
   viewer.MagnifyGlass.RoundRectangleRadiusChanged -= new RoutedPropertyChangedEventHandler<Size>(magnifyGlass_RoundRectangleRadiusChanged); 
   viewer.MagnifyGlass.BackgroundChanged -= new RoutedPropertyChangedEventHandler<Brush>(magnifyGlass_BackgroundChanged); 
}
XAMLCopy Code
<Window x:Class="WPFSamples.MagnifyGlass" Title="MagnifyGlass" Height="600" Width="800" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls"> 
  <DockPanel> 
    <Leadtools_Windows_Controls:BitmapSourceViewer x:Name="Viewer" Source="file:///C:\Program Files\LEAD Technologies\LEADTOOLS 16\Images\slave.jpg" Width="400" Height="400" InteractiveMode="MagnifyGlass"> 
      <Leadtools_Windows_Controls:BitmapSourceViewer.MagnifyGlass> 
        <Leadtools_Windows_Controls:MagnifyGlass Shape="RoundRectangle" RoundRectangleRadius="15,15" BorderBrush="DarkBlue" BorderThickness="10" Crosshair="Fine" CrosshairBrush="Red" CrosshairThickness="5" Width="200" Height="100" Background="DarkGreen" ScaleFactor="1.5" CrosshairChanged="magnifyGlass_CrosshairChanged" CrosshairBrushChanged="magnifyGlass_CrosshairBrushChanged" CrosshairThicknessChanged="magnifyGlass_CrosshairThicknessChanged" BorderBrushChanged="magnifyGlass_BorderBrushChanged" BorderThicknessChanged="magnifyGlass_BorderThicknessChanged" ShapeChanged="magnifyGlass_ShapeChanged" ScaleFactorChanged="magnifyGlass_ScaleFactorChanged" RoundRectangleRadiusChanged="magnifyGlass_RoundRectangleRadiusChanged" BackgroundChanged="magnifyGlass_BackgroundChanged" /> 
      </Leadtools_Windows_Controls:BitmapSourceViewer.MagnifyGlass> 
    </Leadtools_Windows_Controls:BitmapSourceViewer> 
  </DockPanel> 
</Window>

Remarks

In WPF Express, default is rectangle.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family

See Also