ZoomPanel Class |
Namespace: Ab2d.Controls
public class ZoomPanel : ContentControl, IScrollInfo
The ZoomPanel type exposes the following members.
Name | Description | |
---|---|---|
![]() | ActualContentBounds |
Gets the Bounds of the contents of a ZoomPanel after the transformation were applied to it.
|
![]() | ActualViewbox |
Gets the Rect that describes the area of the content that is actually visible on the screen.
|
![]() | AnimationDuration |
Duration of zoom change animation. Default value is 200 milliseconds.
|
![]() | CanHorizontallyScroll |
IScrollInfo.CanHorizontallyScroll
|
![]() | CanVerticallyScroll |
IScrollInfo.CanVerticallyScroll
|
![]() | CenterPosition |
Gets or sets the position that specifies which point of the content will be positioned in the center of the ZoomPanel. The value is in the units (Absolute / Relative) specified by the CenterPositionUnits property.
|
![]() | CenterPositionUnits |
Gets or sets units in which the CenterPosition is specified. Default value is Relative.
|
![]() ![]() | ChangeZoomModeCommand |
ChangeZoomModeCommand
|
![]() | ExtentHeight |
IScrollInfo.ExtentHeight
|
![]() | ExtentWidth |
IScrollInfo.ExtentWidth
|
![]() | HistoryItems |
Provides access to the collection of history items and methods to navigate the history.
|
![]() | HorizontalOffset |
IScrollInfo.HorizontalOffset
|
![]() | IsAnimated |
If True than zoom changes are animated. Default value is true.
|
![]() | IsCustomContent |
Gets a value that indicates if ZoomPanel is currently in custom content mode.
|
![]() | IsHistoryEnabled |
Gets or sets a boolean that specifies if ZoomPanel is saving history of the previous Viewbox and RotationAngle values. Default value is false.
|
![]() | IsMouseWheelZoomEnabled |
Gets or sets if zooming with mouse wheel is enabled or disabled. Default value is true (enabled).
|
![]() | IsPanningAnimated |
If true than also mouse panning is animated, if false mouse panning has immediate effect. Default value is false.
|
![]() | IsToggleZoomModeEnabled |
Gets or sets if zoom mode toggling is enabled. If true than when setting zoom mode once again to the current zoom mode, the zoom mode goes to None.
This is useful for ZoomControllers when for example clicking for the first time on Move button sets the ZoomMode to Move. Clicking on Move button again disables Move mode - goes to None ZoomMode.
Default value is true (enabled).
|
![]() | IsTouchEnabled |
Gets or sets a boolean that specifies if touch and multi-touch control is enabled. Default value is true.
|
![]() | IsTouchMoveEnabled |
Gets or sets a boolean that specifies if moving with touch is enabled. Default value is true.
NOTE: Touch controls work only with .Net 4 build of ZoomPanel (or newer).
|
![]() | IsTouchRotateEnabled |
Gets or sets a boolean that specifies if rotating with multi-touch is enabled. Default value is true.
NOTE: Touch controls work only with .Net 4 build of ZoomPanel (or newer).
|
![]() | IsTouchScaleEnabled |
Gets or sets a boolean that specifies if scaling with multi-touch pinch is enabled. Default value is true.
NOTE: Touch controls work only with .Net 4 build of ZoomPanel (or newer).
|
![]() | IsViewboxLimited |
Gets or sets a Boolean value that specifies if ViewboxLimits is used to limit the ZoomPanel.
|
![]() | IsZoomPositionPreserved |
Gets or sets a Boolean that specifies if the position of the point where zooming in or out occurs is preserved. If false than zooming is also centering the zooming point. Default value is true.
|
![]() ![]() | LicenseInfo |
License information
|
![]() | MouseWheelZoomFactor |
Gets or sets the zoom factor that is applied to mouse wheel zooming.
The value must be bigger or equal than 1. This value is used for zoom in factor. The zoom out factor is calculated in GetZoomOutFactor method as 1 / zoom factor (can be overridden in derived class).
|
![]() ![]() | MoveDownCommand |
MoveDownCommand
|
![]() ![]() | MoveLeftCommand |
MoveLeftCommand
|
![]() ![]() | MoveRightCommand |
MoveRightCommand
|
![]() ![]() | MoveUpCommand |
MoveUpCommand
|
![]() | RectangleFill |
Fill Brush of the Rectangle used in Rectangle ZoomMode.
Default value is #46AAAAFF - semi-transparent light blue.
|
![]() | RectangleStroke |
Stroke of the Rectangle used in Rectangle ZoomMode.
Default value is Blue.
|
![]() ![]() | ResetCommand |
ResetCommand
|
![]() ![]() | ResetToLimitsCommand |
ResetToLimitsCommand
|
![]() | RotationAngle |
Gets or sets the rotation angle in degrees, that determines the angle with witch the content of the ZoomPanel is rotated around the center of the ZoomPanel.
|
![]() | ScrollLineSizeInPercent |
Size in percent of the line when scrolling with ScrollViewer. The size is used when the bottom, up, left or right arrow on scroll slider is clicked.
When scrolling with mouse wheel, the line size is multiplied with the value of scroll wheel settings from Control Panel.
For example 0.1 scrolls the content of ZoomPanel by 10%.
|
![]() | ScrollOwner |
IScrollInfo.ScrollOwner
|
![]() ![]() | SetMoveModeCommand |
SetMoveModeCommand
|
![]() ![]() | SetNoneZoomModeCommand |
SetNoneZoomModeCommand
|
![]() ![]() | SetRectangleModeCommand |
SetRectangleModeCommand
|
![]() ![]() | SetZoomInModeCommand |
SetZoomInModeCommand
|
![]() ![]() | SetZoomOutModeCommand |
SetZoomOutModeCommand
|
![]() | Stretch |
Gets or sets the ZoomPanel System.Windows.Media.Stretch
mode, which determines how content fits into the available space.
|
![]() | UsedViewboxEx |
Gets the ViewboxEx control that is used to show the content of ZoomPanel.
|
![]() | UseLowQualityBitmapScalingModeWhenAnimating |
Gets or sets a Boolean that specifies if LowQuality BitmapScalingMode is used when animating zooming.
After zooming is complete the BitmapScalingMode is set to the previous quality setting.
This mode works only when the Image is an immediate child of ZoomPanel.
By default this property is set to false (using HighQuality mode) except in case WPF is running on lower tier hardware (RenderCapability.Tier is less that 2).
|
![]() | VerticalOffset |
IScrollInfo.VerticalOffset
|
![]() | Viewbox |
Gets or sets the current viewbox as Rect used to determine which part of ZoomPanel's content is shown.
|
![]() | ViewboxLimits |
Gets or sets the System.Rect that limits the maximum Viewbox size used by ZoomPanel - the maximum zoom out level.
|
![]() | ViewboxMinSize |
Gets or sets the System.Size that limits the Viewbox minimum size used by ZoomPanel - the maximum zoom in level.
|
![]() | ViewportHeight |
IScrollInfo.ViewportHeight
|
![]() | ViewportWidth |
IScrollInfo.ViewportWidth
|
![]() | ZoomFactor |
Gets or sets the zoom factor that defines how much the content of the ZoomPanel is scaled (1 - no scale; >1 - zoom in; <1 - zoom out).
|
![]() | ZoomInOutFactor |
Gets or sets the zoom in and out factor for ZoomIn and ZoomOut mode.
The value must be bigger or equal than 1. This value is used for zoom in factor. The zoom out factor is calculated in GetZoomOutFactor method as 1 / zoom factor (can be overridden in derived class).
|
![]() | ZoomMode |
Gets or sets the current zoom mode of the ZoomPanel.
|
Name | Description | |
---|---|---|
![]() ![]() | CalculateVisibleArea |
Calculates the visible area that would be shown if ZoomPanel.Viewbox would be (0,0,1,1).
|
![]() | FitToHeight |
Sets the zoom and translation to show the whole height of the ZoomPanel's content.
|
![]() | FitToLimitsHeight |
Sets the zoom and translation to show the whole limits height of the ZoomPanel's content.
|
![]() | FitToLimitsWidth |
Sets the zoom and translation to show the whole limits width of the ZoomPanel's content (if ZoomPanel is Limited)
|
![]() | FitToWidth |
Sets the zoom and translation to show the whole width of the ZoomPanel's content.
|
![]() | GetCenterPosition |
Returns center positions as Point in the specified units (relative or absolute) and from the specified viewbox.
|
![]() | GetContentSize |
Gets the size of the ZoomPanel's content.
|
![]() | GetViewboxFromCenterAndZoomFactor |
Returns viewbox as Rect from the specified centerPosition, its units and zoomFactor.
|
![]() | GetZoomFactor |
Returns the zoom factor from the specified viewbox as Rect.
The method can be overridden to provide custom zoom factor calculations - for example exponential.
|
![]() | LineDown |
IScrollInfo.LineDown
|
![]() | LineLeft |
IScrollInfo.LineLeft
|
![]() | LineRight |
IScrollInfo.LineRight
|
![]() | LineUp |
IScrollInfo.LineUp
|
![]() | MakeVisible |
IScrollInfo.MakeVisible
|
![]() | MouseWheelDown |
IScrollInfo.MouseWheelDown
|
![]() | MouseWheelLeft |
IScrollInfo.MouseWheelLeft
|
![]() | MouseWheelRight |
IScrollInfo.MouseWheelRight
|
![]() | MouseWheelUp |
IScrollInfo.MouseWheelUp
|
![]() | OnApplyTemplate |
OnApplyTemplate
(Overrides FrameworkElementOnApplyTemplate.) |
![]() | PageDown |
IScrollInfo.PageDown
|
![]() | PageLeft |
IScrollInfo.PageLeft
|
![]() | PageRight |
IScrollInfo.PageRight
|
![]() | PageUp |
IScrollInfo.PageUp
|
![]() | Refresh |
Forces the ZoomPanel to immediately recalculate the visible area based on the current Viewbox settings.
|
![]() ![]() | RegisterCustomContentProvider |
Registers the ZoomPanel control to show custom content.
With custom content the ZoomPanel does not apply scale and translate transform to its content but instead calls the customContentProvider delegate that returns the custom content based on the current zoom parameters.
|
![]() | Reset |
Resets the zoom and translation to show the whole content of ZoomPanel (Viewbox="0 0 1 1"). The method also resets the RotationAngle to 0.
|
![]() | ResetNow |
Immediately resets the zoom and translation to show the whole content of ZoomPanel (Viewbox="0 0 1 1"). The method also resets the RotationAngle to 0.
|
![]() | ResetToLimits |
Resets the zoom and translation to show the content of ZoomPanel based on the ViewboxLimits. If Viewbox is not limited (IsViewboxLimited == false), the method is the same as Reset method. The method also resets the RotationAngle to 0.
|
![]() | ResetToLimitsNow |
Resets the zoom and translation to show the whole content of ZoomPanel. The method also resets the RotationAngle to 0.
|
![]() | SetHorizontalOffset |
IScrollInfo.SetHorizontalOffset
|
![]() | SetVerticalOffset |
IScrollInfo.SetVerticalOffset
|
![]() | SetViewbox |
Sets the viewbox relative to the ZoomPanel content.
|
![]() | SetViewboxNow |
Immediately sets the viewbox relative to the ZoomPanel content.
|
![]() | SetZoom(Double) |
Sets the zoom area to the currently set CenterPosition and the zoomFactor parameter. If IsAnimated property is true, the zoom area change is animated.
|
![]() | SetZoom(Point) |
Sets the zoom area to centerPosition parameter (in the current CenterPositionUnits) and the currently set ZoomFactor. If IsAnimated property is true, the zoom area change is animated.
|
![]() ![]() | SetZoom(Rect) |
Sets the zoom area to the new viewbox. If IsAnimated property is true, the zoom area change is animated.
|
![]() | SetZoom(Point, Double) |
Sets the zoom area to centerPosition parameter (in the current CenterPositionUnits) and the zoomFactor parameter. If IsAnimated property is true, the zoom area change is animated.
|
![]() | SetZoom(Rect, Double) |
Sets the zoom area to the new viewbox. If IsAnimated property is true, the zoom area change is animated.
|
![]() | SetZoom(Point, ZoomPanelCenterPositionUnitsType, Double) |
Sets the zoom area based on centerPosition, units and zoomFactor parameters. If IsAnimated property is true, the viewbox change is animated.
|
![]() | SetZoom(Point, ZoomPanelCenterPositionUnitsType, Double, Double) |
Sets the zoom area based on centerPosition, units and zoomFactor parameters. If IsAnimated property is true, the viewbox change is animated.
|
![]() | SetZoom(Point, ZoomPanelCenterPositionUnitsType, Double, Double, Boolean, Boolean) |
Sets the zoom from the centerPosition and zoomFactor.
|
![]() | SetZoomNow(Double) |
Sets the zoom area to the currently set CenterPosition and the zoomFactor parameter. The zoom area is changed immediately regardless of the IsAnimated property.
|
![]() | SetZoomNow(Point) |
Sets the zoom area to centerPosition parameter (in the current CenterPositionUnits) and the currently set ZoomFactor. The zoom area is changed immediately regardless of the IsAnimated property.
|
![]() ![]() | SetZoomNow(Rect) |
Sets the zoom area to the new viewbox. The zoom area is changed immediately regardless of the IsAnimated property.
|
![]() | SetZoomNow(Point, Double) |
Sets the zoom area to centerPosition parameter (in the current CenterPositionUnits) and the zoomFactor parameter. The zoom area is changed immediately regardless of the IsAnimated property.
|
![]() | SetZoomNow(Rect, Double) |
Sets the zoom area to the new viewbox. If IsAnimated property is true, the zoom area change is animated.
|
![]() | SetZoomNow(Point, ZoomPanelCenterPositionUnitsType, Double) |
Sets the zoom area based on centerPosition, units and zoomFactor parameters. The zoom area is changed immediately regardless of the IsAnimated property.
|
![]() | SetZoomNow(Point, ZoomPanelCenterPositionUnitsType, Double, Double) |
Sets the zoom area based on centerPosition, units and zoomFactor parameters. The zoom area is changed immediately regardless of the IsAnimated property.
|
![]() | Translate |
Translates the content by the dx and dy (in absolute units)
|
![]() | TranslateNow |
Translates the content by the dx and dy (in absolute units).
|
![]() | TranslateRelative |
Translates the content by the dx and dy (in relative units: 1 is the whole width/height of ZoomPanel)
|
![]() | TranslateToCenter |
Translates the content of ZoomPanel so that the mouseNewCenterPoint is shown in the center of ZoomPanel.
|
![]() | TranslateToCenterRelative |
Translates the content of ZoomPanel so that the mouseNewCenterPoint is shown in the center of ZoomPanel.
newRelativeCenterPoint is in relative coordinates - (0.5, 0.5) is the center of ZoomPanel
|
![]() | UnregisterCustomContentProvider |
Unregisters the ZoomPanel control from custom content provider - from now on the ZoomPanel will use ViewboxEx to apply scale and translate transforms to its content
|
![]() | ZoomAndTranslateToCenter |
Zooms and translates the content of ZoomPanel so that the mouseNewCenterPoint is shown in the center of ZoomPanel.
mouseNewCenterPoint is in absolute units.
|
![]() | ZoomAndTranslateToCenterRelative |
Zooms and translates the content of ZoomPanel so that the mouseNewCenterPoint is shown in the center of ZoomPanel.
newRelativeCenterPoint is in relative coordinates - (0.5, 0.5) is the center of ZoomPanel
|
![]() | ZoomAtMousePosition |
Zooms the content of ZoomPanel so that the mousePosition stays at the same location.
|
![]() | ZoomAtRelativeMousePosition |
Zooms the content of ZoomPanel so that the mousePosition stays at the same location.
relativeMousePosition is in relative coordinates - (0.5, 0.5) is the center of ZoomPanel.
|
![]() | ZoomForFactor |
Zooms the scene for the zoomFactor. For example zoom factor 2 means that the currently shown scene is scaled for factor 2 (for 100%).
|
![]() | ZoomForRectangle(Rect) |
Zooms and translates to show the content defined by newZoomRectangle (coordinates absolute units - from ZoomPanel's position and its ActualWidth and ActualHeight)
|
![]() | ZoomForRectangle(Point, Point) |
Zooms and translates to show the content defined by startPoint and endPoint (coordinates in absolute units - from ZoomPanel's position and its ActualWidth and ActualHeight)
|
![]() | ZoomForRectangleRelative |
Zooms and translates to show the content defined by newZoomRectangle (coordinates in relative units - 1,1 is right bottom corner or ZoomPanel)
|
![]() | ZoomToFactor |
Zooms the scene to the zoomFactor regardless of the current zoomFactor. For example zoomFactor 2 shows app. 50% of the content, 4 shows 25% of the content.
|
Name | Description | |
---|---|---|
![]() | PreviewViewboxChanged |
PreviewViewboxChanged occurs before the Viewbox or RotationAngle is changed.
The event can be used to prevent the change of viewbox or RotationAngle (set Handled property to true), or change the new viewbox or RotationAngle before the change is applied.
|
![]() | ViewboxAnimationCompleted |
ViewboxAnimationCompleted occurs after the animation that changed the Viewbox is completed (if Viewbox change was not animated, this event is not fired).
|
![]() | ViewboxAnimationStarted |
ViewboxAnimationStarted occurs after when the animation that change the Viewbox is started (if Viewbox change is not animated, this event is not fired).
|
![]() | ViewboxChanged |
ViewboxChanged occurs after the Viewbox value is changed. If the zooming is animated the event fires when the animation begins - the NewValue is not the current Viewbox value but the final value when the animation will be completed.
|
![]() | ZoomModeChanged |
ZoomModeChanged occurs when ZoomMode is changed
|
Name | Description | |
---|---|---|
![]() ![]() | AnimationDurationProperty |
AnimationDurationProperty
|
![]() ![]() | IsAnimatedProperty |
IsAnimatedProperty
|
![]() ![]() | IsMouseWheelZoomEnabledProperty |
IsMouseWheelZoomEnabledProperty
|
![]() ![]() | IsPanningAnimatedProperty |
IsPanningAnimatedProperty
|
![]() ![]() | IsToggleZoomModeEnabledProperty |
IsToggleZoomModeEnabledProperty
|
![]() ![]() | IsTouchEnabledProperty |
IsTouchEnabledProperty
|
![]() ![]() | IsTouchMoveEnabledProperty |
IsTouchMoveEnabledProperty
|
![]() ![]() | IsTouchRotateEnabledProperty |
IsTouchRotateEnabledProperty
|
![]() ![]() | IsTouchScaleEnabledProperty |
IsTouchScaleEnabledProperty
|
![]() ![]() | IsViewboxLimitedProperty |
IsViewboxLimitedProperty
|
![]() ![]() | IsZoomPositionPreservedProperty |
IsZoomPositionPreserved
|
![]() ![]() | MouseWheelZoomFactorProperty |
MouseWheelZoomFactorProperty
|
![]() ![]() | PreviewViewboxChangedEvent |
PreviewViewboxChangedEvent RoutedEvent
|
![]() ![]() | RectangleFillProperty |
RectangleFillProperty
|
![]() ![]() | RectangleStrokeProperty |
RectangleStrokeProperty
|
![]() ![]() | RotationAngleProperty |
RotationAngleProperty
|
![]() ![]() | StretchProperty |
StretchProperty
|
![]() ![]() | ViewboxAnimationCompletedEvent |
ViewboxAnimationCompletedEvent RoutedEvent
|
![]() ![]() | ViewboxAnimationStartedEvent |
ViewboxAnimationStartedEvent RoutedEvent
|
![]() ![]() | ViewboxChangedEvent |
ViewboxChangedEvent RoutedEvent
|
![]() ![]() | ViewboxLimitsProperty |
ViewboxLimitsProperty
|
![]() ![]() | ViewboxMinSizeProperty |
ViewboxMinSizeProperty
|
![]() ![]() | ZoomFactorProperty |
ZoomFactorProperty
|
![]() ![]() | ZoomInOutFactorProperty |
ZoomInOutFactorProperty
|
![]() ![]() | ZoomModeChangedEvent |
ZoomModeChangedEvent RoutedEvent
|
![]() ![]() | ZoomPanelAnimator |
Gets or sets a class that is used to animate the ZoomPanel. Default value is ZoomPanelQuinticAnimator that adds some easing to animation.
|
ZoomPanel control can be used to simply add a powerful and animated zooming and panning to any WPF application. The control can be used to zoom and pan bitmap images, vector graphics, UI Elements, etc.
Content can be zoomed and panned with mouse, with touch and multi-touch gestures. Touch support can be enabled or disabled with IsTouchEnabled, IsTouchMoveEnabled, IsTouchScaleEnabled and IsTouchRotateEnabled properties. By default all properties are set to true.
NOTE that touch controls are working only in .Net 4 build of ZoomPanel (or newer) and does not work in .Net 3.5 build of the library.
The following image shows the ZoomPanel with ZoomController in the upper left corner, ZoomPanelNavigator in the upper left corner and ZoomPanelMiniMap in the bottom right corner:
ZoomPanel is usually used with a ZoomController that sets the mode in which ZoomPanel works. The following ZoomPanel modes are supported: None, Move, Rectangle, ZoomIn, ZoomOut (see ZoomPanelZoomModeType for more info). The current zoom mode can be get or set with ZoomMode property.
With using ZoomPanelNavigator it is possible to set the zoom factor with a slider and move around the visible area with buttons.
The ZoomPanelMiniMap shows which part of the content is shown. It can be used to preview which part of the content is shown. It also enables moving the shown content and zooming in and out with mouse wheel (shown in the bottom right corner of the image above).
By default the content of the ZoomPanel can be freely zoomed in and out and panned to any direction. But it is possible to limit this by ViewboxLimits, ViewboxMinSize and IsViewboxLimited. The ViewboxLimits sets the maximum Viewbox size used by ZoomPanel - maximum zoom out level. The ViewboxMinSize sets the minimum Viewbox size used by ZoomPanel - maximum zoom in level.
To add scrollbars to the ZoomPanel simply add it inside ScrollViewer control and set the CanContentScroll property on ScrollViewer to True (see the sample below). The ZoomPanel implements the IScrollInfo interface. Therefore it can be fully controlled by the scrollbars. The size and position of the scrollbars is determined by the currently shown area.
By default the zooming in and out is animated using quintic function to ease the animation. The default animation is implemented in ZoomPanelQuinticAnimator class. It is possible to provide custom animations with deriving a class from BaseZoomPanelAnimator and setting its instance to the ZoomPanelAnimator property.
ZoomPanel also has a lot of methods that can be used to modify the ZoomPanel from code-behind. See samples for more info.
With calling RegisterCustomContentProvider it is also possible to zoom dynamic and custom content - the content that is based on the current zoom level - for example a map.
The following sample shows how to use the ZoomPanel and ZoomController:
<Window x:Class="Ab2d.ZoomControlSample.ZoomPanelSample" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ab2d="clr-namespace:Ab2d.Controls;assembly=Ab2d.Controls.ZoomPanel"> <Grid> <ScrollViewer CanContentScroll="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"> <ab2d:ZoomPanel Name="myZoomPanel" Viewbox="0.2 0.2 0.6 0.6" IsAnimated="True" AnimationDuration="0:0:0.5" ViewboxLimits="-0.1 -0.1 1.2 1.2" ViewboxMinSize="0.1 0.1" IsViewboxLimited="True"> <TextBlock>12345</TextBlock> </ab2d:ZoomPanel> </ScrollViewer> <ab2d:ZoomController VerticalAlignment="Top" HorizontalAlignment="Right"/> <ab2d:ZoomPanelNavigator VerticalAlignment="Top" HorizontalAlignment="Left"/> <ab2d:ZoomPanelMiniMap VerticalAlignment="Bottom" HorizontalAlignment="Right"/> </Grid> </Window>
The following code is used to zoom the content of myZoomPanel for factor 1.5 (for 50%):
myZoomPanel.ZoomForFactor(1.5);