优化更新代码,添加界面功能并整合

This commit is contained in:
GG Z
2025-02-10 20:53:40 +08:00
parent 83b846f15f
commit 978e03a67f
1389 changed files with 95739 additions and 22200 deletions

View File

@@ -0,0 +1,112 @@
using System.Windows.Controls;
namespace WPFluent.Controls;
/// <summary>
/// Represents an icon source that uses a glyph from the specified font.
/// </summary>
public class SymbolIconSource : IconSource
{
/// <summary>
/// Identifies the <see cref="Filled"/> dependency property.
/// </summary>
public static readonly DependencyProperty FilledProperty = DependencyProperty.Register(
nameof(Filled),
typeof(bool),
typeof(SymbolIconSource),
new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="FontSize"/> dependency property.
/// </summary>
public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register(
nameof(FontSize),
typeof(double),
typeof(SymbolIconSource),
new PropertyMetadata(SystemFonts.MessageFontSize));
/// <summary>
/// Identifies the <see cref="FontStyle"/> dependency property.
/// </summary>
public static readonly DependencyProperty FontStyleProperty = DependencyProperty.Register(
nameof(FontStyle),
typeof(FontStyle),
typeof(SymbolIconSource),
new PropertyMetadata(FontStyles.Normal));
/// <summary>
/// Identifies the <see cref="FontWeight"/> dependency property.
/// </summary>
public static readonly DependencyProperty FontWeightProperty = DependencyProperty.Register(
nameof(FontWeight),
typeof(FontWeight),
typeof(SymbolIconSource),
new PropertyMetadata(FontWeights.Normal));
/// <summary>
/// Identifies the <see cref="Symbol"/> dependency property.
/// </summary>
public static readonly DependencyProperty SymbolProperty = DependencyProperty.Register(
nameof(Symbol),
typeof(SymbolRegular),
typeof(SymbolIconSource),
new PropertyMetadata(SymbolRegular.Empty));
public override IconElement CreateIconElement()
{
SymbolIcon symbolIcon = new(Symbol, FontSize, Filled);
if (!FontSize.Equals(SystemFonts.MessageFontSize))
{
symbolIcon.FontSize = FontSize;
}
if (FontWeight != FontWeights.Normal)
{
symbolIcon.FontWeight = FontWeight;
}
if (FontStyle != FontStyles.Normal)
{
symbolIcon.FontStyle = FontStyle;
}
if (Foreground != SystemColors.ControlTextBrush)
{
symbolIcon.Foreground = Foreground;
}
return symbolIcon;
}
/// <summary>
/// Gets or sets a value indicating whether or not we should use the <see cref="SymbolFilled"/>.
/// </summary>
public bool Filled { get => (bool)GetValue(FilledProperty); set => SetValue(FilledProperty, value); }
/// <inheritdoc cref="Control.FontSize"/>
public double FontSize { get => (double)GetValue(FontSizeProperty); set => SetValue(FontSizeProperty, value); }
/// <inheritdoc cref="Control.FontStyle"/>
public FontStyle FontStyle
{
get => (FontStyle)GetValue(FontStyleProperty);
set => SetValue(FontStyleProperty, value);
}
/// <inheritdoc cref="Control.FontWeight"/>
public FontWeight FontWeight
{
get => (FontWeight)GetValue(FontWeightProperty);
set => SetValue(FontWeightProperty, value);
}
/// <summary>
/// Gets or sets displayed <see cref="SymbolRegular"/>.
/// </summary>
public SymbolRegular Symbol
{
get => (SymbolRegular)GetValue(SymbolProperty);
set => SetValue(SymbolProperty, value);
}
}