protected SizeF GetIntrinsicSize(float defaultWidth = 100, float defaultHeight = 44) { var minHeight = TypedVirtualView.GetEnvironment <float?>(SkiaEnvironmentKeys.IntrinsicSize.Height) ?? defaultHeight; var minWidth = TypedVirtualView.GetEnvironment <float?>(SkiaEnvironmentKeys.IntrinsicSize.Width) ?? defaultWidth; return(new SizeF(minWidth, minHeight)); }
protected override void DrawBackground(SKCanvas canvas, Color defaultBackgroundColor, RectangleF dirtyRect) { var defaultColor = TypedVirtualView.GetBackgroundColor(Color.Transparent, state: ControlState.Default); Color calculateDefaultBackgroundColor() { var c = defaultColor; c = CurrentState switch { ControlState.Disabled => c.Lerp(Color.Grey, .5), ControlState.Hovered => c.Lerp(Color.Grey, .1), ControlState.Pressed => c.Lerp(Color.Grey, .5), _ => c }; return(c); }; var backgroundColor = TypedVirtualView.GetBackgroundColor(state: CurrentState) ?? calculateDefaultBackgroundColor(); var radius = (this).GetEnvironment <float>(accentRadius); if (radius <= 0 || radius >= 1) { base.DrawBackground(canvas, defaultColor, dirtyRect); base.DrawBackground(canvas, backgroundColor, dirtyRect); return; } base.DrawBackground(canvas, defaultColor, dirtyRect); var paint = new SKPaint(); paint.Color = backgroundColor.ToSKColor(); var circleRadius = 5f.Lerp(Math.Max(dirtyRect.Width, dirtyRect.Height) * 2f, radius); canvas.DrawCircle(animationPoint, circleRadius, paint); }
public override void DragInteraction(PointF[] points) { base.DragInteraction(points); if (!isTracking) { return; } //Only track the first point; var point = points[0]; var percent = (point.X - TrackRect.X) / TrackRect.Width; TypedVirtualView.PercentChanged(percent); }
public virtual void DrawThumb(SKCanvas canvas, float progress, float hSpace, RectangleF rectangle) { using var paint = new SKPaint(); var fillColor = TypedVirtualView.GetThumbColor(defaultThumbColor, CurrentState).ToSKColor(); ThumbRect.X = (rectangle.Width - (hSpace * 2) - ThumbRect.Width) * progress + hSpace; ThumbRect.Y = rectangle.Y + (rectangle.Height - ThumbRect.Height) / 2; TouchTargetRect.Center(ThumbRect.Center()); var knobRect = ThumbRect.ToSKRect(); using var knobPath = new SKPath(); knobPath.Reset(); knobPath.AddOval(knobRect, SKPathDirection.Clockwise); paint.Reset(); paint.IsAntialias = true; paint.Style = SKPaintStyle.Fill; paint.Color = fillColor; canvas.DrawPath(knobPath, paint); }
public virtual void DrawProgress(SKCanvas canvas, float progress, float hSpace, RectangleF rectangle) { using var paint = new SKPaint(); var fillColor = TypedVirtualView.GetProgressColor(defaultProgressColor, CurrentState).ToSKColor(); var width = (rectangle.Width - (hSpace * 2)) * progress; var height = defaultHeight; var y = rectangle.Y + ((rectangle.Height - height) / 2); var highlightRect = new RectangleF(hSpace, y, width, height).ToSKRect(); var trackRect = highlightRect; using var trackPath = new SKPath(); trackPath.Reset(); trackPath.AddRoundRect(trackRect, 1f, 1f, SKPathDirection.Clockwise); paint.Reset(); paint.IsAntialias = true; paint.Style = SKPaintStyle.Fill; paint.Color = fillColor; canvas.DrawPath(trackPath, paint); }
public virtual void DrawTrack(SKCanvas canvas, float hSpace, RectangleF rectangle) { using var paint = new SKPaint(); var fillColor = TypedVirtualView.GetTrackColor(defaultTrackColor, CurrentState).ToSKColor(); TrackRect.Width = rectangle.Width - (hSpace * 2); TrackRect.Height = defaultHeight; TrackRect.Y = rectangle.Y + ((rectangle.Height - TrackRect.Height) / 2); TrackRect.X = hSpace; var highlightRect = TrackRect.ToSKRect(); //var highlightRect = rectangle.ApplyPadding(new Thickness(hSpace, vSpace)).ToSKRect(); using var highlightPath = new SKPath(); highlightPath.Reset(); highlightPath.AddRoundRect(highlightRect, 1f, 1f, SKPathDirection.Clockwise); paint.Reset(); paint.IsAntialias = true; paint.Style = SKPaintStyle.Fill; paint.Color = fillColor; canvas.DrawPath(highlightPath, paint); }
public override string AccessibilityText() => (TypedVirtualView?.GetPercent() ?? 0).ToString("P");