Determines how the control handles scrollbars when the current transformation results in a view area that is larger than the control's size.
public virtual ControlScrollMode ScrollMode { get; set; }
public:
virtual property ControlScrollMode^ ScrollMode
{
ControlScrollMode^ get()
void set(ControlScrollMode^ value)
}
The scroll mode. The default value is ControlScrollMode.Auto.
Changing the value of this property will fire the PropertyChanged and TransformChanged events.
The size of the view area can become larger or smaller than the control's size depending on the size of the items inside the viewer, the view layout, and current transformations. In this case, the control might be required to show or hide scrollbars and determine how to handle panning.
As in the case of any scrolling model, the values of the current scroll offset and the size of the maximum scroll area should be available for querying and changing. This information is stored in the ScrollOffset and MaximumScrollSize properties of this control.
The value of RestrictScroll determines what to do when the user tries to pan the image outside the maximum scroll area (MaximumScrollSize), if the scroll mode was set to ControlScrollMode.Hidden.
Use the value of ScrollMode to determine how the control handles the scrollbars, as follows:
Value | Description |
---|---|
This instructs the control to use actual platform scrollbars. The viewer will show and hide the scrollbars depending on the transformation and image sizes value. This is the default behavior. The value of RestrictScroll is not used in this case and the user cannot pan outside the maximum scroll area. You can manually scroll and pan the image from 0,0 to the maximum allowed (MaximumScrollSize) by using ScrollOffset or ScrollBy. Note: Some platform, such as mobile and tablet browsers, do not support scrollbars. On these platforms ControlScrollMode.Auto will not actually show any scroll bars. Instead, it will have the same behavior as setting ScrollMode to ControlScrollMode to true. |
|
This instructs the control to enable scrolling without the use of actual scrollbars. The viewer will not show the scrollbars no matter what the transformation value is. You can still manually scroll and pan the image from 0,0 to the maximum allowed (MaximumScrollSize) by using ScrollOffset or ScrollBy. Or if desired, set the value of RestrictScroll to true and scroll or pan the image to any value without restriction. |
|
This instructs the viewer to disable scrolling completely. Scrollbars will never be visible regardless of the current transformations and image sizes and any values set into ScrollOffset or passed to ScrollBy will be ignored. Setting RestrictScroll is not used. |
The value of RestrictScroll controls what happens if the user tries to scroll or pan outside the range. When the value of RestrictScroll is true (the default), the user cannot scroll/pan outside the maximum range. This works just like when ControlScrollMode is set to false: the user is allowed unlimited panning and scrolling, and any value in ScrollOffset or ScrollBy can be used (negative values, very large values). This can be useful in some situations like mapping or medical applications.
Note: Changing the value of ScrollMode can affect the value of ScrollOffset. For example, if the scroll mode is ControlScrollMode set to false and the user has panned the image outside the maximum scrolling area, which is legal in this case. Now, if ScrollMode is set to ControlScrollMode.Auto, the scroll offset cannot be outside the maximum scrolling area, and the viewer will change the value of ScrollOffset to the closest legal value for the current mode. This is also applicable when the user changes the value of RestrictScroll from false back to true.
For more information, refer to Image Viewer Scrolling.
Run the demo. Now when you click the Example button, the scroll mode will toggle.
Start with the ImageViewer example, remove all the code inside the example function (search for the "// TODO: add example code here" comment) and insert the following code:
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 ImageViewerScrollModeExample()
{
// Get the ImageViewer control
_imageViewer = _form.ImageViewer;
// Load Image
using (var codecs = new RasterCodecs())
_imageViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Ocr1.tif"));
// Set Zoom Mode to None
_imageViewer.Zoom(ControlSizeMode.None, 1.2, _imageViewer.DefaultZoomOrigin);
// Hook to the ScrollOffset event that triggers when ScrollOffset value is changed
_imageViewer.ScrollOffsetChanged += (sender, e) =>
{
Debug.WriteLine("ScrollOffset changed: (" + _imageViewer.ScrollOffset.X + ", " + _imageViewer.ScrollOffset.Y + ")");
};
// Set ScrollMode to hidden
if (_imageViewer.ScrollMode != ControlScrollMode.Hidden)
{
_imageViewer.ScrollMode = ControlScrollMode.Hidden;
_imageViewer.ScrollOffset = new LeadPoint(100, 100); // Offset the scroll
_imageViewer.RestrictScroll = false;
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document