当前位置: 首页 > news >正文

C#使用开源框架NetronLight绘制流程图

之前使用MindFusion.Diagramming绘制流程图确认很方便,只能试用版,如果长期使用,需要收费。

C#使用MindFusion.Diagramming框架绘制流程图(2):流程图示例_c# 画流程图控件-CSDN博客

这里找一个简易开源框架NetronLight,GIT下载地址

GitCode - 全球开发者的开源社区,开源代码托管平台

NetronLight

NetronLight框架-图控件【GraphControl】是由多个形状节点【ShapeBase】和多个连线【Connection】组成。
 * SimpleRectangle由矩形Rect和四个连接端点【Connector】组成
 * Entity抽象类 表示 图diagram中某一个对象,是所有图的组成对象的基类
 * ①Connector 连接端点 或 【可以附着连接的形状的位置点】: 
 *    主要属性:string Name、Connector AttachedTo、Point Point
 * ②ShapeBase 形状基类
 *    主要属性:ConnectorCollection Connectors【一般来说固定Bottom, Left, Right, Top四个端点】、Rectangle rectangle、string Text、Point Location、Color ShapeColor
 *    派生三个子类   SimpleRectangle【矩形节点】、OvalShape【椭圆节点】、TextLabel【文本标签】
 * ③Connection 连线【节点之间的连线:只能通过 Connector Bottom, Left, Right, Top 这四个点进行连线】
 *    主要属性:Connector From、Connector To

新建窗体应用程序NetronLightDemo,添加对NetronLight项目【或NetronLight.dll】的引用

将默认的Form1重命名为FormNetronLightDemo,

窗体FormNetronLightDemo设计器程序如下:

FormNetronLightDemo.Designer.cs文件


