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 3f7e373e8..6c7eb0822 100644
--- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs
+++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/App.axaml.cs
@@ -1,11 +1,8 @@
-using Avalonia.Controls;
+using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
-using Avalonia.Markup.Xaml.Styling;
-using Avalonia.Styling;
using System.Application.UI.ViewModels;
using System.Application.UI.Views;
-using System.Diagnostics;
using System.IO;
using System.Windows;
using AvaloniaApplication = Avalonia.Application;
@@ -19,7 +16,7 @@ namespace System.Application.UI
[Obsolete("use IOPath.AppDataDirectory", true)]
public DirectoryInfo LocalAppData => new DirectoryInfo(IOPath.AppDataDirectory);
- public DirectoryInfo RootDirectory => new DirectoryInfo(AppContext.BaseDirectory);
+ public static DirectoryInfo RootDirectory => new DirectoryInfo(AppContext.BaseDirectory);
[Obsolete("use AppHelper.ProgramName", true)]
public string ProgramName => AppHelper.ProgramName;
@@ -31,7 +28,7 @@ namespace System.Application.UI
public override void OnFrameworkInitializationCompleted()
{
- // ÔÚUIԤÀÀÖУ¬ApplicationLifetime Ϊ null
+ // 在UI预览中,ApplicationLifetime 为 null
ViewModelBase.IsInDesignMode = ApplicationLifetime == null;
Startup.Init();
diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Pages/SettingsPage.axaml b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Pages/SettingsPage.axaml
index cdef718cf..cc637fa6a 100644
--- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Pages/SettingsPage.axaml
+++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Pages/SettingsPage.axaml
@@ -1,7 +1,7 @@
-
+
-
+
-
@@ -31,7 +27,7 @@
HorizontalAlignment="Stretch"
Spacing="16"
Grid.Row="1">
-
+
diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Program.cs b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Program.cs
index 096a5cdf1..df9f44082 100644
--- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Program.cs
+++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Program.cs
@@ -14,7 +14,7 @@ namespace System.Application.UI
{
// 目前桌面端默认使用 SystemTextJson 如果出现兼容性问题可取消下面这行代码
// Serializable.DefaultJsonImplType = Serializable.JsonImplType.NewtonsoftJson;
-
+
var logger = LogManager.GetCurrentClassLogger();
try
{
diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/System.Application.SteamTools.Client.Desktop.Avalonia.App.csproj b/System.Application.SteamTools.Client.Desktop.Avalonia.App/System.Application.SteamTools.Client.Desktop.Avalonia.App.csproj
index 5c32d349b..dcde47edf 100644
--- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/System.Application.SteamTools.Client.Desktop.Avalonia.App.csproj
+++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/System.Application.SteamTools.Client.Desktop.Avalonia.App.csproj
@@ -1,72 +1,74 @@
-
- WinExe
- net5.0
- false
-
- System.Application.UI
- Steam++
- Assets\Icon.ico
- Properties\app.manifest
-
-
-
- x86
-
-
-
- Properties\AssemblyInfo.cs
-
-
+
+ WinExe
+ net5.0
+ false
+
+ System.Application.UI
+ Steam++
+ Assets\Icon.ico
+ Properties\app.manifest
+
-
-
-
-
-
+
+
+ x86
+
-
-
-
+
+
+ Properties\AssemblyInfo.cs
+
+
-
-
-
+
+
+
+
+
-
-
-
+
+
+
-
-
- MessageBox_Avalonia
-
-
+
+
+
-
-
- %(Filename)
-
-
- Designer
-
-
-
+
+
+
-
-
-
- Assets\VisualElements_150.png
- PreserveNewest
-
-
- Assets\VisualElements_70.png
- PreserveNewest
-
-
- steam++.visualelementsmanifest.xml
- PreserveNewest
-
-
+
+
+ MessageBox_Avalonia
+
+
+
+
+
+ %(Filename)
+
+
+ Designer
+
+
+
+
+
+
+
+ Assets\VisualElements_150.png
+ PreserveNewest
+
+
+ Assets\VisualElements_70.png
+ PreserveNewest
+
+
+ steam++.visualelementsmanifest.xml
+ PreserveNewest
+
+
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/ViewModels/MainWindowViewModel.cs b/System.Application.SteamTools.Client.Desktop.Avalonia.App/ViewModels/MainWindowViewModel.cs
index 17a2f5e5f..b2a5b5f4a 100644
--- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/ViewModels/MainWindowViewModel.cs
+++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/ViewModels/MainWindowViewModel.cs
@@ -16,84 +16,84 @@ namespace System.Application.UI.ViewModels
public MainWindowViewModel() : base()
{
Title = ThisAssembly.AssemblyTrademark;
- SettingsPage = GetViewModel();
+ SettingsPage = new SettingsPageViewModel();
}
- #region ResStrings
+ //#region ResStrings
- string mWelcome = string.Empty;
+ //string mWelcome = string.Empty;
- [ResString]
- public string Welcome
- {
- get => mWelcome;
- set => this.RaiseAndSetIfChanged(ref mWelcome, value);
- }
+ //[ResString]
+ //public string Welcome
+ //{
+ // get => mWelcome;
+ // set => this.RaiseAndSetIfChanged(ref mWelcome, value);
+ //}
- string mCommunityFix = string.Empty;
+ //string mCommunityFix = string.Empty;
- [ResString]
- public string CommunityFix
- {
- get => mCommunityFix;
- set => this.RaiseAndSetIfChanged(ref mCommunityFix, value);
- }
+ //[ResString]
+ //public string CommunityFix
+ //{
+ // get => mCommunityFix;
+ // set => this.RaiseAndSetIfChanged(ref mCommunityFix, value);
+ //}
- string mUserFastChange = string.Empty;
+ //string mUserFastChange = string.Empty;
- [ResString]
- public string UserFastChange
- {
- get => mUserFastChange;
- set => this.RaiseAndSetIfChanged(ref mUserFastChange, value);
- }
+ //[ResString]
+ //public string UserFastChange
+ //{
+ // get => mUserFastChange;
+ // set => this.RaiseAndSetIfChanged(ref mUserFastChange, value);
+ //}
- string mSteamApps = string.Empty;
+ //string mSteamApps = string.Empty;
- [ResString]
- public string SteamApps
- {
- get => mSteamApps;
- set => this.RaiseAndSetIfChanged(ref mSteamApps, value);
- }
+ //[ResString]
+ //public string SteamApps
+ //{
+ // get => mSteamApps;
+ // set => this.RaiseAndSetIfChanged(ref mSteamApps, value);
+ //}
- string mSteamAuth = string.Empty;
+ //string mSteamAuth = string.Empty;
- [ResString]
- public string SteamAuth
- {
- get => mSteamAuth;
- set => this.RaiseAndSetIfChanged(ref mSteamAuth, value);
- }
+ //[ResString]
+ //public string SteamAuth
+ //{
+ // get => mSteamAuth;
+ // set => this.RaiseAndSetIfChanged(ref mSteamAuth, value);
+ //}
- string mGameRelated = string.Empty;
+ //string mGameRelated = string.Empty;
- [ResString]
- public string GameRelated
- {
- get => mGameRelated;
- set => this.RaiseAndSetIfChanged(ref mGameRelated, value);
- }
+ //[ResString]
+ //public string GameRelated
+ //{
+ // get => mGameRelated;
+ // set => this.RaiseAndSetIfChanged(ref mGameRelated, value);
+ //}
- string mSettings = string.Empty;
+ //string mSettings = string.Empty;
- [ResString]
- public string Settings
- {
- get => mSettings;
- set => this.RaiseAndSetIfChanged(ref mSettings, value);
- }
+ //[ResString]
+ //public string Settings
+ //{
+ // get => mSettings;
+ // set => this.RaiseAndSetIfChanged(ref mSettings, value);
+ //}
- string mAbout = string.Empty;
+ //string mAbout = string.Empty;
- [ResString]
- public string About
- {
- get => mAbout;
- set => this.RaiseAndSetIfChanged(ref mAbout, value);
- }
+ //[ResString]
+ //public string About
+ //{
+ // get => mAbout;
+ // set => this.RaiseAndSetIfChanged(ref mAbout, value);
+ //}
- #endregion
+ //#endregion
public SettingsPageViewModel SettingsPage { get; }
}
diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/ViewModels/SettingsPageViewModel.cs b/System.Application.SteamTools.Client.Desktop.Avalonia.App/ViewModels/SettingsPageViewModel.cs
index dc8b37dda..d3fa577db 100644
--- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/ViewModels/SettingsPageViewModel.cs
+++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/ViewModels/SettingsPageViewModel.cs
@@ -1,6 +1,7 @@
using Avalonia.Controls;
using ReactiveUI;
using System.Application.Services;
+using System.Application.UI.Resx;
using System.Collections.Generic;
using System.Linq;
@@ -8,40 +9,40 @@ namespace System.Application.UI.ViewModels
{
public class SettingsPageViewModel : ViewModelBase, ILocalizationViewModel
{
- #region ResStrings
+ //#region ResStrings
- string mSettings_General = string.Empty;
+ //string mSettings_General = string.Empty;
- [ResString]
- public string Settings_General
- {
- get => mSettings_General;
- set => this.RaiseAndSetIfChanged(ref mSettings_General, value);
- }
+ //[ResString]
+ //public string Settings_General
+ //{
+ // get => mSettings_General;
+ // set => this.RaiseAndSetIfChanged(ref mSettings_General, value);
+ //}
- string mSettings_Auth = string.Empty;
+ //string mSettings_Auth = string.Empty;
- [ResString]
- public string Settings_Auth
- {
- get => mSettings_Auth;
- set => this.RaiseAndSetIfChanged(ref mSettings_Auth, value);
- }
+ //[ResString]
+ //public string Settings_Auth
+ //{
+ // get => mSettings_Auth;
+ // set => this.RaiseAndSetIfChanged(ref mSettings_Auth, value);
+ //}
- string mLanguage = string.Empty;
+ //string mLanguage = string.Empty;
- [ResString]
- public string Language
- {
- get => mLanguage;
- set => this.RaiseAndSetIfChanged(ref mLanguage, value);
- }
+ //[ResString]
+ //public string Language
+ //{
+ // get => mLanguage;
+ // set => this.RaiseAndSetIfChanged(ref mLanguage, value);
+ //}
- #endregion
+ //#endregion
public SettingsPageViewModel()
{
- Languages = ILocalizationService.Languages.Select(Convert).ToList();
+ Languages = R.Languages.Select(Convert).ToList();
}
int mCurrentLanguageIndex;
@@ -52,19 +53,28 @@ namespace System.Application.UI.ViewModels
set
{
this.RaiseAndSetIfChanged(ref mCurrentLanguageIndex, value);
- if (!IsInDesignMode)
+ var cultureName = Languages[value].Tag?.ToString();
+ if (string.IsNullOrWhiteSpace(cultureName))
{
- var localizationService = DI.Get();
- var cultureName = Languages[value].Tag?.ToString();
- if (string.IsNullOrWhiteSpace(cultureName))
- {
- cultureName = localizationService.DefaultCurrentUICulture?.Name;
- }
- if (!string.IsNullOrWhiteSpace(cultureName))
- {
- localizationService.ChangeLanguage(cultureName);
- }
+ cultureName = R.DefaultCurrentUICulture?.Name;
}
+ if (!string.IsNullOrWhiteSpace(cultureName))
+ {
+ R.ChangeLanguage(cultureName);
+ }
+ //if (!IsInDesignMode)
+ //{
+ // var localizationService = DI.Get();
+ // var cultureName = Languages[value].Tag?.ToString();
+ // if (string.IsNullOrWhiteSpace(cultureName))
+ // {
+ // cultureName = localizationService.DefaultCurrentUICulture?.Name;
+ // }
+ // if (!string.IsNullOrWhiteSpace(cultureName))
+ // {
+ // localizationService.ChangeLanguage(cultureName);
+ // }
+ //}
}
}
diff --git a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Views/MainView.axaml b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Views/MainView.axaml
index 07f122b74..cad61cb0b 100644
--- a/System.Application.SteamTools.Client.Desktop.Avalonia.App/Views/MainView.axaml
+++ b/System.Application.SteamTools.Client.Desktop.Avalonia.App/Views/MainView.axaml
@@ -5,52 +5,49 @@
mc:Ignorable="d" d:DesignWidth="1200" d:DesignHeight="600"
xmlns:vm="clr-namespace:System.Application.UI.ViewModels"
xmlns:pages="clr-namespace:System.Application.UI.Pages"
- xmlns:resx="clr-namespace:System.Application.Resx;assembly=System.Application.SteamTools.Client.Desktop"
+ xmlns:resx="clr-namespace:System.Application.UI.Resx;assembly=System.Application.SteamTools.Client.Desktop"
x:Class="System.Application.UI.Views.MainView"
FontSize="14"
- Foreground="{StaticResource SystemBaseHighColor}"
- x:DataType="vm:MainWindowViewModel">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Foreground="{StaticResource SystemBaseHighColor}">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/Extensions/ProcessExtensions.cs b/System.Application.SteamTools.Client.Desktop/Extensions/ProcessExtensions.cs
index eb8be9339..23830c4b5 100644
--- a/System.Application.SteamTools.Client.Desktop/Extensions/ProcessExtensions.cs
+++ b/System.Application.SteamTools.Client.Desktop/Extensions/ProcessExtensions.cs
@@ -1,7 +1,8 @@
using System.Application.Services;
using System.Diagnostics;
-namespace System.Application.Extensions
+// ReSharper disable once CheckNamespace
+namespace System.Application
{
///
/// 为 类型提供扩展方法
diff --git a/System.Application.SteamTools.Client.Desktop/Extensions/PropertyChangedExtensions.cs b/System.Application.SteamTools.Client.Desktop/Extensions/PropertyChangedExtensions.cs
index 3127bff2a..7beeada22 100644
--- a/System.Application.SteamTools.Client.Desktop/Extensions/PropertyChangedExtensions.cs
+++ b/System.Application.SteamTools.Client.Desktop/Extensions/PropertyChangedExtensions.cs
@@ -1,77 +1,73 @@
using StatefulModel.EventListeners;
-using System;
-using System.Collections.Generic;
using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-namespace System.Application.Extensions
+// ReSharper disable once CheckNamespace
+namespace System.Application
{
- public static class PropertyChangedExtensions
- {
- ///
- /// 订阅事件
- ///
- public static IDisposable Subscribe(this INotifyPropertyChanged source, PropertyChangedEventHandler handler)
- {
- return new PropertyChangedEventListener(source, handler);
- }
+ public static class PropertyChangedExtensions
+ {
+ ///
+ /// 订阅事件
+ ///
+ public static IDisposable Subscribe(this INotifyPropertyChanged source, PropertyChangedEventHandler handler)
+ {
+ return new PropertyChangedEventListener(source, handler);
+ }
- ///
- /// 订阅事件
- ///
- /// イベント ソース。
- /// イベント発生時に、 を受け取って実行されるメソッド。
- public static IDisposable Subscribe(this INotifyPropertyChanged source, Action action)
- {
- return new PropertyChangedEventListener(source, (sender, args) => action(args.PropertyName));
- }
+ ///
+ /// 订阅事件
+ ///
+ /// イベント ソース。
+ /// イベント発生時に、 を受け取って実行されるメソッド。
+ public static IDisposable Subscribe(this INotifyPropertyChanged source, Action action)
+ {
+ return new PropertyChangedEventListener(source, (sender, args) => action(args.PropertyName));
+ }
- ///
- /// 与指定的属性名称一起执行 订阅事件
- ///
- /// 事件源
- /// 订阅事件的属性的名称
- /// 事件发生时执行的方法
- /// 在调用此方法时 如果只运行一次,则为true,否则为false,默认值是true。
- public static ListenerWrapper Subscribe(this INotifyPropertyChanged source, string propertyName, Action action, bool immediately = true)
- {
- return new ListenerWrapper(source).Subscribe(propertyName, action, immediately);
- }
+ ///
+ /// 与指定的属性名称一起执行 订阅事件
+ ///
+ /// 事件源
+ /// 订阅事件的属性的名称
+ /// 事件发生时执行的方法
+ /// 在调用此方法时 如果只运行一次,则为true,否则为false,默认值是true。
+ public static ListenerWrapper Subscribe(this INotifyPropertyChanged source, string propertyName, Action action, bool immediately = true)
+ {
+ return new ListenerWrapper(source).Subscribe(propertyName, action, immediately);
+ }
- public class ListenerWrapper : IDisposable
- {
- //用于一个事件源
- //当要订阅多个属性更改通知时
- // EventSource // <-INotifyPropertyChanged对象
- // .Subscribe(nameof(Property1),()=> {...})
- // .Subscribe(nameof(Property2),()=> {...})
- // .Subscribe(nameof(Property3),()=> {...})
- // .AddTo(this);
- //仅出于编写目的而准备
+ public class ListenerWrapper : IDisposable
+ {
+ //用于一个事件源
+ //当要订阅多个属性更改通知时
+ // EventSource // <-INotifyPropertyChanged对象
+ // .Subscribe(nameof(Property1),()=> {...})
+ // .Subscribe(nameof(Property2),()=> {...})
+ // .Subscribe(nameof(Property3),()=> {...})
+ // .AddTo(this);
+ //仅出于编写目的而准备
- private readonly PropertyChangedEventListener _listener;
+ private readonly PropertyChangedEventListener _listener;
- internal ListenerWrapper(INotifyPropertyChanged source)
- {
- this._listener = new PropertyChangedEventListener(source);
- }
+ internal ListenerWrapper(INotifyPropertyChanged source)
+ {
+ this._listener = new PropertyChangedEventListener(source);
+ }
- ///
- /// 与指定的属性名称一起执行 订阅事件
- ///
- /// 订阅事件的属性的名称
- /// 事件发生时执行的方法。
- /// 在调用此方法时 如果只运行一次,则为true,否则为false,默认值是true。
- public ListenerWrapper Subscribe(string propertyName, Action action, bool immediately = true)
- {
- if (immediately) action();
- this._listener.Add(propertyName, (sender, args) => action());
- return this;
- }
+ ///
+ /// 与指定的属性名称一起执行 订阅事件
+ ///
+ /// 订阅事件的属性的名称
+ /// 事件发生时执行的方法。
+ /// 在调用此方法时 如果只运行一次,则为true,否则为false,默认值是true。
+ public ListenerWrapper Subscribe(string propertyName, Action action, bool immediately = true)
+ {
+ if (immediately) action();
+ this._listener.Add(propertyName, (sender, args) => action());
+ return this;
+ }
- void IDisposable.Dispose() => this._listener.Dispose();
- }
- }
-}
+ void IDisposable.Dispose() => this._listener.Dispose();
+ }
+ }
+}
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/Mvvm/CompositeDisposable.cs b/System.Application.SteamTools.Client.Desktop/Mvvm/CompositeDisposable.cs
index 4068bf1d4..ab147a0b1 100644
--- a/System.Application.SteamTools.Client.Desktop/Mvvm/CompositeDisposable.cs
+++ b/System.Application.SteamTools.Client.Desktop/Mvvm/CompositeDisposable.cs
@@ -1,25 +1,21 @@
using StatefulModel;
-using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace System.Application.Mvvm
{
///
- /// 提供用于一次处理多个IDisposable对象的功能
+ /// 提供用于一次处理多个IDisposable对象的功能
///
public class CompositeDisposable : IDisposable, ICollection
{
- [NotNull] private readonly object _lockObject = new object();
- [NotNull] private readonly List _targetLists;
- private bool _disposed;
+ readonly object _lockObject = new object();
+ readonly List _targetLists;
+ bool _disposed;
///
- /// 构造函数
+ /// 构造函数
///
public CompositeDisposable()
{
@@ -27,7 +23,7 @@ namespace System.Application.Mvvm
}
///
- /// 构造函数
+ /// 构造函数
///
/// IDisposable集合
public CompositeDisposable([NotNull] IEnumerable sourceDisposableList)
@@ -38,7 +34,7 @@ namespace System.Application.Mvvm
}
///
- /// 获取IDisposable集合的枚举数
+ /// 获取IDisposable集合的枚举数
///
/// IDisposableコレクションの列挙子
public IEnumerator GetEnumerator()
@@ -54,7 +50,7 @@ namespace System.Application.Mvvm
}
///
- /// 在最后添加IDisposable
+ /// 在最后添加IDisposable
///
/// 要添加的IDisposable
public void Add(IDisposable item)
@@ -66,7 +62,7 @@ namespace System.Application.Mvvm
}
///
- /// 删除所有元素
+ /// 删除所有元素
///
public void Clear()
{
@@ -75,7 +71,7 @@ namespace System.Application.Mvvm
}
///
- /// 确定此集合中是否包含元素。
+ /// 确定此集合中是否包含元素。
///
/// 包含的元素
/// 是否包含在集合中
@@ -88,7 +84,7 @@ namespace System.Application.Mvvm
}
///
- /// 将整个内容复制到兼容的一维数组中。 复制操作从目标数组上的指定索引处开始。
+ /// 将整个内容复制到兼容的一维数组中。 复制操作从目标数组上的指定索引处开始。
///
/// 复制目标数组
/// 从目标数组中复制位置的索引
@@ -99,7 +95,7 @@ namespace System.Application.Mvvm
}
///
- /// 获取实际存储的元素数
+ /// 获取实际存储的元素数
///
public int Count
{
@@ -111,7 +107,7 @@ namespace System.Application.Mvvm
}
///
- /// 获取此集合是否为只读 (总是返回false)
+ /// 获取此集合是否为只读 (总是返回false)
///
public bool IsReadOnly
{
@@ -123,7 +119,7 @@ namespace System.Application.Mvvm
}
///
- /// 删除找到的第一个特定对象
+ /// 删除找到的第一个特定对象
///
/// 要删除的对象
/// 是否删除成功
@@ -137,7 +133,7 @@ namespace System.Application.Mvvm
}
///
- /// 释放此集合中的所有元素
+ /// 释放此集合中的所有元素
///
public void Dispose()
{
@@ -146,7 +142,7 @@ namespace System.Application.Mvvm
}
///
- /// 代替IDisposable,添加一个Action来最后释放资源。
+ /// 代替IDisposable,添加一个Action来最后释放资源。
///
/// 使用Action释放资源
public void Add([NotNull] Action releaseAction)
@@ -159,7 +155,7 @@ namespace System.Application.Mvvm
}
///
- /// 在开始处添加一个IDisposable
+ /// 在开始处添加一个IDisposable
///
/// 要添加的IDisposable
public void AddFirst(IDisposable item)
@@ -171,7 +167,7 @@ namespace System.Application.Mvvm
}
///
- /// 代替IDisposable,添加在开始时释放资源的Action。
+ /// 代替IDisposable,添加在开始时释放资源的Action。
///
/// 使用Action释放资源
public void AddFirst([NotNull] Action releaseAction)
@@ -198,4 +194,4 @@ namespace System.Application.Mvvm
if (_disposed) throw new ObjectDisposedException("CompositeDisposable");
}
}
-}
+}
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/Mvvm/EventArgsFactory.cs b/System.Application.SteamTools.Client.Desktop/Mvvm/EventArgsFactory.cs
index 7c7df88b5..41d27af29 100644
--- a/System.Application.SteamTools.Client.Desktop/Mvvm/EventArgsFactory.cs
+++ b/System.Application.SteamTools.Client.Desktop/Mvvm/EventArgsFactory.cs
@@ -1,19 +1,18 @@
using System.Collections.Concurrent;
using System.ComponentModel;
-using System.Diagnostics.CodeAnalysis;
namespace System.Application.Mvvm
{
internal static class EventArgsFactory
{
- [NotNull]
- private static readonly ConcurrentDictionary
- PropertyChangedEventArgsDictionary = new ConcurrentDictionary();
+ static readonly ConcurrentDictionary
+ PropertyChangedEventArgsDictionary =
+ new ConcurrentDictionary();
- public static PropertyChangedEventArgs GetPropertyChangedEventArgs([DisallowNull] string propertyName)
+ public static PropertyChangedEventArgs GetPropertyChangedEventArgs(string? propertyName)
{
return PropertyChangedEventArgsDictionary.GetOrAdd(propertyName ?? string.Empty,
name => new PropertyChangedEventArgs(name));
}
}
-}
+}
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/Mvvm/NotificationObject.cs b/System.Application.SteamTools.Client.Desktop/Mvvm/NotificationObject.cs
index 7e422a551..1e6a54884 100644
--- a/System.Application.SteamTools.Client.Desktop/Mvvm/NotificationObject.cs
+++ b/System.Application.SteamTools.Client.Desktop/Mvvm/NotificationObject.cs
@@ -1,29 +1,26 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
-using System.Text;
using System.Threading;
-using System.Threading.Tasks;
namespace System.Application.Mvvm
{
///
- /// 属性更改通知事件
+ /// 属性更改通知事件
///
[Serializable]
public class NotificationObject : INotifyPropertyChanged
{
///
- /// 属性更改通知事件
+ /// 属性更改通知事件
///
[field: NonSerialized]
public event PropertyChangedEventHandler? PropertyChanged;
///
- /// 引发属性更改通知事件
+ /// 引发属性更改通知事件
///
///
/// () => lambda表达式属性
@@ -42,7 +39,7 @@ namespace System.Application.Mvvm
}
///
- /// 引发属性更改通知事件
+ /// 引发属性更改通知事件
///
/// 属性名称
[NotifyPropertyChangedInvocator]
@@ -53,7 +50,7 @@ namespace System.Application.Mvvm
}
///
- /// 如果该值与上一个值不同,则将其更改并引发属性更改通知事件。
+ /// 如果该值与上一个值不同,则将其更改并引发属性更改通知事件。
///
/// 属性泛型
/// 原始值
@@ -65,7 +62,7 @@ namespace System.Application.Mvvm
protected bool RaisePropertyChangedIfSet(ref T source, T value, string[]? relatedProperties = null,
[CallerMemberName] string propertyName = null)
{
- //如果值相同则什么都不做
+ // 如果值相同则什么都不做
if (EqualityComparer.Default.Equals(source, value))
return false;
@@ -80,7 +77,7 @@ namespace System.Application.Mvvm
}
///
- /// 如果该值与上一个值不同,则将其更改并引发属性更改通知事件。
+ /// 如果该值与上一个值不同,则将其更改并引发属性更改通知事件。
///
/// 属性泛型
/// 原始值
@@ -95,4 +92,4 @@ namespace System.Application.Mvvm
return RaisePropertyChangedIfSet(ref source, value, new[] { relatedProperty }, propertyName);
}
}
-}
+}
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/Mvvm/Notifier.cs b/System.Application.SteamTools.Client.Desktop/Mvvm/Notifier.cs
index a5421b116..b75e65445 100644
--- a/System.Application.SteamTools.Client.Desktop/Mvvm/Notifier.cs
+++ b/System.Application.SteamTools.Client.Desktop/Mvvm/Notifier.cs
@@ -1,32 +1,28 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
+using System.ComponentModel;
using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
namespace System.Application.Mvvm
{
- ///
- /// 属性更改通知支持
- ///
- public class Notifier : INotifyPropertyChanged
- {
- private event PropertyChangedEventHandler PropertyChanged;
+ ///
+ /// 属性更改通知支持
+ ///
+ public class Notifier : INotifyPropertyChanged
+ {
+ private event PropertyChangedEventHandler? PropertyChanged;
- event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
- {
- add { this.PropertyChanged += value; }
- remove { this.PropertyChanged -= value; }
- }
+ event PropertyChangedEventHandler? INotifyPropertyChanged.PropertyChanged
+ {
+ add { PropertyChanged += value; }
+ remove { PropertyChanged -= value; }
+ }
- ///
- /// 引发一个事件
- ///
- ///
- protected virtual void RaisePropertyChanged([CallerMemberName] string propertyName = null)
- {
- this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-}
+ ///
+ /// 引发一个事件
+ ///
+ ///
+ protected virtual void RaisePropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+}
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/Mvvm/NotifyPropertyChangedInvocatorAttribute.cs b/System.Application.SteamTools.Client.Desktop/Mvvm/NotifyPropertyChangedInvocatorAttribute.cs
index 820d5de1d..6c2893dcd 100644
--- a/System.Application.SteamTools.Client.Desktop/Mvvm/NotifyPropertyChangedInvocatorAttribute.cs
+++ b/System.Application.SteamTools.Client.Desktop/Mvvm/NotifyPropertyChangedInvocatorAttribute.cs
@@ -1,23 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace System.Application.Mvvm
+namespace System.Application.Mvvm
{
[AttributeUsage(AttributeTargets.Method)]
internal sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
{
- public NotifyPropertyChangedInvocatorAttribute() { }
+ public NotifyPropertyChangedInvocatorAttribute()
+ {
+ }
- public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName)
+ public NotifyPropertyChangedInvocatorAttribute(string parameterName)
{
ParameterName = parameterName;
}
- [DisallowNull] public string ParameterName { get; }
+ public string? ParameterName { get; }
}
-}
+}
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/ServiceCollectionExtensions.cs b/System.Application.SteamTools.Client.Desktop/ServiceCollectionExtensions.cs
index f37d00fce..bc19fa2f0 100644
--- a/System.Application.SteamTools.Client.Desktop/ServiceCollectionExtensions.cs
+++ b/System.Application.SteamTools.Client.Desktop/ServiceCollectionExtensions.cs
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection.Extensions;
+using System;
using System.Application.Services;
using System.Application.Services.Implementation;
using System.Application.UI;
@@ -14,6 +15,7 @@ namespace Microsoft.Extensions.DependencyInjection
///
///
///
+ [Obsolete("Languages")]
public static IServiceCollection AddLocalizationService(this IServiceCollection services)
{
services.AddSingleton();
@@ -25,6 +27,7 @@ namespace Microsoft.Extensions.DependencyInjection
///
///
///
+ [Obsolete("Languages")]
public static IServiceCollection AddViewModelCollectionService(this IServiceCollection services)
{
services.AddSingleton(new ViewModelCollectionServiceImpl(services));
@@ -38,6 +41,7 @@ namespace Microsoft.Extensions.DependencyInjection
///
///
///
+ [Obsolete("Languages")]
public static IServiceCollection AddViewModel(this IServiceCollection services) where TViewModel : ViewModelBase
{
services.AddSingleton();
diff --git a/System.Application.SteamTools.Client.Desktop/Services/ILocalizationService.cs b/System.Application.SteamTools.Client.Desktop/Services/ILocalizationService.cs
index 81bba0bc7..8854e1e6f 100644
--- a/System.Application.SteamTools.Client.Desktop/Services/ILocalizationService.cs
+++ b/System.Application.SteamTools.Client.Desktop/Services/ILocalizationService.cs
@@ -8,6 +8,7 @@ namespace System.Application.Services
///
/// 本地化、多语言服务
///
+ [Obsolete("Languages")]
public interface ILocalizationService
{
CultureInfo DefaultCurrentUICulture { get; }
diff --git a/System.Application.SteamTools.Client.Desktop/Services/IViewModelCollectionService.cs b/System.Application.SteamTools.Client.Desktop/Services/IViewModelCollectionService.cs
index 841ddb579..48a8639ff 100644
--- a/System.Application.SteamTools.Client.Desktop/Services/IViewModelCollectionService.cs
+++ b/System.Application.SteamTools.Client.Desktop/Services/IViewModelCollectionService.cs
@@ -6,6 +6,7 @@ namespace System.Application.Services
///
/// 视图模型组服务
///
+ [Obsolete("Languages")]
public interface IViewModelCollectionService
{
///
diff --git a/System.Application.SteamTools.Client.Desktop/Services/Implementation/LocalizationServiceImpl.cs b/System.Application.SteamTools.Client.Desktop/Services/Implementation/LocalizationServiceImpl.cs
index 872728ae6..c5728046f 100644
--- a/System.Application.SteamTools.Client.Desktop/Services/Implementation/LocalizationServiceImpl.cs
+++ b/System.Application.SteamTools.Client.Desktop/Services/Implementation/LocalizationServiceImpl.cs
@@ -4,6 +4,7 @@ using System.Linq;
namespace System.Application.Services.Implementation
{
+ [Obsolete("Languages")]
internal sealed class LocalizationServiceImpl : ILocalizationService
{
readonly IViewModelCollectionService vmss;
diff --git a/System.Application.SteamTools.Client.Desktop/Services/Implementation/ViewModelCollectionServiceImpl.cs b/System.Application.SteamTools.Client.Desktop/Services/Implementation/ViewModelCollectionServiceImpl.cs
index a0153a827..a8354de89 100644
--- a/System.Application.SteamTools.Client.Desktop/Services/Implementation/ViewModelCollectionServiceImpl.cs
+++ b/System.Application.SteamTools.Client.Desktop/Services/Implementation/ViewModelCollectionServiceImpl.cs
@@ -5,6 +5,7 @@ using System.Linq;
namespace System.Application.Services.Implementation
{
+ [Obsolete("Languages")]
internal sealed class ViewModelCollectionServiceImpl : IViewModelCollectionService
{
readonly IEnumerable services;
diff --git a/System.Application.SteamTools.Client.Desktop/UI/Resx/R.cs b/System.Application.SteamTools.Client.Desktop/UI/Resx/R.cs
new file mode 100644
index 000000000..1460111a9
--- /dev/null
+++ b/System.Application.SteamTools.Client.Desktop/UI/Resx/R.cs
@@ -0,0 +1,85 @@
+using ReactiveUI;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+
+namespace System.Application.UI.Resx
+{
+ public sealed class R : ReactiveObject
+ {
+ //static readonly Lazy @this = new Lazy(new R());
+
+ //public static R Current => @this.Value;
+
+ public static R Current { get; }
+
+ public static readonly IList> Languages;
+ public static readonly IList> SteamLanguages;
+
+ public static CultureInfo DefaultCurrentUICulture { get; }
+
+ static R()
+ {
+ Current = new R();
+ DefaultCurrentUICulture = CultureInfo.CurrentUICulture;
+ Languages = new Dictionary()
+ {
+ { "", "Auto" },
+ { "en", "English" },
+ { "zh-Hans", "Chinese(Simplified)" },
+ { "zh-Hant", "Chinese(Traditional)" },
+ { "ko", "Koreana" },
+ { "ja", "Japanese" },
+ { "ru", "Russian" },
+ }.ToList();
+ SteamLanguages = new Dictionary()
+ {
+ { "zh-Hans", "schinese" },
+ { "zh-Hant", "tchinese" },
+ { "en","english"},
+ { "ko", "koreana" },
+ { "ja", "japanese" },
+ { "ru", "russian" },
+ }.ToList();
+ }
+
+ static bool IsMatch(CultureInfo cultureInfo, string cultureName)
+ {
+ if (string.IsNullOrWhiteSpace(cultureInfo.Name))
+ {
+ return false;
+ }
+ if (cultureInfo.Name == cultureName)
+ {
+ return true;
+ }
+ else
+ {
+ return IsMatch(cultureInfo.Parent, cultureName);
+ }
+ }
+
+ ///
+ /// 更改语言
+ ///
+ ///
+ public static void ChangeLanguage(string cultureName)
+ {
+ void ChangeLanguage()
+ {
+ if (IsMatch(CultureInfo.CurrentUICulture, cultureName)) return;
+ CultureInfo.CurrentUICulture = new CultureInfo(cultureName);
+ AppResources.Culture = CultureInfo.CurrentUICulture;
+ Current.RaisePropertyChanged(nameof(Res));
+ }
+ MainThreadDesktop.BeginInvokeOnMainThread(ChangeLanguage);
+ }
+
+ R()
+ {
+ Res = new AppResources();
+ }
+
+ public AppResources Res { get; }
+ }
+}
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/UI/Resx/ResourceService.cs b/System.Application.SteamTools.Client.Desktop/UI/Resx/ResourceService.cs
index edb7b4d44..d540430c6 100644
--- a/System.Application.SteamTools.Client.Desktop/UI/Resx/ResourceService.cs
+++ b/System.Application.SteamTools.Client.Desktop/UI/Resx/ResourceService.cs
@@ -1,13 +1,14 @@
-using System.Collections.Generic;
+using ReactiveUI;
+using System.Collections.Generic;
using System.Globalization;
using System.Linq;
-using ReactiveUI;
-namespace System.Application.Resx
+namespace System.Application.UI.Resx
{
///
/// 提供对多语言资源的访问。
///
+ [Obsolete("Languages")]
public class ResourceService : ReactiveObject
{
// singleton
@@ -78,12 +79,12 @@ namespace System.Application.Resx
{
System.Application.UI.Resx.AppResources.Culture = this.SupportedCultures.SingleOrDefault(x => x.Name == name);
//GeneralSettings.Culture.Value = SteamTools.Properties.Resources.Culture?.Name;
- this.RaisePropertyChanged(nameof(this.Resources));
+ this.RaisePropertyChanged(nameof(Resources));
}
public string GetCurrentCultureSteamLanguageName()
{
- return System.Application.UI.Resx.AppResources.Culture == null ? supportedCultureSteamNames.First().Value : supportedCultureSteamNames[System.Application.UI.Resx.AppResources.Culture.Name];
+ return UI.Resx.AppResources.Culture == null ? supportedCultureSteamNames.First().Value : supportedCultureSteamNames[UI.Resx.AppResources.Culture.Name];
}
}
-}
+}
\ No newline at end of file
diff --git a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ILocalizationViewModel.cs b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ILocalizationViewModel.cs
index 12842e4af..b93266ba3 100644
--- a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ILocalizationViewModel.cs
+++ b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ILocalizationViewModel.cs
@@ -7,6 +7,7 @@ namespace System.Application.UI.ViewModels
///
/// 本地化、多语言视图模型
///
+ [Obsolete("Languages")]
public interface ILocalizationViewModel
{
public void OnChangeLanguage()
diff --git a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ResStringAttribute.cs b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ResStringAttribute.cs
index e766168b6..2332b5540 100644
--- a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ResStringAttribute.cs
+++ b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ResStringAttribute.cs
@@ -1,5 +1,6 @@
namespace System.Application.UI.ViewModels
{
+ [Obsolete("Languages")]
[AttributeUsage(AttributeTargets.Property)]
public sealed class ResStringAttribute : Attribute
{
diff --git a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ViewModelBase.cs b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ViewModelBase.cs
index 0e65fc170..83eb0f9d3 100644
--- a/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ViewModelBase.cs
+++ b/System.Application.SteamTools.Client.Desktop/UI/ViewModels/ViewModelBase.cs
@@ -1,16 +1,13 @@
using ReactiveUI;
using System.Application.Mvvm;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
namespace System.Application.UI.ViewModels
{
public class ViewModelBase : ReactiveObject, IDisposable, ILocalizationViewModel
{
- [NonSerialized] private CompositeDisposable _compositeDisposable;
+ [NonSerialized] CompositeDisposable? _compositeDisposable;
- [NonSerialized] private bool _disposed;
+ [NonSerialized] bool _disposed;
public ViewModelBase()
{
@@ -38,6 +35,5 @@ namespace System.Application.UI.ViewModels
if (disposing) _compositeDisposable?.Dispose();
_disposed = true;
}
- protected static TViewModel GetViewModel() where TViewModel : ViewModelBase => DI.Get();
}
}
\ No newline at end of file