Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Phosphor Icons v2.1.1 #339

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ This `IconPacks` library contains controls, markup extensions and converters to
| [Memory Icons](https://pictogrammers.com/library/memory/) | 1.5.0 | 651 | <a href="https://www.nuget.org/packages/MahApps.Metro.IconPacks.MemoryIcons/" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/nuget/dt/MahApps.Metro.IconPacks.MemoryIcons.svg?style=flat-square&&label=MemoryIcons"></a> |
| [Microns](https://github.com/stephenhutchings/microns) | 1.1.4 | 164 | <a href="https://www.nuget.org/packages/MahApps.Metro.IconPacks.Microns/" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/nuget/dt/MahApps.Metro.IconPacks.Microns.svg?style=flat-square&&label=Microns"></a> |
| [Modern UI Icons](https://github.com/Templarian/WindowsIcons) | Feb 12, 2015 | 1260 | <a href="https://www.nuget.org/packages/MahApps.Metro.IconPacks.Modern/" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/nuget/dt/MahApps.Metro.IconPacks.Modern.svg?style=flat-square&&label=Modern"></a> |
| [Phosphor Icons](https://phosphoricons.com/) | 2.1.1 | 7560 | <a href="https://www.nuget.org/packages/MahApps.Metro.IconPacks.PhosphorIcons/" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/nuget/dt/MahApps.Metro.IconPacks.PhosphorIcons.svg?style=flat-square&&label=PhosphorIcons"></a> |
| [Primer Octicons (GitHub)](https://github.com/primer/octicons) | 19.9.0 | 604 | <a href="https://www.nuget.org/packages/MahApps.Metro.IconPacks.Octicons/" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/nuget/dt/MahApps.Metro.IconPacks.Octicons.svg?style=flat-square&&label=Octicons"></a> |
| [PICOL Icons](https://github.com/PicolSigns/Icons) | 1.1.0 | 549 | <a href="https://www.nuget.org/packages/MahApps.Metro.IconPacks.PicolIcons/" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/nuget/dt/MahApps.Metro.IconPacks.PicolIcons.svg?style=flat-square&&label=PicolIcons"></a> |
| [Pixelarticons Free](https://pixelarticons.com/) | 1.8.1 | 486 | <a href="https://www.nuget.org/packages/MahApps.Metro.IconPacks.PixelartIcons/" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/nuget/dt/MahApps.Metro.IconPacks.PixelartIcons.svg?style=flat-square&&label=PixelartIcons"></a> |
Expand Down
14 changes: 14 additions & 0 deletions src/MahApps.Metro.IconPacks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MahApps.Metro.IconPacks.Luc
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MahApps.Metro.IconPacks.GameIcons", "MahApps.Metro.IconPacks\MahApps.Metro.IconPacks.GameIcons.csproj", "{ED5CB032-C631-48B4-AE1F-16B88300A025}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MahApps.Metro.IconPacks.PhosphorIcons", "MahApps.Metro.IconPacks\MahApps.Metro.IconPacks.PhosphorIcons.csproj", "{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -538,6 +540,18 @@ Global
{ED5CB032-C631-48B4-AE1F-16B88300A025}.Release|x64.Build.0 = Release|Any CPU
{ED5CB032-C631-48B4-AE1F-16B88300A025}.Release|x86.ActiveCfg = Release|Any CPU
{ED5CB032-C631-48B4-AE1F-16B88300A025}.Release|x86.Build.0 = Release|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Debug|x64.ActiveCfg = Debug|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Debug|x64.Build.0 = Debug|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Debug|x86.ActiveCfg = Debug|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Debug|x86.Build.0 = Debug|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Release|Any CPU.Build.0 = Release|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Release|x64.ActiveCfg = Release|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Release|x64.Build.0 = Release|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Release|x86.ActiveCfg = Release|Any CPU
{A7C655E4-3B56-4C5B-91B2-0BA28EC7E243}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
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 Phosphor Icons - <see><cref>https://phosphoricons.com/</cref></see>
/// Phosphor Icons are licensed under the MIT License <see><cref>https://github.com/phosphor-icons/core?tab=MIT-1-ov-file#readme</cref></see>
/// </summary>
[MetaData("Phosphor Icons", "https://phosphoricons.com/", "https://github.com/phosphor-icons/core?tab=MIT-1-ov-file#readme")]
public class PackIconPhosphorIcons : PackIconControlBase
{
public static readonly DependencyProperty KindProperty
= DependencyProperty.Register(nameof(Kind), typeof(PackIconPhosphorIconsKind), typeof(PackIconPhosphorIcons), new PropertyMetadata(default(PackIconPhosphorIconsKind), KindPropertyChangedCallback));

private static void KindPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue != e.OldValue)
{
((PackIconPhosphorIcons)dependencyObject).UpdateData();
}
}

/// <summary>
/// Gets or sets the icon to display.
/// </summary>
public PackIconPhosphorIconsKind Kind
{
get { return (PackIconPhosphorIconsKind)GetValue(KindProperty); }
set { SetValue(KindProperty, value); }
}

#if !(NETFX_CORE || WINDOWS_UWP)
static PackIconPhosphorIcons()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(PackIconPhosphorIcons), new FrameworkPropertyMetadata(typeof(PackIconPhosphorIcons)));
}
#endif

public PackIconPhosphorIcons()
{
#if NETFX_CORE || WINDOWS_UWP
this.DefaultStyleKey = typeof(PackIconPhosphorIcons);
#endif
}

protected override void SetKind<TKind>(TKind iconKind)
{
#if NETFX_CORE || WINDOWS_UWP
BindingOperations.SetBinding(this, PackIconPhosphorIcons.KindProperty, new Binding() { Source = iconKind, Mode = BindingMode.OneTime });
#else
this.SetCurrentValue(KindProperty, iconKind);
#endif
}

protected override void UpdateData()
{
if (Kind != default(PackIconPhosphorIconsKind))
{
string data = null;
PackIconPhosphorIconsDataFactory.DataIndex.Value?.TryGetValue(Kind, out data);
this.Data = data;
}
else
{
this.Data = null;
}
}
}
}
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 PhosphorIconsCursorExtension : PhosphorIconsImageExtension, IPackIconCursorExtension
{
public PhosphorIconsCursorExtension() : base() => base.Brush = PackIconCursorHelper.DefaultBrush;
public PhosphorIconsCursorExtension(PackIconPhosphorIconsKind 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);
}
}
}
Loading
Loading