Table of Contents

Class Canvas

Namespace
DrawnUi.Views
Assembly
DrawnUi.Maui.dll

Optimized DrawnView having only one child inside Content property. Can autosize to to children size. For all drawn app put this directly inside the ContentPage as root view. If you put this inside some Maui control like Grid whatever expect more GC collections during animations making them somewhat less fluid.

[ContentProperty("Content")]
public class Canvas : DrawnView, INotifyPropertyChanged, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, IViewController, IVisualElementController, IElementController, IGestureController, IGestureRecognizers, IPropertyMapperView, IHotReloadableView, IReplaceableView, ILayout, ILayoutController, IContentView, IView, IElement, ITransform, IPadding, ICrossPlatformLayout, IDrawnBase, IDisposable, ICanBeUpdatedWithContext, ICanBeUpdated, IAnimatorsManager, IVisualTreeElement, IDisposeManager, IContainer, IList<IView>, ICollection<IView>, IEnumerable<IView>, IEnumerable, IGestureListener
Inheritance
Canvas
Implements
IGestureListener
Inherited Members
Extension Methods

Constructors

Canvas()

public Canvas()

Fields

ContentProperty

public static readonly BindableProperty ContentProperty

Field Value

BindableProperty

Context

protected DrawingContext Context

Field Value

DrawingContext

GesturesDebugColorProperty

public static readonly BindableProperty GesturesDebugColorProperty

Field Value

BindableProperty

GesturesProperty

public static readonly BindableProperty GesturesProperty

Field Value

BindableProperty

LineBreaks

protected List<int> LineBreaks

Field Value

List<int>

ReserveSpaceAroundProperty

public static readonly BindableProperty ReserveSpaceAroundProperty

Field Value

BindableProperty

Properties

AttachedTouchEffect

protected TouchEffect AttachedTouchEffect { get; set; }

Property Value

TouchEffect

Content

public ISkiaControl Content { get; set; }

Property Value

ISkiaControl

ContentSize

public ScaledSize ContentSize { get; protected set; }

Property Value

ScaledSize

DebugPointer

protected SkiaSvg DebugPointer { get; set; }

Property Value

SkiaSvg

DelayNanosBetweenGC

public static long DelayNanosBetweenGC { get; set; }

Property Value

long

Gestures

public GesturesMode Gestures { get; set; }

Property Value

GesturesMode

GesturesDebugColor

public Color GesturesDebugColor { get; set; }

Property Value

Color

HadInput

Have consumed input in previous or current pass. To notify them about UP (release) even if they don't get it via touch.

public Dictionary<Guid, ISkiaGestureListener> HadInput { get; }

Property Value

Dictionary<Guid, ISkiaGestureListener>

HasHover

Exchange point to set itsself or read who has hover

public SkiaControl HasHover { get; set; }

Property Value

SkiaControl

ReceivedInput

Got input during current pass

public HashSet<ISkiaGestureListener> ReceivedInput { get; }

Property Value

HashSet<ISkiaGestureListener>

ReserveSpaceAround

public Thickness ReserveSpaceAround { get; set; }

Property Value

Thickness

TimeLastGC

public static long TimeLastGC { get; set; }

Property Value

long

Methods

AdaptHeightContraintToContentRequest(float, ScaledSize, double)

public float AdaptHeightContraintToContentRequest(float heightConstraintUnits, ScaledSize measuredContent, double sideConstraintsUnits)

Parameters

heightConstraintUnits float
measuredContent ScaledSize
sideConstraintsUnits double

Returns

float

AdaptHeightContraintToRequest(double)

public float AdaptHeightContraintToRequest(double heightConstraint)

Parameters

heightConstraint double

Returns

float

AdaptSizeRequestToContent(double, double)

In UNITS

protected Size AdaptSizeRequestToContent(double widthRequest, double heightRequest)

Parameters

widthRequest double
heightRequest double

Returns

Size

AdaptSizeToContentIfNeeded(double, double, bool)

protected Size AdaptSizeToContentIfNeeded(double widthConstraint, double heightConstraint, bool force = false)

Parameters

widthConstraint double
heightConstraint double
force bool

Returns

Size

AdaptWidthContraintToContentRequest(float, ScaledSize, double)

public float AdaptWidthContraintToContentRequest(float widthConstraintUnits, ScaledSize measuredContent, double sideConstraintsUnits)

Parameters

widthConstraintUnits float
measuredContent ScaledSize
sideConstraintsUnits double

Returns

float

AdaptWidthContraintToRequest(double)

public float AdaptWidthContraintToRequest(double widthConstraint)

Parameters

widthConstraint double

Returns

float

ArrangeOverride(Rect)

We need this mainly to autosize inside grid cells This is also called when parent visibilty changes

protected override Size ArrangeOverride(Rect bounds)

Parameters

bounds Rect

Returns

Size

BreakLine()

public void BreakLine()

CollectGarbage(long)

public static void CollectGarbage(long timeNanos)

Parameters

timeNanos long

CreateDebugPointer()

protected virtual SkiaSvg CreateDebugPointer()

Returns

SkiaSvg

DetachGestures()

protected virtual void DetachGestures()

DisableUpdates()

Disable invalidating and drawing on the canvas

public virtual void DisableUpdates()

Draw(DrawingContext)

protected override void Draw(DrawingContext context)

Parameters

context DrawingContext

DumpDebug()

public void DumpDebug()

EnableUpdates()

Enable canvas rendering itsself

public virtual void EnableUpdates()