namespace NetronLightDemo
{partial class FormNetronLightDemo{/// <summary>/// 必需的设计器变量。/// </summary>private System.ComponentModel.IContainer components = null;/// <summary>/// 清理所有正在使用的资源。/// </summary>/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>protected override void Dispose(bool disposing){if (disposing && (components != null)){components.Dispose();}base.Dispose(disposing);}#region Windows 窗体设计器生成的代码/// <summary>/// 设计器支持所需的方法 - 不要修改/// 使用代码编辑器修改此方法的内容。/// </summary>private void InitializeComponent(){this.graphControl1 = new NetronLight.GraphControl();this.SuspendLayout();// // graphControl1// this.graphControl1.Location = new System.Drawing.Point(12, 4);this.graphControl1.Name = "graphControl1";this.graphControl1.ShowGrid = true;this.graphControl1.Size = new System.Drawing.Size(1093, 592);this.graphControl1.TabIndex = 0;this.graphControl1.Text = "graphControl1";// // FormNetronLightDemo// this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;this.ClientSize = new System.Drawing.Size(1117, 608);this.Controls.Add(this.graphControl1);this.Name = "FormNetronLightDemo";this.Text = "NetronLight框架-图控件【GraphControl】是由多个形状节点【ShapeBase】和多个连线【Connection】组成。Shape由矩形Rec" +"t和四个连接端点【Connector】组成";this.ResumeLayout(false);}#endregionprivate NetronLight.GraphControl graphControl1;}
}

窗体FormNetronLightDemo测试程序如下:

FormNetronLightDemo.cs文件

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NetronLight;namespace NetronLightDemo
{public partial class FormNetronLightDemo : Form{public FormNetronLightDemo(){InitializeComponent();InitDiagram();}/// <summary>/// 初始化一个图/// </summary>private void InitDiagram() {//纯文本标签,无端点TextLabel textLabel = new TextLabel(graphControl1);textLabel.Text = "开源图表框架:NetronLight演示";textLabel.Width = 350;textLabel.Height = 33;textLabel.Location = new Point(100,33);graphControl1.Shapes.Add(textLabel);SimpleRectangle ent = this.graphControl1.AddShape(ShapeTypes.Rectangular, new Point(400, 100)) as SimpleRectangle;ent.Text = "Entity抽象类:所有图的组成对象的基类";ent.Height = 33;ent.Width = 300;ent.ShapeColor = Color.SteelBlue;SimpleRectangle conn = this.graphControl1.AddShape(ShapeTypes.Rectangular, new Point(10, 220)) as SimpleRectangle;conn.Text = "Connection连线:只能通过 Connector Bottom, Left, Right, Top 这四个端点进行连线";conn.Height = 33;conn.Width = 600;conn.ShapeColor = Color.LightSteelBlue;SimpleRectangle shbase = this.graphControl1.AddShape(ShapeTypes.Rectangular, new Point(600, 285)) as SimpleRectangle;shbase.Text = "ShapeBase:形状基类,由四个端口和含有文本的矩形组成";shbase.Height = 33;shbase.Width = 420;shbase.ShapeColor = Color.LightSteelBlue;SimpleRectangle con = this.graphControl1.AddShape(ShapeTypes.Rectangular, new Point(700, 170)) as SimpleRectangle;con.Text = "Connector端口:可以附着连接的形状的位置点";con.Height = 33;con.Width = 350;con.ShapeColor = Color.LightSteelBlue;OvalShape oval = this.graphControl1.AddShape(ShapeTypes.Oval, new Point(450, 360)) as OvalShape;oval.Text = "Oval:椭圆节点";oval.Height = 43;oval.Width = 130;oval.ShapeColor = Color.AliceBlue;OvalShape rec = this.graphControl1.AddShape(ShapeTypes.Oval, new Point(620, 460)) as OvalShape;rec.Text = "SimpleRectangle:矩形节点";rec.Height = 43;rec.Width = 250;rec.ShapeColor = Color.AliceBlue;OvalShape tl = this.graphControl1.AddShape(ShapeTypes.Oval, new Point(850, 360)) as OvalShape;tl.Text = "TextLabel:纯文本节点";tl.Height = 43;tl.Width = 200;tl.ShapeColor = Color.AliceBlue;//创建连线:形状节点 由固定的四个端点Connector组成【Bottom:索引0, Left:索引1, Right:索引2, Top:索引3】graphControl1.AddConnection(ent.Connectors[0], conn.Connectors[3]);graphControl1.AddConnection(ent.Connectors[0], con.Connectors[3]);graphControl1.AddConnection(ent.Connectors[0], shbase.Connectors[3]);graphControl1.AddConnection(shbase.Connectors[0], oval.Connectors[3]);graphControl1.AddConnection(shbase.Connectors[0], rec.Connectors[3]);graphControl1.AddConnection(shbase.Connectors[0], tl.Connectors[3]);}}
}
/** NetronLight框架-图控件【GraphControl】是由多个形状节点【ShapeBase】和多个连线【Connection】组成。* SimpleRectangle由矩形Rect和四个连接端点【Connector】组成* Entity抽象类 表示 图diagram中某一个对象,是所有图的组成对象的基类* ①Connector 连接端点 或 【可以附着连接的形状的位置点】: *    主要属性:string Name、Connector AttachedTo、Point Point* ②ShapeBase 形状基类*    主要属性:ConnectorCollection Connectors【一般来说固定Bottom, Left, Right, Top四个端点】、Rectangle rectangle、string Text、Point Location、Color ShapeColor*    派生三个子类   SimpleRectangle【矩形节点】、OvalShape【椭圆节点】、TextLabel【文本标签】* ③Connection 连线【节点之间的连线:只能通过 Connector Bottom, Left, Right, Top 这四个点进行连线】*    主要属性:Connector From、Connector To
*/

运行如图:

http://www.dtcms.com/a/267332.html

相关文章:

  • Hinge×亚矩云手机:以“深度连接”为名,重构云端社交的“真实感”
  • AI 正在深度重构软件开发的底层逻辑和全生命周期,从技术演进、流程重构和未来趋势三个维度进行系统性分析
  • Jedis 原生之道:Redis 命令 Java 实现指南(二)
  • SpringAI与智能体入门
  • 探索 Ubuntu 上 MongoDB 的安装过程
  • NX二次开发常用函数——获取边对应的面 UF_MODL_ask_edge_faces
  • 使用 C++/Faiss 加速海量 MFCC 特征的相似性搜索
  • 电脑休眠设置
  • 【网络与爬虫 13】智能伪装:Scrapy-Fake-UserAgent反检测技术实战指南
  • springboot中使用线程池
  • 【Elasticsearch】检索排序 分页
  • 20. 有效的括号
  • BUUCTF在线评测-练习场-WebCTF习题[网鼎杯 2020 青龙组]AreUSerialz1-flag获取、解析
  • 【Flask】flask中get方法和post方法区别
  • CMake基础:条件判断详解
  • openai和chatgpt什么关系
  • 单用户模式、紧急模式、救援模式有什么区别
  • 动手学深度学习-学习笔记【二】(基础知识)
  • 若 VSCode 添加到文件夹内右键菜单中显示(通过reg文件方式)
  • 在 Windows 上安装和运行 Apache Kafka
  • Android Input 系列专题【事件的读取与分发】
  • 在SSM+vue项目中上传表单数据和文件
  • android开发中的 AndroidX 版本的查看 及 constraintLayout的简单用法
  • 【性能优化】程序性能优化:疏通胜于堵塞
  • 【Elasticsearch】检索高亮
  • 成为git砖家(12): 看懂git合并分支时冲突提示符
  • HTML初学者第三天
  • hono框架绑定cloudflare的d1数据库操作步骤
  • Redis基础的介绍与使用(一)(Redis简介以及Redis下载和安装)
  • Git 版本控制完全指南:从入门到精通