Refactor ResUI

pull/2148/head
2dust 2022-03-31 19:53:58 +08:00
parent 645e6c4ec0
commit 82b6ee5ad2
20 changed files with 189 additions and 198 deletions

View File

@ -4,6 +4,7 @@ using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -67,12 +68,12 @@ namespace v2rayN.Forms
string remarks = txtRemarks.Text; string remarks = txtRemarks.Text;
if (Utils.IsNullOrEmpty(remarks)) if (Utils.IsNullOrEmpty(remarks))
{ {
UI.Show(UIRes.I18N("PleaseFillRemarks")); UI.Show(ResUI.PleaseFillRemarks);
return; return;
} }
if (Utils.IsNullOrEmpty(txtAddress.Text)) if (Utils.IsNullOrEmpty(txtAddress.Text))
{ {
UI.Show(UIRes.I18N("FillServerAddressCustom")); UI.Show(ResUI.FillServerAddressCustom);
return; return;
} }
vmessItem.remarks = remarks; vmessItem.remarks = remarks;
@ -91,7 +92,7 @@ namespace v2rayN.Forms
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }
@ -109,7 +110,7 @@ namespace v2rayN.Forms
private void btnBrowse_Click(object sender, EventArgs e) private void btnBrowse_Click(object sender, EventArgs e)
{ {
UI.Show(UIRes.I18N("CustomServerTips")); UI.Show(ResUI.CustomServerTips);
OpenFileDialog fileDialog = new OpenFileDialog OpenFileDialog fileDialog = new OpenFileDialog
{ {
@ -132,11 +133,11 @@ namespace v2rayN.Forms
if (ConfigHandler.AddCustomServer(ref config, vmessItem, false) == 0) if (ConfigHandler.AddCustomServer(ref config, vmessItem, false) == 0)
{ {
BindingServer(); BindingServer();
UI.Show(UIRes.I18N("SuccessfullyImportedCustomServer")); UI.Show(ResUI.SuccessfullyImportedCustomServer);
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("FailedImportedCustomServer")); UI.ShowWarning(ResUI.FailedImportedCustomServer);
} }
} }
@ -145,7 +146,7 @@ namespace v2rayN.Forms
var address = txtAddress.Text; var address = txtAddress.Text;
if (Utils.IsNullOrEmpty(address)) if (Utils.IsNullOrEmpty(address))
{ {
UI.Show(UIRes.I18N("FillServerAddressCustom")); UI.Show(ResUI.FillServerAddressCustom);
return; return;
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -194,24 +195,24 @@ namespace v2rayN.Forms
if (Utils.IsNullOrEmpty(address)) if (Utils.IsNullOrEmpty(address))
{ {
UI.Show(UIRes.I18N("FillServerAddress")); UI.Show(ResUI.FillServerAddress);
return; return;
} }
if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port)) if (Utils.IsNullOrEmpty(port) || !Utils.IsNumberic(port))
{ {
UI.Show(UIRes.I18N("FillCorrectServerPort")); UI.Show(ResUI.FillCorrectServerPort);
return; return;
} }
if (eConfigType == EConfigType.Shadowsocks) if (eConfigType == EConfigType.Shadowsocks)
{ {
if (Utils.IsNullOrEmpty(id)) if (Utils.IsNullOrEmpty(id))
{ {
UI.Show(UIRes.I18N("FillPassword")); UI.Show(ResUI.FillPassword);
return; return;
} }
if (Utils.IsNullOrEmpty(security)) if (Utils.IsNullOrEmpty(security))
{ {
UI.Show(UIRes.I18N("PleaseSelectEncryption")); UI.Show(ResUI.PleaseSelectEncryption);
return; return;
} }
} }
@ -219,7 +220,7 @@ namespace v2rayN.Forms
{ {
if (Utils.IsNullOrEmpty(id)) if (Utils.IsNullOrEmpty(id))
{ {
UI.Show(UIRes.I18N("FillUUID")); UI.Show(ResUI.FillUUID);
return; return;
} }
} }
@ -270,7 +271,7 @@ namespace v2rayN.Forms
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }

View File

@ -4,6 +4,7 @@ using System.Windows.Forms;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -104,7 +105,7 @@ namespace v2rayN.Forms
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -73,7 +74,7 @@ namespace v2rayN.Forms
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }

View File

