点击NAT label和状态灯即可重测NAT

This commit is contained in:
AmazingDM
2020-08-28 13:58:31 +08:00
parent f76a1f1a8e
commit a4081b1a7f
3 changed files with 27 additions and 0 deletions

View File

@@ -235,6 +235,22 @@ namespace Netch.Controllers
return result;
}
/// <summary>
/// 重测NAT
/// </summary>
public void RetryNatTest()
{
_ = Task.Run(() =>
{
Global.MainForm.NatTypeStatusText(i18N.Translate("Starting NatTester"));
// Thread.Sleep(1000);
var (nttResult, natType, localEnd, publicEnd) = pNTTController.Start();
var country = Utils.Utils.GetCityCode(publicEnd);
if (nttResult) Global.MainForm.NatTypeStatusText(natType, country);
});
}
/// <summary>
/// 停止
/// </summary>

View File

@@ -605,6 +605,7 @@ namespace Netch.Forms
this.NatTypeStatusLabel.Size = new System.Drawing.Size(36, 17);
this.NatTypeStatusLabel.Text = "NAT:";
this.NatTypeStatusLabel.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
this.NatTypeStatusLabel.Click += new System.EventHandler(this.NatTypeStatusLabel_Click);
//
// NatTypeStatusLightLabel
//
@@ -616,6 +617,7 @@ namespace Netch.Forms
this.NatTypeStatusLightLabel.Size = new System.Drawing.Size(18, 21);
this.NatTypeStatusLightLabel.Text = "⬤";
this.NatTypeStatusLightLabel.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.NatTypeStatusLightLabel.Click += new System.EventHandler(this.NatTypeStatusLabel_Click);
//
// ControlButton
//

View File

@@ -441,5 +441,14 @@ namespace Netch.Forms
if (!_comboBoxInitialized) return;
Global.Settings.ServerComboBoxSelectedIndex = ServerComboBox.SelectedIndex;
}
private void NatTypeStatusLabel_Click(object sender, EventArgs e)
{
//一个不太优雅的🔒
if (_state == State.Started && NatTypeStatusLabel.ToString().Contains("["))
{
_mainController.RetryNatTest();
}
}
}
}