Refactoring

This commit is contained in:
ChsBuffer
2020-09-26 15:00:18 +08:00
parent 801e8e3b8a
commit 9b12ae9462
72 changed files with 1661 additions and 1595 deletions

View File

@@ -0,0 +1,198 @@
namespace Netch.ServerEx.Socks5.Form
{
partial class Socks5Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Socks5Form));
this.ConfigurationGroupBox = new System.Windows.Forms.GroupBox();
this.PasswordLabel = new System.Windows.Forms.Label();
this.UsernameTextBox = new System.Windows.Forms.TextBox();
this.PasswordTextBox = new System.Windows.Forms.TextBox();
this.UsernameLabel = new System.Windows.Forms.Label();
this.AddressLabel = new System.Windows.Forms.Label();
this.PortTextBox = new System.Windows.Forms.TextBox();
this.AddressTextBox = new System.Windows.Forms.TextBox();
this.RemarkTextBox = new System.Windows.Forms.TextBox();
this.RemarkLabel = new System.Windows.Forms.Label();
this.PortLabel = new System.Windows.Forms.Label();
this.ControlButton = new System.Windows.Forms.Button();
this.ConfigurationGroupBox.SuspendLayout();
this.SuspendLayout();
//
// ConfigurationGroupBox
//
this.ConfigurationGroupBox.Controls.Add(this.PasswordLabel);
this.ConfigurationGroupBox.Controls.Add(this.UsernameTextBox);
this.ConfigurationGroupBox.Controls.Add(this.PasswordTextBox);
this.ConfigurationGroupBox.Controls.Add(this.UsernameLabel);
this.ConfigurationGroupBox.Controls.Add(this.AddressLabel);
this.ConfigurationGroupBox.Controls.Add(this.PortTextBox);
this.ConfigurationGroupBox.Controls.Add(this.AddressTextBox);
this.ConfigurationGroupBox.Controls.Add(this.RemarkTextBox);
this.ConfigurationGroupBox.Controls.Add(this.RemarkLabel);
this.ConfigurationGroupBox.Controls.Add(this.PortLabel);
this.ConfigurationGroupBox.Location = new System.Drawing.Point(12, 12);
this.ConfigurationGroupBox.Name = "ConfigurationGroupBox";
this.ConfigurationGroupBox.Size = new System.Drawing.Size(420, 139);
this.ConfigurationGroupBox.TabIndex = 0;
this.ConfigurationGroupBox.TabStop = false;
this.ConfigurationGroupBox.Text = "Configuration";
//
// PasswordLabel
//
this.PasswordLabel.AutoSize = true;
this.PasswordLabel.Location = new System.Drawing.Point(10, 109);
this.PasswordLabel.Name = "PasswordLabel";
this.PasswordLabel.Size = new System.Drawing.Size(64, 17);
this.PasswordLabel.TabIndex = 8;
this.PasswordLabel.Text = "Password";
//
// UsernameTextBox
//
this.UsernameTextBox.Location = new System.Drawing.Point(120, 77);
this.UsernameTextBox.Name = "UsernameTextBox";
this.UsernameTextBox.Size = new System.Drawing.Size(294, 23);
this.UsernameTextBox.TabIndex = 7;
this.UsernameTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// PasswordTextBox
//
this.PasswordTextBox.Location = new System.Drawing.Point(120, 106);
this.PasswordTextBox.Name = "PasswordTextBox";
this.PasswordTextBox.Size = new System.Drawing.Size(294, 23);
this.PasswordTextBox.TabIndex = 9;
this.PasswordTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// UsernameLabel
//
this.UsernameLabel.AutoSize = true;
this.UsernameLabel.Location = new System.Drawing.Point(10, 80);
this.UsernameLabel.Name = "UsernameLabel";
this.UsernameLabel.Size = new System.Drawing.Size(67, 17);
this.UsernameLabel.TabIndex = 6;
this.UsernameLabel.Text = "Username";
//
// AddressLabel
//
this.AddressLabel.AutoSize = true;
this.AddressLabel.Location = new System.Drawing.Point(10, 51);
this.AddressLabel.Name = "AddressLabel";
this.AddressLabel.Size = new System.Drawing.Size(56, 17);
this.AddressLabel.TabIndex = 2;
this.AddressLabel.Text = "Address";
//
// PortTextBox
//
this.PortTextBox.Location = new System.Drawing.Point(358, 48);
this.PortTextBox.Name = "PortTextBox";
this.PortTextBox.Size = new System.Drawing.Size(56, 23);
this.PortTextBox.TabIndex = 5;
this.PortTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// AddressTextBox
//
this.AddressTextBox.Location = new System.Drawing.Point(120, 48);
this.AddressTextBox.Name = "AddressTextBox";
this.AddressTextBox.Size = new System.Drawing.Size(232, 23);
this.AddressTextBox.TabIndex = 3;
this.AddressTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// RemarkTextBox
//
this.RemarkTextBox.Location = new System.Drawing.Point(120, 19);
this.RemarkTextBox.Name = "RemarkTextBox";
this.RemarkTextBox.Size = new System.Drawing.Size(294, 23);
this.RemarkTextBox.TabIndex = 1;
this.RemarkTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// RemarkLabel
//
this.RemarkLabel.AutoSize = true;
this.RemarkLabel.Location = new System.Drawing.Point(10, 22);
this.RemarkLabel.Name = "RemarkLabel";
this.RemarkLabel.Size = new System.Drawing.Size(53, 17);
this.RemarkLabel.TabIndex = 0;
this.RemarkLabel.Text = "Remark";
//
// PortLabel
//
this.PortLabel.AutoSize = true;
this.PortLabel.Location = new System.Drawing.Point(351, 51);
this.PortLabel.Name = "PortLabel";
this.PortLabel.Size = new System.Drawing.Size(11, 17);
this.PortLabel.TabIndex = 4;
this.PortLabel.Text = ":";
//
// ControlButton
//
this.ControlButton.Location = new System.Drawing.Point(357, 157);
this.ControlButton.Name = "ControlButton";
this.ControlButton.Size = new System.Drawing.Size(75, 23);
this.ControlButton.TabIndex = 1;
this.ControlButton.Text = "Save";
this.ControlButton.UseVisualStyleBackColor = true;
this.ControlButton.Click += new System.EventHandler(this.ControlButton_Click);
//
// Socks5
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(444, 192);
this.Controls.Add(this.ControlButton);
this.Controls.Add(this.ConfigurationGroupBox);
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(3, 4, 3, 4);
this.MaximizeBox = false;
this.Name = "Socks5Form";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Socks5";
this.Load += new System.EventHandler(this.Shadowsocks_Load);
this.ConfigurationGroupBox.ResumeLayout(false);
this.ConfigurationGroupBox.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.GroupBox ConfigurationGroupBox;
private System.Windows.Forms.Button ControlButton;
private System.Windows.Forms.Label RemarkLabel;
private System.Windows.Forms.TextBox RemarkTextBox;
private System.Windows.Forms.Label PortLabel;
private System.Windows.Forms.TextBox AddressTextBox;
private System.Windows.Forms.TextBox PortTextBox;
private System.Windows.Forms.Label AddressLabel;
private System.Windows.Forms.TextBox PasswordTextBox;
private System.Windows.Forms.Label UsernameLabel;
private System.Windows.Forms.Label PasswordLabel;
private System.Windows.Forms.TextBox UsernameTextBox;
}
}