FindViewCoordinatesRecursive(SkiaControl, SkiaControl, SKPoint)

protected virtual SKPoint? FindViewCoordinatesRecursive(SkiaControl current, SkiaControl target, SKPoint pointInCurrent)

Parameters

current SkiaControl
target SkiaControl
pointInCurrent SKPoint

Returns

SKPoint?

GetGesturePositionInsideControl(SkiaControl, SKPoint)

Returns the point in the local coordinate system of the view (relative to its Top/Left). This works for any view on the canvas, even if it is not a direct child of this control. It recursively traverses the visual tree to find the view and calculates the coordinates taking into account all transforms and scroll offsets along the path. Returns points (DIPs).

public virtual SKPoint GetGesturePositionInsideControl(SkiaControl view, SKPoint screenPointPixels)

Parameters

view SkiaControl
screenPointPixels SKPoint

Returns

SKPoint

GetMeasuringRectForChildren(float, float, float)

All in in UNITS, OUT in PIXELS

public SKRect GetMeasuringRectForChildren(float widthConstraint, float heightConstraint, float scale)

Parameters

widthConstraint float
heightConstraint float
scale float

Returns

SKRect

Invalidate()

Makes the control dirty, in need to be remeasured and rendered but this doesn't call Update, it's up yo you

public override void Invalidate()

InvalidateMeasure()

Marks the current measure of an element as invalidated.

protected override void InvalidateMeasure()

IsSavedGesture(TouchActionResult)

Define if consuming this gesture will register child inside HadInput

protected bool IsSavedGesture(TouchActionResult type)

Parameters

type TouchActionResult

Returns

bool

LayoutVisibilityChanged()

public virtual void LayoutVisibilityChanged()

Measure(float, float)

public override ScaledSize Measure(float widthConstraintPts, float heightConstraintPts)

Parameters

widthConstraintPts float
heightConstraintPts float

Returns

ScaledSize

MeasureChild(SkiaControl, double, double, double)

PIXELS

protected ScaledSize MeasureChild(SkiaControl child, double availableWidth, double availableHeight, double scale)

Parameters

child SkiaControl
availableWidth double
availableHeight double
scale double

Returns

ScaledSize

MeasureOverride(double, double)

Allows subclasses to implement custom Measure logic during a controls measure pass.

protected override Size MeasureOverride(double widthConstraint, double heightConstraint)

Parameters

widthConstraint double

The width constraint to request.

heightConstraint double

The height constraint to request.

Returns

Size

The requested size that an element wants in order to be displayed on the device.

OnChildAdded(SkiaControl)

protected override void OnChildAdded(SkiaControl child)

Parameters

child SkiaControl

OnDestroyingVew()

protected override void OnDestroyingVew()

OnDisposing()

public override void OnDisposing()

OnGestureEvent(TouchActionType, TouchActionEventArgs, TouchActionResult)

IGestureListener implementation

public virtual void OnGestureEvent(TouchActionType type, TouchActionEventArgs args1, TouchActionResult touchAction)

Parameters

type TouchActionType
args1 TouchActionEventArgs
touchAction TouchActionResult

OnGesturesAttachChanged()

protected virtual void OnGesturesAttachChanged()

OnHandlerChanged()

When overridden in a derived class, should raise the HandlerChanged event.

protected override void OnHandlerChanged()

Remarks

It is the implementor's responsibility to raise the HandlerChanged event.

OnHandlerChanging(HandlerChangingEventArgs)

When overridden in a derived class, should raise the HandlerChanging event.

protected override void OnHandlerChanging(HandlerChangingEventArgs args)

Parameters

args HandlerChangingEventArgs

Provides data for the HandlerChanging event.

Remarks

It is the implementor's responsibility to raise the HandlerChanging event.

OnParentChanged()

When overridden in a derived class, should raise the ParentChanged event.

protected override void OnParentChanged()

Remarks

It is the implementor's responsibility to raise the ParentChanged event.

OnPropertyChanged(string)

Method that is called when a bound property is changed.

protected override void OnPropertyChanged(string propertyName = null)

Parameters

propertyName string

The name of the bound property that changed.

OnSizeChanged()

protected override void OnSizeChanged()

PlayRippleAnimation(Color, double, double, bool)

public void PlayRippleAnimation(Color color, double x, double y, bool removePrevious = true)

Parameters

color Color
x double
y double
removePrevious bool

PlayShimmerAnimation(Color, float, float, int, bool)

public void PlayShimmerAnimation(Color color, float shimmerWidth, float shimmerAngle, int speedMs = 1000, bool removePrevious = false)

Parameters

color Color
shimmerWidth float
shimmerAngle float
speedMs int
removePrevious bool

ProcessGestures(SkiaGesturesParameters)

protected virtual void ProcessGestures(SkiaGesturesParameters args)

Parameters

args SkiaGesturesParameters

SetChildren(IEnumerable<SkiaControl>)

public override void SetChildren(IEnumerable<SkiaControl> views)

Parameters

views IEnumerable<SkiaControl>

SetContent(SkiaControl)

Use Content property for direct access

protected virtual void SetContent(SkiaControl view)

Parameters

view SkiaControl

SignalInput(ISkiaGestureListener, TouchActionResult)

Gets signal from a listener that in has processed gestures. Return false if should not process gestures.

public bool SignalInput(ISkiaGestureListener listener, TouchActionResult gestureType)

Parameters

listener ISkiaGestureListener
gestureType TouchActionResult

Returns

bool

Events

Tapped

public event EventHandler Tapped

Event Type

EventHandler