From 9ff50247e70e6d74599e31e5559e58945ad3af4a Mon Sep 17 00:00:00 2001 From: Tienyu Yang <53754724+lingrottin@users.noreply.github.com> Date: Sun, 25 Feb 2024 03:11:12 +0800 Subject: [PATCH] Fix Windows 10 acrylic --- MapTP.App/BlurManager.cs | 10 +++++----- MapTP.App/MainWindow.xaml.cs | 9 +++++---- MapTP.App/MapTP.App.csproj | 20 ++++++++++++++++++++ MapTP.sln | 6 ++++++ 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/MapTP.App/BlurManager.cs b/MapTP.App/BlurManager.cs index 56e6588..ddff1b4 100644 --- a/MapTP.App/BlurManager.cs +++ b/MapTP.App/BlurManager.cs @@ -80,7 +80,7 @@ private void Composite(IntPtr handle, bool isEnabled) var osVersion = Environment.OSVersion.Version; var windows10_1809 = new Version(10, 0, 17763); var windows10 = new Version(10, 0); - var windows11_buildver = 22000; + var windows11_buildver = 22000; // 创建 AccentPolicy 对象。 var accent = new AccentPolicy(); @@ -91,10 +91,10 @@ private void Composite(IntPtr handle, bool isEnabled) accent.AccentState = AccentState.ACCENT_DISABLED; } else if(Environment.OSVersion.Version.Build >= windows11_buildver) - { - accent.AccentState = AccentState.ACCENT_INVALID_STATE; // disable Acrylic and do nothing - } - else if (osVersion > windows10_1809) + { + accent.AccentState = AccentState.ACCENT_INVALID_STATE; // disable Acrylic and do nothing + } + else if (osVersion > windows10_1809) { // 如果系统在 Windows 10 (1809) 以上,则启用亚克力效果,并组合已设置的叠加颜色和透明度。 // 请参见《在 WPF 程序中应用 Windows 10 真•亚克力效果》 diff --git a/MapTP.App/MainWindow.xaml.cs b/MapTP.App/MainWindow.xaml.cs index dedddc6..6155ca1 100644 --- a/MapTP.App/MainWindow.xaml.cs +++ b/MapTP.App/MainWindow.xaml.cs @@ -206,15 +206,16 @@ private void OnLoaded(object sender, RoutedEventArgs e) // Subscribe to PresentationSource's ContentRendered event presentationSource.ContentRendered += (s,ev)=>OnRendered(PresentationSource.FromVisual((Visual)sender) as HwndSource); + } else { - var WalterlvCompositor = new BlurManager(this) { - Color = Color.FromArgb(0x33, 0x87, 0xce, 0xfa) + Color = Color.FromArgb(0x1f, 0x87, 0xce, 0xfa), + IsEnabled = true }; - WalterlvCompositor.IsEnabled = true; + this.WindowChrome.GlassFrameThickness = new Thickness(0, 0, 1, 0); } } @@ -417,7 +418,7 @@ private void SaveConfig() private void OnWindowCloses(object sender, System.ComponentModel.CancelEventArgs e) { - SaveConfig(); + if (ptpExists) SaveConfig(); e.Cancel = false; return; } diff --git a/MapTP.App/MapTP.App.csproj b/MapTP.App/MapTP.App.csproj index ac3b388..d25038d 100644 --- a/MapTP.App/MapTP.App.csproj +++ b/MapTP.App/MapTP.App.csproj @@ -39,6 +39,26 @@ app.manifest + + true + bin\Debug-R\ + DEBUG;TRACE + full + AnyCPU + 10.0 + prompt + true + + + bin\Release-R\ + TRACE + true + pdbonly + AnyCPU + 10.0 + prompt + true + diff --git a/MapTP.sln b/MapTP.sln index 6b54fdb..2bde300 100644 --- a/MapTP.sln +++ b/MapTP.sln @@ -7,13 +7,19 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug-R|Any CPU = Debug-R|Any CPU Release|Any CPU = Release|Any CPU + Release-R|Any CPU = Release-R|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {B640177C-8B8A-4E97-931A-8C13EF816C12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B640177C-8B8A-4E97-931A-8C13EF816C12}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B640177C-8B8A-4E97-931A-8C13EF816C12}.Debug-R|Any CPU.ActiveCfg = Debug-R|Any CPU + {B640177C-8B8A-4E97-931A-8C13EF816C12}.Debug-R|Any CPU.Build.0 = Debug-R|Any CPU {B640177C-8B8A-4E97-931A-8C13EF816C12}.Release|Any CPU.ActiveCfg = Release|Any CPU {B640177C-8B8A-4E97-931A-8C13EF816C12}.Release|Any CPU.Build.0 = Release|Any CPU + {B640177C-8B8A-4E97-931A-8C13EF816C12}.Release-R|Any CPU.ActiveCfg = Release-R|Any CPU + {B640177C-8B8A-4E97-931A-8C13EF816C12}.Release-R|Any CPU.Build.0 = Release-R|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE