Table of Contents

Class ZoomContent

Namespace
DrawnUi.Draw
Assembly
DrawnUi.Maui.dll

Wrapper to zoom and pan content by changing the rendering scale so not affecting quality, this is not a transform.

DEBUG INSTRUCTIONS:

  • Key debug outputs are enabled for pan movements and clamp operations
  • Call DumpDebugState() manually to get a full state dump
  • Uncomment debug sections in DrawViews, MeasureContent, ComputeContentScale for frame-by-frame debugging
  • Watch for [ClampOffsetImage] CLAMPED! messages to see when pan limits are hit
  • The DebugSummary provides comprehensive state when hitting pan limits
public class ZoomContent : ContentLayout, INotifyPropertyChanged, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, IVisualElementController, IElementController, IView, ITransform, IElement, IVisualTreeElement, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, IHasAfterEffects, ISkiaDisposable, ISkiaGridLayout, ISkiaLayout, ISkiaControl, IDrawnBase, ICanBeUpdatedWithContext, ICanBeUpdated, ILayoutInsideViewport, IInsideViewport, IDisposable, IVisibilityAware, IWithContent, ISkiaGestureListener
Inheritance
ZoomContent
Implements
Inherited Members
Extension Methods

Constructors

ZoomContent()

public ZoomContent()

Fields

ContentScaledRect

protected SKRect ContentScaledRect

Field Value

SKRect

InvertPanProperty

public static readonly BindableProperty InvertPanProperty

Field Value

BindableProperty

LastValue

Last ViewportZoom value we are animating from

protected double LastValue

Field Value

double

OffsetImage

Pan offset in screen/pixel coordinates

protected SKPoint OffsetImage

Field Value

SKPoint

PanSpeedProperty

public static readonly BindableProperty PanSpeedProperty

Field Value

BindableProperty

PanningModeProperty

public static readonly BindableProperty PanningModeProperty

Field Value

BindableProperty

Value

protected double Value

Field Value

double

ViewportZoomProperty

public static readonly BindableProperty ViewportZoomProperty

Field Value

BindableProperty

ZoomLockedProperty

public static readonly BindableProperty ZoomLockedProperty

Field Value

BindableProperty

ZoomMaxProperty

public static readonly BindableProperty ZoomMaxProperty

Field Value

BindableProperty

ZoomMinProperty

public static readonly BindableProperty ZoomMinProperty

Field Value

BindableProperty

ZoomSpeedProperty

public static readonly BindableProperty ZoomSpeedProperty

Field Value

BindableProperty

_animatorValue

protected RangeAnimator _animatorValue

Field Value

RangeAnimator

_panStarted

protected PointF _panStarted

Field Value

PointF

Properties

InvertPan

When false (default), panning centers the zoom on the finger position (finger "sticks" to content). When true, panning moves the content like a scroll view (content moves in same direction as finger).

public bool InvertPan { get; set; }

Property Value

bool

PanSpeed

public double PanSpeed { get; set; }

Property Value

double

PanningMode

public PanningModeType PanningMode { get; set; }

Property Value

PanningModeType

ViewportZoom

public double ViewportZoom { get; set; }

Property Value

double

ZoomLocked

public bool ZoomLocked { get; set; }

Property Value

bool

ZoomMax

public double ZoomMax { get; set; }

Property Value

double

ZoomMin

public double ZoomMin { get; set; }

Property Value

double

ZoomSpeed

How much of finger movement will affect zoom change

public double ZoomSpeed { get; set; }

Property Value

double

Methods

ComputeContentScale(SKRect, float, SKPoint)

Computes the scaled destination rectangle and scale for content rendering. OffsetImage is expected to be in screen/pixel coordinates relative to the viewport.

public (SKRect ScaledDestination, float Scale) ComputeContentScale(SKRect destination, float scale, SKPoint offsetPixels)

Parameters

destination SKRect
scale float
offsetPixels SKPoint

Returns

(SKRect ScaledDestination, float Scale)

DrawViews(DrawingContext)

Base method will call RenderViewsList. Return number of drawn views.

protected override int DrawViews(DrawingContext context)

Parameters

context DrawingContext

Returns

int

InitializeAnimator()

protected void InitializeAnimator()

OnBindingContextChanged()

First Maui will apply bindings to your controls, then it would call OnBindingContextChanged, so beware on not to break bindings.

protected override void OnBindingContextChanged()

ProcessGestures(SkiaGesturesParameters, GestureEventProcessingInfo)

public override ISkiaGestureListener ProcessGestures(SkiaGesturesParameters args, GestureEventProcessingInfo apply)

Parameters

args SkiaGesturesParameters
apply GestureEventProcessingInfo

Returns

ISkiaGestureListener

Reset()

public void Reset()

ScalePixels(float)

protected float ScalePixels(float value)

Parameters

value float

Returns

float

ScalePoints(double)

protected float ScalePoints(double value)

Parameters

value double

Returns

float

SetZoom(double, bool)

public void SetZoom(double zoom, bool animate)

Parameters

zoom double
animate bool