添加项目文件。

This commit is contained in:
GG Z
2024-09-22 11:05:41 +08:00
parent fb5d55723a
commit 49ceaae6a8
764 changed files with 78850 additions and 0 deletions

View File

@@ -0,0 +1,302 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:exc="clr-namespace:Wpf.Ui.Extend.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/Wpf.Ui;component/Controls/TextBox/TextBox.xaml" />
</ResourceDictionary.MergedDictionaries>
<ControlTemplate x:Key="DefaultUiTextBoxExControlTemplate" TargetType="{x:Type exc:TextBoxEx}">
<DockPanel>
<TextBlock
x:Name="Header_TextBlock"
Margin="5"
VerticalAlignment="Center"
DockPanel.Dock="{TemplateBinding HeaderPlacement}"
Focusable="False"
Foreground="{TemplateBinding Foreground}"
Text="{TemplateBinding Header}" />
<Grid
x:Name="Grid"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Border
Name="ContentBorder"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
Name="ControlIconLeft"
Grid.Column="0"
Margin="{StaticResource TextBoxLeftIconMargin}"
VerticalAlignment="Center"
Content="{TemplateBinding Icon}"
Focusable="False"
TextElement.FontSize="{TemplateBinding FontSize}"
Visibility="Visible" />
<TextBlock
x:Name="PART_Prefix"
Grid.Column="1"
Padding="4,0"
VerticalAlignment="Center"
Foreground="{DynamicResource TextControlPlaceholderForeground}"
IsHitTestVisible="False"
Text="{TemplateBinding Prefix}" />
<!-- 内容 -->
<Grid
Grid.Column="2"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<controls:PassiveScrollViewer
Name="PART_ContentHost"
Foreground="{TemplateBinding Foreground}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
ScrollViewer.CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
ScrollViewer.HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
ScrollViewer.VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
Style="{DynamicResource DefaultTextBoxScrollViewerStyle}" />
<TextBlock
Name="PlaceholderTextBlock"
Margin="0"
Padding="1,0"
VerticalAlignment="Center"
Foreground="{DynamicResource TextControlPlaceholderForeground}"
Text="{TemplateBinding PlaceholderText}"
TextBlock.FontSize="{TemplateBinding FontSize}" />
</Grid>
<controls:Button
Name="ClearButton"
Grid.Column="3"
MinWidth="{StaticResource TextBoxClearButtonHeight}"
MinHeight="{StaticResource TextBoxClearButtonHeight}"
Margin="{StaticResource TextBoxClearButtonMargin}"
Padding="{StaticResource TextBoxClearButtonPadding}"
HorizontalAlignment="Center"
VerticalAlignment="Center"
HorizontalContentAlignment="Center"
VerticalContentAlignment="Center"
Appearance="Secondary"
Background="Transparent"
BorderBrush="Transparent"
Command="{Binding Path=TemplateButtonCommand, RelativeSource={RelativeSource TemplatedParent}}"
Cursor="Arrow"
Foreground="{DynamicResource TextControlButtonForeground}"
IsTabStop="False">
<controls:Button.Icon>
<controls:SymbolIcon FontSize="{TemplateBinding FontSize}" Symbol="Dismiss24" />
</controls:Button.Icon>
</controls:Button>
<TextBlock
x:Name="PART_Suffix"
Grid.Column="4"
Padding="4,0"
VerticalAlignment="Center"
Foreground="{DynamicResource TextControlPlaceholderForeground}"
IsHitTestVisible="False"
Text="{TemplateBinding Suffix}" />
<ContentPresenter
Name="ControlIconRight"
Grid.Column="5"
Margin="{StaticResource TextBoxRightIconMargin}"
VerticalAlignment="Center"
Content="{TemplateBinding Icon}"
TextElement.FontSize="{TemplateBinding FontSize}" />
</Grid>
</Border>
<Border
Name="AccentBorder"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
BorderThickness="{StaticResource TextBoxAccentBorderThemeThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}" />
</Grid>
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="Header" Value="{x:Null}">
<Setter TargetName="Header_TextBlock" Property="Margin" Value="0" />
<Setter TargetName="Header_TextBlock" Property="Visibility" Value="Collapsed" />
</Trigger>
<!-- 标题左右对齐时,控制最小宽度 -->
<Trigger Property="HeaderPlacement" Value="Left">
<Setter TargetName="Grid" Property="MinWidth" Value="80" />
<Setter TargetName="Header_TextBlock" Property="HorizontalAlignment" Value="Right" />
</Trigger>
<Trigger Property="HeaderPlacement" Value="Right">
<Setter TargetName="Grid" Property="MinWidth" Value="80" />
<Setter TargetName="Header_TextBlock" Property="HorizontalAlignment" Value="Left" />
</Trigger>
<Trigger Property="exc:TextBoxEx.PlaceholderEnabled" Value="False">
<Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="exc:TextBoxEx.ShowClearButton" Value="False">
<Setter TargetName="ClearButton" Property="Visibility" Value="Collapsed" />
<Setter TargetName="ClearButton" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="exc:TextBoxEx.ClearButtonEnabled" Value="False">
<Setter TargetName="ClearButton" Property="Visibility" Value="Collapsed" />
<Setter TargetName="ClearButton" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="exc:TextBoxEx.IconPlacement" Value="Left">
<Setter TargetName="ControlIconRight" Property="Visibility" Value="Collapsed" />
<Setter TargetName="ControlIconRight" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="exc:TextBoxEx.IconPlacement" Value="Right">
<Setter TargetName="ControlIconLeft" Property="Visibility" Value="Collapsed" />
<Setter TargetName="ControlIconLeft" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="exc:TextBoxEx.Icon" Value="{x:Null}">
<Setter TargetName="ControlIconRight" Property="Visibility" Value="Collapsed" />
<Setter TargetName="ControlIconRight" Property="Margin" Value="0" />
<Setter TargetName="ControlIconLeft" Property="Visibility" Value="Collapsed" />
<Setter TargetName="ControlIconLeft" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="UIElement.IsFocused" Value="True">
<Setter TargetName="AccentBorder" Property="BorderThickness" Value="0,0,0,2" />
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlFocusedBorderBrush}" />
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundFocused}" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
<Condition Property="UIElement.IsMouseOver" Value="True" />
<Condition Property="UIElement.IsFocused" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundPointerOver}" />
</MultiTrigger>
<Trigger Property="TextBoxBase.IsReadOnly" Value="True">
<Setter TargetName="ClearButton" Property="Visibility" Value="Collapsed" />
<Setter TargetName="ClearButton" Property="Margin" Value="0" />
</Trigger>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="FrameworkElement.Cursor" Value="IBeam" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource TextControlBackgroundDisabled}" />
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
<Setter TargetName="AccentBorder" Property="BorderBrush" Value="{DynamicResource TextControlBorderBrushDisabled}" />
<Setter TargetName="ControlIconLeft" Property="TextElement.Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
<Setter TargetName="ControlIconRight" Property="TextElement.Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
<Setter TargetName="PlaceholderTextBlock" Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundDisabled}" />
<Setter Property="exc:TextBoxEx.ClearButtonEnabled" Value="False" />
</Trigger>
<Trigger Property="Prefix" Value="{x:Null}">
<Setter TargetName="PART_Prefix" Property="Margin" Value="0" />
<Setter TargetName="PART_Prefix" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="Suffix" Value="{x:Null}">
<Setter TargetName="PART_Suffix" Property="Margin" Value="0" />
<Setter TargetName="PART_Suffix" Property="Visibility" Value="Collapsed" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate x:Key="DefaultUiTextBoxTextExSelectionEnabledControlTemplate" TargetType="{x:Type exc:TextBoxEx}">
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Border
Name="ContentBorder"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}"
Focusable="False">
<Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid Margin="{TemplateBinding Padding}">
<controls:PassiveScrollViewer
Name="PART_ContentHost"
Foreground="{TemplateBinding Foreground}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
ScrollViewer.CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
ScrollViewer.HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
ScrollViewer.VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
Style="{DynamicResource DefaultTextBoxScrollViewerStyle}" />
</Grid>
</Grid>
</Border>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="TextBoxExErrorTemplate">
<StackPanel>
<AdornedElementPlaceholder Name="Adorner" />
<TextBlock
HorizontalAlignment="Right"
Foreground="Red"
Text="{Binding ElementName=Adorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
</StackPanel>
</ControlTemplate>
<Style x:Key="DefaultUiTextBoxExStyle" TargetType="{x:Type exc:TextBoxEx}">
<Setter Property="FrameworkElement.FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
<Setter Property="FrameworkElement.ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" />
<Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="TextBoxBase.CaretBrush" Value="{DynamicResource TextControlForeground}" />
<Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextControlElevationBorderBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource TextBoxBorderThemeThickness}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="MinHeight" Value="{DynamicResource TextControlThemeMinHeight}" />
<Setter Property="MinWidth" Value="{DynamicResource TextControlThemeMinWidth}" />
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
<Setter Property="Border.CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="exc:TextBoxEx.ClearButtonEnabled" Value="True" />
<Setter Property="exc:TextBoxEx.IconPlacement" Value="Left" />
<Setter Property="UIElement.SnapsToDevicePixels" Value="True" />
<Setter Property="FrameworkElement.OverridesDefaultStyle" Value="True" />
<Setter Property="Validation.ErrorTemplate" Value="{StaticResource TextBoxExErrorTemplate}" />
<Style.Triggers>
<Trigger Property="HeaderPlacement" Value="Left">
<Setter Property="HorizontalAlignment" Value="Right" />
</Trigger>
<Trigger Property="HeaderPlacement" Value="Right">
<Setter Property="HorizontalAlignment" Value="Left" />
</Trigger>
<Trigger Property="exc:TextBoxEx.IsTextSelectionEnabled" Value="False">
<Setter Property="Template" Value="{StaticResource DefaultUiTextBoxExControlTemplate}" />
</Trigger>
<Trigger Property="exc:TextBoxEx.IsTextSelectionEnabled" Value="True">
<Setter Property="TextBoxBase.IsReadOnly" Value="True" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Padding" Value="0" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template" Value="{StaticResource DefaultUiTextBoxTextExSelectionEnabledControlTemplate}" />
</Trigger>
</Style.Triggers>
</Style>
<Style BasedOn="{StaticResource DefaultUiTextBoxExStyle}" TargetType="{x:Type exc:TextBoxEx}" />
</ResourceDictionary>

