Add option for restart after change language

This commit is contained in:
Mohsen Shahindust 2023-04-06 18:51:44 +03:30
parent cfffb5756e
commit 6315157ac7
11 changed files with 421 additions and 362 deletions

BIN
.vs/v2rayN2/v17/.wsuo Normal file

Binary file not shown.

View file

@ -39,7 +39,7 @@ namespace v2rayN
Environment.Exit(0); Environment.Exit(0);
return; return;
} }
Global.IsRestarted = (e.Args ?? new string[] { }).Any(t => t == Global.Restarted);
Global.processJob = new Job(); Global.processJob = new Job();
Logging.Setup(); Logging.Setup();

View file

@ -81,6 +81,7 @@
public const string SpeedUnit = ""; public const string SpeedUnit = "";
public const int MinFontSize = 10; public const int MinFontSize = 10;
public const string RebootAs = "rebootas"; public const string RebootAs = "rebootas";
public const string Restarted = "restarted";
public static readonly List<string> IEProxyProtocols = new() { public static readonly List<string> IEProxyProtocols = new() {
"{ip}:{http_port}", "{ip}:{http_port}",
@ -129,7 +130,7 @@
public static Job processJob { get; set; } public static Job processJob { get; set; }
public static bool ShowInTaskbar { get; set; } public static bool ShowInTaskbar { get; set; }
public static string ExePathKey { get; set; } public static string ExePathKey { get; set; }
public static bool IsRestarted { get; set; }=false;
#endregion #endregion
} }

File diff suppressed because it is too large Load diff

View file

@ -1057,4 +1057,10 @@
<data name="TbSettingsEnableHWA" xml:space="preserve"> <data name="TbSettingsEnableHWA" xml:space="preserve">
<value>فعال‌سازی شتاب‌دهنده سخت‌افزاری (نیاز به راه‌اندازی مجدد)</value> <value>فعال‌سازی شتاب‌دهنده سخت‌افزاری (نیاز به راه‌اندازی مجدد)</value>
</data> </data>
<data name="MsgChangeLanguage" xml:space="preserve">
<value>برای ایجاد تغییر آیا مایل به راه اندازی مجداد هستید؟</value>
</data>
<data name="TbChangeLanguage" xml:space="preserve">
<value>راه اندازی مجداد</value>
</data>
</root> </root>

View file

@ -1150,4 +1150,10 @@
<data name="SpeedDisplayText" xml:space="preserve"> <data name="SpeedDisplayText" xml:space="preserve">
<value>{0}:{1}/s↑ | {2}/s↓</value> <value>{0}:{1}/s↑ | {2}/s↓</value>
</data> </data>
<data name="MsgChangeLanguage" xml:space="preserve">
<value>Do you want restart to change effected?</value>
</data>
<data name="TbChangeLanguage" xml:space="preserve">
<value>Restart</value>
</data>
</root> </root>

View file

@ -1099,4 +1099,10 @@
<data name="TbSettingsEnableHWA" xml:space="preserve"> <data name="TbSettingsEnableHWA" xml:space="preserve">
<value>Включить аппаратное ускорение (требуется перезагрузка)</value> <value>Включить аппаратное ускорение (требуется перезагрузка)</value>
</data> </data>
<data name="MsgChangeLanguage" xml:space="preserve">
<value>Вы хотите перезапустить, чтобы изменения вступили в силу?</value>
</data>
<data name="TbChangeLanguage" xml:space="preserve">
<value>перезапуск</value>
</data>
</root> </root>

View file

@ -1147,4 +1147,10 @@
<data name="LvMoreUrl" xml:space="preserve"> <data name="LvMoreUrl" xml:space="preserve">
<value>更多地址(url),用逗号(,)分隔</value> <value>更多地址(url),用逗号(,)分隔</value>
</data> </data>
<data name="MsgChangeLanguage" xml:space="preserve">
<value>您要重新启动以使更改生效吗?</value>
</data>
<data name="TbChangeLanguage" xml:space="preserve">
<value>重新开始</value>
</data>
</root> </root>

View file

@ -1756,7 +1756,7 @@ namespace v2rayN.ViewModels
private void AutoHideStartup() private void AutoHideStartup()
{ {
if (_config.uiItem.autoHideStartup) if (!Global.IsRestarted && _config.uiItem.autoHideStartup)
{ {
Observable.Range(1, 1) Observable.Range(1, 1)
.Delay(TimeSpan.FromSeconds(1)) .Delay(TimeSpan.FromSeconds(1))

View file

@ -354,6 +354,7 @@
Grid.Column="1" Grid.Column="1"
Width="100" Width="100"
Margin="8" Margin="8"
SelectionChanged="cmbCurrentLanguage_SelectionChanged"
materialDesign:HintAssist.Hint="Language" materialDesign:HintAssist.Hint="Language"
Style="{StaticResource DefComboBox}" /> Style="{StaticResource DefComboBox}" />

View file

@ -1,6 +1,7 @@
using ReactiveUI; using ReactiveUI;
using Splat; using Splat;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Reactive.Disposables; using System.Reactive.Disposables;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@ -203,8 +204,9 @@ namespace v2rayN.Views
{ {
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
} }
}
}
bool Isloaded = false;
#region Event #region Event
private void UpdateViewHandler(EViewAction action) private void UpdateViewHandler(EViewAction action)
@ -596,8 +598,21 @@ namespace v2rayN.Views
} }
} }
#endregion #endregion
private void cmbCurrentLanguage_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (Isloaded)
{
if (MessageBox.Show(ResUI.MsgChangeLanguage, ResUI.TbChangeLanguage, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{
Process.Start(Process.GetCurrentProcess().MainModule.FileName,Global.Restarted);
Application.Current.Shutdown();
}
}
else
Isloaded = true;
}
} }
} }