/
PackIconFeatherIcons.cs
76 lines (69 loc) · 2.62 KB
/
PackIconFeatherIcons.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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>
/// Feather is licensed under the MIT License <see><cref>https://github.com/feathericons/feather?tab=MIT-1-ov-file#readme</cref></see>
/// Contributions, corrections and requests can be made on GitHub <see><cref>https://feathericons.com/</cref></see>.
/// </summary>
[MetaData("Feather Icons", "https://feathericons.com/", "https://github.com/feathericons/feather?tab=MIT-1-ov-file#readme")]
public class PackIconFeatherIcons : PackIconControlBase
{
public static readonly DependencyProperty KindProperty
= DependencyProperty.Register(nameof(Kind), typeof(PackIconFeatherIconsKind), typeof(PackIconFeatherIcons), new PropertyMetadata(default(PackIconFeatherIconsKind), KindPropertyChangedCallback));
private static void KindPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue != e.OldValue)
{
((PackIconFeatherIcons)dependencyObject).UpdateData();
}
}
/// <summary>
/// Gets or sets the icon to display.
/// </summary>
public PackIconFeatherIconsKind Kind
{
get { return (PackIconFeatherIconsKind)GetValue(KindProperty); }
set { SetValue(KindProperty, value); }
}
#if !(NETFX_CORE || WINDOWS_UWP)
static PackIconFeatherIcons()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIconFeatherIcons), new FrameworkPropertyMetadata(typeof(PackIconFeatherIcons)));
}
#endif
public PackIconFeatherIcons()
{
#if NETFX_CORE || WINDOWS_UWP
this.DefaultStyleKey = typeof(PackIconFeatherIcons);
#endif
}
protected override void SetKind<TKind>(TKind iconKind)
{
#if NETFX_CORE || WINDOWS_UWP
BindingOperations.SetBinding(this, PackIconFeatherIcons.KindProperty, new Binding() { Source = iconKind, Mode = BindingMode.OneTime });
#else
this.SetCurrentValue(KindProperty, iconKind);
#endif
}
protected override void UpdateData()
{
if (Kind != default(PackIconFeatherIconsKind))
{
string data = null;
PackIconFeatherIconsDataFactory.DataIndex.Value?.TryGetValue(Kind, out data);
this.Data = data;
}
else
{
this.Data = null;
}
}
}
}