Gets a value that indicates if this mode has started.
public virtual bool IsStarted { get; }
true if this mode has started; otherwise, it is false.
The value of IsStarted will be set to true after Start is called and will be set back to false when Stop is called.
When the mode is started, the required service events are hooked into and the mode is waiting for user interaction. For example, a click and move to initiate a drag operation in the ImageViewerPanZoomInteractiveMode.
When the mode is working, it is in the middle of performing the operation, for example, panning the image in the viewer in the case of ImageViewerPanZoomInteractiveMode.
This value is useful when deriving your own interactive mode classes. Refer to ImageViewerInteractiveMode for an example.
using Leadtools;using Leadtools.Controls;using Leadtools.Codecs;using Leadtools.Drawing;using Leadtools.ImageProcessing;using Leadtools.ImageProcessing.Color;public ImageViewerForm _form = new ImageViewerForm();public ImageViewer _imageViewer;public void ImageViewerInteractiveModeExample(){// Get the Form's ImageViewer control_imageViewer = _form.ImageViewer;// Use vertical view layout_imageViewer.ViewLayout = new ImageViewerVerticalViewLayout();// Add 4 items to the viewerusing (var codecs = new RasterCodecs()){for (var page = 1; page <= 4; page++){var item = new ImageViewerItem();var fileName = Path.Combine(LEAD_VARS.ImagesDir, string.Format("ocr{0}.tif", page));// Create a thumbnail from the imageusing (var image = codecs.Load(fileName, page)){item.Image = image.CreateThumbnail(180, 180, 24, RasterViewPerspective.TopLeft, RasterSizeFlags.Resample);}item.Text = string.Format("Item {0}", page - 1);_imageViewer.Items.Add(item);}}// Create and add the ItemRotate interactive mode to the viewerItemRotateInteractiveMode itemRotate = new ItemRotateInteractiveMode { IsEnabled = true };_imageViewer.InteractiveModes.BeginUpdate();_imageViewer.InteractiveModes.Add(itemRotate);_imageViewer.InteractiveModes.EndUpdate();}public class ItemRotateInteractiveMode : ImageViewerInteractiveMode{public ItemRotateInteractiveMode() : base(){this.AutoItemMode = ImageViewerAutoItemMode.AutoSet;this.IdleCursor = Cursors.VSplit;this.MouseButtons = MouseButtons.Left | MouseButtons.Right;}public override string Name{get { return "ItemRotate"; }}public override int Id{get { return ImageViewerInteractiveMode.UserModeId; }}public override void Start(ImageViewer imageViewer){base.Start(imageViewer);var service = base.InteractiveService;// Rotate events on horizontal dragservice.DragStarted += new EventHandler<InteractiveDragStartedEventArgs>(service_DragStarted);service.DragDelta += new EventHandler<InteractiveDragDeltaEventArgs>(service_DragDelta);service.DragCompleted += new EventHandler<InteractiveDragCompletedEventArgs>(service_DragCompleted);// Reset event on double tapservice.DoubleTap += new EventHandler<InteractiveEventArgs>(service_DoubleTap);}public override void Stop(ImageViewer imageViewer){if (IsStarted){var service = base.InteractiveService;service.DragStarted -= new EventHandler<InteractiveDragStartedEventArgs>(service_DragStarted);service.DragDelta -= new EventHandler<InteractiveDragDeltaEventArgs>(service_DragDelta);service.DragCompleted -= new EventHandler<InteractiveDragCompletedEventArgs>(service_DragCompleted);service.DoubleTap -= new EventHandler<InteractiveEventArgs>(service_DoubleTap);base.Stop(imageViewer);}}private void service_DragStarted(object sender, InteractiveDragStartedEventArgs e){// Make sure pinch is not working, otherwise, ignore panif (!this.CanStartWork(e))return;// Make sure we are on an itemif (this.Item == null)return;Debug.WriteLine("Item Starting Rotation Angle: " + this.Item.RotateAngle);e.IsHandled = true;this.OnWorkStarted(EventArgs.Empty);}private void service_DragDelta(object sender, InteractiveDragDeltaEventArgs e){if (!this.IsWorking)return;var item = this.Item;if (item == null)return;// Find out what to doif (e.Change.X == 0 && e.Change.Y == 0)return;// Rotate clockwise when dragging right and counter-clockwise when dragging leftif(e.Change.X > 0)this.Item.RotateAngle += 2;else if (e.Change.X < 0)this.Item.RotateAngle -= 2;e.IsHandled = true;}private void service_DragCompleted(object sender, InteractiveDragCompletedEventArgs e){if (!this.IsWorking)return;Debug.WriteLine("Item Final Rotation Angle: " + this.Item.RotateAngle);e.IsHandled = true;OnWorkCompleted(EventArgs.Empty);}private void service_DoubleTap(object sender, InteractiveEventArgs e){// Make sure we not working alreadyif (this.IsWorking || !this.CanStartWork(e))return;// Make sure we have an itemvar item = this.Item;if (item == null)return;e.IsHandled = true;this.OnWorkStarted(EventArgs.Empty);ResetPosition(this.ImageViewer, item);this.OnWorkCompleted(EventArgs.Empty);}private void ResetPosition(ImageViewer imageViewer, ImageViewerItem item){// Use the identity matrix to reset the transform of the itemitem.Transform = LeadMatrix.Identity;}}static class LEAD_VARS{public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";}