From 98acd52e2551c5be60ddd2b78d3b8537ba35d7dd Mon Sep 17 00:00:00 2001 From: DebugST <74035651+DebugST@users.noreply.github.com> Date: Fri, 30 Apr 2021 14:34:57 +0800 Subject: [PATCH 1/5] update v2.0 md update v2.0 md --- README.md | 136 +++++++++++++++++++----------------------------------- 1 file changed, 47 insertions(+), 89 deletions(-) diff --git a/README.md b/README.md index 1131111..34a73ed 100644 --- a/README.md +++ b/README.md @@ -1,106 +1,64 @@ -## STNodeEditor +# STNodeEditor -`STNodeEditor` 是一个很不错的节点编辑器 使用方式非常简洁 提供了丰富的属性以及事件 可以非常方便的完成节点之间数据的交互及通知 大量的重载函数供开发者使用具有很高的自由性 +STNodeEditor 是一个轻量且功能强大的节点编辑器 使用方式非常简洁 提供了丰富的属性以及事件可以非常方便的完成节点之间数据的交互及通知 大量的重载函数供开发者使用具有很高的自由性 -编译环境: `VS 2010 (.Net 3.5)` +![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/page_top.png) -![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/node.png) +# STNodeEditor -此控件采用 [`MIT`](https://opensource.org/licenses/mit-license.php) 开源协议开源 使开发者能够拥有更大的自由度更少的限制 +![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/stnodeeditor.gif) -`STNodeEditor` 拥有非常方便的UI自定义能力 提供的 `STNodeControl` 基类 可以让开发者能够像自定义 `WinForm` 控件一样去定义 节点需要的控件 +`STNodeEditor`拥有非常强大的功能 支持画布的移动和缩放 可以对节点位置以及连线进行锁定 连线时候会自动检测数据类型是否兼容 以及连线是否重复或者构成环形线路等问题 -![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/formImage.png) +* 拖动标题移动节点 +* 右击标题弹出菜单 (需要设置`ContextMenuStrip`) +* 拖动连接点进行连线 +* 右击连线断开连接 +* 中键拖动移动画布 (若笔记本触摸板支持 可二指拖动) +* CTRL+鼠标滚轮 缩放画布 -## 简要说明 -* 画布 - * 移动 `鼠标中键` 拖动 Mac用户可二指拖动 `触控板` - * 缩放 按下 `Control` + `鼠标滚轮` - * 画布中的节点内容以及连线关系可通过 `STNodeEditor.Load/SaveCanvas()` 加载或者保存 -* 删除连线 - * 悬停到连线上 `鼠标右键` -* 移动节点 - * `鼠标左键` 拖动 `节点标题` - * 之所以是拖动标题而不是节点任意位置 是因为作者的设计思路是将节点视为一个 `窗体` 窗体的客户区域留给开发者自定义 -* STNode - * 如同 `System.Windows.Forms.TreeView` 一样 所有的节点都保存在 `STNodeEditor.Nodes` 中 其数据类型为 `STNode` - * `STNode` 为抽象类被 `abstract` 修饰 需要开发者自己继承向节点中添加选项 - * `STNode` 有三个重要属性 `InputOptions` `OutputOptions` `Controls` +注:节点Body区域进行的操作编辑器不会响应 因为在节点客户区内部的操作将被转换为节点的事件 -## 示例 -```cs -public class DemoNode : STNode -{ - protected override void OnCreate() { - //在创建节点时候向其添加需要的选项 - base.OnCreate(); - this.InputOptions.Add(new STNodeOption("Input", typeof(string), false)); - this.InputOptions.Add(new STNodeOption("SingleNode", typeof(System.Drawing.Image), true)); - this.InputOptions.Add(new STNodeOption("SingleNode", typeof(object), true)); +因为作者将一个节点视为一个`Form` 而编辑器容器则为`Desktop` 开发者可以像开发`WinForm`程序一样去开发一个节点 - this.OutputOptions.Add(new STNodeOption("output", typeof(string), false)); - this.OutputOptions.Add(new STNodeOption("Single", typeof(System.Drawing.Icon), true)); - this.OutputOptions.Add(new STNodeOption("Single", typeof(object), true)); +# STNodeHub - this.Title = "Demo_Node"; - } -} -//stNodeEditor1.SetTypeColor(type, color);此方法会自动替换已存在值 -stNodeEditor1.TypeColor.Add(typeof(string), Color.Yellow); -stNodeEditor1.TypeColor.Add(typeof(Image), Color.Red); -stNodeEditor1.Nodes.Add(new DemoNode()); -``` -上述代码的 `DemoNode` 被添加到节点编辑器中的效果为 +![STNodeHub](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/stnodehub.gif) -![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/node_demo.png) +`STNodeHub`是一个内置的节点 其主要作用分线 可以将一个输出分散到多个输入或多个输出集中到一个输入点上以避免重复布线 也可在节点布线复杂时用于绕线 -由此可见 开发者要自定义一个节点相当便捷 当然上述代码并没有包含事件处理 上述代码仅仅是在演示 `STNodeOption` 的效果 下列代码则是一个包含了计算两个整数和的功能 -```cs -public class NodeNumberAdd : STNode -{ - private STNodeOption m_in_num1; - private STNodeOption m_in_num2; - private STNodeOption m_out_num; - private int m_nNum1, m_nNum2; +HUB的输入输出默认为`object`类型 当一个连接被连入时候将会自动更换数据类型并增加新行 - protected override void OnCreate() { - base.OnCreate(); - this.Title = "NumberAdd"; - m_in_num1 = new STNodeOption("num1", typeof(int), true);//只能有一个连线 - m_in_num2 = new STNodeOption("num2", typeof(int), true);//只能有一个连线 - m_out_num = new STNodeOption("result", typeof(int), false);//可以多个连线 - this.InputOptions.Add(m_in_num1); - this.InputOptions.Add(m_in_num2); - this.OutputOptions.Add(m_out_num); - m_in_num1.DataTransfer += new STNodeOptionEventHandler(m_in_num_DataTransfer); - m_in_num2.DataTransfer += new STNodeOptionEventHandler(m_in_num_DataTransfer); - } - //当有数据传入时 - void m_in_num_DataTransfer(object sender, STNodeOptionEventArgs e) { - //判断连线是否是连接状态(建立连线 断开连线 都会触发该事件) - if (e.Status == ConnectionStatus.Connected) { - if (sender == m_in_num1) - m_nNum1 = (int)e.TargetOption.Data;//TargetOption为触发此事件的Option - else - m_nNum2 = (int)e.TargetOption.Data; - } else { - if (sender == m_in_num1) m_nNum1 = 0; else m_nNum2 = 0; - } - //向输出选项上的所有连线传输数据 输出选项上的所有连线都会触发 DataTransfer 事件 - m_out_num.TransferData(m_nNum1 + m_nNum2); //m_out_num.Data 将被自动设置 - } +注:仅`STNodeHub`可以修改连接点的数据类型 因为相应字段被`internal`标记 而作为第三方扩展的STNode中是无法修改已添加连接点的数据类型的 - protected override void OnOwnerChanged() { - //通常刚被添加到节点编辑器时触发 如是以插件方式提供的节点 应当向编辑器提交数据类型颜色 - base.OnOwnerChanged(); - if (this.Owner == null) return; //或者通过m_in_num1.DotColor = Color.Red;进行设置 - this.Owner.SetTypeColor(typeof(int),Color.Red); - } -} -``` -效果为 +## STNodeTreeView + +![STNodeTreeView](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/stnodetreeview.gif) + +`STNodeTreeView`可与`STNodeEditor`结合使用`STNodeTreeView`中的节点可直接拖拽进`STNodeEditor`中 并且提供预览和检索功能 + +`STNodeTreeView`的使用简单 无需像`System.Windows.Forms.TreeView`需要自行去构造树 + +通过使用`STNodeAttribute`标记继承的`STNode`可直接设置需要在`STNodeTreeView`中显示的路径 以及希望在`STNodePropertyGrid`中显示的信息 + +注:若希望节点能够在`STNodeTreeView`中显示 必须使用`STNodeAttribute`标记`STNode`子类 + +# STNodePropertyGrid + +![STNodePropertyGrid](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/stnodepropertygrid.gif) + +若`STNode`中的属性被`STNodePropertyAttribute`标记则会在`STNodePropertyGrid`中显示 默认情况下支持`int,float,double,bool,string,enum`以及上述数据类型的`Array` 若希望显示的属性数据类型不被支持 可以对`DescriptorType`进行扩展重写 详细请参考DEMO + +可以看到在`STNodePropertyGrid`的面板中可以显示节点的一些信息 作者认为提供给大家的是一套框架 大家可以基于这套框架打造一套自己的框架 而为框架编写节点的`Coder`应该有权利选择是否留下个人信息 + +# STNodeEditorPannel + +![STNodeEditorPannel](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/stnodeeditorpannel.gif) + +`STNodeEditorPannel`是`STNodeEditor` `STNodeTreeView` `STNodePropertyGrid`的一套组合控件 + +可以通过拖动手柄控制布局 -![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/node_add.png) 更多细节请参考文档 @@ -109,6 +67,6 @@ public class NodeNumberAdd : STNode 开发文档: [DebugST.github.io/DotNet_WinForm_NodeEditor/doc.html](https://DebugST.github.io/DotNet_WinForm_NodeEditor/doc.html) ## 关于作者 -* Github: [DebugST](https://DebugST.github.io) +* Github: [DebugST](https://github.com/DebugST/) * Blog: [Crystal_lz](http://st233.com) * Mail: (2212233137@qq.com) From c1c1cf1e38cba634915dc82fda4a211f7c900235 Mon Sep 17 00:00:00 2001 From: DebugST <74035651+DebugST@users.noreply.github.com> Date: Fri, 30 Apr 2021 14:59:54 +0800 Subject: [PATCH 2/5] modified v2.0 md add some images as comment --- README.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 34a73ed..3f1747b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,14 @@ STNodeEditor 是一个轻量且功能强大的节点编辑器 使用方式非常 ![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/page_top.png) +项目主页 (Project home): [DebugST.github.io/DotNet_WinForm_NodeEditor](https://DebugST.github.io/DotNet_WinForm_NodeEditor) (简体中文, English) + +教程文档: [DebugST.github.io/DotNet_WinForm_NodeEditor/doc_cn.html](https://DebugST.github.io/DotNet_WinForm_NodeEditor/doc_cn.html) + +Tutorials and API: [DebugST.github.io/DotNet_WinForm_NodeEditor/doc_en.html](https://DebugST.github.io/DotNet_WinForm_NodeEditor/doc_en.html) + +Mail: (2212233137@qq.com) + # STNodeEditor ![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/stnodeeditor.gif) @@ -17,9 +25,9 @@ STNodeEditor 是一个轻量且功能强大的节点编辑器 使用方式非常 * 中键拖动移动画布 (若笔记本触摸板支持 可二指拖动) * CTRL+鼠标滚轮 缩放画布 -注:节点Body区域进行的操作编辑器不会响应 因为在节点客户区内部的操作将被转换为节点的事件 +__注:节点Body区域进行的操作编辑器不会响应 因为在节点客户区内部的操作将被转换为节点的事件__ -因为作者将一个节点视为一个`Form` 而编辑器容器则为`Desktop` 开发者可以像开发`WinForm`程序一样去开发一个节点 +__因为作者将一个节点视为一个`Form` 而编辑器容器则为`Desktop` 开发者可以像开发`WinForm`程序一样去开发一个节点__ # STNodeHub @@ -29,7 +37,7 @@ STNodeEditor 是一个轻量且功能强大的节点编辑器 使用方式非常 HUB的输入输出默认为`object`类型 当一个连接被连入时候将会自动更换数据类型并增加新行 -注:仅`STNodeHub`可以修改连接点的数据类型 因为相应字段被`internal`标记 而作为第三方扩展的STNode中是无法修改已添加连接点的数据类型的 +__注:仅`STNodeHub`可以修改连接点的数据类型 因为相应字段被`internal`标记 而作为第三方扩展的STNode中是无法修改已添加连接点的数据类型的__ ## STNodeTreeView @@ -41,7 +49,7 @@ HUB的输入输出默认为`object`类型 当一个连接被连入时候将会 通过使用`STNodeAttribute`标记继承的`STNode`可直接设置需要在`STNodeTreeView`中显示的路径 以及希望在`STNodePropertyGrid`中显示的信息 -注:若希望节点能够在`STNodeTreeView`中显示 必须使用`STNodeAttribute`标记`STNode`子类 +__注:若希望节点能够在`STNodeTreeView`中显示 必须使用`STNodeAttribute`标记`STNode`子类__ # STNodePropertyGrid @@ -49,7 +57,9 @@ HUB的输入输出默认为`object`类型 当一个连接被连入时候将会 若`STNode`中的属性被`STNodePropertyAttribute`标记则会在`STNodePropertyGrid`中显示 默认情况下支持`int,float,double,bool,string,enum`以及上述数据类型的`Array` 若希望显示的属性数据类型不被支持 可以对`DescriptorType`进行扩展重写 详细请参考DEMO -可以看到在`STNodePropertyGrid`的面板中可以显示节点的一些信息 作者认为提供给大家的是一套框架 大家可以基于这套框架打造一套自己的框架 而为框架编写节点的`Coder`应该有权利选择是否留下个人信息 +可以看到在`STNodePropertyGrid`的面板中可以显示节点的一些信息 作者认为提供给大家的是一套框架 大家可以基于这套框架打造一套自己的框架 + +__而为框架编写节点的`Coder`应该有权利选择是否留下个人信息__ # STNodeEditorPannel @@ -59,13 +69,6 @@ HUB的输入输出默认为`object`类型 当一个连接被连入时候将会 可以通过拖动手柄控制布局 - -更多细节请参考文档 - -项目主页: [DebugST.github.io/DotNet_WinForm_NodeEditor](https://DebugST.github.io/DotNet_WinForm_NodeEditor) - -开发文档: [DebugST.github.io/DotNet_WinForm_NodeEditor/doc.html](https://DebugST.github.io/DotNet_WinForm_NodeEditor/doc.html) - ## 关于作者 * Github: [DebugST](https://github.com/DebugST/) * Blog: [Crystal_lz](http://st233.com) From ccf3fa5a567d0e20d098e7fa9359f7963cb9ef01 Mon Sep 17 00:00:00 2001 From: DebugST <74035651+DebugST@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:34:31 +0800 Subject: [PATCH 3/5] update format update some format --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3f1747b..2b56f26 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ HUB的输入输出默认为`object`类型 当一个连接被连入时候将会 __注:仅`STNodeHub`可以修改连接点的数据类型 因为相应字段被`internal`标记 而作为第三方扩展的STNode中是无法修改已添加连接点的数据类型的__ -## STNodeTreeView +# STNodeTreeView ![STNodeTreeView](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/stnodetreeview.gif) @@ -69,7 +69,7 @@ __而为框架编写节点的`Coder`应该有权利选择是否留下个人信 可以通过拖动手柄控制布局 -## 关于作者 +# 关于作者 * Github: [DebugST](https://github.com/DebugST/) * Blog: [Crystal_lz](http://st233.com) * Mail: (2212233137@qq.com) From 38a1341e1b6b5d39f639697eba926e6b3cfd8441 Mon Sep 17 00:00:00 2001 From: DebugST <74035651+DebugST@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:45:44 +0800 Subject: [PATCH 4/5] modified some error key world modified some error key world --- docs/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.html b/docs/index.html index 61719d3..49efd88 100644 --- a/docs/index.html +++ b/docs/index.html @@ -64,7 +64,7 @@

