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:
62
Handlers/GraphicsViewHandler.cs
Normal file
62
Handlers/GraphicsViewHandler.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
using Microsoft.Maui.Handlers;
|
||||
using Microsoft.Maui.Graphics;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Microsoft.Maui.Platform.Linux.Handlers;
|
||||
|
||||
/// <summary>
|
||||
/// Handler for GraphicsView on Linux using Skia rendering.
|
||||
/// Maps IGraphicsView interface to SkiaGraphicsView platform view.
|
||||
/// IGraphicsView has: Drawable, Invalidate()
|
||||
/// </summary>
|
||||
public partial class GraphicsViewHandler : ViewHandler<IGraphicsView, SkiaGraphicsView>
|
||||
{
|
||||
public static IPropertyMapper<IGraphicsView, GraphicsViewHandler> Mapper = new PropertyMapper<IGraphicsView, GraphicsViewHandler>(ViewHandler.ViewMapper)
|
||||
{
|
||||
[nameof(IGraphicsView.Drawable)] = MapDrawable,
|
||||
[nameof(IView.Background)] = MapBackground,
|
||||
};
|
||||
|
||||
public static CommandMapper<IGraphicsView, GraphicsViewHandler> CommandMapper = new(ViewHandler.ViewCommandMapper)
|
||||
{
|
||||
[nameof(IGraphicsView.Invalidate)] = MapInvalidate,
|
||||
};
|
||||
|
||||
public GraphicsViewHandler() : base(Mapper, CommandMapper)
|
||||
{
|
||||
}
|
||||
|
||||
public GraphicsViewHandler(IPropertyMapper? mapper, CommandMapper? commandMapper = null)
|
||||
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SkiaGraphicsView CreatePlatformView()
|
||||
{
|
||||
return new SkiaGraphicsView();
|
||||
}
|
||||
|
||||
public static void MapDrawable(GraphicsViewHandler handler, IGraphicsView graphicsView)
|
||||
{
|
||||
if (handler.PlatformView is null) return;
|
||||
handler.PlatformView.Drawable = graphicsView.Drawable;
|
||||
}
|
||||
|
||||
public static void MapBackground(GraphicsViewHandler handler, IGraphicsView graphicsView)
|
||||
{
|
||||
if (handler.PlatformView is null) return;
|
||||
|
||||
if (graphicsView.Background is SolidPaint solidPaint && solidPaint.Color is not null)
|
||||
{
|
||||
handler.PlatformView.BackgroundColor = solidPaint.Color.ToSKColor();
|
||||
}
|
||||
}
|
||||
|
||||
public static void MapInvalidate(GraphicsViewHandler handler, IGraphicsView graphicsView, object? args)
|
||||
{
|
||||
handler.PlatformView?.Invalidate();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user