@ -12,6 +12,7 @@ using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Tool; using v2rayN.Tool;
using System.Linq; using System.Linq;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -228,22 +229,22 @@ namespace v2rayN.Forms
lvServers.RegisterDragEvent(UpdateDragEventHandler); lvServers.RegisterDragEvent(UpdateDragEventHandler);
lvServers.Columns.Add("", 30); lvServers.Columns.Add("", 30);
lvServers.Columns.Add(UIRes.I18N("LvServiceType"), 80); lvServers.Columns.Add(ResUI.LvServiceType, 80);
lvServers.Columns.Add(UIRes.I18N("LvAlias"), 100); lvServers.Columns.Add(ResUI.LvAlias, 100);
lvServers.Columns.Add(UIRes.I18N("LvAddress"), 120); lvServers.Columns.Add(ResUI.LvAddress, 120);
lvServers.Columns.Add(UIRes.I18N("LvPort"), 100); lvServers.Columns.Add(ResUI.LvPort, 100);
lvServers.Columns.Add(UIRes.I18N("LvEncryptionMethod"), 120); lvServers.Columns.Add(ResUI.LvEncryptionMethod, 120);
lvServers.Columns.Add(UIRes.I18N("LvTransportProtocol"), 120); lvServers.Columns.Add(ResUI.LvTransportProtocol, 120);
lvServers.Columns.Add(UIRes.I18N("LvTLS"), 100); lvServers.Columns.Add(ResUI.LvTLS, 100);
lvServers.Columns.Add(UIRes.I18N("LvSubscription"), 100); lvServers.Columns.Add(ResUI.LvSubscription, 100);
lvServers.Columns.Add(UIRes.I18N("LvTestResults"), 120, HorizontalAlignment.Right); lvServers.Columns.Add(ResUI.LvTestResults, 120, HorizontalAlignment.Right);
if (statistics != null && statistics.Enable) if (statistics != null && statistics.Enable)
{ {
lvServers.Columns.Add(UIRes.I18N("LvTodayDownloadDataAmount"), 70); lvServers.Columns.Add(ResUI.LvTodayDownloadDataAmount, 70);
lvServers.Columns.Add(UIRes.I18N("LvTodayUploadDataAmount"), 70); lvServers.Columns.Add(ResUI.LvTodayUploadDataAmount, 70);
lvServers.Columns.Add(UIRes.I18N("LvTotalDownloadDataAmount"), 70); lvServers.Columns.Add(ResUI.LvTotalDownloadDataAmount, 70);
lvServers.Columns.Add(UIRes.I18N("LvTotalUploadDataAmount"), 70); lvServers.Columns.Add(ResUI.LvTotalUploadDataAmount, 70);
} }
lvServers.EndUpdate(); lvServers.EndUpdate();
} }
@ -485,7 +486,7 @@ namespace v2rayN.Forms
{ {
tabGroup.TabPages.Clear(); tabGroup.TabPages.Clear();
string title = $" {UIRes.I18N("AllGroupServers")} "; string title = $" {ResUI.AllGroupServers} ";
var tabPage = new TabPage(title); var tabPage = new TabPage(title);
tabPage.Name = ""; tabPage.Name = "";
tabGroup.TabPages.Add(tabPage); tabGroup.TabPages.Add(tabPage);
@ -727,7 +728,7 @@ namespace v2rayN.Forms
{ {
return; return;
} }
if (UI.ShowYesNo(UIRes.I18N("RemoveServer")) == DialogResult.No) if (UI.ShowYesNo(ResUI.RemoveServer) == DialogResult.No)
{ {
return; return;
} }
@ -744,7 +745,7 @@ namespace v2rayN.Forms
int newCount = ConfigHandler.DedupServerList(ref config, ref lstVmess); int newCount = ConfigHandler.DedupServerList(ref config, ref lstVmess);
RefreshServers(); RefreshServers();
_ = LoadV2ray(); _ = LoadV2ray();
UI.Show(string.Format(UIRes.I18N("RemoveDuplicateServerResult"), oldCount, newCount)); UI.Show(string.Format(ResUI.RemoveDuplicateServerResult, oldCount, newCount));
} }
private void menuCopyServer_Click(object sender, EventArgs e) private void menuCopyServer_Click(object sender, EventArgs e)
@ -784,11 +785,11 @@ namespace v2rayN.Forms
{ {
//if (!config.sysAgentEnabled) //if (!config.sysAgentEnabled)
//{ //{
// UI.Show(UIRes.I18N("NeedHttpGlobalProxy")); // UI.Show(ResUI.NeedHttpGlobalProxy"));
// return; // return;
//} //}
//UI.Show(UIRes.I18N("SpeedServerTips")); //UI.Show(ResUI.SpeedServerTips"));
Speedtest(ESpeedActionType.Realping); Speedtest(ESpeedActionType.Realping);
} }
@ -797,11 +798,11 @@ namespace v2rayN.Forms
{ {
//if (!config.sysAgentEnabled) //if (!config.sysAgentEnabled)
//{ //{
// UI.Show(UIRes.I18N("NeedHttpGlobalProxy")); // UI.Show(ResUI.NeedHttpGlobalProxy"));
// return; // return;
//} //}
//UI.Show(UIRes.I18N("SpeedServerTips")); //UI.Show(ResUI.SpeedServerTips"));
Speedtest(ESpeedActionType.Speedtest); Speedtest(ESpeedActionType.Speedtest);
} }
@ -816,7 +817,7 @@ namespace v2rayN.Forms
{ {
SpeedtestHandler statistics = new SpeedtestHandler(ref config); SpeedtestHandler statistics = new SpeedtestHandler(ref config);
string result = statistics.RunAvailabilityCheck() + "ms"; string result = statistics.RunAvailabilityCheck() + "ms";
AppendText(false, string.Format(UIRes.I18N("TestMeOutput"), result)); AppendText(false, string.Format(ResUI.TestMeOutput, result));
} }
private void menuClearStatistic_Click(object sender, EventArgs e) private void menuClearStatistic_Click(object sender, EventArgs e)
@ -857,8 +858,8 @@ namespace v2rayN.Forms
if (sb.Length > 0) if (sb.Length > 0)
{ {
Utils.SetClipboardData(sb.ToString()); Utils.SetClipboardData(sb.ToString());
AppendText(false, UIRes.I18N("BatchExportURLSuccessfully")); AppendText(false, ResUI.BatchExportURLSuccessfully);
//UI.Show(UIRes.I18N("BatchExportURLSuccessfully")); //UI.Show(ResUI.BatchExportURLSuccessfully"));
} }
} }
@ -880,7 +881,7 @@ namespace v2rayN.Forms
if (sb.Length > 0) if (sb.Length > 0)
{ {
Utils.SetClipboardData(Utils.Base64Encode(sb.ToString())); Utils.SetClipboardData(Utils.Base64Encode(sb.ToString()));
UI.Show(UIRes.I18N("BatchExportSubscriptionSuccessfully")); UI.Show(ResUI.BatchExportSubscriptionSuccessfully);
} }
} }
@ -950,7 +951,7 @@ namespace v2rayN.Forms
{ {
if (index < 0) if (index < 0)
{ {
UI.Show(UIRes.I18N("PleaseSelectServer")); UI.Show(ResUI.PleaseSelectServer);
return -1; return -1;
} }
if (ConfigHandler.SetDefaultServer(ref config, lstVmess[index]) == 0) if (ConfigHandler.SetDefaultServer(ref config, lstVmess[index]) == 0)
@ -973,7 +974,7 @@ namespace v2rayN.Forms
{ {
if (lvServers.SelectedIndices.Count <= 0) if (lvServers.SelectedIndices.Count <= 0)
{ {
UI.Show(UIRes.I18N("PleaseSelectServer")); UI.Show(ResUI.PleaseSelectServer);
return index; return index;
} }
@ -1020,7 +1021,7 @@ namespace v2rayN.Forms
if (ret > 0) if (ret > 0)
{ {
RefreshServers(); RefreshServers();
UI.Show(string.Format(UIRes.I18N("SuccessfullyImportedServerViaClipboard"), ret)); UI.Show(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
} }
} }
@ -1042,7 +1043,7 @@ namespace v2rayN.Forms
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
UI.ShowWarning(UIRes.I18N("NoValidQRcodeFound")); UI.ShowWarning(ResUI.NoValidQRcodeFound);
} }
else else
{ {
@ -1050,7 +1051,7 @@ namespace v2rayN.Forms
if (ret > 0) if (ret > 0)
{ {
RefreshServers(); RefreshServers();
UI.Show(UIRes.I18N("SuccessfullyImportedServerViaScan")); UI.Show(ResUI.SuccessfullyImportedServerViaScan);
} }
} }
} }
@ -1316,7 +1317,7 @@ namespace v2rayN.Forms
int index = GetLvSelectedIndex(); int index = GetLvSelectedIndex();
if (index < 0) if (index < 0)
{ {
UI.Show(UIRes.I18N("PleaseSelectServer")); UI.Show(ResUI.PleaseSelectServer);
return; return;
} }
if (ConfigHandler.MoveServer(ref config, ref lstVmess, index, eMove) == 0) if (ConfigHandler.MoveServer(ref config, ref lstVmess, index, eMove) == 0)
@ -1412,12 +1413,12 @@ namespace v2rayN.Forms
string fileName = Utils.GetPath(Utils.GetDownloadFileName(msg)); string fileName = Utils.GetPath(Utils.GetDownloadFileName(msg));
FileManager.ZipExtractToFile(fileName, config.ignoreGeoUpdateCore ? "geo" : ""); FileManager.ZipExtractToFile(fileName, config.ignoreGeoUpdateCore ? "geo" : "");
AppendText(false, UIRes.I18N("MsgUpdateV2rayCoreSuccessfullyMore")); AppendText(false, ResUI.MsgUpdateV2rayCoreSuccessfullyMore);
Global.reloadV2ray = true; Global.reloadV2ray = true;
_ = LoadV2ray(); _ = LoadV2ray();
AppendText(false, UIRes.I18N("MsgUpdateV2rayCoreSuccessfully")); AppendText(false, ResUI.MsgUpdateV2rayCoreSuccessfully);
} }
}; };
(new UpdateHandle()).CheckUpdateCore(type, config, _updateUI); (new UpdateHandle()).CheckUpdateCore(type, config, _updateUI);
@ -1659,7 +1660,7 @@ namespace v2rayN.Forms
if (fm.ShowDialog() == DialogResult.OK) if (fm.ShowDialog() == DialogResult.OK)
{ {
MsgFilter = fm.MsgFilter; MsgFilter = fm.MsgFilter;
gbMsgTitle.Text = string.Format(UIRes.I18N("MsgInformationTitle"), MsgFilter); gbMsgTitle.Text = string.Format(ResUI.MsgInformationTitle, MsgFilter);
} }
} }
#endregion #endregion