View File

@@ -0,0 +1,57 @@
using System.Windows;
using System.Windows.Controls;
namespace Wpf.Ui.Extend.Controls
{
public class TextBoxEx : Wpf.Ui.Controls.TextBox
{
static TextBoxEx()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(TextBoxEx), new FrameworkPropertyMetadata(typeof(TextBoxEx)));
}
public string Prefix
{
get { return (string)GetValue(PrefixProperty); }
set { SetValue(PrefixProperty, value); }
}
// Using a DependencyProperty as the backing store for Prefix. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PrefixProperty =
DependencyProperty.Register(nameof(Prefix), typeof(string), typeof(TextBoxEx), new PropertyMetadata(null));
public string Suffix
{
get { return (string)GetValue(SuffixProperty); }
set { SetValue(SuffixProperty, value); }
}
// Using a DependencyProperty as the backing store for Suffix. This enables animation, styling, binding, etc...
public static readonly DependencyProperty SuffixProperty =
DependencyProperty.Register(nameof(Suffix), typeof(string), typeof(TextBoxEx), new PropertyMetadata(null));
public string Header
{
get { return (string)GetValue(HeaderProperty); }
set { SetValue(HeaderProperty, value); }
}
public static readonly DependencyProperty HeaderProperty =
DependencyProperty.Register(nameof(Header), typeof(string), typeof(TextBoxEx), new PropertyMetadata(null));
public Dock HeaderPlacement
{
get { return (Dock)GetValue(HeaderPlacementProperty); }
set { SetValue(HeaderPlacementProperty, value); }
}
public static readonly DependencyProperty HeaderPlacementProperty =
DependencyProperty.Register(nameof(HeaderPlacement), typeof(Dock), typeof(TextBoxEx), new PropertyMetadata(Dock.Top));
}
}