From b44c2ccd8c7a1be5c3ea0e50f5c0d2120245fafe Mon Sep 17 00:00:00 2001 From: SlimeNull Date: Fri, 30 Aug 2024 16:41:40 +0800 Subject: [PATCH] feat: more about fluent design --- .../FluentResource.cs | 154 +++++++++++-- .../FluentResourceNames.txt | 133 +++++++++++ .../Styles/OverviewResources.xaml | 100 +++++---- .../Styles/PasswordBoxResources.xaml | 38 ++-- .../Styles/TextBoxResources.xaml | 38 ++-- EleCho.WpfSuite.FluentDesign/Themes/Dark.xaml | 166 +++++++++++++- .../Themes/Light.xaml | 210 +++++++++++++----- EleCho.WpfSuite/Controls/ScrollBar.cs | 10 +- .../Controls/ScrollBarResources.xaml | 154 +++++++++++-- EleCho.WpfSuite/Controls/Thumb.cs | 37 ++- EleCho.WpfSuite/Controls/ThumbResources.xaml | 81 ++++++- WpfTest/MainWindow.xaml | 9 +- WpfTest/Tests/TempPage.xaml | 8 + WpfTest/Tests/TempPage.xaml.cs | 17 ++ 14 files changed, 964 insertions(+), 191 deletions(-) create mode 100644 EleCho.WpfSuite.FluentDesign/FluentResourceNames.txt diff --git a/EleCho.WpfSuite.FluentDesign/FluentResource.cs b/EleCho.WpfSuite.FluentDesign/FluentResource.cs index 7cfeb61..33a67bc 100644 --- a/EleCho.WpfSuite.FluentDesign/FluentResource.cs +++ b/EleCho.WpfSuite.FluentDesign/FluentResource.cs @@ -2,25 +2,139 @@ { public enum FluentResource { - TextColor, - PrimaryColor, - ControlBackgroundColor, - ControlHoverBackgroundColor, - ControlPressedBackgroundColor, - TextControlBackgroundColor, - TextControlHoverBackgroundColor, - TextControlFocusedBackgroundColor, - - TextBrush, - PrimaryBrush, - ControlBackgroundBrush, - ControlHoverBackgroundBrush, - ControlPressedBackgroundBrush, - TextControlBackgroundBrush, - TextControlHoverBackgroundBrush, - TextControlFocusedBackgroundBrush, - - ControlBorderBrush, - TextControlBorderBrush, + TextFillColorPrimaryBrush, + TextFillColorSecondaryBrush, + TextFillColorTertiaryBrush, + TextFillColorDisabledBrush, + + AccentTextFillColorPrimaryBrush, + AccentTextFillColorSecondaryBrush, + AccentTextFillColorTertiaryBrush, + AccentTextFillColorDisabledBrush, + + TextOnAccentFillColorPrimaryBrush, + TextOnAccentFillColorSecondaryBrush, + TextOnAccentFillColorDisabledBrush, + TextOnAccentFillColorSelectedTextBrush, + + ControlFillColorDefaultBrush, + ControlFillColorSecondaryBrush, + ControlFillColorTertiaryBrush, + ControlFillColorQuarternaryBrush, + ControlFillColorDisabledBrush, + ControlFillColorTransparentBrush, + ControlFillColorInputActiveBrush, + + ControlAltFillColorTransparentBrush, + ControlAltFillColorSecondaryBrush, + ControlAltFillColorTertiaryBrush, + ControlAltFillColorQuarternaryBrush, + ControlAltFillColorDisabledBrush, + + ControlSolidFillColorDefaultBrush, + ControlStrongFillColorDefaultBrush, + ControlStrongFillColorDisabledBrush, + + SubtleFillColorTransparentBrush, + SubtleFillColorSecondaryBrush, + SubtleFillColorTertiaryBrush, + SubtleFillColorDisabledBrush, + + ControlOnImageFillColorDefaultBrush, + ControlOnImageFillColorSecondaryBrush, + ControlOnImageFillColorTertiaryBrush, + ControlOnImageFillColorDisabledBrush, + + AccentFillColorDefaultBrush, + AccentFillColorSecondaryBrush, + AccentFillColorTertiaryBrush, + AccentFillColorDisabledBrush, + AccentFillColorSelectedTextBackgroundBrush, + + CardStrokeColorDefaultBrush, + CardStrokeColorDefaultSolidBrush, + + ControlElevationBorderBrush, + CircleElevationBorderBrush, + TextControlElevationBorderBrush, + TextControlElevationBorderFocusedBrush, + AccentControlElevationBorderBrush, + + ControlStrokeColorDefaultBrush, + ControlStrokeColorSecondaryBrush, + ControlStrokeColorOnAccentDefaultBrush, + ControlStrokeColorOnAccentSecondaryBrush, + ControlStrokeColorOnAccentTertiaryBrush, + ControlStrokeColorOnAccentDisabledBrush, + ControlStrokeColorForStrongFillWhenOnImageBrush, + + ControlStrongStrokeColorDefaultBrush, + ControlStrongStrokeColorDisabledBrush, + + SurfaceStrokeColorDefaultBrush, + SurfaceStrokeColorFlyoutBrush, + + DividerStrokeColorDefaultBrush, + + FocusStrokeColorOuterBrush, + FocusStrokeColorInnerBrush, + + CardBackgroundFillColorDefaultBrush, + CardBackgroundFillColorSecondaryBrush, + CardBackgroundTertiaryBrush, + + SmokeFillColorDefaultBrush, + + LayerFillColorDefaultBrush, + LayerFillColorAltBrush, + + LayerOnAcrylicFillColorDefaultBrush, + + LayerOnMicaBaseAltFillColorDefaultBrush, + LayerOnMicaBaseAltFillColorTertiaryBrush, + LayerOnMicaBaseAltFillColorTransparentBrush, + LayerOnMicaBaseAltFillColorSecondaryBrush, + + SolidBackgroundFillColorBaseBrush, + SolidBackgroundFillColorBaseAltBrush, + SolidBackgroundFillColorSecondaryBrush, + SolidBackgroundFillColorTertiaryBrush, + SolidBackgroundFillColorQuarternaryBrush, + SolidBackgroundFillColorQuinaryBrush, + SolidBackgroundFillColorSenaryBrush, + + MicaBackgroundFillColorBaseBrush, + MicaBackgroundFillColorBaseAltBrush, + + AcrylicBackgroundFillColorBaseBrush, + AcrylicBackgroundFillColorDefaultBrush, + + AccentAcrylicBackgroundFillColorBaseBrush, + AccentAcrylicBackgroundFillColorDefaultBrush, + + + SystemFillColorSuccessBrush, + SystemFillColorCautionBrush, + SystemFillColorCriticalBrush, + SystemFillColorSuccessBackgroundBrush, + SystemFillColorCautionBackgroundBrush, + SystemFillColorCriticalBackgroundBrush, + SystemFillColorAttentionBrush, + SystemFillColorNeutralBrush, + SystemFillColorSolidNeutralBrush, + SystemFillColorAttentionBackgroundBrush, + SystemFillColorNeutralBackgroundBrush, + SystemFillColorSolidNeutralBackgroundBrush, + SystemFillColorSolidAttentionBackgroundBrush, + + SystemColorWindowTextColor, + SystemColorHighlightTextColor, + SystemColorButtonTextColor, + SystemColorHotlightColor, + SystemColorWindowColor, + SystemColorHighlightColor, + SystemColorButtonFaceColor, + SystemColorGreyTextColor, + } } diff --git a/EleCho.WpfSuite.FluentDesign/FluentResourceNames.txt b/EleCho.WpfSuite.FluentDesign/FluentResourceNames.txt new file mode 100644 index 0000000..c56eb71 --- /dev/null +++ b/EleCho.WpfSuite.FluentDesign/FluentResourceNames.txt @@ -0,0 +1,133 @@ +TextFillColorPrimaryBrush +TextFillColorSecondaryBrush +TextFillColorTertiaryBrush +TextFillColorDisabledBrush + +AccentTextFillColorPrimaryBrush +AccentTextFillColorSecondaryBrush +AccentTextFillColorTertiaryBrush +AccentTextFillColorDisabledBrush + +TextOnAccentFillColorPrimaryBrush +TextOnAccentFillColorSecondaryBrush +TextOnAccentFillColorDisabledBrush +TextOnAccentFillColorSelectedTextBrush + +ControlFillColorDefaultBrush +ControlFillColorSecondaryBrush +ControlFillColorTertiaryBrush +ControlFillColorQuarternaryBrush +ControlFillColorDisabledBrush +ControlFillColorTransparentBrush +ControlFillColorInputActiveBrush + +ControlAltFillColorTransparentBrush +ControlAltFillColorSecondaryBrush +ControlAltFillColorTertiaryBrush +ControlAltFillColorQuarternaryBrush +ControlAltFillColorDisabledBrush + +ControlSolidFillColorDefaultBrush +ControlStrongFillColorDefaultBrush +ControlStrongFillColorDisabledBrush + +SubtleFillColorTransparentBrush +SubtleFillColorSecondaryBrush +SubtleFillColorTertiaryBrush +SubtleFillColorDisabledBrush + +ControlOnImageFillColorDefaultBrush +ControlOnImageFillColorSecondaryBrush +ControlOnImageFillColorTertiaryBrush +ControlOnImageFillColorDisabledBrush + +AccentFillColorDefaultBrush +AccentFillColorSecondaryBrush +AccentFillColorTertiaryBrush +AccentFillColorDisabledBrush +AccentFillColorSelectedTextBackgroundBrush + +CardStrokeColorDefaultBrush +CardStrokeColorDefaultSolidBrush + +ControlElevationBorderBrush +CircleElevationBorderBrush +TextControlElevationBorderBrush +TextControlElevationBorderFocusedBrush +AccentControlElevationBorderBrush + +ControlStrokeColorDefaultBrush +ControlStrokeColorSecondaryBrush +ControlStrokeColorOnAccentDefaultBrush +ControlStrokeColorOnAccentSecondaryBrush +ControlStrokeColorOnAccentTertiaryBrush +ControlStrokeColorOnAccentDisabledBrush +ControlStrokeColorForStrongFillWhenOnImageBrush + +ControlStrongStrokeColorDefaultBrush +ControlStrongStrokeColorDisabledBrush + +SurfaceStrokeColorDefaultBrush +SurfaceStrokeColorFlyoutBrush + +DividerStrokeColorDefaultBrush + +FocusStrokeColorOuterBrush +FocusStrokeColorInnerBrush + +CardBackgroundFillColorDefaultBrush +CardBackgroundFillColorSecondaryBrush +CardBackgroundTertiaryBrush + +SmokeFillColorDefaultBrush + +LayerFillColorDefaultBrush +LayerFillColorAltBrush + +LayerOnAcrylicFillColorDefaultBrush + +LayerOnMicaBaseAltFillColorDefaultBrush +LayerOnMicaBaseAltFillColorTertiaryBrush +LayerOnMicaBaseAltFillColorTransparentBrush +LayerOnMicaBaseAltFillColorSecondaryBrush + +SolidBackgroundFillColorBaseBrush +SolidBackgroundFillColorBaseAltBrush +SolidBackgroundFillColorSecondaryBrush +SolidBackgroundFillColorTertiaryBrush +SolidBackgroundFillColorQuarternaryBrush +SolidBackgroundFillColorQuinaryBrush +SolidBackgroundFillColorSenaryBrush + +MicaBackgroundFillColorBaseBrush +MicaBackgroundFillColorBaseAltBrush + +AcrylicBackgroundFillColorBaseBrush +AcrylicBackgroundFillColorDefaultBrush + +AccentAcrylicBackgroundFillColorBaseBrush +AccentAcrylicBackgroundFillColorDefaultBrush + + +SystemFillColorSuccessBrush +SystemFillColorCautionBrush +SystemFillColorCriticalBrush +SystemFillColorSuccessBackgroundBrush +SystemFillColorCautionBackgroundBrush +SystemFillColorCriticalBackgroundBrush +SystemFillColorAttentionBrush +SystemFillColorNeutralBrush +SystemFillColorSolidNeutralBrush +SystemFillColorAttentionBackgroundBrush +SystemFillColorNeutralBackgroundBrush +SystemFillColorSolidNeutralBackgroundBrush +SystemFillColorSolidAttentionBackgroundBrush + +SystemColorWindowTextColor +SystemColorHighlightTextColor +SystemColorButtonTextColor +SystemColorHotlightColor +SystemColorWindowColor +SystemColorHighlightColor +SystemColorButtonFaceColor +SystemColorGreyTextColor diff --git a/EleCho.WpfSuite.FluentDesign/Styles/OverviewResources.xaml b/EleCho.WpfSuite.FluentDesign/Styles/OverviewResources.xaml index 3213926..974648c 100644 --- a/EleCho.WpfSuite.FluentDesign/Styles/OverviewResources.xaml +++ b/EleCho.WpfSuite.FluentDesign/Styles/OverviewResources.xaml @@ -9,51 +9,38 @@ - #0067c0 - - - + @@ -103,21 +91,29 @@ + + diff --git a/WpfTest/Tests/TempPage.xaml b/WpfTest/Tests/TempPage.xaml index 28eb8b0..a785caf 100644 --- a/WpfTest/Tests/TempPage.xaml +++ b/WpfTest/Tests/TempPage.xaml @@ -260,6 +260,14 @@ + + + + + diff --git a/WpfTest/Tests/TempPage.xaml.cs b/WpfTest/Tests/TempPage.xaml.cs index a1779b6..7819f48 100644 --- a/WpfTest/Tests/TempPage.xaml.cs +++ b/WpfTest/Tests/TempPage.xaml.cs @@ -15,6 +15,8 @@ using System.Windows.Shapes; using System.Windows.Threading; using CommunityToolkit.Mvvm.ComponentModel; +using EleCho.WpfSuite; +using EleCho.WpfSuite.FluentDesign; namespace WpfTest.Tests { @@ -39,5 +41,20 @@ private void Button_Click(object sender, RoutedEventArgs e) { buttonContentControl.Content = System.IO.Path.GetRandomFileName(); } + + private void ToggleThemeButton_Click(object sender, RoutedEventArgs e) + { + var resources = App.Current.Resources.MergedDictionaries + .OfType() + .FirstOrDefault(); + var window = Window.GetWindow(this); + + if (resources is not null && + window is not null) + { + resources.IsDarkMode ^= true; + WindowOption.SetIsDarkMode(window, !WindowOption.GetIsDarkMode(window)); + } + } } }