add MessageBoxX()

This commit is contained in:
ChsBuffer
2020-07-07 01:45:48 +08:00
parent 401e348402
commit 8f1f8de906
18 changed files with 94 additions and 70 deletions

View File

@@ -49,7 +49,7 @@ namespace Netch.Controllers
}
catch (Exception e)
{
if (MessageBox.Show(i18N.Translate("Failed to set the system proxy, it may be caused by the lack of dependent programs. Do you want to jump to Netch's official website to download dependent programs?"), i18N.Translate("Information"), MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
if (MessageBoxX.Show(i18N.Translate("Failed to set the system proxy, it may be caused by the lack of dependent programs. Do you want to jump to Netch's official website to download dependent programs?"), confirm:true) == DialogResult.OK)
{
Process.Start("https://netch.org/#/?id=%e4%be%9d%e8%b5%96");
}

View File

@@ -43,12 +43,12 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Please enter a correct IP address"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please enter a correct IP address"));
}
}
else
{
MessageBox.Show(i18N.Translate("Please enter an IP"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please enter an IP"));
}
}
@@ -60,7 +60,7 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Please select an IP"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select an IP"));
}
}
@@ -73,7 +73,7 @@ namespace Netch.Forms
}
Configuration.Save();
MessageBox.Show(i18N.Translate("Saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Saved"));
Close();
}
}

View File

