(六十五)c#Winform自定义控件-思维导图/组织架构图(工业)

前提入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。GitHub:https://github.com/kwwwvagaa/NetWinformControl码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git如果觉得写的还行,请点个star支持一下吧欢迎前来交流探讨:企鹅群568015492麻烦博客下...

(六十五)c#Winform自定义控件-思维导图/组织架构图(工业)

前提

入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。

GitHub:https://github.com/kwwwvagaa/NetWinformControl

码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

如果觉得写的还行,请点个 star 支持一下吧

欢迎前来交流探讨: 企鹅群568015492企鹅群568015492

麻烦博客下方点个【推荐】,谢谢

NuGet

Install-Package HZH_Controls

目录

https://www.cnblogs.com/bfyx/p/11364884.html

用处及效果

准备工作

依然是用GDI 画的,不懂的可以先百度一下

开始

添加一个实体类,用以记录数据源节点信息

  1  public class MindMappingItemEntity  2  {  3/// <summary>  4/// Gets or sets the identifier.  5/// </summary>  6/// <value>The identifier.</value>  7public string ID { get; set; }  8private string _text;  9/// <summary> 10/// Gets or sets the text. 11/// </summary> 12/// <value>The text.</value> 13public string Text 14   { 15 get { return _text; } 16 set 17 { 18  _text = value; 19  ResetSize(); 20 } 21   } 22/// <summary> 23/// Gets or sets the data source. 24/// </summary> 25/// <value>The data source.</value> 26public object DataSource { get; set; } 27/// <summary> 28/// The childrens 29/// </summary> 30private MindMappingItemEntity[] _Childrens; 31/// <summary> 32/// Gets or sets the childrens. 33/// </summary> 34/// <value>The childrens.</value> 35public MindMappingItemEntity[] Childrens 36   { 37 get { return _Childrens; } 38 set 39 { 40  _Childrens = value; 41  if (value != null && value.Length > 0) 42  { 43value.ToList().ForEach(p => { if (p != null) { p.ParentItem = this; } }); 44  } 45 } 46   } 47/// <summary> 48/// The back color 49/// </summary> 50private Color backColor = Color.Transparent; 51  52/// <summary> 53/// Gets or sets the color of the back. 54/// </summary> 55/// <value>The color of the back.</value> 56public Color BackColor 57   { 58 get { return backColor; } 59 set { backColor = value; } 60   } 61  62private Font font = new Font("微软雅黑", 10); 63  64public Font Font 65   { 66 get { return font; } 67 set 68 { 69  font = value; 70  ResetSize(); 71 } 72   } 73  74/// <summary> 75/// The fore color 76/// </summary> 77private Color foreColor = Color.Black; 78  79/// <summary> 80/// Gets or sets the color of the fore. 81/// </summary> 82/// <value>The color of the fore.</value> 83public Color ForeColor 84   { 85 get { return foreColor; } 86 set { foreColor = value; } 87   } 88private bool _IsExpansion = false; 89/// <summary> 90/// Gets or sets a value indicating whether the instance is expanded. 91/// </summary> 92/// <value><c>true</c> if this instance is expansion; otherwise, <c>false</c>.</value> 93public bool IsExpansion 94   {
源文地址:https://www.guoxiongfei.cn/cntech/26821.html