-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from MahApps/icons/MemoryIconsv1.5.0
Add Memory Icons v1.5.0
- Loading branch information
Showing
24 changed files
with
1,846 additions
and
1 deletion.
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
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/MemoryIcons/PackIconMemoryIcons.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 Memory Icons <see><cref>https://pictogrammers.com/library/memory/</cref></see> | ||
/// In accordance of <see><cref>https://github.com/Pictogrammers/Memory?tab=License-1-ov-file#readme</cref></see>. | ||
/// </summary> | ||
[MetaData("Memory Icons", "https://pictogrammers.com/library/memory/", "https://github.com/Pictogrammers/Memory?tab=License-1-ov-file#readme")] | ||
public class PackIconMemoryIcons : PackIconControlBase | ||
{ | ||
public static readonly DependencyProperty KindProperty | ||
= DependencyProperty.Register(nameof(Kind), typeof(PackIconMemoryIconsKind), typeof(PackIconMemoryIcons), new PropertyMetadata(default(PackIconMemoryIconsKind), KindPropertyChangedCallback)); | ||
|
||
private static void KindPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (e.NewValue != e.OldValue) | ||
{ | ||
((PackIconMemoryIcons)dependencyObject).UpdateData(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the icon to display. | ||
/// </summary> | ||
public PackIconMemoryIconsKind Kind | ||
{ | ||
get { return (PackIconMemoryIconsKind)GetValue(KindProperty); } | ||
set { SetValue(KindProperty, value); } | ||
} | ||
|
||
#if !(NETFX_CORE || WINDOWS_UWP) | ||
static PackIconMemoryIcons() | ||
{ | ||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIconMemoryIcons), new FrameworkPropertyMetadata(typeof(PackIconMemoryIcons))); | ||
} | ||
#endif | ||
|
||
public PackIconMemoryIcons() | ||
{ | ||
#if NETFX_CORE || WINDOWS_UWP | ||
this.DefaultStyleKey = typeof(PackIconMemoryIcons); | ||
#endif | ||
} | ||
|
||
protected override void SetKind<TKind>(TKind iconKind) | ||
{ | ||
#if NETFX_CORE || WINDOWS_UWP | ||
BindingOperations.SetBinding(this, PackIconMemoryIcons.KindProperty, new Binding() { Source = iconKind, Mode = BindingMode.OneTime }); | ||
#else | ||
this.SetCurrentValue(KindProperty, iconKind); | ||
#endif | ||
} | ||
|
||
protected override void UpdateData() | ||
{ | ||
if (Kind != default(PackIconMemoryIconsKind)) | ||
{ | ||
string data = null; | ||
PackIconMemoryIconsDataFactory.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/MemoryIcons/PackIconMemoryIconsCursorExtension.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 MemoryIconsCursorExtension : MemoryIconsImageExtension, IPackIconCursorExtension | ||
{ | ||
public MemoryIconsCursorExtension() : base() => base.Brush = PackIconCursorHelper.DefaultBrush; | ||
public MemoryIconsCursorExtension(PackIconMemoryIconsKind 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.