优化更新代码,添加界面功能并整合
This commit is contained in:
67
WPFluent/Controls/IconElement/SymbolGlyph.cs
Normal file
67
WPFluent/Controls/IconElement/SymbolGlyph.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
|
||||
|
||||
|
||||
namespace WPFluent.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Set of static methods to operate on <see cref="SymbolRegular"/> and <see cref="SymbolFilled"/>.
|
||||
/// </summary>
|
||||
public static class SymbolGlyph
|
||||
{
|
||||
/// <summary>
|
||||
/// If the filled icon is not found in some places, this one will be displayed.
|
||||
/// </summary>
|
||||
public const SymbolFilled DefaultFilledIcon = SymbolFilled.BorderNone24;
|
||||
/// <summary>
|
||||
/// If the icon is not found in some places, this one will be displayed.
|
||||
/// </summary>
|
||||
public const SymbolRegular DefaultIcon = SymbolRegular.BorderNone24;
|
||||
|
||||
/// <summary>
|
||||
/// Finds icon based on name.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the icon.</param>
|
||||
public static SymbolRegular Parse(string name)
|
||||
{
|
||||
if(string.IsNullOrEmpty(name))
|
||||
{
|
||||
return DefaultIcon;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (SymbolRegular)Enum.Parse(typeof(SymbolRegular), name);
|
||||
} catch(Exception)
|
||||
{
|
||||
#if DEBUG
|
||||
throw;
|
||||
#else
|
||||
return DefaultIcon;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds icon based on name.
|
||||
/// </summary>
|
||||
/// <param name="name">Name of the icon.</param>
|
||||
public static SymbolFilled ParseFilled(string name)
|
||||
{
|
||||
if(string.IsNullOrEmpty(name))
|
||||
{
|
||||
return DefaultFilledIcon;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (SymbolFilled)Enum.Parse(typeof(SymbolFilled), name);
|
||||
} catch(Exception)
|
||||
{
|
||||
#if DEBUG
|
||||
throw;
|
||||
#else
|
||||
return DefaultFilledIcon;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user