Skip to content

Commit

Permalink
feat: add general PackIconCursorExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
punker76 committed Apr 26, 2024
1 parent a32e3c5 commit 5e5baed
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/MahApps.Metro.IconPacks/PackIconCursorExtension.cs
@@ -0,0 +1,34 @@
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;

namespace MahApps.Metro.IconPacks
{
[MarkupExtensionReturnType(typeof(Cursor))]
public class PackIconCursorExtension : PackIconImageExtension, IPackIconCursorExtension
{
public PackIconCursorExtension() : base() => base.Brush = PackIconCursorHelper.DefaultBrush;

public PackIconCursorExtension(Enum kind) : base(kind) => base.Brush = PackIconCursorHelper.DefaultBrush;

/// <inheritdoc/>
public Point HotSpot { get; set; }
/// <inheritdoc/>
public double Width { get; set; } = PackIconCursorHelper.DefaultWidth;
/// <inheritdoc/>
public double Height { get; set; } = PackIconCursorHelper.DefaultHeight;
/// <inheritdoc/>
public Brush StrokeBrush { get; set; }
/// <inheritdoc/>
public double StrokeThickness { get; set; } = PackIconCursorHelper.DefaultStrokeThickness;

public override object ProvideValue(IServiceProvider serviceProvider)
{
TransformGroup transformGroup = (TransformGroup)GetTransformGroup(this.Kind);
Geometry geometry = PackIconCursorHelper.GetCursorGeometry(GetPathData(this.Kind), transformGroup, Width, Height);
return PackIconCursorHelper.GeometryToCursor(geometry, Brush, StrokeBrush, StrokeThickness, HotSpot);
}
}
}

0 comments on commit 5e5baed

Please sign in to comment.