/dotnet:uifrom dotnet
Use when drawing or hosting .NET UI, covering Skia surfaces, shaped text, vector art, color, and Eto controls
Ships in dotnet. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Drawn and hosted .NET UI from pixel contracts to platform handlers. Resolve Eto members from the assembly loaded by the host.
[REFERENCES]:
Drawn surfaces sit where no native control can (viewport overlay, plot, tile gallery, color or curve editor, manipulated handle), every other control is the host's and owns accessibility, IME, undo, focus order, and theme:
| [INDEX] | [NEED] | [FORM] |
|---|---|---|
| [01] | Text and number entry | TextBox, TextArea, NumericStepper, host unit-parsing field |
| [02] | Captions, readouts, row labels | Label cells in a TableLayout |
| [03] | Lists, trees, grids | TreeGridView, GridView with CellFormatting for emphasis |
| [04] | Sections, tabs, panes, progress | Expander, TabControl, Splitter, ProgressBar |
| [05] | Actions in menus, toolbars, popups | One Command into MenuBar, ToolBar, ContextMenu |
| [06] | Toolbar in a panel or window | Eto ToolBar, a drawn toolbar stands over a viewport alone |
| [07] | Overlay, gallery, plot, swatch or curve editor | Drawable holding one scene |
PixelLayout the scene moves on each reconcileTextBox, a drawn editor stands only in an overlay no native field can enterErrors.CancelledThemeChanged as a FinSKColorF, SystemColors.Highlight supplies an accent where a host exposes no accent settingAssembly.GetManifestResourceNames(), a <name>_darkmode resource beside <name> selects by themeOne surface type per scene owns its pixels and its SKImageInfo contract (device size, SKColorType, SKAlphaType.Premul, SKColorSpace) fixed before the first draw. Host adapters forward input and blit a snapshot:
SKCanvasSKSurface.Create answers null for an info its backend refuses, an allocation returns a Fault under Reason.Refused naming the infoSKSurface.Create(info, pixels, rowBytes, releaseProc, context) draws into host memory and releases it with the surface, one object owns bothSKPixmap(info, pointer, rowBytes) views host bits without a copy, SKSurface.Create(pixmap, props) draws into themFlush(submit: true) submits GPU work, a raster surface draws synchronously and a Flush on it does nothingReadPixelsSnapshot() runs once per frame after its last draw, a snapshot alive during a later draw forces Skia to copy the surfaceColorSpace left null disables conversion for every source, a null source is read as sRGBSKColorSpacePrimaries.ToColorSpaceXyz(out toXyzD50), a D65-relative matrix tags the wrong whiteSKColorType.RgbaF16 tagged SKColorSpace.CreateSrgbLinear(), values past 1.0 survive until the display blitColorSpace and ColorType together, an 8-bit target clips bothSKImage.FromPixelCopy per content change, owned and disposed by their producerSKPixmap.ReadPixels, an SKImage and SKBitmap round trip restates itScale(scale) once per frame maps logical units, strokes and font sizes stay logicalSKRegion through Op(rect, SKRegionOperation.Union), ClipRegion restricts the repaint, SetEmpty closes the frameSKRectI.Ceiling(rect, outwards: true) bounds damage and clips, SKRectI.Round(rect) places a frame, hand floors and ceils restate themClipRegion is device space and ignores the matrix, the damage clip precedes ScaleQuickReject(rect) tests transformed geometry against the clip and skips a draw before its paint is builtSKSurfaceProperties(SKPixelGeometry) enables LCD text on an opaque surface, a cleared transparent surface takes grayscale edgingIsUseDeviceIndependentFonts selects no hinting and PixelGeometry.Unknown grayscale edgingMapRect sizes a layer by contentinternal sealed class Frame : IDisposable {
private readonly SKSurface surface;
private readonly SKRegion damage;
private Frame(SKSurface surface, SKImageInfo info) {
this.surface = surface;
damage = new SKRegion(info.Rect);
}
public static Fin<Frame> Allocated(SKImageInfo info, SKSurfaceProperties properties) =>
Surfaced(info, () => SKSurface.Create(info, properties)).Map(made => new Frame(made, info));
private static Fin<SKSurface> Surfaced(SKImageInfo info, Func<SKSurface> create) =>
Optional(create()).ToFin(Fault.Of(Reason.Refused, (info.Width, info.Height, info.ColorType)));
public void Damage(SKRect logical, float scale) =>
damage.Op(SKRectI.Ceiling(SKMatrix.CreateScale(scale, scale).MapRect(logical), outwards: true), SKRegionOperation.Union);
public SKImage Paint(Action<SKCanvas> draw, float scale) {
using (SKAutoCanvasRestore scope = new(surface.Canvas, doSave: true)) {
surface.Canvas.ClipRegion(damage);
surface.Canvas.Scale(scale);
draw(surface.Canvas);
}
damage.SetEmpty();
return surface.Snapshot();
}
public void Dispose() {
damage.Dispose();
surface.Dispose();
}
}
Paints are style objects built once, every effect on one is a reference-counted handle the building scope owns, and a draw loop allocates nothing:
SKRect, SKRoundRect, SKRegion, and SKMatrix, a record of four edges or nine cells restates one and loses its membersSKRoundRect or SKPath) per layout feeds fill, stroke, clip, shadow, focus ring, backdrop, and Contains hit testDeflate), corners stay concentric where a path offset distortsSKRoundRect.SetRectRadii scales over-long radii itself, Inflate and Deflate grow a rim or spread, a hand fit or offset restates themSKPathEffect.CreateCorner rounds with circular arcsSKMatrix.TryInvert runs once per matrix change and the inverse is held, a fresh inverse per mapped point pays the inversion per pointSaveLayer(limit, paint) serves group alpha, a blend mode over a group, or an image filterSKCanvasSaveLayerRecFlags.PreserveLcdText is set, grayscale edging inside layers avoids the mismatchSKCanvasSaveLayerRec.Backdrop filters what the live canvas already holds, inside a picture or offscreen it filters that recording aloneSKImageFilter graph per shadow, built once per (shadow, color) and applied through a bounded layer around the outline drawSrcIn), a renderer per case restates the graphCreateBlendMode(SrcIn) clip the result to its shapeCreateDilate and CreateErode grow square cornersSKMaskFilter.ConvertRadiusToSigma maps a radius and SKMatrix.MapRadius scales a sigma under the transformSKImage.ApplyImageFilter runs offline on the CPU with the CTM lostCreateDropShadowOnly and SKColorFilter.CreateBlendMode quantize to SKColor, a float color enters CreateColorMatrix in its last columnSKPaint.GetFastBounds over the filter handle answers a filtered draw's reachClipRoundRect costs less than ClipPath over one shape, antialias: true buys a coverage mask, a device-snapped rect clips without oneIsDither removes 8-bit banding in gradientsSKRuntimeEffect.BuildShader into a static builder, each use binds its own uniforms and children into Effect.ToShaderWithLocalMatrix on a built shader makes a second handle per useSKPictureRecorder.BeginRecording(cullRect, useRTree: true) and replay per frameSKImage.FromPicture rasterizes a picture when replay cost leadsDstIn gradient over the children's layer, one SaveLayer per faded containerSKBlendMode.Clear, the host control fills the holeSKPathEffect.CreateDash rhythms scaled by the pen width, one effect per series per layoutSKColorF grows per frameinternal sealed class Outline : IDisposable {
private readonly SKRoundRect shape;
private readonly SKRoundRect rim;
private readonly SKPath path;
public Outline(SKRect frame, float radius, float strokeWidth) {
shape = new SKRoundRect(frame, radius);
rim = new SKRoundRect(shape);
rim.Deflate(strokeWidth / 2f, strokeWidth / 2f);
using SKPathBuilder builder = new();
builder.AddRoundRect(shape);
path = builder.Detach();
}
public void Fill(SKCanvas canvas, SKPaint paint) => canvas.DrawRoundRect(shape, paint);
public void Stroke(SKCanvas canvas, SKPaint paint) => canvas.DrawRoundRect(rim, paint);
public void Clip(SKCanvas canvas) => canvas.ClipRoundRect(shape, antialias: true);
public bool Hit(SKPoint point) => path.Contains(point.X, point.Y);
public void Dispose() {
path.Dispose();
rim.Dispose();
shape.Dispose();
}
}
internal readonly record struct Vignette(SKSize Size, SKColorF Tint) {
private const string Source = $$"""uniform float2 {{nameof(Size)}}; layout(color) uniform half4 {{nameof(Tint)}}; half4 main(float2 p) { float2 q = p / {{nameof(Size)}} - 0.5; half4 c = {{nameof(Tint)}} * half(dot(q, q)); return half4(c.rgb * c.a, c.a); }""";
private static readonly SKRuntimeShaderBuilder Builder = SKRuntimeEffect.BuildShader(Source);
public SKShader Build(SKMatrix placement) {
using SKRuntimeEffectUniforms uniforms = new(Builder.Effect) { [nameof(Size)] = Size, [nameof(Tint)] = Tint };
using SKRuntimeEffectChildren children = new(Builder.Effect);
return Builder.Effect.ToShader(uniforms, children, placement);
}
}
Vector art loads once through Svg.Skia into an SKPicture and draws at any scale, tint and theme enter at load, and the loader runs at realization off the paint path:
SvgService.Open(stream, parameters) parses one document, SKSvg.ToPicture(fragment, model, loader) renders it through a shared SkiaModelSkiaModel(SKSvgSettings) and SkiaSvgAssetLoader(model) build once per target, SKSvgSettings.Srgb and SrgbLinear hold its SKColorSpaceSKSvg.CreateFromStream(stream, parameters) parses and renders with its own model and loader into Picture, one instance per documentSKSvg.ReLoad(parameters) rebuilds from the kept source when the static SKSvg.CacheOriginalStream is set, and throws otherwiseSKSvg.Draw(canvas, fragment, model, loader) paints a document with no picture kept, a one-shot export takes itSvgParameters(Entities, Css, CurrentColor, LoadOptions) fills XML entities and injects a stylesheet before renderCurrentColor resolves currentColor to a System.Drawing.ColorCurrentColor at loadSKShader.CreatePicture under CreateColorFilter(CreateColorMatrix), one shader per (asset, tint) drawn as a rectSKColorFilter.CreateBlendMode(tint, SrcIn) quantizes the tint to 8 bits, and a paint on DrawPicture opens a layer per drawSKSvgSettings.TypefaceProviders resolves fonts named in art, StandaloneViewport resolves percentage sizes of a root with no viewportSKImage.FromPicture(picture, size)SKImage.FromPicture tags sRGB alone, an F16 or wide-gamut raster of a picture draws it on an explicit surfaceSvgService.GetDimensions(fragment, viewport) reads intrinsic size and viewBox, the viewport resolves percentage sizesHitTestElements(point, canvasMatrix) and HitTestTopmostElement(point, canvasMatrix) hit test loaded art on an SKSvgFault with the asset as subject under Reason.Missing, Unparsed, or Empty, a throw at paint stops the frameIcon(scale, bitmap), the previous icon is disposed on retheme, no PNG round tripUnicolour states every color fact at design scale (swatch, palette, theme color, LUT bake) under one Configuration. Skia receives SKColorF with an SKColorSpace, a pixel pass bakes a matrix or curve once:
Configuration(rgbConfig, xyzConfig, ybrConfig, camConfig, dynamicRange, iccConfig) fixes primaries, transfer, white, adaptation, viewing, rangeConfiguration.Default is sRGB under D65 with ChromaticAdaptation.BradfordConvertToConfiguration adapts the white point and re-encodes under the target primariesRgbConfiguration.StandardRgb, DisplayP3, Rec2020, Rec2100Pq, Rec2100Hlg, Acescg hold primaries, white, and transferRgbConfiguration.ToLinear and FromLinear are Func<double, DynamicRange, double>DynamicRange.Standard and High set the luminance PQ and HLG encode againstUnicolour constructs from a ColourSpace triplet, a hex string, Chromaticity with luminance, a CCT with Locus, a Temperature, or an SpdBlend(backdrop, BlendMode) composites, Palette(other, space, count) returns a rampMix(other, ColourSpace.Oklch, amount, HueSpan) interpolates one stepPalette at style time indexed per frame, a Mix per frame allocates per hovered colorContrast(other) is the WCAG ratio, a legibility floor lifts Oklch.L until the ratio holds and keeps hue and chromaOklch.L of the window fill below the window text, a host flag restates itDifference(reference, DeltaE.Ok) orders perceptual distance, Ciede2000 and Itp serve print and HDRMapToRgbGamut(GamutMap.OklchChromaReduction) keeps hue and lightness, RgbClipping shifts both, WxyPurityReduction keeps dominant wavelengthIsInRgbGamut tests before a bakeTemperature on an instance answers Cct and Duv with IsValid within the locus distanceSimulate(Cvd, severity) previews deficiencyColourmaps.Viridis.Map(x) and Palette(count) sample a perceptual map from Wacton.Unicolour.DatasetsCss.FromName(name) answers a named color or null, Css.All lists the namesRgbLinear and Xyz of primaries and white, luma from YbrConfiguration, into Vector4 lanes or a uniformToLinear(value, dynamicRange)SKColorF from Rgb with the sRGB tag or from RgbLinear with the linear tag, SKColor from Rgb.Byte255Unicolour.Hex and Rgb.Byte255.Hex write #RRGGBB and answer - outside the RGB gamut, MapToRgbGamut precedes themColourSpace.HslStyle.TextColor and HaloColor are 8-bit SKColor, a float color draws the block through a layer paintinternal static class Swatches {
public static SKColorF Srgb(Unicolour color) => new((float)color.Rgb.R, (float)color.Rgb.G, (float)color.Rgb.B, (float)color.Alpha.A);
public static SKColorF Over(Unicolour color, Unicolour ground) => Srgb(color.Blend(ground, BlendMode.Normal).MapToRgbGamut(GamutMap.OklchChromaReduction));
public static Seq<SKColorF> Ramp(Unicolour resting, Unicolour active, int steps) => toSeq(resting.Palette(active, ColourSpace.Oklab, steps)).Map(Srgb);
}
Text becomes pixels through one measured block per text, sealed style, and width. RichTextKit itemizes, shapes, breaks, lays out, and paints, HarfBuzz shapes a run that needs features or axes, SKFont rasterizes:
TextBlock instances cache per key and paint per frame, a block is device-free and survives a scale changeMeasuredWidth at MaxWidth = null, min-content uses UAX #14 line breaks, word boundaries and bidi caret distances give different measuresLayout reshapes every run, the wrapped block replaces the unbounded one when the resolved width differs, none lays out twice at one widthStyle.Seal() fixes a style for sharing across blocks and as a cache key, StyleManager.FromStyle dedupes equal styles into one instanceTextPaintOptions (Edging, Hinting, SubpixelPositioning, Selection) derives from surface properties and changes no layoutCopy and ApplyStyle relayout the blockWordBoundaryIndicies, CaretIndicies, and LineIndiciesTextBlock.Paint owns halo, underline, and selection, changing completed runs leaves wrapping and caret metrics staleAlignment, the host culture decides BaseDirectionTextBlock.MeasuredOverhang grows the invalidation rect, glyphs past the advance box repaint with itFont per face and axis set, scaled at UnitsPerEm, serves every size through one multiply by Size / UnitsPerEmBuffer per thread, cleared per runinternal sealed record BlockKey(string Text, IStyle Face, Option<float> Width);
internal sealed class Blocks(SKSurfaceProperties raster) {
private readonly TextPaintOptions options = new() {
Edging = raster.PixelGeometry is SKPixelGeometry.Unknown ? SKFontEdging.Antialias : SKFontEdging.SubpixelAntialias,
Hinting = raster.IsUseDeviceIndependentFonts ? SKFontHinting.None : SKFontHinting.Slight,
};
private readonly StyleManager styles = new();
private readonly AtomHashMap<BlockKey, TextBlock> laid = AtomHashMap<BlockKey, TextBlock>();
public TextBlock Laid(string text, Style face, Option<float> width) {
BlockKey key = new(text, styles.FromStyle(face), width);
return laid.FindOrAdd(key, () => {
TextBlock block = new() { MaxWidth = key.Width.ToNullable() };
block.AddText(key.Text, key.Face);
return block;
});
}
public void Paint(SKCanvas canvas, TextBlock block, SKPoint origin) => block.Paint(canvas, origin, options);
}
Eto hosts the scene through one handler interface per capability, implemented in full per platform and resolved once at construction. Native casts sit inside one platform file:
Find<T>() are a service locator, absence on one platform shows as a refused eventPlatform.Instance.IsMac, ControlObject, NativeHandle, and ToNative() are read in the platform file alone, shared code reads the seam memberBitmapData.TranslateArgbToData of opaque red answers red in the low byte for SKColorType.Rgba8888Bgra8888 answers red in bits 16 to 23, alpha type derives from BitmapData.PremultipliedAlpha, a per-platform constant restates bothBitmap.Lock, LockBits) in one Bgra8888 pair, a PNG round trip restates itLoaded idiom over LoadComplete and UnLoad owns every host subscription, and a reload re-acquiresUITimer(handler) and Command(execute) take their handler at construction, no subscription pair followsParentWindow.LogicalPixelSize, a maximum over Screen.Screens mismatches every other monitorLogicalPixelSizeChanged on the window rebuilds device-sized caches and backings, SizeChanged alone misses a monitor moveDrawable.Height written from a preferred size runs once per content change, a write per paint relayouts the parent per framePixels.Info reads color type and alpha type from the locked BitmapData:
internal sealed class SceneCanvas(Action<SKCanvas> draw) : Drawable {
private Option<Bitmap> backing;
protected override void OnPaint(PaintEventArgs e) {
float scale = ParentWindow.LogicalPixelSize;
Size pixels = Size.Ceiling(Size * scale);
Bitmap target = backing.Filter(held => held.Size == pixels).IfNone(() => {
_ = backing.Iter(static held => held.Dispose());
Bitmap made = new(pixels, PixelFormat.Format32bppRgba);
backing = made;
return made;
});
using (BitmapData data = target.Lock()) {
using SKSurface surface = SKSurface.Create(Pixels.Info(data, pixels), data.Data, data.ScanWidth);
surface.Canvas.Scale(scale);
draw(surface.Canvas);
}
e.Graphics.ImageInterpolation = ImageInterpolation.None;
e.Graphics.DrawImage(target, new RectangleF(PointF.Empty, Size));
base.OnPaint(e);
}
protected override void Dispose(bool disposing) {
if (disposing) _ = backing.Iter(static held => held.Dispose());
base.Dispose(disposing);
}
}
| [INDEX] | [WRONG_FORM] | [CORRECT_FORM] |
|---|---|---|
| [01] | Drawn text field, tabs, expander, splitter, progress, or caption | TextBox, TabControl, Expander, Splitter, Label |
| [02] | Second scene raster host per surface or per host | One surface type owning allocation, damage, and paint |
| [03] | Per-texel gamut or transfer loop in managed code before a blit | Source and destination tagged, Skia converts on draw |
| [04] | Target format selected by ColorType alone | ColorType and ColorSpace together select the F16 target |
| [05] | Snapshot() between draws, or one snapshot per blit path | One snapshot after the frame's last draw |
| [06] | SKPaint, SKPath, SKFont, or filter allocated in a draw loop | Built per style or per layout, reused per draw |
| [07] | Shadow, clip, stroke, and hit test from separate geometry | One outline feeding every derivation, cached per layout |
| [08] | Inset shadow drawn as a drop shadow clipped Difference | Inverted-alpha outline offset, blurred, and clipped SrcIn |
| [09] | SaveLayer() around every group, or DrawPicture with a paint | SaveLayer(limit, paint) for an effect, null picture paint |
| [10] | ClipPath(path, antialias: true) per child on a plain rounded rect | ClipRoundRect once around the children |
| [11] | Backdrop blur recorded inside a picture or offscreen | Backdrop filter on the live canvas alone |
| [12] | Cache key missing scale or color space, or keyed on a reference | Key on content, scale, color type, and color space |
| [13] | One cache cleared on every size or scale change | Device-free caches survive, device-dependent caches rebuild |
| [14] | Mix or Contrast per hover frame, memo keyed on animated colors | Palette table at style time, color through a layer paint |
| [15] | CreateShader per frame, or a per-use builder disposing the effect | BuildShader once as a static, uniforms and children per use |
| [16] | Gradient colors as SKColor on a linear target | SKColorF[] tagged with their SKColorSpace |
| [17] | SrcIn tint filter over art that holds its own colors | SvgParameters.CurrentColor at load, tint for monochrome art |
| [18] | SVG parsed on the paint thread, or rasterized per draw | Picture at realization, image per (asset, parameters, scale) |
| [19] | new SKSvg() per asset, ReLoad without CacheOriginalStream | SvgService.Open into one SkiaModel, the toggle set first |
| [20] | new Unicolour inside a pixel or sample loop | Matrix or curve derived once, baked into a span kernel or shader |
| [21] | Hand alpha composite, white point adaptation, or CCT fit | Blend, ConvertToConfiguration, Unicolour.Temperature |
| [22] | Hand RGB clipping of an out-of-gamut color | MapToRgbGamut(GamutMap.OklchChromaReduction) |
| [23] | Style file, decoder, or color string grammar | Typed color values declared in code beside their style |
| [24] | TextBlock laid out per paint, or one block per candidate width | Laid block cached by text, sealed style, and width |
| [25] | Copy and ApplyStyle to recolor text per frame | Layer paint or color filter over the laid block |
| [26] | Whitespace scan or Split(' ') for wrap and word points | WordBoundaryIndicies, LineIndicies |
| [27] | Glyphs or widths replaced after TextBlock.Layout | Shaping inputs supplied before line breaking and caret layout |
| [28] | Blob, Face, Font, or Buffer built per paint or weakly held | One Font per face and axis set in a scene-owned cache |
| [29] | SKShaper.Shape followed by a second shape for features | One Font.Shape(buffer, features) |
| [30] | Platform.Add<TDelegate> per fact, Find<T>() at each call site | One IHandler per capability, CreateShared<T>() once |
| [31] | Pixel order as a registered per-platform constant | TranslateArgbToData of opaque red on the locked BitmapData |
| [32] | IsMac branch or ControlObject cast in shared code | Seam member the platform file implements |
| [33] | Runtime class swap on a toolkit-owned native view | Native view subclass in the platform file |
| [34] | BitmapData held for the bitmap's life, drawn while locked | Lock, draw through Skia, dispose, then Graphics.DrawImage |
| [35] | Logical size as the backing size, scale from the largest screen | Logical size times the window's LogicalPixelSize |
| [36] | Thread or Task body touching a control, Invoke from a worker | AsyncInvoke or InvokeAsync onto the UI thread |
| [37] | UITimer as an animation frame clock | Display link behind the seam, UITimer for cadence |
| [38] | LoadComplete subscribed per control, realization in a constructor | One Loaded idiom subscribing and releasing per control |
| [39] | One Command per menu item, button, and context item | One Command converted to MenuItem and ToolItem |
| [40] | Shortcut dispatched by hand in KeyDown | Command.Shortcut, MapPlatformCommand for edit commands |
| [41] | Icon re-rasterized per cell bind, or Icon.FromHandle(GetHicon()) | new Icon(scale, bitmap) per (asset, scale, theme), disposed |
| [42] | Graphics plots, captions, or glyphs beside a Skia scene | One Skia scene in the Drawable, Graphics blits alone |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub bsamiee/rasm --plugin dotnet8 skills in this plugin
/codelensUse when reading, diagnosing, or refactoring a file in a .NET solution, covering the roslyn-codelens MCP server/codingUse when writing or reviewing C#, covering functional design with result and effect types/debuggingUse when C# or another CoreCLR program misbehaves at runtime and its cause is unproven (wrong value, failing test, exception, hang, crash, breakpoint that never stops), covering DNCDbg launches and attaches, held starts, test runners, PDB documents, exception stops, expressions, live process reads, and dumpsOther plugins' skills for the same job