protected virtual void OnClipperPaint(object sender, SKPaintSurfaceEventArgs e) { var canvas = e.Surface.Canvas; canvas.Clear(); ClippingGeometry = Element.Clip; if (ClippingGeometry == null) { return; } using (var paint = new SKPaint { IsAntialias = true, Style = SKPaintStyle.Fill, Color = SKColors.White }) { canvas.DrawPath(ClippingGeometry.ToSKPath(), paint); RealControl?.SetClipperCanvas(ClipperCanvas); if (_backgroundCanvas.IsValueCreated) { BackgroundCanvas.SetClipperCanvas(ClipperCanvas); } } }
async void UpdateSource(bool initialize) { if (initialize && Element.Source == default(ImageSource)) { return; } ImageSource source = Element.Source; ((IImageController)Element).SetIsLoading(true); if (RealControl != null) { bool success = await RealControl.LoadFromImageSourceAsync(source); if (!IsDisposed && success) { ((IVisualElementController)Element).PlatformSizeChanged(); UpdateAfterLoading(initialize); } } if (!IsDisposed) { ((IImageController)Element).SetIsLoading(false); } }
void UpdateAspect(bool initialize) { if (initialize && Element.Aspect == Aspect.AspectFit) { return; } RealControl.ApplyAspect(Element.Aspect); }
void UpdateRadius(bool init) { CornerRadius = Element.CornerRadius; int topLeft = Forms.ConvertToScaledPixel(Element.CornerRadius.TopLeft); int topRight = Forms.ConvertToScaledPixel(Element.CornerRadius.TopRight); int bottomLeft = Forms.ConvertToScaledPixel(Element.CornerRadius.BottomLeft); int bottomRight = Forms.ConvertToScaledPixel(Element.CornerRadius.BottomRight); if (!init) { RealControl.Draw(); } }
void UpdateFile(bool initialize) { if (initialize && Specific.GetFile(Element) == default || Element.Source != default(ImageSource)) { return; } if (RealControl != null) { bool success = RealControl.LoadFromFile(Specific.GetFile(Element)); if (!IsDisposed && success) { ((IVisualElementController)Element).PlatformSizeChanged(); UpdateAfterLoading(initialize); } } }
protected override void UpdateLayout() { base.UpdateLayout(); RealControl.Draw(Control.Geometry); }
protected override ESize Measure(int availableWidth, int availableHeight) { return(RealControl != null?RealControl.Measure(availableWidth, availableHeight) : base.Measure(availableHeight, availableHeight)); }