From 49cd9d03422e63e990b44cc672c0167a4e28f662 Mon Sep 17 00:00:00 2001 From: rmbgame Date: Mon, 8 Mar 2021 17:42:26 +0800 Subject: [PATCH] message result sync --- .../App.axaml.cs | 13 ++++- .../Views/MainWindow.axaml | 1 + .../MessageWindowServiceImpl.cs | 21 +++++--- .../UI/Controls/ToastMessage.axaml | 2 +- .../Application/UI/Styles/Controls.xaml | 1 + .../Application/UI/Windows}/FluentWindow.cs | 0 .../UI/Windows/LoginWindow.axaml.cs | 2 +- .../UI/Windows/MessageWindow.axaml | 52 +++++++++++++------ .../UI/Windows/MessageWindow.axaml.cs | 2 +- .../Services/IDesktopAppService.cs | 5 +- .../Services/IMessageWindowService.cs | 2 + .../UI/ViewModels/Pages/DebugPageViewModel.cs | 13 ++++- .../Windows/MessageWindowViewModel.cs | 24 +++++++-- .../Views/Window/MessageDialog.xaml | 3 -- 14 files changed, 101 insertions(+), 40 deletions(-) rename {System.Application.SteamTools.Client.Desktop.Avalonia.App => System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows}/FluentWindow.cs (100%) diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs b/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs index 320df52cc..7f3c4f844 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs +++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs @@ -22,6 +22,7 @@ using System.Linq; using System.Application.Models.Settings; using System.Application.UI.Resx; using System.Application.Models; +using System.Threading.Tasks; #if WINDOWS using System.Windows.Shell; using WpfApplication = System.Windows.Application; @@ -239,11 +240,19 @@ namespace System.Application.UI } } - public void ShowChildWindow(object window) + public async Task ShowChildWindow(object window) { if (window is Window w) { - w.ShowDialog(MainWindow); + await w.ShowDialog(MainWindow); + } + } + + public void ShowWindow(object window) + { + if (window is Window w) + { + w.Show(MainWindow); } } diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Views/MainWindow.axaml b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Views/MainWindow.axaml index 7fe7eb8a4..b22c87012 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Views/MainWindow.axaml +++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Views/MainWindow.axaml @@ -11,6 +11,7 @@ x:Class="System.Application.UI.Views.MainWindow" x:Name="MainWindow" WindowStartupLocation="CenterScreen" + ExtendClientAreaTitleBarHeightHint="50" Background="{x:Null}" Title="{Binding Title,Mode=OneWay}" Topmost="{Binding Topmost}"> diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia/Application/Services/Implementation/MessageWindowServiceImpl.cs b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/Services/Implementation/MessageWindowServiceImpl.cs index 154feb371..a219328f2 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia/Application/Services/Implementation/MessageWindowServiceImpl.cs +++ b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/Services/Implementation/MessageWindowServiceImpl.cs @@ -20,22 +20,29 @@ namespace System.Application.Services.Implementation return ShowDialog(messageBoxText, caption, false); } - public Task ShowDialog(string messageBoxText, string caption, bool isCancelcBtn) + public async Task ShowDialog(string messageBoxText, string caption, bool isCancelcBtn) { - return MainThreadDesktop.InvokeOnMainThreadAsync(() => + return await MainThreadDesktop.InvokeOnMainThreadAsync(async () => { - var dialog = new MessageWindowViewModel + var window = new MessageWindow(); + var dialog = new MessageWindowViewModel(window) { Content = messageBoxText, Title = caption }; - var window = new MessageWindow { DataContext = dialog }; - window.WindowStartupLocation = WindowStartupLocation.CenterScreen; - AppHelper.Current.ShowChildWindow(window); + window.DataContext = dialog; + //window.WindowStartupLocation = WindowStartupLocation.CenterScreen; + await AppHelper.Current.ShowChildWindow(window); return dialog.DialogResult; }); } + public void CloseWindow(object window) + { + if (window is Window w) + w.Close(); + } + static Type GetWindowType(IMessageWindowService.CustomWindow customWindow) => customWindow switch { IMessageWindowService.CustomWindow.MessageBox => typeof(MessageWindow), @@ -53,7 +60,7 @@ namespace System.Application.Services.Implementation window.DataContext = dataContext; } window.WindowStartupLocation = WindowStartupLocation.CenterScreen; - AppHelper.Current.ShowChildWindow(window); + AppHelper.Current.ShowWindow(window); }); } } diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml index d2451bbcb..a6d0fcb45 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml +++ b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml @@ -14,7 +14,7 @@ - + - + + + + + + + + + diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml.cs b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml.cs index ffd77cf97..e8e449318 100644 --- a/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml.cs +++ b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml.cs @@ -4,7 +4,7 @@ using Avalonia.Markup.Xaml; namespace System.Application.UI.Windows { - public class MessageWindow : Window + public class MessageWindow : FluentWindow { public MessageWindow() { diff --git a/System.Application.SteamTools.Client.Desktop/Services/IDesktopAppService.cs b/System.Application.SteamTools.Client.Desktop/Services/IDesktopAppService.cs index b2e55c5bd..e5630e11a 100644 --- a/System.Application.SteamTools.Client.Desktop/Services/IDesktopAppService.cs +++ b/System.Application.SteamTools.Client.Desktop/Services/IDesktopAppService.cs @@ -1,5 +1,6 @@ using System.Application.Models; using System.Collections.Generic; +using System.Threading.Tasks; using System.Windows.Input; namespace System.Application.Services @@ -14,7 +15,9 @@ namespace System.Application.Services /// /// 打开子窗口 /// - void ShowChildWindow(object window); + Task ShowChildWindow(object window); + + void ShowWindow(object window); /// /// 退出整个程序 diff --git a/System.Application.SteamTools.Client.Desktop/Services/IMessageWindowService.cs b/System.Application.SteamTools.Client.Desktop/Services/IMessageWindowService.cs index 02e172d01..044c7f7bb 100644 --- a/System.Application.SteamTools.Client.Desktop/Services/IMessageWindowService.cs +++ b/System.Application.SteamTools.Client.Desktop/Services/IMessageWindowService.cs @@ -30,6 +30,8 @@ namespace System.Application.Services /// 一个 值,用于指定用户单击了哪个消息框按钮。 Task ShowDialog(string messageBoxText, string caption, bool isCancelcBtn); + void CloseWindow(object window); + Task Show(CustomWindow window, ViewModelBase? dataContext = null); public enum CustomWindow : byte diff --git a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs index d49c77042..b7a4474a9 100644 --- a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs +++ b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Pages/DebugPageViewModel.cs @@ -28,11 +28,20 @@ namespace System.Application.UI.ViewModels public void DebugButton_Click() { - Services.ToastService.Current.Notify("Test CommandTest CommandTest CommandTest CommandTest CommandTest Command"); + Services.ToastService.Current.Notify("Test CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest CommandTest Command"); DebugString += Services.ToastService.Current.Message + Environment.NewLine; DebugString += Services.ToastService.Current.IsVisible + Environment.NewLine; - //DI.Get().ShowDialog("Test", "Test"); + var result = DI.Get().ShowDialog(@"Steam++ v1.1.2 2021-01-29 +更新内容 +1、新增账号切换的状态栏右下角登录新账号功能 +2、新增实时刷新获取Steam新登录的账号数据功能 +3、新增FAQ常见问题疑难解答文本,可以在关于中找到它 +4、优化配置文件备份机制,如果配置文件出错会提示还原上次读取成功的配置 +5、优化错误日志记录,现在它更详细了 +6、修复谷歌验证码代理方式为全局跳转recatpcha +7、修复配置文件加载时提示根元素错误 +8、修复某些情况下开机自启失效问题", "Title").ContinueWith(s => DebugString += s.Result + Environment.NewLine); } } } \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Windows/MessageWindowViewModel.cs b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Windows/MessageWindowViewModel.cs index 97882e1d1..1dc75660e 100644 --- a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Windows/MessageWindowViewModel.cs +++ b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Windows/MessageWindowViewModel.cs @@ -1,20 +1,34 @@ using ReactiveUI; +using System.Application.Services; namespace System.Application.UI.ViewModels.Windows { - public class MessageWindowViewModel : WindowViewModel + public class MessageWindowViewModel : WindowViewModel { - public MessageWindowViewModel() + private readonly T Window; + public MessageWindowViewModel(T window) { - + Window = window; } - private string _Content; - public string Content + private string? _Content; + public string? Content { get => _Content; set => this.RaiseAndSetIfChanged(ref _Content, value); } + + public void OK() + { + DialogResult = true; + DI.Get().CloseWindow(Window); + } + + public void Cancel() + { + DialogResult = false; + DI.Get().CloseWindow(Window); + } } } diff --git a/source/SteamTools/Views/Window/MessageDialog.xaml b/source/SteamTools/Views/Window/MessageDialog.xaml index bafed1ef1..655fcfc87 100644 --- a/source/SteamTools/Views/Window/MessageDialog.xaml +++ b/source/SteamTools/Views/Window/MessageDialog.xaml @@ -14,9 +14,6 @@ Title="{Binding Title}" Topmost="{Binding Topmost}" Style="{DynamicResource MetroDialogStyleKey}" - UseLayoutRounding="True" - TextOptions.TextFormattingMode="Display" - SnapsToDevicePixels="True" WindowStartupLocation="CenterOwner" SizeToContent="Height" d:DataContext="{d:DesignInstance vm:DialogWindowViewModel}">