View File

@ -5,6 +5,7 @@ using System.Windows.Forms;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -101,9 +102,9 @@ namespace v2rayN.Forms
ComboItem[] cbSource = new ComboItem[] ComboItem[] cbSource = new ComboItem[]
{ {
new ComboItem{ID = (int)Global.StatisticsFreshRate.quick, Text = UIRes.I18N("QuickFresh")}, new ComboItem{ID = (int)Global.StatisticsFreshRate.quick, Text = ResUI.QuickFresh},
new ComboItem{ID = (int)Global.StatisticsFreshRate.medium, Text = UIRes.I18N("MediumFresh")}, new ComboItem{ID = (int)Global.StatisticsFreshRate.medium, Text = ResUI.MediumFresh},
new ComboItem{ID = (int)Global.StatisticsFreshRate.slow, Text = UIRes.I18N("SlowFresh")}, new ComboItem{ID = (int)Global.StatisticsFreshRate.slow, Text = ResUI.SlowFresh},
}; };
cbFreshrate.DataSource = cbSource; cbFreshrate.DataSource = cbSource;
@ -187,7 +188,7 @@ namespace v2rayN.Forms
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }
@ -211,12 +212,12 @@ namespace v2rayN.Forms
bool sniffingEnabled = chksniffingEnabled.Checked; bool sniffingEnabled = chksniffingEnabled.Checked;
if (Utils.IsNullOrEmpty(localPort) || !Utils.IsNumberic(localPort)) if (Utils.IsNullOrEmpty(localPort) || !Utils.IsNumberic(localPort))
{ {
UI.Show(UIRes.I18N("FillLocalListeningPort")); UI.Show(ResUI.FillLocalListeningPort);
return -1; return -1;
} }
if (Utils.IsNullOrEmpty(protocol)) if (Utils.IsNullOrEmpty(protocol))
{ {
UI.Show(UIRes.I18N("PleaseSelectProtocol")); UI.Show(ResUI.PleaseSelectProtocol);
return -1; return -1;
} }
@ -229,7 +230,7 @@ namespace v2rayN.Forms
{ {
if (remoteDNS.Contains("{") || remoteDNS.Contains("}")) if (remoteDNS.Contains("{") || remoteDNS.Contains("}"))
{ {
UI.Show(UIRes.I18N("FillCorrectDNSText")); UI.Show(ResUI.FillCorrectDNSText);
return -1; return -1;
} }
} }
@ -248,12 +249,12 @@ namespace v2rayN.Forms
{ {
if (Utils.IsNullOrEmpty(localPort2) || !Utils.IsNumberic(localPort2)) if (Utils.IsNullOrEmpty(localPort2) || !Utils.IsNumberic(localPort2))
{ {
UI.Show(UIRes.I18N("FillLocalListeningPort")); UI.Show(ResUI.FillLocalListeningPort);
return -1; return -1;
} }
if (Utils.IsNullOrEmpty(protocol2)) if (Utils.IsNullOrEmpty(protocol2))
{ {
UI.Show(UIRes.I18N("PleaseSelectProtocol")); UI.Show(ResUI.PleaseSelectProtocol);
return -1; return -1;
} }
if (config.inbound.Count < 2) if (config.inbound.Count < 2)
@ -312,7 +313,7 @@ namespace v2rayN.Forms
|| Utils.IsNullOrEmpty(readBufferSize) || !Utils.IsNumberic(readBufferSize) || Utils.IsNullOrEmpty(readBufferSize) || !Utils.IsNumberic(readBufferSize)
|| Utils.IsNullOrEmpty(writeBufferSize) || !Utils.IsNumberic(writeBufferSize)) || Utils.IsNullOrEmpty(writeBufferSize) || !Utils.IsNumberic(writeBufferSize))
{ {
UI.Show(UIRes.I18N("FillKcpParameters")); UI.Show(ResUI.FillKcpParameters);
return -1; return -1;
} }
config.kcpItem.mtu = Utils.ToInt(mtu); config.kcpItem.mtu = Utils.ToInt(mtu);

View File

