Skip to content

Commit

Permalink
Fix Windows 10 acrylic
Browse files Browse the repository at this point in the history
  • Loading branch information
lingrottin committed Feb 24, 2024
1 parent 6104ee4 commit 9ff5024
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
10 changes: 5 additions & 5 deletions MapTP.App/BlurManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 真•亚克力效果》
Expand Down
9 changes: 5 additions & 4 deletions MapTP.App/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -417,7 +418,7 @@ private void SaveConfig()

private void OnWindowCloses(object sender, System.ComponentModel.CancelEventArgs e)
{
SaveConfig();
if (ptpExists) SaveConfig();
e.Cancel = false;
return;
}
Expand Down
20 changes: 20 additions & 0 deletions MapTP.App/MapTP.App.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug-R|AnyCPU'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\Debug-R\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>10.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release-R|AnyCPU'">
<OutputPath>bin\Release-R\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>10.0</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
Expand Down
6 changes: 6 additions & 0 deletions MapTP.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9ff5024

Please sign in to comment.