Visual Basic (Declaration) | |
---|---|
Public Event InteractiveUserRectangle As EventHandler(Of RectangleInteractiveEventArgs) |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As ImageViewer Dim handler As EventHandler(Of RectangleInteractiveEventArgs) AddHandler instance.InteractiveUserRectangle, handler |
C# | |
---|---|
public event EventHandler<RectangleInteractiveEventArgs> InteractiveUserRectangle |
C++/CLI | |
---|---|
public: event EventHandler<RectangleInteractiveEventArgs^>^ InteractiveUserRectangle |
The event handler receives an argument of type RectangleInteractiveEventArgs containing data related to this event. The following RectangleInteractiveEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Bounds | Gets the bounds location for the current interactive rectangle mode. Supported in Silverlight, Windows Phone 7 |
Cancel (Inherited from Leadtools.Windows.Controls.InteractiveEventArgs) | Gets or sets a value indicating whether the interactive mode should be canceled. Supported in Silverlight, Windows Phone 7 |
Handled (Inherited from System.Windows.RoutedEventArgs) | |
OriginalSource (Inherited from System.Windows.RoutedEventArgs) | |
RoutedEvent (Inherited from System.Windows.RoutedEventArgs) | |
Source (Inherited from System.Windows.RoutedEventArgs) | |
Status (Inherited from Leadtools.Windows.Controls.InteractiveEventArgs) | Gets the current status of the interactive mode. Supported in Silverlight, Windows Phone 7 |
This example will use the user-defined rectangle interactive mode to let the user select a rectangle on the image to invert.
Visual Basic | Copy Code |
---|---|
Public Sub BitmapSourceViewer_IsInteractiveModeBusy(ByVal viewer As ImageViewer) AddHandler viewer.InteractiveUserRectangle, AddressOf viewer_InteractiveUserRectangle viewer.InteractiveMode = InteractiveMode.UserRectangle MessageBox.Show("Interactive mode set to draw a rectangular geometry." & Constants.vbLf & "If mouse is dragged up or to the left, interactive mode is cancelled") End Sub Private Sub viewer_InteractiveUserRectangle(ByVal sender As Object, ByVal e As RectangleInteractiveEventArgs) Console.WriteLine("" & e.Status) Dim viewer As ImageViewer = TryCast(sender, ImageViewer) Dim ee As RectangleInteractiveEventArgs = New RectangleInteractiveEventArgs(e.Status, e.Bounds) If e.Status = InteractiveModeStatus.End Then e.Cancel = True If (Not viewer.IsInteractiveModeBusy) Then MessageBox.Show("Interactive mode (Rectangular geometry) cancelled") viewer.InteractiveMode = InteractiveMode.None End If End If Console.WriteLine("" & e.Bounds.Left & ", " & e.Bounds.Top & ", " & e.Bounds.Right & ", " & e.Bounds.Bottom) End Sub |
C# | Copy Code |
---|---|
public void BitmapSourceViewer_IsInteractiveModeBusy(ImageViewer viewer) { viewer.InteractiveUserRectangle += new EventHandler<RectangleInteractiveEventArgs>(viewer_InteractiveUserRectangle); viewer.InteractiveMode = InteractiveMode.UserRectangle; MessageBox.Show("Interactive mode set to draw a rectangular geometry.\nIf mouse is dragged up or to the left, interactive mode is cancelled"); } void viewer_InteractiveUserRectangle(object sender, RectangleInteractiveEventArgs e) { Console.WriteLine(@"" + e.Status); ImageViewer viewer = sender as ImageViewer; RectangleInteractiveEventArgs ee = new RectangleInteractiveEventArgs(e.Status, e.Bounds); if (e.Status == InteractiveModeStatus.End) { e.Cancel = true; if (!viewer.IsInteractiveModeBusy) { MessageBox.Show("Interactive mode (Rectangular geometry) cancelled"); viewer.InteractiveMode = InteractiveMode.None; } } Console.WriteLine(@"" + e.Bounds.Left + ", " + e.Bounds.Top + ", " + e.Bounds.Right + ", " + e.Bounds.Bottom); } |
SilverlightCSharp | Copy Code |
---|---|
public void BitmapSourceViewer_IsInteractiveModeBusy(ImageViewer viewer) { viewer.InteractiveUserRectangle += new EventHandler<RectangleInteractiveEventArgs>(viewer_InteractiveUserRectangle); viewer.InteractiveMode = InteractiveMode.UserRectangle; MessageBox.Show("Interactive mode set to draw a rectangular geometry.\nIf mouse is dragged up or to the left, interactive mode is cancelled"); } void viewer_InteractiveUserRectangle(object sender, RectangleInteractiveEventArgs e) { Console.WriteLine(@"" + e.Status); ImageViewer viewer = sender as ImageViewer; RectangleInteractiveEventArgs ee = new RectangleInteractiveEventArgs(e.Status, e.Bounds); if (e.Status == InteractiveModeStatus.End) { e.Cancel = true; if (!viewer.IsInteractiveModeBusy) { MessageBox.Show("Interactive mode (Rectangular geometry) cancelled"); viewer.InteractiveMode = InteractiveMode.None; } } Console.WriteLine(@"" + e.Bounds.Left + ", " + e.Bounds.Top + ", " + e.Bounds.Right + ", " + e.Bounds.Bottom); } |
SilverlightVB | Copy Code |
---|---|
Public Sub BitmapSourceViewer_IsInteractiveModeBusy(ByVal viewer As ImageViewer) AddHandler viewer.InteractiveUserRectangle, AddressOf viewer_InteractiveUserRectangle viewer.InteractiveMode = InteractiveMode.UserRectangle MessageBox.Show("Interactive mode set to draw a rectangular geometry." & Constants.vbLf & "If mouse is dragged up or to the left, interactive mode is cancelled") End Sub Private Sub viewer_InteractiveUserRectangle(ByVal sender As Object, ByVal e As RectangleInteractiveEventArgs) Console.WriteLine("" & e.Status) Dim viewer As ImageViewer = TryCast(sender, ImageViewer) Dim ee As RectangleInteractiveEventArgs = New RectangleInteractiveEventArgs(e.Status, e.Bounds) If e.Status = InteractiveModeStatus.End Then e.Cancel = True If (Not viewer.IsInteractiveModeBusy) Then MessageBox.Show("Interactive mode (Rectangular geometry) cancelled") viewer.InteractiveMode = InteractiveMode.None End If End If Console.WriteLine("" & e.Bounds.Left & ", " & e.Bounds.Top & ", " & e.Bounds.Right & ", " & e.Bounds.Bottom) End Sub |
Occurs when the ImageViewer.InteractiveMode property is set to InteractiveMode.UseRectangle.
Use the InteractiveMode.UserRectangle and ImageViewer.InteractiveUserRectangle to draw a rectangle on the surface of the control. The ImageViewer object will handle mouse cursor down and up events, mouse movement, canceling (through the ESC key or when the control loses the focus) and clipping.
The ImageViewer.InteractiveUserRectangle event will occur every time the user moves the mouse or clicks any of the buttons with the corresponding data in the RectangleInteractiveEventArgs of the event.
You can use the user-defined rectangle interactive mode to perform additional interactive operations on the viewer not handled by any of the pre-defined InteractiveMode.
You can use the BoundsToImageCoordinates and BoundsFromImageCoordinates methods to convert a rectangle between image and control coordinates.
Target Platforms: Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family