mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-24 19:00:04 +08:00
新增win11上可设置背景透明材质Acrylic 或 Mica效果
This commit is contained in:
@@ -322,7 +322,8 @@ namespace System.Application.UI
|
||||
public override void RegisterServices()
|
||||
{
|
||||
IViewModelBase.IsInDesignMode = ApplicationLifetime == null;
|
||||
if (ViewModelBase.IsInDesignMode) Startup.Init(DILevel.MainProcess | DILevel.GUI);
|
||||
if (ViewModelBase.IsInDesignMode)
|
||||
Startup.Init(DILevel.MainProcess | DILevel.GUI);
|
||||
|
||||
AvaloniaLocator.CurrentMutable.Bind<IFontManagerImpl>().ToConstant(DI.Get<IFontManagerImpl>());
|
||||
base.RegisterServices();
|
||||
@@ -484,7 +485,20 @@ namespace System.Application.UI
|
||||
#pragma warning restore CA1416 // 验证平台兼容性
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前打开窗口的AvaloniaWinodw背景透明材质
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
public void SetAllWindowransparencyMateria(int level)
|
||||
{
|
||||
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
foreach (var window in desktop.Windows.Where(x => x.IsActive))
|
||||
{
|
||||
window.TransparencyLevelHint = (WindowTransparencyLevel)level;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exits the app by calling <c>Shutdown()</c> on the <c>IClassicDesktopStyleApplicationLifetime</c>.
|
||||
|
||||
+21
-4
@@ -222,7 +222,11 @@ namespace System.Application.Services.Implementation
|
||||
{
|
||||
try
|
||||
{
|
||||
app.CloseWindow(vm);
|
||||
if (app.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var window = desktop.Windows.FirstOrDefault(x => x.DataContext == vm);
|
||||
window?.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -235,7 +239,12 @@ namespace System.Application.Services.Implementation
|
||||
{
|
||||
try
|
||||
{
|
||||
return app.IsVisibleWindow(vm);
|
||||
if (app.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var window = desktop.Windows.FirstOrDefault(x => x.DataContext == vm);
|
||||
return window?.IsVisible == true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -249,7 +258,11 @@ namespace System.Application.Services.Implementation
|
||||
{
|
||||
try
|
||||
{
|
||||
app.HideWindow(vm);
|
||||
if (app.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var window = desktop.Windows.FirstOrDefault(x => x.DataContext == vm);
|
||||
window?.Hide();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -262,7 +275,11 @@ namespace System.Application.Services.Implementation
|
||||
{
|
||||
try
|
||||
{
|
||||
app.ShowWindowNoParent(vm);
|
||||
if (app.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var window = desktop.Windows.FirstOrDefault(x => x.DataContext == vm);
|
||||
window?.Show();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -63,51 +63,6 @@ namespace System.Application.UI
|
||||
window.Show();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据WindowViewModel显示window
|
||||
/// </summary>
|
||||
/// <param name="window"></param>
|
||||
void ShowWindowNoParent(WindowViewModel vm)
|
||||
{
|
||||
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var window = desktop.Windows.FirstOrDefault(x => x.DataContext == vm);
|
||||
window?.Show();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据WindowViewModel关闭window
|
||||
/// </summary>
|
||||
/// <param name="window"></param>
|
||||
void CloseWindow(WindowViewModel vm)
|
||||
{
|
||||
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var window = desktop.Windows.FirstOrDefault(x => x.DataContext == vm);
|
||||
window?.Close();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsVisibleWindow(WindowViewModel vm)
|
||||
{
|
||||
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var window = desktop.Windows.FirstOrDefault(x => x.DataContext == vm);
|
||||
return window?.IsVisible == true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void HideWindow(WindowViewModel vm)
|
||||
{
|
||||
if (Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
var window = desktop.Windows.FirstOrDefault(x => x.DataContext == vm);
|
||||
window?.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前渲染子系统名称
|
||||
/// </summary>
|
||||
|
||||
@@ -5,13 +5,10 @@
|
||||
<Border Padding="20">
|
||||
<StackPanel Classes="Settings">
|
||||
<Border Classes="Item">
|
||||
<StackPanel Spacing="10" VerticalAlignment="Center">
|
||||
<WrapPanel>
|
||||
<TextBlock Text="当前 ArchiSteamFarm 版本 : " VerticalAlignment="Center"></TextBlock>
|
||||
<TextBlock Text="V5.0.1.0" VerticalAlignment="Center"></TextBlock>
|
||||
</WrapPanel>
|
||||
<!--<TextBlock Text="最新 ArchiSteamFarm 版本 : " VerticalAlignment="Center"></TextBlock>
|
||||
<TextBlock Text="{ReflectionBinding Source={x:Static ms:ASFSettings.ArchiSteamFarmExePath},Path=Value,Mode=OneWay}" VerticalAlignment="Center"></TextBlock>-->
|
||||
<StackPanel>
|
||||
<TextBlock Text="程序启动时自动运行ASF"/>
|
||||
<TextBlock Classes="prompt"
|
||||
Text="程序启动时自动运行ASF"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
@@ -115,7 +112,7 @@
|
||||
|
||||
<Style Selector="StackPanel.Settings TextBlock.prompt">
|
||||
<Setter Property="FontSize" Value="{StaticResource FontSizeH8}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource InactiveForegroundBrushKey}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiActiveForegroundColorKey}" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<!--<Setter Property="Margin" Value="10 0" />-->
|
||||
<Setter Property="TextWrapping" Value="Wrap" />
|
||||
|
||||
@@ -46,9 +46,9 @@
|
||||
<SolidColorBrush x:Key="SemiactiveBorderBrushKey"
|
||||
Color="#FF3F3F46" />
|
||||
|
||||
<Color x:Key="SemiActiveForegroundColorKey">#FFA0A0A0</Color>
|
||||
<Color x:Key="SemiActiveForegroundColorKey">#FFCFCFCF</Color>
|
||||
<SolidColorBrush x:Key="SemiActiveForegroundBrushKey"
|
||||
Color="#FFA1A0A0" />
|
||||
Color="{StaticResource SemiActiveForegroundColorKey}" />
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
</Design.PreviewWith>
|
||||
|
||||
<Style.Resources>
|
||||
<Color x:Key="ThemeColorKey">#AAFCFCFC</Color>
|
||||
<Color x:Key="ThemeColorKey">#AAFFFFFF</Color>
|
||||
<SolidColorBrush x:Key="ThemeBrushKey"
|
||||
Color="{StaticResource ThemeColorKey}" />
|
||||
|
||||
<Color x:Key="BackgroundColorKey">#FFF7F7F7</Color>
|
||||
<Color x:Key="BackgroundColorKey">#FFFCFCFC</Color>
|
||||
<SolidColorBrush x:Key="BackgroundBrushKey"
|
||||
Color="{StaticResource BackgroundColorKey}" />
|
||||
|
||||
|
||||
@@ -32,22 +32,22 @@
|
||||
TintOpacity="1"/>
|
||||
</ExperimentalAcrylicBorder.Material>
|
||||
</ExperimentalAcrylicBorder>
|
||||
<ExperimentalAcrylicBorder IsHitTestVisible="False"
|
||||
<!--<ExperimentalAcrylicBorder IsHitTestVisible="False"
|
||||
DockPanel.Dock="Right">
|
||||
<ExperimentalAcrylicBorder.Material>
|
||||
<ExperimentalAcrylicMaterial TintColor="{DynamicResource BackgroundColorKey}"
|
||||
MaterialOpacity="{ReflectionBinding Value,Source={x:Static ms:UISettings.AcrylicOpacity},Mode=OneWay}"
|
||||
TintOpacity="1"/>
|
||||
</ExperimentalAcrylicBorder.Material>
|
||||
</ExperimentalAcrylicBorder>
|
||||
<!--<ExperimentalAcrylicBorder IsHitTestVisible="False"
|
||||
</ExperimentalAcrylicBorder>-->
|
||||
<ExperimentalAcrylicBorder IsHitTestVisible="False"
|
||||
DockPanel.Dock="Right">
|
||||
<ExperimentalAcrylicBorder.Material>
|
||||
<ExperimentalAcrylicMaterial TintColor="{DynamicResource ThemeColorKey}"
|
||||
MaterialOpacity="{ReflectionBinding Value,Source={x:Static ms:UISettings.AcrylicOpacity},Mode=OneWay}"
|
||||
TintOpacity="1"/>
|
||||
</ExperimentalAcrylicBorder.Material>
|
||||
</ExperimentalAcrylicBorder>-->
|
||||
<ExperimentalAcrylicBorder.Material>
|
||||
<ExperimentalAcrylicMaterial TintColor="{DynamicResource ThemeColorKey}"
|
||||
MaterialOpacity="{ReflectionBinding Value,Source={x:Static ms:UISettings.AcrylicOpacity},Mode=OneWay}"
|
||||
TintOpacity="1"/>
|
||||
</ExperimentalAcrylicBorder.Material>
|
||||
</ExperimentalAcrylicBorder>
|
||||
</DockPanel>
|
||||
|
||||
<!--Content-->
|
||||
@@ -72,7 +72,7 @@
|
||||
</ui:NavigationView.PaneHeader>-->
|
||||
|
||||
<ui:NavigationView.Content>
|
||||
<ui:Frame x:Name="frame" DataContext="{Binding SelectedItem}" Margin="-10 0 0 0">
|
||||
<ui:Frame x:Name="frame" DataContext="{Binding SelectedItem}">
|
||||
<ui:Frame.DataTemplates>
|
||||
<DataTemplate DataType="vm:ProxyScriptManagePageViewModel">
|
||||
<pages:ProxyScriptManagePage/>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:ms="using:System.Application.Settings"
|
||||
xmlns:converters="using:System.Application.Converters"
|
||||
xmlns:ui="using:FluentAvalonia.UI.Controls"
|
||||
xmlns:sys="using:System"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
@@ -92,6 +93,20 @@
|
||||
|
||||
<Separator Classes="Separator"/>
|
||||
|
||||
<Border Classes="Item" IsVisible="{x:Static sys:OperatingSystem2.IsWindows11AtLeast}">
|
||||
<DockPanel>
|
||||
<TextBlock Text="{ReflectionBinding Path=Res.Settings_UI_WindowTransparencyMaterial,Mode=OneWay,Source={x:Static resx:R.Current}}"/>
|
||||
|
||||
<ComboBox SelectedIndex="{Binding Source={x:Static ms:UISettings.WindowBackgroundMateria},Path=Value, Mode=TwoWay}">
|
||||
<ComboBoxItem Content="不透明" IsVisible="False"/>
|
||||
<ComboBoxItem Content="完全透明" IsVisible="False"/>
|
||||
<ComboBoxItem Content="高斯模糊" IsVisible="False"/>
|
||||
<ComboBoxItem Content="Win10 Acrylic"/>
|
||||
<ComboBoxItem Content="Win11 Mica"/>
|
||||
</ComboBox>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
|
||||
<!--<StackPanel Orientation="Vertical">
|
||||
<DockPanel>
|
||||
<TextBlock Text="使用动态桌面背景"/>
|
||||
|
||||
@@ -11,15 +11,15 @@ namespace System.Application.UI.Views.Windows
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
ExtendClientAreaToDecorationsHint = false;
|
||||
ExtendClientAreaToDecorationsHint = true;
|
||||
ExtendClientAreaTitleBarHeightHint = -1;
|
||||
TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur;
|
||||
TransparencyLevelHint = WindowTransparencyLevel.Mica;
|
||||
SystemDecorations = SystemDecorations.Full;
|
||||
ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.PreferSystemChrome;
|
||||
|
||||
if (OperatingSystem2.IsWindows10AtLeast)
|
||||
if (OperatingSystem2.IsWindows11AtLeast)
|
||||
{
|
||||
AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>().ForceNativeTitleBarToTheme(this, "Light");
|
||||
AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>().ForceNativeTitleBarToTheme(this, "Dark");
|
||||
}
|
||||
#if DEBUG
|
||||
this.AttachDevTools();
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Avalonia.Controls
|
||||
ExtendClientAreaTitleBarHeightHint = -1;
|
||||
|
||||
//}
|
||||
TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur;
|
||||
TransparencyLevelHint = (WindowTransparencyLevel)UISettings.WindowBackgroundMateria.Value;
|
||||
SystemDecorations = SystemDecorations.Full;
|
||||
|
||||
this.GetObservable(WindowStateProperty)
|
||||
@@ -58,7 +58,7 @@ namespace Avalonia.Controls
|
||||
IPlatformService.Instance.FixAvaloniaFluentWindowStyleOnWin7(PlatformImpl.Handle.Handle);
|
||||
#pragma warning restore CA1416 // 验证平台兼容性
|
||||
}
|
||||
else if (OperatingSystem2.IsWindows10AtLeast)
|
||||
else if (OperatingSystem2.IsWindows11AtLeast)
|
||||
{
|
||||
AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>().ForceNativeTitleBarToTheme(this, "Dark");
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using FluentAvalonia.Styling;
|
||||
using ReactiveUI;
|
||||
using System.Application.Models;
|
||||
using System.Application.Services;
|
||||
using System.Application.Settings;
|
||||
using System.Application.UI.ViewModels;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -25,7 +26,7 @@ namespace System.Application.UI.Views.Windows
|
||||
ExtendClientAreaTitleBarHeightHint = -1;
|
||||
ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome;
|
||||
//SystemDecorations = SystemDecorations.None;
|
||||
TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur;
|
||||
TransparencyLevelHint = (WindowTransparencyLevel)UISettings.WindowBackgroundMateria.Value;
|
||||
SizeToContent = Avalonia.Controls.SizeToContent.Height;
|
||||
CanResize = false;
|
||||
ShowInTaskbar = false;
|
||||
|
||||
@@ -16,7 +16,16 @@ namespace System.Application.Settings
|
||||
{
|
||||
Theme.ValueChanged += Theme_ValueChanged;
|
||||
AppGridSize.ValueChanged += AppGridSize_ValueChanged;
|
||||
EnableDesktopBackground.ValueChanged += EnableDesktopBackground_ValueChanged;
|
||||
|
||||
if (OperatingSystem2.IsWindows)
|
||||
{
|
||||
EnableDesktopBackground.ValueChanged += EnableDesktopBackground_ValueChanged;
|
||||
}
|
||||
|
||||
if (OperatingSystem2.IsWindows11AtLeast)
|
||||
{
|
||||
WindowBackgroundMateria.ValueChanged += WindowBackgroundMateria_ValueChanged;
|
||||
}
|
||||
|
||||
if (WindowViewModel.IsSupportedSizePosition)
|
||||
{
|
||||
@@ -24,18 +33,20 @@ namespace System.Application.Settings
|
||||
}
|
||||
}
|
||||
|
||||
static void WindowBackgroundMateria_ValueChanged(object sender, ValueChangedEventArgs<int> e)
|
||||
{
|
||||
IApplication.Instance.SetAllWindowransparencyMateria(e.NewValue);
|
||||
}
|
||||
|
||||
static void EnableDesktopBackground_ValueChanged(object? sender, ValueChangedEventArgs<bool> e)
|
||||
{
|
||||
if (OperatingSystem2.IsWindows)
|
||||
if (e.NewValue)
|
||||
{
|
||||
if (e.NewValue)
|
||||
{
|
||||
IApplication.Instance.SetDesktopBackgroundWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
INativeWindowApiService.Instance.ResetWallerpaper();
|
||||
}
|
||||
IApplication.Instance.SetDesktopBackgroundWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
INativeWindowApiService.Instance.ResetWallerpaper();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +69,8 @@ namespace System.Application.Settings
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 主题
|
||||
/// </summary>
|
||||
@@ -89,11 +102,17 @@ namespace System.Application.Settings
|
||||
= GetProperty(defaultValue: "Default", autoSave: true);
|
||||
|
||||
/// <summary>
|
||||
/// 窗口毛玻璃背景透明度
|
||||
/// 窗口背景透明度
|
||||
/// </summary>
|
||||
public static SerializableProperty<double> AcrylicOpacity { get; }
|
||||
= GetProperty(defaultValue: .8, autoSave: true);
|
||||
|
||||
/// <summary>
|
||||
/// 窗口背景材质
|
||||
/// </summary>
|
||||
public static SerializableProperty<int> WindowBackgroundMateria { get; }
|
||||
= GetProperty(defaultValue: 3, autoSave: true);
|
||||
|
||||
/// <summary>
|
||||
/// 库存游戏封面大小
|
||||
/// </summary>
|
||||
|
||||
@@ -42,5 +42,11 @@ namespace System.Application.UI
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前打开窗口的AvaloniaWinodw背景透明材质
|
||||
/// </summary>
|
||||
/// <param name="level"></param>
|
||||
void SetAllWindowransparencyMateria(int level);
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -3889,6 +3889,15 @@ namespace System.Application.UI.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 窗口背景透明材质 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Settings_UI_WindowTransparencyMaterial {
|
||||
get {
|
||||
return ResourceManager.GetString("Settings_UI_WindowTransparencyMaterial", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 退出登录 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -1566,6 +1566,9 @@
|
||||
<data name="Settings_UI_CustomBackgroundImage" xml:space="preserve">
|
||||
<value>自定义背景图片</value>
|
||||
</data>
|
||||
<data name="Settings_UI_WindowTransparencyMaterial" xml:space="preserve">
|
||||
<value>窗口背景透明材质</value>
|
||||
</data>
|
||||
<data name="Reset" xml:space="preserve">
|
||||
<value>重置</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user