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

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,113 @@
<!--
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.
Based on Microsoft XAML for Win UI
Copyright (c) Microsoft Corporation. All Rights Reserved.
-->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:system="clr-namespace:System;assembly=System.Runtime">
<Thickness x:Key="CardControlPadding">14,16,14,16</Thickness>
<Thickness x:Key="CardControlBorderThemeThickness">1</Thickness>
<Thickness x:Key="CardControlIconMargin">0,0,14,0</Thickness>
<Thickness x:Key="CardControlContentMargin">14,0,0,0</Thickness>
<system:Double x:Key="CardControlIconSize">24.0</system:Double>
<Style x:Key="DefaultUiCardControlStyle" TargetType="{x:Type controls:CardControl}">
<!-- Universal WPF UI focus -->
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<!-- Universal WPF UI focus -->
<Setter Property="Background" Value="{DynamicResource CardBackground}" />
<Setter Property="Foreground" Value="{DynamicResource CardForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource CardBorderBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource CardControlBorderThemeThickness}" />
<Setter Property="Padding" Value="{StaticResource CardControlPadding}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:CardControl}">
<Border
x:Name="ContentBorder"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentControl
x:Name="ControlIcon"
Grid.Column="0"
Margin="{StaticResource CardControlIconMargin}"
VerticalAlignment="Center"
Content="{TemplateBinding Icon}"
Focusable="False"
FontSize="{StaticResource CardControlIconSize}"
Foreground="{TemplateBinding Foreground}"
KeyboardNavigation.IsTabStop="False" />
<ContentPresenter
x:Name="HeaderContentPresenter"
Grid.Column="1"
VerticalAlignment="Center"
Content="{TemplateBinding Header}"
TextElement.Foreground="{TemplateBinding Foreground}" />
<ContentPresenter
x:Name="ContentPresenter"
Grid.Column="2"
Margin="{StaticResource CardControlContentMargin}"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
TextElement.Foreground="{TemplateBinding Foreground}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Content" Value="{x:Null}">
<Setter TargetName="ContentPresenter" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="Content" Value="">
<Setter TargetName="ContentPresenter" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="Header" Value="{x:Null}">
<Setter TargetName="ControlIcon" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="Header" Value="">
<Setter TargetName="ControlIcon" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="ControlIcon" Property="Margin" Value="0" />
<Setter TargetName="ControlIcon" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultUiCardControlStyle}" TargetType="{x:Type controls:CardControl}" />
</ResourceDictionary>

View File

@@ -0,0 +1,67 @@
using WPFluent.AutomationPeers;
using System.Windows.Automation.Peers;
namespace WPFluent.Controls;
/// <summary>
/// Inherited from the <see cref="System.Windows.Controls.Primitives.ButtonBase"/> control which displays an additional
/// control on the right side of the card.
/// </summary>
public class CardControl : System.Windows.Controls.Primitives.ButtonBase, IIconControl
{
/// <summary>
/// Identifies the <see cref="CornerRadius"/> dependency property.
/// </summary>
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(
nameof(CornerRadius),
typeof(CornerRadius),
typeof(CardControl),
new PropertyMetadata(new CornerRadius(0)));
/// <summary>
/// Identifies the <see cref="Header"/> dependency property.
/// </summary>
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(
nameof(Header),
typeof(object),
typeof(CardControl),
new PropertyMetadata(null));
/// <summary>
/// Identifies the <see cref="Icon"/> dependency property.
/// </summary>
public static readonly DependencyProperty IconProperty = DependencyProperty.Register(
nameof(Icon),
typeof(IconElement),
typeof(CardControl),
new PropertyMetadata(null));
protected override AutomationPeer OnCreateAutomationPeer() { return new CardControlAutomationPeer(this); }
/// <summary>
/// Gets or sets the corner radius of the control.
/// </summary>
[Bindable(true)]
[Category("Appearance")]
public CornerRadius CornerRadius
{
get => (CornerRadius)GetValue(CornerRadiusProperty);
set => SetValue(CornerRadiusProperty, value);
}
/// <summary>
/// Gets or sets header which is used for each item in the control.
/// </summary>
[Bindable(true)]
public object Header { get => GetValue(HeaderProperty); set => SetValue(HeaderProperty, value); }
/// <summary>
/// Gets or sets displayed <see cref="IconElement"/>.
/// </summary>
[Bindable(true)]
[Category("Appearance")]
public IconElement? Icon { get => (IconElement?)GetValue(IconProperty); set => SetValue(IconProperty, value); }
}