@ -4,6 +4,7 @@ using System.Windows.Forms;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -125,7 +126,7 @@ namespace v2rayN.Forms
} }
if (!hasRule) if (!hasRule)
{ {
UI.ShowWarning(string.Format(UIRes.I18N("RoutingRuleDetailRequiredTips"), "Port/Protocol/Domain/IP")); UI.ShowWarning(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP"));
return; return;
} }
this.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK;

View File

@ -4,6 +4,7 @@ using System.Windows.Forms;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -114,7 +115,7 @@ namespace v2rayN.Forms
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }
@ -154,7 +155,7 @@ namespace v2rayN.Forms
{ {
if (lvRoutings.SelectedIndices.Count <= 0) if (lvRoutings.SelectedIndices.Count <= 0)
{ {
UI.Show(UIRes.I18N("PleaseSelectRules")); UI.Show(ResUI.PleaseSelectRules);
return index; return index;
} }
@ -198,7 +199,7 @@ namespace v2rayN.Forms
int index = GetLvSelectedIndex(); int index = GetLvSelectedIndex();
if (index < 0) if (index < 0)
{ {
UI.Show(UIRes.I18N("PleaseSelectRules")); UI.Show(ResUI.PleaseSelectRules);
return; return;
} }
if (ConfigHandler.MoveRoutingRule(ref routingItem, index, eMove) == 0) if (ConfigHandler.MoveRoutingRule(ref routingItem, index, eMove) == 0)
@ -232,7 +233,7 @@ namespace v2rayN.Forms
{ {
return; return;
} }
if (UI.ShowYesNo(UIRes.I18N("RemoveRules")) == DialogResult.No) if (UI.ShowYesNo(ResUI.RemoveRules) == DialogResult.No)
{ {
return; return;
} }
@ -253,7 +254,7 @@ namespace v2rayN.Forms
if (lst.Count > 0) if (lst.Count > 0)
{ {
Utils.SetClipboardData(Utils.ToJson(lst)); Utils.SetClipboardData(Utils.ToJson(lst));
//UI.Show(UIRes.I18N("OperationSuccess")); //UI.Show(ResUI.OperationSuccess"));
} }
} }
@ -323,7 +324,7 @@ namespace v2rayN.Forms
if (AddBatchRoutingRules(ref routingItem, result) == 0) if (AddBatchRoutingRules(ref routingItem, result) == 0)
{ {
RefreshRoutingsView(); RefreshRoutingsView();
UI.Show(UIRes.I18N("OperationSuccess")); UI.Show(ResUI.OperationSuccess);
} }
} }
@ -333,7 +334,7 @@ namespace v2rayN.Forms
if (AddBatchRoutingRules(ref routingItem, clipboardData) == 0) if (AddBatchRoutingRules(ref routingItem, clipboardData) == 0)
{ {
RefreshRoutingsView(); RefreshRoutingsView();
UI.Show(UIRes.I18N("OperationSuccess")); UI.Show(ResUI.OperationSuccess);
} }
} }
private void menuImportRulesFromUrl_Click(object sender, EventArgs e) private void menuImportRulesFromUrl_Click(object sender, EventArgs e)
@ -341,7 +342,7 @@ namespace v2rayN.Forms
var url = txtUrl.Text.Trim(); var url = txtUrl.Text.Trim();
if (Utils.IsNullOrEmpty(url)) if (Utils.IsNullOrEmpty(url))
{ {
UI.Show(UIRes.I18N("MsgNeedUrl")); UI.Show(ResUI.MsgNeedUrl);
return; return;
} }
DownloadHandle downloadHandle = new DownloadHandle(); DownloadHandle downloadHandle = new DownloadHandle();
@ -349,13 +350,13 @@ namespace v2rayN.Forms
if (AddBatchRoutingRules(ref routingItem, clipboardData) == 0) if (AddBatchRoutingRules(ref routingItem, clipboardData) == 0)
{ {
RefreshRoutingsView(); RefreshRoutingsView();
UI.Show(UIRes.I18N("OperationSuccess")); UI.Show(ResUI.OperationSuccess);
} }
} }
private int AddBatchRoutingRules(ref RoutingItem routingItem, string clipboardData) private int AddBatchRoutingRules(ref RoutingItem routingItem, string clipboardData)
{ {
bool blReplace = false; bool blReplace = false;
if (UI.ShowYesNo(UIRes.I18N("AddBatchRoutingRulesYesNo")) == DialogResult.No) if (UI.ShowYesNo(ResUI.AddBatchRoutingRulesYesNo) == DialogResult.No)
{ {
blReplace = true; blReplace = true;
} }

View File

@ -4,6 +4,7 @@ using System.Windows.Forms;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -61,7 +62,7 @@ namespace v2rayN.Forms
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }
@ -144,10 +145,10 @@ namespace v2rayN.Forms
lvRoutings.HeaderStyle = ColumnHeaderStyle.Clickable; lvRoutings.HeaderStyle = ColumnHeaderStyle.Clickable;
lvRoutings.Columns.Add("", 30); lvRoutings.Columns.Add("", 30);
lvRoutings.Columns.Add(UIRes.I18N("LvAlias"), 200); lvRoutings.Columns.Add(ResUI.LvAlias, 200);
lvRoutings.Columns.Add(UIRes.I18N("LvCount"), 60); lvRoutings.Columns.Add(ResUI.LvCount, 60);
lvRoutings.Columns.Add(UIRes.I18N("LvUrl"), 240); lvRoutings.Columns.Add(ResUI.LvUrl, 240);
lvRoutings.Columns.Add(UIRes.I18N("LvCustomIcon"), 240); lvRoutings.Columns.Add(ResUI.LvCustomIcon, 240);
lvRoutings.EndUpdate(); lvRoutings.EndUpdate();
} }
@ -211,7 +212,7 @@ namespace v2rayN.Forms
{ {
if (lvRoutings.SelectedIndices.Count <= 0) if (lvRoutings.SelectedIndices.Count <= 0)
{ {
UI.Show(UIRes.I18N("PleaseSelectRules")); UI.Show(ResUI.PleaseSelectRules);
return index; return index;
} }
@ -259,7 +260,7 @@ namespace v2rayN.Forms
{ {
return; return;
} }
if (UI.ShowYesNo(UIRes.I18N("RemoveRules")) == DialogResult.No) if (UI.ShowYesNo(ResUI.RemoveRules) == DialogResult.No)
{ {
return; return;
} }
@ -282,7 +283,7 @@ namespace v2rayN.Forms
{ {
if (index < 0) if (index < 0)
{ {
UI.Show(UIRes.I18N("PleaseSelectServer")); UI.Show(ResUI.PleaseSelectServer);
return -1; return -1;
} }
if (ConfigHandler.SetDefaultRouting(ref config, index) == 0) if (ConfigHandler.SetDefaultRouting(ref config, index) == 0)
@ -301,7 +302,7 @@ namespace v2rayN.Forms
txtBlockDomain.Text = "geosite:category-ads-all"; txtBlockDomain.Text = "geosite:category-ads-all";
UI.Show(UIRes.I18N("OperationSuccess")); UI.Show(ResUI.OperationSuccess);
} }
private void menuImportAdvancedRules_Click(object sender, EventArgs e) private void menuImportAdvancedRules_Click(object sender, EventArgs e)

View File

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -156,34 +157,34 @@ namespace v2rayN.Forms
if (network.Equals(Global.DefaultNetwork)) if (network.Equals(Global.DefaultNetwork))
{ {
tipRequestHost.Text = UIRes.I18N("TransportRequestHostTip1"); tipRequestHost.Text = ResUI.TransportRequestHostTip1;
tipHeaderType.Text = UIRes.I18N("TransportHeaderTypeTip1"); tipHeaderType.Text = ResUI.TransportHeaderTypeTip1;
} }
else if (network.Equals("kcp")) else if (network.Equals("kcp"))
{ {
tipHeaderType.Text = UIRes.I18N("TransportHeaderTypeTip2"); tipHeaderType.Text = ResUI.TransportHeaderTypeTip2;
tipPath.Text = UIRes.I18N("TransportPathTip5"); tipPath.Text = ResUI.TransportPathTip5;
} }
else if (network.Equals("ws")) else if (network.Equals("ws"))
{ {
tipRequestHost.Text = UIRes.I18N("TransportRequestHostTip2"); tipRequestHost.Text = ResUI.TransportRequestHostTip2;
tipPath.Text = UIRes.I18N("TransportPathTip1"); tipPath.Text = ResUI.TransportPathTip1;
} }
else if (network.Equals("h2")) else if (network.Equals("h2"))
{ {
tipRequestHost.Text = UIRes.I18N("TransportRequestHostTip3"); tipRequestHost.Text = ResUI.TransportRequestHostTip3;
tipPath.Text = UIRes.I18N("TransportPathTip2"); tipPath.Text = ResUI.TransportPathTip2;
} }
else if (network.Equals("quic")) else if (network.Equals("quic"))
{ {
tipRequestHost.Text = UIRes.I18N("TransportRequestHostTip4"); tipRequestHost.Text = ResUI.TransportRequestHostTip4;
tipPath.Text = UIRes.I18N("TransportPathTip3"); tipPath.Text = ResUI.TransportPathTip3;
tipHeaderType.Text = UIRes.I18N("TransportHeaderTypeTip3"); tipHeaderType.Text = ResUI.TransportHeaderTypeTip3;
} }
else if (network.Equals("grpc")) else if (network.Equals("grpc"))
{ {
tipPath.Text = UIRes.I18N("TransportPathTip4"); tipPath.Text = ResUI.TransportPathTip4;
tipHeaderType.Text = UIRes.I18N("TransportHeaderTypeTip4"); tipHeaderType.Text = ResUI.TransportHeaderTypeTip4;
labHeaderType.Visible = false; labHeaderType.Visible = false;
} }
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
using v2rayN.Handler; using v2rayN.Handler;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Forms namespace v2rayN.Forms
{ {
@ -74,7 +75,7 @@ namespace v2rayN.Forms
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }

View File

@ -3,6 +3,7 @@ using System.IO;
using System.Net; using System.Net;
using System.Text; using System.Text;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@ -39,7 +40,7 @@ namespace v2rayN.Handler
try try
{ {
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13); Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, UIRes.I18N("Downloading"))); UpdateCompleted?.Invoke(this, new ResultEventArgs(false, ResUI.Downloading));
progressPercentage = -1; progressPercentage = -1;
totalBytesToReceive = 0; totalBytesToReceive = 0;
@ -215,7 +216,7 @@ namespace v2rayN.Handler
try try
{ {
Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13); Utils.SetSecurityProtocol(LazyConfig.Instance.GetConfig().enableSecurityProtocolTls13);
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, UIRes.I18N("Downloading"))); UpdateCompleted?.Invoke(this, new ResultEventArgs(false, ResUI.Downloading));
progressPercentage = -1; progressPercentage = -1;
totalBytesToReceive = 0; totalBytesToReceive = 0;

View File

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using v2rayN.Mode; using v2rayN.Mode;
using System.Linq; using System.Linq;
using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@ -88,7 +89,7 @@ namespace v2rayN.Handler
if (item.configType != EConfigType.Vmess if (item.configType != EConfigType.Vmess
&& item.configType != EConfigType.VLESS) && item.configType != EConfigType.VLESS)
{ {
UI.Show(UIRes.I18N("NonVmessService")); UI.Show(ResUI.NonVmessService);
return; return;
} }
@ -115,7 +116,7 @@ namespace v2rayN.Handler
} }
else else
{ {
UI.ShowWarning(string.Format(UIRes.I18N("SaveClientConfigurationIn"), fileName)); UI.ShowWarning(string.Format(ResUI.SaveClientConfigurationIn, fileName));
} }
} }
@ -128,7 +129,7 @@ namespace v2rayN.Handler
if (item.configType != EConfigType.Vmess if (item.configType != EConfigType.Vmess
&& item.configType != EConfigType.VLESS) && item.configType != EConfigType.VLESS)
{ {
UI.Show(UIRes.I18N("NonVmessService")); UI.Show(ResUI.NonVmessService);
return; return;
} }
@ -155,7 +156,7 @@ namespace v2rayN.Handler
} }
else else
{ {
UI.ShowWarning(string.Format(UIRes.I18N("SaveServerConfigurationIn"), fileName)); UI.ShowWarning(string.Format(ResUI.SaveServerConfigurationIn, fileName));
} }
} }
@ -191,11 +192,11 @@ namespace v2rayN.Handler
if (ret == 0) if (ret == 0)
{ {
UI.Show(UIRes.I18N("OperationSuccess")); UI.Show(ResUI.OperationSuccess);
} }
else else
{ {
UI.ShowWarning(UIRes.I18N("OperationFailed")); UI.ShowWarning(ResUI.OperationFailed);
} }
} }
} }
@ -268,12 +269,12 @@ namespace v2rayN.Handler
try try
{ {
HotkeyManager.Current.AddOrReplace(((int)item.eGlobalHotkey).ToString(), keys, handler); HotkeyManager.Current.AddOrReplace(((int)item.eGlobalHotkey).ToString(), keys, handler);
var msg = string.Format(UIRes.I18N("RegisterGlobalHotkeySuccessfully"), $"{item.eGlobalHotkey.ToString()} = {keys}"); var msg = string.Format(ResUI.RegisterGlobalHotkeySuccessfully, $"{item.eGlobalHotkey.ToString()} = {keys}");
update(false, msg); update(false, msg);
} }
catch (Exception ex) catch (Exception ex)
{ {
var msg = string.Format(UIRes.I18N("RegisterGlobalHotkeyFailed"), $"{item.eGlobalHotkey.ToString()} = {keys}", ex.Message); var msg = string.Format(ResUI.RegisterGlobalHotkeyFailed, $"{item.eGlobalHotkey.ToString()} = {keys}", ex.Message);
update(false, msg); update(false, msg);
Utils.SaveLog(msg); Utils.SaveLog(msg);
} }

