UCMindMappingPanel.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. // ***********************************************************************
  2. // Assembly : HZH_Controls
  3. // Created : 2019-09-11
  4. //
  5. // ***********************************************************************
  6. // <copyright file="UCMindMappingPanel.cs">
  7. // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
  8. // </copyright>
  9. //
  10. // Blog: https://www.cnblogs.com/bfyx
  11. // GitHub:https://github.com/kwwwvagaa/NetWinformControl
  12. // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
  13. //
  14. // If you use this code, please keep this note.
  15. // ***********************************************************************
  16. using System;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. using System.Drawing;
  20. using System.Data;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Windows.Forms;
  24. namespace HZH_Controls.Controls
  25. {
  26. /// <summary>
  27. /// Class UCMindMappingPanel.
  28. /// Implements the <see cref="System.Windows.Forms.UserControl" />
  29. /// </summary>
  30. /// <seealso cref="System.Windows.Forms.UserControl" />
  31. [DefaultEvent("ItemClicked")]
  32. public partial class UCMindMappingPanel : UserControl
  33. {
  34. /// <summary>
  35. /// The item context menu strip
  36. /// </summary>
  37. private ContextMenuStrip itemContextMenuStrip;
  38. /// <summary>
  39. /// Gets or sets the item context menu strip.
  40. /// </summary>
  41. /// <value>The item context menu strip.</value>
  42. [Description("节点关联的右键菜单"), Category("自定义")]
  43. public ContextMenuStrip ItemContextMenuStrip
  44. {
  45. get { return itemContextMenuStrip; }
  46. set
  47. {
  48. itemContextMenuStrip = value;
  49. this.ucMindMapping1.ItemContextMenuStrip = value;
  50. }
  51. }
  52. /// <summary>
  53. /// The item backcolor
  54. /// </summary>
  55. private Color itemBackcolor = Color.FromArgb(255, 77, 59);
  56. /// <summary>
  57. /// Gets or sets the item backcolor.
  58. /// </summary>
  59. /// <value>The item backcolor.</value>
  60. [Description("节点背景色,优先级小于数据源中设置的背景色"), Category("自定义")]
  61. public Color ItemBackcolor
  62. {
  63. get { return itemBackcolor; }
  64. set
  65. {
  66. itemBackcolor = value;
  67. this.ucMindMapping1.ItemBackcolor = value;
  68. }
  69. }
  70. /// <summary>
  71. /// The data source
  72. /// </summary>
  73. private MindMappingItemEntity dataSource;
  74. /// <summary>
  75. /// Gets or sets the data source.
  76. /// </summary>
  77. /// <value>The data source.</value>
  78. [Description("数据源"), Category("自定义")]
  79. public MindMappingItemEntity DataSource
  80. {
  81. get { return dataSource; }
  82. set
  83. {
  84. dataSource = value;
  85. this.ucMindMapping1.DataSource = value;
  86. }
  87. }
  88. /// <summary>
  89. /// Gets or sets the data source.
  90. /// </summary>
  91. /// <value>The data source.</value>
  92. [Description("数据源"), Category("自定义")]
  93. public event EventHandler ItemClicked;
  94. /// <summary>
  95. /// The line color
  96. /// </summary>
  97. private Color lineColor = Color.Black;
  98. /// <summary>
  99. /// Gets or sets the color of the line.
  100. /// </summary>
  101. /// <value>The color of the line.</value>
  102. [Description("线条颜色"), Category("自定义")]
  103. public Color LineColor
  104. {
  105. get { return lineColor; }
  106. set
  107. {
  108. lineColor = value;
  109. this.ucMindMapping1.LineColor = value;
  110. }
  111. }
  112. /// <summary>
  113. /// Gets the select entity.
  114. /// </summary>
  115. /// <value>The select entity.</value>
  116. [Description("选中的数据源"), Category("自定义")]
  117. public MindMappingItemEntity SelectEntity
  118. {
  119. get { return ucMindMapping1.SelectEntity; }
  120. }
  121. /// <summary>
  122. /// Initializes a new instance of the <see cref="UCMindMappingPanel" /> class.
  123. /// </summary>
  124. public UCMindMappingPanel()
  125. {
  126. this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  127. this.SetStyle(ControlStyles.DoubleBuffer, true);
  128. this.SetStyle(ControlStyles.ResizeRedraw, true);
  129. this.SetStyle(ControlStyles.Selectable, true);
  130. this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
  131. this.SetStyle(ControlStyles.UserPaint, true);
  132. InitializeComponent();
  133. ucMindMapping1.ItemClicked += ucMindMapping1_ItemClicked;
  134. }
  135. /// <summary>
  136. /// Handles the ItemClicked event of the ucMindMapping1 control.
  137. /// </summary>
  138. /// <param name="sender">The source of the event.</param>
  139. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  140. void ucMindMapping1_ItemClicked(object sender, EventArgs e)
  141. {
  142. if (ItemClicked != null)
  143. {
  144. ItemClicked(sender, e);
  145. }
  146. }
  147. }
  148. }