LEADTOOLS WinRT(Leadtools.Controls)
LEAD Technologies, Inc

ImageViewerRubberBandEventArgs Class

Example 

Members 
Contains data for the ImageViewerRubberBandInteractiveMode.RubberBandStarted, ImageViewerRubberBandInteractiveMode.RubberBandDelta and ImageViewerRubberBandInteractiveMode.RubberBandCompleted events. WinRT support
Syntax
public sealed class ImageViewerRubberBandEventArgs : ~Remove~ 
function Leadtools.Controls.ImageViewerRubberBandEventArgs()
Example
Copy CodeCopy Code  
[TestMethod]
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();
   }
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ImageViewerRubberBandEventArgs Members
Leadtools.Controls Namespace

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.