View File

@ -9,6 +9,7 @@ using System.Threading.Tasks;
using System.Web; using System.Web;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@ -318,7 +319,7 @@ namespace v2rayN.Handler
string result = clipboardData.TrimEx();// Utils.GetClipboardData(); string result = clipboardData.TrimEx();// Utils.GetClipboardData();
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
msg = UIRes.I18N("FailedReadConfiguration"); msg = ResUI.FailedReadConfiguration;
return null; return null;
} }
@ -338,7 +339,7 @@ namespace v2rayN.Handler
} }
else if (result.StartsWith(Global.ssProtocol)) else if (result.StartsWith(Global.ssProtocol))
{ {
msg = UIRes.I18N("ConfigurationFormatIncorrect"); msg = ResUI.ConfigurationFormatIncorrect;
vmessItem = ResolveSSLegacy(result); vmessItem = ResolveSSLegacy(result);
if (vmessItem == null) if (vmessItem == null)
@ -358,7 +359,7 @@ namespace v2rayN.Handler
} }
else if (result.StartsWith(Global.socksProtocol)) else if (result.StartsWith(Global.socksProtocol))
{ {
msg = UIRes.I18N("ConfigurationFormatIncorrect"); msg = ResUI.ConfigurationFormatIncorrect;
vmessItem = ResolveSocksNew(result); vmessItem = ResolveSocksNew(result);
if (vmessItem == null) if (vmessItem == null)
@ -378,7 +379,7 @@ namespace v2rayN.Handler
} }
else if (result.StartsWith(Global.trojanProtocol)) else if (result.StartsWith(Global.trojanProtocol))
{ {
msg = UIRes.I18N("ConfigurationFormatIncorrect"); msg = ResUI.ConfigurationFormatIncorrect;
vmessItem = ResolveTrojan(result); vmessItem = ResolveTrojan(result);
} }
@ -390,13 +391,13 @@ namespace v2rayN.Handler
} }
else else
{ {
msg = UIRes.I18N("NonvmessOrssProtocol"); msg = ResUI.NonvmessOrssProtocol;
return null; return null;
} }
} }
catch catch
{ {
msg = UIRes.I18N("Incorrectconfiguration"); msg = ResUI.Incorrectconfiguration;
return null; return null;
} }
@ -416,7 +417,7 @@ namespace v2rayN.Handler
VmessQRCode vmessQRCode = Utils.FromJson<VmessQRCode>(result); VmessQRCode vmessQRCode = Utils.FromJson<VmessQRCode>(result);
if (vmessQRCode == null) if (vmessQRCode == null)
{ {
msg = UIRes.I18N("FailedConversionConfiguration"); msg = ResUI.FailedConversionConfiguration;
return null; return null;
} }

View File

@ -6,6 +6,7 @@ using System.Net.Sockets;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@ -117,7 +118,7 @@ namespace v2rayN.Handler
pid = _v2rayHandler.LoadV2rayConfigString(_config, _selecteds); pid = _v2rayHandler.LoadV2rayConfigString(_config, _selecteds);
if (pid < 0) if (pid < 0)
{ {
_updateFunc(_selecteds[0].indexId, UIRes.I18N("OperationFailed")); _updateFunc(_selecteds[0].indexId, ResUI.OperationFailed);
return; return;
} }
@ -203,7 +204,7 @@ namespace v2rayN.Handler
pid = _v2rayHandler.LoadV2rayConfigString(_config, _selecteds); pid = _v2rayHandler.LoadV2rayConfigString(_config, _selecteds);
if (pid < 0) if (pid < 0)
{ {
_updateFunc(_selecteds[0].indexId, UIRes.I18N("OperationFailed")); _updateFunc(_selecteds[0].indexId, ResUI.OperationFailed);
return; return;
} }

