A newer version of this code is now available.
ImageBox control has had quite a big update, you can download the source from the link below, or from our GitHub page.
Listed below are the changes made during this update, we hope you enjoy them!
Changes and new features
- Zooming with the mouse is now smoother, and the control attempts to keep the area under the mouse before the zoom in the same area after the zoon.
- Added a
ZoomLevelsproperty which allows you to configure the different zoom levels supported by the control. Now instead of the control trying to guess the next zoom level, it cycles appropriately through the defined levels. Currently ZoomLevels (apart from the default series) can only be set at runtime.
ZoomIncrementproperty has been removed due to the introduction of the new zoom levels.
ScrollTomethods allow you to scroll to a given location in the source image.
- Split shortcut handling into two methods
ProcessScrollingShortcutsfor handling arrow keys and
ProcessImageShortcutsfor handling pretty much anything else.
EnableShortcutsproperty, allowing the built in keyboard support to be disabled. When this property is true,
ProcessImageShortcutsis not called, allowing the control to still be scrolled via the keyboard, but not zoomed etc.
- Zooming can now be performed by the -/+ keys (
- When zooming (except via mouse action), if the
AutoCenterproperty is set, the control will always center the image even when scrollbars are present.
EndUpdatemethods allow you to disable and enable painting of the control, for example when changing multiple properties at once.
- Added a new
GetSelectedImagemethod which creates a new
Bitmapbased on the current selection.
- Added new
FitRectanglemethod which takes a given rectangle and ensure it fits within the image boundaries
AllowClickZoomproperty now defaults to
PointToImagefunction no longer adds +1 to the result of the function.
- Added a new
ZoomToRegionmethod. This will caculate and appropriate zoom level and scrollbar positions to fit a given rectangle.
- Added new
SelectionMode.Zoom. When this mode is selected, drawing a region will automatically zoom and position the control to fit the region, after which the region is automatically cleared.
- Panning no longer tries to activate if no scrollbars are visible
- A new base class,
VirtualScrollableControlis now used instead of
ScrollableControl. This removes completely the flicker issues present in previous versions of the control.
- The BorderStyle property has been moved to the
ScrollControlclass, so that borders now correctly surround the control (including scrollbars) rather than just the client area.
- If the
true, the control no longer magically zooms after panning or selecting a region. Code previously in the
OnMouseClickoverride is now in
- If both
AutoPanand a valid
SelectionModeare set, only selections are processed, instead of the control tying to do both. As a result of this fix, setting the
SelectionModeproperty no longer resets
- With the introduction of the
MouseWheelevent is now raised as expected.
ScrollPropertiesclass hasn't been fully integrated with the
ScrollControl, setting properties on this class won't update the owner control.
Related articles you may be interested in
- Displaying multi-page tiff files using the ImageBox control and C#
- Adding drag handles to an ImageBox to allow resizing of selection regions
- ImageBox 220.127.116.11 update
- ImageBox and TabList update's - virtual mode, pixel grid, bug fixes and more!
- Zooming to fit a region in a ScrollableControl
- Zooming into a fixed point on a ScrollableControl
- Arcade explosion generator
- Creating an image viewer in C# Part 5: Selecting part of an image
- Extending the ImageBox component to display the contents of a PDF file using C#
- Creating a scrollable and zoomable image viewer in C# Part 4
- Creating a scrollable and zoomable image viewer in C# Part 3
- Creating a scrollable and zoomable image viewer in C# Part 2
- Creating a scrollable and zoomable image viewer in C# Part 1
Cyotek ImageBox Control, 18.104.22.168 update