添加复制服务器分享链接按钮

 添加模式删除按钮
 添加自定义配置数量(在设置里修改后需重启软件)
:speech_balloon:添加快捷配置翻译
This commit is contained in:
Amazing_DM
2020-02-13 19:22:44 +08:00
parent 282e000beb
commit b39e5d2dbe
8 changed files with 279 additions and 154 deletions

View File

@@ -53,8 +53,14 @@ namespace Netch.Forms
this.AboutToolStripButton = new System.Windows.Forms.ToolStripButton();
this.VersionLabel = new System.Windows.Forms.ToolStripLabel();
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
this.CopyLinkPictureBox = new System.Windows.Forms.PictureBox();
this.DeleteModePictureBox = new System.Windows.Forms.PictureBox();
this.EditModePictureBox = new System.Windows.Forms.PictureBox();
this.ProfileNameText = new System.Windows.Forms.TextBox();
this.ProfileLabel = new System.Windows.Forms.Label();
this.SpeedPictureBox = new System.Windows.Forms.PictureBox();
this.DeletePictureBox = new System.Windows.Forms.PictureBox();
this.EditPictureBox = new System.Windows.Forms.PictureBox();
this.ModeLabel = new System.Windows.Forms.Label();
this.ModeComboBox = new System.Windows.Forms.SearchComboBox();
this.ServerComboBox = new System.Windows.Forms.ComboBox();
@@ -72,19 +78,17 @@ namespace Netch.Forms
this.SettingsButton = new System.Windows.Forms.Button();
this.ProfileGroupBox = new System.Windows.Forms.GroupBox();
this.ProfileTable = new System.Windows.Forms.TableLayoutPanel();
this.EditModePictureBox = new System.Windows.Forms.PictureBox();
this.SpeedPictureBox = new System.Windows.Forms.PictureBox();
this.DeletePictureBox = new System.Windows.Forms.PictureBox();
this.EditPictureBox = new System.Windows.Forms.PictureBox();
this.MenuStrip.SuspendLayout();
this.ConfigurationGroupBox.SuspendLayout();
this.StatusStrip.SuspendLayout();
this.NotifyMenu.SuspendLayout();
this.ProfileGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.CopyLinkPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.DeleteModePictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.EditModePictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.SpeedPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.DeletePictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.EditPictureBox)).BeginInit();
this.StatusStrip.SuspendLayout();
this.NotifyMenu.SuspendLayout();
this.ProfileGroupBox.SuspendLayout();
this.SuspendLayout();
//
// MenuStrip
@@ -101,7 +105,7 @@ namespace Netch.Forms
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
this.MenuStrip.Name = "MenuStrip";
this.MenuStrip.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
this.MenuStrip.Size = new System.Drawing.Size(608, 26);
this.MenuStrip.Size = new System.Drawing.Size(629, 26);
this.MenuStrip.TabIndex = 0;
//
// ServerToolStripMenuItem
@@ -264,6 +268,8 @@ namespace Netch.Forms
//
// ConfigurationGroupBox
//
this.ConfigurationGroupBox.Controls.Add(this.CopyLinkPictureBox);
this.ConfigurationGroupBox.Controls.Add(this.DeleteModePictureBox);
this.ConfigurationGroupBox.Controls.Add(this.EditModePictureBox);
this.ConfigurationGroupBox.Controls.Add(this.ProfileNameText);
this.ConfigurationGroupBox.Controls.Add(this.ProfileLabel);
@@ -276,11 +282,46 @@ namespace Netch.Forms
this.ConfigurationGroupBox.Controls.Add(this.ServerLabel);
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 28);
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
this.ConfigurationGroupBox.Size = new System.Drawing.Size(584, 113);
this.ConfigurationGroupBox.Size = new System.Drawing.Size(605, 113);
this.ConfigurationGroupBox.TabIndex = 1;
this.ConfigurationGroupBox.TabStop = false;
this.ConfigurationGroupBox.Text = "Configuration";
//
// CopyLinkPictureBox
//
this.CopyLinkPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.CopyLinkPictureBox.Image = global::Netch.Properties.Resources.CopyLink;
this.CopyLinkPictureBox.Location = new System.Drawing.Point(582, 25);
this.CopyLinkPictureBox.Name = "CopyLinkPictureBox";
this.CopyLinkPictureBox.Size = new System.Drawing.Size(18, 18);
this.CopyLinkPictureBox.TabIndex = 14;
this.CopyLinkPictureBox.TabStop = false;
this.CopyLinkPictureBox.Click += new System.EventHandler(this.CopyLinkPictureBox_Click);
//
// DeleteModePictureBox
//
this.DeleteModePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.DeleteModePictureBox.Image = global::Netch.Properties.Resources.delete;
this.DeleteModePictureBox.Location = new System.Drawing.Point(540, 57);
this.DeleteModePictureBox.Name = "DeleteModePictureBox";
this.DeleteModePictureBox.Size = new System.Drawing.Size(16, 16);
this.DeleteModePictureBox.TabIndex = 13;
this.DeleteModePictureBox.TabStop = false;
this.DeleteModePictureBox.Click += new System.EventHandler(this.DeleteModePictureBox_Click);
//
// EditModePictureBox
//
this.EditModePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.EditModePictureBox.ErrorImage = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.Image = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.InitialImage = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.Location = new System.Drawing.Point(518, 56);
this.EditModePictureBox.Name = "EditModePictureBox";
this.EditModePictureBox.Size = new System.Drawing.Size(16, 16);
this.EditModePictureBox.TabIndex = 12;
this.EditModePictureBox.TabStop = false;
this.EditModePictureBox.Click += new System.EventHandler(this.EditModePictureBox_Click);
//
// ProfileNameText
//
this.ProfileNameText.Location = new System.Drawing.Point(57, 83);
@@ -297,6 +338,39 @@ namespace Netch.Forms
this.ProfileLabel.TabIndex = 10;
this.ProfileLabel.Text = "Profile";
//
// SpeedPictureBox
//
this.SpeedPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.SpeedPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("SpeedPictureBox.Image")));
this.SpeedPictureBox.Location = new System.Drawing.Point(562, 26);
this.SpeedPictureBox.Name = "SpeedPictureBox";
this.SpeedPictureBox.Size = new System.Drawing.Size(16, 16);
this.SpeedPictureBox.TabIndex = 9;
this.SpeedPictureBox.TabStop = false;
this.SpeedPictureBox.Click += new System.EventHandler(this.SpeedPictureBox_Click);
//
// DeletePictureBox
//
this.DeletePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.DeletePictureBox.Image = ((System.Drawing.Image)(resources.GetObject("DeletePictureBox.Image")));
this.DeletePictureBox.Location = new System.Drawing.Point(540, 26);
this.DeletePictureBox.Name = "DeletePictureBox";
this.DeletePictureBox.Size = new System.Drawing.Size(16, 16);
this.DeletePictureBox.TabIndex = 8;
this.DeletePictureBox.TabStop = false;
this.DeletePictureBox.Click += new System.EventHandler(this.DeletePictureBox_Click);
//
// EditPictureBox
//
this.EditPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.EditPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("EditPictureBox.Image")));
this.EditPictureBox.Location = new System.Drawing.Point(518, 26);
this.EditPictureBox.Name = "EditPictureBox";
this.EditPictureBox.Size = new System.Drawing.Size(16, 16);
this.EditPictureBox.TabIndex = 7;
this.EditPictureBox.TabStop = false;
this.EditPictureBox.Click += new System.EventHandler(this.EditPictureBox_Click);
//
// ModeLabel
//
this.ModeLabel.AutoSize = true;
@@ -350,7 +424,7 @@ namespace Netch.Forms
this.UploadSpeedLabel});
this.StatusStrip.Location = new System.Drawing.Point(0, 254);
this.StatusStrip.Name = "StatusStrip";
this.StatusStrip.Size = new System.Drawing.Size(608, 22);
this.StatusStrip.Size = new System.Drawing.Size(629, 22);
this.StatusStrip.SizingGrip = false;
this.StatusStrip.TabIndex = 2;
//
@@ -384,7 +458,7 @@ namespace Netch.Forms
//
// ControlButton
//
this.ControlButton.Location = new System.Drawing.Point(521, 219);
this.ControlButton.Location = new System.Drawing.Point(542, 219);
this.ControlButton.Name = "ControlButton";
this.ControlButton.Size = new System.Drawing.Size(75, 27);
this.ControlButton.TabIndex = 3;
@@ -439,7 +513,7 @@ namespace Netch.Forms
this.ProfileGroupBox.Controls.Add(this.ProfileTable);
this.ProfileGroupBox.Location = new System.Drawing.Point(12, 147);
this.ProfileGroupBox.Name = "ProfileGroupBox";
this.ProfileGroupBox.Size = new System.Drawing.Size(584, 65);
this.ProfileGroupBox.Size = new System.Drawing.Size(605, 65);
this.ProfileGroupBox.TabIndex = 13;
this.ProfileGroupBox.TabStop = false;
this.ProfileGroupBox.Text = "Profiles";
@@ -457,60 +531,14 @@ namespace Netch.Forms
this.ProfileTable.RowCount = 1;
this.ProfileTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.ProfileTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.ProfileTable.Size = new System.Drawing.Size(578, 43);
this.ProfileTable.Size = new System.Drawing.Size(599, 43);
this.ProfileTable.TabIndex = 0;
//
// EditModePictureBox
//
this.EditModePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.EditModePictureBox.ErrorImage = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.Image = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.InitialImage = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.Location = new System.Drawing.Point(518, 56);
this.EditModePictureBox.Name = "EditModePictureBox";
this.EditModePictureBox.Size = new System.Drawing.Size(16, 16);
this.EditModePictureBox.TabIndex = 12;
this.EditModePictureBox.TabStop = false;
this.EditModePictureBox.Click += new System.EventHandler(this.EditModePictureBox_Click);
//
// SpeedPictureBox
//
this.SpeedPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.SpeedPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("SpeedPictureBox.Image")));
this.SpeedPictureBox.Location = new System.Drawing.Point(562, 26);
this.SpeedPictureBox.Name = "SpeedPictureBox";
this.SpeedPictureBox.Size = new System.Drawing.Size(16, 16);
this.SpeedPictureBox.TabIndex = 9;
this.SpeedPictureBox.TabStop = false;
this.SpeedPictureBox.Click += new System.EventHandler(this.SpeedPictureBox_Click);
//
// DeletePictureBox
//
this.DeletePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.DeletePictureBox.Image = ((System.Drawing.Image)(resources.GetObject("DeletePictureBox.Image")));
this.DeletePictureBox.Location = new System.Drawing.Point(540, 26);
this.DeletePictureBox.Name = "DeletePictureBox";
this.DeletePictureBox.Size = new System.Drawing.Size(16, 16);
this.DeletePictureBox.TabIndex = 8;
this.DeletePictureBox.TabStop = false;
this.DeletePictureBox.Click += new System.EventHandler(this.DeletePictureBox_Click);
//
// EditPictureBox
//
this.EditPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.EditPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("EditPictureBox.Image")));
this.EditPictureBox.Location = new System.Drawing.Point(518, 26);
this.EditPictureBox.Name = "EditPictureBox";
this.EditPictureBox.Size = new System.Drawing.Size(16, 16);
this.EditPictureBox.TabIndex = 7;
this.EditPictureBox.TabStop = false;
this.EditPictureBox.Click += new System.EventHandler(this.EditPictureBox_Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(608, 276);
this.ClientSize = new System.Drawing.Size(629, 276);
this.Controls.Add(this.ProfileGroupBox);
this.Controls.Add(this.SettingsButton);
this.Controls.Add(this.ControlButton);
@@ -531,15 +559,17 @@ namespace Netch.Forms
this.MenuStrip.PerformLayout();
this.ConfigurationGroupBox.ResumeLayout(false);
this.ConfigurationGroupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.CopyLinkPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DeleteModePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.EditModePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.SpeedPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DeletePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.EditPictureBox)).EndInit();
this.StatusStrip.ResumeLayout(false);
this.StatusStrip.PerformLayout();
this.NotifyMenu.ResumeLayout(false);
this.ProfileGroupBox.ResumeLayout(false);
this.ProfileGroupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.EditModePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.SpeedPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DeletePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.EditPictureBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -591,5 +621,7 @@ namespace Netch.Forms
private System.Windows.Forms.TableLayoutPanel ProfileTable;
private System.Windows.Forms.ToolStripMenuItem ManageProcessModeToolStripMenuItem;
private System.Windows.Forms.PictureBox EditModePictureBox;
private System.Windows.Forms.PictureBox DeleteModePictureBox;
private System.Windows.Forms.PictureBox CopyLinkPictureBox;
}
}

