配置文件功能完善

This commit is contained in:
rmbgame
2021-03-06 11:01:13 +08:00
parent 3cbcabeedf
commit ca93b3f9c8
29 changed files with 906 additions and 77 deletions
@@ -288,6 +288,15 @@ namespace System.Application.UI.Resx {
/// <summary>
/// 查找类似 以该账号登录Steam 的本地化字符串。
/// </summary>
public static string UserChange_BtnText {
get {
return ResourceManager.GetString("UserChange_BtnText", resourceCulture);
}
}
/// <summary>
/// 查找类似 按下此按钮将重启Steam并以该账号登录 的本地化字符串。
/// </summary>
public static string UserChange_BtnTootlip {
get {
return ResourceManager.GetString("UserChange_BtnTootlip", resourceCulture);
@@ -192,9 +192,12 @@
<data name="SteamAuth" xml:space="preserve">
<value>本地令牌</value>
</data>
<data name="UserChange_BtnTootlip" xml:space="preserve">
<data name="UserChange_BtnText" xml:space="preserve">
<value>以该账号登录Steam</value>
</data>
<data name="UserChange_BtnTootlip" xml:space="preserve">
<value>按下此按钮将重启Steam并以该账号登录</value>
</data>
<data name="UserFastChange" xml:space="preserve">
<value>账号切换</value>
</data>
@@ -18,6 +18,8 @@ namespace System.Application.UI.Resx
public static readonly IList<KeyValuePair<string, string>> Languages;
public static readonly Dictionary<string, string> SteamLanguages;
public AppResources Res { get; set; } = new AppResources();
public static CultureInfo DefaultCurrentUICulture { get; }
static R()
@@ -43,6 +45,8 @@ namespace System.Application.UI.Resx
{ "ja", "japanese" },
{ "ru", "russian" },
};
AppResources.Culture = DefaultCurrentUICulture;
}
static bool IsMatch(CultureInfo cultureInfo, string cultureName)
@@ -67,15 +71,19 @@ namespace System.Application.UI.Resx
/// <param name="cultureName"></param>
public static void ChangeLanguage(string cultureName)
{
void ChangeLanguage()
{
if (IsMatch(CultureInfo.CurrentUICulture, cultureName)) return;
CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo(cultureName);
AppResources.Culture = CultureInfo.GetCultureInfo(cultureName);
Current.Res = new AppResources();
Current.RaisePropertyChanged(nameof(Res));
}
MainThreadDesktop.BeginInvokeOnMainThread(ChangeLanguage);
//void ChangeLanguage()
//{
if (IsMatch(CultureInfo.CurrentUICulture, cultureName)) return;
// CultureInfo.CurrentUICulture = CultureInfo.GetCultureInfo(cultureName);
if (string.IsNullOrWhiteSpace(cultureName))
AppResources.Culture = null;
else
AppResources.Culture = CultureInfo.GetCultureInfo(Languages.SingleOrDefault(x => x.Key == cultureName).Key);
//AppResources.Culture = CultureInfo.GetCultureInfo(cultureName);
Current.Res = new AppResources();
Current.RaisePropertyChanged(nameof(Res));
//}
//MainThreadDesktop.BeginInvokeOnMainThread(ChangeLanguage);
}
public static string GetCurrentCultureSteamLanguageName()
@@ -83,7 +91,5 @@ namespace System.Application.UI.Resx
return AppResources.Culture == null ? Languages.First().Value : SteamLanguages[AppResources.Culture.Name];
}
//public AppResources Res => new AppResources();
public AppResources Res { get; set; } = new AppResources();
}
}
@@ -1,4 +1,6 @@
using ReactiveUI;
using System.Application.Models.Settings;
using System.Application.UI.Resx;
using System.Collections.Generic;
using System.Linq;
using System.Properties;
@@ -58,8 +60,6 @@ namespace System.Application.UI.ViewModels
(this.ASFPage = new ArchiSteamFarmPlusPageViewModel().AddTo(this)),
(this.GameRelatedPage = new GameRelatedPageViewModel().AddTo(this)),
(this.OtherPlatformPage = new OtherPlatformPageViewModel().AddTo(this)),
#region SystemTab
SettingsPageViewModel.Instance,
@@ -72,15 +72,7 @@ namespace System.Application.UI.ViewModels
this.SelectedItem = this.TabItems.First();
if (ViewModelBase.IsInDesignMode)
{
return;
}
Task.Run(Initialize).ContinueWith(s =>
{
Log.Error(nameof(MainWindowViewModel), s.Exception, nameof(Initialize) + "Action Error");
}, TaskContinuationOptions.OnlyOnFaulted)
.ContinueWith(s => s.Dispose());
Task.Run(Initialize).ForgetAndDispose();
}
@@ -1,4 +1,5 @@
using ReactiveUI;
using System.Application.Models.Settings;
using System.Application.UI.Resx;
using System.Collections.Generic;
using System.Linq;
@@ -15,22 +16,20 @@ namespace System.Application.UI.ViewModels
protected set { throw new NotImplementedException(); }
}
KeyValuePair<string, string> _SelectLanguage;
public KeyValuePair<string, string> SelectLanguage
{
get => _SelectLanguage;
protected set => this.RaiseAndSetIfChanged(ref _SelectLanguage, value);
}
public SettingsPageViewModel()
{
SelectLanguage = R.Languages.SingleOrDefault(x => x.Key == UISettings.Language.Value);
if (SelectLanguage.Key == null)
SelectLanguage = R.Languages.First();
this.WhenAnyValue(x => x.SelectLanguage)
.Subscribe(x => UISettings.Language.Value = x.Key);
}
KeyValuePair<string, string> _CurrentLanguage = R.Languages.First();
public KeyValuePair<string, string> CurrentLanguage
{
get => _CurrentLanguage;
set
{
this.RaiseAndSetIfChanged(ref _CurrentLanguage, value);
R.ChangeLanguage(_CurrentLanguage.Key);
}
}
}
}