View File

@ -8,6 +8,7 @@ using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@ -53,7 +54,7 @@ namespace v2rayN.Handler
{ {
if (args.Success) if (args.Success)
{ {
_updateFunc(false, UIRes.I18N("MsgDownloadV2rayCoreSuccessfully")); _updateFunc(false, ResUI.MsgDownloadV2rayCoreSuccessfully);
try try
{ {
@ -93,7 +94,7 @@ namespace v2rayN.Handler
{ {
if (args.Success) if (args.Success)
{ {
_updateFunc(false, string.Format(UIRes.I18N("MsgParsingSuccessfully"), "v2rayN")); _updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, "v2rayN"));
url = args.Msg; url = args.Msg;
askToDownload(downloadHandle, url, true); askToDownload(downloadHandle, url, true);
@ -103,7 +104,7 @@ namespace v2rayN.Handler
_updateFunc(false, args.Msg); _updateFunc(false, args.Msg);
} }
}; };
_updateFunc(false, string.Format(UIRes.I18N("MsgStartUpdating"), "v2rayN")); _updateFunc(false, string.Format(ResUI.MsgStartUpdating, "v2rayN"));
CheckUpdateAsync(ECoreType.v2rayN); CheckUpdateAsync(ECoreType.v2rayN);
} }
@ -122,8 +123,8 @@ namespace v2rayN.Handler
{ {
if (args.Success) if (args.Success)
{ {
_updateFunc(false, UIRes.I18N("MsgDownloadV2rayCoreSuccessfully")); _updateFunc(false, ResUI.MsgDownloadV2rayCoreSuccessfully);
_updateFunc(false, UIRes.I18N("MsgUnpacking")); _updateFunc(false, ResUI.MsgUnpacking);
try try
{ {
@ -149,7 +150,7 @@ namespace v2rayN.Handler
{ {
if (args.Success) if (args.Success)
{ {
_updateFunc(false, string.Format(UIRes.I18N("MsgParsingSuccessfully"), "Core")); _updateFunc(false, string.Format(ResUI.MsgParsingSuccessfully, "Core"));
url = args.Msg; url = args.Msg;
askToDownload(downloadHandle, url, true); askToDownload(downloadHandle, url, true);
} }
@ -158,7 +159,7 @@ namespace v2rayN.Handler
_updateFunc(false, args.Msg); _updateFunc(false, args.Msg);
} }
}; };
_updateFunc(false, string.Format(UIRes.I18N("MsgStartUpdating"), "Core")); _updateFunc(false, string.Format(ResUI.MsgStartUpdating, "Core"));
CheckUpdateAsync(type); CheckUpdateAsync(type);
} }
@ -168,11 +169,11 @@ namespace v2rayN.Handler
_config = config; _config = config;
_updateFunc = update; _updateFunc = update;
_updateFunc(false, UIRes.I18N("MsgUpdateSubscriptionStart")); _updateFunc(false, ResUI.MsgUpdateSubscriptionStart);
if (config.subItem == null || config.subItem.Count <= 0) if (config.subItem == null || config.subItem.Count <= 0)
{ {
_updateFunc(false, UIRes.I18N("MsgNoValidSubscription")); _updateFunc(false, ResUI.MsgNoValidSubscription);
return; return;
} }
@ -189,7 +190,7 @@ namespace v2rayN.Handler
} }
if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url)) if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url))
{ {
_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgNoValidSubscription")}"); _updateFunc(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
continue; continue;
} }
@ -198,17 +199,17 @@ namespace v2rayN.Handler
{ {
if (args.Success) if (args.Success)
{ {
_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgGetSubscriptionSuccessfully")}"); _updateFunc(false, $"{hashCode}{ResUI.MsgGetSubscriptionSuccessfully}");
//string result = Utils.Base64Decode(args.Msg); //string result = Utils.Base64Decode(args.Msg);
string result = args.Msg; string result = args.Msg;
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgSubscriptionDecodingFailed")}"); _updateFunc(false, $"{hashCode}{ResUI.MsgSubscriptionDecodingFailed}");
return; return;
} }
//ConfigHandler.RemoveServerViaSubid(ref config, id); //ConfigHandler.RemoveServerViaSubid(ref config, id);
//_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgClearSubscription")}"); //_updateFunc(false, $"{hashCode}{ResUI.MsgClearSubscription")}");
// RefreshServers(); // RefreshServers();
int ret = ConfigHandler.AddBatchServers(ref config, result, id, groupId); int ret = ConfigHandler.AddBatchServers(ref config, result, id, groupId);
if (ret > 0) if (ret > 0)
@ -217,9 +218,9 @@ namespace v2rayN.Handler
} }
else else
{ {
_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgFailedImportSubscription")}"); _updateFunc(false, $"{hashCode}{ResUI.MsgFailedImportSubscription}");
} }
_updateFunc(true, $"{hashCode}{UIRes.I18N("MsgUpdateSubscriptionEnd")}"); _updateFunc(true, $"{hashCode}{ResUI.MsgUpdateSubscriptionEnd}");
} }
else else
{ {
@ -234,7 +235,7 @@ namespace v2rayN.Handler
WebProxy webProxy = blProxy ? new WebProxy(Global.Loopback, _config.GetLocalPort(Global.InboundHttp)) : null; WebProxy webProxy = blProxy ? new WebProxy(Global.Loopback, _config.GetLocalPort(Global.InboundHttp)) : null;
downloadHandle3.WebDownloadString(url, webProxy, userAgent); downloadHandle3.WebDownloadString(url, webProxy, userAgent);
_updateFunc(false, $"{hashCode}{UIRes.I18N("MsgStartGettingSubscriptions")}"); _updateFunc(false, $"{hashCode}{ResUI.MsgStartGettingSubscriptions}");
} }
} }
@ -255,7 +256,7 @@ namespace v2rayN.Handler
{ {
if (args.Success) if (args.Success)
{ {
_updateFunc(false, string.Format(UIRes.I18N("MsgDownloadGeoFileSuccessfully"), geoName)); _updateFunc(false, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, geoName));
try try
{ {
@ -366,7 +367,7 @@ namespace v2rayN.Handler
string filePath = Utils.GetPath(core); string filePath = Utils.GetPath(core);
if (!File.Exists(filePath)) if (!File.Exists(filePath))
{ {
string msg = string.Format(UIRes.I18N("NotFoundCore"), @""); string msg = string.Format(ResUI.NotFoundCore, @"");
//ShowMsg(true, msg); //ShowMsg(true, msg);
return ""; return "";
} }
@ -404,21 +405,21 @@ namespace v2rayN.Handler
if (type == ECoreType.v2fly) if (type == ECoreType.v2fly)
{ {
curVersion = "v" + getCoreVersion(type); curVersion = "v" + getCoreVersion(type);
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion); message = string.Format(ResUI.IsLatestCore, curVersion);
string osBit = Environment.Is64BitProcess ? "64" : "32"; string osBit = Environment.Is64BitProcess ? "64" : "32";
url = string.Format(v2flyCoreUrl, version, osBit); url = string.Format(v2flyCoreUrl, version, osBit);
} }
else if (type == ECoreType.Xray) else if (type == ECoreType.Xray)
{ {
curVersion = "v" + getCoreVersion(type); curVersion = "v" + getCoreVersion(type);
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion); message = string.Format(ResUI.IsLatestCore, curVersion);
string osBit = Environment.Is64BitProcess ? "64" : "32"; string osBit = Environment.Is64BitProcess ? "64" : "32";
url = string.Format(xrayCoreUrl, version, osBit); url = string.Format(xrayCoreUrl, version, osBit);
} }
else if (type == ECoreType.v2rayN) else if (type == ECoreType.v2rayN)
{ {
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString(); curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
message = string.Format(UIRes.I18N("IsLatestN"), curVersion); message = string.Format(ResUI.IsLatestN, curVersion);
url = string.Format(nUrl, version); url = string.Format(nUrl, version);
} }
else else
@ -446,7 +447,7 @@ namespace v2rayN.Handler
bool blDownload = false; bool blDownload = false;
if (blAsk) if (blAsk)
{ {
if (UI.ShowYesNo(string.Format(UIRes.I18N("DownloadYesNo"), url)) == DialogResult.Yes) if (UI.ShowYesNo(string.Format(ResUI.DownloadYesNo, url)) == DialogResult.Yes)
{ {
blDownload = true; blDownload = true;
} }

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using v2rayN.Base; using v2rayN.Base;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@ -32,11 +33,11 @@ namespace v2rayN.Handler
{ {
if (node == null) if (node == null)
{ {
msg = UIRes.I18N("CheckServerSettings"); msg = ResUI.CheckServerSettings;
return -1; return -1;
} }
msg = UIRes.I18N("InitialConfiguration"); msg = ResUI.InitialConfiguration;
if (node.configType == EConfigType.Custom) if (node.configType == EConfigType.Custom)
{ {
return GenerateClientCustomConfig(node, fileName, out msg); return GenerateClientCustomConfig(node, fileName, out msg);
@ -46,7 +47,7 @@ namespace v2rayN.Handler
string result = Utils.GetEmbedText(SampleClient); string result = Utils.GetEmbedText(SampleClient);
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
msg = UIRes.I18N("FailedGetDefaultConfiguration"); msg = ResUI.FailedGetDefaultConfiguration;
return -1; return -1;
} }
@ -54,7 +55,7 @@ namespace v2rayN.Handler
V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result); V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result);
if (v2rayConfig == null) if (v2rayConfig == null)
{ {
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return -1; return -1;
} }
@ -80,11 +81,11 @@ namespace v2rayN.Handler
Utils.ToJsonFile(v2rayConfig, fileName, false); Utils.ToJsonFile(v2rayConfig, fileName, false);
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), $"[{config.GetGroupRemarks(node.groupId)}] {node.GetSummary()}"); msg = string.Format(ResUI.SuccessfulConfiguration, $"[{config.GetGroupRemarks(node.groupId)}] {node.GetSummary()}");
} }
catch catch
{ {
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return -1; return -1;
} }
return 0; return 0;
@ -901,7 +902,7 @@ namespace v2rayN.Handler
//检查GUI设置 //检查GUI设置
if (node == null) if (node == null)
{ {
msg = UIRes.I18N("CheckServerSettings"); msg = ResUI.CheckServerSettings;
return -1; return -1;
} }
@ -917,7 +918,7 @@ namespace v2rayN.Handler
} }
if (!File.Exists(addressFileName)) if (!File.Exists(addressFileName))
{ {
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return -1; return -1;
} }
File.Copy(addressFileName, fileName); File.Copy(addressFileName, fileName);
@ -925,7 +926,7 @@ namespace v2rayN.Handler
//check again //check again
if (!File.Exists(fileName)) if (!File.Exists(fileName))
{ {
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return -1; return -1;
} }
@ -944,12 +945,12 @@ namespace v2rayN.Handler
} }
File.WriteAllLines(fileName, fileContent); File.WriteAllLines(fileName, fileContent);
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), $"[{LazyConfig.Instance.GetConfig().GetGroupRemarks(node.groupId)}] {node.GetSummary()}"); msg = string.Format(ResUI.SuccessfulConfiguration, $"[{LazyConfig.Instance.GetConfig().GetGroupRemarks(node.groupId)}] {node.GetSummary()}");
} }
catch (Exception ex) catch (Exception ex)
{ {
Utils.SaveLog("GenerateClientCustomConfig", ex); Utils.SaveLog("GenerateClientCustomConfig", ex);
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return -1; return -1;
} }
return 0; return 0;
@ -973,17 +974,17 @@ namespace v2rayN.Handler
//检查GUI设置 //检查GUI设置
if (node == null) if (node == null)
{ {
msg = UIRes.I18N("CheckServerSettings"); msg = ResUI.CheckServerSettings;
return -1; return -1;
} }
msg = UIRes.I18N("InitialConfiguration"); msg = ResUI.InitialConfiguration;
//取得默认配置 //取得默认配置
string result = Utils.GetEmbedText(SampleServer); string result = Utils.GetEmbedText(SampleServer);
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
msg = UIRes.I18N("FailedGetDefaultConfiguration"); msg = ResUI.FailedGetDefaultConfiguration;
return -1; return -1;
} }
@ -991,7 +992,7 @@ namespace v2rayN.Handler
V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result); V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result);
if (v2rayConfig == null) if (v2rayConfig == null)
{ {
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return -1; return -1;
} }
@ -1008,11 +1009,11 @@ namespace v2rayN.Handler
Utils.ToJsonFile(v2rayConfig, fileName, false); Utils.ToJsonFile(v2rayConfig, fileName, false);
msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), node.GetSummary()); msg = string.Format(ResUI.SuccessfulConfiguration, node.GetSummary());
} }
catch catch
{ {
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return -1; return -1;
} }
return 0; return 0;
@ -1110,7 +1111,7 @@ namespace v2rayN.Handler
string result = Utils.LoadResource(fileName); string result = Utils.LoadResource(fileName);
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
msg = UIRes.I18N("FailedReadConfiguration"); msg = ResUI.FailedReadConfiguration;
return null; return null;
} }
@ -1118,14 +1119,14 @@ namespace v2rayN.Handler
V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result); V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result);
if (v2rayConfig == null) if (v2rayConfig == null)
{ {
msg = UIRes.I18N("FailedConversionConfiguration"); msg = ResUI.FailedConversionConfiguration;
return null; return null;
} }
if (v2rayConfig.outbounds == null if (v2rayConfig.outbounds == null
|| v2rayConfig.outbounds.Count <= 0) || v2rayConfig.outbounds.Count <= 0)
{ {
msg = UIRes.I18N("IncorrectClientConfiguration"); msg = ResUI.IncorrectClientConfiguration;
return null; return null;
} }
@ -1139,7 +1140,7 @@ namespace v2rayN.Handler
|| outbound.settings.vnext[0].users == null || outbound.settings.vnext[0].users == null
|| outbound.settings.vnext[0].users.Count <= 0) || outbound.settings.vnext[0].users.Count <= 0)
{ {
msg = UIRes.I18N("IncorrectClientConfiguration"); msg = ResUI.IncorrectClientConfiguration;
return null; return null;
} }
@ -1232,7 +1233,7 @@ namespace v2rayN.Handler
} }
catch catch
{ {
msg = UIRes.I18N("IncorrectClientConfiguration"); msg = ResUI.IncorrectClientConfiguration;
return null; return null;
} }
@ -1256,7 +1257,7 @@ namespace v2rayN.Handler
string result = Utils.LoadResource(fileName); string result = Utils.LoadResource(fileName);
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
msg = UIRes.I18N("FailedReadConfiguration"); msg = ResUI.FailedReadConfiguration;
return null; return null;
} }
@ -1264,14 +1265,14 @@ namespace v2rayN.Handler
V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result); V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result);
if (v2rayConfig == null) if (v2rayConfig == null)
{ {
msg = UIRes.I18N("FailedConversionConfiguration"); msg = ResUI.FailedConversionConfiguration;
return null; return null;
} }
if (v2rayConfig.inbounds == null if (v2rayConfig.inbounds == null
|| v2rayConfig.inbounds.Count <= 0) || v2rayConfig.inbounds.Count <= 0)
{ {
msg = UIRes.I18N("IncorrectServerConfiguration"); msg = ResUI.IncorrectServerConfiguration;
return null; return null;
} }
@ -1283,7 +1284,7 @@ namespace v2rayN.Handler
|| inbound.settings.clients == null || inbound.settings.clients == null
|| inbound.settings.clients.Count <= 0) || inbound.settings.clients.Count <= 0)
{ {
msg = UIRes.I18N("IncorrectServerConfiguration"); msg = ResUI.IncorrectServerConfiguration;
return null; return null;
} }
@ -1377,7 +1378,7 @@ namespace v2rayN.Handler
} }
catch catch
{ {
msg = UIRes.I18N("IncorrectClientConfiguration"); msg = ResUI.IncorrectClientConfiguration;
return null; return null;
} }
return vmessItem; return vmessItem;
@ -1418,25 +1419,25 @@ namespace v2rayN.Handler
{ {
if (config == null) if (config == null)
{ {
msg = UIRes.I18N("CheckServerSettings"); msg = ResUI.CheckServerSettings;
return ""; return "";
} }
msg = UIRes.I18N("InitialConfiguration"); msg = ResUI.InitialConfiguration;
Config configCopy = Utils.DeepCopy(config); Config configCopy = Utils.DeepCopy(config);
string result = Utils.GetEmbedText(SampleClient); string result = Utils.GetEmbedText(SampleClient);
if (Utils.IsNullOrEmpty(result)) if (Utils.IsNullOrEmpty(result))
{ {
msg = UIRes.I18N("FailedGetDefaultConfiguration"); msg = ResUI.FailedGetDefaultConfiguration;
return ""; return "";
} }
V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result); V2rayConfig v2rayConfig = Utils.FromJson<V2rayConfig>(result);
if (v2rayConfig == null) if (v2rayConfig == null)
{ {
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return ""; return "";
} }
List<IPEndPoint> lstIpEndPoints = null; List<IPEndPoint> lstIpEndPoints = null;
@ -1517,12 +1518,12 @@ namespace v2rayN.Handler
v2rayConfig.routing.rules.Add(rule); v2rayConfig.routing.rules.Add(rule);
} }
//msg = string.Format(UIRes.I18N("SuccessfulConfiguration"), node.getSummary()); //msg = string.Format(ResUI.SuccessfulConfiguration"), node.getSummary());
return Utils.ToJson(v2rayConfig); return Utils.ToJson(v2rayConfig);
} }
catch catch
{ {
msg = UIRes.I18N("FailedGenDefaultConfiguration"); msg = ResUI.FailedGenDefaultConfiguration;
return ""; return "";
} }
} }

