Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add general PackIconCursorExtension
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} | ||
} |