From 72ae2097f11657c88b32373206d7e1bc782853c1 Mon Sep 17 00:00:00 2001 From: SlimeNull Date: Sat, 6 Jul 2024 14:17:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=20FluentDesign=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eCho - Backup.WpfSuite.FluentDesign.csproj | 43 +++++ .../EleCho.WpfSuite.FluentDesign.csproj | 13 +- .../FluentDesignResourceKey.cs | 23 +++ .../FluentDesignResources.cs | 28 +++- .../FluentDesignThemeResources.cs | 62 +++++++ .../OverviewResources.xaml} | 50 ++---- .../Styles/PasswordBoxResources.xaml | 153 +++++++++++++++++ .../Styles/TextBoxResources.xaml | 154 ++++++++++++++++++ EleCho.WpfSuite.FluentDesign/Themes/Dark.xaml | 7 + .../Themes/Light.xaml | 54 ++++++ EleCho.WpfSuite.sln | 2 +- WpfTest/Tests/PanelsTestPage.xaml | 2 +- WpfTest/Tests/ScrollTestPage.xaml | 120 +++++++------- WpfTest/Tests/TempPage.xaml | 57 +++---- WpfTest/Tests/TempPage.xaml.cs | 14 +- WpfTest/Tests/TextBoxTestPage.xaml | 9 +- WpfTest/WelcomePage.xaml | 42 ++++- WpfTest/WelcomePage.xaml.cs | 11 ++ 18 files changed, 676 insertions(+), 168 deletions(-) create mode 100644 EleCho.WpfSuite.FluentDesign/EleCho - Backup.WpfSuite.FluentDesign.csproj create mode 100644 EleCho.WpfSuite.FluentDesign/FluentDesignResourceKey.cs create mode 100644 EleCho.WpfSuite.FluentDesign/FluentDesignThemeResources.cs rename EleCho.WpfSuite.FluentDesign/{FluentDesignResources.xaml => Styles/OverviewResources.xaml} (74%) create mode 100644 EleCho.WpfSuite.FluentDesign/Styles/PasswordBoxResources.xaml create mode 100644 EleCho.WpfSuite.FluentDesign/Styles/TextBoxResources.xaml create mode 100644 EleCho.WpfSuite.FluentDesign/Themes/Dark.xaml create mode 100644 EleCho.WpfSuite.FluentDesign/Themes/Light.xaml diff --git a/EleCho.WpfSuite.FluentDesign/EleCho - Backup.WpfSuite.FluentDesign.csproj b/EleCho.WpfSuite.FluentDesign/EleCho - Backup.WpfSuite.FluentDesign.csproj new file mode 100644 index 0000000..590103b --- /dev/null +++ b/EleCho.WpfSuite.FluentDesign/EleCho - Backup.WpfSuite.FluentDesign.csproj @@ -0,0 +1,43 @@ + + + + net8.0-windows;net6.0-windows;net48;net47;net46;net45 + enable + latest + true + true + EleCho.WpfSuite + + 0.0.1 + + EleCho + Copyright © 2024 EleCho + https://github.com/OrgEleCho/EleCho.WpfSuite + logo.png + WPF;MVVM;Toolkit;Controls;Converters;BindingProxy + WPF layout panels, controls, value converters, utilities suite + MIT + README.md + + + + + + + + + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + diff --git a/EleCho.WpfSuite.FluentDesign/EleCho.WpfSuite.FluentDesign.csproj b/EleCho.WpfSuite.FluentDesign/EleCho.WpfSuite.FluentDesign.csproj index 79b964a..df8d591 100644 --- a/EleCho.WpfSuite.FluentDesign/EleCho.WpfSuite.FluentDesign.csproj +++ b/EleCho.WpfSuite.FluentDesign/EleCho.WpfSuite.FluentDesign.csproj @@ -21,15 +21,22 @@ - + - + - + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + diff --git a/EleCho.WpfSuite.FluentDesign/FluentDesignResourceKey.cs b/EleCho.WpfSuite.FluentDesign/FluentDesignResourceKey.cs new file mode 100644 index 0000000..94b066e --- /dev/null +++ b/EleCho.WpfSuite.FluentDesign/FluentDesignResourceKey.cs @@ -0,0 +1,23 @@ +using System.Reflection; +using System.Windows; + +namespace EleCho.WpfSuite.FluentDesign +{ + public class FluentDesignResourceKey : ResourceKey + { + private static readonly Assembly s_thisAssembly = Assembly.GetExecutingAssembly(); + + public override Assembly Assembly => s_thisAssembly; + + public string Name { get; set; } = string.Empty; + + public FluentDesignResourceKey(string name) + { + Name = name; + } + + public FluentDesignResourceKey() + { + } + } +} diff --git a/EleCho.WpfSuite.FluentDesign/FluentDesignResources.cs b/EleCho.WpfSuite.FluentDesign/FluentDesignResources.cs index 244780c..981a926 100644 --- a/EleCho.WpfSuite.FluentDesign/FluentDesignResources.cs +++ b/EleCho.WpfSuite.FluentDesign/FluentDesignResources.cs @@ -4,20 +4,32 @@ namespace EleCho.WpfSuite.FluentDesign { - public class FluentDesignResourceKey : ResourceKey - { - private static readonly Assembly s_thisAssembly = Assembly.GetExecutingAssembly(); - - public override Assembly Assembly => s_thisAssembly; - } public class FluentDesignResources : ResourceDictionary { + FluentDesignThemeResources _themeResource; + ResourceDictionary _overviewResources; + public FluentDesignResources() { - MergedDictionaries.Add(new ResourceDictionary() { Source = new Uri("pack://application:,,,/EleCho.WpfSuite.FluentDesign;component/FluentDesignResources.xaml") }); + _themeResource = new FluentDesignThemeResources(); + _overviewResources = new ResourceDictionary() { Source = new Uri("pack://application:,,,/EleCho.WpfSuite.FluentDesign;component/Styles/OverviewResources.xaml") }; + + MergedDictionaries.Add(_themeResource); + MergedDictionaries.Add(_overviewResources); } - + public bool IsDarkMode + { + get => _themeResource.IsDarkMode; + set => _themeResource.IsDarkMode = value; + } + + + // color keys + public static readonly FluentDesignResourceKey PrimaryColorKey = new FluentDesignResourceKey(nameof(PrimaryColorKey)); + + // brush keys + public static readonly FluentDesignResourceKey PrimaryBrushKey = new FluentDesignResourceKey(nameof(PrimaryBrushKey)); } } diff --git a/EleCho.WpfSuite.FluentDesign/FluentDesignThemeResources.cs b/EleCho.WpfSuite.FluentDesign/FluentDesignThemeResources.cs new file mode 100644 index 0000000..729d948 --- /dev/null +++ b/EleCho.WpfSuite.FluentDesign/FluentDesignThemeResources.cs @@ -0,0 +1,62 @@ +using System; +using System.Windows; + +namespace EleCho.WpfSuite.FluentDesign +{ + public class FluentDesignThemeResources : ResourceDictionary + { + private readonly ResourceDictionary _lightThemeResources = new(); + private readonly ResourceDictionary _darkThemeResources = new(); + + public FluentDesignThemeResources() + { + _lightThemeResources = new ResourceDictionary() { Source = new Uri("pack://application:,,,/EleCho.WpfSuite.FluentDesign;component/Themes/Light.xaml") }; + _darkThemeResources = new ResourceDictionary() { Source = new Uri("pack://application:,,,/EleCho.WpfSuite.FluentDesign;component/Themes/Dark.xaml") }; + + MergedDictionaries.Add(_lightThemeResources); + } + + public bool IsDarkMode + { + get => MergedDictionaries.Contains(_darkThemeResources); + set + { + MergedDictionaries.Clear(); + + if (value) + { + MergedDictionaries.Add(_darkThemeResources); + } + else + { + MergedDictionaries.Add(_lightThemeResources); + } + } + } + + // color keys + public static readonly FluentDesignResourceKey TextColorKey = new FluentDesignResourceKey(nameof(TextColorKey)); + + public static readonly FluentDesignResourceKey ControlBackgroundColorKey = new FluentDesignResourceKey(nameof(ControlBackgroundColorKey)); + public static readonly FluentDesignResourceKey ControlHoverBackgroundColorKey = new FluentDesignResourceKey(nameof(ControlHoverBackgroundColorKey)); + public static readonly FluentDesignResourceKey ControlPressedBackgroundColorKey = new FluentDesignResourceKey(nameof(ControlPressedBackgroundColorKey)); + + public static readonly FluentDesignResourceKey TextBoxBackgroundColorKey = new FluentDesignResourceKey(nameof(TextBoxBackgroundColorKey)); + public static readonly FluentDesignResourceKey TextBoxHoverBackgroundColorKey = new FluentDesignResourceKey(nameof(TextBoxHoverBackgroundColorKey)); + public static readonly FluentDesignResourceKey TextBoxFocusedBackgroundColorKey = new FluentDesignResourceKey(nameof(TextBoxFocusedBackgroundColorKey)); + + + // brush keys + public static readonly FluentDesignResourceKey TextBrushKey = new FluentDesignResourceKey(nameof(TextBrushKey)); + + public static readonly FluentDesignResourceKey ControlBackgroundBrushKey = new FluentDesignResourceKey(nameof(ControlBackgroundBrushKey)); + public static readonly FluentDesignResourceKey ControlHoverBackgroundBrushKey = new FluentDesignResourceKey(nameof(ControlHoverBackgroundBrushKey)); + public static readonly FluentDesignResourceKey ControlPressedBackgroundBrushKey = new FluentDesignResourceKey(nameof(ControlPressedBackgroundBrushKey)); + public static readonly FluentDesignResourceKey ControlBorderBrushKey = new FluentDesignResourceKey(nameof(ControlBorderBrushKey)); + + public static readonly FluentDesignResourceKey TextBoxBackgroundBrushKey = new FluentDesignResourceKey(nameof(TextBoxBackgroundBrushKey)); + public static readonly FluentDesignResourceKey TextBoxHoverBackgroundBrushKey = new FluentDesignResourceKey(nameof(TextBoxHoverBackgroundBrushKey)); + public static readonly FluentDesignResourceKey TextBoxFocusedBackgroundBrushKey = new FluentDesignResourceKey(nameof(TextBoxFocusedBackgroundBrushKey)); + public static readonly FluentDesignResourceKey TextBoxBorderBrushKey = new FluentDesignResourceKey(nameof(TextBoxBorderBrushKey)); + } +} diff --git a/EleCho.WpfSuite.FluentDesign/FluentDesignResources.xaml b/EleCho.WpfSuite.FluentDesign/Styles/OverviewResources.xaml similarity index 74% rename from EleCho.WpfSuite.FluentDesign/FluentDesignResources.xaml rename to EleCho.WpfSuite.FluentDesign/Styles/OverviewResources.xaml index 97c410e..fd17cf9 100644 --- a/EleCho.WpfSuite.FluentDesign/FluentDesignResources.xaml +++ b/EleCho.WpfSuite.FluentDesign/Styles/OverviewResources.xaml @@ -1,12 +1,16 @@  - SimpleDesign + + + + - #0067c0 - + #0067c0 + @@ -23,40 +27,16 @@ - + - - - - + \ No newline at end of file diff --git a/EleCho.WpfSuite.FluentDesign/Styles/TextBoxResources.xaml b/EleCho.WpfSuite.FluentDesign/Styles/TextBoxResources.xaml new file mode 100644 index 0000000..72c20fd --- /dev/null +++ b/EleCho.WpfSuite.FluentDesign/Styles/TextBoxResources.xaml @@ -0,0 +1,154 @@ + + + + \ No newline at end of file diff --git a/EleCho.WpfSuite.FluentDesign/Themes/Dark.xaml b/EleCho.WpfSuite.FluentDesign/Themes/Dark.xaml new file mode 100644 index 0000000..afe41e4 --- /dev/null +++ b/EleCho.WpfSuite.FluentDesign/Themes/Dark.xaml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/EleCho.WpfSuite.FluentDesign/Themes/Light.xaml b/EleCho.WpfSuite.FluentDesign/Themes/Light.xaml new file mode 100644 index 0000000..773e3d6 --- /dev/null +++ b/EleCho.WpfSuite.FluentDesign/Themes/Light.xaml @@ -0,0 +1,54 @@ + + + White + + #EEFFFFFF + #88FFFFFF + #44FFFFFF + + #AAFFFFFF + #66FFFFFF + White + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EleCho.WpfSuite.sln b/EleCho.WpfSuite.sln index 172b5ca..d6d80f6 100644 --- a/EleCho.WpfSuite.sln +++ b/EleCho.WpfSuite.sln @@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "解决方案项", "解决 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EleCho.WpfSuite.SimpleDesign", "EleCho.WpfSuite.SimpleDesign\EleCho.WpfSuite.SimpleDesign.csproj", "{EAD122E7-549D-4057-83C4-DCD2A04E4481}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EleCho.WpfSuite.FluentDesign", "EleCho.WpfSuite.FluentDesign\EleCho.WpfSuite.FluentDesign.csproj", "{B1568882-49D8-4D6A-8DC9-8BFFC0D46104}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EleCho.WpfSuite.FluentDesign", "EleCho.WpfSuite.FluentDesign\EleCho.WpfSuite.FluentDesign.csproj", "{B1568882-49D8-4D6A-8DC9-8BFFC0D46104}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/WpfTest/Tests/PanelsTestPage.xaml b/WpfTest/Tests/PanelsTestPage.xaml index ee59ba6..422d41e 100644 --- a/WpfTest/Tests/PanelsTestPage.xaml +++ b/WpfTest/Tests/PanelsTestPage.xaml @@ -7,7 +7,7 @@ xmlns:ws="https://schemas.elecho.dev/wpfsuite" mc:Ignorable="d" xmlns:i="http://schemas.microsoft.com/xaml/behaviors" - d:DesignHeight="450" d:DesignWidth="800" + d:DesignHeight="950" d:DesignWidth="800" d:Background="White" Title="PanelsTestPage"> diff --git a/WpfTest/Tests/ScrollTestPage.xaml b/WpfTest/Tests/ScrollTestPage.xaml index b0236f1..aa40f5d 100644 --- a/WpfTest/Tests/ScrollTestPage.xaml +++ b/WpfTest/Tests/ScrollTestPage.xaml @@ -44,36 +44,36 @@ Padding="14" Clip="{Binding RelativeSource={RelativeSource AncestorType=ws:Border},Path=ContentClip}"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -89,36 +89,36 @@ MouseScrollDeltaFactor="-1" Clip="{Binding RelativeSource={RelativeSource AncestorType=ws:Border},Path=ContentClip}"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WpfTest/Tests/TempPage.xaml b/WpfTest/Tests/TempPage.xaml index d35f9f3..a5b631b 100644 --- a/WpfTest/Tests/TempPage.xaml +++ b/WpfTest/Tests/TempPage.xaml @@ -23,6 +23,23 @@ + + + + + + + + + + + + @@ -33,7 +50,7 @@ MaxHeight="300" Placeholder="Multi line TextBox"/> - @@ -99,42 +116,6 @@ CornerRadius="10" IsIndeterminate="True"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/WpfTest/Tests/TempPage.xaml.cs b/WpfTest/Tests/TempPage.xaml.cs index 6768a91..a1779b6 100644 --- a/WpfTest/Tests/TempPage.xaml.cs +++ b/WpfTest/Tests/TempPage.xaml.cs @@ -27,15 +27,6 @@ public TempPage() InitializeComponent(); } - bool flag = false; - private void Button_Click(object sender, RoutedEventArgs e) - { - var targetState = flag ? "Normal" : "TestState"; - flag ^= true; - - VisualStateManager.GoToElementState(testBorder, targetState, true); - } - [ObservableProperty] private Brush? _currentBrush; @@ -43,5 +34,10 @@ partial void OnCurrentBrushChanged(Brush? value) { Debug.WriteLine(value); } + + private void Button_Click(object sender, RoutedEventArgs e) + { + buttonContentControl.Content = System.IO.Path.GetRandomFileName(); + } } } diff --git a/WpfTest/Tests/TextBoxTestPage.xaml b/WpfTest/Tests/TextBoxTestPage.xaml index a511b41..0b936be 100644 --- a/WpfTest/Tests/TextBoxTestPage.xaml +++ b/WpfTest/Tests/TextBoxTestPage.xaml @@ -18,15 +18,13 @@ Margin="0 0 0 12"/> - - @@ -36,8 +34,7 @@ + MinWidth="200"/> diff --git a/WpfTest/WelcomePage.xaml b/WpfTest/WelcomePage.xaml index 340a835..de323e0 100644 --- a/WpfTest/WelcomePage.xaml +++ b/WpfTest/WelcomePage.xaml @@ -53,16 +53,44 @@ Padding="5"/> - + - + Focusable="True" + ws:WindowOption.Backdrop="Mica"> + + + - + Height="250" + x:Name="PopupContent"> + + + + + + + + + + + + + + + + + diff --git a/WpfTest/WelcomePage.xaml.cs b/WpfTest/WelcomePage.xaml.cs index 083888c..5c6914c 100644 --- a/WpfTest/WelcomePage.xaml.cs +++ b/WpfTest/WelcomePage.xaml.cs @@ -31,6 +31,9 @@ public partial class WelcomePage : Page [ObservableProperty] private bool _transitionReverse; + [ObservableProperty] + private bool _popupOpen; + public ObservableCollection ImageSources { get; } = new() { new BitmapImage(new Uri("pack://application:,,,/WpfTest;component/Assets/Banners/1.jpg")), @@ -49,6 +52,14 @@ public WelcomePage() DataContext = this; } + [RelayCommand] + public async void TogglePopup() + { + await Task.Yield(); + + PopupOpen ^= true; + } + [RelayCommand] public void GoPrev() {