View File

@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Text; using System.Text;
using v2rayN.Mode; using v2rayN.Mode;
using v2rayN.Resx;
namespace v2rayN.Handler namespace v2rayN.Handler
{ {
@ -40,13 +41,13 @@ namespace v2rayN.Handler
var item = ConfigHandler.GetDefaultServer(ref config); var item = ConfigHandler.GetDefaultServer(ref config);
if (item == null) if (item == null)
{ {
ShowMsg(false, UIRes.I18N("CheckServerSettings")); ShowMsg(false, ResUI.CheckServerSettings);
return; return;
} }
if (SetCore(config, item) != 0) if (SetCore(config, item) != 0)
{ {
ShowMsg(false, UIRes.I18N("CheckServerSettings")); ShowMsg(false, ResUI.CheckServerSettings);
return; return;
} }
string fileName = Utils.GetPath(v2rayConfigRes); string fileName = Utils.GetPath(v2rayConfigRes);
@ -180,7 +181,7 @@ namespace v2rayN.Handler
} }
if (Utils.IsNullOrEmpty(fileName)) if (Utils.IsNullOrEmpty(fileName))
{ {
string msg = string.Format(UIRes.I18N("NotFoundCore"), coreInfo.coreUrl); string msg = string.Format(ResUI.NotFoundCore, coreInfo.coreUrl);
ShowMsg(false, msg); ShowMsg(false, msg);
} }
return fileName; return fileName;
@ -191,7 +192,7 @@ namespace v2rayN.Handler
/// </summary> /// </summary>
private void V2rayStart() private void V2rayStart()
{ {
ShowMsg(false, string.Format(UIRes.I18N("StartService"), DateTime.Now.ToString())); ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString()));
try try
{ {
@ -245,7 +246,7 @@ namespace v2rayN.Handler
/// </summary> /// </summary>
private int V2rayStartNew(string configStr) private int V2rayStartNew(string configStr)
{ {
ShowMsg(false, string.Format(UIRes.I18N("StartService"), DateTime.Now.ToString())); ShowMsg(false, string.Format(ResUI.StartService, DateTime.Now.ToString()));
try try
{ {

View File

@ -1,26 +0,0 @@
using System.Collections.Generic;
using System.Reflection;
using System.Resources;
namespace v2rayN
{
public class UIRes
{
static ResourceManager res = new ResourceManager("v2rayN.Resx.ResUI", Assembly.GetExecutingAssembly());
static string LoadString(ResourceManager resMgr, string key)
{
string value = resMgr.GetString(key);
if (value == null)
{
throw new KeyNotFoundException($"key: {key}");
}
return value;
}
public static string I18N(string key)
{
return LoadString(res, key);
}
}
}

View File

@ -262,7 +262,6 @@
<Compile Include="Tool\Job.cs" /> <Compile Include="Tool\Job.cs" />
<Compile Include="Tool\Logging.cs" /> <Compile Include="Tool\Logging.cs" />
<Compile Include="Tool\QueryableExtension.cs" /> <Compile Include="Tool\QueryableExtension.cs" />
<Compile Include="Tool\UIRes.cs" />
<Compile Include="Tool\UI.cs" /> <Compile Include="Tool\UI.cs" />
<Compile Include="Tool\Utils.cs" /> <Compile Include="Tool\Utils.cs" />
<Compile Include="Handler\V2rayConfigHandler.cs" /> <Compile Include="Handler\V2rayConfigHandler.cs" />