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

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,19 @@
namespace WPFluent.Controls;
/// <summary>
/// Defines several predefined text styles that you can apply to some elements responsible for displaying it. <para><see
/// href="https://learn.microsoft.com/en-us/windows/apps/design/style/typography"/></para>
/// </summary>
public enum FontTypography
{
Caption,
Body,
BodyStrong,
Subtitle,
Title,
TitleLarge,
Display,
}

View File

@@ -0,0 +1,70 @@
using WPFluent.Extensions;
// ReSharper disable once CheckNamespace
namespace WPFluent.Controls;
/// <summary>
/// Extended <see cref="System.Windows.Controls.TextBlock"/> with additional parameters like <see
/// cref="FontTypography"/>.
/// </summary>
public class TextBlock : System.Windows.Controls.TextBlock
{
/// <summary>
/// Identifies the <see cref="FontTypography"/> dependency property.
/// </summary>
public static readonly DependencyProperty FontTypographyProperty = DependencyProperty.Register(
nameof(FontTypography),
typeof(FontTypography),
typeof(TextBlock),
new PropertyMetadata(
FontTypography.Body,
static(o, args) =>
{
((TextBlock)o).OnFontTypographyChanged((FontTypography)args.NewValue);
}));
/// <summary>
/// Identifies the <see cref="Appearance"/> dependency property.
/// </summary>
public static readonly DependencyProperty AppearanceProperty = DependencyProperty.Register(
nameof(Appearance),
typeof(TextColor),
typeof(TextBlock),
new PropertyMetadata(
TextColor.Primary,
static(o, args) =>
{
((TextBlock)o).OnAppearanceChanged((TextColor)args.NewValue);
}));
public TextBlock()
{
var defaultFontTypography = (FontTypography)FontTypographyProperty.DefaultMetadata.DefaultValue;
SetResourceReference(StyleProperty, defaultFontTypography.ToResourceValue());
}
private void OnAppearanceChanged(TextColor textColor)
{ SetResourceReference(ForegroundProperty, textColor.ToResourceValue()); }
private void OnFontTypographyChanged(FontTypography newTypography)
{ SetResourceReference(StyleProperty, newTypography.ToResourceValue()); }
/// <summary>
/// Gets or sets the color of the text.
/// </summary>
public TextColor Appearance
{
get => (TextColor)GetValue(AppearanceProperty);
set => SetValue(AppearanceProperty, value);
}
/// <summary>
/// Gets or sets the <see cref="FontTypography"/> of the text.
/// </summary>
public FontTypography FontTypography
{
get => (FontTypography)GetValue(FontTypographyProperty);
set => SetValue(FontTypographyProperty, value);
}
}

View File

@@ -0,0 +1,25 @@
<!--
This Source Code Form is subject to the terms of the MIT License.
If a copy of the MIT was not distributed with this file, You can obtain one at https://opensource.org/licenses/MIT.
Copyright (C) Leszek Pomianowski and WPF UI Contributors.
All Rights Reserved.
-->
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="{x:Type TextBlock}">
<!--<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}"/>-->
<!-- The Display option causes a large aliasing effect -->
<!--<Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />-->
<Setter Property="Background" Value="Transparent" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="Focusable" Value="False" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
</Style>
</ResourceDictionary>

View File

@@ -0,0 +1,30 @@
namespace WPFluent.Controls;
/// <summary>
/// Colors for UI labels and static text
/// </summary>
public enum TextColor
{
/// <summary>
/// Rest or Hover
/// </summary>
Primary,
/// <summary>
/// Rest or Hover
/// </summary>
Secondary,
/// <summary>
/// Pressed only (not accessible)
/// </summary>
Tertiary,
/// <summary>
/// Disabled only (not accessible)
/// </summary>
Disabled,
}