@@ -23,15 +23,13 @@ namespace Netch.Forms
// 服务器、模式 需选择
if (ServerComboBox.SelectedIndex == -1)
{
MessageBox.Show(i18N.Translate("Please select a server first"), i18N.Translate("Information"),
MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select a server first"));
return;
}
if (ModeComboBox.SelectedIndex == -1)
{
MessageBox.Show(i18N.Translate("Please select an mode first"), i18N.Translate("Information"),
MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select an mode first"));
return;
}
@@ -56,7 +54,7 @@ namespace Netch.Forms
//LastDownloadBandwidth = 0;
//UploadSpeedLabel.Text = "↑: 0 KB/s";
DownloadSpeedLabel.Text = "↑↓: 0 KB/s";
UsedBandwidthLabel.Text = $"{i18N.Translate("Used")}{i18N.Translate(": ")}0 KB";
UsedBandwidthLabel.Text = $"{i18N.Translate("Used",": ")}0 KB";
UsedBandwidthLabel.Visible = UploadSpeedLabel.Visible = DownloadSpeedLabel.Visible = true;
@@ -201,7 +199,7 @@ namespace Netch.Forms
}
UsedBandwidthLabel.Text =
$"{i18N.Translate("Used")}{i18N.Translate(": ")}{Bandwidth.Compute(upload + download)}";
$"{i18N.Translate("Used",": ")}{Bandwidth.Compute(upload + download)}";
UploadSpeedLabel.Text = $"↑: {Bandwidth.Compute(upload - LastUploadBandwidth)}/s";
DownloadSpeedLabel.Text = $"↓: {Bandwidth.Compute(download - LastDownloadBandwidth)}/s";

View File

@@ -38,7 +38,7 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Import servers error!"), i18N.Translate("Error"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
MessageBoxX.Show(i18N.Translate("Import servers error!"), info: false);
}
InitServer();
@@ -106,7 +106,7 @@ namespace Netch.Forms
// 当前 ServerComboBox 中至少有一项
if (ServerComboBox.SelectedIndex == -1)
{
MessageBox.Show(i18N.Translate("Please select a server first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select a server first"));
return;
}
@@ -213,7 +213,7 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("No subscription link"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("No subscription link"));
}
}
@@ -249,7 +249,7 @@ namespace Netch.Forms
NFAPI.nf_registerDriver("netfilter2");
}
MessageBox.Show(this, i18N.Translate("Service has been restarted"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Service has been restarted"), owner: this);
Enabled = true;
});
}
@@ -284,16 +284,16 @@ namespace Netch.Forms
File.Delete(driver);
MessageBox.Show(this, i18N.Translate("Service has been uninstalled"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Service has been uninstalled"), owner: this);
}
catch (Exception ex)
{
MessageBox.Show(this, i18N.Translate("Error") + i18N.Translate(": ") + ex, i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Error") + i18N.Translate(": ") + ex, info: false, owner: this);
}
}
else
{
MessageBox.Show(this, i18N.Translate("Service has been uninstalled"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Service has been uninstalled"), owner: this);
}
Enabled = true;
@@ -308,7 +308,7 @@ namespace Netch.Forms
{
InitMode();
MessageBox.Show(this, i18N.Translate("Modes have been reload"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Modes have been reload"), owner: this);
Enabled = true;
});
}
@@ -320,7 +320,7 @@ namespace Netch.Forms
{
DNS.Cache.Clear();
MessageBox.Show(this, i18N.Translate("DNS cache cleanup succeeded"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("DNS cache cleanup succeeded"), owner: this);
StatusText(i18N.Translate("DNS cache cleanup succeeded"));
Enabled = true;
});
@@ -366,7 +366,7 @@ namespace Netch.Forms
// 当前 ServerComboBox 中至少有一项
if (ServerComboBox.SelectedIndex == -1)
{
MessageBox.Show(i18N.Translate("Please select a server first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select a server first"));
return;
}
@@ -399,7 +399,7 @@ namespace Netch.Forms
catch (Exception e)
{
Logging.Info("使用代理更新 ACL 失败!" + e.Message);
MessageBox.Show(i18N.Translate("ACL update failed") + "\n" + e.Message);
MessageBoxX.Show(i18N.Translate("ACL update failed") + "\n" + e.Message);
}
finally
{
@@ -421,7 +421,7 @@ namespace Netch.Forms
// 未开启自动停止
if (!Global.Settings.StopWhenExited)
{
MessageBox.Show(i18N.Translate("Please press Stop button first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please press Stop button first"));
Visible = true;
ShowInTaskbar = true; // 显示在系统任务栏
@@ -479,7 +479,7 @@ namespace Netch.Forms
else
{
Logging.Info("ACL 更新失败!" + args.Error);
MessageBox.Show(i18N.Translate("ACL update failed") + "\n" + args.Error);
MessageBoxX.Show(i18N.Translate("ACL update failed") + "\n" + args.Error);
}
}
finally

View File

@@ -21,7 +21,7 @@ namespace Netch.Forms
{
NotifyIcon.ShowBalloonTip(5,
UpdateChecker.Name,
$"{i18N.Translate(@"New version available")}{i18N.Translate(@": ")}{updater.LatestVersionNumber}",
$"{i18N.Translate(@"New version available",": ")}{updater.LatestVersionNumber}",
ToolTipIcon.Info);
};
updater.Check(false, false);

View File

@@ -141,15 +141,15 @@ namespace Netch.Forms
{
if (ServerComboBox.SelectedIndex == -1)
{
MessageBox.Show(i18N.Translate("Please select a server first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select a server first"));
}
else if (ModeComboBox.SelectedIndex == -1)
{
MessageBox.Show(i18N.Translate("Please select an mode first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select an mode first"));
}
else if (ProfileNameText.Text == "")
{
MessageBox.Show(i18N.Translate("Please enter a profile name first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please enter a profile name first"));
}
else
{
@@ -161,7 +161,7 @@ namespace Netch.Forms
{
if (ProfileButtons[index].Text == i18N.Translate("Error") || ProfileButtons[index].Text == i18N.Translate("None"))
{
MessageBox.Show(i18N.Translate("No saved profile here. Save a profile first by Ctrl+Click on the button"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("No saved profile here. Save a profile first by Ctrl+Click on the button"));
}
try

View File

@@ -224,12 +224,14 @@ namespace Netch.Forms
ProfileGroupBox.Text = i18N.Translate("Profiles");
// 加载翻译
UsedBandwidthLabel.Text = $@"{i18N.Translate("Used")}{i18N.Translate(": ")}0 KB";
UsedBandwidthLabel.Text = $@"{i18N.Translate("Used", ": ")}0 KB";
UpdateStatus();
VersionLabel.Text = UpdateChecker.Version;
}
#region MISC
#region MISC
/// <summary>
/// 监听电源事件自动重启Netch服务
/// </summary>
@@ -285,7 +287,7 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Please select a server first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select a server first"));
}
}
@@ -324,7 +326,7 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Please select an mode first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select an mode first"));
}
}
@@ -349,7 +351,7 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Please select an mode first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select an mode first"));
}
}
@@ -370,7 +372,7 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Please select a server first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select a server first"));
}
}
@@ -393,7 +395,7 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Please select a server first"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please select a server first"));
}
}

