←Select platform

ImageViewerInteractiveMode Class

Summary

Represents the base class for the rich user experience features of an ImageViewer

Syntax

C#
VB
Java
Objective-C
WinRT C#
public abstract class ImageViewerInteractiveMode  
Public MustInherit Class ImageViewerInteractiveMode  
public sealed class ImageViewerInteractiveMode  
iOS: 
@interface LTImageViewerInteractiveMode : NSObject <LTInteractiveServiceDelegate, LTInteractiveServiceBasicDelegate, UIGestureRecognizerDelegate, NSCoding> 
macOS: 
@interface LTImageViewerInteractiveMode : NSObject <LTInteractiveServiceMouseDelegate, NSCoding> 
public abstract class ImageViewerInteractiveMode 
function Leadtools.Controls.ImageViewerInteractiveMode() 

Remarks

ImageViewerInteractiveMode works with the InteractiveService object of the ImageViewer to provide rich user interface experience when the user interacts with the viewer using mouse or touch.

ImageViewerInteractiveMode is a base abstract class, you can derive your own class to handle custom interaction with the viewer. Out of the box, LEADTOOLS provide the following implementations:

Class Description
ImageViewerPanZoomInteractiveMode

Supports panning and zooming with the mouse and multi-touch.

ImageViewerZoomToInteractiveMode

Zooms to image rectangle created by the user using mouse or touch.

ImageViewerMagnifyGlassInteractiveMode

Magnifies the portion of the image under the mouse or touch.

ImageViewerCenterAtInteractiveMode

Centers the image inside the user based on user mouse click or touch tap.

ImageViewerRubberBandInteractiveMode

Draws a temporary rectangle on top of the image using the mouse or touch. Can be used to perform any extra functionality such as drawing a region of interest for a user-defined operation.

To use an interactive mode, you create an instance of any of the derived classes and assign it to the viewer using one of the following methods:

Example

WinRT C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
 
// RotateInteractiveMode 
[TestClass] 
public class ImageViewerRotateInteractiveMode : ImageViewerInteractiveMode 
{ 
   public ImageViewerRotateInteractiveMode() 
   { 
   } 
   public override string Name 
   { 
      get { return "Rotate"; } 
   } 
 
   public override string ToString() 
   { 
      return Name; 
   } 
 
   // Called by the base class when the mode is started 
   public override void Start(ImageViewer viewer) 
   { 
      base.Start(viewer); 
 
      // add EventHandlers to the DragStarted, DragDelta and DragCompleted events 
      base.InteractiveService.DragStarted += InteractiveService_DragStarted; 
      base.InteractiveService.DragDelta += InteractiveService_DragDelta; 
      base.InteractiveService.DragCompleted += InteractiveService_DragCompleted; 
   } 
 
   // Called by the base class when the mode is stopped 
   public override void Stop(ImageViewer viewer) 
   { 
      // Check if we have started 
      if (IsStarted) 
      { 
         // remove EventHandlers from events 
         base.InteractiveService.DragStarted -= InteractiveService_DragStarted; 
         base.InteractiveService.DragDelta -= InteractiveService_DragDelta; 
         base.InteractiveService.DragCompleted -= InteractiveService_DragCompleted; 
 
         // Always call base class stop method 
         base.Stop(viewer); 
      } 
   } 
 
   // Called when the user starts a drag operation 
   void InteractiveService_DragStarted(object sender, InteractiveDragStartedEventArgs e) 
   { 
 
      if (!this.CanStartWork(e)) 
      { 
         return; 
      } 
 
      // Inform whoever is listening that we have started working 
      this.OnWorkStarted(EventArgs.Empty); 
 
 
   } 
 
   // Called when the user is dragging 
   void InteractiveService_DragDelta(object sender, InteractiveDragDeltaEventArgs e) 
   { 
      // If we are not working (for example, the user has not clicked the mouse button yet), then 
      // nothing to do 
      if (!this.IsWorking) 
      { 
         return; 
      } 
 
      // Perform our operation, get the change of the drag, then increase 
      // or decrease the current rotation angle based on direction 
      var viewer = this.ImageViewerControl; 
      var change = e.Change; 
      var delta = 4; 
      if (change.X < 0) 
      { 
         viewer.RotateAngle = viewer.RotateAngle - delta; 
      } 
      else if (change.X > 0) 
      { 
         viewer.RotateAngle = viewer.RotateAngle + delta; 
      } 
 
   } 
 
   // Called when the user has stopped dragging 
   void InteractiveService_DragCompleted(object sender, InteractiveDragCompletedEventArgs e) 
   { 
      if (!this.IsWorking) 
      { 
         return; 
      } 
 
      // Inform whoever is listening that we have stoped working 
      this.OnWorkCompleted(EventArgs.Empty); 
   } 
} 
 
//set InteractiveMode in new ImageViewer 
ImageViewer InteractiveModeExample() 
{ 
   Uri imageUrl = new Uri("ms-appx:///Assets/PngImage2.png"); 
 
   // Create the viewer 
   var viewer = new Leadtools.Controls.ImageViewer(); 
 
   // Set the image Source 
   viewer.Source = new BitmapImage(imageUrl); 
 
   // Set Rotate as our interactive mode 
   viewer.DefaultInteractiveMode = new ImageViewerRotateInteractiveMode(); 
 
   return viewer; 
} 

Requirements

Target Platforms

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

Leadtools.Controls Assembly (WinRT / WPF / iOS / OS X / Android)