diff --git a/doc/controls/ZoomContentControl.md b/doc/controls/ZoomContentControl.md index 3ca2e89ba..b7eec9a20 100644 --- a/doc/controls/ZoomContentControl.md +++ b/doc/controls/ZoomContentControl.md @@ -68,7 +68,5 @@ xmlns:utu="using:Uno.Toolkit.UI" | Method| Return Type| Description| |-----------------------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `ResetZoom()`| `void`| Resets the zoom level to its default value.| -| `ResetOffset()`| `void`| Resets the horizontal and vertical offset to its default value. | | `FitToCanvas()`| `void`| Adjust the zoom level so that the content fits within the available space.| | `CenterContent()`| `void`| Centers the content within the available space.| diff --git a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.Properties.cs b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.Properties.cs index 830e5be49..96c0b215d 100644 --- a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.Properties.cs +++ b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.Properties.cs @@ -37,14 +37,14 @@ public partial class ZoomContentControl { #region DependencyProperty: HorizontalOffset - /// Identifies the HorizontalOffset dependency property. + /// Identifies the HorizontalOffset dependency property. public static DependencyProperty HorizontalOffsetProperty { get; } = DependencyProperty.Register( nameof(HorizontalOffset), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double), OnHorizontalOffsetChanged)); - /// Gets or sets the horizontal offset for panning the content. + /// Gets or sets the horizontal offset for panning the content. public double HorizontalOffset { get => (double)GetValue(HorizontalOffsetProperty); @@ -55,15 +55,14 @@ public double HorizontalOffset #region DependencyProperty: HorizontalScrollValue - /// Identifies the HorizontalScrollValue dependency property. + /// Identifies the HorizontalScrollValue dependency property. public static DependencyProperty HorizontalScrollValueProperty { get; } = DependencyProperty.Register( nameof(HorizontalScrollValue), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the value of the horizontal scrollbar. - /// It's used to represent the scroll position within the scroll bar UI + /// Gets or sets the value of the horizontal scrollbar. It's used to represent the scroll position within the scroll bar UI. public double HorizontalScrollValue { get => (double)GetValue(HorizontalScrollValueProperty); @@ -74,14 +73,14 @@ public double HorizontalScrollValue #region DependencyProperty: HorizontalMinScroll - /// Identifies the HorizontalMinScroll dependency property. + /// Identifies the HorizontalMinScroll dependency property. public static DependencyProperty HorizontalMinScrollProperty { get; } = DependencyProperty.Register( nameof(HorizontalMinScroll), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the minimum horizontal scroll limit. + /// Gets or sets the minimum horizontal scroll limit. public double HorizontalMinScroll { get => (double)GetValue(HorizontalMinScrollProperty); @@ -92,14 +91,14 @@ public double HorizontalMinScroll #region DependencyProperty: HorizontalMaxScroll - /// Identifies the HorizontalMaxScroll dependency property. + /// Identifies the HorizontalMaxScroll dependency property. public static DependencyProperty HorizontalMaxScrollProperty { get; } = DependencyProperty.Register( nameof(HorizontalMaxScroll), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the maximum horizontal scroll limit. + /// Gets or sets the maximum horizontal scroll limit. public double HorizontalMaxScroll { get => (double)GetValue(HorizontalMaxScrollProperty); @@ -110,14 +109,14 @@ public double HorizontalMaxScroll #region DependencyProperty: HorizontalZoomCenter - /// Identifies the HorizontalZoomCenter dependency property. + /// Identifies the HorizontalZoomCenter dependency property. public static DependencyProperty HorizontalZoomCenterProperty { get; } = DependencyProperty.Register( nameof(HorizontalZoomCenter), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the horizontal center point for zooming. + /// Gets or sets the horizontal center point for zooming. public double HorizontalZoomCenter { get => (double)GetValue(HorizontalZoomCenterProperty); @@ -128,14 +127,14 @@ public double HorizontalZoomCenter #region DependencyProperty: VerticalOffset - /// Identifies the VerticalOffset dependency property. + /// Identifies the VerticalOffset dependency property. public static DependencyProperty VerticalOffsetProperty { get; } = DependencyProperty.Register( nameof(VerticalOffset), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double), OnVerticalOffsetChanged)); - /// Gets or sets the vertical offset for panning the content. + /// Gets or sets the vertical offset for panning the content. public double VerticalOffset { get => (double)GetValue(VerticalOffsetProperty); @@ -146,14 +145,14 @@ public double VerticalOffset #region DependencyProperty: VerticalMaxScroll - /// Identifies the VerticalMaxScroll dependency property. + /// Identifies the VerticalMaxScroll dependency property. public static DependencyProperty VerticalMaxScrollProperty { get; } = DependencyProperty.Register( nameof(VerticalMaxScroll), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the maximum vertical scroll limit. + /// Gets or sets the maximum vertical scroll limit. public double VerticalMaxScroll { get => (double)GetValue(VerticalMaxScrollProperty); @@ -164,14 +163,14 @@ public double VerticalMaxScroll #region DependencyProperty: VerticalMinScroll - /// Identifies the VerticalMinScroll dependency property. + /// Identifies the VerticalMinScroll dependency property. public static DependencyProperty VerticalMinScrollProperty { get; } = DependencyProperty.Register( nameof(VerticalMinScroll), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the minimum vertical scroll limit. + /// Gets or sets the minimum vertical scroll limit. public double VerticalMinScroll { get => (double)GetValue(VerticalMinScrollProperty); @@ -182,14 +181,14 @@ public double VerticalMinScroll #region DependencyProperty: VerticalZoomCenter - /// Identifies the VerticalZoomCenter dependency property. + /// Identifies the VerticalZoomCenter dependency property. public static DependencyProperty VerticalZoomCenterProperty { get; } = DependencyProperty.Register( nameof(VerticalZoomCenter), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the vertical center point for zooming. + /// Gets or sets the vertical center point for zooming. public double VerticalZoomCenter { get => (double)GetValue(VerticalZoomCenterProperty); @@ -200,14 +199,14 @@ public double VerticalZoomCenter #region DependencyProperty: ViewportWidth - /// Identifies the ViewportWidth dependency property. + /// Identifies the ViewportWidth dependency property. public static DependencyProperty ViewportWidthProperty { get; } = DependencyProperty.Register( nameof(ViewportWidth), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the width of the viewport. + /// Gets or sets the width of the viewport. public double ViewportWidth { get => (double)GetValue(ViewportWidthProperty); @@ -218,14 +217,14 @@ public double ViewportWidth #region DependencyProperty: ViewportHeight - /// Identifies the ViewportHeight dependency property. + /// Identifies the ViewportHeight dependency property. public static DependencyProperty ViewportHeightProperty { get; } = DependencyProperty.Register( nameof(ViewportHeight), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double))); - /// Gets or sets the height of the viewport. + /// Gets or sets the height of the viewport. public double ViewportHeight { get => (double)GetValue(ViewportHeightProperty); @@ -236,14 +235,14 @@ public double ViewportHeight #region DependencyProperty: ZoomLevel - /// Identifies the ZoomLevel dependency property. + /// Identifies the ZoomLevel dependency property. public static DependencyProperty ZoomLevelProperty { get; } = DependencyProperty.Register( nameof(ZoomLevel), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(1d, OnZoomLevelChanged)); - /// Gets or sets the current zoom level. + /// Gets or sets the current zoom level. public double ZoomLevel { get => (double)GetValue(ZoomLevelProperty); @@ -254,14 +253,14 @@ public double ZoomLevel #region DependencyProperty: MinZoomLevel - /// Identifies the MinZoomLevel dependency property. + /// Identifies the MinZoomLevel dependency property. public static DependencyProperty MinZoomLevelProperty { get; } = DependencyProperty.Register( nameof(MinZoomLevel), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(default(double), OnMinZoomLevelChanged)); - /// Gets or sets the minimum zoom level allowed. + /// Gets or sets the minimum zoom level allowed. public double MinZoomLevel { get => (double)GetValue(MinZoomLevelProperty); @@ -272,14 +271,14 @@ public double MinZoomLevel #region DependencyProperty: MaxZoomLevel - /// Identifies the MaxZoomLevel dependency property. + /// Identifies the MaxZoomLevel dependency property. public static DependencyProperty MaxZoomLevelProperty { get; } = DependencyProperty.Register( nameof(MaxZoomLevel), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(500d, OnMaxZoomLevelChanged)); - /// Gets or sets the maximum zoom level allowed. + /// Gets or sets the maximum zoom level allowed. public double MaxZoomLevel { get => (double)GetValue(MaxZoomLevelProperty); @@ -290,14 +289,14 @@ public double MaxZoomLevel #region DependencyProperty: PanWheelRatio - /// Identifies the PanWheelRatio dependency property. + /// Identifies the PanWheelRatio dependency property. public static DependencyProperty PanWheelRatioProperty { get; } = DependencyProperty.Register( nameof(PanWheelRatio), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(0.25d)); - /// Gets or sets the ratio used for panning with the mouse wheel. + /// Gets or sets the ratio used for panning with the mouse wheel. public double PanWheelRatio { get => (double)GetValue(PanWheelRatioProperty); @@ -308,14 +307,14 @@ public double PanWheelRatio #region DependencyProperty: ScaleWheelRatio - /// Identifies the ScaleWheelRatio dependency property. + /// Identifies the ScaleWheelRatio dependency property. public static DependencyProperty ScaleWheelRatioProperty { get; } = DependencyProperty.Register( nameof(ScaleWheelRatio), typeof(double), typeof(ZoomContentControl), new PropertyMetadata(0.0006d)); - /// Gets or sets the ratio used for scaling the zoom level with the mouse wheel. + /// Gets or sets the ratio used for scaling the zoom level with the mouse wheel. public double ScaleWheelRatio { get => (double)GetValue(ScaleWheelRatioProperty); @@ -326,14 +325,14 @@ public double ScaleWheelRatio #region DependencyProperty: IsActive - /// Identifies the IsActive dependency property. + /// Identifies the IsActive dependency property. public static DependencyProperty IsActiveProperty { get; } = DependencyProperty.Register( nameof(IsActive), typeof(bool), typeof(ZoomContentControl), new PropertyMetadata(true, OnIsActiveChanged)); - /// Gets or sets a value indicating whether the control is active. + /// Gets or sets a value indicating whether the control is active. public bool IsActive { get => (bool)GetValue(IsActiveProperty); @@ -344,14 +343,14 @@ public bool IsActive #region DependencyProperty: IsZoomAllowed - /// Identifies the IsZoomAllowed dependency property. + /// Identifies the IsZoomAllowed dependency property. public static DependencyProperty IsZoomAllowedProperty { get; } = DependencyProperty.Register( nameof(IsZoomAllowed), typeof(bool), typeof(ZoomContentControl), new PropertyMetadata(true)); - /// Gets or sets a value indicating whether zooming is allowed. + /// Gets or sets a value indicating whether zooming is allowed. public bool IsZoomAllowed { get => (bool)GetValue(IsZoomAllowedProperty); @@ -362,14 +361,14 @@ public bool IsZoomAllowed #region DependencyProperty: IsHorizontalScrollBarVisible - /// Identifies the IsHorizontalScrollBarVisible dependency property. + /// Identifies the IsHorizontalScrollBarVisible dependency property. public static DependencyProperty IsHorizontalScrollBarVisibleProperty { get; } = DependencyProperty.Register( nameof(IsHorizontalScrollBarVisible), typeof(bool), typeof(ZoomContentControl), new PropertyMetadata(true)); - /// Gets or sets a value indicating whether the horizontal scrollbar is visible. + /// Gets or sets a value indicating whether the horizontal scrollbar is visible. public bool IsHorizontalScrollBarVisible { get => (bool)GetValue(IsHorizontalScrollBarVisibleProperty); @@ -380,14 +379,14 @@ public bool IsHorizontalScrollBarVisible #region DependencyProperty: IsPanAllowed - /// Identifies the IsPanAllowed dependency property. + /// Identifies the IsPanAllowed dependency property. public static DependencyProperty IsPanAllowedProperty { get; } = DependencyProperty.Register( nameof(IsPanAllowed), typeof(bool), typeof(ZoomContentControl), new PropertyMetadata(true)); - /// Gets or sets a value indicating whether panning is allowed. + /// Gets or sets a value indicating whether panning is allowed. public bool IsPanAllowed { get => (bool)GetValue(IsPanAllowedProperty); @@ -398,14 +397,14 @@ public bool IsPanAllowed #region DependencyProperty: IsVerticalScrollBarVisible - /// Identifies the IsVerticalScrollBarVisible dependency property. + /// Identifies the IsVerticalScrollBarVisible dependency property. public static DependencyProperty IsVerticalScrollBarVisibleProperty { get; } = DependencyProperty.Register( nameof(IsVerticalScrollBarVisible), typeof(bool), typeof(ZoomContentControl), new PropertyMetadata(true)); - /// Gets or sets a value indicating whether the vertical scrollbar is visible. + /// Gets or sets a value indicating whether the vertical scrollbar is visible. public bool IsVerticalScrollBarVisible { get => (bool)GetValue(IsVerticalScrollBarVisibleProperty); @@ -416,14 +415,14 @@ public bool IsVerticalScrollBarVisible #region DependencyProperty: AutoZoomToCanvasOnSizeChanged - /// Identifies the AutoZoomToCanvasOnSizeChanged dependency property. + /// Identifies the AutoZoomToCanvasOnSizeChanged dependency property. public static DependencyProperty AutoZoomToCanvasOnSizeChangedProperty { get; } = DependencyProperty.Register( nameof(AutoZoomToCanvasOnSizeChanged), typeof(bool), typeof(ZoomContentControl), new PropertyMetadata(true)); - /// Gets or sets a value indicating whether the control should automatically zoom to fit the canvas when its size changes. + /// Gets or sets a value indicating whether the control should automatically zoom to fit the canvas when its size changes. public bool AutoZoomToCanvasOnSizeChanged { get => (bool)GetValue(AutoZoomToCanvasOnSizeChangedProperty); @@ -434,14 +433,14 @@ public bool AutoZoomToCanvasOnSizeChanged #region DependencyProperty: AdditionalMargin - /// Identifies the AdditionalMargin dependency property. + /// Identifies the AdditionalMargin dependency property. public static DependencyProperty AdditionalMarginProperty { get; } = DependencyProperty.Register( nameof(AdditionalMargin), typeof(Thickness), typeof(ZoomContentControl), new PropertyMetadata(new Thickness(0))); - /// Gets or sets additional margins around the content. + /// Gets or sets additional margins around the content. public Thickness AdditionalMargin { get => (Thickness)GetValue(AdditionalMarginProperty); @@ -452,14 +451,14 @@ public Thickness AdditionalMargin #region DependencyProperty: ContentBoundsVisibility - /// Identifies the ContentBoundsVisibility dependency property. + /// Identifies the ContentBoundsVisibility dependency property. public static DependencyProperty ContentBoundsVisibilityProperty { get; } = DependencyProperty.Register( nameof(ContentBoundsVisibility), typeof(BoundsVisibilityFlag), typeof(ZoomContentControl), new PropertyMetadata(BoundsVisibilityFlag.None)); - /// Gets or sets the visibility data for the content bounds. + /// Gets or sets the visibility data for the content bounds. public BoundsVisibilityFlag ContentBoundsVisibility { get => (BoundsVisibilityFlag)GetValue(ContentBoundsVisibilityProperty); diff --git a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.cs b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.cs index 3857e44ad..a74da89c9 100644 --- a/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.cs +++ b/src/Uno.Toolkit.UI/Controls/ZoomContentControl/ZoomContentControl.cs @@ -67,6 +67,10 @@ public ZoomContentControl() DefaultStyleKey = typeof(ZoomContentControl); Loaded += OnLoaded; SizeChanged += OnSizeChanged; + PointerPressed += OnPointerPressed; + PointerReleased += OnPointerReleased; + PointerMoved += OnPointerMoved; + PointerWheelChanged += OnPointerWheelChanged; } // Events @@ -216,7 +220,6 @@ T FindTemplatePart(string name) where T : class => ResetZoom(); RegisterToControlEvents(); - RegisterPointerHandlers(); } // Event handlers @@ -258,19 +261,6 @@ private void RegisterToControlEvents() } } - private void RegisterPointerHandlers() - { - PointerPressed -= OnPointerPressed; - PointerReleased -= OnPointerReleased; - PointerMoved -= OnPointerMoved; - PointerWheelChanged -= OnPointerWheelChanged; - - PointerPressed += OnPointerPressed; - PointerReleased += OnPointerReleased; - PointerMoved += OnPointerMoved; - PointerWheelChanged += OnPointerWheelChanged; - } - private void ScrollV_Scroll(object sender, ScrollEventArgs e) { if ((_previousVerticalScrollValue > e.NewValue && !CanScrollUp()) ||