View File

@@ -167,7 +167,7 @@ namespace Netch.Forms.Mode
}
else
{
MessageBox.Show(i18N.Translate("Please enter an process name (xxx.exe)"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please enter an process name (xxx.exe)"));
}
}
@@ -185,7 +185,7 @@ namespace Netch.Forms.Mode
if (dialog.ShowDialog(Win32Native.GetForegroundWindow()) == CommonFileDialogResult.Ok)
{
ScanDirectory(dialog.FileName);
MessageBox.Show(i18N.Translate("Scan completed"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Scan completed"));
}
}
@@ -222,14 +222,14 @@ namespace Netch.Forms.Mode
File.WriteAllText(Path.Combine("mode", FilenameTextBox.Text) + ".txt", text);
MessageBox.Show(i18N.Translate("Mode updated successfully"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Mode updated successfully"));
Global.MainForm.UpdateMode(mode, EditMode_Old);
Close();
}
else
{
MessageBox.Show(i18N.Translate("Unable to add empty rule"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Unable to add empty rule"));
}
}
else
@@ -258,7 +258,7 @@ namespace Netch.Forms.Mode
{
if (Global.Settings.ModeFileNameType == 0 && string.IsNullOrWhiteSpace(FilenameTextBox.Text))
{
MessageBox.Show(i18N.Translate("Please enter a mode filename"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please enter a mode filename"));
return;
}
var ModeFilename = Path.Combine("mode", FilenameTextBox.Text);
@@ -266,7 +266,7 @@ namespace Netch.Forms.Mode
// 如果文件已存在,返回
if (File.Exists(ModeFilename + ".txt"))
{
MessageBox.Show(i18N.Translate("File already exists.\n Please Change the filename"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("File already exists.\n Please Change the filename"));
return;
}
@@ -297,19 +297,19 @@ namespace Netch.Forms.Mode
File.WriteAllText(ModeFilename + ".txt", text);
MessageBox.Show(i18N.Translate("Mode added successfully"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Mode added successfully"));
Global.MainForm.AddMode(mode);
Close();
}
else
{
MessageBox.Show(i18N.Translate("Unable to add empty rule"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Unable to add empty rule"));
}
}
else
{
MessageBox.Show(i18N.Translate("Please enter a mode remark"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please enter a mode remark"));
}
}
}

View File

@@ -121,7 +121,7 @@ namespace Netch.Forms.Server
}
Configuration.Save();
MessageBox.Show(i18N.Translate("Saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Saved"));
Global.MainForm.InitServer();
Close();
}

View File

@@ -141,7 +141,7 @@ namespace Netch.Forms.Server
}
Configuration.Save();
MessageBox.Show(i18N.Translate("Saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Saved"));
Global.MainForm.InitServer();
Close();
}

View File

@@ -104,7 +104,7 @@ namespace Netch.Forms.Server
}
Configuration.Save();
MessageBox.Show(i18N.Translate("Saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Saved"));
Global.MainForm.InitServer();
Close();
}

View File

@@ -100,7 +100,7 @@ namespace Netch.Forms.Server
}
Configuration.Save();
MessageBox.Show(i18N.Translate("Saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Saved"));
Global.MainForm.InitServer();
Close();
}

View File

@@ -119,7 +119,7 @@ namespace Netch.Forms.Server
}
if (AlterIDTextBox.Text == "")
{
MessageBox.Show(i18N.Translate("Please fill in alterID"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Please fill in alterID"));
return;
}
if (Index == -1)
@@ -167,7 +167,7 @@ namespace Netch.Forms.Server
}
Configuration.Save();
MessageBox.Show(i18N.Translate("Saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Saved"));
Global.MainForm.InitServer();
Close();
}

View File

@@ -228,7 +228,7 @@ namespace Netch.Forms
catch (FormatException)
{
Socks5PortTextBox.Text = Global.Settings.Socks5LocalPort.ToString();
MessageBox.Show(i18N.Translate("Port value illegal. Try again."), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Port value illegal. Try again."));
return;
}
@@ -249,7 +249,7 @@ namespace Netch.Forms
catch (FormatException)
{
HTTPPortTextBox.Text = Global.Settings.HTTPLocalPort.ToString();
MessageBox.Show(i18N.Translate("Port value illegal. Try again."), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Port value illegal. Try again."));
return;
}
@@ -270,7 +270,7 @@ namespace Netch.Forms
catch (FormatException)
{
RedirectorTextBox.Text = Global.Settings.RedirectorTCPPort.ToString();
MessageBox.Show(i18N.Translate("Port value illegal. Try again."), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Port value illegal. Try again."));
return;
}
@@ -298,7 +298,7 @@ namespace Netch.Forms
}
catch (FormatException)
{
MessageBox.Show(i18N.Translate("IP address format illegal. Try again."), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("IP address format illegal. Try again."));
TUNTAPAddressTextBox.Text = Global.Settings.TUNTAP.Address;
TUNTAPNetmaskTextBox.Text = Global.Settings.TUNTAP.Netmask;
@@ -332,7 +332,7 @@ namespace Netch.Forms
catch (FormatException)
{
ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
MessageBox.Show(i18N.Translate("ProfileCount value illegal. Try again."), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("ProfileCount value illegal. Try again."));
return;
}
@@ -355,7 +355,7 @@ namespace Netch.Forms
catch (FormatException)
{
ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
MessageBox.Show(i18N.Translate("STUN_ServerPort value illegal. Try again."), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("STUN_ServerPort value illegal. Try again."));
return;
}
@@ -377,7 +377,7 @@ namespace Netch.Forms
catch (FormatException)
{
ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
MessageBox.Show(i18N.Translate("Detection interval value illegal. Try again."), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Detection interval value illegal. Try again."));
return;
}
@@ -399,7 +399,7 @@ namespace Netch.Forms
Global.Settings.TUNTAP.UseFakeDNS = UseFakeDNSCheckBox.Checked;
Configuration.Save();
MessageBox.Show(i18N.Translate("Saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Saved"));
Close();
}
}

View File

@@ -83,7 +83,7 @@ namespace Netch.Forms
}
private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show(i18N.Translate("Delete or not ? Will clean up the corresponding group of items in the server list"), i18N.Translate("Information"), MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
if (MessageBoxX.Show(i18N.Translate("Delete or not ? Will clean up the corresponding group of items in the server list"), confirm: true) == DialogResult.OK)
{
if (SubscribeLinkListView.SelectedItems.Count > 0)
{
@@ -161,7 +161,7 @@ namespace Netch.Forms
Configuration.Save();
Global.Settings.UseProxyToUpdateSubscription = UseSelectedServerCheckBox.Checked;
MessageBox.Show(i18N.Translate("Successfully saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Successfully saved"));
}
});
if (saveFlag)
@@ -182,17 +182,17 @@ namespace Netch.Forms
}
else
{
MessageBox.Show(i18N.Translate("Links must start with http:// or https://"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Links must start with http:// or https://"));
}
}
else
{
MessageBox.Show(i18N.Translate("Link can not be empty"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Link can not be empty"));
}
}
else
{
MessageBox.Show(i18N.Translate("Remark can not be empty"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Remark can not be empty"));
}
}
@@ -200,7 +200,7 @@ namespace Netch.Forms
{
Configuration.Save();
Global.Settings.UseProxyToUpdateSubscription = UseSelectedServerCheckBox.Checked;
MessageBox.Show(i18N.Translate("Successfully saved"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Successfully saved"));
Close();
}
/// <summary>

View File

@@ -62,7 +62,7 @@ namespace Netch
if (!mutex.WaitOne(0, false))
{
// 弹出提示
MessageBox.Show(i18N.Translate("Netch is already running"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show(i18N.Translate("Netch is already running"));
// 退出进程
Environment.Exit(1);
@@ -76,7 +76,7 @@ namespace Netch
{
// 弹出提示
MessageBox.Show($"{i18N.Translate("Netch is not compatible with your system.")}\n{i18N.Translate("Current arch of Netch:")} {PROC}\n{i18N.Translate("Current arch of system:")} {OS}", i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show($"{i18N.Translate("Netch is not compatible with your system.")}\n{i18N.Translate("Current arch of Netch:")} {PROC}\n{i18N.Translate("Current arch of system:")} {OS}");
// 退出进程
Environment.Exit(1);

View File

@@ -69,7 +69,7 @@ namespace Netch.Utils
else
{
// 弹出提示
MessageBox.Show("如果你是第一次使用本软件\n请务必前往http://netch.org 安装程序所需依赖,\n否则程序将无法正常运行", i18N.Translate("注意!"), MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBoxX.Show("如果你是第一次使用本软件\n请务必前往http://netch.org 安装程序所需依赖,\n否则程序将无法正常运行", i18N.Translate("注意!"));
// 创建 data 文件夹并保存默认设置
Save();
@@ -164,7 +164,7 @@ namespace Netch.Utils
if (string.IsNullOrEmpty(Global.TUNTAP.ComponentID))
{
Logging.Info("未找到可用 TUN/TAP 适配器");
if (MessageBox.Show(i18N.Translate("TUN/TAP driver is not detected. Is it installed now?"), i18N.Translate("Information"), MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
if (MessageBoxX.Show(i18N.Translate("TUN/TAP driver is not detected. Is it installed now?"),confirm:true) == DialogResult.OK)
{
addtap();
//给点时间不然立马安装完毕就查找适配器可能会导致找不到适配器ID
@@ -175,7 +175,7 @@ namespace Netch.Utils
{
return false;
}
//MessageBox.Show(i18N.Translate("Please install TAP-Windows and create an TUN/TAP adapter manually"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
//MessageBoxX.Show(i18N.Translate("Please install TAP-Windows and create an TUN/TAP adapter manually"));
// return false;
}

View File

@@ -0,0 +1,24 @@
using System.Windows.Forms;
namespace Netch.Utils
{
class MessageBoxX
{
/// <summary>
/// </summary>
/// <param name="text">内容</param>
/// <param name="title">自定义标题</param>
/// <param name="info">弹窗等级 (标题, 图标)</param>
/// <param name="confirm">需要确认</param>
/// <param name="owner">阻止 owner Focus() 直到 Messageox 被关闭</param>
public static DialogResult Show(string text, string title = "", bool info = true, bool confirm = false,IWin32Window owner = null)
{
return MessageBox.Show(
owner: owner,
text: i18N.Translate(text: text),
caption: i18N.Translate(string.IsNullOrWhiteSpace(title) ? (info ? "Information" : "Error") : title),
buttons: confirm ? MessageBoxButtons.OKCancel : MessageBoxButtons.OK,
icon: info ? MessageBoxIcon.Information : MessageBoxIcon.Exclamation);
}
}
}