diff --git a/SteamToolsV2+.sln b/SteamToolsV2+.sln index 5c5a3f632e5..40c9dc62ad0 100644 --- a/SteamToolsV2+.sln +++ b/SteamToolsV2+.sln @@ -1391,6 +1391,7 @@ Global {3763D6C4-82B7-4C13-9BB8-886FC1BD83B6} = {8E38AAF2-8C7D-4B0D-AB25-AB37EECB4029} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution + RESX_NeutralResourcesLanguage = zh-Hans SolutionGuid = {9313F2B4-10DA-43AA-A481-CAA7571C740C} EndGlobalSection EndGlobal diff --git a/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs b/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs index 2f568b5ed6f..a6f95b07c1b 100644 --- a/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia.App/App.axaml.cs @@ -28,6 +28,7 @@ using FluentAvalonia.Styling; using Avalonia.Media; using System.Reactive.Disposables; +using System.Application.UI.Views.Controls; #if WINDOWS //using WpfApplication = System.Windows.Application; #endif @@ -491,6 +492,17 @@ public void SetAllWindowransparencyMateria(int level) foreach (var window in desktop.Windows) { window.TransparencyLevelHint = (WindowTransparencyLevel)level; + + if (window.TransparencyLevelHint == WindowTransparencyLevel.Transparent || + window.TransparencyLevelHint == WindowTransparencyLevel.None || + window.TransparencyLevelHint == WindowTransparencyLevel.Blur) + { + ((IPseudoClasses)window.Classes).Set(":transparent", true); + } + else + { + ((IPseudoClasses)window.Classes).Set(":transparent", false); + } } } } diff --git a/src/ST.Client.Desktop.Avalonia.App/Views/MainWindow.axaml b/src/ST.Client.Desktop.Avalonia.App/Views/MainWindow.axaml index 817949f7305..9af8d7bcf83 100644 --- a/src/ST.Client.Desktop.Avalonia.App/Views/MainWindow.axaml +++ b/src/ST.Client.Desktop.Avalonia.App/Views/MainWindow.axaml @@ -17,18 +17,9 @@ Topmost="{Binding Topmost}" x:DataType="vm:MainWindowViewModel" x:CompileBindings="True"> - - - - + diff --git a/src/ST.Client.Desktop.Avalonia.App/Views/MainWindow.axaml.cs b/src/ST.Client.Desktop.Avalonia.App/Views/MainWindow.axaml.cs index d1ca021176c..47e6cb9aa67 100644 --- a/src/ST.Client.Desktop.Avalonia.App/Views/MainWindow.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia.App/Views/MainWindow.axaml.cs @@ -21,13 +21,9 @@ public MainWindow() : base() { InitializeComponent(); - //var background = this.FindControl("DesktopBackground"); - //_backHandle = background.Handle; + var background = this.FindControl("DesktopBackground"); + _backHandle = background.Handle; - //if (OperatingSystem2.IsWindows && !OperatingSystem2.IsWindows11AtLeast) - //{ - // TransparencyLevelHint = WindowTransparencyLevel.Transparent; - //} #if DEBUG this.AttachDevTools(); #endif @@ -35,12 +31,13 @@ public MainWindow() : base() StartupTrace.Restart("MainWindow.ctor"); #endif } + protected override void OnClosing(CancelEventArgs e) { #if !UI_DEMO if (StartupOptions.Value.HasNotifyIcon) { - _isOpenWindow = false; + IsHideWindow = true; e.Cancel = true; Hide(); @@ -49,7 +46,7 @@ protected override void OnClosing(CancelEventArgs e) tab.Deactivation(); } #endif - base.OnClosed(e); + base.OnClosing(e); } protected override void FluentWindow_Opened(object? sender, EventArgs e) diff --git a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/AvaloniaWin32WindowingPlatformImpl.cs b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/AvaloniaWin32WindowingPlatformImpl.cs index 85f64fdc2b2..a175aab187b 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/AvaloniaWin32WindowingPlatformImpl.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/Services/Implementation/AvaloniaWin32WindowingPlatformImpl.cs @@ -98,7 +98,9 @@ protected override IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr l // I retain the SystemBorder & ability resize the window in the transparent // area over the drop shadows, meaning resize handles don't overlap the window - if (wParam != IntPtr.Zero && _owner?.Window.CanResize == true) + if (wParam != IntPtr.Zero && + _owner?.Window.CanResize == true && + _owner?.IsHideWindow == false) { var ncParams = Marshal.PtrToStructure(lParam); @@ -115,6 +117,8 @@ protected override IntPtr WndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr l WindowState == WindowState.FullScreen) { //newSize.top += GetResizeHandleHeight(); + + _owner.IsNewSizeWindow = false; } else { @@ -217,8 +221,9 @@ private void EnsureExtended() var marg = new Win32Interop.MARGINS(); // WS_OVERLAPPEDWINDOW - // 0x00C00000L 会导致标题栏有奇怪的白边 - var style = 0x00000000L | 0x00080000L | 0x00040000L | 0x00020000L | 0x00010000L; + // 0x00C00000L 0x00080000L 不需要标题栏 + // 0x00040000L 创建一个具有粗框的窗口可以用来调整窗口的大小 + var style = 0x00000000L | 0X00800000L | 0x00020000L | 0x00010000L; // This is causing the window to appear solid but is completely transparent. Weird... //Win32Interop.GetWindowLongPtr(Hwnd, -16).ToInt32(); diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Styles/DrawingSvg.xaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Styles/DrawingSvg.xaml index 24e69341523..093199b555d 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Styles/DrawingSvg.xaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Styles/DrawingSvg.xaml @@ -61,8 +61,9 @@ M7 7.5C7 4.42386 9.42386 2 12.5 2C15.5761 2 18 4.42386 18 7.5C18 10.5761 15.5761 13 12.5 13C12.0069 13 11.4935 12.9536 11 12.8199V13C11 13.5523 10.5523 14 10 14H9V15C9 15.5523 8.55228 16 8 16H7V16.5C7 17.3284 6.32843 18 5.5 18H3.5C2.67157 18 2 17.3284 2 16.5V14.9142C2 14.5164 2.15804 14.1349 2.43934 13.8536L6.98018 9.31271C7.11378 9.17912 7.17968 8.94454 7.12154 8.67456C7.04001 8.29598 7 7.89668 7 7.5ZM15 6C15 5.44772 14.5523 5 14 5C13.4477 5 13 5.44772 13 6C13 6.55228 13.4477 7 14 7C14.5523 7 15 6.55228 15 6Z - - M10 2C14.4183 2 18 5.58172 18 10C18 14.4183 14.4183 18 10 18C5.58172 18 2 14.4183 2 10C2 5.58172 5.58172 2 10 2ZM10 3C6.13401 3 3 6.13401 3 10C3 13.866 6.13401 17 10 17C13.866 17 17 13.866 17 10C17 6.13401 13.866 3 10 3ZM6.5 9.5H13.5C13.7761 9.5 14 9.72386 14 10C14 10.2455 13.8231 10.4496 13.5899 10.4919L13.5 10.5H6.5C6.22386 10.5 6 10.2761 6 10C6 9.75454 6.17688 9.55039 6.41012 9.50806L6.5 9.5H13.5H6.5Z + + M704 107.136a448 448 0 1 1-384 0v72.256a384 384 0 1 0 384 0z + M480 96V512a32 32 0 0 0 64 0V96a32 32 0 0 0-64 0z diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Styles/Settings.xaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Styles/Settings.xaml index 19059b09e7b..d7fef86fe32 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Styles/Settings.xaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Styles/Settings.xaml @@ -187,13 +187,14 @@ - + + + + + diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/EmptyControl.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/EmptyControl.cs index 9aa7e9fb4c6..77352ec0b29 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/EmptyControl.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/EmptyControl.cs @@ -13,79 +13,116 @@ public class EmptyControl : TemplatedControl readonly INativeWindowApiService windowApiService = INativeWindowApiService.Instance; Window window; - Window Parent; + Window ParentWindow; IntPtr _Handle; + IntPtr _DwmHandle; public EmptyControl() { //this.InitializeComponent(); - this.GetObservable(IsVisibleProperty) - .Subscribe(x => - { - if (x) + if (OperatingSystem2.IsWindows) + { + this.GetObservable(IsVisibleProperty) + .Subscribe(x => { - if (window == null) + if (x) { - this.LayoutUpdated += EmptyControl_LayoutUpdated; - this.AttachedToVisualTree += EmptyControl_AttachedToVisualTree; - this.DetachedFromVisualTree += EmptyControl_DetachedFromVisualTree; - window = new Window + if (window == null) { - Width = this.Bounds.Width, - Height = this.Bounds.Height, - Background = Avalonia.Media.Brushes.Transparent, - WindowStartupLocation = WindowStartupLocation.Manual, - WindowState = WindowState.Normal, - ExtendClientAreaToDecorationsHint = true, - ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.PreferSystemChrome, - SystemDecorations = SystemDecorations.Full, - CanResize = false, - TransparencyLevelHint = WindowTransparencyLevel.Transparent, - ShowInTaskbar = false, - Focusable = false - }; - if (Parent != null && VisualRoot != null) - EmptyControl_AttachedToVisualTree(null, new VisualTreeAttachmentEventArgs(Parent, VisualRoot)); + this.LayoutUpdated += EmptyControl_LayoutUpdated; + this.AttachedToVisualTree += EmptyControl_AttachedToVisualTree; + this.DetachedFromVisualTree += EmptyControl_DetachedFromVisualTree; + window = new Window + { + Width = this.Bounds.Width, + Height = this.Bounds.Height, + Background = null, + WindowStartupLocation = WindowStartupLocation.Manual, + WindowState = WindowState.Normal, + ExtendClientAreaToDecorationsHint = true, + ExtendClientAreaTitleBarHeightHint = -1, + ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome, + SystemDecorations = SystemDecorations.Full, + CanResize = false, + TransparencyLevelHint = WindowTransparencyLevel.Transparent, + ShowInTaskbar = false, + Topmost = false, + Focusable = false, + IsEnabled = false, + ShowActivated = false, + IsTabStop = false, + IsHitTestVisible = false, + }; + window.GotFocus += Window_GotFocus; + if (Parent != null && VisualRoot != null) + EmptyControl_AttachedToVisualTree(null, new VisualTreeAttachmentEventArgs(Parent, VisualRoot)); + } } - } - else - { - if (window != null) + else { - if (Parent != null && VisualRoot != null) - EmptyControl_DetachedFromVisualTree(null, new VisualTreeAttachmentEventArgs(Parent, VisualRoot)); - this.LayoutUpdated -= EmptyControl_LayoutUpdated; - this.AttachedToVisualTree -= EmptyControl_AttachedToVisualTree; - this.DetachedFromVisualTree -= EmptyControl_DetachedFromVisualTree; - window = null; + if (window != null) + { + if (Parent != null && VisualRoot != null) + EmptyControl_DetachedFromVisualTree(null, new VisualTreeAttachmentEventArgs(Parent, VisualRoot)); + this.LayoutUpdated -= EmptyControl_LayoutUpdated; + this.AttachedToVisualTree -= EmptyControl_AttachedToVisualTree; + this.DetachedFromVisualTree -= EmptyControl_DetachedFromVisualTree; + window = null; + } } - } - }); + }); + } + } + + private void Window_GotFocus(object? sender, Avalonia.Input.GotFocusEventArgs e) + { + ParentWindow.Focus(); } private void EmptyControl_DetachedFromVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { - if (OperatingSystem2.IsWindows && UISettings.EnableDesktopBackground.Value) - { - windowApiService.ReleaseBackground(_Handle); - Parent.PositionChanged -= Parent_PositionChanged; - Close(); - } + windowApiService.ReleaseBackground(_DwmHandle); + ParentWindow.PositionChanged -= Parent_PositionChanged; + ParentWindow.Closing -= ParentWindow_Closing; + ParentWindow.GotFocus -= ParentWindow_GotFocus; + Close(); } private void EmptyControl_AttachedToVisualTree(object? sender, VisualTreeAttachmentEventArgs e) { - if (OperatingSystem2.IsWindows && UISettings.EnableDesktopBackground.Value) - { + ParentWindow = (Window)e.Root; + ParentWindow.Topmost = true; + Show(); + ParentWindow.Topmost = false; + ParentWindow.PositionChanged += Parent_PositionChanged; + ParentWindow.Closing += ParentWindow_Closing; + ParentWindow.GotFocus += ParentWindow_GotFocus; + ParentWindow.Opened += ParentWindow_Opened; + _Handle = window.PlatformImpl.Handle.Handle; + windowApiService.SetWindowPenetrate(_Handle); + //windowApiService.SetParentWindow(_Handle, ParentWindow.PlatformImpl.Handle.Handle); + _DwmHandle = windowApiService.SetDesktopBackgroundToWindow( + _Handle, (int)window.Width, (int)window.Height); + } + + private void ParentWindow_Opened(object? sender, EventArgs e) + { + if (window != null) Show(); - Parent = (Window)e.Root; - Parent.PositionChanged += Parent_PositionChanged; - _Handle = Handle; - _Handle = windowApiService.SetDesktopBackgroundToWindow( - _Handle, (int)window.Width, (int)window.Height); + } - windowApiService.SetWindowPenetrate(Handle); - } + private void ParentWindow_GotFocus(object? sender, Avalonia.Input.GotFocusEventArgs e) + { + window.Topmost = true; + window.Topmost = false; + ParentWindow.Topmost = true; + ParentWindow.Topmost = false; + } + + private void ParentWindow_Closing(object? sender, ComponentModel.CancelEventArgs e) + { + if (window != null) + window.Hide(); } private void Parent_PositionChanged(object? sender, PixelPointEventArgs e) @@ -95,13 +132,10 @@ private void Parent_PositionChanged(object? sender, PixelPointEventArgs e) private void EmptyControl_LayoutUpdated(object? sender, System.EventArgs e) { - if (OperatingSystem2.IsWindows && UISettings.EnableDesktopBackground.Value) - { - window.Position = this.PointToScreen(this.Bounds.Position); - window.Width = this.Bounds.Width; - window.Height = this.Bounds.Height; - windowApiService.BackgroundUpdate(_Handle, (int)window.Width, (int)window.Height); - } + window.Position = this.PointToScreen(this.Bounds.Position); + window.Width = this.Bounds.Width; + window.Height = this.Bounds.Height; + windowApiService.BackgroundUpdate(_DwmHandle, (int)window.Width, (int)window.Height); //NativeMethods.SetWindowPos(HWND, NativeMethods.HWND_TOPMOST, window.Position.X, window.Position.Y, (int)window.Width, (int)window.Height, 0); } @@ -118,7 +152,7 @@ public void Show() public IntPtr Handle { - get { return window.PlatformImpl.Handle.Handle; } + get { return _Handle; } } public void Close() diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/TitleBar.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/TitleBar.axaml index 3e6413d666e..bb92c94cd8e 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/TitleBar.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Controls/TitleBar.axaml @@ -7,15 +7,14 @@ mc:Ignorable="d" x:Name="u" IsHitTestVisible="False" - Background="Transparent" x:Class="System.Application.UI.Views.Controls.TitleBar"> + + + - - - @@ -28,29 +27,30 @@ Opacity="0.8"> --> - - + - + x:Name="Back"> - + - - ("Back"); + this.GetObservable(IsVisibleBackgroundProperty) .Subscribe(x => back.IsVisible = x); } diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml index 769294d519c..f38ab144a9e 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml @@ -17,35 +17,30 @@ x:CompileBindings="True"> - + - + + TintOpacity="1" + MaterialOpacity="{ReflectionBinding Value,Source={x:Static ms:UISettings.AcrylicOpacity},Mode=OneWay}"/> - + + TintOpacity="1" + MaterialOpacity="{ReflectionBinding Value,Source={x:Static ms:UISettings.AcrylicOpacity},Mode=OneWay}"/> - diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml.cs index 0de331ea96b..26938e3d288 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/MainView.axaml.cs @@ -8,7 +8,9 @@ using Avalonia.ReactiveUI; using FluentAvalonia.UI.Controls; using FluentAvalonia.UI.Media.Animation; +using System.Application.Settings; using System.Application.UI.ViewModels; +using System.Application.UI.Views.Controls; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; @@ -17,17 +19,12 @@ namespace System.Application.UI.Views { public class MainView : ReactiveUserControl { + private readonly IBrush? _backgroundTemp; + public MainView() { InitializeComponent(); - //var sp = this.FindControl("titleMenu"); - //if (sp != null) - // if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - // sp.Margin = new Avalonia.Thickness(0, 0, 140, 0); - // else - // sp.Margin = new Avalonia.Thickness(0, 6, 10, 0); - var avatar = this.FindControl("avatar"); var nav = this.FindControl("NavigationView"); var back = this.FindControl("NavBarBackground"); @@ -98,6 +95,28 @@ public MainView() } }); } + + //UISettings.EnableDesktopBackground.Subscribe(x => + //{ + // Background = x ? null : _BackGroundTemp; + //}); + + var title = this.FindControl("title"); + if (title != null) + { + _backgroundTemp = title.Background; + UISettings.EnableDesktopBackground.Subscribe(x => + { + var t = (WindowTransparencyLevel)UISettings.WindowBackgroundMateria.Value; + if (t == WindowTransparencyLevel.Transparent) + { + title.Background = x ? null : _backgroundTemp; + if (x) + UISettings.EnableCustomBackgroundImage.Value = x; + } + + }); + } } private void InitializeComponent() diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/ArchiSteamFarmPlus/ASF_BotPage.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/ArchiSteamFarmPlus/ASF_BotPage.axaml index e39608673e0..d21a728336b 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/ArchiSteamFarmPlus/ASF_BotPage.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/ArchiSteamFarmPlus/ASF_BotPage.axaml @@ -157,26 +157,37 @@ CommandParameter="{Binding}"> - - diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/ArchiSteamFarmPlus/ArchiSteamFarmPlusPage.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/ArchiSteamFarmPlus/ArchiSteamFarmPlusPage.axaml index 68b8c8957d2..9a54eff1e01 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/ArchiSteamFarmPlus/ArchiSteamFarmPlusPage.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/ArchiSteamFarmPlus/ArchiSteamFarmPlusPage.axaml @@ -19,7 +19,6 @@ x:CompileBindings="True" x:Class="System.Application.UI.Views.Pages.ArchiSteamFarmPlusPage"> - + Label="刷新Bot"> diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/Settings/Settings_UI.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/Settings/Settings_UI.axaml index fbc77c860f1..021cab4317b 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/Settings/Settings_UI.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Pages/Settings/Settings_UI.axaml @@ -101,25 +101,30 @@ - + - + - - + + + + + + - + diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/DebugWindow.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/DebugWindow.axaml index 0edb479e2bd..be3512fc0f1 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/DebugWindow.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/DebugWindow.axaml @@ -5,6 +5,7 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="System.Application.UI.Views.Windows.DebugWindow" Background="{x:Null}" + CanResize="False" Title="DebugWindow"> Welcome to Avalonia! diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/DebugWindow.axaml.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/DebugWindow.axaml.cs index 19645712636..7f8a23e3958 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/DebugWindow.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/DebugWindow.axaml.cs @@ -13,7 +13,7 @@ public DebugWindow() ExtendClientAreaToDecorationsHint = true; ExtendClientAreaTitleBarHeightHint = -1; - TransparencyLevelHint = WindowTransparencyLevel.Mica; + TransparencyLevelHint = WindowTransparencyLevel.Transparent; SystemDecorations = SystemDecorations.Full; ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.PreferSystemChrome; diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/LocalAuthPage/AddAuthWindow.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/LocalAuthPage/AddAuthWindow.axaml index 198ae8a6e58..7e8f27083f8 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/LocalAuthPage/AddAuthWindow.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/LocalAuthPage/AddAuthWindow.axaml @@ -21,22 +21,7 @@ Title="{Binding Title}"> - + diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/MessageBoxWindow.axaml b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/MessageBoxWindow.axaml index b973cde41b2..d75fac7df45 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/MessageBoxWindow.axaml +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/MessageBoxWindow.axaml @@ -26,16 +26,7 @@ - - + - + - + diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/TaskBarWindow.axaml.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/TaskBarWindow.axaml.cs index 80d11603280..560c96e5201 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/TaskBarWindow.axaml.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/TaskBarWindow.axaml.cs @@ -20,17 +20,23 @@ public partial class TaskBarWindow : ReactiveWindow public TaskBarWindow() { InitializeComponent(); - Topmost = true; - + + TransparencyLevelHint = (WindowTransparencyLevel)UISettings.WindowBackgroundMateria.Value; + + if (TransparencyLevelHint == WindowTransparencyLevel.Transparent || + TransparencyLevelHint == WindowTransparencyLevel.None || + TransparencyLevelHint == WindowTransparencyLevel.Blur) + { + TransparencyLevelHint = WindowTransparencyLevel.AcrylicBlur; + } + ExtendClientAreaToDecorationsHint = true; ExtendClientAreaTitleBarHeightHint = -1; ExtendClientAreaChromeHints = Avalonia.Platform.ExtendClientAreaChromeHints.NoChrome; SystemDecorations = SystemDecorations.Full; - TransparencyLevelHint = (WindowTransparencyLevel)UISettings.WindowBackgroundMateria.Value; SizeToContent = Avalonia.Controls.SizeToContent.Height; - CanResize = false; - ShowInTaskbar = false; + //Initialized += Window_Opened; Opened += Window_Opened; LostFocus += Window_LostFocus; @@ -122,6 +128,8 @@ private void Window_Opened(object? sender, EventArgs e) { Position = new PixelPoint(x.Item1, heightPoint); } + Topmost = false; + Topmost = true; }); } diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WindowBase/FluentWindow.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WindowBase/FluentWindow.cs index b20c1afe45a..89aa687bddc 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WindowBase/FluentWindow.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WindowBase/FluentWindow.cs @@ -42,12 +42,22 @@ public FluentWindow(bool isSaveStatus) } } } - //if (OperatingSystem2.IsWindows) - //{ + + TransparencyLevelHint = (WindowTransparencyLevel)UISettings.WindowBackgroundMateria.Value; + + if (TransparencyLevelHint == WindowTransparencyLevel.Transparent || + TransparencyLevelHint == WindowTransparencyLevel.None || + TransparencyLevelHint == WindowTransparencyLevel.Blur) + { + PseudoClasses.Set(":transparent", true); + } + else + { + PseudoClasses.Set(":transparent", false); + } + ExtendClientAreaToDecorationsHint = true; ExtendClientAreaTitleBarHeightHint = -1; - //} - TransparencyLevelHint = (WindowTransparencyLevel)UISettings.WindowBackgroundMateria.Value; SystemDecorations = SystemDecorations.Full; this.GetObservable(WindowStateProperty) @@ -106,7 +116,7 @@ public FluentWindow(bool isSaveStatus) private void FluentWindow_PositionChanged(object? sender, PixelPointEventArgs e) { - if (_isOpenWindow == false) + if (IsHideWindow) return; if (DataContext is WindowViewModel vm) { @@ -115,10 +125,8 @@ private void FluentWindow_PositionChanged(object? sender, PixelPointEventArgs e) } } - protected bool _isOpenWindow; protected virtual void FluentWindow_Opened(object? sender, EventArgs e) { - _isOpenWindow = true; if (DataContext is WindowViewModel vm) { if (vm.SizePosition.X > 0 && vm.SizePosition.Y > 0) @@ -132,43 +140,34 @@ protected virtual void FluentWindow_Opened(object? sender, EventArgs e) } } - if (CanResize) + if (CanResize && !IsHideWindow) { if (vm.SizePosition.Width > 0 && Screens.Primary.WorkingArea.Width >= vm.SizePosition.Width) - Width = vm.SizePosition.Width + (((ICoreWindow)this).IsNewSizeWindow ? 16 : 0); + Width = vm.SizePosition.Width; if (vm.SizePosition.Height > 0 && Screens.Primary.WorkingArea.Height >= vm.SizePosition.Height) - Height = vm.SizePosition.Height + (((ICoreWindow)this).IsNewSizeWindow ? 8 : 0); + Height = vm.SizePosition.Height; HandleResized(new Size(Width, Height), PlatformResizeReason.Application); - this.WhenAnyValue(x => x.ClientSize) .Subscribe(x => { - vm.SizePosition.Width = x.Width; - vm.SizePosition.Height = x.Height; + vm.SizePosition.Width = x.Width + (IsNewSizeWindow ? 16 : 0); + vm.SizePosition.Height = x.Height + (IsNewSizeWindow ? 8 : 0); }); } - - - - //this.GetObservable(WidthProperty).Subscribe(v => - //{ - // vm.SizePosition.Width = v; - //}); - //this.GetObservable(HeightProperty).Subscribe(v => - //{ - // vm.SizePosition.Height = v; - //}); } + + IsHideWindow = false; } protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); + _systemCaptionButtons = e.NameScope.Find("SystemCaptionButtons"); if (_systemCaptionButtons != null) { @@ -196,8 +195,9 @@ protected override void OnClosed(EventArgs e) MinMaxCloseControl? ICoreWindow.SystemCaptionButtons => _systemCaptionButtons; - bool ICoreWindow.IsNewSizeWindow { get; set; } + public bool IsNewSizeWindow { get; set; } + public bool IsHideWindow { get; set; } #endregion } diff --git a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WindowBase/ICoreWindow.cs b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WindowBase/ICoreWindow.cs index c048060bbff..1505e3a629e 100644 --- a/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WindowBase/ICoreWindow.cs +++ b/src/ST.Client.Desktop.Avalonia/Application/UI/Views/Windows/WindowBase/ICoreWindow.cs @@ -18,7 +18,9 @@ internal partial interface ICoreWindow { Window Window { get; } - bool IsNewSizeWindow { get; set; } + public bool IsNewSizeWindow { get; set; } + + public bool IsHideWindow { get; set; } MinMaxCloseControl? SystemCaptionButtons { get; } diff --git a/src/ST.Client.Desktop.Windows/Internals/MouseHook.cs b/src/ST.Client.Desktop.Windows/Internals/MouseHook.cs index c060837b0df..590a2b1d00d 100644 --- a/src/ST.Client.Desktop.Windows/Internals/MouseHook.cs +++ b/src/ST.Client.Desktop.Windows/Internals/MouseHook.cs @@ -120,8 +120,8 @@ struct MSLLHOOKSTRUCT public const uint OCR_HAND = 32649; [DllImport(User32Window.LibraryName, CharSet = CharSet.Auto)] - public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, - IntPtr pvParam, uint fWinIni); + public static extern bool SystemParametersInfo(uint uAction, uint uParam, + IntPtr lpvParam, uint init); public enum SystemParametersDesktopInfo : uint { diff --git a/src/ST.Client.Desktop.Windows/Internals/User32Window.cs b/src/ST.Client.Desktop.Windows/Internals/User32Window.cs index 0157d6e4a21..09992ca51a3 100644 --- a/src/ST.Client.Desktop.Windows/Internals/User32Window.cs +++ b/src/ST.Client.Desktop.Windows/Internals/User32Window.cs @@ -171,6 +171,9 @@ int nMaxCount //最大值 [DllImport(LibraryName, ExactSpelling = true)] public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); + [DllImport(LibraryName, CharSet = CharSet.Auto)] + public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, UnmanagedMethods.SetWindowPosFlags uFlags); + //[DllImport(LibraryName, ExactSpelling = true)] //public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool bRepaint); diff --git a/src/ST.Client.Desktop.Windows/Services/Implementation/NativeWindowApiServiceImpl.cs b/src/ST.Client.Desktop.Windows/Services/Implementation/NativeWindowApiServiceImpl.cs index 120d067eedd..25b379dc908 100644 --- a/src/ST.Client.Desktop.Windows/Services/Implementation/NativeWindowApiServiceImpl.cs +++ b/src/ST.Client.Desktop.Windows/Services/Implementation/NativeWindowApiServiceImpl.cs @@ -4,6 +4,7 @@ using System.Runtime.Versioning; using System.Text; using System.Windows; +using static UnmanagedMethods; namespace System.Application.Services.Implementation { @@ -144,7 +145,7 @@ public void ToWallerpaperWindow(NativeWindowModel window) } return true; }), IntPtr.Zero); - User32Window.SetParent(window.Handle, workerw); + SetParentWindow(window.Handle, workerw); int p1 = User32Window.GetWindowLongA(window.Handle, (int)WindowLongFlags.GWL_STYLE); @@ -160,6 +161,15 @@ public void ToWallerpaperWindow(NativeWindowModel window) } } + public string? GetWallerpaperImagePath() + { + IntPtr p = IntPtr.Zero; + MouseHook.SystemParametersInfo((uint)MouseHook.SystemParametersDesktopInfo.SPI_GETDESKWALLPAPER, 300, p, (uint)MouseHook.SystemParamtersInfoFlags.None); + var result = Marshal.PtrToStringAuto(p); //默认桌面路径 + Marshal.FreeHGlobal(p); + return result; + } + public void ResetWallerpaper() { //string result = string.Empty; @@ -167,7 +177,13 @@ public void ResetWallerpaper() MouseHook.SystemParametersInfo((uint)MouseHook.SystemParametersDesktopInfo.SPI_GETDESKWALLPAPER, 300, p, (uint)MouseHook.SystemParamtersInfoFlags.None); //result = Marshal.PtrToStringAuto(p); //默认桌面路径 MouseHook.SystemParametersInfo((uint)MouseHook.SystemParametersDesktopInfo.SPI_SETDESKWALLPAPER, 1, p, (uint)MouseHook.SystemParamtersInfoFlags.SPIF_UPDATEINIFILE | (uint)MouseHook.SystemParamtersInfoFlags.SPIF_SENDWININICHANGE); - //Marshal.FreeHGlobal(p); + Marshal.FreeHGlobal(p); + } + + public void SetParentWindow(IntPtr source, IntPtr dest) + { + User32Window.SetParent(source, dest); + //User32Window.SetWindowLong(source, (int)WindowLongParam.GWL_HWNDPARENT, (int)dest); } /// @@ -188,7 +204,8 @@ public void SetWindowPenetrate(IntPtr dest) { int style = User32Window.GetWindowLongA(dest, (int)WindowLongFlags.GWL_EXSTYLE); User32Window.SetWindowLong(dest, (int)WindowLongFlags.GWL_EXSTYLE, style | (int)UnmanagedMethods.WindowStyles.WS_EX_TRANSPARENT | (int)UnmanagedMethods.WindowStyles.WS_EX_LAYERED); - User32Window.SetLayeredWindowAttributes(dest, 0, 100, 0); + User32Window.SetLayeredWindowAttributes(dest, 0, 255, 0x2); + //User32Window.SetLayeredWindowAttributes(dest, 0, 100, 0); } /// @@ -228,6 +245,8 @@ public IntPtr SetDesktopBackgroundToWindow(IntPtr dest, int width, int height) // backgroundPath = Marshal.PtrToStringAuto(r); //默认桌面路径 // return; //} + //User32Window.SetWindowPos(dest, HWND_BOTTOM, 0, 0, 0, 0, + // SetWindowPosFlags.SWP_NOSIZE | SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_SHOWWINDOW); IntPtr p = User32Window.FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Progman", null); @@ -237,7 +256,6 @@ public IntPtr SetDesktopBackgroundToWindow(IntPtr dest, int width, int height) if (temp == 0) BackgroundUpdate(dest, width, height); - return dest; } diff --git a/src/ST.Client/Services/INativeWindowApiService.cs b/src/ST.Client/Services/INativeWindowApiService.cs index 6d87132200a..5c3d0c19cee 100644 --- a/src/ST.Client/Services/INativeWindowApiService.cs +++ b/src/ST.Client/Services/INativeWindowApiService.cs @@ -52,11 +52,19 @@ public interface INativeWindowApiService void ToWallerpaperWindow(NativeWindowModel window); /// - /// 刷新壁纸 + /// 获取桌面壁纸图片路径 + /// + /// + string? GetWallerpaperImagePath(); + + /// + /// 刷新桌面壁纸 /// /// void ResetWallerpaper(); + void SetParentWindow(IntPtr source, IntPtr dest); + void SetActiveWindow(NativeWindowModel window); /// diff --git a/src/ST.Client/UI/Resx/AppResources.Designer.cs b/src/ST.Client/UI/Resx/AppResources.Designer.cs index 9bb3ae868cb..4baaeb1a0b2 100644 --- a/src/ST.Client/UI/Resx/AppResources.Designer.cs +++ b/src/ST.Client/UI/Resx/AppResources.Designer.cs @@ -3916,6 +3916,25 @@ public static string Settings_UI_Dark { } } + /// + /// 查找类似 使用动态桌面背景 的本地化字符串。 + /// + public static string Settings_UI_EnableDesktopBackground { + get { + return ResourceManager.GetString("Settings_UI_EnableDesktopBackground", resourceCulture); + } + } + + /// + /// 查找类似 *实验性功能(开启此功能时建议将透明材质设置为Transparent或AcrylicBlur) + ///这个功能可以将 Wallpaper Engine 以及其它壁纸软件的动态壁纸设置为程序背景,如果你没有启动 Wallpaper Engine ,则默认使用桌面背景。该效果只在主窗口生效,其它窗口会默认使用图片背景。 的本地化字符串。 + /// + public static string Settings_UI_EnableDesktopBackground_Tip { + get { + return ResourceManager.GetString("Settings_UI_EnableDesktopBackground_Tip", resourceCulture); + } + } + /// /// 查找类似 启用圆角界面 的本地化字符串。 /// diff --git a/src/ST.Client/UI/Resx/AppResources.resx b/src/ST.Client/UI/Resx/AppResources.resx index 0f5106ab75a..a61da92ea96 100644 --- a/src/ST.Client/UI/Resx/AppResources.resx +++ b/src/ST.Client/UI/Resx/AppResources.resx @@ -1121,6 +1121,13 @@ 背景透明度 + + 使用动态桌面背景 + + + *实验性功能(开启此功能时建议将透明材质设置为Transparent或AcrylicBlur) +这个功能可以将 Wallpaper Engine 以及其它壁纸软件的动态壁纸设置为程序背景,如果你没有启动 Wallpaper Engine ,则默认使用桌面背景。该效果只在主窗口生效,其它窗口会默认使用图片背景。 + 深色 diff --git a/src/ST.Client/UI/ViewModels/Pages/ArchiSteamFarmPlus/ArchiSteamFarmPlusPageViewModel.cs b/src/ST.Client/UI/ViewModels/Pages/ArchiSteamFarmPlus/ArchiSteamFarmPlusPageViewModel.cs index 8e72830221a..321f16e94bc 100644 --- a/src/ST.Client/UI/ViewModels/Pages/ArchiSteamFarmPlus/ArchiSteamFarmPlusPageViewModel.cs +++ b/src/ST.Client/UI/ViewModels/Pages/ArchiSteamFarmPlus/ArchiSteamFarmPlusPageViewModel.cs @@ -109,11 +109,6 @@ public async void RedeemKeyBot(Bot bot) public void GoToBotSettings(Bot bot) { - if (!ASFService.Current.IsASFRuning) - { - Toast.Show("请先运行ASF功能"); - return; - } Browser2.Open(IPCUrl + "/bot/" + bot.BotName); } diff --git a/src/ST.Client/UI/ViewModels/Pages/Settings/SettingsPageViewModel.cs b/src/ST.Client/UI/ViewModels/Pages/Settings/SettingsPageViewModel.cs index 8a8ff059802..8990c684a3c 100644 --- a/src/ST.Client/UI/ViewModels/Pages/Settings/SettingsPageViewModel.cs +++ b/src/ST.Client/UI/ViewModels/Pages/Settings/SettingsPageViewModel.cs @@ -50,6 +50,7 @@ public SettingsPageViewModel() }); ResetImage_Click = ReactiveCommand.Create(() => SetBackgroundImagePath(null)); + } public static SettingsPageViewModel Instance { get; } = new();