优化更新代码,添加界面功能并整合
This commit is contained in:
44
WPFluent/Extensions/SymbolExtensions.cs
Normal file
44
WPFluent/Extensions/SymbolExtensions.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user