更新整理

This commit is contained in:
GG Z
2025-04-24 20:56:44 +08:00
parent 155cef46f8
commit 5b6d67b571
813 changed files with 14437 additions and 12362 deletions

View File

@@ -2,9 +2,9 @@
namespace WPFluent.Controls;
public class ChooseBox : TextBox
public class ChooseBox : System.Windows.Controls.TextBox
{
private Button PART_ChooseButton;
private System.Windows.Controls.Button PART_ChooseButton;
static ChooseBox()
{ DefaultStyleKeyProperty.OverrideMetadata(typeof(ChooseBox), new FrameworkPropertyMetadata(typeof(ChooseBox))); }
@@ -12,24 +12,39 @@ public class ChooseBox : TextBox
#region Event Implement Function
private void PART_ChooseButton_Click(object sender, RoutedEventArgs e)
{
switch(ChooseBoxType)
switch (ChooseBoxType)
{
case ChooseBoxType.SingleFile:
OpenFileDialog openFileDialog =
new()
{
Multiselect = false,
//"文本文件|*.*|C#文件|*.cs|所有文件|*.*"
Filter = Filter
};
if(openFileDialog.ShowDialog() == true)
{
Multiselect = false,
//"文本文件|*.*|C#文件|*.cs|所有文件|*.*"
Filter = Filter
};
if (openFileDialog.ShowDialog() == true)
this.Text = openFileDialog.FileName;
break;
case ChooseBoxType.MultiFile:
OpenFileDialog multiFileDialog =
new()
{
Multiselect = true,
Filter = Filter
};
if (multiFileDialog.ShowDialog() == true)
{
string fileName = string.Empty;
foreach (var item in multiFileDialog.FileNames)
{
fileName += item + ";";
}
this.Text = fileName.TrimEnd(';');
}
break;
case ChooseBoxType.Folder:
var folderDialog = new VistaFolderBrowserDialog();
if(folderDialog.ShowDialog() == true)
if (folderDialog.ShowDialog() == true)
this.Text = folderDialog.SelectedPath;
break;
case ChooseBoxType.SaveFile:
@@ -40,7 +55,7 @@ public class ChooseBox : TextBox
DefaultExt = DefaultExt, //设置默认格式(可以不设)
AddExtension = true //设置自动在文件名中添加扩展名
};
if(fileDialog.ShowDialog() == true)
if (fileDialog.ShowDialog() == true)
this.Text = fileDialog.FileName;
break;
}
@@ -51,9 +66,8 @@ public class ChooseBox : TextBox
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
PART_ChooseButton = this.GetTemplateChild("PART_ChooseButton") as Button;
if(PART_ChooseButton != null)
PART_ChooseButton = this.GetTemplateChild("PART_ChooseButton") as System.Windows.Controls.Button;
if (PART_ChooseButton != null)
{
PART_ChooseButton.Click += PART_ChooseButton_Click;
}
@@ -140,5 +154,5 @@ public class ChooseBox : TextBox
typeof(string),
typeof(ChooseBox),
new PropertyMetadata(string.Empty));
#endregion
#endregion
}

View File

@@ -5,6 +5,7 @@
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Resources/DesignTime.xaml" />-->
<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Resources/Variables.xaml" />
<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Controls/TextBox/TextBox.xaml" />
</ResourceDictionary.MergedDictionaries>
<PathGeometry x:Key="icon" Figures="M147.01175 430.890704c-44.791136 0-81.108273 36.303834-81.108273 81.109296 0 44.778856 36.316114 81.108273 81.108273 81.108273 44.792159 0 81.109296-36.329417 81.109296-81.108273C228.121046 467.194538 191.804932 430.890704 147.01175 430.890704zM511.999488 430.890704c-44.791136 0-81.108273 36.303834-81.108273 81.109296 0 44.778856 36.316114 81.108273 81.108273 81.108273 44.792159 0 81.109296-36.329417 81.109296-81.108273C593.108784 467.194538 556.791647 430.890704 511.999488 430.890704zM876.987227 430.890704c-44.791136 0-81.108273 36.303834-81.108273 81.109296 0 44.778856 36.316114 81.108273 81.108273 81.108273s81.108273-36.329417 81.108273-81.108273C958.094476 467.194538 921.778362 430.890704 876.987227 430.890704z" />
<Style TargetType="{x:Type controls:ChooseBox}">
@@ -52,7 +53,7 @@
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<controls:PassiveScrollViewer
Name="PART_ContentHost"
x:Name="PART_ContentHost"
Margin="{TemplateBinding Padding}"
Foreground="{TemplateBinding Foreground}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
@@ -65,7 +66,7 @@
x:Name="PART_ChooseButton"
Grid.Column="1"
Width="{TemplateBinding ChooseButtonWidth}"
Foreground="{TemplateBinding BorderBrush}"
Foreground="{TemplateBinding Foreground}"
Style="{TemplateBinding ChooseButtonStyle}" />
</Grid>
</Border>