From f09f700bc933e55a077c142c5f0296ee8e5d3d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 18 Jan 2025 21:03:27 +0800 Subject: [PATCH 001/108] Update Styles.Buttons.xaml --- src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml b/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml index 42239c33..af6606b2 100644 --- a/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml +++ b/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml @@ -137,7 +137,8 @@ Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" - CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" /> + CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" + SnapsToDevicePixels="True" /> Date: Sat, 18 Jan 2025 21:03:39 +0800 Subject: [PATCH 002/108] Update LoadingBase.cs --- src/WPFDevelopers.Shared/Controls/Loadings/LoadingBase.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/WPFDevelopers.Shared/Controls/Loadings/LoadingBase.cs b/src/WPFDevelopers.Shared/Controls/Loadings/LoadingBase.cs index b849a75f..e93dfee2 100644 --- a/src/WPFDevelopers.Shared/Controls/Loadings/LoadingBase.cs +++ b/src/WPFDevelopers.Shared/Controls/Loadings/LoadingBase.cs @@ -4,7 +4,7 @@ namespace WPFDevelopers.Controls { - public abstract class LoadingBase:ContentControl + public abstract class LoadingBase : ContentControl { public bool IsLoading { @@ -31,5 +31,5 @@ private static object CoerceIsLoading(DependencyObject d, object baseValue) protected virtual void OnIsLoadingChanged(bool oldValue, bool newValue) { } - } + } } From d6ee082f31e89fbcbb15293f6d49623e080e9b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 18 Jan 2025 21:04:44 +0800 Subject: [PATCH 003/108] =?UTF-8?q?Fix=20issue=20=EF=BC=88#134=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix issue (#134) --- .../Controls/ScreenCut/ScreenCaptureExt.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCaptureExt.cs b/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCaptureExt.cs index b8fe61b0..b8ec38fc 100644 --- a/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCaptureExt.cs +++ b/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCaptureExt.cs @@ -37,8 +37,7 @@ public ScreenCaptureExt(ThemeType? themeType = null) { if(themeType == null) { - var existingResourceDictionary = - (Resources)Application.Current.Resources.MergedDictionaries.FirstOrDefault(x => x is Resources); + var existingResourceDictionary = Application.Current.TryFindResource("Resources") as Resources; if (existingResourceDictionary != null) themeType = existingResourceDictionary.Theme; else From b89896d76b6a208cacf886bde70b227a5f3834a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 18 Jan 2025 21:05:08 +0800 Subject: [PATCH 004/108] Update Message.cs --- src/WPFDevelopers.Shared/Controls/Message/Message.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/WPFDevelopers.Shared/Controls/Message/Message.cs b/src/WPFDevelopers.Shared/Controls/Message/Message.cs index a707e1a2..4bf3eefb 100644 --- a/src/WPFDevelopers.Shared/Controls/Message/Message.cs +++ b/src/WPFDevelopers.Shared/Controls/Message/Message.cs @@ -1,7 +1,6 @@ using System; using System.Windows; using WPFDevelopers.Helpers; -using System.Windows.Media; namespace WPFDevelopers.Controls { From 9191619dc137980b9ee738f37687dc795d927f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sun, 19 Jan 2025 21:20:18 +0800 Subject: [PATCH 005/108] =?UTF-8?q?Fix=20issue=EF=BC=88=20#136=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix issue( #136) --- src/WPFDevelopers.Net40/Themes/Generic.xaml | 2 +- src/WPFDevelopers.Net40/Window.cs | 67 +++++++++---------- src/WPFDevelopers.Net45x/Themes/Generic.xaml | 5 +- src/WPFDevelopers.Net45x/Window.cs | 64 ++++++++---------- .../Core/Helpers/MonitorHelper.cs | 31 +++++++++ .../WPFDevelopers.Shared.projitems | 1 + 6 files changed, 97 insertions(+), 73 deletions(-) create mode 100644 src/WPFDevelopers.Shared/Core/Helpers/MonitorHelper.cs diff --git a/src/WPFDevelopers.Net40/Themes/Generic.xaml b/src/WPFDevelopers.Net40/Themes/Generic.xaml index 7042df93..a29ac312 100644 --- a/src/WPFDevelopers.Net40/Themes/Generic.xaml +++ b/src/WPFDevelopers.Net40/Themes/Generic.xaml @@ -18,7 +18,7 @@ - + diff --git a/src/WPFDevelopers.Net40/Window.cs b/src/WPFDevelopers.Net40/Window.cs index 3f6e4189..3e1af973 100644 --- a/src/WPFDevelopers.Net40/Window.cs +++ b/src/WPFDevelopers.Net40/Window.cs @@ -1,13 +1,13 @@ using Microsoft.Windows.Shell; using System; -using System.Runtime.InteropServices; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using WPFDevelopers.Controls; -using WPFDevelopers.Helpers; +using WPFDevelopers.Core.Helpers; +using static WPFDevelopers.Core.Helpers.MonitorHelper; namespace WPFDevelopers.Net40 { @@ -48,8 +48,8 @@ public Window() CanMinimizeWindow)); CommandBindings.Add(new CommandBinding(SystemCommands.RestoreWindowCommand, RestoreWindow, CanResizeWindow)); - } + public override void OnApplyTemplate() { base.OnApplyTemplate(); @@ -62,6 +62,7 @@ public override void OnApplyTemplate() } } + private void Icon_MouseDoubleClick(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) @@ -102,7 +103,7 @@ private void Window_Loaded(object sender, RoutedEventArgs e) { hWnd = new WindowInteropHelper(this).Handle; HwndSource.FromHwnd(hWnd).AddHook(WindowProc); - if(TitleBarMode == TitleBarMode.Normal) + if (TitleBarMode == TitleBarMode.Normal) TitleHeight = SystemParameters2.Current.WindowNonClientFrameThickness.Top; } @@ -132,12 +133,17 @@ private void CloseWindow(object sender, ExecutedRoutedEventArgs e) private void MaximizeWindow(object sender, ExecutedRoutedEventArgs e) { - SystemCommands.MaximizeWindow(this); + if (WindowState == WindowState.Normal) + { + WindowStyle = WindowStyle.SingleBorderWindow; + WindowState = WindowState.Maximized; + WindowStyle = WindowStyle.None; + } } private void MinimizeWindow(object sender, ExecutedRoutedEventArgs e) { - SendMessage(hWnd, ApiCodes.WM_SYSCOMMAND, new IntPtr(ApiCodes.SC_MINIMIZE), IntPtr.Zero); + SendMessage(hWnd, MonitorHelper.WindowsMessageCodes.WM_SYSCOMMAND, new IntPtr(MonitorHelper.WindowsMessageCodes.SC_MINIMIZE), IntPtr.Zero); } private void RestoreWindow(object sender, ExecutedRoutedEventArgs e) @@ -145,39 +151,30 @@ private void RestoreWindow(object sender, ExecutedRoutedEventArgs e) SystemCommands.RestoreWindow(this); } - - internal class ApiCodes - { - public const int SC_RESTORE = 0xF120; - public const int SC_MINIMIZE = 0xF020; - public const int WM_SYSCOMMAND = 0x0112; - } - private IntPtr hWnd; - - [DllImport(Win32.User32)] - public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); - + private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { - if (msg == ApiCodes.WM_SYSCOMMAND) + switch (msg) { - if (wParam.ToInt32() == ApiCodes.SC_MINIMIZE) - { - _windowStyle = WindowStyle; - if (WindowStyle != WindowStyle.SingleBorderWindow) - WindowStyle = WindowStyle.SingleBorderWindow; - WindowState = WindowState.Minimized; - handled = true; - } - else if (wParam.ToInt32() == ApiCodes.SC_RESTORE) - { - WindowState = WindowState.Normal; - WindowStyle = WindowStyle.None; - if(WindowStyle.None != _windowStyle) - WindowStyle = _windowStyle; - handled = true; - } + case WindowsMessageCodes.WM_SYSCOMMAND: + if (wParam.ToInt32() == WindowsMessageCodes.SC_MINIMIZE) + { + _windowStyle = WindowStyle; + if (WindowStyle != WindowStyle.SingleBorderWindow) + WindowStyle = WindowStyle.SingleBorderWindow; + WindowState = WindowState.Minimized; + handled = true; + } + else if (wParam.ToInt32() == WindowsMessageCodes.SC_RESTORE) + { + WindowState = WindowState.Normal; + WindowStyle = WindowStyle.None; + if (WindowStyle.None != _windowStyle) + WindowStyle = _windowStyle; + handled = true; + } + break; } return IntPtr.Zero; } diff --git a/src/WPFDevelopers.Net45x/Themes/Generic.xaml b/src/WPFDevelopers.Net45x/Themes/Generic.xaml index 9c1840aa..fdf8f056 100644 --- a/src/WPFDevelopers.Net45x/Themes/Generic.xaml +++ b/src/WPFDevelopers.Net45x/Themes/Generic.xaml @@ -20,8 +20,9 @@ - - + + diff --git a/src/WPFDevelopers.Net45x/Window.cs b/src/WPFDevelopers.Net45x/Window.cs index fc6f039d..9a7ab665 100644 --- a/src/WPFDevelopers.Net45x/Window.cs +++ b/src/WPFDevelopers.Net45x/Window.cs @@ -1,14 +1,12 @@ -using Standard; -using System; -using System.Reflection; -using System.Runtime.InteropServices; +using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Interop; using System.Windows.Media; using WPFDevelopers.Controls; -using WPFDevelopers.Helpers; +using WPFDevelopers.Core.Helpers; +using static WPFDevelopers.Core.Helpers.MonitorHelper; namespace WPFDevelopers.Net45x { @@ -140,12 +138,17 @@ private void CloseWindow(object sender, ExecutedRoutedEventArgs e) private void MaximizeWindow(object sender, ExecutedRoutedEventArgs e) { - SystemCommands.MaximizeWindow(this); + if (WindowState == WindowState.Normal) + { + WindowStyle = WindowStyle.SingleBorderWindow; + WindowState = WindowState.Maximized; + WindowStyle = WindowStyle.None; + } } private void MinimizeWindow(object sender, ExecutedRoutedEventArgs e) { - SendMessage(hWnd, ApiCodes.WM_SYSCOMMAND, new IntPtr(ApiCodes.SC_MINIMIZE), IntPtr.Zero); + MonitorHelper.SendMessage(hWnd, MonitorHelper.WindowsMessageCodes.WM_SYSCOMMAND, new IntPtr(MonitorHelper.WindowsMessageCodes.SC_MINIMIZE), IntPtr.Zero); } private void RestoreWindow(object sender, ExecutedRoutedEventArgs e) @@ -153,43 +156,34 @@ private void RestoreWindow(object sender, ExecutedRoutedEventArgs e) SystemCommands.RestoreWindow(this); } - internal class ApiCodes - { - public const int SC_RESTORE = 0xF120; - public const int SC_MINIMIZE = 0xF020; - public const int WM_SYSCOMMAND = 0x0112; - } private IntPtr hWnd; - [DllImport(Win32.User32)] - public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); - private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) { - if (msg == ApiCodes.WM_SYSCOMMAND) + switch (msg) { - if (wParam.ToInt32() == ApiCodes.SC_MINIMIZE) - { - _windowStyle = WindowStyle; - if (WindowStyle != WindowStyle.SingleBorderWindow) - WindowStyle = WindowStyle.SingleBorderWindow; - WindowState = WindowState.Minimized; - handled = true; - } - else if (wParam.ToInt32() == ApiCodes.SC_RESTORE) - { - WindowState = WindowState.Normal; - WindowStyle = WindowStyle.None; - if (WindowStyle.None != _windowStyle) - WindowStyle = _windowStyle; - handled = true; - } + case WindowsMessageCodes.WM_SYSCOMMAND: + if (wParam.ToInt32() == WindowsMessageCodes.SC_MINIMIZE) + { + _windowStyle = WindowStyle; + if (WindowStyle != WindowStyle.SingleBorderWindow) + WindowStyle = WindowStyle.SingleBorderWindow; + WindowState = WindowState.Minimized; + handled = true; + } + else if (wParam.ToInt32() == WindowsMessageCodes.SC_RESTORE) + { + WindowState = WindowState.Normal; + WindowStyle = WindowStyle.None; + if (WindowStyle.None != _windowStyle) + WindowStyle = _windowStyle; + handled = true; + } + break; } - return IntPtr.Zero; } - private void ShowSystemMenu(object sender, ExecutedRoutedEventArgs e) { var element = e.OriginalSource as FrameworkElement; diff --git a/src/WPFDevelopers.Shared/Core/Helpers/MonitorHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/MonitorHelper.cs new file mode 100644 index 00000000..f9a84d6b --- /dev/null +++ b/src/WPFDevelopers.Shared/Core/Helpers/MonitorHelper.cs @@ -0,0 +1,31 @@ +using Standard; +using System; +using System.Runtime.InteropServices; +using WPFDevelopers.Helpers; + +namespace WPFDevelopers.Core.Helpers +{ + public static class MonitorHelper + { + internal class WindowsMessageCodes + { + public const int SC_RESTORE = 0xF120; + public const int SC_MINIMIZE = 0xF020; + public const int WM_SYSCOMMAND = 0x0112; + public const int WM_DEADCHAR = 0x0024; + } + + [DllImport(Win32.User32)] + internal static extern bool GetMonitorInfo(IntPtr hMonitor, MONITORINFO lpmi); + + /// + /// + /// + [DllImport(Win32.User32)] + internal static extern IntPtr MonitorFromWindow(IntPtr handle, int flags); + + [DllImport(Win32.User32)] + internal static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); + + } +} diff --git a/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems b/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems index dfd16bf8..dbc3519a 100644 --- a/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems +++ b/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems @@ -63,6 +63,7 @@ + From e82637410cce88ec6bcc47b2603e059498057a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 25 Jan 2025 23:05:24 +0800 Subject: [PATCH 006/108] Create SimpleWrapPanel.cs --- .../Controls/Panel/SimpleWrapPanel.cs | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/WPFDevelopers.Shared/Controls/Panel/SimpleWrapPanel.cs diff --git a/src/WPFDevelopers.Shared/Controls/Panel/SimpleWrapPanel.cs b/src/WPFDevelopers.Shared/Controls/Panel/SimpleWrapPanel.cs new file mode 100644 index 00000000..c299f335 --- /dev/null +++ b/src/WPFDevelopers.Shared/Controls/Panel/SimpleWrapPanel.cs @@ -0,0 +1,69 @@ +using System; +using System.Windows; +using System.Windows.Controls; + +namespace WPFDevelopers.Controls +{ + public class SimpleWrapPanel : Panel + { + public static readonly DependencyProperty SpacingProperty = DependencyProperty.Register( + nameof(Spacing), typeof(double), typeof(SimpleWrapPanel), + new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsMeasure)); + + public double Spacing + { + get => (double)GetValue(SpacingProperty); + set => SetValue(SpacingProperty, value); + } + + protected override Size MeasureOverride(Size constraint) + { + double panelWidth = constraint.Width == double.PositiveInfinity ? 0 : constraint.Width; + double currentLineWidth = 0; + double currentLineHeight = 0; + double totalHeight = 0; + var spacing = Spacing; + foreach (UIElement child in InternalChildren) + { + if (child == null) continue; + child.Measure(new Size(Math.Min(panelWidth, constraint.Width), double.PositiveInfinity)); + var desiredSize = child.DesiredSize; + if (currentLineWidth + desiredSize.Width > panelWidth) + { + totalHeight += currentLineHeight + spacing; + currentLineWidth = 0; + currentLineHeight = 0; + } + currentLineWidth += desiredSize.Width + spacing; + currentLineHeight = Math.Max(currentLineHeight, desiredSize.Height); + } + + totalHeight += currentLineHeight; + return new Size(panelWidth, totalHeight); + } + + protected override Size ArrangeOverride(Size finalSize) + { + double panelWidth = finalSize.Width; + double currentLineWidth = 0; + double currentLineHeight = 0; + double currentY = 0; + var spacing = Spacing; + foreach (UIElement child in InternalChildren) + { + if (child == null) continue; + var desiredSize = child.DesiredSize; + if (currentLineWidth + desiredSize.Width > panelWidth) + { + currentY += currentLineHeight + spacing; + currentLineWidth = 0; + currentLineHeight = 0; + } + child.Arrange(new Rect(new Point(currentLineWidth, currentY), desiredSize)); + currentLineWidth += desiredSize.Width + spacing; + currentLineHeight = Math.Max(currentLineHeight, desiredSize.Height); + } + return finalSize; + } + } +} From 3c8c0587a9b8c99bc5dabd129d22d38c698c4a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 25 Jan 2025 23:05:39 +0800 Subject: [PATCH 007/108] Update Mask.xaml --- src/WPFDevelopers.Shared/Themes/Mask.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WPFDevelopers.Shared/Themes/Mask.xaml b/src/WPFDevelopers.Shared/Themes/Mask.xaml index 4c709aa0..b5fce93e 100644 --- a/src/WPFDevelopers.Shared/Themes/Mask.xaml +++ b/src/WPFDevelopers.Shared/Themes/Mask.xaml @@ -11,7 +11,7 @@ TargetType="{x:Type controls:MaskControl}"> - + From 416e32fe6c7e7103c59eda24e23f8c67c6ce4ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 25 Jan 2025 23:06:39 +0800 Subject: [PATCH 008/108] Update WPFDevelopers.Shared.projitems --- src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems | 1 + 1 file changed, 1 insertion(+) diff --git a/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems b/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems index dbc3519a..4cecb108 100644 --- a/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems +++ b/src/WPFDevelopers.Shared/WPFDevelopers.Shared.projitems @@ -27,6 +27,7 @@ + From c2214ca2f9639a73fb2596a1fa0c9a19b594caa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 25 Jan 2025 23:08:02 +0800 Subject: [PATCH 009/108] Create Tag --- src/WPFDevelopers.Shared/Controls/Tag/Tag.cs | 52 +++++++++++++++ src/WPFDevelopers.Shared/Themes/Tag.xaml | 66 +++++++++++++++++++ src/WPFDevelopers.Shared/Themes/Theme40.txt | 3 +- src/WPFDevelopers.Shared/Themes/Theme45x.txt | 3 +- .../WPFDevelopers.Shared.projitems | 5 ++ 5 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 src/WPFDevelopers.Shared/Controls/Tag/Tag.cs create mode 100644 src/WPFDevelopers.Shared/Themes/Tag.xaml diff --git a/src/WPFDevelopers.Shared/Controls/Tag/Tag.cs b/src/WPFDevelopers.Shared/Controls/Tag/Tag.cs new file mode 100644 index 00000000..4be6235c --- /dev/null +++ b/src/WPFDevelopers.Shared/Controls/Tag/Tag.cs @@ -0,0 +1,52 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; + +namespace WPFDevelopers.Controls +{ + public class Tag :ContentControl + { + private static RoutedCommand _closeCommand = null; + public bool IsClose + { + get { return (bool)GetValue(IsCloseProperty); } + set { SetValue(IsCloseProperty, value); } + } + + public static readonly DependencyProperty IsCloseProperty = + DependencyProperty.Register("IsClose", typeof(bool), typeof(Tag), new PropertyMetadata(true)); + + + public event RoutedEventHandler Close + { + add { AddHandler(CloseEvent, value); } + remove { RemoveHandler(CloseEvent, value); } + } + + public static readonly RoutedEvent CloseEvent = + EventManager.RegisterRoutedEvent("Close", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Tag)); + + public static RoutedCommand CloseCommand + { + get { return _closeCommand; } + } + + static Tag() + { + _closeCommand = new RoutedCommand("Close", typeof(Tag)); + DefaultStyleKeyProperty.OverrideMetadata(typeof(Tag), new FrameworkPropertyMetadata(typeof(Tag))); + CommandManager.RegisterClassCommandBinding(typeof(Tag),new CommandBinding(CloseCommand, OnCloseExecuted)); + } + private static void OnCloseExecuted(object sender, ExecutedRoutedEventArgs e) + { + if (sender is Tag tag) + tag.OnClose(); + } + + protected virtual void OnClose() + { + var args = new RoutedEventArgs(CloseEvent,this); + RaiseEvent(args); + } + } +} diff --git a/src/WPFDevelopers.Shared/Themes/Tag.xaml b/src/WPFDevelopers.Shared/Themes/Tag.xaml new file mode 100644 index 00000000..d995e548 --- /dev/null +++ b/src/WPFDevelopers.Shared/Themes/Tag.xaml @@ -0,0 +1,66 @@ + + + + + + - - + + - - - - - - - - - - + + + + + + + + + + - - - - - + - - - - - - - - - - + + + + + + + + + + - - - - - + + - - - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + @@ -699,7 +636,7 @@ @@ -5051,14 +4960,14 @@ @@ -6229,11 +6138,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - + @@ -699,7 +636,7 @@ @@ -5052,14 +4962,14 @@ @@ -6230,11 +6140,11 @@ diff --git a/src/WPFDevelopers.Samples.Shared/Controls/ChatEmoji/ChatEmoji.cs b/src/WPFDevelopers.Samples.Shared/Controls/ChatEmoji/ChatEmoji.cs index a1363adb..7851627a 100644 --- a/src/WPFDevelopers.Samples.Shared/Controls/ChatEmoji/ChatEmoji.cs +++ b/src/WPFDevelopers.Samples.Shared/Controls/ChatEmoji/ChatEmoji.cs @@ -1,7 +1,7 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Media; -using WPFDevelopers.Helpers; +using WPFDevelopers.Core; namespace WPFDevelopers.Samples.Controls { @@ -124,7 +124,7 @@ private void UpdateIsRight() { //m_textBlock.Foreground = Brushes.White; leftWrapPanel.Visibility = Visibility.Visible; - border.Background = ControlsHelper.Brush; + border.Background = ThemeManager.Instance.BackgroundBrush; rightWrapPanel.Visibility = Visibility.Collapsed; } } diff --git a/src/WPFDevelopers.Samples.Shared/Controls/ChatEmoji/ChatEmoji.xaml b/src/WPFDevelopers.Samples.Shared/Controls/ChatEmoji/ChatEmoji.xaml index 773bb073..d955b222 100644 --- a/src/WPFDevelopers.Samples.Shared/Controls/ChatEmoji/ChatEmoji.xaml +++ b/src/WPFDevelopers.Samples.Shared/Controls/ChatEmoji/ChatEmoji.xaml @@ -42,7 +42,7 @@ Margin="0,20,-14,0" VerticalAlignment="Top" Data="{StaticResource WD.ChatLeftGeometry}" - Fill="{DynamicResource WD.BackgroundSolidColorBrush}" + Fill="{DynamicResource WD.BackgroundBrush}" SnapsToDevicePixels="True" Stretch="Fill" StrokeThickness="0" diff --git a/src/WPFDevelopers.Samples.Shared/Controls/CodeViewer/CodeViewer.cs b/src/WPFDevelopers.Samples.Shared/Controls/CodeViewer/CodeViewer.cs index 2bf4a1af..381698d5 100644 --- a/src/WPFDevelopers.Samples.Shared/Controls/CodeViewer/CodeViewer.cs +++ b/src/WPFDevelopers.Samples.Shared/Controls/CodeViewer/CodeViewer.cs @@ -41,7 +41,7 @@ TabItem CreateTabItem(SourceCodeModel codeModel) var partTextEditor = new TextEditor(); partTextEditor.Options = new TextEditorOptions { ConvertTabsToSpaces = true }; partTextEditor.TextArea.SelectionCornerRadius = 0; - partTextEditor.SetResourceReference(TextArea.SelectionBrushProperty, "WD.WindowBorderBrushSolidColorBrush"); + partTextEditor.SetResourceReference(TextArea.SelectionBrushProperty, "WD.WindowBorderBrush"); partTextEditor.TextArea.SelectionBorder = null; partTextEditor.TextArea.SelectionForeground = null; partTextEditor.IsReadOnly = true; diff --git a/src/WPFDevelopers.Samples.Shared/Controls/CodeViewer/CodeViewer.xaml b/src/WPFDevelopers.Samples.Shared/Controls/CodeViewer/CodeViewer.xaml index 729ecf28..b7806822 100644 --- a/src/WPFDevelopers.Samples.Shared/Controls/CodeViewer/CodeViewer.xaml +++ b/src/WPFDevelopers.Samples.Shared/Controls/CodeViewer/CodeViewer.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartBarExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartBarExample.xaml index 20485c13..c58dc1c5 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartBarExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartBarExample.xaml @@ -11,11 +11,11 @@ d:DesignWidth="800" mc:Ignorable="d"> - + + Background="{DynamicResource WD.BackgroundBrush}"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml index 26a69c63..2fcc89e6 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartLineExample.xaml @@ -11,7 +11,7 @@ d:DesignWidth="800" mc:Ignorable="d"> - + @@ -20,7 +20,7 @@ + Background="{DynamicResource WD.BackgroundBrush}"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartPieExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartPieExample.xaml index 0fc4bf16..00066e9d 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartPieExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartPieExample.xaml @@ -11,7 +11,7 @@ d:DesignWidth="800" mc:Ignorable="d"> - + @@ -20,7 +20,7 @@ + Background="{DynamicResource WD.BackgroundBrush}"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml index 705ce488..621e7b85 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChartRadarExample.xaml @@ -14,7 +14,7 @@ + Background="{DynamicResource WD.BackgroundBrush}"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChatEmojiExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChatEmojiExample.xaml index 45552b88..2846f9a5 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/ChatEmojiExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/ChatEmojiExample.xaml @@ -12,7 +12,7 @@ mc:Ignorable="d"> - + @@ -42,7 +42,7 @@ - + @@ -128,7 +128,7 @@ - + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/EdgePage.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/EdgePage.xaml index b05c7475..16da8114 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/EdgePage.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/EdgePage.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews.DrawerMenu" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" - Title="EdgePage" Background="{DynamicResource WD.PrimaryPressedSolidColorBrush}"> + Title="EdgePage" Background="{DynamicResource WD.PrimaryPressedBrush}"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/HomePage.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/HomePage.xaml index ca293b96..a5ae8889 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/HomePage.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawerMenu/HomePage.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews.DrawerMenu" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" - Title="HomePage" Background="{StaticResource WD.PrimaryTextSolidColorBrush}"> + Title="HomePage" Background="{StaticResource WD.PrimaryTextBrush}"> + FontSize="{StaticResource WD.PrimaryFontSize}"> Home diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawingExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawingExample.xaml index 001b7f97..73bd8065 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawingExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/DrawingExample.xaml @@ -15,7 +15,7 @@ - + @@ -25,7 +25,7 @@ - - + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/LogoAnimationExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/LogoAnimationExample.xaml index 80d39b45..e2e2ff81 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/LogoAnimationExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/LogoAnimationExample.xaml @@ -9,10 +9,10 @@ d:DesignHeight="450" d:DesignWidth="800"> - + Effect="{StaticResource WD.PrimaryShadowDepth}" Margin="20"> @@ -45,7 +45,7 @@ + To="{StaticResource WD.PrimaryColor}"/> - @@ -142,7 +142,7 @@ - diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml index e202e5fa..ebe5789d 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/MainWindow.xaml @@ -49,7 +49,7 @@ Width="20" Height="20" Data="{StaticResource WD.WarningGeometry}" - Fill="{DynamicResource WD.PrimaryNormalSolidColorBrush}" + Fill="{DynamicResource WD.PrimaryBrush}" Stretch="Uniform" /> @@ -102,7 +102,7 @@ + Background="{DynamicResource WD.BackgroundBrush}"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/NavMenu3DExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/NavMenu3DExample.xaml index 8ea467f9..85dc191f 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/NavMenu3DExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/NavMenu3DExample.xaml @@ -20,7 +20,7 @@ Height="235" Margin="10,0" VerticalAlignment="Top" - Background="{DynamicResource WD.BackgroundSolidColorBrush}" + Background="{DynamicResource WD.BackgroundBrush}" SnapsToDevicePixels="True"> @@ -49,7 +49,7 @@ Width="40" Height="40" Data="{StaticResource WD.BusGeometry}" - Fill="{DynamicResource WD.WindowForegroundColorBrush}" + Fill="{DynamicResource WD.WindowTextBrush}" Stretch="Uniform" /> @@ -63,7 +63,7 @@ Width="40" Height="40" Data="{StaticResource WD.FriendGeometry}" - Fill="{DynamicResource WD.WindowForegroundColorBrush}" + Fill="{DynamicResource WD.WindowTextBrush}" Stretch="Uniform" /> @@ -77,7 +77,7 @@ Width="40" Height="40" Data="{StaticResource WD.AlarmClockGeometry}" - Fill="{DynamicResource WD.WindowForegroundColorBrush}" + Fill="{DynamicResource WD.WindowTextBrush}" Stretch="Uniform" /> @@ -92,7 +92,7 @@ Width="40" Height="40" Data="{StaticResource WD.BuildingRegularGeometry}" - Fill="{DynamicResource WD.WindowForegroundColorBrush}" + Fill="{DynamicResource WD.WindowTextBrush}" Stretch="Uniform" /> @@ -103,7 +103,7 @@ Width="40" Height="40" Data="{StaticResource WD.BuildingRegularGeometry}" - Fill="{DynamicResource WD.WindowForegroundColorBrush}" + Fill="{DynamicResource WD.WindowTextBrush}" Stretch="Uniform" /> @@ -142,7 +142,7 @@ Margin="0,20" HorizontalAlignment="Center" VerticalAlignment="Top" - FontSize="{StaticResource WD.NormalFontSize}" + FontSize="{StaticResource WD.PrimaryFontSize}" FontWeight="Black"> Github 源代码 diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/NumberCard/NumberCardControl.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/NumberCard/NumberCardControl.xaml index 02bde8db..5ab796f0 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/NumberCard/NumberCardControl.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/NumberCard/NumberCardControl.xaml @@ -16,7 +16,7 @@ - + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml index ee612981..6875f45e 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/OtherControlExample.xaml @@ -15,7 +15,7 @@ Height="200" HorizontalAlignment="Center" VerticalAlignment="Center" - Background="{StaticResource WD.BlackSolidColorBrush}"> + Background="{DynamicResource WD.PrimaryTextBrush}"> diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/RainbowButtonsExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/RainbowButtonsExample.xaml index 5bee194b..8694c93d 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/RainbowButtonsExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/RainbowButtonsExample.xaml @@ -7,7 +7,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="450" d:DesignWidth="800" - Background="{StaticResource WD.BlackSolidColorBrush}" + Background="{DynamicResource WD.PrimaryTextBrush}" mc:Ignorable="d"> /WPFDevelopers.Samples;component/Resources/Fonts/fixedsys.ttf#Fixedsys Excelsior 3.01 diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml index 1b30541c..900b4a89 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/RulerControlExample.xaml @@ -28,11 +28,11 @@ + Background="{StaticResource WD.CircleMenuDualBrush}"> + Background="{StaticResource WD.DangerBrush}"> + Background="{StaticResource WD.WarningBrush}"> @@ -50,13 +50,13 @@ diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml b/src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml index cc8498ac..4700f92a 100644 --- a/src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/SixGirdViewExample.xaml @@ -25,7 +25,7 @@ - - #CD7474 - - #CFA0A0 - - #B70404 - - - #B31B1B - - - - #BB5F5F - - - #B70404 - - - \ No newline at end of file diff --git a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems index c5a79204..56a70d25 100644 --- a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems +++ b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems @@ -1024,10 +1024,6 @@ MSBuild:Compile Designer - - MSBuild:Compile - Designer - diff --git a/src/WPFDevelopers.Samples.Shared/app.manifest b/src/WPFDevelopers.Samples.Shared/app.manifest index bc6bbbbc..d43f804b 100644 --- a/src/WPFDevelopers.Samples.Shared/app.manifest +++ b/src/WPFDevelopers.Samples.Shared/app.manifest @@ -1,54 +1,48 @@  - - - - - - - - + + + + + + + + - - - - - + + - - + + - - + + - - + + - - + + - - + + - - - - PerMonitor - true - - - - - - + + diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartBase.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartBase.cs index 01711ec1..eb3761d5 100644 --- a/src/WPFDevelopers.Shared/Controls/Charts/ChartBase.cs +++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartBase.cs @@ -6,6 +6,7 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Effects; +using WPFDevelopers.Core; using WPFDevelopers.Helpers; namespace WPFDevelopers.Controls @@ -39,7 +40,7 @@ static ChartBase() protected double StartY { get; set; } protected double StartX { get; set; } = 40; - protected Brush NormalBrush => ControlsHelper.PrimaryNormalBrush; + protected Brush NormalBrush => ThemeManager.Instance.PrimaryBrush; public IEnumerable> Datas @@ -85,12 +86,12 @@ protected override void OnMouseMove(MouseEventArgs e) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, - Foreground = (Brush) Application.Current.TryFindResource("WD.WindowForegroundColorBrush") + Foreground = (Brush) Application.Current.TryFindResource("WD.WindowTextBrush") }; _border = new Border { Child = _textBlock, - Background = (Brush) Application.Current.TryFindResource("WD.ChartFillSolidColorBrush"), + Background = (Brush) Application.Current.TryFindResource("WD.ChartFillBrush"), Effect = Application.Current.TryFindResource("WD.PopupShadowDepth") as DropShadowEffect, Margin = new Thickness(10), CornerRadius = new CornerRadius(3), diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartLine.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartLine.cs index c2deb755..25a57c0b 100644 --- a/src/WPFDevelopers.Shared/Controls/Charts/ChartLine.cs +++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartLine.cs @@ -55,8 +55,7 @@ protected override void OnRender(DrawingContext drawingContext) PointCache = dicts; if (points.Count > 1) { - var color = (Color) Application.Current.TryFindResource("WD.PrimaryNormalColor"); - var rectBrush = new SolidColorBrush(color); + var rectBrush = new SolidColorBrush(ThemeManager.Instance.PrimaryColor); rectBrush.Opacity = 0.3; rectBrush.Freeze(); var streamGeometry = new StreamGeometry(); diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartPie.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartPie.cs index dc3c6f91..257fe5dd 100644 --- a/src/WPFDevelopers.Shared/Controls/Charts/ChartPie.cs +++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartPie.cs @@ -89,7 +89,7 @@ protected override void OnMouseMove(MouseEventArgs e) { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, - Foreground = (Brush) Application.Current.TryFindResource("WD.WindowForegroundColorBrush"), + Foreground = (Brush) Application.Current.TryFindResource("WD.WindowTextBrush"), Padding = new Thickness(4, 0, 2, 0) }; _ellipse = new Ellipse @@ -105,7 +105,7 @@ protected override void OnMouseMove(MouseEventArgs e) _border = new Border { Child = _stackPanel, - Background = (Brush) Application.Current.TryFindResource("WD.ChartFillSolidColorBrush"), + Background = (Brush) Application.Current.TryFindResource("WD.ChartFillBrush"), Effect = Application.Current.TryFindResource("WD.PopupShadowDepth") as DropShadowEffect, Margin = new Thickness(10), CornerRadius = new CornerRadius(3), diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartRadar.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartRadar.cs index 55a75504..352d6ce0 100644 --- a/src/WPFDevelopers.Shared/Controls/Charts/ChartRadar.cs +++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartRadar.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Windows; using System.Windows.Media; +using WPFDevelopers.Core; using WPFDevelopers.Helpers; namespace WPFDevelopers.Controls @@ -25,7 +26,7 @@ protected override void OnRender(DrawingContext drawingContext) _penXAxis = new Pen { Thickness = 1, - Brush = Application.Current.TryFindResource("WD.ChartXAxisSolidColorBrush") as Brush + Brush = Application.Current.TryFindResource("WD.ChartXAxisBrush") as Brush }; _penXAxis.Freeze(); @@ -76,8 +77,8 @@ protected override void OnRender(DrawingContext drawingContext) PointCache = dicts; streamGeometry.Freeze(); - var color = (Color) Application.Current.TryFindResource("WD.PrimaryNormalColor"); - var rectBrush = new SolidColorBrush(color); + //var color = (Color) Application.Current.TryFindResource("WD.PrimaryColor"); + var rectBrush = new SolidColorBrush(ThemeManager.Instance.PrimaryColor); rectBrush.Opacity = 0.5; rectBrush.Freeze(); drawingContext.DrawGeometry(rectBrush, myPen, streamGeometry); @@ -120,7 +121,7 @@ private PointCollection GetPolygonPoint(Point center, double r, { drawingContext.DrawLine(_penXAxis, p1, p2); var formattedText = DrawingContextHelper.GetFormattedText(item.Key, - ControlsHelper.PrimaryNormalBrush, + ThemeManager.Instance.PrimaryBrush, FlowDirection.LeftToRight, 20.001D); if (p2.Y > center.Y && p2.X < center.X) drawingContext.DrawText(formattedText, diff --git a/src/WPFDevelopers.Shared/Controls/Charts/ChartRect.cs b/src/WPFDevelopers.Shared/Controls/Charts/ChartRect.cs index 08ec16b4..8dcfe647 100644 --- a/src/WPFDevelopers.Shared/Controls/Charts/ChartRect.cs +++ b/src/WPFDevelopers.Shared/Controls/Charts/ChartRect.cs @@ -15,7 +15,7 @@ public class ChartRect : ChartBase protected override void OnRender(DrawingContext drawingContext) { base.OnRender(drawingContext); - ChartFill = Application.Current.TryFindResource("WD.ChartFillSolidColorBrush") as Brush; + ChartFill = Application.Current.TryFindResource("WD.ChartFillBrush") as Brush; var myPen = new Pen { Thickness = 1, @@ -53,7 +53,7 @@ protected override void OnRender(DrawingContext drawingContext) var xAxisPen = new Pen { Thickness = 1, - Brush = Application.Current.TryFindResource("WD.ChartXAxisSolidColorBrush") as Brush + Brush = Application.Current.TryFindResource("WD.ChartXAxisBrush") as Brush }; xAxisPen.Freeze(); var max = Convert.ToInt32(Datas.Max(kvp => kvp.Value)); diff --git a/src/WPFDevelopers.Shared/Controls/Loading/Loading.cs b/src/WPFDevelopers.Shared/Controls/Loading/Loading.cs index 4746d582..a2d3d4d8 100644 --- a/src/WPFDevelopers.Shared/Controls/Loading/Loading.cs +++ b/src/WPFDevelopers.Shared/Controls/Loading/Loading.cs @@ -1,7 +1,7 @@ using System.Windows; using System.Windows.Documents; using System.Windows.Media; -using WPFDevelopers.Helpers; +using WPFDevelopers.Core; using WPFDevelopers.Utilities; namespace WPFDevelopers.Controls @@ -22,7 +22,7 @@ public class Loading : BaseControl public static LoadingType GetLoadingType(DependencyObject obj) { - return (LoadingType) obj.GetValue(LoadingTypeProperty); + return (LoadingType)obj.GetValue(LoadingTypeProperty); } public static void SetLoadingType(DependencyObject obj, LoadingType value) @@ -87,8 +87,8 @@ private static void CreateLoading(UIElement uIElement, bool isRemove = false) var type = GetLoadingType(uIElement); var isLoading = GetIsShow(uIElement); if (!isLoading) return; - var w = (double) uIElement.GetValue(ActualWidthProperty); - var h = (double) uIElement.GetValue(ActualHeightProperty); + var w = (double)uIElement.GetValue(ActualWidthProperty); + var h = (double)uIElement.GetValue(ActualHeightProperty); switch (type) { case LoadingType.Default: @@ -122,13 +122,13 @@ private static void CreateLoading(UIElement uIElement, bool isRemove = false) if (value != null) adornerContainer.Child = new MaskControl(uIElement) - {Content = value, Background = ControlsHelper.Brush}; + { Content = value, Background = ThemeManager.Instance.BackgroundBrush }; layer.Add(adornerContainer); } public static bool GetIsShow(DependencyObject obj) { - return (bool) obj.GetValue(IsShowProperty); + return (bool)obj.GetValue(IsShowProperty); } public static void SetIsShow(DependencyObject obj, bool value) diff --git a/src/WPFDevelopers.Shared/Controls/MessageBox/WDMessageBox.cs b/src/WPFDevelopers.Shared/Controls/MessageBox/WDMessageBox.cs index 9409a759..51c6d946 100644 --- a/src/WPFDevelopers.Shared/Controls/MessageBox/WDMessageBox.cs +++ b/src/WPFDevelopers.Shared/Controls/MessageBox/WDMessageBox.cs @@ -246,22 +246,22 @@ private void DisplayImage(MessageBoxImage image) case MessageBoxImage.Warning: _geometry = (Geometry) Application.Current.TryFindResource("WD.WarningGeometry"); _solidColorBrush = - (SolidColorBrush) Application.Current.TryFindResource("WD.WarningSolidColorBrush"); + (SolidColorBrush) Application.Current.TryFindResource("WD.WarningBrush"); break; case MessageBoxImage.Error: _geometry = (Geometry) Application.Current.TryFindResource("WD.ErrorGeometry"); _solidColorBrush = - (SolidColorBrush) Application.Current.TryFindResource("WD.DangerSolidColorBrush"); + (SolidColorBrush) Application.Current.TryFindResource("WD.DangerBrush"); break; case MessageBoxImage.Information: _geometry = (Geometry) Application.Current.TryFindResource("WD.WarningGeometry"); _solidColorBrush = - (SolidColorBrush) Application.Current.TryFindResource("WD.SuccessNormalBrush"); + (SolidColorBrush) Application.Current.TryFindResource("WD.SuccessBrush"); break; case MessageBoxImage.Question: _geometry = (Geometry) Application.Current.TryFindResource("WD.QuestionGeometry"); _solidColorBrush = - (SolidColorBrush) Application.Current.TryFindResource("WD.NormalSolidColorBrush"); + (SolidColorBrush) Application.Current.TryFindResource("WD.PrimaryBrush"); break; } } diff --git a/src/WPFDevelopers.Shared/Controls/NotifyIcon/Runtimes/User32/LoadImageFlags.cs b/src/WPFDevelopers.Shared/Controls/NotifyIcon/Runtimes/User32/LoadImageFlags.cs index 9ba367fd..4da3e3c5 100644 --- a/src/WPFDevelopers.Shared/Controls/NotifyIcon/Runtimes/User32/LoadImageFlags.cs +++ b/src/WPFDevelopers.Shared/Controls/NotifyIcon/Runtimes/User32/LoadImageFlags.cs @@ -63,7 +63,7 @@ public enum LoadImageFlags : uint // for images that have non-standard sizes, that may change after loading, or that // are loaded from a file. When loading a system icon or cursor, you must use PInvoke.User32.LoadImageFlags.LR_SHARED // or the function will fail to load the resource. This function finds the first - // image in the cache with the requested resource name, regardless of the size requested. + // image in the _cacheBrush with the requested resource name, regardless of the size requested. LR_SHARED = 0x8000u, // // Summary: diff --git a/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCutAdorner.cs b/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCutAdorner.cs index 34f4d940..d6664ba4 100644 --- a/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCutAdorner.cs +++ b/src/WPFDevelopers.Shared/Controls/ScreenCut/ScreenCutAdorner.cs @@ -1,12 +1,11 @@ -using System; -using System.Windows; +using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Shapes; -using WPFDevelopers.Helpers; +using WPFDevelopers.Core; namespace WPFDevelopers.Controls { @@ -277,7 +276,7 @@ private FrameworkElementFactory GetFactory(Brush back) { var fef = new FrameworkElementFactory(typeof(Ellipse)); fef.SetValue(Shape.FillProperty, back); - fef.SetValue(Shape.StrokeProperty, ControlsHelper.PrimaryNormalBrush); + fef.SetValue(Shape.StrokeProperty, ThemeManager.Instance.PrimaryBrush); fef.SetValue(Shape.StrokeThicknessProperty, (double)2); return fef; } diff --git a/src/WPFDevelopers.Shared/Controls/Theme/Theme.cs b/src/WPFDevelopers.Shared/Controls/Theme/Theme.cs index 0cb29a74..a38b11bb 100644 --- a/src/WPFDevelopers.Shared/Controls/Theme/Theme.cs +++ b/src/WPFDevelopers.Shared/Controls/Theme/Theme.cs @@ -74,7 +74,9 @@ protected override DependencyObject GetContainerForItemOverride() private SolidColorBrush GetColorBrush(string colorHex) { - return new SolidColorBrush((Color)ColorConverter.ConvertFromString(colorHex)); + var brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString(colorHex)); + brush.Freeze(); + return brush; } protected override void OnSelectionChanged(SelectionChangedEventArgs e) @@ -111,7 +113,6 @@ private void ThemeRefresh(ThemeItem removeItem) return; var newResourceDictionary = new ResourceDictionary { Source = new Uri(resourcePath) }; mergedDictionaries.Insert(0, newResourceDictionary); - ControlsHelper.ThemeRefresh(); } } } \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Core/Converts/DangerColorConverter.cs b/src/WPFDevelopers.Shared/Core/Converts/DangerColorConverter.cs new file mode 100644 index 00000000..a9d3e1fb --- /dev/null +++ b/src/WPFDevelopers.Shared/Core/Converts/DangerColorConverter.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Windows.Data; +using System.Windows.Media; + +namespace WPFDevelopers.Converts +{ + public class DangerColorConverter : IValueConverter + { + private Dictionary, SolidColorBrush> _cacheBrush = new Dictionary, SolidColorBrush>(); + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is SolidColorBrush dangerBrush) + { + double brightnessIncrement = 0.5; + if (parameter != null && double.TryParse(parameter.ToString(), out double parsedValue)) + { + brightnessIncrement = parsedValue; + } + var cacheKey = Tuple.Create(dangerBrush.Color, brightnessIncrement); + if (_cacheBrush.ContainsKey(cacheKey)) + { + return _cacheBrush[cacheKey]; + } + else + { + var newColor = dangerBrush.Color.AddBrightness(brightnessIncrement); + var newBrush = new SolidColorBrush(newColor); + newBrush.Freeze(); + _cacheBrush[cacheKey] = newBrush; + return newBrush; + } + //var newColor = dangerBrush.Color.AddBrightness(brightnessIncrement); + //var newBrush = new SolidColorBrush(newColor); + //newBrush.Freeze(); + //return newBrush; + } + + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + public static class ColorExtensions + { + public static Color AddBrightness(this Color color, double factor) + { + factor = Math.Max(0, Math.Min(factor, 1)); + var r = (byte)Math.Min(color.R + factor * 255, 255); + var g = (byte)Math.Min(color.G + factor * 255, 255); + var b = (byte)Math.Min(color.B + factor * 255, 255); + return Color.FromArgb(color.A, r, g, b); + } + } +} diff --git a/src/WPFDevelopers.Shared/Core/Converts/IndexToColor.cs b/src/WPFDevelopers.Shared/Core/Converts/IndexToColor.cs index e418a918..a6afa810 100644 --- a/src/WPFDevelopers.Shared/Core/Converts/IndexToColor.cs +++ b/src/WPFDevelopers.Shared/Core/Converts/IndexToColor.cs @@ -11,9 +11,9 @@ public class IndexToColor : IValueConverter public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var num = System.Convert.ToInt32(value); - var brush = (SolidColorBrush)Application.Current.TryFindResource("WD.CircularSingularSolidColorBrush"); + var brush = (SolidColorBrush)Application.Current.TryFindResource("WD.CircleMenuBrush"); if (num % 2 == 1) - brush = (SolidColorBrush)Application.Current.TryFindResource("WD.CircularDualSolidColorBrush"); + brush = (SolidColorBrush)Application.Current.TryFindResource("WD.CircleMenuDualBrush"); return brush; } diff --git a/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs index ec39a65b..bbf78c20 100644 --- a/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs +++ b/src/WPFDevelopers.Shared/Core/Helpers/ControlsHelper.cs @@ -20,71 +20,6 @@ public class ControlsHelper : DependencyObject { private static Win32.DeskTopSize size; - public static Brush Brush = (Brush)Application.Current.TryFindResource("WD.BackgroundSolidColorBrush"); - - /// - /// PrimaryNormalBrush - /// - public static Brush PrimaryNormalBrush = (Brush)Application.Current.TryFindResource("WD.PrimaryNormalSolidColorBrush"); - - public static Brush WindowForegroundBrush = - (Brush)Application.Current.TryFindResource("WD.PrimaryTextSolidColorBrush"); - - private static bool _IsCurrentDark; - - public static void OnSubThemeChanged() - { - if (!_IsCurrentDark) - { - PrimaryNormalBrush = (Brush)Application.Current.TryFindResource("WD.PrimaryNormalSolidColorBrush"); - Application.Current.Resources["WD.WindowBorderBrushSolidColorBrush"] = PrimaryNormalBrush; - } - } - - public static void ToggleLightAndDark(bool isDark = false) - { - var type = isDark ? ThemeType.Dark : ThemeType.Light; - - var existingResourceDictionary = - (Resources)Application.Current.Resources.MergedDictionaries.FirstOrDefault(x => x is Resources); - if (existingResourceDictionary != null) - { - existingResourceDictionary.Theme = type; - if (type == ThemeType.Light) - { - PrimaryNormalBrush = (Brush)Application.Current.TryFindResource("WD.PrimaryNormalSolidColorBrush"); - Application.Current.Resources["WD.WindowBorderBrushSolidColorBrush"] = PrimaryNormalBrush; - WindowForegroundBrush = (Brush)Application.Current.TryFindResource("WD.PrimaryTextSolidColorBrush"); - if (Application.Current.TryFindResource("WD.DefaultBackgroundColor") is Color color) - { - var solidColorBrush = new SolidColorBrush(color); - Application.Current.Resources["WD.DefaultBackgroundSolidColorBrush"] = solidColorBrush; - - } - } - else - { - if (Application.Current.TryFindResource("WD.WindowBorderBrushColor") is Color color) - { - var colorBrush = new SolidColorBrush(color); - Application.Current.Resources["WD.WindowBorderBrushSolidColorBrush"] = colorBrush; - Application.Current.Resources["WD.DefaultBackgroundSolidColorBrush"] = colorBrush; - } - - WindowForegroundBrush = (Brush)Application.Current.TryFindResource("WD.DefaultBackgroundSolidColorBrush"); - } - - Brush = (Brush)Application.Current.TryFindResource("WD.BackgroundSolidColorBrush"); - _IsCurrentDark = isDark; - ThemeRefresh(); - } - } - - public static void ThemeRefresh() - { - OnSubThemeChanged(); - } - public static void WindowShake(Window window = null) { if (window == null) diff --git a/src/WPFDevelopers.Shared/Core/Helpers/DrawingContextHelper.cs b/src/WPFDevelopers.Shared/Core/Helpers/DrawingContextHelper.cs index 8cea8bfa..5d960e65 100644 --- a/src/WPFDevelopers.Shared/Core/Helpers/DrawingContextHelper.cs +++ b/src/WPFDevelopers.Shared/Core/Helpers/DrawingContextHelper.cs @@ -10,12 +10,12 @@ public static class DrawingContextHelper /// /// 字体资源 /// - public static FontFamily FontFamily = Application.Current.TryFindResource("WD.NormalFontFamily") as FontFamily; + public static FontFamily FontFamily = Application.Current.TryFindResource("WD.FontFamily") as FontFamily; /// /// 默认颜色 /// - public static Brush Brush = Application.Current.TryFindResource("WD.PrimaryNormalSolidColorBrush") as Brush; + public static Brush Brush = Application.Current.TryFindResource("WD.PrimaryBrush") as Brush; /// /// 颜色转换 diff --git a/src/WPFDevelopers.Shared/Core/Helpers/ThemeManager.cs b/src/WPFDevelopers.Shared/Core/Helpers/ThemeManager.cs new file mode 100644 index 00000000..365bf10f --- /dev/null +++ b/src/WPFDevelopers.Shared/Core/Helpers/ThemeManager.cs @@ -0,0 +1,65 @@ +using System.Collections.Generic; +using System; +using System.Linq; +using System.Windows; +using System.Windows.Media; +using WPFDevelopers.Helpers; + +namespace WPFDevelopers.Core +{ + public class ThemeManager + { + private Resources _cachedResources; + private static ThemeManager _instance; + public static ThemeManager Instance + { + get + { + if (_instance == null) + { + _instance = new ThemeManager(); + } + return _instance; + } + } + public Color PrimaryColor + { + get => (Color)Application.Current.TryFindResource("WD.PrimaryColor"); + + } + + public Brush PrimaryBrush + { + get => (Brush)Application.Current.TryFindResource("WD.PrimaryBrush"); + + } + public Brush BackgroundBrush + { + get => (Brush)Application.Current.TryFindResource("WD.BackgroundBrush"); + } + + public Dictionary, SolidColorBrush> PrimaryColorCache = new Dictionary, SolidColorBrush>(); + + public Dictionary, Color>> ColorCache = + new Dictionary, Color>>(); + + + public Resources GetResources() + { + if (_cachedResources != null) + return _cachedResources; + + _cachedResources = (Resources)Application.Current.Resources.MergedDictionaries + .FirstOrDefault(x => x is Resources); + + return _cachedResources; + } + + public void SetTheme(ThemeType themeType) + { + var resources = GetResources(); + if (resources != null) + resources.Theme = themeType; + } + } +} diff --git a/src/WPFDevelopers.Shared/Resources.cs b/src/WPFDevelopers.Shared/Resources.cs index 98499e69..9f6f2255 100644 --- a/src/WPFDevelopers.Shared/Resources.cs +++ b/src/WPFDevelopers.Shared/Resources.cs @@ -1,9 +1,13 @@ using System; +using System.Collections.Generic; +using System.ComponentModel; using System.IO; using System.IO.Compression; +using System.Linq; using System.Reflection; using System.Threading.Tasks; using System.Windows; +using System.Windows.Media; using WPFDevelopers.Core; using WPFDevelopers.Helpers; @@ -11,6 +15,9 @@ namespace WPFDevelopers { public class Resources : ResourceDictionary { + + private string[] resourceKeys = { "WindowBorderColor", "PrimaryColor" }; + public static event ThemeChangedEvent ThemeChanged; private ThemeType _theme; public ThemeType Theme @@ -19,6 +26,32 @@ public ThemeType Theme set => InitializeTheme(value); } + private SolidColorBrush _color; + public SolidColorBrush Color + { + get => _color; + set + { + if (_color != value) + { + _color = value; + OnPropertyChanged(nameof(Color)); + var newBrush = new SolidColorBrush(_color.Color); + newBrush.Freeze(); + UpdateResourceDictionaryColor(key: "Primary", color: newBrush.Color); + UpdateResourceDictionaryColor(key: "WindowBorder", color: newBrush.Color); + UpdateResourceDictionaryColor(key: "PrimaryMouseOver", color: newBrush.Color); + } + } + } + + public Resources() + { + var resourceDictionary = new ResourceDictionary { Source = new Uri("pack://application:,,,/WPFDevelopers;component/Themes/Theme.xaml") }; + if (Application.Current.Resources != null) + Application.Current.Resources.MergedDictionaries.Add(resourceDictionary); + } + protected void InitializeTheme(ThemeType themeType) { _theme = themeType; @@ -26,9 +59,10 @@ protected void InitializeTheme(ThemeType themeType) var path = GetResourceUri(GetThemeResourceName(themeType)); MergedDictionaries.Add(new ResourceDictionary { Source = path }); ThemeChanged?.Invoke(themeType); + UpdateColorOnThemeChange(); Task.Factory.StartNew(PublishWPFDevelopersExt); } - + void PublishWPFDevelopersExt() { if (!File.Exists(Helper.GetTempPathVersionExt)) @@ -62,5 +96,113 @@ protected string GetThemeResourceName(ThemeType themeType) { return themeType == ThemeType.Light ? "Light.Color" : "Dark.Color"; } + + void UpdateColorOnThemeChange() + { + UpdateResourceDictionaryColor(); + var primary = Color != null ? Color.Color : default; + UpdateResourceDictionaryColor(key: "WindowBorder", color: primary); + UpdateResourceDictionaryColor(key: "PrimaryMouseOver", color: primary); + var successColor = GetColorFromResource("Success"); + UpdateResourceDictionaryColor(key: "SuccessMouseOver", color: successColor != default ? successColor : default); + var warningColor = GetColorFromResource("Warning"); + UpdateResourceDictionaryColor(key: "WarningMouseOver", color: warningColor != default ? warningColor : default); + var dangerColor = GetColorFromResource("Danger"); + UpdateResourceDictionaryColor(key: "DangerMouseOver", color: dangerColor != default ? dangerColor : default); + } + + Color GetColorFromResource(string colorName) + { + Color color = default; + if (Application.Current.TryFindResource(GenerateColorResourceKey(colorName)) is Color colorResource) + color = colorResource; + return color; + } + + string GenerateColorResourceKey(string key) + { + return $"WD.{key}Color"; + } + + void UpdateResourceDictionaryColor(string key = "Primary", Color color = default) + { + var newKey = GenerateColorResourceKey(key); + if (Application.Current.TryFindResource(newKey) is Color colorRes) + { + Color newColor = colorRes; + if (color != default) + newColor = color; + if (!ThemeManager.Instance.ColorCache.ContainsKey(newColor)) + { + ThemeManager.Instance.ColorCache[newColor] = new Dictionary, Color>(); + } + var keyTuple = Tuple.Create(Theme, newKey); + if (ThemeManager.Instance.ColorCache.ContainsKey(newColor) + && + ThemeManager.Instance.ColorCache[newColor].ContainsKey(keyTuple) + && + !Array.Exists(resourceKeys, i => newKey.EndsWith(i))) + newColor = ThemeManager.Instance.ColorCache[newColor][keyTuple]; + else + { + if (Theme == ThemeType.Dark + && + !Array.Exists(resourceKeys, i => newKey.EndsWith(i))) + { + var transparent = Brushes.Transparent.Color; + ThemeManager.Instance.ColorCache[newColor][keyTuple] = transparent; + newColor = transparent; + } + else + { + if (Color != null + && + !Array.Exists(resourceKeys, i => newKey.EndsWith(i))) + { + var brightnessColor = new Color + { + A = (byte)(newColor.A * 0.1), + R = newColor.R, + G = newColor.G, + B = newColor.B + }; + newColor = brightnessColor; + } + else + { + Color tempColor = newColor; + if (!Array.Exists(resourceKeys, i => newKey.EndsWith(i))) + tempColor = colorRes; + if (newKey.EndsWith("WindowBorderColor") + && + Application.Current.TryFindResource(GenerateColorResourceKey("Base")) is Color colorBase + && + Theme == ThemeType.Dark) + tempColor = colorBase; + ThemeManager.Instance.ColorCache[newColor][keyTuple] = tempColor; + newColor = tempColor; + } + + } + } + SetResourceColorAndBrush(newKey, newColor); + } + } + + void SetResourceColorAndBrush(string key,Color color) + { + Application.Current.Resources[key] = color; + var newBrush = new SolidColorBrush(color); + newBrush.Freeze(); + var keyBrush = key.Replace("Color", "Brush"); + Application.Current.Resources[keyBrush] = newBrush; + } + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void OnPropertyChanged(string propertyName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); + } } } diff --git a/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml b/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml index af6606b2..95a52078 100644 --- a/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml +++ b/src/WPFDevelopers.Shared/Styles/Styles.Buttons.xaml @@ -3,7 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:controls="clr-namespace:WPFDevelopers.Controls" xmlns:convert="clr-namespace:WPFDevelopers.Converts" - xmlns:helpers="clr-namespace:WPFDevelopers.Helpers"> + xmlns:helpers="clr-namespace:WPFDevelopers.Helpers" + xmlns:sys="clr-namespace:System;assembly=mscorlib"> @@ -23,7 +24,7 @@ - + @@ -227,41 +217,29 @@ x:Key="WD.WarningPrimaryButton" BasedOn="{StaticResource WD.PrimaryButton}" TargetType="{x:Type Button}"> - - - - - - - - - - - - - + @@ -269,41 +247,29 @@ x:Key="WD.DangerPrimaryButton" BasedOn="{StaticResource WD.PrimaryButton}" TargetType="{x:Type Button}"> - - - - - - - - - - - - - + @@ -333,7 +299,7 @@ 0.7 - 4 - 32 + 4 + 32 16 8 6 - 6 + 6 #FFFFFF #C0C4CC - #202020 + #202020 + Color="{StaticResource WD.PrimaryBackgroundColor}" /> #323232 - #202020 + #202020 + Color="{StaticResource WD.WindowBorderColor}" /> #202020 #202020 #202020 #202020 #42414F #86849D diff --git a/src/WPFDevelopers.Shared/Themes/Basic/Font.xaml b/src/WPFDevelopers.Shared/Themes/Basic/Font.xaml index a8566135..e36113c4 100644 --- a/src/WPFDevelopers.Shared/Themes/Basic/Font.xaml +++ b/src/WPFDevelopers.Shared/Themes/Basic/Font.xaml @@ -1,26 +1,27 @@ - + - 13 + 13 14 16 - - Helvetica Neue For Number, - -apple-system, - BlinkMacSystemFont, + + Helvetica Neue For Number, + -apple-system, + BlinkMacSystemFont, Segoe UI, - Roboto, - PingFang SC, - Hiragino Sans GB, - Microsoft YaHei, - Helvetica Neue, - Helvetica, Arial, + Roboto, + PingFang SC, + Hiragino Sans GB, + Microsoft YaHei, + Helvetica Neue, + Helvetica, Arial, sans-serif - Normal - Normal - Normal + Normal + Normal + Normal \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Themes/Basic/Light.Color.xaml b/src/WPFDevelopers.Shared/Themes/Basic/Light.Color.xaml index fba9cc3e..90ff9007 100644 --- a/src/WPFDevelopers.Shared/Themes/Basic/Light.Color.xaml +++ b/src/WPFDevelopers.Shared/Themes/Basic/Light.Color.xaml @@ -7,59 +7,66 @@ #303133 #606266 #FFFFFF + + #409EFF + + #DCDFE6 #F5F7FA #EBEEF5 #E4E7ED #E0E6F1 #6E7079 diff --git a/src/WPFDevelopers.Shared/Themes/BreadCrumbBar.xaml b/src/WPFDevelopers.Shared/Themes/BreadCrumbBar.xaml index 4a459cb8..3875a4e2 100644 --- a/src/WPFDevelopers.Shared/Themes/BreadCrumbBar.xaml +++ b/src/WPFDevelopers.Shared/Themes/BreadCrumbBar.xaml @@ -23,7 +23,7 @@ Width="9" Height="9" Data="{StaticResource WD.ChevronRightGeometry}" - Fill="{DynamicResource WD.PlaceholderTextSolidColorBrush}" + Fill="{DynamicResource WD.PlaceholderTextBrush}" IsHitTestVisible="False" Stretch="Uniform"> @@ -43,7 +43,7 @@ - + diff --git a/src/WPFDevelopers.Shared/Themes/BreathLamp.xaml b/src/WPFDevelopers.Shared/Themes/BreathLamp.xaml index aead8e0a..2c65e535 100644 --- a/src/WPFDevelopers.Shared/Themes/BreathLamp.xaml +++ b/src/WPFDevelopers.Shared/Themes/BreathLamp.xaml @@ -249,9 +249,9 @@ - - - + + + diff --git a/src/WPFDevelopers.Shared/Themes/BubblleControl.xaml b/src/WPFDevelopers.Shared/Themes/BubblleControl.xaml index d009e552..9dbc1750 100644 --- a/src/WPFDevelopers.Shared/Themes/BubblleControl.xaml +++ b/src/WPFDevelopers.Shared/Themes/BubblleControl.xaml @@ -12,10 +12,10 @@ TargetType="controls:BubblleControl"> - + - - + + diff --git a/src/WPFDevelopers.Shared/Themes/CircleMenu.xaml b/src/WPFDevelopers.Shared/Themes/CircleMenu.xaml index a85d8065..cad8dccc 100644 --- a/src/WPFDevelopers.Shared/Themes/CircleMenu.xaml +++ b/src/WPFDevelopers.Shared/Themes/CircleMenu.xaml @@ -38,7 +38,7 @@ - + @@ -91,12 +91,12 @@ x:Name="PART_Ellipse" Width="100" Height="100" - Fill="{StaticResource WD.PrimaryNormalSolidColorBrush}" /> + Fill="{DynamicResource WD.PrimaryBrush}" /> diff --git a/src/WPFDevelopers.Shared/Themes/CircleProgressBar.xaml b/src/WPFDevelopers.Shared/Themes/CircleProgressBar.xaml index 4b4037bb..b781f683 100644 --- a/src/WPFDevelopers.Shared/Themes/CircleProgressBar.xaml +++ b/src/WPFDevelopers.Shared/Themes/CircleProgressBar.xaml @@ -16,11 +16,11 @@ - - + + - + @@ -80,53 +80,13 @@ - + - + diff --git a/src/WPFDevelopers.Shared/Themes/CropAvatar.xaml b/src/WPFDevelopers.Shared/Themes/CropAvatar.xaml index 365290c0..9593205c 100644 --- a/src/WPFDevelopers.Shared/Themes/CropAvatar.xaml +++ b/src/WPFDevelopers.Shared/Themes/CropAvatar.xaml @@ -19,7 +19,7 @@ x:Name="PART_Layout" Width="200" Height="200" - Fill="{DynamicResource WD.BlackSolidColorBrush}" + Fill="{DynamicResource WD.BlackBrush}" Opacity=".5"> @@ -51,7 +51,7 @@ diff --git a/src/WPFDevelopers.Shared/Themes/CropImage.xaml b/src/WPFDevelopers.Shared/Themes/CropImage.xaml index 500a43ee..96d5dc87 100644 --- a/src/WPFDevelopers.Shared/Themes/CropImage.xaml +++ b/src/WPFDevelopers.Shared/Themes/CropImage.xaml @@ -20,7 +20,7 @@ diff --git a/src/WPFDevelopers.Shared/Themes/Dark.Blue.xaml b/src/WPFDevelopers.Shared/Themes/Dark.Blue.xaml deleted file mode 100644 index 02b99f70..00000000 --- a/src/WPFDevelopers.Shared/Themes/Dark.Blue.xaml +++ /dev/null @@ -1,25 +0,0 @@ - - - - #FFFFFF - - - #FFC6E2FF - - #FFEBF4FF - - #FF398DE6 - - - #409EFF - - - #66B1FF - - - #3A8EE6 - - - \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Themes/DateRangePicker.xaml b/src/WPFDevelopers.Shared/Themes/DateRangePicker.xaml index 8c810d93..d35ceaa4 100644 --- a/src/WPFDevelopers.Shared/Themes/DateRangePicker.xaml +++ b/src/WPFDevelopers.Shared/Themes/DateRangePicker.xaml @@ -22,19 +22,19 @@ HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="12" - Foreground="{DynamicResource WD.PrimaryTextSolidColorBrush}" + Foreground="{DynamicResource WD.PrimaryTextBrush}" Text="{Binding}" /> + Fill="{DynamicResource WD.BaseBrush}" /> - + - - + + @@ -205,7 +205,7 @@ Background="Transparent" Focusable="True" Foreground="{TemplateBinding Foreground}" - SelectionBrush="{DynamicResource WD.WindowBorderBrushSolidColorBrush}" /> + SelectionBrush="{DynamicResource WD.WindowBorderBrush}" /> + SelectionBrush="{DynamicResource WD.WindowBorderBrush}" /> - - + + @@ -30,13 +30,13 @@ + Effect="{StaticResource WD.PrimaryShadowDepth}"> diff --git a/src/WPFDevelopers.Shared/Themes/DrawerMenu.xaml b/src/WPFDevelopers.Shared/Themes/DrawerMenu.xaml index 49a3298f..11ad64d5 100644 --- a/src/WPFDevelopers.Shared/Themes/DrawerMenu.xaml +++ b/src/WPFDevelopers.Shared/Themes/DrawerMenu.xaml @@ -29,7 +29,7 @@ @@ -86,11 +86,11 @@ - - + + - + @@ -108,7 +108,7 @@ TargetType="controls:DrawerMenuItem"> - + @@ -156,11 +156,11 @@ - + - + @@ -185,13 +185,13 @@ TargetType="controls:DrawerMenu"> - - - + + + - + - + diff --git a/src/WPFDevelopers.Shared/Themes/EdgeLight.xaml b/src/WPFDevelopers.Shared/Themes/EdgeLight.xaml index 56bd31da..6b333966 100644 --- a/src/WPFDevelopers.Shared/Themes/EdgeLight.xaml +++ b/src/WPFDevelopers.Shared/Themes/EdgeLight.xaml @@ -9,7 +9,7 @@ x:Key="WD.EdgeLight" BasedOn="{StaticResource WD.ControlBasicStyle}" TargetType="{x:Type controls:EdgeLight}"> - + diff --git a/src/WPFDevelopers.Shared/Themes/IPEditBox.xaml b/src/WPFDevelopers.Shared/Themes/IPEditBox.xaml index 15cb15b9..1c6a7d19 100644 --- a/src/WPFDevelopers.Shared/Themes/IPEditBox.xaml +++ b/src/WPFDevelopers.Shared/Themes/IPEditBox.xaml @@ -11,11 +11,11 @@ BasedOn="{StaticResource WD.ControlBasicStyle}" TargetType="{x:Type controls:IPEditBox}"> - - + + - + @@ -66,17 +66,17 @@ - + - + - + diff --git a/src/WPFDevelopers.Shared/Themes/Light.Blue.xaml b/src/WPFDevelopers.Shared/Themes/Light.Blue.xaml deleted file mode 100644 index a57741b9..00000000 --- a/src/WPFDevelopers.Shared/Themes/Light.Blue.xaml +++ /dev/null @@ -1,27 +0,0 @@ - - - - #FFC6E2FF - - - #FFEBF4FF - - - #FF398DE6 - - - #409EFF - - - - #66B1FF - - - #3A8EE6 - - - - - \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Themes/Light.Green.xaml b/src/WPFDevelopers.Shared/Themes/Light.Green.xaml index 40160720..2bcf86de 100644 --- a/src/WPFDevelopers.Shared/Themes/Light.Green.xaml +++ b/src/WPFDevelopers.Shared/Themes/Light.Green.xaml @@ -2,23 +2,23 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" po:Freeze="True"> - #8CF4BB - + #8CF4BB + - #DEFAEB - + #DEFAEB + - #03C25A - + #03C25A + #00B050 - - + + - #6DE0A1 - + #6DE0A1 + #01A74C - + \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Themes/Light.Orange.xaml b/src/WPFDevelopers.Shared/Themes/Light.Orange.xaml index 936cbe46..cd58923f 100644 --- a/src/WPFDevelopers.Shared/Themes/Light.Orange.xaml +++ b/src/WPFDevelopers.Shared/Themes/Light.Orange.xaml @@ -3,23 +3,23 @@ xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" po:Freeze="True"> - #FFCA93 - + #FFCA93 + - #FAEFE4 - + #FAEFE4 + - #FF901D - + #FF901D + #FE9426 - - + + - #FAAD5E - + #FAAD5E + #FA840A - + \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Themes/Light.Pink.xaml b/src/WPFDevelopers.Shared/Themes/Light.Pink.xaml index 454b600f..c0dcd507 100644 --- a/src/WPFDevelopers.Shared/Themes/Light.Pink.xaml +++ b/src/WPFDevelopers.Shared/Themes/Light.Pink.xaml @@ -3,21 +3,21 @@ xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" po:Freeze="True"> - #FA7FBC - - #F8D8E8 - - #F8027D - + #FA7FBC + + #F8D8E8 + + #F8027D + #FF007F - - + + - #FE4EA6 - + #FE4EA6 + #F8027D - + \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Themes/Light.Purple.xaml b/src/WPFDevelopers.Shared/Themes/Light.Purple.xaml index 629944ff..7523c637 100644 --- a/src/WPFDevelopers.Shared/Themes/Light.Purple.xaml +++ b/src/WPFDevelopers.Shared/Themes/Light.Purple.xaml @@ -3,23 +3,23 @@ xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" po:Freeze="True"> - #D79BFE - + #D79BFE + - #F1E2FA - + #F1E2FA + - #C167FC - + #C167FC + #A21BFC - - + + - #B64BFC - + #B64BFC + #9700FC - + \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Themes/Light.Red.xaml b/src/WPFDevelopers.Shared/Themes/Light.Red.xaml index e684a920..a5166c2f 100644 --- a/src/WPFDevelopers.Shared/Themes/Light.Red.xaml +++ b/src/WPFDevelopers.Shared/Themes/Light.Red.xaml @@ -3,21 +3,21 @@ xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" po:Freeze="True"> - #FF8DA7 - - #FFD6DF - - #FF275A - + #FF8DA7 + + #FFD6DF + + #FF275A + #FF033E - - + + - #FE6E90 - + #FE6E90 + #FF0943 - + \ No newline at end of file diff --git a/src/WPFDevelopers.Shared/Themes/LoadingGroup.xaml b/src/WPFDevelopers.Shared/Themes/LoadingGroup.xaml index 965d0de3..5dbfd319 100644 --- a/src/WPFDevelopers.Shared/Themes/LoadingGroup.xaml +++ b/src/WPFDevelopers.Shared/Themes/LoadingGroup.xaml @@ -90,19 +90,19 @@ Canvas.Left="0" Width="20" Height="20" - Fill="{StaticResource WD.DangerSolidColorBrush}" /> + Fill="{StaticResource WD.DangerBrush}" /> + Fill="{StaticResource WD.SuccessBrush}" /> + Fill="{StaticResource WD.WarningBrush}" /> diff --git a/src/WPFDevelopers.Shared/Themes/Magnifier.xaml b/src/WPFDevelopers.Shared/Themes/Magnifier.xaml index 08efbe83..7cadf6dc 100644 --- a/src/WPFDevelopers.Shared/Themes/Magnifier.xaml +++ b/src/WPFDevelopers.Shared/Themes/Magnifier.xaml @@ -15,7 +15,7 @@ - + diff --git a/src/WPFDevelopers.Shared/Themes/Mask.xaml b/src/WPFDevelopers.Shared/Themes/Mask.xaml index b5fce93e..31d287d4 100644 --- a/src/WPFDevelopers.Shared/Themes/Mask.xaml +++ b/src/WPFDevelopers.Shared/Themes/Mask.xaml @@ -11,7 +11,7 @@ TargetType="{x:Type controls:MaskControl}"> - + diff --git a/src/WPFDevelopers.Shared/Themes/Message.xaml b/src/WPFDevelopers.Shared/Themes/Message.xaml index 78d3e421..ad70dfa9 100644 --- a/src/WPFDevelopers.Shared/Themes/Message.xaml +++ b/src/WPFDevelopers.Shared/Themes/Message.xaml @@ -11,8 +11,8 @@ x:Key="WD.MessageListBoxItem" BasedOn="{StaticResource WD.ControlBasicStyle}" TargetType="{x:Type controls:MessageListBoxItem}"> - - + + @@ -83,7 +83,7 @@ BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{Binding Path=(helpers:ElementHelper.CornerRadius), RelativeSource={RelativeSource TemplatedParent}}" - Effect="{StaticResource WD.NormalShadowDepth}" + Effect="{StaticResource WD.PrimaryShadowDepth}" SnapsToDevicePixels="True" UseLayoutRounding="True" /> @@ -98,7 +98,7 @@ Width="15" Height="15" Data="{StaticResource WD.InformationGeometry}" - Fill="{DynamicResource WD.PrimaryNormalSolidColorBrush}" + Fill="{DynamicResource WD.PrimaryBrush}" Stretch="Fill" /> @@ -141,23 +141,23 @@ - - + + - - + + - - + + - - + + diff --git a/src/WPFDevelopers.Shared/Themes/MultiSelectComboBox.xaml b/src/WPFDevelopers.Shared/Themes/MultiSelectComboBox.xaml index 06320fce..a9c85a17 100644 --- a/src/WPFDevelopers.Shared/Themes/MultiSelectComboBox.xaml +++ b/src/WPFDevelopers.Shared/Themes/MultiSelectComboBox.xaml @@ -15,7 +15,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -66,10 +66,10 @@ - + - - + + @@ -124,9 +124,9 @@ Panel.ZIndex="1" Background="Transparent" Focusable="True" - Foreground="{DynamicResource WD.PrimaryTextSolidColorBrush}" + Foreground="{DynamicResource WD.PrimaryTextBrush}" IsReadOnly="True" - SelectionBrush="{DynamicResource WD.WindowBorderBrushSolidColorBrush}" + SelectionBrush="{DynamicResource WD.WindowBorderBrush}" Style="{x:Null}" Template="{StaticResource WD.ComboBoxTextBox}" Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" /> @@ -137,8 +137,8 @@ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Background="Transparent" - FontSize="{StaticResource WD.NormalFontSize}" - Foreground="{DynamicResource WD.RegularTextSolidColorBrush}" + FontSize="{StaticResource WD.PrimaryFontSize}" + Foreground="{DynamicResource WD.RegularTextBrush}" IsHitTestVisible="False" Text="{Binding Path=(helpers:ElementHelper.Watermark), RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" TextTrimming="CharacterEllipsis" @@ -257,7 +257,7 @@ - + diff --git a/src/WPFDevelopers.Shared/Themes/MultiSelectSearchComboBox.xaml b/src/WPFDevelopers.Shared/Themes/MultiSelectSearchComboBox.xaml index d7a7df3d..68917dd4 100644 --- a/src/WPFDevelopers.Shared/Themes/MultiSelectSearchComboBox.xaml +++ b/src/WPFDevelopers.Shared/Themes/MultiSelectSearchComboBox.xaml @@ -19,10 +19,10 @@ - + - - + + @@ -68,9 +68,9 @@ Panel.ZIndex="1" Background="Transparent" Focusable="True" - Foreground="{DynamicResource WD.PrimaryTextSolidColorBrush}" + Foreground="{DynamicResource WD.PrimaryTextBrush}" IsReadOnly="True" - SelectionBrush="{DynamicResource WD.WindowBorderBrushSolidColorBrush}" + SelectionBrush="{DynamicResource WD.WindowBorderBrush}" Style="{x:Null}" Template="{StaticResource WD.ComboBoxTextBox}" Text="{Binding Text, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" /> @@ -80,8 +80,8 @@ HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Background="Transparent" - FontSize="{StaticResource WD.NormalFontSize}" - Foreground="{DynamicResource WD.RegularTextSolidColorBrush}" + FontSize="{StaticResource WD.PrimaryFontSize}" + Foreground="{DynamicResource WD.RegularTextBrush}" IsHitTestVisible="False" Text="{Binding Path=(helpers:ElementHelper.Watermark), RelativeSource={RelativeSource TemplatedParent}}" TextTrimming="CharacterEllipsis" @@ -203,7 +203,7 @@ - + diff --git a/src/WPFDevelopers.Shared/Themes/NavMenu3D.xaml b/src/WPFDevelopers.Shared/Themes/NavMenu3D.xaml index 1dedff14..0cf58a68 100644 --- a/src/WPFDevelopers.Shared/Themes/NavMenu3D.xaml +++ b/src/WPFDevelopers.Shared/Themes/NavMenu3D.xaml @@ -14,9 +14,9 @@ - - - + + + diff --git a/src/WPFDevelopers.Shared/Themes/NumericBox.xaml b/src/WPFDevelopers.Shared/Themes/NumericBox.xaml index be3e5677..1920bee2 100644 --- a/src/WPFDevelopers.Shared/Themes/NumericBox.xaml +++ b/src/WPFDevelopers.Shared/Themes/NumericBox.xaml @@ -13,12 +13,12 @@ - - + + - + @@ -55,7 +55,7 @@ InputMethod.IsInputMethodEnabled="False" IsReadOnly="{TemplateBinding IsReadOnly}" IsTabStop="{TemplateBinding IsTabStop}" - SelectionBrush="{DynamicResource WD.WindowBorderBrushSolidColorBrush}" + SelectionBrush="{DynamicResource WD.WindowBorderBrush}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Style="{x:Null}" TabIndex="{TemplateBinding TabIndex}" @@ -105,7 +105,7 @@ - + diff --git a/src/WPFDevelopers.Shared/Themes/Pagination.xaml b/src/WPFDevelopers.Shared/Themes/Pagination.xaml index de2a2c1a..8fa1cb6d 100644 --- a/src/WPFDevelopers.Shared/Themes/Pagination.xaml +++ b/src/WPFDevelopers.Shared/Themes/Pagination.xaml @@ -46,8 +46,8 @@ - - + + @@ -74,13 +74,13 @@ - - - + + + - - + + diff --git a/src/WPFDevelopers.Shared/Themes/ScreenCut.xaml b/src/WPFDevelopers.Shared/Themes/ScreenCut.xaml index c3be26a1..6cf71b20 100644 --- a/src/WPFDevelopers.Shared/Themes/ScreenCut.xaml +++ b/src/WPFDevelopers.Shared/Themes/ScreenCut.xaml @@ -33,14 +33,14 @@ + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/WPFDevelopers.Samples.Shared/ExampleViews/UsageColor.xaml.cs b/src/WPFDevelopers.Samples.Shared/ExampleViews/UsageColor.xaml.cs new file mode 100644 index 00000000..a8271668 --- /dev/null +++ b/src/WPFDevelopers.Samples.Shared/ExampleViews/UsageColor.xaml.cs @@ -0,0 +1,72 @@ +using System.Collections.ObjectModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using WPFDevelopers.Controls; + +namespace WPFDevelopers.Samples.ExampleViews +{ + /// + /// UsageColor.xaml 的交互逻辑 + /// + public partial class UsageColor : UserControl + { + public ObservableCollection Colors + { + get { return (ObservableCollection)GetValue(ColorsProperty); } + set { SetValue(ColorsProperty, value); } + } + + public static readonly DependencyProperty ColorsProperty = + DependencyProperty.Register(nameof(Colors), typeof(ObservableCollection), typeof(UsageColor), new PropertyMetadata(new ObservableCollection())); + public UsageColor() + { + InitializeComponent(); + DataContext = this; + Loaded += UsageColor_Loaded; + } + + private void UsageColor_Loaded(object sender, RoutedEventArgs e) + { + Colors.Clear(); + Colors.Add(new ColorItem { Name = "Primary", BrushKey = "WD.PrimaryBrush", Brush = (SolidColorBrush)ThemeManager.Instance.PrimaryBrush, MouseOverKey = "WD.PrimaryMouseOverBrush", MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.PrimaryMouseOverBrush") }); + Colors.Add(new ColorItem { Name = "Success", BrushKey = "WD.SuccessBrush", Brush = ThemeManager.Instance.Resources.TryFindResource("WD.SuccessBrush"), MouseOverKey = "WD.SuccessMouseOverBrush", MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.SuccessMouseOverBrush") }); + Colors.Add(new ColorItem { Name = "Warning", BrushKey = "WD.WarningBrush", Brush = ThemeManager.Instance.Resources.TryFindResource("WD.WarningBrush"), MouseOverKey = "WD.WarningMouseOverBrush", MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.WarningMouseOverBrush") }); + Colors.Add(new ColorItem { Name = "Danger", BrushKey = "WD.DangerBrush", Brush = ThemeManager.Instance.Resources.TryFindResource("WD.DangerBrush"), MouseOverKey = "WD.DangerMouseOverBrush", MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.DangerMouseOverBrush") }); + Colors.Add(new ColorItem { Name = "Primary Text", BrushKey = "WD.PrimaryTextBrush", IsMouseOver = false, Brush = ThemeManager.Instance.Resources.TryFindResource("WD.PrimaryTextBrush"), MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.PrimaryTextBrush") }); + Colors.Add(new ColorItem { Name = "Regular Text", BrushKey = "WD.RegularTextBrush", IsMouseOver = false, Brush = ThemeManager.Instance.Resources.TryFindResource("WD.RegularTextBrush"), MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.RegularTextBrush") }); + Colors.Add(new ColorItem { Name = "Placeholder Text", BrushKey = "WD.PlaceholderTextBrush", IsMouseOver = false, Brush = ThemeManager.Instance.Resources.TryFindResource("WD.PlaceholderTextBrush"), MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.PlaceholderTextBrush") }); + Colors.Add(new ColorItem { Name = "Border Base", BrushKey = "WD.BaseBrush", IsMouseOver = false, Brush = ThemeManager.Instance.Resources.TryFindResource("WD.BaseBrush"), MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.BaseBrush") }); + Colors.Add(new ColorItem { Name = "Lighter", BrushKey = "WD.LighterBrush", IsMouseOver = false, Brush = ThemeManager.Instance.Resources.TryFindResource("WD.LighterBrush"), MouseOverBrush = ThemeManager.Instance.Resources.TryFindResource("WD.LighterBrush") }); + } + + public void BtnPrimary_Click(object sender, RoutedEventArgs e) + { + var btn = sender as Button; + var key = btn.Tag.ToString(); + Message.Push($"{key} 已复制粘贴板"); + Clipboard.SetText($"{{DynamicResource {key}}}"); + } + + public void BtnMouseOver_Click(object sender, RoutedEventArgs e) + { + var btn = sender as Button; + var key = btn.Tag.ToString(); + Message.Push($"{key} 已复制粘贴板"); + Clipboard.SetText($"{{DynamicResource {key}}}"); + } + + } + public class ColorItem + { + public string Name { get; set; } + public SolidColorBrush Brush { get; set; } + public string BrushKey { get; set; } + public string ColorCode => Brush?.Color.ToString(); + public SolidColorBrush MouseOverBrush { get; set; } + public bool IsMouseOver { get; set; } = true; + public string MouseOver => IsMouseOver == true ? "MouseOver" : string.Empty; + public string MouseOverKey { get; set; } + public string MouseOverColorCode => IsMouseOver == true ? MouseOverBrush?.Color.ToString() : string.Empty; + } +} diff --git a/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs b/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs index 1ce3291a..921fb7bd 100644 --- a/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs +++ b/src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs @@ -7,6 +7,7 @@ public enum MenuEnum { NavMenu3D, UsageGuide, + UsageColor, BasicControls, NotifyIcon, PanningItems, diff --git a/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs b/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs index 7f866c87..10ecebcb 100644 --- a/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs +++ b/src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs @@ -121,6 +121,9 @@ void MenuItemSelection(string _menuName) case MenuEnum.UsageGuide: ControlPanel = new UsageGuide(); break; + case MenuEnum.UsageColor: + ControlPanel = new UsageColor(); + break; case MenuEnum.BasicControls: ControlPanel = new BasicControlsExample(); break; diff --git a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems index 356e13d1..5ea670d5 100644 --- a/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems +++ b/src/WPFDevelopers.Samples.Shared/WPFDevelopers.Samples.Shared.projitems @@ -305,6 +305,9 @@ TagExample.xaml + + UsageColor.xaml + UsageGuide.xaml @@ -845,6 +848,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer From 3fb2696da131c8a8c4bff0591a2490c0e7566333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 15 Mar 2025 23:05:38 +0800 Subject: [PATCH 097/108] Update WPFDevelopers.sln --- src/WPFDevelopers.sln | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/WPFDevelopers.sln b/src/WPFDevelopers.sln index 4014fd8b..3e8b4d97 100644 --- a/src/WPFDevelopers.sln +++ b/src/WPFDevelopers.sln @@ -80,9 +80,9 @@ Global {88DD2697-4DF1-40DC-B33B-DE1FD9846800} = {2C729CA5-1110-40DA-8EF4-2A7549072C53} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - RESX_SaveFilesImmediatelyUponChange = False - RESX_NeutralResourcesLanguage = zh-CN SolutionGuid = {641F8D5D-5514-4C9A-9FAB-7FAF38D9C008} + RESX_NeutralResourcesLanguage = zh-CN + RESX_SaveFilesImmediatelyUponChange = False EndGlobalSection GlobalSection(SharedMSBuildProjectFiles) = preSolution WPFDevelopers.Samples.Shared\WPFDevelopers.Samples.Shared.projitems*{31f881a8-9ddf-4fc2-999b-d47bc25cb47d}*SharedItemsImports = 5 @@ -91,7 +91,6 @@ Global WPFDevelopers.Samples.Shared\WPFDevelopers.Samples.Shared.projitems*{a0a4e0f8-745e-401a-a654-d4962ca9cc64}*SharedItemsImports = 13 Microsoft.Windows.Shell\Microsoft.Windows.Shell.projitems*{a608ceb8-62c0-47ab-8f8e-6f1e033cfd74}*SharedItemsImports = 5 WPFDevelopers.Shared\WPFDevelopers.Shared.projitems*{a608ceb8-62c0-47ab-8f8e-6f1e033cfd74}*SharedItemsImports = 5 - Microsoft.Windows.Shell\Microsoft.Windows.Shell.projitems*{ad525acc-1df1-4ff6-8cc8-412b866e748a}*SharedItemsImports = 5 WPFDevelopers.Shared\WPFDevelopers.Shared.projitems*{ad525acc-1df1-4ff6-8cc8-412b866e748a}*SharedItemsImports = 5 WPFDevelopers.Shared\WPFDevelopers.Shared.projitems*{f424a42d-ed95-4c4a-8b74-50a7c59658de}*SharedItemsImports = 13 EndGlobalSection From c2ce6e3b2f2f685aad024639c2be95c2ad472bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=97=AB=E9=A9=9A=E9=8F=B5?= Date: Sat, 15 Mar 2025 23:05:42 +0800 Subject: [PATCH 098/108] Update Theme.xaml --- src/WPFDevelopers.Net45x/Themes/Theme.xaml | 121 ++++++++++----------- 1 file changed, 59 insertions(+), 62 deletions(-) diff --git a/src/WPFDevelopers.Net45x/Themes/Theme.xaml b/src/WPFDevelopers.Net45x/Themes/Theme.xaml index 4973da7f..429c480c 100644 --- a/src/WPFDevelopers.Net45x/Themes/Theme.xaml +++ b/src/WPFDevelopers.Net45x/Themes/Theme.xaml @@ -2023,6 +2023,19 @@ + + + + + + + + + + + + + @@ -2371,6 +2384,8 @@ + + @@ -2398,6 +2413,8 @@ + + @@ -2472,6 +2489,8 @@ + + @@ -2513,6 +2532,8 @@ + + @@ -2594,8 +2615,7 @@ - - + @@ -2611,7 +2631,7 @@ - + @@ -3704,60 +3724,6 @@ - - - -