Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Game Icons Apr 7, 2024 ![2024-05-06_10h18_47](https://github.com/MahApps/MahApps.Metro.IconPacks/assets/658431/3cafae68-a154-47e8-bb86-0bf4dce55993)
- Loading branch information
Showing
23 changed files
with
8,842 additions
and
2 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
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
76 changes: 76 additions & 0 deletions
76
src/MahApps.Metro.IconPacks/Icons/GameIcons/PackIconGameIcons.cs
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,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
#if (NETFX_CORE || WINDOWS_UWP) | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Data; | ||
#else | ||
using System.Windows; | ||
#endif | ||
|
||
namespace MahApps.Metro.IconPacks | ||
{ | ||
/// <summary> | ||
/// All icons sourced from Game Icons <see><cref>https://github.com/game-icons/icons</cref></see> | ||
/// In accordance of <see><cref>https://github.com/game-icons/icons?tab=License-1-ov-file#readme</cref></see>. | ||
/// </summary> | ||
[MetaData("Game Icons", "https://github.com/game-icons/icons", "https://github.com/game-icons/icons?tab=License-1-ov-file#readme")] | ||
public class PackIconGameIcons : PackIconControlBase | ||
{ | ||
public static readonly DependencyProperty KindProperty | ||
= DependencyProperty.Register(nameof(Kind), typeof(PackIconGameIconsKind), typeof(PackIconGameIcons), new PropertyMetadata(default(PackIconGameIconsKind), KindPropertyChangedCallback)); | ||
|
||
private static void KindPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (e.NewValue != e.OldValue) | ||
{ | ||
((PackIconGameIcons)dependencyObject).UpdateData(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the icon to display. | ||
/// </summary> | ||
public PackIconGameIconsKind Kind | ||
{ | ||
get { return (PackIconGameIconsKind)GetValue(KindProperty); } | ||
set { SetValue(KindProperty, value); } | ||
} | ||
|
||
#if !(NETFX_CORE || WINDOWS_UWP) | ||
static PackIconGameIcons() | ||
{ | ||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIconGameIcons), new FrameworkPropertyMetadata(typeof(PackIconGameIcons))); | ||
} | ||
#endif | ||
|
||
public PackIconGameIcons() | ||
{ | ||
#if NETFX_CORE || WINDOWS_UWP | ||
this.DefaultStyleKey = typeof(PackIconGameIcons); | ||
#endif | ||
} | ||
|
||
protected override void SetKind<TKind>(TKind iconKind) | ||
{ | ||
#if NETFX_CORE || WINDOWS_UWP | ||
BindingOperations.SetBinding(this, PackIconGameIcons.KindProperty, new Binding() { Source = iconKind, Mode = BindingMode.OneTime }); | ||
#else | ||
this.SetCurrentValue(KindProperty, iconKind); | ||
#endif | ||
} | ||
|
||
protected override void UpdateData() | ||
{ | ||
if (Kind != default(PackIconGameIconsKind)) | ||
{ | ||
string data = null; | ||
PackIconGameIconsDataFactory.DataIndex.Value?.TryGetValue(Kind, out data); | ||
this.Data = data; | ||
} | ||
else | ||
{ | ||
this.Data = null; | ||
} | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/MahApps.Metro.IconPacks/Icons/GameIcons/PackIconGameIconsCursorExtension.cs
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,33 @@ | ||
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 GameIconsCursorExtension : GameIconsImageExtension, IPackIconCursorExtension | ||
{ | ||
public GameIconsCursorExtension() : base() => base.Brush = PackIconCursorHelper.DefaultBrush; | ||
public GameIconsCursorExtension(PackIconGameIconsKind 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); | ||
} | ||
} | ||
} |
Oops, something went wrong.