Draws a rectangle on the viewer.
public class ImageViewerRubberBandInteractiveMode : Leadtools.Controls.ImageViewerInteractiveMode
Public Class ImageViewerRubberBandInteractiveMode
Inherits Leadtools.Controls.ImageViewerInteractiveMode
public sealed class ImageViewerRubberBandInteractiveMode : Leadtools.Controls.ImageViewerInteractiveMode
@interface LTImageViewerRubberBandInteractiveMode : LTImageViewerInteractiveMode <NSCoding>
public class ImageViewerRubberBandInteractiveMode extends ImageViewerInteractiveMode
function Leadtools.Controls.ImageViewerRubberBandInteractiveMode()
ImageViewerRubberBandInteractiveMode derives from ImageViewerInteractiveMode and subscribes to the following events of the InteractiveService:
ImageViewerRubberBandInteractiveMode works as follows:
ImageViewerRubberBandInteractiveMode interactive mode does not perform any action on the viewer (besides drawing, moving and then removing the rectangle). It is up to the user to implement any custom operation required. For example, to select a region of interest on the image. ImageViewerZoomToInteractiveMode derives from ImageViewerRubberBandInteractiveMode and calls ImageViewer.ZoomToRect upon the receiving of RubberBandCompleted event.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
public void ImageViewerRubberBandInteractiveModeExample()
{
// Set rubber band as the default interactive mode
ImageViewerRubberBandInteractiveMode rubberBandMode = new ImageViewerRubberBandInteractiveMode();
// Customize it
rubberBandMode.BorderColor = Windows.UI.Color.FromArgb(255, 255, 0, 0);
rubberBandMode.BorderDashArray = 4;
rubberBandMode.BorderThickness = 2;
rubberBandMode.BorderDashOffset = 2;
// Hook to its RubberBandCompleted event
rubberBandMode.RubberBandCompleted += rubberBandMode_RubberBandCompleted;
_viewer.DefaultInteractiveMode = rubberBandMode;
_infoLabel.Text = "Draw a blue with yellow border rectangle on the image";
}
// Called by the base class when the mode is stopped
void rubberBandMode_RubberBandCompleted(object sender, ImageViewerRubberBandEventArgs e)
{
// Get the final rectangle
LeadRectD rect = LeadRectDHelper.FromLTRB(e.Point1.X, e.Point1.Y, e.Point2.X, e.Point2.Y);
// Get the visible rect of the _viewer
Rect imageControlRect = _viewer.ImageControlRectangle(true);
LeadRectD visibleRect = LeadRectDHelper.FromLTRB(imageControlRect.Left, imageControlRect.Top, imageControlRect.Right, imageControlRect.Bottom);
// Interset this rectangle with the visible area of the _viewer
rect = LeadRectDHelper.Intersect(rect, visibleRect);
// Make sure it has some width and height and not too small
if (rect.Width > 0 && rect.Height > 0)
{
// Get the viewer canvas
Canvas viewerCanvas = _viewer.InteractiveModeCanvas;
double x = rect.X;
double y = rect.Y;
double width = rect.Width;
double height = rect.Height;
// Add rectangle shape filled with Blue
Rectangle rectShape = new Rectangle
{
Width = rect.Width,
Height = rect.Height,
Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 0, 255)),
StrokeThickness = 2
};
Canvas.SetLeft(rectShape, x);
Canvas.SetTop(rectShape, y);
viewerCanvas.Children.Add(rectShape);
// Invalidate the _viewer (so it draws the back canvas into the foreground)
_viewer.Invalidate();
}
}
Products |
Support |
Feedback: ImageViewerRubberBandInteractiveMode Class - OLeadtools.Controls |
Introduction |
Help Version 19.0.2017.3.23
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.