View File

@@ -1030,7 +1030,7 @@ namespace Netch.Forms
public void InitProfile()
{
var num_profile = 4;
var num_profile = Global.Settings.ProfileCount;
ProfileTable.ColumnCount = num_profile;
while (Global.Settings.profiles.Count < num_profile)
@@ -1143,11 +1143,6 @@ namespace Netch.Forms
}
}
private void CopyServerLinkPictureBox_Click(object sender, EventArgs e)
{
}
private void DeleteModePictureBox_Click(object sender, EventArgs e)
{
// 当前ModeComboBox中至少有一项
@@ -1172,5 +1167,19 @@ namespace Netch.Forms
MessageBox.Show(Utils.i18N.Translate("Please select an mode first"), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void CopyLinkPictureBox_Click(object sender, EventArgs e)
{
// 当前ServerComboBox中至少有一项
if (ServerComboBox.SelectedIndex != -1)
{
var selectedMode = (Models.Server)ServerComboBox.SelectedItem;
Clipboard.SetText(Utils.ShareLink.GetShareLink(selectedMode));
}
else
{
MessageBox.Show(Utils.i18N.Translate("Please select a server first"), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

View File

@@ -50,6 +50,8 @@
this.ControlButton = new System.Windows.Forms.Button();
this.GlobalBypassIPsButton = new System.Windows.Forms.Button();
this.BehaviorGroupBox = new System.Windows.Forms.GroupBox();
this.ProfileCount_Label = new System.Windows.Forms.Label();
this.ProfileCount_TextBox = new System.Windows.Forms.TextBox();
this.CheckUpdateWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox();
@@ -68,11 +70,9 @@
this.PortGroupBox.Controls.Add(this.HTTPPortTextBox);
this.PortGroupBox.Controls.Add(this.Socks5PortLabel);
this.PortGroupBox.Controls.Add(this.Socks5PortTextBox);
this.PortGroupBox.Location = new System.Drawing.Point(15, 15);
this.PortGroupBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.PortGroupBox.Location = new System.Drawing.Point(12, 12);
this.PortGroupBox.Name = "PortGroupBox";
this.PortGroupBox.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.PortGroupBox.Size = new System.Drawing.Size(525, 175);
this.PortGroupBox.Size = new System.Drawing.Size(420, 140);
this.PortGroupBox.TabIndex = 0;
this.PortGroupBox.TabStop = false;
this.PortGroupBox.Text = "Local Port";
@@ -80,29 +80,26 @@
// RedirectorLabel
//
this.RedirectorLabel.AutoSize = true;
this.RedirectorLabel.Location = new System.Drawing.Point(11, 138);
this.RedirectorLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.RedirectorLabel.Location = new System.Drawing.Point(9, 110);
this.RedirectorLabel.Name = "RedirectorLabel";
this.RedirectorLabel.Size = new System.Drawing.Size(119, 20);
this.RedirectorLabel.Size = new System.Drawing.Size(95, 17);
this.RedirectorLabel.TabIndex = 6;
this.RedirectorLabel.Text = "Redirector TCP";
//
// RedirectorTextBox
//
this.RedirectorTextBox.Location = new System.Drawing.Point(150, 134);
this.RedirectorTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.RedirectorTextBox.Location = new System.Drawing.Point(120, 107);
this.RedirectorTextBox.Name = "RedirectorTextBox";
this.RedirectorTextBox.Size = new System.Drawing.Size(366, 27);
this.RedirectorTextBox.Size = new System.Drawing.Size(294, 23);
this.RedirectorTextBox.TabIndex = 7;
this.RedirectorTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// AllowDevicesCheckBox
//
this.AllowDevicesCheckBox.AutoSize = true;
this.AllowDevicesCheckBox.Location = new System.Drawing.Point(150, 100);
this.AllowDevicesCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.AllowDevicesCheckBox.Location = new System.Drawing.Point(120, 80);
this.AllowDevicesCheckBox.Name = "AllowDevicesCheckBox";
this.AllowDevicesCheckBox.Size = new System.Drawing.Size(259, 24);
this.AllowDevicesCheckBox.Size = new System.Drawing.Size(206, 21);
this.AllowDevicesCheckBox.TabIndex = 5;
this.AllowDevicesCheckBox.Text = "Allow other Devices to connect";
this.AllowDevicesCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -111,38 +108,34 @@
// HTTPPortLabel
//
this.HTTPPortLabel.AutoSize = true;
this.HTTPPortLabel.Location = new System.Drawing.Point(11, 68);
this.HTTPPortLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.HTTPPortLabel.Location = new System.Drawing.Point(9, 54);
this.HTTPPortLabel.Name = "HTTPPortLabel";
this.HTTPPortLabel.Size = new System.Drawing.Size(48, 20);
this.HTTPPortLabel.Size = new System.Drawing.Size(38, 17);
this.HTTPPortLabel.TabIndex = 3;
this.HTTPPortLabel.Text = "HTTP";
//
// HTTPPortTextBox
//
this.HTTPPortTextBox.Location = new System.Drawing.Point(150, 64);
this.HTTPPortTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.HTTPPortTextBox.Location = new System.Drawing.Point(120, 51);
this.HTTPPortTextBox.Name = "HTTPPortTextBox";
this.HTTPPortTextBox.Size = new System.Drawing.Size(366, 27);
this.HTTPPortTextBox.Size = new System.Drawing.Size(294, 23);
this.HTTPPortTextBox.TabIndex = 4;
this.HTTPPortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// Socks5PortLabel
//
this.Socks5PortLabel.AutoSize = true;
this.Socks5PortLabel.Location = new System.Drawing.Point(11, 31);
this.Socks5PortLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.Socks5PortLabel.Location = new System.Drawing.Point(9, 25);
this.Socks5PortLabel.Name = "Socks5PortLabel";
this.Socks5PortLabel.Size = new System.Drawing.Size(60, 20);
this.Socks5PortLabel.Size = new System.Drawing.Size(49, 17);
this.Socks5PortLabel.TabIndex = 0;
this.Socks5PortLabel.Text = "Socks5";
//
// Socks5PortTextBox
//
this.Socks5PortTextBox.Location = new System.Drawing.Point(150, 28);
this.Socks5PortTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Socks5PortTextBox.Location = new System.Drawing.Point(120, 22);
this.Socks5PortTextBox.Name = "Socks5PortTextBox";
this.Socks5PortTextBox.Size = new System.Drawing.Size(366, 27);
this.Socks5PortTextBox.Size = new System.Drawing.Size(294, 23);
this.Socks5PortTextBox.TabIndex = 1;
this.Socks5PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
@@ -157,11 +150,9 @@
this.TUNTAPGroupBox.Controls.Add(this.TUNTAPNetmaskTextBox);
this.TUNTAPGroupBox.Controls.Add(this.TUNTAPAddressLabel);
this.TUNTAPGroupBox.Controls.Add(this.TUNTAPAddressTextBox);
this.TUNTAPGroupBox.Location = new System.Drawing.Point(15, 198);
this.TUNTAPGroupBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.TUNTAPGroupBox.Location = new System.Drawing.Point(12, 158);
this.TUNTAPGroupBox.Name = "TUNTAPGroupBox";
this.TUNTAPGroupBox.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.TUNTAPGroupBox.Size = new System.Drawing.Size(525, 205);
this.TUNTAPGroupBox.Size = new System.Drawing.Size(420, 164);
this.TUNTAPGroupBox.TabIndex = 3;
this.TUNTAPGroupBox.TabStop = false;
this.TUNTAPGroupBox.Text = "TUN/TAP";
@@ -169,10 +160,9 @@
// TUNTAPUseCustomDNSCheckBox
//
this.TUNTAPUseCustomDNSCheckBox.AutoSize = true;
this.TUNTAPUseCustomDNSCheckBox.Location = new System.Drawing.Point(150, 172);
this.TUNTAPUseCustomDNSCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.TUNTAPUseCustomDNSCheckBox.Location = new System.Drawing.Point(120, 138);
this.TUNTAPUseCustomDNSCheckBox.Name = "TUNTAPUseCustomDNSCheckBox";
this.TUNTAPUseCustomDNSCheckBox.Size = new System.Drawing.Size(154, 24);
this.TUNTAPUseCustomDNSCheckBox.Size = new System.Drawing.Size(127, 21);
this.TUNTAPUseCustomDNSCheckBox.TabIndex = 9;
this.TUNTAPUseCustomDNSCheckBox.Text = "Use Custom DNS";
this.TUNTAPUseCustomDNSCheckBox.UseVisualStyleBackColor = true;
@@ -181,86 +171,77 @@
// TUNTAPDNSLabel
//
this.TUNTAPDNSLabel.AutoSize = true;
this.TUNTAPDNSLabel.Location = new System.Drawing.Point(11, 140);
this.TUNTAPDNSLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.TUNTAPDNSLabel.Location = new System.Drawing.Point(9, 112);
this.TUNTAPDNSLabel.Name = "TUNTAPDNSLabel";
this.TUNTAPDNSLabel.Size = new System.Drawing.Size(41, 20);
this.TUNTAPDNSLabel.Size = new System.Drawing.Size(34, 17);
this.TUNTAPDNSLabel.TabIndex = 7;
this.TUNTAPDNSLabel.Text = "DNS";
//
// TUNTAPDNSTextBox
//
this.TUNTAPDNSTextBox.Location = new System.Drawing.Point(150, 136);
this.TUNTAPDNSTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.TUNTAPDNSTextBox.Location = new System.Drawing.Point(120, 110);
this.TUNTAPDNSTextBox.Name = "TUNTAPDNSTextBox";
this.TUNTAPDNSTextBox.Size = new System.Drawing.Size(366, 27);
this.TUNTAPDNSTextBox.Size = new System.Drawing.Size(294, 23);
this.TUNTAPDNSTextBox.TabIndex = 8;
this.TUNTAPDNSTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// TUNTAPGatewayLabel
//
this.TUNTAPGatewayLabel.AutoSize = true;
this.TUNTAPGatewayLabel.Location = new System.Drawing.Point(11, 104);
this.TUNTAPGatewayLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.TUNTAPGatewayLabel.Location = new System.Drawing.Point(9, 83);
this.TUNTAPGatewayLabel.Name = "TUNTAPGatewayLabel";
this.TUNTAPGatewayLabel.Size = new System.Drawing.Size(71, 20);
this.TUNTAPGatewayLabel.Size = new System.Drawing.Size(57, 17);
this.TUNTAPGatewayLabel.TabIndex = 5;
this.TUNTAPGatewayLabel.Text = "Gateway";
//
// TUNTAPGatewayTextBox
//
this.TUNTAPGatewayTextBox.Location = new System.Drawing.Point(150, 100);
this.TUNTAPGatewayTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.TUNTAPGatewayTextBox.Location = new System.Drawing.Point(120, 80);
this.TUNTAPGatewayTextBox.Name = "TUNTAPGatewayTextBox";
this.TUNTAPGatewayTextBox.Size = new System.Drawing.Size(366, 27);
this.TUNTAPGatewayTextBox.Size = new System.Drawing.Size(294, 23);
this.TUNTAPGatewayTextBox.TabIndex = 6;
this.TUNTAPGatewayTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// TUNTAPNetmaskLabel
//
this.TUNTAPNetmaskLabel.AutoSize = true;
this.TUNTAPNetmaskLabel.Location = new System.Drawing.Point(11, 68);
this.TUNTAPNetmaskLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.TUNTAPNetmaskLabel.Location = new System.Drawing.Point(9, 54);
this.TUNTAPNetmaskLabel.Name = "TUNTAPNetmaskLabel";
this.TUNTAPNetmaskLabel.Size = new System.Drawing.Size(73, 20);
this.TUNTAPNetmaskLabel.Size = new System.Drawing.Size(60, 17);
this.TUNTAPNetmaskLabel.TabIndex = 3;
this.TUNTAPNetmaskLabel.Text = "Netmask";
//
// TUNTAPNetmaskTextBox
//
this.TUNTAPNetmaskTextBox.Location = new System.Drawing.Point(150, 64);
this.TUNTAPNetmaskTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.TUNTAPNetmaskTextBox.Location = new System.Drawing.Point(120, 51);
this.TUNTAPNetmaskTextBox.Name = "TUNTAPNetmaskTextBox";
this.TUNTAPNetmaskTextBox.Size = new System.Drawing.Size(366, 27);
this.TUNTAPNetmaskTextBox.Size = new System.Drawing.Size(294, 23);
this.TUNTAPNetmaskTextBox.TabIndex = 4;
this.TUNTAPNetmaskTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// TUNTAPAddressLabel
//
this.TUNTAPAddressLabel.AutoSize = true;
this.TUNTAPAddressLabel.Location = new System.Drawing.Point(11, 31);
this.TUNTAPAddressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.TUNTAPAddressLabel.Location = new System.Drawing.Point(9, 25);
this.TUNTAPAddressLabel.Name = "TUNTAPAddressLabel";
this.TUNTAPAddressLabel.Size = new System.Drawing.Size(69, 20);
this.TUNTAPAddressLabel.Size = new System.Drawing.Size(56, 17);
this.TUNTAPAddressLabel.TabIndex = 1;
this.TUNTAPAddressLabel.Text = "Address";
//
// TUNTAPAddressTextBox
//
this.TUNTAPAddressTextBox.Location = new System.Drawing.Point(150, 28);
this.TUNTAPAddressTextBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.TUNTAPAddressTextBox.Location = new System.Drawing.Point(120, 22);
this.TUNTAPAddressTextBox.Name = "TUNTAPAddressTextBox";
this.TUNTAPAddressTextBox.Size = new System.Drawing.Size(366, 27);
this.TUNTAPAddressTextBox.Size = new System.Drawing.Size(294, 23);
this.TUNTAPAddressTextBox.TabIndex = 2;
this.TUNTAPAddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// ControlButton
//
this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.ControlButton.Location = new System.Drawing.Point(446, 588);
this.ControlButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.ControlButton.Location = new System.Drawing.Point(357, 514);
this.ControlButton.Name = "ControlButton";
this.ControlButton.Size = new System.Drawing.Size(94, 29);
this.ControlButton.Size = new System.Drawing.Size(75, 23);
this.ControlButton.TabIndex = 11;
this.ControlButton.Text = "Save";
this.ControlButton.UseVisualStyleBackColor = true;
@@ -269,10 +250,9 @@
// GlobalBypassIPsButton
//
this.GlobalBypassIPsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.GlobalBypassIPsButton.Location = new System.Drawing.Point(15, 588);
this.GlobalBypassIPsButton.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.GlobalBypassIPsButton.Location = new System.Drawing.Point(12, 514);
this.GlobalBypassIPsButton.Name = "GlobalBypassIPsButton";
this.GlobalBypassIPsButton.Size = new System.Drawing.Size(160, 29);
this.GlobalBypassIPsButton.Size = new System.Drawing.Size(128, 23);
this.GlobalBypassIPsButton.TabIndex = 10;
this.GlobalBypassIPsButton.Text = "Global Bypass IPs";
this.GlobalBypassIPsButton.UseVisualStyleBackColor = true;
@@ -280,26 +260,42 @@
//
// BehaviorGroupBox
//
this.BehaviorGroupBox.Controls.Add(this.ProfileCount_Label);
this.BehaviorGroupBox.Controls.Add(this.ProfileCount_TextBox);
this.BehaviorGroupBox.Controls.Add(this.CheckUpdateWhenOpenedCheckBox);
this.BehaviorGroupBox.Controls.Add(this.StartWhenOpenedCheckBox);
this.BehaviorGroupBox.Controls.Add(this.StopWhenExitedCheckBox);
this.BehaviorGroupBox.Controls.Add(this.ExitWhenClosedCheckBox);
this.BehaviorGroupBox.Location = new System.Drawing.Point(15, 412);
this.BehaviorGroupBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BehaviorGroupBox.Location = new System.Drawing.Point(12, 330);
this.BehaviorGroupBox.Name = "BehaviorGroupBox";
this.BehaviorGroupBox.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.BehaviorGroupBox.Size = new System.Drawing.Size(525, 165);
this.BehaviorGroupBox.Size = new System.Drawing.Size(420, 178);
this.BehaviorGroupBox.TabIndex = 8;
this.BehaviorGroupBox.TabStop = false;
this.BehaviorGroupBox.Text = "Behavior";
//
// ProfileCount_Label
//
this.ProfileCount_Label.AutoSize = true;
this.ProfileCount_Label.Location = new System.Drawing.Point(9, 133);
this.ProfileCount_Label.Name = "ProfileCount_Label";
this.ProfileCount_Label.Size = new System.Drawing.Size(79, 17);
this.ProfileCount_Label.TabIndex = 8;
this.ProfileCount_Label.Text = "ProfileCount";
//
// ProfileCount_TextBox
//
this.ProfileCount_TextBox.Location = new System.Drawing.Point(222, 130);
this.ProfileCount_TextBox.Name = "ProfileCount_TextBox";
this.ProfileCount_TextBox.Size = new System.Drawing.Size(192, 23);
this.ProfileCount_TextBox.TabIndex = 9;
this.ProfileCount_TextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// CheckUpdateWhenOpenedCheckBox
//
this.CheckUpdateWhenOpenedCheckBox.AutoSize = true;
this.CheckUpdateWhenOpenedCheckBox.Location = new System.Drawing.Point(150, 129);
this.CheckUpdateWhenOpenedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.CheckUpdateWhenOpenedCheckBox.Location = new System.Drawing.Point(120, 103);
this.CheckUpdateWhenOpenedCheckBox.Name = "CheckUpdateWhenOpenedCheckBox";
this.CheckUpdateWhenOpenedCheckBox.Size = new System.Drawing.Size(235, 24);
this.CheckUpdateWhenOpenedCheckBox.Size = new System.Drawing.Size(190, 21);
this.CheckUpdateWhenOpenedCheckBox.TabIndex = 8;
this.CheckUpdateWhenOpenedCheckBox.Text = "Check update when opened";
this.CheckUpdateWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -308,10 +304,9 @@
// StartWhenOpenedCheckBox
//
this.StartWhenOpenedCheckBox.AutoSize = true;
this.StartWhenOpenedCheckBox.Location = new System.Drawing.Point(150, 95);
this.StartWhenOpenedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.StartWhenOpenedCheckBox.Location = new System.Drawing.Point(120, 76);
this.StartWhenOpenedCheckBox.Name = "StartWhenOpenedCheckBox";
this.StartWhenOpenedCheckBox.Size = new System.Drawing.Size(170, 24);
this.StartWhenOpenedCheckBox.Size = new System.Drawing.Size(137, 21);
this.StartWhenOpenedCheckBox.TabIndex = 7;
this.StartWhenOpenedCheckBox.Text = "Start when opened";
this.StartWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -320,10 +315,9 @@
// StopWhenExitedCheckBox
//
this.StopWhenExitedCheckBox.AutoSize = true;
this.StopWhenExitedCheckBox.Location = new System.Drawing.Point(150, 61);
this.StopWhenExitedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.StopWhenExitedCheckBox.Location = new System.Drawing.Point(120, 49);
this.StopWhenExitedCheckBox.Name = "StopWhenExitedCheckBox";
this.StopWhenExitedCheckBox.Size = new System.Drawing.Size(159, 24);
this.StopWhenExitedCheckBox.Size = new System.Drawing.Size(127, 21);
this.StopWhenExitedCheckBox.TabIndex = 6;
this.StopWhenExitedCheckBox.Text = "Stop when exited";
this.StopWhenExitedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -332,10 +326,9 @@
// ExitWhenClosedCheckBox
//
this.ExitWhenClosedCheckBox.AutoSize = true;
this.ExitWhenClosedCheckBox.Location = new System.Drawing.Point(150, 28);
this.ExitWhenClosedCheckBox.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.ExitWhenClosedCheckBox.Location = new System.Drawing.Point(120, 22);
this.ExitWhenClosedCheckBox.Name = "ExitWhenClosedCheckBox";
this.ExitWhenClosedCheckBox.Size = new System.Drawing.Size(152, 24);
this.ExitWhenClosedCheckBox.Size = new System.Drawing.Size(123, 21);
this.ExitWhenClosedCheckBox.TabIndex = 5;
this.ExitWhenClosedCheckBox.Text = "Exit when closed";
this.ExitWhenClosedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -343,9 +336,9 @@
//
// SettingForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(120F, 120F);
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(555, 630);
this.ClientSize = new System.Drawing.Size(444, 548);
this.Controls.Add(this.BehaviorGroupBox);
this.Controls.Add(this.PortGroupBox);
this.Controls.Add(this.GlobalBypassIPsButton);
@@ -354,7 +347,7 @@
this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.MaximizeBox = false;
this.Name = "SettingForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
@@ -398,5 +391,7 @@
private System.Windows.Forms.CheckBox StopWhenExitedCheckBox;
private System.Windows.Forms.CheckBox StartWhenOpenedCheckBox;
private System.Windows.Forms.CheckBox CheckUpdateWhenOpenedCheckBox;
private System.Windows.Forms.Label ProfileCount_Label;
private System.Windows.Forms.TextBox ProfileCount_TextBox;
}
}

View File

@@ -73,6 +73,9 @@ namespace Netch.Forms
StopWhenExitedCheckBox.Text = Utils.i18N.Translate(StopWhenExitedCheckBox.Text);
StartWhenOpenedCheckBox.Text = Utils.i18N.Translate(StartWhenOpenedCheckBox.Text);
CheckUpdateWhenOpenedCheckBox.Text = Utils.i18N.Translate(CheckUpdateWhenOpenedCheckBox.Text);
ProfileCount_Label.Text = Utils.i18N.Translate(ProfileCount_Label.Text);
ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
if (Global.Settings.TUNTAP.DNS.Count > 0)
{
@@ -235,6 +238,26 @@ namespace Netch.Forms
return;
}
try
{
var ProfileCount = int.Parse(ProfileCount_TextBox.Text);
if (ProfileCount>0)
{
Global.Settings.ProfileCount = ProfileCount;
}
else
{
throw new FormatException();
}
}
catch (FormatException)
{
ProfileCount_TextBox.Text = Global.Settings.ProfileCount.ToString();
MessageBox.Show(Utils.i18N.Translate("ProfileCount value illegal. Try again."), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Global.Settings.TUNTAP.Address = TUNTAPAddressTextBox.Text;
Global.Settings.TUNTAP.Netmask = TUNTAPNetmaskTextBox.Text;

View File

@@ -119,10 +119,14 @@ namespace Netch.Models
/// </summary>
public List<string> BypassIPs = new List<string>();
/// <summary>
/// Saved profiles
/// 已保存的快捷配置
/// </summary>
public List<Profile> profiles = new List<Profile>();
/// <summary>
/// 快捷配置数量
/// </summary>
public int ProfileCount = 4;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 637 B

After

Width:  |  Height:  |  Size: 715 B

View File

@@ -130,6 +130,8 @@
"Global Bypass IPs": "全局直连 IP",
"Port value illegal. Try again.": "端口值非法。请重试。",
"Check update when opened": "打开软件时检查更新",
"ProfileCount": "快捷配置数量(重启软件生效)",
"ProfileCount value illegal. Try again.": "快捷配置数值非法。请重试。",
"TUN/TAP driver is not detected. Is it installed now?": "未检测到TUN/TAP驱动是否现在安装",
"Profile": "配置名",

View File

@@ -21,6 +21,66 @@ namespace Netch.Utils
{
return Encoding.UTF8.GetString(Convert.FromBase64String(text.Replace("-", "+").Replace("_", "/").PadRight(text.Length + (4 - text.Length % 4) % 4, '=')));
}
/// <summary>
/// URL 传输安全的 Base64 加密
/// </summary>
/// <param name="text">需要加密的字符串</param>
/// <returns>加密后的字符串</returns>
public static string URLSafeBase64Encode(string text)
{
return Convert.ToBase64String(Encoding.UTF8.GetBytes(text)).Replace("-", "+").Replace("_", "/").PadRight(text.Length + (4 - text.Length % 4) % 4, '=');
}
/// <summary>
/// 根据服务器生成分享链接
/// </summary>
/// <param name="server">需要获取分享链接的服务器</param>
/// <returns>解码后的字符串</returns>
public static string GetShareLink(Models.Server server)
{
string retLinkStr = "";
switch (server.Type)
{
case "Socks5":
// https://t.me/socks?server=1.1.1.1&port=443
retLinkStr = string.Format("https://t.me/socks?server={0}&port={1}", server.Hostname, server.Port);
break;
case "SS":
// ss://method:password@server:port#Remark
retLinkStr = "ss://" + URLSafeBase64Encode(string.Format("{0}:{1}@{2}:{3}", server.EncryptMethod, server.Password, server.Hostname, server.Port)) + "#" + HttpUtility.UrlEncode(server.Remark);
break;
case "SSR":
// https://github.com/shadowsocksr-backup/shadowsocks-rss/wiki/SSR-QRcode-scheme
// ssr://base64(host:port:protocol:method:obfs:base64pass/?obfsparam=base64param&protoparam=base64param&remarks=base64remarks&group=base64group&udpport=0&uot=0)
string paraStr = string.Format("/?obfsparam={0}&protoparam={1}&remarks={2}", URLSafeBase64Encode(server.OBFSParam), URLSafeBase64Encode(server.ProtocolParam), URLSafeBase64Encode(server.Remark));
retLinkStr = "ssr://" + URLSafeBase64Encode(string.Format("{0}:{1}:{2}:{3}:{4}:{5}{6}", server.Hostname, server.Port, server.Protocol, server.EncryptMethod, server.OBFS, URLSafeBase64Encode(server.Password), paraStr));
break;
case "VMess":
string vmessJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
{
v = "2",
ps = server.Remark,
add = server.Hostname,
port = server.Port,
id = server.UserID,
aid = server.AlterID,
net = server.TransferProtocol,
type = server.FakeType,
host = server.Host,
path = server.Path,
tls = server.TLSSecure ? "tls" : ""
});
retLinkStr = "vmess://" + URLSafeBase64Encode(vmessJson);
break;
default:
return null;
}
return retLinkStr;
}
public static List<Server> Parse(string text)
{
@@ -109,7 +169,7 @@ namespace Netch.Utils
{
var data = new Server();
data.Type = "SS";
text = text.Replace("/?", "?");
try
{