From 828f93bc5ccafb43cca05723d3f3578abd0a407c Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 19 Mar 2022 09:23:19 +0800 Subject: [PATCH] Improve custom configuration --- .../v2rayN/Forms/AddServer2Form.Designer.cs | 38 +++++---- v2rayN/v2rayN/Forms/AddServer2Form.cs | 20 +++++ v2rayN/v2rayN/Forms/AddServer2Form.resx | 81 ++++++++++++++----- .../v2rayN/Forms/AddServer2Form.zh-Hans.resx | 3 + v2rayN/v2rayN/Resx/ResUI.Designer.cs | 9 +++ v2rayN/v2rayN/Resx/ResUI.resx | 3 + v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx | 3 + 7 files changed, 122 insertions(+), 35 deletions(-) diff --git a/v2rayN/v2rayN/Forms/AddServer2Form.Designer.cs b/v2rayN/v2rayN/Forms/AddServer2Form.Designer.cs index 88808170..25f8d715 100644 --- a/v2rayN/v2rayN/Forms/AddServer2Form.Designer.cs +++ b/v2rayN/v2rayN/Forms/AddServer2Form.Designer.cs @@ -31,6 +31,9 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddServer2Form)); this.btnClose = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.btnEdit = new System.Windows.Forms.Button(); + this.cmbCoreType = new System.Windows.Forms.ComboBox(); + this.labCoreType = new System.Windows.Forms.Label(); this.btnBrowse = new System.Windows.Forms.Button(); this.txtAddress = new System.Windows.Forms.TextBox(); this.label13 = new System.Windows.Forms.Label(); @@ -40,8 +43,6 @@ this.panel2 = new System.Windows.Forms.Panel(); this.btnOK = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); - this.cmbCoreType = new System.Windows.Forms.ComboBox(); - this.labCoreType = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.panel2.SuspendLayout(); this.SuspendLayout(); @@ -56,6 +57,7 @@ // // groupBox1 // + this.groupBox1.Controls.Add(this.btnEdit); this.groupBox1.Controls.Add(this.cmbCoreType); this.groupBox1.Controls.Add(this.labCoreType); this.groupBox1.Controls.Add(this.btnBrowse); @@ -68,6 +70,25 @@ this.groupBox1.Name = "groupBox1"; this.groupBox1.TabStop = false; // + // btnEdit + // + resources.ApplyResources(this.btnEdit, "btnEdit"); + this.btnEdit.Name = "btnEdit"; + this.btnEdit.UseVisualStyleBackColor = true; + this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click); + // + // cmbCoreType + // + this.cmbCoreType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbCoreType.FormattingEnabled = true; + resources.ApplyResources(this.cmbCoreType, "cmbCoreType"); + this.cmbCoreType.Name = "cmbCoreType"; + // + // labCoreType + // + resources.ApplyResources(this.labCoreType, "labCoreType"); + this.labCoreType.Name = "labCoreType"; + // // btnBrowse // resources.ApplyResources(this.btnBrowse, "btnBrowse"); @@ -119,18 +140,6 @@ resources.ApplyResources(this.panel1, "panel1"); this.panel1.Name = "panel1"; // - // cmbCoreType - // - this.cmbCoreType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cmbCoreType.FormattingEnabled = true; - resources.ApplyResources(this.cmbCoreType, "cmbCoreType"); - this.cmbCoreType.Name = "cmbCoreType"; - // - // labCoreType - // - resources.ApplyResources(this.labCoreType, "labCoreType"); - this.labCoreType.Name = "labCoreType"; - // // AddServer2Form // resources.ApplyResources(this, "$this"); @@ -164,5 +173,6 @@ private System.Windows.Forms.Button btnBrowse; private System.Windows.Forms.ComboBox cmbCoreType; private System.Windows.Forms.Label labCoreType; + private System.Windows.Forms.Button btnEdit; } } \ No newline at end of file diff --git a/v2rayN/v2rayN/Forms/AddServer2Form.cs b/v2rayN/v2rayN/Forms/AddServer2Form.cs index 7e7a28fb..892bb48f 100644 --- a/v2rayN/v2rayN/Forms/AddServer2Form.cs +++ b/v2rayN/v2rayN/Forms/AddServer2Form.cs @@ -1,4 +1,6 @@ using System; +using System.Diagnostics; +using System.IO; using System.Windows.Forms; using v2rayN.Handler; using v2rayN.Mode; @@ -66,6 +68,11 @@ namespace v2rayN.Forms UI.Show(UIRes.I18N("PleaseFillRemarks")); return; } + if (Utils.IsNullOrEmpty(txtAddress.Text)) + { + UI.Show(UIRes.I18N("FillServerAddressCustom")); + return; + } vmessItem.remarks = remarks; if (Utils.IsNullOrEmpty(cmbCoreType.Text)) { @@ -130,5 +137,18 @@ namespace v2rayN.Forms UI.ShowWarning(UIRes.I18N("FailedImportedCustomServer")); } } + + private void btnEdit_Click(object sender, EventArgs e) + { + var address = txtAddress.Text; + if (Utils.IsNullOrEmpty(address)) + { + UI.Show(UIRes.I18N("FillServerAddressCustom")); + return; + } + + address = Path.Combine(Utils.GetTempPath(), address); + Process.Start(address); + } } } diff --git a/v2rayN/v2rayN/Forms/AddServer2Form.resx b/v2rayN/v2rayN/Forms/AddServer2Form.resx index 726f0cae..23a0a255 100644 --- a/v2rayN/v2rayN/Forms/AddServer2Form.resx +++ b/v2rayN/v2rayN/Forms/AddServer2Form.resx @@ -143,6 +143,34 @@ 0 + + + NoControl + + + 208, 110 + + + 75, 23 + + + 43 + + + &Edit + + + btnEdit + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupBox1 + + + 0 + 127, 157 @@ -162,12 +190,11 @@ groupBox1 - 0 + 1 True - NoControl @@ -193,7 +220,7 @@ groupBox1 - 1 + 2 NoControl @@ -220,7 +247,7 @@ groupBox1 - 2 + 3 127, 62 @@ -244,7 +271,7 @@ groupBox1 - 3 + 4 True @@ -271,7 +298,7 @@ groupBox1 - 4 + 5 127, 23 @@ -292,7 +319,7 @@ groupBox1 - 5 + 6 True @@ -319,7 +346,7 @@ groupBox1 - 6 + 7 True @@ -346,7 +373,7 @@ groupBox1 - 7 + 8 Fill @@ -375,18 +402,6 @@ 0 - - 357, 17 - - - 75, 23 - - - 5 - - - &OK - btnOK @@ -423,6 +438,30 @@ 1 + + 357, 17 + + + 75, 23 + + + 5 + + + &OK + + + btnOK + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + panel2 + + + 1 + Top diff --git a/v2rayN/v2rayN/Forms/AddServer2Form.zh-Hans.resx b/v2rayN/v2rayN/Forms/AddServer2Form.zh-Hans.resx index 232e5b76..45296254 100644 --- a/v2rayN/v2rayN/Forms/AddServer2Form.zh-Hans.resx +++ b/v2rayN/v2rayN/Forms/AddServer2Form.zh-Hans.resx @@ -126,6 +126,9 @@ 取消(&C) + + 编辑(&E) + 确定(&O) diff --git a/v2rayN/v2rayN/Resx/ResUI.Designer.cs b/v2rayN/v2rayN/Resx/ResUI.Designer.cs index f08cfec5..892684b2 100644 --- a/v2rayN/v2rayN/Resx/ResUI.Designer.cs +++ b/v2rayN/v2rayN/Resx/ResUI.Designer.cs @@ -249,6 +249,15 @@ namespace v2rayN.Resx { } } + /// + /// 查找类似 Please browse to import server configuration 的本地化字符串。 + /// + internal static string FillServerAddressCustom { + get { + return ResourceManager.GetString("FillServerAddressCustom", resourceCulture); + } + } + /// /// 查找类似 Please fill in the user ID 的本地化字符串。 /// diff --git a/v2rayN/v2rayN/Resx/ResUI.resx b/v2rayN/v2rayN/Resx/ResUI.resx index 626a0ce2..81b80999 100644 --- a/v2rayN/v2rayN/Resx/ResUI.resx +++ b/v2rayN/v2rayN/Resx/ResUI.resx @@ -451,4 +451,7 @@ All servers + + Please browse to import server configuration + \ No newline at end of file diff --git a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx index 44dce0d3..986200aa 100644 --- a/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx @@ -451,4 +451,7 @@ 所有服务器 + + 请浏览导入服务器配置 + \ No newline at end of file