Initial commit: .NET MAUI Linux Platform
Complete Linux platform implementation for .NET MAUI with:
- 35+ Skia-rendered controls (Button, Label, Entry, CarouselView, etc.)
- Platform services (Clipboard, FilePicker, Notifications, DragDrop, etc.)
- Accessibility support (AT-SPI2, High Contrast)
- HiDPI and Input Method support
- 216 unit tests
- CI/CD workflows
- Project templates
- Documentation
🤖 Generated with Claude Code
This commit is contained in:
65
Views/SkiaGraphicsView.cs
Normal file
65
Views/SkiaGraphicsView.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user