From 3a95b8b802171c0eca7e04ff4ad0ea3b8a78d2da Mon Sep 17 00:00:00 2001 From: rmbgame Date: Sat, 6 Mar 2021 17:56:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=BC=B9=E6=A1=86=E7=AA=97=E5=8F=A3=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=90=90=E5=8F=B8=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UI/Controls/ToastMessage.axaml | 12 ++ .../UI/Controls/ToastMessage.axaml.cs | 19 +++ .../UI/Windows/MessageWindow.axaml | 9 ++ .../UI/Windows/MessageWindow.axaml.cs | 22 +++ .../Models/SteamApp.cs | 2 - .../Serialization/FileSettingsProvider.cs | 138 +++++++++--------- .../Implementation/SteamServiceImpl.cs | 3 +- ...plication.SteamTools.Client.Desktop.csproj | 4 - .../Pages/SteamAccountPageViewModel.cs | 4 +- .../UI/ViewModels/Windows/MessageWindow.cs | 14 ++ 10 files changed, 148 insertions(+), 79 deletions(-) create mode 100644 System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml create mode 100644 System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml.cs create mode 100644 System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml create mode 100644 System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml.cs create mode 100644 System.Application.SteamTools.Client.Desktop/UI/ViewModels/Windows/MessageWindow.cs 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 new file mode 100644 index 000000000..6609b5950 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml.cs b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml.cs new file mode 100644 index 000000000..2886ed45e --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Controls/ToastMessage.axaml.cs @@ -0,0 +1,19 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace System.Application.UI.Controls +{ + public class ToastMessage : UserControl + { + public ToastMessage() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml new file mode 100644 index 000000000..37e44c71b --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml @@ -0,0 +1,9 @@ + + + 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 new file mode 100644 index 000000000..ffd77cf97 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop.Avalonia/Application/UI/Windows/MessageWindow.axaml.cs @@ -0,0 +1,22 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace System.Application.UI.Windows +{ + public class MessageWindow : Window + { + public MessageWindow() + { + InitializeComponent(); +#if DEBUG + this.AttachDevTools(); +#endif + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/System.Application.SteamTools.Client.Desktop/Models/SteamApp.cs b/System.Application.SteamTools.Client.Desktop/Models/SteamApp.cs index eef31cbc8..058a55a6c 100644 --- a/System.Application.SteamTools.Client.Desktop/Models/SteamApp.cs +++ b/System.Application.SteamTools.Client.Desktop/Models/SteamApp.cs @@ -42,6 +42,4 @@ namespace System.Application.Models return $"{AppId} | {Name}"; } } - - } \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/Serialization/FileSettingsProvider.cs b/System.Application.SteamTools.Client.Desktop/Serialization/FileSettingsProvider.cs index aeec29e7d..1725459b3 100644 --- a/System.Application.SteamTools.Client.Desktop/Serialization/FileSettingsProvider.cs +++ b/System.Application.SteamTools.Client.Desktop/Serialization/FileSettingsProvider.cs @@ -5,66 +5,66 @@ using System.Linq; namespace System.Application.Serialization { - public class FileSettingsProvider : ISerializationProvider - { - private readonly string _path; - private readonly object _sync = new object(); - private SortedDictionary _settings = new SortedDictionary(); + public class FileSettingsProvider : ISerializationProvider + { + private readonly string _path; + private readonly object _sync = new object(); + private SortedDictionary _settings = new SortedDictionary(); - public bool IsLoaded { get; private set; } + public bool IsLoaded { get; private set; } - public FileSettingsProvider(string path) - { - this._path = path; - } + public FileSettingsProvider(string path) + { + this._path = path; + } - public void SetValue(string key, T value) - { - lock (this._sync) - { - this._settings[key] = value; - } - } + public void SetValue(string key, T value) + { + lock (this._sync) + { + this._settings[key] = value; + } + } - public bool TryGetValue(string key, out T value) - { - lock (this._sync) - { - object obj; - if (this._settings.TryGetValue(key, out obj) && obj is T) - { - value = (T)obj; - return true; - } - } + public bool TryGetValue(string key, out T value) + { + lock (this._sync) + { + object obj; + if (this._settings.TryGetValue(key, out obj) && obj is T) + { + value = (T)obj; + return true; + } + } - value = default(T); - return false; - } + value = default(T); + return false; + } - public bool RemoveValue(string key) - { - lock (this._sync) - { - return this._settings.Remove(key); - } - } + public bool RemoveValue(string key) + { + lock (this._sync) + { + return this._settings.Remove(key); + } + } - public void Save() - { - if (this._settings.Count == 0) return; + public void Save() + { + if (this._settings.Count == 0) return; - var dir = Path.GetDirectoryName(this._path); - if (dir == null) throw new DirectoryNotFoundException(); + var dir = Path.GetDirectoryName(this._path); + if (dir == null) throw new DirectoryNotFoundException(); - if (!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } + if (!Directory.Exists(dir)) + { + Directory.CreateDirectory(dir); + } - lock (this._sync) - { + lock (this._sync) + { using var stream = new FileStream(this._path, FileMode.Create, FileAccess.ReadWrite); if (stream.Position > 0) { @@ -74,12 +74,12 @@ namespace System.Application.Serialization stream.Write(data, 0, data.Length); //XamlServices.Save(stream, this._settings); } - } + } - public void Load() - { - if (File.Exists(this._path)) - { + public void Load() + { + if (File.Exists(this._path)) + { using var stream = new FileStream(this._path, FileMode.Open, FileAccess.Read); lock (this._sync) { @@ -95,21 +95,21 @@ namespace System.Application.Serialization : new SortedDictionary(source); } } - else - { - lock (this._sync) - { - this._settings = new SortedDictionary(); - } - } + else + { + lock (this._sync) + { + this._settings = new SortedDictionary(); + } + } - this.IsLoaded = true; - } + this.IsLoaded = true; + } - event EventHandler ISerializationProvider.Reloaded - { - add { } - remove { } - } - } + event EventHandler ISerializationProvider.Reloaded + { + add { } + remove { } + } + } } diff --git a/System.Application.SteamTools.Client.Desktop/Services/Implementation/SteamServiceImpl.cs b/System.Application.SteamTools.Client.Desktop/Services/Implementation/SteamServiceImpl.cs index ca6f4405b..33ad3aecd 100644 --- a/System.Application.SteamTools.Client.Desktop/Services/Implementation/SteamServiceImpl.cs +++ b/System.Application.SteamTools.Client.Desktop/Services/Implementation/SteamServiceImpl.cs @@ -95,8 +95,7 @@ namespace System.Application.Services.Implementation else { toast.Show(SR.SteamInstallPathNotFound); - } - } + } } public string GetLastLoginUserName() => platformService.GetLastSteamLoginUserName(); diff --git a/System.Application.SteamTools.Client.Desktop/System.Application.SteamTools.Client.Desktop.csproj b/System.Application.SteamTools.Client.Desktop/System.Application.SteamTools.Client.Desktop.csproj index f7b86740b..702fb0e0c 100644 --- a/System.Application.SteamTools.Client.Desktop/System.Application.SteamTools.Client.Desktop.csproj +++ b/System.Application.SteamTools.Client.Desktop/System.Application.SteamTools.Client.Desktop.csproj @@ -67,8 +67,4 @@ PreserveNewest - - - - \ No newline at end of file diff --git a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Pages/SteamAccountPageViewModel.cs b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Pages/SteamAccountPageViewModel.cs index b4dbe53b0..660efaba8 100644 --- a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Pages/SteamAccountPageViewModel.cs +++ b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Pages/SteamAccountPageViewModel.cs @@ -1,5 +1,6 @@ using ReactiveUI; using System.Application.Models; +using System.Application.Models.Settings; using System.Application.Services; using System.Application.UI.Resx; using System.Collections.Generic; @@ -33,7 +34,6 @@ namespace System.Application.UI.ViewModels internal async override Task Initialize() { - SteamUsers = new ObservableCollection(steamService.GetRememberUserList()); if (!SteamUsers.Any_Nullable()) { @@ -64,7 +64,7 @@ namespace System.Application.UI.ViewModels { steamService.SetCurrentUser(accountName); steamService.TryKillSteamProcess(); - steamService.StartSteam(); + steamService.StartSteam(SteamSettings.SteamStratParameter.Value); } } diff --git a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Windows/MessageWindow.cs b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Windows/MessageWindow.cs new file mode 100644 index 000000000..4ad8b3158 --- /dev/null +++ b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/Windows/MessageWindow.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace System.Application.UI.ViewModels.Windows +{ + public class MessageWindow : WindowViewModel + { + public MessageWindow() + { + Title = ""; + } + } +}