View File

@@ -0,0 +1,56 @@
using System;
using Netch.Utils;
namespace Netch.ServerEx.Socks5.Form
{
public partial class Socks5Form : System.Windows.Forms.Form
{
private readonly Socks5 _server;
public Socks5Form(Models.Server server = default)
{
InitializeComponent();
_server = (Socks5) (server ?? new Socks5());
}
private void Shadowsocks_Load(object sender, EventArgs e)
{
#region InitText
ConfigurationGroupBox.Text = i18N.Translate(ConfigurationGroupBox.Text);
RemarkLabel.Text = i18N.Translate(RemarkLabel.Text);
AddressLabel.Text = i18N.Translate(AddressLabel.Text);
UsernameLabel.Text = i18N.Translate(UsernameLabel.Text);
PasswordLabel.Text = i18N.Translate(PasswordLabel.Text);
ControlButton.Text = i18N.Translate(ControlButton.Text);
#endregion
RemarkTextBox.Text = _server.Remark;
AddressTextBox.Text = _server.Hostname;
PortTextBox.Text = _server.Port.ToString();
UsernameTextBox.Text = _server.Username;
PasswordTextBox.Text = _server.Password;
}
private void ControlButton_Click(object sender, EventArgs e)
{
if (!ushort.TryParse(PortTextBox.Text, out var port)) return;
_server.Remark = RemarkTextBox.Text;
_server.Type = "Socks5";
_server.Hostname = AddressTextBox.Text;
_server.Port = port;
_server.Username = UsernameTextBox.Text;
_server.Password = PasswordTextBox.Text;
_server.Country = null;
if (Global.Settings.Server.IndexOf(_server) == -1)
Global.Settings.Server.Add(_server);
MessageBoxX.Show(i18N.Translate("Saved"));
Close();
}
}
}

File diff suppressed because it is too large Load Diff