From 2ced6005715d8dd0f3f874254292daafe74780ae Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Thu, 30 Apr 2020 01:22:27 +0800 Subject: [PATCH] add Watermark --- .../HandyControlDemo_Core_GE30.csproj | 3 +- .../HandyControlDemo_Net_40.csproj | 22 ++- .../HandyControlDemo_Net_GE45.csproj | 24 ++- src/Shared/HandyControlDemo_Shared/App.xaml | 2 +- .../HandyControlDemo_Shared/App.xaml.cs | 3 +- .../Properties/App.config | 5 + .../Resources/Themes/Basic/Brushes.xaml | 114 +----------- .../UserControl/Basic/Avatar.xaml | 2 +- .../UserControl/Main/BlogsView.xaml | 17 +- .../UserControl/Main/ContributorsView.xaml | 17 +- .../UserControl/Main/NoUserContent.xaml.cs | 10 +- .../UserControl/Main/ProjectsView.xaml | 17 +- .../UserControl/Main/QQGroupView.xaml | 4 +- .../UserControl/Main/WebsitesView.xaml | 17 +- .../ViewModel/Basic/ChatBoxViewModel.cs | 4 - .../Basic/InteractiveDialogViewModel.cs | 4 - .../ViewModel/Controls/BadgeDemoViewModel.cs | 4 - .../ViewModel/Controls/CardDemoViewModel.cs | 4 - .../ViewModel/Controls/DialogDemoViewModel.cs | 4 +- .../ViewModel/Controls/GrowlDemoViewModel.cs | 4 - .../Controls/ImageBrowserDemoViewModel.cs | 4 - .../Controls/NotificationDemoViewModel.cs | 6 +- .../Controls/NotifyIconDemoViewModel.cs | 4 - .../Controls/PaginationDemoViewModel.cs | 4 - .../Controls/SearchBarDemoViewModel.cs | 4 - .../Controls/SideMenuDemoViewModel.cs | 4 - .../Controls/SplitButtonDemoViewModel.cs | 4 - .../ViewModel/Controls/SpriteDemoViewModel.cs | 4 - .../Controls/StepBarDemoViewModel.cs | 4 - .../Controls/TabControlDemoViewModel.cs | 4 - .../ViewModel/Controls/WindowDemoViewModel.cs | 4 - .../ViewModel/Main/MainViewModel.cs | 4 - .../ViewModel/Main/NoUserViewModel.cs | 4 - .../ViewModel/ViewModelLocator.cs | 55 +++--- .../Window/CustomNonClientAreaWindow.xaml | 16 +- .../Controls/Other/Watermark.cs | 164 ++++++++++++++++++ .../HandyControl_Shared.projitems | 9 + .../Themes/Styles/Base/MenuBaseStyle.xaml | 4 +- .../Styles/Base/WatermarkBaseStyle.xaml | 20 +++ .../Themes/Styles/Style.xaml | 1 + .../Themes/Styles/Watermark.xaml | 10 ++ .../Tools/GlobalShortcut.cs | 12 ++ 42 files changed, 357 insertions(+), 269 deletions(-) create mode 100644 src/Shared/HandyControl_Shared/Controls/Other/Watermark.cs create mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/Base/WatermarkBaseStyle.xaml create mode 100644 src/Shared/HandyControl_Shared/Themes/Styles/Watermark.xaml diff --git a/src/Core_GE30/HandyControlDemo_Core_GE30/HandyControlDemo_Core_GE30.csproj b/src/Core_GE30/HandyControlDemo_Core_GE30/HandyControlDemo_Core_GE30.csproj index 0231a345..9a72efda 100644 --- a/src/Core_GE30/HandyControlDemo_Core_GE30/HandyControlDemo_Core_GE30.csproj +++ b/src/Core_GE30/HandyControlDemo_Core_GE30/HandyControlDemo_Core_GE30.csproj @@ -34,8 +34,7 @@ - - + diff --git a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj index f6afa157..2afd198a 100644 --- a/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj +++ b/src/Net_40/HandyControlDemo_Net_40/HandyControlDemo_Net_40.csproj @@ -43,6 +43,9 @@ ..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico + + OnOutputUpdated + @@ -220,7 +223,7 @@ Resources\Img\Flag\ru.png - + Resources\Img\Flag\tr.png @@ -424,7 +427,7 @@ - + Properties\Langs\Lang.tr.resx @@ -585,4 +588,19 @@ + + if not exist Langs md Langs +rd /s /q Langs\en +rd /s /q Langs\fa +rd /s /q Langs\fr +rd /s /q Langs\ko-KR +rd /s /q Langs\ru +rd /s /q Langs\tr +move en Langs +move fa Langs +move fr Langs +move ko-KR Langs +move ru Langs +move tr Langs + \ No newline at end of file diff --git a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj index a482ad24..9219c787 100644 --- a/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj +++ b/src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj @@ -113,6 +113,9 @@ ..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico + + OnOutputUpdated + @@ -141,7 +144,7 @@ 6.0.1 - + 5.4.1.1 @@ -298,7 +301,7 @@ Resources\Img\Flag\ru.png - + Resources\Img\Flag\tr.png @@ -492,7 +495,7 @@ - + Properties\Langs\Lang.tr.resx @@ -656,4 +659,19 @@ + + if not exist Langs md Langs +rd /s /q Langs\en +rd /s /q Langs\fa +rd /s /q Langs\fr +rd /s /q Langs\ko-KR +rd /s /q Langs\ru +rd /s /q Langs\tr +move en Langs +move fa Langs +move fr Langs +move ko-KR Langs +move ru Langs +move tr Langs + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml b/src/Shared/HandyControlDemo_Shared/App.xaml index 57f9f649..da21212a 100644 --- a/src/Shared/HandyControlDemo_Shared/App.xaml +++ b/src/Shared/HandyControlDemo_Shared/App.xaml @@ -27,7 +27,7 @@ - + diff --git a/src/Shared/HandyControlDemo_Shared/App.xaml.cs b/src/Shared/HandyControlDemo_Shared/App.xaml.cs index 9a85705a..f358fa17 100644 --- a/src/Shared/HandyControlDemo_Shared/App.xaml.cs +++ b/src/Shared/HandyControlDemo_Shared/App.xaml.cs @@ -92,8 +92,7 @@ namespace HandyControlDemo skins0.MergedDictionaries.Clear(); skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(skin)); skins0.MergedDictionaries.Add(ResourceHelper.GetSkin(typeof(App).Assembly, "Resources/Themes", skin)); - - + var skins1 = Resources.MergedDictionaries[1]; skins1.MergedDictionaries.Clear(); skins1.MergedDictionaries.Add(new ResourceDictionary diff --git a/src/Shared/HandyControlDemo_Shared/Properties/App.config b/src/Shared/HandyControlDemo_Shared/Properties/App.config index 49cc43e1..df82ad2d 100644 --- a/src/Shared/HandyControlDemo_Shared/Properties/App.config +++ b/src/Shared/HandyControlDemo_Shared/Properties/App.config @@ -1,3 +1,8 @@  + + + + + \ No newline at end of file diff --git a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Basic/Brushes.xaml b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Basic/Brushes.xaml index 3d620ea4..a6cb95f5 100644 --- a/src/Shared/HandyControlDemo_Shared/Resources/Themes/Basic/Brushes.xaml +++ b/src/Shared/HandyControlDemo_Shared/Resources/Themes/Basic/Brushes.xaml @@ -8,121 +8,19 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/Avatar.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/Avatar.xaml index f0199ed4..d1770751 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Basic/Avatar.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Basic/Avatar.xaml @@ -16,7 +16,7 @@ - + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/BlogsView.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/BlogsView.xaml index eb809c0a..d7f0e5dc 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/BlogsView.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/BlogsView.xaml @@ -2,13 +2,16 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" + xmlns:hc="https://handyorg.github.io/handycontrol" DataContext="{Binding BlogsView,Source={StaticResource Locator}}" Background="{DynamicResource SecondaryRegionBrush}"> - - - - - - - + + + + + + + + + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/ContributorsView.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/ContributorsView.xaml index a54aa694..8f807024 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/ContributorsView.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/ContributorsView.xaml @@ -2,13 +2,16 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" + xmlns:hc="https://handyorg.github.io/handycontrol" DataContext="{Binding ContributorsView,Source={StaticResource Locator}}" Background="{DynamicResource SecondaryRegionBrush}"> - - - - - - - + + + + + + + + + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml.cs index a44361b1..d439d97c 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml.cs +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/NoUserContent.xaml.cs @@ -19,15 +19,15 @@ namespace HandyControlDemo.UserControl private void ButtonLangs_OnClick(object sender, RoutedEventArgs e) { - if (e.OriginalSource is Button button && button.Tag is string tag) + if (e.OriginalSource is Button button && button.Tag is string langName) { PopupConfig.IsOpen = false; - if (tag.Equals(GlobalData.Config.Lang)) return; - ConfigHelper.Instance.SetLang(tag); - LangProvider.Culture = new CultureInfo(tag); + if (langName.Equals(GlobalData.Config.Lang)) return; + ConfigHelper.Instance.SetLang(langName); + LangProvider.Culture = new CultureInfo(langName); Messenger.Default.Send(null, "LangUpdated"); - GlobalData.Config.Lang = tag; + GlobalData.Config.Lang = langName; GlobalData.Save(); } } diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/ProjectsView.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/ProjectsView.xaml index 5ef7ed0e..8082f01c 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/ProjectsView.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/ProjectsView.xaml @@ -2,13 +2,16 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" + xmlns:hc="https://handyorg.github.io/handycontrol" DataContext="{Binding ProjectsView,Source={StaticResource Locator}}" Background="{DynamicResource SecondaryRegionBrush}"> - - - - - - - + + + + + + + + + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/QQGroupView.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/QQGroupView.xaml index 36e93801..86351a97 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/QQGroupView.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/QQGroupView.xaml @@ -3,7 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:hc="https://handyorg.github.io/handycontrol" Background="{DynamicResource SecondaryRegionBrush}"> - + @@ -16,5 +16,5 @@ - + diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Main/WebsitesView.xaml b/src/Shared/HandyControlDemo_Shared/UserControl/Main/WebsitesView.xaml index 74852972..258f8597 100644 --- a/src/Shared/HandyControlDemo_Shared/UserControl/Main/WebsitesView.xaml +++ b/src/Shared/HandyControlDemo_Shared/UserControl/Main/WebsitesView.xaml @@ -2,13 +2,16 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:userControl="clr-namespace:HandyControlDemo.UserControl" + xmlns:hc="https://handyorg.github.io/handycontrol" DataContext="{Binding WebsitesView,Source={StaticResource Locator}}" Background="{DynamicResource SecondaryRegionBrush}"> - - - - - - - + + + + + + + + + diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/ChatBoxViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/ChatBoxViewModel.cs index e19fd556..72e4010f 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/ChatBoxViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/ChatBoxViewModel.cs @@ -7,11 +7,7 @@ using System.Windows; using System.Windows.Input; using System.Windows.Media.Imaging; using GalaSoft.MvvmLight; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -#endif using GalaSoft.MvvmLight.Messaging; using HandyControl.Controls; using HandyControl.Data; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/InteractiveDialogViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/InteractiveDialogViewModel.cs index d9a19626..2e483e9d 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/InteractiveDialogViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Basic/InteractiveDialogViewModel.cs @@ -1,10 +1,6 @@ using System; using GalaSoft.MvvmLight; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -#endif using HandyControl.Tools.Extension; namespace HandyControlDemo.ViewModel diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/BadgeDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/BadgeDemoViewModel.cs index 5570cc4e..b06bfe4e 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/BadgeDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/BadgeDemoViewModel.cs @@ -1,10 +1,6 @@ using System; using GalaSoft.MvvmLight; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -#endif namespace HandyControlDemo.ViewModel { diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/CardDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/CardDemoViewModel.cs index 671d2c52..9799eba8 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/CardDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/CardDemoViewModel.cs @@ -1,9 +1,5 @@ using System; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -#endif using HandyControlDemo.Data; using HandyControlDemo.Service; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs index f223cd5a..51c379a5 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/DialogDemoViewModel.cs @@ -1,11 +1,9 @@ using System; using System.Windows; using GalaSoft.MvvmLight; -#if netle40 using GalaSoft.MvvmLight.Command; -#else +#if !netle40 using System.Threading.Tasks; -using GalaSoft.MvvmLight.CommandWpf; #endif using HandyControl.Controls; using HandyControl.Tools.Extension; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/GrowlDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/GrowlDemoViewModel.cs index 2685093b..dfda7028 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/GrowlDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/GrowlDemoViewModel.cs @@ -1,10 +1,6 @@ using System; using System.Windows; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif using HandyControl.Controls; using HandyControl.Data; using HandyControlDemo.Window; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/ImageBrowserDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/ImageBrowserDemoViewModel.cs index fb1fa279..2fa5120a 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/ImageBrowserDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/ImageBrowserDemoViewModel.cs @@ -1,9 +1,5 @@ using System; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif using HandyControl.Controls; namespace HandyControlDemo.ViewModel diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotificationDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotificationDemoViewModel.cs index e5ed3be9..5dd38997 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotificationDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotificationDemoViewModel.cs @@ -1,8 +1,4 @@ -#if netle40 -using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif +using GalaSoft.MvvmLight.Command; using System; using GalaSoft.MvvmLight; using HandyControl.Controls; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotifyIconDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotifyIconDemoViewModel.cs index 428371dd..9d84a0ed 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotifyIconDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/NotifyIconDemoViewModel.cs @@ -1,10 +1,6 @@ using System; using GalaSoft.MvvmLight; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif using HandyControl.Controls; using HandyControl.Data; using HandyControlDemo.Data; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/PaginationDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/PaginationDemoViewModel.cs index 29db0a61..d3cd65fd 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/PaginationDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/PaginationDemoViewModel.cs @@ -1,11 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif using HandyControl.Data; using HandyControlDemo.Data; using HandyControlDemo.Service; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SearchBarDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SearchBarDemoViewModel.cs index 61ff2dbb..75dccd5f 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SearchBarDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SearchBarDemoViewModel.cs @@ -1,10 +1,6 @@ using System; using GalaSoft.MvvmLight; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif using HandyControl.Controls; namespace HandyControlDemo.ViewModel diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SideMenuDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SideMenuDemoViewModel.cs index 9ae05f36..f5636cd0 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SideMenuDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SideMenuDemoViewModel.cs @@ -2,11 +2,7 @@ using GalaSoft.MvvmLight; using HandyControl.Controls; using HandyControl.Data; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif namespace HandyControlDemo.ViewModel { diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SplitButtonDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SplitButtonDemoViewModel.cs index 43a77e8f..3469b16b 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SplitButtonDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SplitButtonDemoViewModel.cs @@ -1,11 +1,7 @@ using System; using GalaSoft.MvvmLight; using HandyControl.Controls; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif namespace HandyControlDemo.ViewModel { diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SpriteDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SpriteDemoViewModel.cs index b6bc4fe0..f6f83dd7 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SpriteDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/SpriteDemoViewModel.cs @@ -1,11 +1,7 @@ using System; using HandyControl.Controls; using HandyControlDemo.UserControl; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif namespace HandyControlDemo.ViewModel { diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs index 49d03a53..efe95b8e 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/StepBarDemoViewModel.cs @@ -1,11 +1,7 @@ using System; using System.Linq; using System.Windows.Controls; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif using HandyControl.Controls; using HandyControlDemo.Data; using HandyControlDemo.Service; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/TabControlDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/TabControlDemoViewModel.cs index 0546ae7b..103d4fab 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/TabControlDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/TabControlDemoViewModel.cs @@ -4,11 +4,7 @@ using HandyControl.Controls; using HandyControl.Data; using HandyControlDemo.Data; using HandyControlDemo.Service; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -#endif namespace HandyControlDemo.ViewModel { diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/WindowDemoViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/WindowDemoViewModel.cs index a6246c52..6acc5fe4 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/WindowDemoViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Controls/WindowDemoViewModel.cs @@ -1,10 +1,6 @@ using System; using System.Windows; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -# endif using HandyControlDemo.Tools; namespace HandyControlDemo.ViewModel diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Main/MainViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Main/MainViewModel.cs index 1f3d4207..1de5800c 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Main/MainViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Main/MainViewModel.cs @@ -1,11 +1,7 @@ using System; using System.Collections.Generic; using System.Windows.Controls; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -#endif using GalaSoft.MvvmLight.Messaging; using HandyControl.Controls; using HandyControlDemo.Data; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/Main/NoUserViewModel.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/Main/NoUserViewModel.cs index 7504b0d8..977ddc7b 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/Main/NoUserViewModel.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/Main/NoUserViewModel.cs @@ -1,10 +1,6 @@ using System; using GalaSoft.MvvmLight; -#if netle40 using GalaSoft.MvvmLight.Command; -#else -using GalaSoft.MvvmLight.CommandWpf; -#endif using GalaSoft.MvvmLight.Messaging; using HandyControlDemo.Data; using HandyControlDemo.Tools; diff --git a/src/Shared/HandyControlDemo_Shared/ViewModel/ViewModelLocator.cs b/src/Shared/HandyControlDemo_Shared/ViewModel/ViewModelLocator.cs index af874736..397d68b9 100644 --- a/src/Shared/HandyControlDemo_Shared/ViewModel/ViewModelLocator.cs +++ b/src/Shared/HandyControlDemo_Shared/ViewModel/ViewModelLocator.cs @@ -1,6 +1,5 @@ using System; using System.Windows; -using CommonServiceLocator; using GalaSoft.MvvmLight.Ioc; using HandyControlDemo.Data; using HandyControlDemo.Service; @@ -11,10 +10,8 @@ namespace HandyControlDemo.ViewModel { public ViewModelLocator() { - ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); - SimpleIoc.Default.Register(); - var dataService = ServiceLocator.Current.GetInstance(); + var dataService = SimpleIoc.Default.GetInstance(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(() => new GrowlDemoViewModel(), "GrowlDemo"); @@ -49,57 +46,57 @@ namespace HandyControlDemo.ViewModel #region Vm - public MainViewModel Main => ServiceLocator.Current.GetInstance(); + public MainViewModel Main => SimpleIoc.Default.GetInstance(); - public GrowlDemoViewModel GrowlDemo => ServiceLocator.Current.GetInstance("GrowlDemo"); + public GrowlDemoViewModel GrowlDemo => SimpleIoc.Default.GetInstance("GrowlDemo"); - public GrowlDemoViewModel GrowlDemoWithToken => ServiceLocator.Current.GetInstance("GrowlDemoWithToken"); + public GrowlDemoViewModel GrowlDemoWithToken => SimpleIoc.Default.GetInstance("GrowlDemoWithToken"); - public ImageBrowserDemoViewModel ImageBrowserDemo => ServiceLocator.Current.GetInstance(); + public ImageBrowserDemoViewModel ImageBrowserDemo => SimpleIoc.Default.GetInstance(); - public ComboBoxDemoViewModel ComboBoxDemo => ServiceLocator.Current.GetInstance(); + public ComboBoxDemoViewModel ComboBoxDemo => SimpleIoc.Default.GetInstance(); - public WindowDemoViewModel WindowDemo => ServiceLocator.Current.GetInstance(); + public WindowDemoViewModel WindowDemo => SimpleIoc.Default.GetInstance(); - public ItemsDisplayViewModel ContributorsView => ServiceLocator.Current.GetInstance("Contributors"); + public ItemsDisplayViewModel ContributorsView => SimpleIoc.Default.GetInstance("Contributors"); - public ItemsDisplayViewModel BlogsView => ServiceLocator.Current.GetInstance("Blogs"); + public ItemsDisplayViewModel BlogsView => SimpleIoc.Default.GetInstance("Blogs"); - public ItemsDisplayViewModel ProjectsView => ServiceLocator.Current.GetInstance("Projects"); + public ItemsDisplayViewModel ProjectsView => SimpleIoc.Default.GetInstance("Projects"); - public ItemsDisplayViewModel WebsitesView => ServiceLocator.Current.GetInstance("Websites"); + public ItemsDisplayViewModel WebsitesView => SimpleIoc.Default.GetInstance("Websites"); - public StepBarDemoViewModel StepBarDemo => ServiceLocator.Current.GetInstance(); + public StepBarDemoViewModel StepBarDemo => SimpleIoc.Default.GetInstance(); - public PaginationDemoViewModel PaginationDemo => ServiceLocator.Current.GetInstance(); + public PaginationDemoViewModel PaginationDemo => SimpleIoc.Default.GetInstance(); public ChatBoxViewModel ChatBox => new ChatBoxViewModel(); - public CoverViewModel CoverView => ServiceLocator.Current.GetInstance(); + public CoverViewModel CoverView => SimpleIoc.Default.GetInstance(); - public DialogDemoViewModel DialogDemo => ServiceLocator.Current.GetInstance(); + public DialogDemoViewModel DialogDemo => SimpleIoc.Default.GetInstance(); - public SearchBarDemoViewModel SearchBarDemo => ServiceLocator.Current.GetInstance(); + public SearchBarDemoViewModel SearchBarDemo => SimpleIoc.Default.GetInstance(); - public NotifyIconDemoViewModel NotifyIconDemo => ServiceLocator.Current.GetInstance(); + public NotifyIconDemoViewModel NotifyIconDemo => SimpleIoc.Default.GetInstance(); - public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance(); + public InteractiveDialogViewModel InteractiveDialog => SimpleIoc.Default.GetInstance(); - public BadgeDemoViewModel BadgeDemo => ServiceLocator.Current.GetInstance(); + public BadgeDemoViewModel BadgeDemo => SimpleIoc.Default.GetInstance(); - public SideMenuDemoViewModel SideMenuDemo => ServiceLocator.Current.GetInstance(); + public SideMenuDemoViewModel SideMenuDemo => SimpleIoc.Default.GetInstance(); - public TabControlDemoViewModel TabControlDemo => new TabControlDemoViewModel(ServiceLocator.Current.GetInstance()); + public TabControlDemoViewModel TabControlDemo => new TabControlDemoViewModel(SimpleIoc.Default.GetInstance()); - public NoUserViewModel NoUser => ServiceLocator.Current.GetInstance(); + public NoUserViewModel NoUser => SimpleIoc.Default.GetInstance(); - public CardDemoViewModel CardDemo => new CardDemoViewModel(ServiceLocator.Current.GetInstance()); + public CardDemoViewModel CardDemo => new CardDemoViewModel(SimpleIoc.Default.GetInstance()); - public SpriteDemoViewModel SpriteDemo => ServiceLocator.Current.GetInstance(); + public SpriteDemoViewModel SpriteDemo => SimpleIoc.Default.GetInstance(); - public NotificationDemoViewModel NotificationDemo => ServiceLocator.Current.GetInstance(); + public NotificationDemoViewModel NotificationDemo => SimpleIoc.Default.GetInstance(); - public SplitButtonDemoViewModel SplitButtonDemo => ServiceLocator.Current.GetInstance(); + public SplitButtonDemoViewModel SplitButtonDemo => SimpleIoc.Default.GetInstance(); #endregion } diff --git a/src/Shared/HandyControlDemo_Shared/Window/CustomNonClientAreaWindow.xaml b/src/Shared/HandyControlDemo_Shared/Window/CustomNonClientAreaWindow.xaml index 7915ac2c..cda859ef 100644 --- a/src/Shared/HandyControlDemo_Shared/Window/CustomNonClientAreaWindow.xaml +++ b/src/Shared/HandyControlDemo_Shared/Window/CustomNonClientAreaWindow.xaml @@ -19,40 +19,40 @@ Width="800"> - + diff --git a/src/Shared/HandyControl_Shared/Controls/Other/Watermark.cs b/src/Shared/HandyControl_Shared/Controls/Other/Watermark.cs new file mode 100644 index 00000000..3c01033e --- /dev/null +++ b/src/Shared/HandyControl_Shared/Controls/Other/Watermark.cs @@ -0,0 +1,164 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Markup; +using System.Windows.Media; +using System.Windows.Shapes; +using HandyControl.Data; + +namespace HandyControl.Controls +{ + [TemplatePart(Name = ElementRoot, Type = typeof(Border))] + [ContentProperty(nameof(Content))] + public class Watermark : Control + { + private const string ElementRoot = "PART_Root"; + + private Border _borderRoot; + + private DrawingBrush _brush; + + public static readonly DependencyProperty AngleProperty = DependencyProperty.Register( + "Angle", typeof(double), typeof(Watermark), new FrameworkPropertyMetadata(ValueBoxes.Double0Box, FrameworkPropertyMetadataOptions.AffectsRender)); + + public double Angle + { + get => (double) GetValue(AngleProperty); + set => SetValue(AngleProperty, value); + } + + public static readonly DependencyProperty ContentProperty = DependencyProperty.Register( + "Content", typeof(object), typeof(Watermark), new PropertyMetadata(default)); + + public object Content + { + get => GetValue(ContentProperty); + set => SetValue(ContentProperty, value); + } + + public static readonly DependencyProperty MarkProperty = DependencyProperty.Register( + "Mark", typeof(object), typeof(Watermark), new FrameworkPropertyMetadata(default, FrameworkPropertyMetadataOptions.AffectsRender)); + + public object Mark + { + get => GetValue(MarkProperty); + set => SetValue(MarkProperty, value); + } + + public static readonly DependencyProperty MarkWidthProperty = DependencyProperty.Register( + "MarkWidth", typeof(double), typeof(Watermark), new FrameworkPropertyMetadata(ValueBoxes.Double0Box, FrameworkPropertyMetadataOptions.AffectsRender)); + + public double MarkWidth + { + get => (double) GetValue(MarkWidthProperty); + set => SetValue(MarkWidthProperty, value); + } + + public static readonly DependencyProperty MarkHeightProperty = DependencyProperty.Register( + "MarkHeight", typeof(double), typeof(Watermark), new FrameworkPropertyMetadata(ValueBoxes.Double0Box, FrameworkPropertyMetadataOptions.AffectsRender)); + + public double MarkHeight + { + get => (double) GetValue(MarkHeightProperty); + set => SetValue(MarkHeightProperty, value); + } + + public static readonly DependencyProperty MarkBrushProperty = DependencyProperty.Register( + "MarkBrush", typeof(Brush), typeof(Watermark), new FrameworkPropertyMetadata(default(Brush), FrameworkPropertyMetadataOptions.AffectsRender)); + + public Brush MarkBrush + { + get => (Brush) GetValue(MarkBrushProperty); + set => SetValue(MarkBrushProperty, value); + } + + public static readonly DependencyProperty AutoSizeEnabledProperty = DependencyProperty.Register( + "AutoSizeEnabled", typeof(bool), typeof(Watermark), new PropertyMetadata(ValueBoxes.TrueBox)); + + public bool AutoSizeEnabled + { + get => (bool) GetValue(AutoSizeEnabledProperty); + set => SetValue(AutoSizeEnabledProperty, value); + } + + public static readonly DependencyProperty MarkMarginProperty = DependencyProperty.Register( + "MarkMargin", typeof(Thickness), typeof(Watermark), new PropertyMetadata(default(Thickness))); + + public Thickness MarkMargin + { + get => (Thickness) GetValue(MarkMarginProperty); + set => SetValue(MarkMarginProperty, value); + } + + public override void OnApplyTemplate() => _borderRoot = GetTemplateChild(ElementRoot) as Border; + + private void EnsureBrush() + { + var presenter = new ContentPresenter(); + + if (Mark is Geometry geometry) + { + presenter.Content = new Path + { + Width = MarkWidth, + Height = MarkHeight, + Fill = MarkBrush, + Stretch = Stretch.Uniform, + Data = geometry + }; + } + else if (Mark is string str) + { + presenter.Content = new TextBlock + { + Text = str, + FontSize = FontSize + }; + } + else + { + presenter.Content = Mark; + } + + Size markSize; + if (AutoSizeEnabled) + { + presenter.Measure(new Size(double.MaxValue, double.MaxValue)); + markSize = presenter.DesiredSize; + } + else + { + markSize = new Size(MarkWidth, MarkHeight); + } + + _brush = new DrawingBrush + { + ViewportUnits = BrushMappingMode.Absolute, + Stretch = Stretch.Uniform, + TileMode = TileMode.Tile, + Transform = new RotateTransform(Angle), + Drawing = new GeometryDrawing + { + Brush = new VisualBrush(new Border + { + Background = Brushes.Transparent, + Padding = MarkMargin, + Child = presenter + }), + Geometry = new RectangleGeometry(new Rect(markSize)) + }, + Viewport = new Rect(markSize) + }; + + RenderOptions.SetCacheInvalidationThresholdMinimum(_brush, 0.5); + RenderOptions.SetCacheInvalidationThresholdMaximum(_brush, 2); + RenderOptions.SetCachingHint(_brush, CachingHint.Cache); + + if (_borderRoot != null) + { + _borderRoot.Background = _brush; + } + } + + protected override void OnRender(DrawingContext drawingContext) => EnsureBrush(); + } +} diff --git a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems index e07b2caa..b447dd89 100644 --- a/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems +++ b/src/Shared/HandyControl_Shared/HandyControl_Shared.projitems @@ -36,6 +36,7 @@ + @@ -414,6 +415,14 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml index d9d3be29..bd9f7e1b 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/MenuBaseStyle.xaml @@ -85,7 +85,7 @@ - + @@ -125,7 +125,7 @@ - + diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Base/WatermarkBaseStyle.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Base/WatermarkBaseStyle.xaml new file mode 100644 index 00000000..98861afc --- /dev/null +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Base/WatermarkBaseStyle.xaml @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml index ac11aa8f..73480e70 100644 --- a/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Style.xaml @@ -86,6 +86,7 @@ + \ No newline at end of file diff --git a/src/Shared/HandyControl_Shared/Themes/Styles/Watermark.xaml b/src/Shared/HandyControl_Shared/Themes/Styles/Watermark.xaml new file mode 100644 index 00000000..9b9ebd58 --- /dev/null +++ b/src/Shared/HandyControl_Shared/Themes/Styles/Watermark.xaml @@ -0,0 +1,10 @@ + + + + + + +