Added termination speed test

pull/4802/head
2dust 2024-02-25 18:28:59 +08:00
parent 4c5546bf52
commit 5ff4d35a30
9 changed files with 78 additions and 20 deletions

View File

@ -78,6 +78,8 @@ namespace v2rayN
public const string GrpcMultiMode = "multi";
public const int MaxPort = 65536;
public const string CommandClearMsg = "CommandClearMsg";
public const string CommandSendMsgView = "CommandSendMsgView";
public const string CommandStopSpeedTest = "CommandStopSpeedTest";
public const string DelayUnit = "";
public const string SpeedUnit = "";
public const int MinFontSize = 10;

View File

@ -21,13 +21,13 @@ namespace v2rayN.Handler
public void SendMessage(string msg)
{
MessageBus.Current.SendMessage(msg, "MsgView");
MessageBus.Current.SendMessage(msg, Global.CommandSendMsgView);
}
public void SendMessage(string msg, bool time)
{
msg = $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {msg}";
MessageBus.Current.SendMessage(msg, "MsgView");
MessageBus.Current.SendMessage(msg, Global.CommandSendMsgView);
}
}
}

View File

@ -1,4 +1,5 @@
using System.Diagnostics;
using ReactiveUI;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using v2rayN.Model;
@ -213,8 +214,24 @@ namespace v2rayN.Handler
DownloadHandle downloadHandle = new();
var exitLoop = false;
MessageBus.Current.Listen<string>(Global.CommandStopSpeedTest)
.Subscribe(x =>
{
if (!exitLoop)
{
UpdateFunc("", ResUI.SpeedtestingStop);
}
exitLoop = true;
});
foreach (var it in _selecteds)
{
if (exitLoop)
{
UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
continue;
}
if (!it.allowTest)
{
continue;
@ -270,8 +287,25 @@ namespace v2rayN.Handler
DownloadHandle downloadHandle = new();
var exitLoop = false;
MessageBus.Current.Listen<string>(Global.CommandStopSpeedTest)
.Subscribe(x =>
{
if (!exitLoop)
{
UpdateFunc("", ResUI.SpeedtestingStop);
}
exitLoop = true;
});
foreach (var it in _selecteds)
{
if (exitLoop)
{
UpdateFunc(it.indexId, "", ResUI.SpeedtestingSkip);
continue;
}
if (!it.allowTest)
{
continue;

View File

@ -916,7 +916,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Clear All 的本地化字符串。
/// 查找类似 Clear all 的本地化字符串。
/// </summary>
public static string menuMsgViewClear {
get {
@ -934,7 +934,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Copy All 的本地化字符串。
/// 查找类似 Copy all 的本地化字符串。
/// </summary>
public static string menuMsgViewCopyAll {
get {
@ -952,7 +952,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Select All (Ctrl+A) 的本地化字符串。
/// 查找类似 Select all (Ctrl+A) 的本地化字符串。
/// </summary>
public static string menuMsgViewSelectAll {
get {
@ -1123,7 +1123,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Rule Add 的本地化字符串。
/// 查找类似 Add Rule 的本地化字符串。
/// </summary>
public static string menuRuleAdd {
get {
@ -1150,7 +1150,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Remove Rules (Delete) 的本地化字符串。
/// 查找类似 Remove Rule (Delete) 的本地化字符串。
/// </summary>
public static string menuRuleRemove {
get {
@ -1159,7 +1159,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Select All (Ctrl+A) 的本地化字符串。
/// 查找类似 Select all (Ctrl+A) 的本地化字符串。
/// </summary>
public static string menuSelectAll {
get {
@ -1339,7 +1339,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Pac Mode 的本地化字符串。
/// 查找类似 PAC mode 的本地化字符串。
/// </summary>
public static string menuSystemProxyPac {
get {
@ -1780,7 +1780,16 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Waiting for testing...... 的本地化字符串。
/// 查找类似 Test terminating... 的本地化字符串。
/// </summary>
public static string SpeedtestingStop {
get {
return ResourceManager.GetString("SpeedtestingStop", resourceCulture);
}
}
/// <summary>
/// 查找类似 Waiting for testing (press ESC to terminate)... 的本地化字符串。
/// </summary>
public static string SpeedtestingWait {
get {
@ -2078,7 +2087,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Set directly by pressing the keyboard, Take effect after restart 的本地化字符串。
/// 查找类似 Set directly by pressing the keyboard, take effect after restart 的本地化字符串。
/// </summary>
public static string TbGlobalHotkeySettingTip {
get {
@ -3086,7 +3095,7 @@ namespace v2rayN.Resx {
}
/// <summary>
/// 查找类似 Pac Mode 的本地化字符串。
/// 查找类似 PAC mode 的本地化字符串。
/// </summary>
public static string TbSystemProxyPac {
get {

View File

@ -1079,7 +1079,7 @@
<value>Enable hardware acceleration(Require restart)</value>
</data>
<data name="SpeedtestingWait" xml:space="preserve">
<value>Waiting for testing......</value>
<value>Waiting for testing (press ESC to terminate)...</value>
</data>
<data name="TipDisplayLog" xml:space="preserve">
<value>Please turn off when there is an abnormal disconnection</value>
@ -1192,4 +1192,7 @@
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>Updating subscription, only determine remarks exists</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>Test terminating...</value>
</data>
</root>

View File

@ -1079,7 +1079,7 @@
<value>启用硬件加速(需重启)</value>
</data>
<data name="SpeedtestingWait" xml:space="preserve">
<value>等待测试中......</value>
<value>等待测试中按ESC终止...</value>
</data>
<data name="TipDisplayLog" xml:space="preserve">
<value>当有异常断流时请关闭</value>
@ -1189,4 +1189,7 @@
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>更新订阅时只判断别名已存在否</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>测试终止中...</value>
</data>
</root>

View File

@ -1079,7 +1079,7 @@
<value>啟用硬體加速(需重啟)</value>
</data>
<data name="SpeedtestingWait" xml:space="preserve">
<value>等待測試中......</value>
<value>等待测试中按ESC终止...</value>
</data>
<data name="TipDisplayLog" xml:space="preserve">
<value>當有異常斷流時請關閉</value>
@ -1162,4 +1162,7 @@
<data name="TbSettingsEnableUpdateSubOnlyRemarksExist" xml:space="preserve">
<value>更新訂閱時只判斷別名是否存在</value>
</data>
<data name="SpeedtestingStop" xml:space="preserve">
<value>測試終止中...</value>
</data>
</root>

View File

@ -356,6 +356,10 @@ namespace v2rayN.Views
{
ViewModel?.Reload();
}
else if (e.Key == Key.Escape)
{
MessageBus.Current.SendMessage("true", Global.CommandStopSpeedTest);
}
}
}
@ -475,10 +479,10 @@ namespace v2rayN.Views
var lvColumnItem = _config.uiItem.mainColumnItem.OrderBy(t => t.Index).ToList();
var displayIndex = 0;
foreach(var item in lvColumnItem)
foreach (var item in lvColumnItem)
{
foreach (MyDGTextColumn item2 in lstProfiles.Columns)
{
foreach (MyDGTextColumn item2 in lstProfiles.Columns)
{
if (item2.ExName == item.Name)
{
if (item.Width < 0)

View File

@ -18,7 +18,7 @@ namespace v2rayN.Views
{
InitializeComponent();
_config = LazyConfig.Instance.GetConfig();
MessageBus.Current.Listen<string>("MsgView").Subscribe(x => DelegateAppendText(x));
MessageBus.Current.Listen<string>(Global.CommandSendMsgView).Subscribe(x => DelegateAppendText(x));
Global.PresetMsgFilters.ForEach(it =>
{
cmbMsgFilter.Items.Add(it);