LEADTOOLS WinRT(Leadtools.Controls)
LEAD Technologies, Inc

ScrollOffset Property

Example 

Gets or sets the scroll offset value. WinRT support
Syntax
public Point ScrollOffset {get; set;}
 get_ScrollOffset();
set_ScrollOffset(value);

Property Value

The current scroll offset value. The default value is 0,0.
Remarks

Changing the value of this property will fire the PropertyChanged, ScrollChanged and TransformChanged events.

When the value of ScrollMode is ImageViewerScrollMode.Auto, then the value of ScrollOffset contains the current scrollbars offset. When the user clicks and drags on the scrollbars, the value of ScrollOffset (and the scrollbars thumbs) changes accordingly. The minimum value allowed is 0,0 (top-left) and the the maximum value allowed is stored in ScrollRange (setting ScrollOffset to ScrollRange will cause the viewer to scroll the image to the bottom-right corner. . You can manually pan the image by setting a value in ScrollOffset or calling ScrollBy.

When the value of ScrollMode is ImageViewerScrollMode.Hidden, then the value of ScrollOffset contains the virtual scroll (pan) offset, you can pan the image by changing the value of ScrollOffset or calling ScrollBy. If the value of RestrictHiddenScrollMode is true, then the minimum and maximum scroll values are the same as the case above. If the value of RestrictHiddenScrollMode is false, then there is no minimum and maximum scroll ranges, you are allowed to set ScrollOffset to any value. 0,0 and ScrollRange will still be the values to use if you want to either scroll the image to top-left or right-bottom.

When the value of ScrollMode is ImageViewerScrollMode.Disabled, then trying to change the value of ScrollOffset or calling ScrollBy will be ignored.

Example
Copy CodeCopy Code  
[TestMethod]
public void ScrollOffsetExample()
{
   bool scrollChangedHooked = false;
   // Set DefaultInteractiveMode property to ImageViewerPanZoomInteractiveMode to see the example effect
   ImageViewerPanZoomInteractiveMode panZoomMode = new ImageViewerPanZoomInteractiveMode();
   _viewer.DefaultInteractiveMode = panZoomMode;
   // Subscribe to the PropertyChanged event

   // Get the scroll current range
   Size scrollRange = _viewer.ScrollRange;

   if(!scrollChangedHooked)
   {
      // First click, hook to the event
      scrollChangedHooked = true;
      _viewer.ScrollChanged += _viewer_ScrollChanged;
   }
   else
   {
      // Other clicks, scroll to bottom-right
      _viewer.ScrollOffset = new Point(scrollRange.Width, scrollRange.Height);
   }
}

void _viewer_ScrollChanged(object sender, EventArgs e)
{
   // Show the scroll offset and range
   Point scrollOffset = _viewer.ScrollOffset;
   _infoLabel.Text =
      "Current scroll offset: " + scrollOffset.X + ", " + scrollOffset.Y +
      ". Scroll range: " + _viewer.ScrollRange.Width + ", " + _viewer.ScrollRange.Height +
      ". Click Example again to scroll to bottom-right";
}
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

ImageViewer Class
ImageViewer Members

 

 


Products | Support | Contact Us | Copyright Notices

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