Files
Shrlalgo.RvKits/WPFluent/Extensions/SymbolExtensions.cs

45 lines
1.4 KiB
C#

using WPFluent.Controls;
using System.Text;
namespace WPFluent.Extensions;
/// <summary>
/// Set of extensions for the enumeration of icons to facilitate their management and replacement.
/// </summary>
public static class SymbolExtensions
{
/// <summary>
/// Converts <see cref="SymbolRegular"/> to <see langword="string"/> based on the ID.
/// </summary>
public static string GetString(this SymbolRegular icon)
{ return Encoding.Unicode.GetString(BitConverter.GetBytes((int)icon)).TrimEnd('\0'); }
/// <summary>
/// Converts <see cref="SymbolFilled"/> to <see langword="string"/> based on the ID.
/// </summary>
public static string GetString(this SymbolFilled icon)
{ return Encoding.Unicode.GetString(BitConverter.GetBytes((int)icon)).TrimEnd('\0'); }
/// <summary>
/// Replaces <see cref="SymbolRegular"/> with <see cref="SymbolFilled"/>.
/// </summary>
public static SymbolFilled Swap(this SymbolRegular icon)
{
// It is possible that the alternative icon does not exist
return SymbolGlyph.ParseFilled(icon.ToString());
}
/// <summary>
/// Replaces <see cref="SymbolFilled"/> with <see cref="SymbolRegular"/>.
/// </summary>
public static SymbolRegular Swap(this SymbolFilled icon)
{
// It is possible that the alternative icon does not exist
return SymbolGlyph.Parse(icon.ToString());
}
}