Occurs when the user is using the
MagnifyGlass.
Syntax
XAML Attributes Usage | |
---|
<object InteractiveMagnifyGlass=EventHandler<ExceptionRoutedEventArgs>/> ... |
Example
This example lets you drag the mouse to magnify parts of the image.
Also, it displays the contents of the InteractiveMagnifyGlass event in the console.
Visual Basic | Copy Code |
---|
Private Sub viewer_InteractiveMagnifyGlass(ByVal sender As Object, ByVal e As BitmapSourceViewerLineEventArgs)
Dim BitmapSourceViewer As BitmapSourceViewer = CType(IIf(TypeOf sender Is BitmapSourceViewer, sender, Nothing), BitmapSourceViewer)
If e.Status = BitmapSourceViewerInteractiveStatus.Begin Then
BitmapSourceViewer.Cursor = Cursors.None
ElseIf e.Status = BitmapSourceViewerInteractiveStatus.End Then
BitmapSourceViewer.Cursor = Cursors.Arrow
End If
Console.WriteLine("InteractiveMagnifyGlass: e.Begin {0}, e.End{1}, e.Status {2}, e.Cancel {3}", e.Begin, e.End, e.Status, e.Cancel)
End Sub
Public Sub BitmapSourceViewer_InteractiveMagnifyGlass(ByVal viewer As BitmapSourceViewer)
viewer.InteractiveMode = BitmapSourceViewerInteractiveMode.MagnifyGlass
AddHandler viewer.InteractiveMagnifyGlass, AddressOf viewer_InteractiveMagnifyGlass
End Sub |
C# | Copy Code |
---|
private void viewer_InteractiveMagnifyGlass(object sender, BitmapSourceViewerLineEventArgs e) { BitmapSourceViewer BitmapSourceViewer = sender as BitmapSourceViewer; if (e.Status == BitmapSourceViewerInteractiveStatus.Begin) BitmapSourceViewer.MagnifyGlass.Cursor = Cursors.None; else if (e.Status == BitmapSourceViewerInteractiveStatus.End) BitmapSourceViewer.MagnifyGlass.Cursor = Cursors.Arrow; Console.WriteLine("InteractiveMagnifyGlass: e.Begin {0}, e.End{1}, e.Status {2}, e.Cancel {3}", e.Begin, e.End, e.Status, e.Cancel); } public void BitmapSourceViewer_InteractiveMagnifyGlass(BitmapSourceViewer viewer) { viewer.InteractiveMode = BitmapSourceViewerInteractiveMode.MagnifyGlass; viewer.InteractiveMagnifyGlass += new InteractiveMagnifyGlassEventHandler(viewer_InteractiveMagnifyGlass); // Drag mouse across image to see the magnifying glass // After you are done, you must remove the event handler as in below // // viewer.InteractiveMagnifyGlass -= new BitmapSourceViewer.InteractiveMagnifyGlassEventHandler(viewer_InteractiveMagnifyGlass); } |
XAML | Copy Code |
---|
<Window x:Class="WPFSamples.BitmapSourceViewer" Height="600" Width="800" Title="Interactive MagnifyGlass Sample" 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 Name="theViewer" Source="file:///C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\slave.jpg" DockPanel.Dock="Bottom" HorizontalAlignment="Center" VerticalAlignment="Bottom" InteractiveMode="MagnifyGlass" MagnifyGlass="150, 150, 1.5" InteractiveMagnifyGlass="viewer_InteractiveMagnifyGlass" /> </DockPanel> </Window> |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
See Also