mirror of
https://github.com/eggplantlwj/VisionEdit.git
synced 2026-03-24 08:46:35 +08:00
1、优化LOG显示与引用
2、添加PMA工具,工具内容待完善 3、修复流程树显示 4、添加开源项目,优化UI空间 5、其他BUG更改
This commit is contained in:
@@ -0,0 +1,237 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="MindMappingItemEntity.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class MindMappingItemEntity.
|
||||
/// </summary>
|
||||
public class MindMappingItemEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the identifier.
|
||||
/// </summary>
|
||||
/// <value>The identifier.</value>
|
||||
public string ID { get; set; }
|
||||
/// <summary>
|
||||
/// The text
|
||||
/// </summary>
|
||||
private string _text;
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
/// <value>The text.</value>
|
||||
public string Text
|
||||
{
|
||||
get { return _text; }
|
||||
set
|
||||
{
|
||||
_text = value;
|
||||
ResetSize();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
public object DataSource { get; set; }
|
||||
/// <summary>
|
||||
/// The childrens
|
||||
/// </summary>
|
||||
private MindMappingItemEntity[] _Childrens;
|
||||
/// <summary>
|
||||
/// Gets or sets the childrens.
|
||||
/// </summary>
|
||||
/// <value>The childrens.</value>
|
||||
public MindMappingItemEntity[] Childrens
|
||||
{
|
||||
get { return _Childrens; }
|
||||
set
|
||||
{
|
||||
_Childrens = value;
|
||||
if (value != null && value.Length > 0)
|
||||
{
|
||||
value.ToList().ForEach(p => { if (p != null) { p.ParentItem = this; } });
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The back color
|
||||
/// </summary>
|
||||
private Color? backColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the back.
|
||||
/// </summary>
|
||||
/// <value>The color of the back.</value>
|
||||
public Color? BackColor
|
||||
{
|
||||
get { return backColor; }
|
||||
set { backColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font
|
||||
/// </summary>
|
||||
private Font font = new Font("微软雅黑", 10);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the font.
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
public Font Font
|
||||
{
|
||||
get { return font; }
|
||||
set
|
||||
{
|
||||
font = value;
|
||||
ResetSize();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fore color
|
||||
/// </summary>
|
||||
private Color foreColor = Color.Black;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the fore.
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
public Color ForeColor
|
||||
{
|
||||
get { return foreColor; }
|
||||
set { foreColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The is expansion
|
||||
/// </summary>
|
||||
private bool _IsExpansion = false;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the instance is expanded.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is expansion; otherwise, <c>false</c>.</value>
|
||||
public bool IsExpansion
|
||||
{
|
||||
get
|
||||
{
|
||||
return _IsExpansion;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == _IsExpansion)
|
||||
return;
|
||||
_IsExpansion = value;
|
||||
if (!value && _Childrens != null && _Childrens.Length > 0)
|
||||
{
|
||||
_Childrens.ToList().ForEach(p => { if (p != null) { p.IsExpansion = false; } });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent item.
|
||||
/// </summary>
|
||||
/// <value>The parent item.</value>
|
||||
public MindMappingItemEntity ParentItem { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets all childrens maximum show count.
|
||||
/// </summary>
|
||||
/// <value>All childrens maximum show count.</value>
|
||||
public int AllChildrensMaxShowHeight { get { return GetAllChildrensMaxShowHeight(); } }
|
||||
/// <summary>
|
||||
/// Gets the maximum level.
|
||||
/// </summary>
|
||||
/// <value>The maximum level.</value>
|
||||
public int AllChildrensMaxShowWidth { get { return GetAllChildrensMaxShowWidth(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all childrens maximum show count.
|
||||
/// </summary>
|
||||
/// <returns>System.Int32.</returns>
|
||||
private int GetAllChildrensMaxShowHeight()
|
||||
{
|
||||
if (!_IsExpansion || _Childrens == null || _Childrens.Length <= 0)
|
||||
return ItemHeight + 10;
|
||||
else
|
||||
{
|
||||
return _Childrens.Sum(p => p == null ? 0 : p.AllChildrensMaxShowHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the maximum level.
|
||||
/// </summary>
|
||||
/// <returns>System.Int32.</returns>
|
||||
private int GetAllChildrensMaxShowWidth()
|
||||
{
|
||||
if (!_IsExpansion || _Childrens == null || _Childrens.Length <= 0)
|
||||
return ItemWidth + 50;
|
||||
else
|
||||
{
|
||||
return ItemWidth + 50 + _Childrens.Max(p => p == null ? 0 : p.AllChildrensMaxShowWidth);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the working rectangle.
|
||||
/// </summary>
|
||||
/// <value>The working rectangle.</value>
|
||||
internal RectangleF WorkingRectangle { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the draw rectangle.
|
||||
/// </summary>
|
||||
/// <value>The draw rectangle.</value>
|
||||
internal RectangleF DrawRectangle { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the expansion rectangle.
|
||||
/// </summary>
|
||||
/// <value>The expansion rectangle.</value>
|
||||
internal RectangleF ExpansionRectangle { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the height of the item.
|
||||
/// </summary>
|
||||
/// <value>The height of the item.</value>
|
||||
int ItemHeight { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the width of the item.
|
||||
/// </summary>
|
||||
/// <value>The width of the item.</value>
|
||||
int ItemWidth { get; set; }
|
||||
/// <summary>
|
||||
/// Resets the size.
|
||||
/// </summary>
|
||||
private void ResetSize()
|
||||
{
|
||||
string _t = _text;
|
||||
if (string.IsNullOrEmpty(_t))
|
||||
{
|
||||
_t = "aaaa";
|
||||
}
|
||||
Bitmap bit = new Bitmap(1, 1);
|
||||
var g = Graphics.FromImage(bit);
|
||||
var size = g.MeasureString(_t, font);
|
||||
g.Dispose();
|
||||
bit.Dispose();
|
||||
ItemHeight = (int)size.Height;
|
||||
ItemWidth = (int)size.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCMindMapping.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCMindMapping.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
internal class UCMindMapping : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The item context menu strip
|
||||
/// </summary>
|
||||
private ContextMenuStrip itemContextMenuStrip;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item context menu strip.
|
||||
/// </summary>
|
||||
/// <value>The item context menu strip.</value>
|
||||
[Description("节点关联的右键菜单"), Category("自定义")]
|
||||
public ContextMenuStrip ItemContextMenuStrip
|
||||
{
|
||||
get { return itemContextMenuStrip; }
|
||||
set { itemContextMenuStrip = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The item backcolor
|
||||
/// </summary>
|
||||
private Color itemBackcolor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item backcolor.
|
||||
/// </summary>
|
||||
/// <value>The item backcolor.</value>
|
||||
[Description("节点背景色,优先级小于数据源中设置的背景色"), Category("自定义")]
|
||||
public Color ItemBackcolor
|
||||
{
|
||||
get { return itemBackcolor; }
|
||||
set
|
||||
{
|
||||
itemBackcolor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The line color
|
||||
/// </summary>
|
||||
private Color lineColor = Color.Black;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the line.
|
||||
/// </summary>
|
||||
/// <value>The color of the line.</value>
|
||||
[Description("线条颜色"), Category("自定义")]
|
||||
public Color LineColor
|
||||
{
|
||||
get { return lineColor; }
|
||||
set
|
||||
{
|
||||
lineColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The split width
|
||||
/// </summary>
|
||||
private int splitWidth = 50;
|
||||
// private int itemHeight = 20;
|
||||
/// <summary>
|
||||
/// The padding
|
||||
/// </summary>
|
||||
private int padding = 20;
|
||||
|
||||
/// <summary>
|
||||
/// The m rect working
|
||||
/// </summary>
|
||||
Rectangle m_rectWorking = Rectangle.Empty;
|
||||
/// <summary>
|
||||
/// Occurs when [item clicked].
|
||||
/// </summary>
|
||||
public event EventHandler ItemClicked;
|
||||
/// <summary>
|
||||
/// The data source
|
||||
/// </summary>
|
||||
private MindMappingItemEntity dataSource;
|
||||
|
||||
/// <summary>
|
||||
/// The select entity
|
||||
/// </summary>
|
||||
private MindMappingItemEntity selectEntity;
|
||||
/// <summary>
|
||||
/// Gets the select entity.
|
||||
/// </summary>
|
||||
/// <value>The select entity.</value>
|
||||
[Description("选中的数据源"), Category("自定义")]
|
||||
public MindMappingItemEntity SelectEntity
|
||||
{
|
||||
get { return selectEntity; }
|
||||
private set { selectEntity = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public MindMappingItemEntity DataSource
|
||||
{
|
||||
get { return dataSource; }
|
||||
set
|
||||
{
|
||||
dataSource = value;
|
||||
|
||||
ResetSize();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCMindMapping" /> class.
|
||||
/// </summary>
|
||||
public UCMindMapping()
|
||||
{
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
this.SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
this.SetStyle(ControlStyles.ResizeRedraw, true);
|
||||
this.SetStyle(ControlStyles.Selectable, true);
|
||||
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Click += UCMindMapping_Click;
|
||||
this.DoubleClick += UCMindMapping_DoubleClick;
|
||||
this.Load += UCMindMapping_Load;
|
||||
this.MouseClick += UCMindMapping_MouseClick;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCMindMapping control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void UCMindMapping_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Parent != null)
|
||||
{
|
||||
//父控件大小改变时重置大小和位置
|
||||
this.Parent.SizeChanged += (a, b) =>
|
||||
{
|
||||
ResetSize();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 双击处理,主要用于检测节点双击展开折叠
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void UCMindMapping_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
var mouseLocation = this.PointToClient(Control.MousePosition);
|
||||
|
||||
bool bln = CheckDrawRectClick(dataSource, mouseLocation);
|
||||
if (bln)
|
||||
{
|
||||
ResetSize();
|
||||
this.Parent.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单击处理,主要用于单击节点事件和,展开关闭圆圈处理
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void UCMindMapping_Click(object sender, EventArgs e)
|
||||
{
|
||||
var mouseLocation = this.PointToClient(Control.MousePosition);
|
||||
|
||||
bool bln = CheckExpansionClick(dataSource, mouseLocation);
|
||||
if (bln)
|
||||
{
|
||||
ResetSize();
|
||||
this.Parent.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseClick event of the UCMindMapping control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||||
void UCMindMapping_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (itemContextMenuStrip != null && e.Button == System.Windows.Forms.MouseButtons.Right)
|
||||
{
|
||||
bool bln = CheckDrawRectClick(dataSource, e.Location, false);
|
||||
if (bln)
|
||||
{
|
||||
itemContextMenuStrip.Show(this.PointToScreen(e.Location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 双击检查
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="mouseLocation">The mouse location.</param>
|
||||
/// <param name="blnDoExpansion">if set to <c>true</c> [BLN do expansion].</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
private bool CheckDrawRectClick(MindMappingItemEntity item, Point mouseLocation, bool blnDoExpansion = true)
|
||||
{
|
||||
if (item == null)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if (item.DrawRectangle.Contains(mouseLocation))
|
||||
{
|
||||
if (blnDoExpansion)
|
||||
item.IsExpansion = !item.IsExpansion;
|
||||
return true;
|
||||
}
|
||||
if (item.Childrens != null && item.Childrens.Length > 0)
|
||||
{
|
||||
foreach (var child in item.Childrens)
|
||||
{
|
||||
var bln = CheckDrawRectClick(child, mouseLocation, blnDoExpansion);
|
||||
if (bln)
|
||||
return bln;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单击检查
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="mouseLocation">The mouse location.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
private bool CheckExpansionClick(MindMappingItemEntity item, Point mouseLocation)
|
||||
{
|
||||
if (item == null)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if (item.DrawRectangle.Contains(mouseLocation))
|
||||
{
|
||||
selectEntity = item;
|
||||
if (ItemClicked != null )
|
||||
{
|
||||
ItemClicked(item, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.ExpansionRectangle.Contains(mouseLocation))
|
||||
{
|
||||
item.IsExpansion = !item.IsExpansion;
|
||||
return true;
|
||||
}
|
||||
if (item.Childrens != null && item.Childrens.Length > 0)
|
||||
{
|
||||
foreach (var child in item.Childrens)
|
||||
{
|
||||
var bln = CheckExpansionClick(child, mouseLocation);
|
||||
if (bln)
|
||||
return bln;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
|
||||
/// </summary>
|
||||
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
base.OnPaint(e);
|
||||
if (m_rectWorking == Rectangle.Empty || m_rectWorking == null)
|
||||
return;
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
|
||||
int intHeight = dataSource.AllChildrensMaxShowHeight;
|
||||
dataSource.WorkingRectangle = new RectangleF(m_rectWorking.Left, m_rectWorking.Top + (m_rectWorking.Height - intHeight) / 2, m_rectWorking.Width, intHeight);
|
||||
|
||||
DrawItem(dataSource, g);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
MessageBox.Show(exc.ToString(), "错误");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 画节点
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="g">The g.</param>
|
||||
private void DrawItem(MindMappingItemEntity item, Graphics g)
|
||||
{
|
||||
//节点
|
||||
var size = g.MeasureString(item.Text, item.Font);
|
||||
item.DrawRectangle = new RectangleF(item.WorkingRectangle.Left + 2, item.WorkingRectangle.Top + (item.WorkingRectangle.Height - size.Height) / 2 + 2, size.Width + 4, size.Height + 4);
|
||||
GraphicsPath drawPath = item.DrawRectangle.CreateRoundedRectanglePath(5);
|
||||
if (item.BackColor.HasValue)
|
||||
g.FillPath(new SolidBrush(item.BackColor.Value), drawPath);
|
||||
else
|
||||
g.FillPath(new SolidBrush(itemBackcolor), drawPath);
|
||||
|
||||
g.DrawString(item.Text, item.Font, new SolidBrush(item.ForeColor), item.DrawRectangle.Location.X + 2, item.DrawRectangle.Location.Y + 2);
|
||||
//子节点
|
||||
if (item.Childrens != null && item.IsExpansion)
|
||||
{
|
||||
for (int i = 0; i < item.Childrens.Length; i++)
|
||||
{
|
||||
var child = item.Childrens[i];
|
||||
if (i == 0)
|
||||
{
|
||||
child.WorkingRectangle = new RectangleF(item.DrawRectangle.Right + splitWidth, item.WorkingRectangle.Top, item.WorkingRectangle.Width - (item.DrawRectangle.Width + splitWidth), child.AllChildrensMaxShowHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
child.WorkingRectangle = new RectangleF(item.DrawRectangle.Right + splitWidth, item.Childrens[i - 1].WorkingRectangle.Bottom, item.WorkingRectangle.Width - (item.DrawRectangle.Width + splitWidth), child.AllChildrensMaxShowHeight);
|
||||
}
|
||||
DrawItem(child, g);
|
||||
}
|
||||
}
|
||||
//连线
|
||||
if (item.ParentItem != null)
|
||||
{
|
||||
g.DrawLines(new Pen(new SolidBrush(lineColor), 1), new PointF[]
|
||||
{
|
||||
new PointF(item.ParentItem.DrawRectangle.Right,item.ParentItem.DrawRectangle.Top+item.ParentItem.DrawRectangle.Height/2),
|
||||
new PointF(item.ParentItem.DrawRectangle.Right+12,item.ParentItem.DrawRectangle.Top+item.ParentItem.DrawRectangle.Height/2),
|
||||
//new PointF(item.ParentItem.DrawRectangle.Right+12,item.DrawRectangle.Top+item.DrawRectangle.Height/2),
|
||||
new PointF(item.DrawRectangle.Left-12,item.DrawRectangle.Top+item.DrawRectangle.Height/2),
|
||||
new PointF(item.DrawRectangle.Left,item.DrawRectangle.Top+item.DrawRectangle.Height/2),
|
||||
});
|
||||
}
|
||||
//展开折叠按钮
|
||||
if (item.Childrens != null && item.Childrens.Length > 0)
|
||||
{
|
||||
RectangleF _rect = new RectangleF(item.DrawRectangle.Right + 1, item.DrawRectangle.Top + (item.DrawRectangle.Height - 10) / 2, 10, 10);
|
||||
item.ExpansionRectangle = _rect;
|
||||
g.FillEllipse(new SolidBrush(this.BackColor), _rect);
|
||||
g.DrawEllipse(new Pen(new SolidBrush(Color.Black)), _rect);
|
||||
g.DrawLine(new Pen(new SolidBrush(lineColor)), _rect.Left + 2, _rect.Y + _rect.Height / 2, _rect.Right - 2, _rect.Y + _rect.Height / 2);
|
||||
if (!item.IsExpansion)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(lineColor)), _rect.Left + _rect.Width / 2, _rect.Top + 2, _rect.Left + _rect.Width / 2, _rect.Bottom - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置大小
|
||||
/// </summary>
|
||||
private void ResetSize()
|
||||
{
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
if (dataSource == null)
|
||||
{
|
||||
m_rectWorking = Rectangle.Empty;
|
||||
this.Size = this.Parent.Size;
|
||||
}
|
||||
else
|
||||
{
|
||||
int intWidth = dataSource.AllChildrensMaxShowWidth;
|
||||
int intHeight = dataSource.AllChildrensMaxShowHeight;
|
||||
this.Width = intWidth + padding * 2;
|
||||
this.Height = intHeight + padding * 2;
|
||||
if (this.Width < this.Parent.Width)
|
||||
this.Width = this.Parent.Width;
|
||||
m_rectWorking = new Rectangle(padding, padding, intWidth, intHeight);
|
||||
if (this.Height > this.Parent.Height)
|
||||
{
|
||||
//this.Location = new Point(0, 0);
|
||||
}
|
||||
else
|
||||
this.Location = new Point(0, (this.Parent.Height - this.Height) / 2);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
80
UsingControl/HZHControls/Controls/FactoryControls/MindMapping/UCMindMappingPanel.Designer.cs
generated
Normal file
80
UsingControl/HZHControls/Controls/FactoryControls/MindMapping/UCMindMappingPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,80 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCMindMappingPanel.Designer.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCMindMappingPanel.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCMindMappingPanel
|
||||
{
|
||||
/// <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 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ucMindMapping1 = new HZH_Controls.Controls.UCMindMapping();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ucMindMapping1
|
||||
//
|
||||
this.ucMindMapping1.Location = new System.Drawing.Point(0, 0);
|
||||
this.ucMindMapping1.Name = "ucMindMapping1";
|
||||
this.ucMindMapping1.Size = new System.Drawing.Size(200, 200);
|
||||
this.ucMindMapping1.TabIndex = 0;
|
||||
//
|
||||
// UCMindMappingPanel
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.AutoScroll = true;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.ucMindMapping1);
|
||||
this.Name = "UCMindMappingPanel";
|
||||
this.Size = new System.Drawing.Size(200, 200);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The uc mind mapping1
|
||||
/// </summary>
|
||||
private UCMindMapping ucMindMapping1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCMindMappingPanel.cs">
|
||||
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
|
||||
// </copyright>
|
||||
//
|
||||
// Blog: https://www.cnblogs.com/bfyx
|
||||
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
|
||||
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
|
||||
//
|
||||
// If you use this code, please keep this note.
|
||||
// ***********************************************************************
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCMindMappingPanel.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[DefaultEvent("ItemClicked")]
|
||||
public partial class UCMindMappingPanel : UserControl
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The item context menu strip
|
||||
/// </summary>
|
||||
private ContextMenuStrip itemContextMenuStrip;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item context menu strip.
|
||||
/// </summary>
|
||||
/// <value>The item context menu strip.</value>
|
||||
[Description("节点关联的右键菜单"), Category("自定义")]
|
||||
public ContextMenuStrip ItemContextMenuStrip
|
||||
{
|
||||
get { return itemContextMenuStrip; }
|
||||
set
|
||||
{
|
||||
itemContextMenuStrip = value;
|
||||
this.ucMindMapping1.ItemContextMenuStrip = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The item backcolor
|
||||
/// </summary>
|
||||
private Color itemBackcolor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item backcolor.
|
||||
/// </summary>
|
||||
/// <value>The item backcolor.</value>
|
||||
[Description("节点背景色,优先级小于数据源中设置的背景色"), Category("自定义")]
|
||||
public Color ItemBackcolor
|
||||
{
|
||||
get { return itemBackcolor; }
|
||||
set
|
||||
{
|
||||
itemBackcolor = value;
|
||||
this.ucMindMapping1.ItemBackcolor = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The data source
|
||||
/// </summary>
|
||||
private MindMappingItemEntity dataSource;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public MindMappingItemEntity DataSource
|
||||
{
|
||||
get { return dataSource; }
|
||||
set
|
||||
{
|
||||
dataSource = value;
|
||||
this.ucMindMapping1.DataSource = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public event EventHandler ItemClicked;
|
||||
|
||||
/// <summary>
|
||||
/// The line color
|
||||
/// </summary>
|
||||
private Color lineColor = Color.Black;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the line.
|
||||
/// </summary>
|
||||
/// <value>The color of the line.</value>
|
||||
[Description("线条颜色"), Category("自定义")]
|
||||
public Color LineColor
|
||||
{
|
||||
get { return lineColor; }
|
||||
set
|
||||
{
|
||||
lineColor = value;
|
||||
this.ucMindMapping1.LineColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the select entity.
|
||||
/// </summary>
|
||||
/// <value>The select entity.</value>
|
||||
[Description("选中的数据源"), Category("自定义")]
|
||||
public MindMappingItemEntity SelectEntity
|
||||
{
|
||||
get { return ucMindMapping1.SelectEntity; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCMindMappingPanel" /> class.
|
||||
/// </summary>
|
||||
public UCMindMappingPanel()
|
||||
{
|
||||
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
this.SetStyle(ControlStyles.DoubleBuffer, true);
|
||||
this.SetStyle(ControlStyles.ResizeRedraw, true);
|
||||
this.SetStyle(ControlStyles.Selectable, true);
|
||||
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
this.SetStyle(ControlStyles.UserPaint, true);
|
||||
InitializeComponent();
|
||||
ucMindMapping1.ItemClicked += ucMindMapping1_ItemClicked;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the ItemClicked event of the ucMindMapping1 control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
void ucMindMapping1_ItemClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (ItemClicked != null)
|
||||
{
|
||||
ItemClicked(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user