STNodeEditor

-

STNodeEditor 是一个轻量且功能强大的节点编辑器 使用方式非常简洁 提供了丰富的属性以及事件可以非常方便的完成节点之间数据的交互及通知 大量的重载函数供开发者使用具有很高的自由性

+

STNodeEditor 是一个轻量且功能强大的节点编辑器 使用方式非常简洁 提供了丰富的属性以及事件可以非常方便的完成节点之间数据的交互及通知 大量的虚函数可供开发者重写具有很高的自由性

下载 STNodeEditor
@@ -215,4 +215,4 @@
- \ No newline at end of file + From 2957bc40c99eb8b8d5245fcbdc9fb2eb1ec1c577 Mon Sep 17 00:00:00 2001 From: DebugST <74035651+DebugST@users.noreply.github.com> Date: Fri, 30 Apr 2021 15:48:35 +0800 Subject: [PATCH 5/5] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b56f26..9be42a5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # STNodeEditor -STNodeEditor 是一个轻量且功能强大的节点编辑器 使用方式非常简洁 提供了丰富的属性以及事件可以非常方便的完成节点之间数据的交互及通知 大量的重载函数供开发者使用具有很高的自由性 +STNodeEditor 是一个轻量且功能强大的节点编辑器 纯`GDI`实现无任何依赖库仅仅`100+Kb` 使用方式非常简洁 提供了丰富的属性以及事件可以非常方便的完成节点之间数据的交互及通知 大量的虚函数可供开发者重写具有很高的自由性 + +Environment: VS2010(.NET 3.5) ![STNodeEditor](https://debugst.github.io/DotNet_WinForm_NodeEditor/images/page_top.png)