-
-
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 #239 from MahApps/icons/FileIconsv2.1.43
Add File Icons v2.1.43
- Loading branch information
Showing
25 changed files
with
2,328 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
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/FileIcons/PackIconFileIcons.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> | ||
/// File Icons are licensed under the [MIT license](<see><cref>https://github.com/file-icons/atom/blob/master/LICENSE.md</cref></see>). | ||
/// Contributions, corrections and requests can be made on GitHub <see><cref>https://github.com/file-icons/icons</cref></see>. | ||
/// </summary> | ||
[MetaData("https://github.com/file-icons/icons", "https://github.com/file-icons/atom/blob/master/LICENSE.md")] | ||
public class PackIconFileIcons : PackIconControlBase | ||
{ | ||
public static readonly DependencyProperty KindProperty | ||
= DependencyProperty.Register(nameof(Kind), typeof(PackIconFileIconsKind), typeof(PackIconFileIcons), new PropertyMetadata(default(PackIconFileIconsKind), KindPropertyChangedCallback)); | ||
|
||
private static void KindPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) | ||
{ | ||
if (e.NewValue != e.OldValue) | ||
{ | ||
((PackIconFileIcons)dependencyObject).UpdateData(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the icon to display. | ||
/// </summary> | ||
public PackIconFileIconsKind Kind | ||
{ | ||
get { return (PackIconFileIconsKind)GetValue(KindProperty); } | ||
set { SetValue(KindProperty, value); } | ||
} | ||
|
||
#if !(NETFX_CORE || WINDOWS_UWP) | ||
static PackIconFileIcons() | ||
{ | ||
DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIconFileIcons), new FrameworkPropertyMetadata(typeof(PackIconFileIcons))); | ||
} | ||
#endif | ||
|
||
public PackIconFileIcons() | ||
{ | ||
#if NETFX_CORE || WINDOWS_UWP | ||
this.DefaultStyleKey = typeof(PackIconFileIcons); | ||
#endif | ||
} | ||
|
||
protected override void SetKind<TKind>(TKind iconKind) | ||
{ | ||
#if NETFX_CORE || WINDOWS_UWP | ||
BindingOperations.SetBinding(this, PackIconFileIcons.KindProperty, new Binding() { Source = iconKind, Mode = BindingMode.OneTime }); | ||
#else | ||
this.SetCurrentValue(KindProperty, iconKind); | ||
#endif | ||
} | ||
|
||
protected override void UpdateData() | ||
{ | ||
if (Kind != default(PackIconFileIconsKind)) | ||
{ | ||
string data = null; | ||
PackIconFileIconsDataFactory.DataIndex.Value?.TryGetValue(Kind, out data); | ||
this.Data = data; | ||
} | ||
else | ||
{ | ||
this.Data = null; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.