Update Option items Notification

This commit is contained in:
ChsBuffer
2021-01-07 10:52:58 +08:00
parent 5bfcbab543
commit 6e499c3948
5 changed files with 22 additions and 15 deletions

View File

@@ -363,7 +363,6 @@ namespace Netch.Controllers
/// <returns>是否成功卸载</returns>
public static bool UninstallDriver()
{
Global.MainForm.StatusText(i18N.TranslateFormat("Uninstalling {0}", "NF Service"));
Logging.Info("卸载 NF 驱动");
try
{

View File

@@ -212,12 +212,16 @@ namespace Netch.Forms
DNS.Cache.Clear();
});
StatusText(i18N.Translate("DNS cache cleanup succeeded"));
NotifyTip(i18N.Translate("DNS cache cleanup succeeded"));
}
catch (Exception)
{
// ignored
}
finally
{
StatusText();
}
}
private void updateACLWithProxyToolStripMenuItem_Click(object sender, EventArgs e)
@@ -239,8 +243,7 @@ namespace Netch.Forms
}
Enabled = false;
NotifyTip(i18N.Translate("Updating in the background"));
StatusText(i18N.TranslateFormat("Updating {0}", "ACL"));
try
{
if (useProxy)
@@ -274,6 +277,7 @@ namespace Netch.Forms
State = State.Stopped;
}
StatusText();
Enabled = true;
}
}
@@ -282,12 +286,12 @@ namespace Netch.Forms
{
Enabled = false;
NotifyTip(i18N.Translate("Updating in the background"));
StatusText(i18N.TranslateFormat("Updating {0}", "PAC"));
try
{
var req = WebUtil.CreateRequest(Global.Settings.PAC);
string pac = Path.Combine(Global.NetchDir, $"bin\\pac.txt");
string pac = Path.Combine(Global.NetchDir, "bin\\pac.txt");
await WebUtil.DownloadFileAsync(req, pac);
@@ -300,6 +304,7 @@ namespace Netch.Forms
}
finally
{
StatusText();
Enabled = true;
}
}
@@ -314,24 +319,25 @@ namespace Netch.Forms
{
if (NFController.UninstallDriver())
{
StatusText(i18N.TranslateFormat("{0} has been uninstalled", "NF Service"));
NotifyTip(i18N.TranslateFormat("{0} has been uninstalled", "NF Service"));
}
});
}
finally
{
StatusText();
Enabled = true;
}
}
private async void UninstallTapDriverToolStripMenuItem_Click(object sender, EventArgs e)
{
StatusText(i18N.TranslateFormat("Uninstalling {0}", "TUN/TAP driver"));
Enabled = false;
StatusText(i18N.TranslateFormat("Uninstalling {0}", "TUN/TAP driver"));
try
{
await Task.Run(TUNTAP.deltapall);
StatusText(i18N.TranslateFormat("{0} has been uninstalled", "TUN/TAP driver"));
NotifyTip(i18N.TranslateFormat("{0} has been uninstalled", "TUN/TAP driver"));
}
catch (Exception exception)
{
@@ -339,7 +345,7 @@ namespace Netch.Forms
}
finally
{
State = State.Waiting;
StatusText();
Enabled = true;
}
}

View File

@@ -47,7 +47,7 @@ namespace Netch.Forms
_state = value;
StatusText(i18N.Translate(StateExtension.GetStatusString(value)));
StatusText();
switch (value)
{
case State.Waiting:
@@ -173,7 +173,7 @@ namespace Netch.Forms
/// 更新状态栏文本
/// </summary>
/// <param name="text"></param>
public void StatusText(string text)
public void StatusText(string text = null)
{
if (InvokeRequired)
{
@@ -181,6 +181,7 @@ namespace Netch.Forms
return;
}
text ??= i18N.Translate(StateExtension.GetStatusString(State));
StatusLabel.Text = i18N.Translate("Status", ": ") + text;
}

View File

@@ -348,12 +348,13 @@ namespace Netch.Forms
try
{
await Task.Run(TestServer);
Refresh();
NotifyTip(i18N.Translate("Test done"));
}
finally
{
Enabled = true;
StatusText(i18N.Translate("Test done"));
Refresh();
StatusText();
}
}

View File

@@ -67,7 +67,7 @@
"Manage Subscribe Links": "管理订阅链接",
"Update Servers From Subscribe Links": "从订阅链接更新服务器",
"No subscription link": "没有任何一条订阅链接",
"Updating in the background": "正在后台更新中",
"Updating {0}": "正在更新 {0}",
"Update {1} server(s) from {0}": "从 {0} 更新 {1} 个服务器",
"Update servers error from {0}": "从 {0} 更新服务器失败",
"Delete the corresponding group of items in the server list?": "是否删除订阅对应服务器?",