From d655083ebea5675b59e2d9d970cd6ef802e326bc Mon Sep 17 00:00:00 2001
From: KevinZonda <33132228+KevinZonda@users.noreply.github.com>
Date: Sat, 20 Jun 2020 04:45:10 +0800
Subject: [PATCH] [nodelist] add treelist ui and base logic
---
NaiveSharp/App.config | 6 +-
NaiveSharp/Controller/Extension/Dictionary.cs | 2 +-
NaiveSharp/Controller/Extension/String.cs | 2 +-
NaiveSharp/Controller/Extension/String[].cs | 6 +-
.../Extension/TreeNodeCollection.cs | 25 ++
NaiveSharp/Controller/NodeList.cs | 35 +-
NaiveSharp/NaiveSharp.csproj | 3 +
NaiveSharp/Properties/Resources.Designer.cs | 68 ++--
NaiveSharp/Properties/Settings.Designer.cs | 22 +-
NaiveSharp/View/MainWindow.Designer.cs | 310 ++++++++++--------
NaiveSharp/View/MainWindow.cs | 12 +-
11 files changed, 301 insertions(+), 190 deletions(-)
create mode 100644 NaiveSharp/Controller/Extension/TreeNodeCollection.cs
diff --git a/NaiveSharp/App.config b/NaiveSharp/App.config
index 56efbc7..ecdcf8a 100644
--- a/NaiveSharp/App.config
+++ b/NaiveSharp/App.config
@@ -1,6 +1,6 @@
-
+
-
+
-
\ No newline at end of file
+
diff --git a/NaiveSharp/Controller/Extension/Dictionary.cs b/NaiveSharp/Controller/Extension/Dictionary.cs
index a8024c8..bc2d478 100644
--- a/NaiveSharp/Controller/Extension/Dictionary.cs
+++ b/NaiveSharp/Controller/Extension/Dictionary.cs
@@ -2,7 +2,7 @@
namespace NaiveSharp.Controller.Extension
{
- public static class Dictionary
+ public static class DictionaryEx
{
public static bool HasKey(this Dictionary dic, K value)
=> dic.ContainsKey(value);
diff --git a/NaiveSharp/Controller/Extension/String.cs b/NaiveSharp/Controller/Extension/String.cs
index e74b021..c827a15 100644
--- a/NaiveSharp/Controller/Extension/String.cs
+++ b/NaiveSharp/Controller/Extension/String.cs
@@ -2,7 +2,7 @@
namespace NaiveSharp.Controller.Extension
{
- public static class String
+ public static class StringEx
{
public static string ToBase64(this string str)
=> ConvertToBase64(str, false);
diff --git a/NaiveSharp/Controller/Extension/String[].cs b/NaiveSharp/Controller/Extension/String[].cs
index 133ef9b..41265aa 100644
--- a/NaiveSharp/Controller/Extension/String[].cs
+++ b/NaiveSharp/Controller/Extension/String[].cs
@@ -2,11 +2,11 @@
namespace NaiveSharp.Controller.Extension
{
- public static class StringArray
+ public static class StringArrayEx
{
public static string[] Trim(this string[] ss)
{
- for (int i = 0; i < ss.Length; --i)
+ for (int i = 0; i < ss.Length; ++i)
{
ss[i] = ss[i].Trim();
}
@@ -22,7 +22,7 @@ public static string[] Trim(this string[] ss, bool removeNullOrWhiteSpace)
else
{
var x = new List();
- for (int i = 0; i < ss.Length; --i)
+ for (int i = 0; i < ss.Length; ++i)
{
if (string.IsNullOrWhiteSpace(ss[i]))
{
diff --git a/NaiveSharp/Controller/Extension/TreeNodeCollection.cs b/NaiveSharp/Controller/Extension/TreeNodeCollection.cs
new file mode 100644
index 0000000..d0b3a37
--- /dev/null
+++ b/NaiveSharp/Controller/Extension/TreeNodeCollection.cs
@@ -0,0 +1,25 @@
+using System.Linq;
+using System.Windows.Forms;
+
+namespace NaiveSharp.Controller.Extension
+{
+ public static class TreeNodeCollectionEx
+ {
+ public static bool ContainsText(this TreeNodeCollection tnc, string text)
+ {
+ /*
+ => tnc.Cast()
+ .Where(tn => tn.Text == text)
+ .Count() > 0;
+ */
+ foreach (TreeNode tn in tnc)
+ {
+ if (tn.Text == text)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
diff --git a/NaiveSharp/Controller/NodeList.cs b/NaiveSharp/Controller/NodeList.cs
index b15edd4..5eff4e5 100644
--- a/NaiveSharp/Controller/NodeList.cs
+++ b/NaiveSharp/Controller/NodeList.cs
@@ -1,13 +1,44 @@
-using System.Collections.Generic;
+using NaiveSharp.Controller.Extension;
+
+using System;
+using System.Linq;
+using System.Collections.Generic;
using System.Windows.Forms;
namespace NaiveSharp.Controller
{
public class NodeList
{
- public static void LoadFromStringArray(string[] s)
+ public static void LoadFromStringArray(ref TreeView tv, string[] s)
{
+ tv.Nodes.Clear();
+ s = s.Trim(true);
+
+ string group = "default";
+ for (int i = 0; i < s.Length; ++i)
+ {
+ if (s[i].StartsEndsWith("[", "]"))
+ {
+ group = s[i].Substring(1, s[i].Length - 2);
+ if (!tv.Nodes.ContainsText(group))
+ {
+ tv.Nodes.Add(new TreeNode() { Name = group, Text = group });
+ }
+ }
+ else
+ {
+ if (i == 0)
+ {
+ tv.Nodes.Add(new TreeNode() { Name = group, Text = group });
+ }
+ tv.Nodes[group].Nodes.Add(new TreeNode()
+ {
+ Tag = s[i],
+ Text = new Uri(s[i]).Fragment.Substring(1)
+ });
+ }
+ }
}
public static string[] ToStringArray(TreeView tv)
diff --git a/NaiveSharp/NaiveSharp.csproj b/NaiveSharp/NaiveSharp.csproj
index af9a48d..7448778 100644
--- a/NaiveSharp/NaiveSharp.csproj
+++ b/NaiveSharp/NaiveSharp.csproj
@@ -30,6 +30,7 @@
0.5.0.%2a
false
true
+
AnyCPU
@@ -84,6 +85,7 @@
+
@@ -120,6 +122,7 @@
True
Resources.resx
+ True
About.cs
diff --git a/NaiveSharp/Properties/Resources.Designer.cs b/NaiveSharp/Properties/Resources.Designer.cs
index 25e6139..3c31c84 100644
--- a/NaiveSharp/Properties/Resources.Designer.cs
+++ b/NaiveSharp/Properties/Resources.Designer.cs
@@ -1,69 +1,61 @@
//------------------------------------------------------------------------------
//
-// 此代码由工具生成。
-// 运行时版本: 4.0.30319.42000
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
//
-// 对此文件的更改可能导致不正确的行为,如果
-// 重新生成代码,则所做更改将丢失。
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
//------------------------------------------------------------------------------
-namespace NaiveSharp.Properties
-{
-
-
+namespace NaiveSharp.Properties {
+ using System;
+
+
///
- /// 强类型资源类,用于查找本地化字符串等。
+ /// A strongly-typed resource class, for looking up localized strings, etc.
///
- // 此类是由 StronglyTypedResourceBuilder
- // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
- // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
- // (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ internal class Resources {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
+ internal Resources() {
}
-
+
///
- /// 返回此类使用的缓存 ResourceManager 实例。
+ /// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NaiveSharp.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
- /// 覆盖当前线程的 CurrentUICulture 属性
- /// 使用此强类型的资源类的资源查找。
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
diff --git a/NaiveSharp/Properties/Settings.Designer.cs b/NaiveSharp/Properties/Settings.Designer.cs
index c357a2e..7e4672c 100644
--- a/NaiveSharp/Properties/Settings.Designer.cs
+++ b/NaiveSharp/Properties/Settings.Designer.cs
@@ -8,21 +8,17 @@
//
//------------------------------------------------------------------------------
-namespace NaiveSharp.Properties
-{
-
-
+namespace NaiveSharp.Properties {
+
+
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.6.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
+
+ public static Settings Default {
+ get {
return defaultInstance;
}
}
diff --git a/NaiveSharp/View/MainWindow.Designer.cs b/NaiveSharp/View/MainWindow.Designer.cs
index 6000cd9..6290efd 100644
--- a/NaiveSharp/View/MainWindow.Designer.cs
+++ b/NaiveSharp/View/MainWindow.Designer.cs
@@ -36,21 +36,21 @@ private void InitializeComponent()
this.rdoGlobal = new System.Windows.Forms.RadioButton();
this.rdoGfwlist = new System.Windows.Forms.RadioButton();
this.rdoGeoIP = new System.Windows.Forms.RadioButton();
- this.tblInfo = new System.Windows.Forms.TableLayoutPanel();
+ this.tlpInfo = new System.Windows.Forms.TableLayoutPanel();
this.lblUsername = new System.Windows.Forms.Label();
this.lblPassword = new System.Windows.Forms.Label();
this.lblHost = new System.Windows.Forms.Label();
- this.tblProxyMode = new System.Windows.Forms.TableLayoutPanel();
+ this.tlpProxyMode = new System.Windows.Forms.TableLayoutPanel();
this.lblProxyMode = new System.Windows.Forms.Label();
this.btnRun = new System.Windows.Forms.Button();
this.lblExit = new System.Windows.Forms.Button();
this.lblStop = new System.Windows.Forms.Button();
- this.tblScheme = new System.Windows.Forms.TableLayoutPanel();
+ this.tlpScheme = new System.Windows.Forms.TableLayoutPanel();
this.lblScheme = new System.Windows.Forms.Label();
this.rdoHttps = new System.Windows.Forms.RadioButton();
this.rdoQuic = new System.Windows.Forms.RadioButton();
this.chkPadding = new System.Windows.Forms.CheckBox();
- this.tblOperate = new System.Windows.Forms.TableLayoutPanel();
+ this.tlpOperate = new System.Windows.Forms.TableLayoutPanel();
this.lblSave = new System.Windows.Forms.Button();
this.icnNotify = new System.Windows.Forms.NotifyIcon(this.components);
this.cmsNotify = new System.Windows.Forms.ContextMenuStrip(this.components);
@@ -58,19 +58,24 @@ private void InitializeComponent()
this.tsmGlobal = new System.Windows.Forms.ToolStripMenuItem();
this.tsmGFWList = new System.Windows.Forms.ToolStripMenuItem();
this.tsmGeoIP = new System.Windows.Forms.ToolStripMenuItem();
- this.smiAbout = new System.Windows.Forms.ToolStripMenuItem();
+ this.smiRun = new System.Windows.Forms.ToolStripMenuItem();
+ this.smiStop = new System.Windows.Forms.ToolStripMenuItem();
+ this.tss1 = new System.Windows.Forms.ToolStripSeparator();
this.smiCopyShareLink = new System.Windows.Forms.ToolStripMenuItem();
this.smiLoadShareLink = new System.Windows.Forms.ToolStripMenuItem();
this.tss2 = new System.Windows.Forms.ToolStripSeparator();
- this.smiRun = new System.Windows.Forms.ToolStripMenuItem();
- this.smiStop = new System.Windows.Forms.ToolStripMenuItem();
+ this.smiAbout = new System.Windows.Forms.ToolStripMenuItem();
this.smiExit = new System.Windows.Forms.ToolStripMenuItem();
- this.tss1 = new System.Windows.Forms.ToolStripSeparator();
- this.tblInfo.SuspendLayout();
- this.tblProxyMode.SuspendLayout();
- this.tblScheme.SuspendLayout();
- this.tblOperate.SuspendLayout();
+ this.tvwNodeList = new System.Windows.Forms.TreeView();
+ this.tlpNodeListControl = new System.Windows.Forms.TableLayoutPanel();
+ this.btnDelNode = new System.Windows.Forms.Button();
+ this.btnAddNode = new System.Windows.Forms.Button();
+ this.tlpInfo.SuspendLayout();
+ this.tlpProxyMode.SuspendLayout();
+ this.tlpScheme.SuspendLayout();
+ this.tlpOperate.SuspendLayout();
this.cmsNotify.SuspendLayout();
+ this.tlpNodeListControl.SuspendLayout();
this.SuspendLayout();
//
// txtUsername
@@ -146,27 +151,27 @@ private void InitializeComponent()
this.rdoGeoIP.UseVisualStyleBackColor = true;
this.rdoGeoIP.CheckedChanged += new System.EventHandler(this.rdoGeoIP_CheckedChanged);
//
- // tblInfo
- //
- this.tblInfo.ColumnCount = 2;
- this.tblInfo.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F));
- this.tblInfo.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 80F));
- this.tblInfo.Controls.Add(this.txtHost, 1, 0);
- this.tblInfo.Controls.Add(this.txtPassword, 1, 2);
- this.tblInfo.Controls.Add(this.txtUsername, 1, 1);
- this.tblInfo.Controls.Add(this.lblUsername, 0, 1);
- this.tblInfo.Controls.Add(this.lblPassword, 0, 2);
- this.tblInfo.Controls.Add(this.lblHost, 0, 0);
- this.tblInfo.Location = new System.Drawing.Point(12, 44);
- this.tblInfo.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.tblInfo.Name = "tblInfo";
- this.tblInfo.RowCount = 3;
- this.tblInfo.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
- this.tblInfo.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
- this.tblInfo.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
- this.tblInfo.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
- this.tblInfo.Size = new System.Drawing.Size(372, 94);
- this.tblInfo.TabIndex = 7;
+ // tlpInfo
+ //
+ this.tlpInfo.ColumnCount = 2;
+ this.tlpInfo.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20F));
+ this.tlpInfo.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 80F));
+ this.tlpInfo.Controls.Add(this.txtHost, 1, 0);
+ this.tlpInfo.Controls.Add(this.txtPassword, 1, 2);
+ this.tlpInfo.Controls.Add(this.txtUsername, 1, 1);
+ this.tlpInfo.Controls.Add(this.lblUsername, 0, 1);
+ this.tlpInfo.Controls.Add(this.lblPassword, 0, 2);
+ this.tlpInfo.Controls.Add(this.lblHost, 0, 0);
+ this.tlpInfo.Location = new System.Drawing.Point(153, 44);
+ this.tlpInfo.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.tlpInfo.Name = "tlpInfo";
+ this.tlpInfo.RowCount = 3;
+ this.tlpInfo.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
+ this.tlpInfo.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
+ this.tlpInfo.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
+ this.tlpInfo.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25F));
+ this.tlpInfo.Size = new System.Drawing.Size(372, 94);
+ this.tlpInfo.TabIndex = 7;
//
// lblUsername
//
@@ -198,25 +203,25 @@ private void InitializeComponent()
this.lblHost.TabIndex = 11;
this.lblHost.Text = "Host";
//
- // tblProxyMode
- //
- this.tblProxyMode.ColumnCount = 4;
- this.tblProxyMode.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.004F));
- this.tblProxyMode.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
- this.tblProxyMode.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
- this.tblProxyMode.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
- this.tblProxyMode.Controls.Add(this.lblProxyMode, 0, 0);
- this.tblProxyMode.Controls.Add(this.rdoGeoIP, 3, 0);
- this.tblProxyMode.Controls.Add(this.rdoGlobal, 1, 0);
- this.tblProxyMode.Controls.Add(this.rdoGfwlist, 2, 0);
- this.tblProxyMode.Location = new System.Drawing.Point(12, 141);
- this.tblProxyMode.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.tblProxyMode.Name = "tblProxyMode";
- this.tblProxyMode.RowCount = 1;
- this.tblProxyMode.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tblProxyMode.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
- this.tblProxyMode.Size = new System.Drawing.Size(372, 26);
- this.tblProxyMode.TabIndex = 8;
+ // tlpProxyMode
+ //
+ this.tlpProxyMode.ColumnCount = 4;
+ this.tlpProxyMode.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.004F));
+ this.tlpProxyMode.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
+ this.tlpProxyMode.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
+ this.tlpProxyMode.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
+ this.tlpProxyMode.Controls.Add(this.lblProxyMode, 0, 0);
+ this.tlpProxyMode.Controls.Add(this.rdoGeoIP, 3, 0);
+ this.tlpProxyMode.Controls.Add(this.rdoGlobal, 1, 0);
+ this.tlpProxyMode.Controls.Add(this.rdoGfwlist, 2, 0);
+ this.tlpProxyMode.Location = new System.Drawing.Point(153, 141);
+ this.tlpProxyMode.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.tlpProxyMode.Name = "tlpProxyMode";
+ this.tlpProxyMode.RowCount = 1;
+ this.tlpProxyMode.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tlpProxyMode.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 26F));
+ this.tlpProxyMode.Size = new System.Drawing.Size(372, 26);
+ this.tlpProxyMode.TabIndex = 8;
//
// lblProxyMode
//
@@ -264,24 +269,24 @@ private void InitializeComponent()
this.lblStop.UseVisualStyleBackColor = true;
this.lblStop.Click += new System.EventHandler(this.lblStop_Click);
//
- // tblScheme
- //
- this.tblScheme.ColumnCount = 4;
- this.tblScheme.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.004F));
- this.tblScheme.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
- this.tblScheme.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
- this.tblScheme.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
- this.tblScheme.Controls.Add(this.lblScheme, 0, 0);
- this.tblScheme.Controls.Add(this.rdoHttps, 1, 0);
- this.tblScheme.Controls.Add(this.rdoQuic, 2, 0);
- this.tblScheme.Controls.Add(this.chkPadding, 3, 0);
- this.tblScheme.Location = new System.Drawing.Point(12, 13);
- this.tblScheme.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.tblScheme.Name = "tblScheme";
- this.tblScheme.RowCount = 1;
- this.tblScheme.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tblScheme.Size = new System.Drawing.Size(372, 27);
- this.tblScheme.TabIndex = 12;
+ // tlpScheme
+ //
+ this.tlpScheme.ColumnCount = 4;
+ this.tlpScheme.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.004F));
+ this.tlpScheme.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
+ this.tlpScheme.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
+ this.tlpScheme.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 26.66533F));
+ this.tlpScheme.Controls.Add(this.lblScheme, 0, 0);
+ this.tlpScheme.Controls.Add(this.rdoHttps, 1, 0);
+ this.tlpScheme.Controls.Add(this.rdoQuic, 2, 0);
+ this.tlpScheme.Controls.Add(this.chkPadding, 3, 0);
+ this.tlpScheme.Location = new System.Drawing.Point(153, 13);
+ this.tlpScheme.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.tlpScheme.Name = "tlpScheme";
+ this.tlpScheme.RowCount = 1;
+ this.tlpScheme.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tlpScheme.Size = new System.Drawing.Size(372, 27);
+ this.tlpScheme.TabIndex = 12;
//
// lblScheme
//
@@ -333,24 +338,24 @@ private void InitializeComponent()
this.chkPadding.UseVisualStyleBackColor = true;
this.chkPadding.CheckedChanged += new System.EventHandler(this.chkPadding_CheckedChanged);
//
- // tblOperate
- //
- this.tblOperate.ColumnCount = 4;
- this.tblOperate.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
- this.tblOperate.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
- this.tblOperate.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
- this.tblOperate.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
- this.tblOperate.Controls.Add(this.lblSave, 0, 0);
- this.tblOperate.Controls.Add(this.btnRun, 1, 0);
- this.tblOperate.Controls.Add(this.lblExit, 3, 0);
- this.tblOperate.Controls.Add(this.lblStop, 2, 0);
- this.tblOperate.Location = new System.Drawing.Point(12, 171);
- this.tblOperate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.tblOperate.Name = "tblOperate";
- this.tblOperate.RowCount = 1;
- this.tblOperate.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
- this.tblOperate.Size = new System.Drawing.Size(372, 42);
- this.tblOperate.TabIndex = 13;
+ // tlpOperate
+ //
+ this.tlpOperate.ColumnCount = 4;
+ this.tlpOperate.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
+ this.tlpOperate.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
+ this.tlpOperate.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
+ this.tlpOperate.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 25F));
+ this.tlpOperate.Controls.Add(this.lblSave, 0, 0);
+ this.tlpOperate.Controls.Add(this.btnRun, 1, 0);
+ this.tlpOperate.Controls.Add(this.lblExit, 3, 0);
+ this.tlpOperate.Controls.Add(this.lblStop, 2, 0);
+ this.tlpOperate.Location = new System.Drawing.Point(153, 171);
+ this.tlpOperate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.tlpOperate.Name = "tlpOperate";
+ this.tlpOperate.RowCount = 1;
+ this.tlpOperate.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
+ this.tlpOperate.Size = new System.Drawing.Size(372, 42);
+ this.tlpOperate.TabIndex = 13;
//
// lblSave
//
@@ -405,30 +410,42 @@ private void InitializeComponent()
// tsmGlobal
//
this.tsmGlobal.Name = "tsmGlobal";
- this.tsmGlobal.Size = new System.Drawing.Size(180, 22);
+ this.tsmGlobal.Size = new System.Drawing.Size(117, 22);
this.tsmGlobal.Text = "Global";
this.tsmGlobal.Click += new System.EventHandler(this.tsmGlobal_Click);
//
// tsmGFWList
//
this.tsmGFWList.Name = "tsmGFWList";
- this.tsmGFWList.Size = new System.Drawing.Size(180, 22);
+ this.tsmGFWList.Size = new System.Drawing.Size(117, 22);
this.tsmGFWList.Text = "GFWList";
this.tsmGFWList.Click += new System.EventHandler(this.tsmGFWList_Click);
//
// tsmGeoIP
//
this.tsmGeoIP.Name = "tsmGeoIP";
- this.tsmGeoIP.Size = new System.Drawing.Size(180, 22);
+ this.tsmGeoIP.Size = new System.Drawing.Size(117, 22);
this.tsmGeoIP.Text = "GeoIP";
this.tsmGeoIP.Click += new System.EventHandler(this.tsmGeoIP_Click);
//
- // smiAbout
+ // smiRun
//
- this.smiAbout.Name = "smiAbout";
- this.smiAbout.Size = new System.Drawing.Size(194, 22);
- this.smiAbout.Text = "About...";
- this.smiAbout.Click += new System.EventHandler(this.smiAbout_Click);
+ this.smiRun.Name = "smiRun";
+ this.smiRun.Size = new System.Drawing.Size(194, 22);
+ this.smiRun.Text = "Run";
+ this.smiRun.Click += new System.EventHandler(this.smiRun_Click);
+ //
+ // smiStop
+ //
+ this.smiStop.Name = "smiStop";
+ this.smiStop.Size = new System.Drawing.Size(194, 22);
+ this.smiStop.Text = "Stop";
+ this.smiStop.Click += new System.EventHandler(this.smiStop_Click);
+ //
+ // tss1
+ //
+ this.tss1.Name = "tss1";
+ this.tss1.Size = new System.Drawing.Size(191, 6);
//
// smiCopyShareLink
//
@@ -449,19 +466,12 @@ private void InitializeComponent()
this.tss2.Name = "tss2";
this.tss2.Size = new System.Drawing.Size(191, 6);
//
- // smiRun
- //
- this.smiRun.Name = "smiRun";
- this.smiRun.Size = new System.Drawing.Size(194, 22);
- this.smiRun.Text = "Run";
- this.smiRun.Click += new System.EventHandler(this.smiRun_Click);
- //
- // smiStop
+ // smiAbout
//
- this.smiStop.Name = "smiStop";
- this.smiStop.Size = new System.Drawing.Size(194, 22);
- this.smiStop.Text = "Stop";
- this.smiStop.Click += new System.EventHandler(this.smiStop_Click);
+ this.smiAbout.Name = "smiAbout";
+ this.smiAbout.Size = new System.Drawing.Size(194, 22);
+ this.smiAbout.Text = "About...";
+ this.smiAbout.Click += new System.EventHandler(this.smiAbout_Click);
//
// smiExit
//
@@ -470,21 +480,60 @@ private void InitializeComponent()
this.smiExit.Text = "Exit";
this.smiExit.Click += new System.EventHandler(this.smiExit_Click);
//
- // tss1
- //
- this.tss1.Name = "tss1";
- this.tss1.Size = new System.Drawing.Size(191, 6);
+ // tvwNodeList
+ //
+ this.tvwNodeList.Location = new System.Drawing.Point(12, 12);
+ this.tvwNodeList.Name = "tvwNodeList";
+ this.tvwNodeList.Size = new System.Drawing.Size(134, 154);
+ this.tvwNodeList.TabIndex = 14;
+ this.tvwNodeList.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvwNodeList_AfterSelect);
+ //
+ // tlpNodeListControl
+ //
+ this.tlpNodeListControl.ColumnCount = 2;
+ this.tlpNodeListControl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
+ this.tlpNodeListControl.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
+ this.tlpNodeListControl.Controls.Add(this.btnDelNode, 1, 0);
+ this.tlpNodeListControl.Controls.Add(this.btnAddNode, 0, 0);
+ this.tlpNodeListControl.Location = new System.Drawing.Point(12, 171);
+ this.tlpNodeListControl.Name = "tlpNodeListControl";
+ this.tlpNodeListControl.RowCount = 1;
+ this.tlpNodeListControl.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
+ this.tlpNodeListControl.Size = new System.Drawing.Size(134, 42);
+ this.tlpNodeListControl.TabIndex = 15;
+ //
+ // btnDelNode
+ //
+ this.btnDelNode.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.btnDelNode.Location = new System.Drawing.Point(70, 6);
+ this.btnDelNode.Name = "btnDelNode";
+ this.btnDelNode.Size = new System.Drawing.Size(61, 29);
+ this.btnDelNode.TabIndex = 1;
+ this.btnDelNode.Text = "Delete";
+ this.btnDelNode.UseVisualStyleBackColor = true;
+ //
+ // btnAddNode
+ //
+ this.btnAddNode.Anchor = System.Windows.Forms.AnchorStyles.None;
+ this.btnAddNode.Location = new System.Drawing.Point(3, 6);
+ this.btnAddNode.Name = "btnAddNode";
+ this.btnAddNode.Size = new System.Drawing.Size(61, 29);
+ this.btnAddNode.TabIndex = 0;
+ this.btnAddNode.Text = "Add";
+ this.btnAddNode.UseVisualStyleBackColor = true;
//
// MainWindow
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Window;
- this.ClientSize = new System.Drawing.Size(393, 221);
- this.Controls.Add(this.tblOperate);
- this.Controls.Add(this.tblScheme);
- this.Controls.Add(this.tblProxyMode);
- this.Controls.Add(this.tblInfo);
+ this.ClientSize = new System.Drawing.Size(534, 221);
+ this.Controls.Add(this.tlpNodeListControl);
+ this.Controls.Add(this.tvwNodeList);
+ this.Controls.Add(this.tlpOperate);
+ this.Controls.Add(this.tlpScheme);
+ this.Controls.Add(this.tlpProxyMode);
+ this.Controls.Add(this.tlpInfo);
this.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
@@ -494,14 +543,15 @@ private void InitializeComponent()
this.Text = "Naive # 0.5 Preview";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainWindow_FormClosing);
this.Load += new System.EventHandler(this.MainWindows_Load);
- this.tblInfo.ResumeLayout(false);
- this.tblInfo.PerformLayout();
- this.tblProxyMode.ResumeLayout(false);
- this.tblProxyMode.PerformLayout();
- this.tblScheme.ResumeLayout(false);
- this.tblScheme.PerformLayout();
- this.tblOperate.ResumeLayout(false);
+ this.tlpInfo.ResumeLayout(false);
+ this.tlpInfo.PerformLayout();
+ this.tlpProxyMode.ResumeLayout(false);
+ this.tlpProxyMode.PerformLayout();
+ this.tlpScheme.ResumeLayout(false);
+ this.tlpScheme.PerformLayout();
+ this.tlpOperate.ResumeLayout(false);
this.cmsNotify.ResumeLayout(false);
+ this.tlpNodeListControl.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -521,10 +571,10 @@ private void InitializeComponent()
private System.Windows.Forms.RadioButton rdoGlobal;
public System.Windows.Forms.RadioButton rdoHttps;
public System.Windows.Forms.RadioButton rdoQuic;
- private System.Windows.Forms.TableLayoutPanel tblInfo;
- private System.Windows.Forms.TableLayoutPanel tblOperate;
- private System.Windows.Forms.TableLayoutPanel tblProxyMode;
- private System.Windows.Forms.TableLayoutPanel tblScheme;
+ private System.Windows.Forms.TableLayoutPanel tlpInfo;
+ private System.Windows.Forms.TableLayoutPanel tlpOperate;
+ private System.Windows.Forms.TableLayoutPanel tlpProxyMode;
+ private System.Windows.Forms.TableLayoutPanel tlpScheme;
public System.Windows.Forms.TextBox txtHost;
public System.Windows.Forms.TextBox txtPassword;
public System.Windows.Forms.TextBox txtUsername;
@@ -545,6 +595,10 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem tsmGFWList;
private System.Windows.Forms.ToolStripMenuItem tsmGeoIP;
private System.Windows.Forms.ToolStripSeparator tss1;
+ private System.Windows.Forms.TableLayoutPanel tlpNodeListControl;
+ private System.Windows.Forms.Button btnDelNode;
+ private System.Windows.Forms.Button btnAddNode;
+ public System.Windows.Forms.TreeView tvwNodeList;
}
}
diff --git a/NaiveSharp/View/MainWindow.cs b/NaiveSharp/View/MainWindow.cs
index 5d16d7f..bcf91aa 100644
--- a/NaiveSharp/View/MainWindow.cs
+++ b/NaiveSharp/View/MainWindow.cs
@@ -15,6 +15,11 @@ public MainWindow()
{
InitializeComponent();
SyncModeToSMI();
+
+ // THIS IS FOR TEST
+ // TODO: LOGIC
+ NodeList.LoadFromStringArray(ref this.tvwNodeList, new string[] { "naive+https://what:happened@test.someone.cf?padding=false#Naive!", "[222]", "naive+https://some.public.rs?padding=true#Public-01" });
+
if (File.Exists(PATH.CONFIG_NODE_NS))
{
try
@@ -30,7 +35,7 @@ public MainWindow()
private void MainWindows_Load(object sender, EventArgs e)
{
- if (System.IO.File.Exists("DEBUG"))
+ if (File.Exists("DEBUG"))
{
Config.Debug = true;
this.Text = "[DEBUG]" + this.Text;
@@ -241,5 +246,10 @@ private void tsmGeoIP_Click(object sender, EventArgs e)
tsmGFWList.Checked = tsmGFWList.Checked = false;
SyncModeToSMI();
}
+
+ private void tvwNodeList_AfterSelect(object sender, TreeViewEventArgs e)
+ {
+ MessageBox.Show((string)tvwNodeList.SelectedNode.Tag);
+ }
}
}
\ No newline at end of file