Files
Dave Friedel 2a4e35cd39 Fix compilation: restore clean RC1 codebase
- Restore clean BindableProperty.Create syntax from RC1 commit
- Remove decompiler artifacts with mangled delegate types
- Add Svg.Skia package reference for icon support
- Fix duplicate type definitions
- Library now compiles successfully (0 errors)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 07:43:44 -05:00

66 lines
1.8 KiB
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using SkiaSharp;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Graphics.Skia;
namespace Microsoft.Maui.Platform;
/// <summary>
/// Skia-rendered graphics view that supports IDrawable for custom drawing.
/// </summary>
public class SkiaGraphicsView : SkiaView
{
private IDrawable? _drawable;
public IDrawable? Drawable
{
get => _drawable;
set
{
_drawable = value;
Invalidate();
}
}
protected override void OnDraw(SKCanvas canvas, SKRect bounds)
{
// Draw background
if (BackgroundColor != SKColors.Transparent)
{
using var bgPaint = new SKPaint
{
Color = BackgroundColor,
Style = SKPaintStyle.Fill
};
canvas.DrawRect(bounds, bgPaint);
}
// Draw using IDrawable
if (_drawable != null)
{
var dirtyRect = new RectF(bounds.Left, bounds.Top, bounds.Width, bounds.Height);
using var skiaCanvas = new SkiaCanvas();
skiaCanvas.Canvas = canvas;
_drawable.Draw(skiaCanvas, dirtyRect);
}
}
protected override SKSize MeasureOverride(SKSize availableSize)
{
// Graphics view takes all available space by default
if (availableSize.Width < float.MaxValue && availableSize.Height < float.MaxValue)
{
return availableSize;
}
// Return a reasonable default size
return new SKSize(
availableSize.Width < float.MaxValue ? availableSize.Width : 100,
availableSize.Height < float.MaxValue ? availableSize.Height : 100);
}
}