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,71 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-10-08
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="NavigationMenuItem.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.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class NavigationMenuItem.
|
||||
/// </summary>
|
||||
public class NavigationMenuItem : NavigationMenuItemBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The items
|
||||
/// </summary>
|
||||
private NavigationMenuItem[] items;
|
||||
/// <summary>
|
||||
/// Gets or sets the items.
|
||||
/// </summary>
|
||||
/// <value>The items.</value>
|
||||
[Description("子项列表")]
|
||||
public NavigationMenuItem[] Items
|
||||
{
|
||||
get { return items; }
|
||||
set
|
||||
{
|
||||
items = value;
|
||||
if (value != null)
|
||||
{
|
||||
foreach (var item in value)
|
||||
{
|
||||
item.ParentItem = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance has split lint at top.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance has split lint at top; otherwise, <c>false</c>.</value>
|
||||
[Description("是否在此项顶部显示一个分割线")]
|
||||
public bool HasSplitLintAtTop { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent item.
|
||||
/// </summary>
|
||||
/// <value>The parent item.</value>
|
||||
[Description("父节点")]
|
||||
public NavigationMenuItem ParentItem { get; private set; }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
public class NavigationMenuItemBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The icon
|
||||
/// </summary>
|
||||
private Image icon;
|
||||
/// <summary>
|
||||
/// Gets or sets the icon.
|
||||
/// </summary>
|
||||
/// <value>The icon.</value>
|
||||
[Description("图标,仅顶级节点有效")]
|
||||
public Image Icon
|
||||
{
|
||||
get { return icon; }
|
||||
set { icon = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The text
|
||||
/// </summary>
|
||||
private string text;
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
/// <value>The text.</value>
|
||||
|
||||
[Description("文本")]
|
||||
public string Text
|
||||
{
|
||||
get { return text; }
|
||||
set { text = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The show tip
|
||||
/// </summary>
|
||||
private bool showTip;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [show tip].当TipText为空时只显示一个小圆点,否则显示TipText文字
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [show tip]; otherwise, <c>false</c>.</value>
|
||||
[Description("是否显示角标,仅顶级节点有效")]
|
||||
public bool ShowTip
|
||||
{
|
||||
get { return showTip; }
|
||||
set { showTip = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The tip text
|
||||
/// </summary>
|
||||
private string tipText;
|
||||
/// <summary>
|
||||
/// Gets or sets the tip text
|
||||
/// </summary>
|
||||
/// <value>The tip text.</value>
|
||||
[Description("角标文字,仅顶级节点有效")]
|
||||
public string TipText
|
||||
{
|
||||
get { return tipText; }
|
||||
set { tipText = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The anchor right
|
||||
/// </summary>
|
||||
private bool anchorRight;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [anchor right].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [anchor right]; otherwise, <c>false</c>.</value>
|
||||
[Description("是否靠右对齐")]
|
||||
public bool AnchorRight
|
||||
{
|
||||
get { return anchorRight; }
|
||||
set { anchorRight = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The item width
|
||||
/// </summary>
|
||||
private int itemWidth = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the item.
|
||||
/// </summary>
|
||||
/// <value>The width of the item.</value>
|
||||
[Description("宽度")]
|
||||
public int ItemWidth
|
||||
{
|
||||
get { return itemWidth; }
|
||||
set { itemWidth = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源")]
|
||||
public object DataSource { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
public class NavigationMenuItemExt : NavigationMenuItemBase
|
||||
{
|
||||
public System.Windows.Forms.Control ShowControl { get; set; }
|
||||
}
|
||||
}
|
||||
49
UsingControl/HZHControls/Controls/NavigationMenu/UCNavigationMenu.Designer.cs
generated
Normal file
49
UsingControl/HZHControls/Controls/NavigationMenu/UCNavigationMenu.Designer.cs
generated
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
partial class UCNavigationMenu
|
||||
{
|
||||
/// <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.SuspendLayout();
|
||||
//
|
||||
// UCNavigationMenu
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(57)))), ((int)(((byte)(61)))), ((int)(((byte)(73)))));
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.Name = "UCNavigationMenu";
|
||||
this.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
|
||||
this.Size = new System.Drawing.Size(529, 60);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,553 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-10-08
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCNavigationMenu.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;
|
||||
using HZH_Controls.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCNavigationMenu.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[DefaultEvent("ClickItemed")]
|
||||
public partial class UCNavigationMenu : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [click itemed].
|
||||
/// </summary>
|
||||
[Description("点击节点事件"), Category("自定义")]
|
||||
|
||||
public event EventHandler ClickItemed;
|
||||
/// <summary>
|
||||
/// The select item
|
||||
/// </summary>
|
||||
private NavigationMenuItem selectItem = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the select item.
|
||||
/// </summary>
|
||||
/// <value>The select item.</value>
|
||||
[Description("选中的节点"), Category("自定义")]
|
||||
public NavigationMenuItem SelectItem
|
||||
{
|
||||
get { return selectItem; }
|
||||
private set { selectItem = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The items
|
||||
/// </summary>
|
||||
NavigationMenuItem[] items;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the items.
|
||||
/// </summary>
|
||||
/// <value>The items.</value>
|
||||
[Description("节点列表"), Category("自定义")]
|
||||
public NavigationMenuItem[] Items
|
||||
{
|
||||
get { return items; }
|
||||
set
|
||||
{
|
||||
items = value;
|
||||
ReloadMenu();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The tip color
|
||||
/// </summary>
|
||||
private Color tipColor = Color.FromArgb(255, 87, 34);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the tip.
|
||||
/// </summary>
|
||||
/// <value>The color of the tip.</value>
|
||||
[Description("角标颜色"), Category("自定义")]
|
||||
public Color TipColor
|
||||
{
|
||||
get { return tipColor; }
|
||||
set { tipColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override System.Drawing.Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
foreach (Control c in this.Controls)
|
||||
{
|
||||
c.ForeColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
foreach (Control c in this.Controls)
|
||||
{
|
||||
c.Font = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m LST anchors
|
||||
/// </summary>
|
||||
Dictionary<NavigationMenuItem, FrmAnchor> m_lstAnchors = new Dictionary<NavigationMenuItem, FrmAnchor>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCNavigationMenu"/> class.
|
||||
/// </summary>
|
||||
public UCNavigationMenu()
|
||||
{
|
||||
InitializeComponent();
|
||||
items = new NavigationMenuItem[0];
|
||||
if (ControlHelper.IsDesignMode())
|
||||
{
|
||||
items = new NavigationMenuItem[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
items[i] = new NavigationMenuItem()
|
||||
{
|
||||
Text = "菜单" + (i + 1),
|
||||
AnchorRight = i >= 2
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the menu.
|
||||
/// </summary>
|
||||
private void ReloadMenu()
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
this.Controls.Clear();
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
var menu = (NavigationMenuItem)item;
|
||||
Label lbl = new Label();
|
||||
lbl.AutoSize = false;
|
||||
lbl.TextAlign = ContentAlignment.MiddleCenter;
|
||||
lbl.Width = menu.ItemWidth;
|
||||
lbl.Text = menu.Text;
|
||||
|
||||
lbl.Font = Font;
|
||||
lbl.ForeColor = ForeColor;
|
||||
|
||||
lbl.Paint += lbl_Paint;
|
||||
lbl.MouseEnter += lbl_MouseEnter;
|
||||
lbl.Tag = menu;
|
||||
lbl.Click += lbl_Click;
|
||||
if (menu.AnchorRight)
|
||||
{
|
||||
lbl.Dock = DockStyle.Right;
|
||||
}
|
||||
else
|
||||
{
|
||||
lbl.Dock = DockStyle.Left;
|
||||
}
|
||||
this.Controls.Add(lbl);
|
||||
|
||||
lbl.BringToFront();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Click event of the lbl 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 lbl_Click(object sender, EventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
if (lbl.Tag != null)
|
||||
{
|
||||
var menu = (NavigationMenuItem)lbl.Tag;
|
||||
if (menu.Items == null || menu.Items.Length <= 0)
|
||||
{
|
||||
selectItem = menu;
|
||||
|
||||
while (m_lstAnchors.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var item in m_lstAnchors)
|
||||
{
|
||||
item.Value.Close();
|
||||
m_lstAnchors.Remove(item.Key);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (ClickItemed != null)
|
||||
{
|
||||
ClickItemed(this, e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseList(menu);
|
||||
if (m_lstAnchors.ContainsKey(menu))
|
||||
{
|
||||
if (m_lstAnchors[menu] != null && !m_lstAnchors[menu].IsDisposed)
|
||||
{
|
||||
m_lstAnchors[menu].Close();
|
||||
}
|
||||
m_lstAnchors.Remove(menu);
|
||||
}
|
||||
ShowMoreMenu(lbl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseEnter event of the lbl 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 lbl_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
ShowMoreMenu(lbl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks the show.
|
||||
/// </summary>
|
||||
/// <param name="menu">The menu.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
private bool CheckShow(NavigationMenuItem menu)
|
||||
{
|
||||
//检查已经打开的节点
|
||||
if (m_lstAnchors.ContainsKey(menu))
|
||||
{
|
||||
CloseList(menu);
|
||||
return false;
|
||||
}
|
||||
if (HasInCacheChild(menu))
|
||||
{
|
||||
if (m_lstAnchors.ContainsKey(menu.ParentItem))
|
||||
{
|
||||
CloseList(menu.ParentItem);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 1; )
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var item in m_lstAnchors)
|
||||
{
|
||||
if (m_lstAnchors[item.Key] != null && !m_lstAnchors[item.Key].IsDisposed)
|
||||
{
|
||||
m_lstAnchors[item.Key].Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
m_lstAnchors.Clear();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether [has in cache child] [the specified menu].
|
||||
/// </summary>
|
||||
/// <param name="menu">The menu.</param>
|
||||
/// <returns><c>true</c> if [has in cache child] [the specified menu]; otherwise, <c>false</c>.</returns>
|
||||
private bool HasInCacheChild(NavigationMenuItem menu)
|
||||
{
|
||||
foreach (var item in m_lstAnchors)
|
||||
{
|
||||
if (item.Key == menu)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.Key.Items != null)
|
||||
{
|
||||
if (item.Key.Items.Contains(menu))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the list.
|
||||
/// </summary>
|
||||
/// <param name="menu">The menu.</param>
|
||||
private void CloseList(NavigationMenuItem menu)
|
||||
{
|
||||
if (menu.Items != null)
|
||||
{
|
||||
foreach (var item in menu.Items)
|
||||
{
|
||||
CloseList(item);
|
||||
if (m_lstAnchors.ContainsKey(item))
|
||||
{
|
||||
if (m_lstAnchors[item] != null && !m_lstAnchors[item].IsDisposed)
|
||||
{
|
||||
m_lstAnchors[item].Close();
|
||||
m_lstAnchors[item] = null;
|
||||
m_lstAnchors.Remove(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the more menu.
|
||||
/// </summary>
|
||||
/// <param name="lbl">The label.</param>
|
||||
private void ShowMoreMenu(Label lbl)
|
||||
{
|
||||
var menu = (NavigationMenuItem)lbl.Tag;
|
||||
if (CheckShow(menu))
|
||||
{
|
||||
if (menu.Items != null && menu.Items.Length > 0)
|
||||
{
|
||||
Panel panel = new Panel();
|
||||
panel.BackColor = Color.White;
|
||||
panel.Paint += panel_Paint;
|
||||
panel.Padding = new System.Windows.Forms.Padding(1);
|
||||
Size size = GetItemsSize(menu.Items);
|
||||
var height = size.Height * menu.Items.Length + 2;
|
||||
height += menu.Items.Count(p => p.HasSplitLintAtTop);//分割线
|
||||
if (size.Width < lbl.Width)
|
||||
size.Width = lbl.Width;
|
||||
panel.Size = new Size(size.Width, height);
|
||||
|
||||
foreach (var item in menu.Items)
|
||||
{
|
||||
if (item.HasSplitLintAtTop)
|
||||
{
|
||||
UCSplitLine_H line = new UCSplitLine_H();
|
||||
line.Dock = DockStyle.Top;
|
||||
panel.Controls.Add(line);
|
||||
line.BringToFront();
|
||||
}
|
||||
Label _lbl = new Label();
|
||||
_lbl.Font = Font;
|
||||
_lbl.ForeColor = this.BackColor;
|
||||
_lbl.AutoSize = false;
|
||||
_lbl.TextAlign = ContentAlignment.MiddleCenter;
|
||||
_lbl.Height = size.Height;
|
||||
_lbl.Text = item.Text;
|
||||
_lbl.Dock = DockStyle.Top;
|
||||
_lbl.BringToFront();
|
||||
_lbl.Paint += lbl_Paint;
|
||||
_lbl.MouseEnter += lbl_MouseEnter;
|
||||
_lbl.Tag = item;
|
||||
_lbl.Click += lbl_Click;
|
||||
_lbl.Size = new System.Drawing.Size(size.Width, size.Height);
|
||||
panel.Controls.Add(_lbl);
|
||||
_lbl.BringToFront();
|
||||
}
|
||||
Point point = Point.Empty;
|
||||
|
||||
if (menu.ParentItem != null)
|
||||
{
|
||||
Point p = lbl.Parent.PointToScreen(lbl.Location);
|
||||
if (p.X + lbl.Width + panel.Width > Screen.PrimaryScreen.Bounds.Width)
|
||||
{
|
||||
point = new Point(-1 * panel.Width - 2, -1 * lbl.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
point = new Point(panel.Width + 2, -1 * lbl.Height);
|
||||
}
|
||||
}
|
||||
m_lstAnchors[menu] = new FrmAnchor(lbl, panel, point);
|
||||
m_lstAnchors[menu].FormClosing += UCNavigationMenu_FormClosing;
|
||||
m_lstAnchors[menu].Show(this);
|
||||
m_lstAnchors[menu].Size = new Size(size.Width, height);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the FormClosing event of the UCNavigationMenu control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="FormClosingEventArgs"/> instance containing the event data.</param>
|
||||
void UCNavigationMenu_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
FrmAnchor frm = sender as FrmAnchor;
|
||||
if (m_lstAnchors.ContainsValue(frm))
|
||||
{
|
||||
foreach (var item in m_lstAnchors)
|
||||
{
|
||||
if (item.Value == frm)
|
||||
{
|
||||
m_lstAnchors.Remove(item.Key);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Paint event of the panel control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
|
||||
void panel_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.SetGDIHigh();
|
||||
Rectangle rect = new Rectangle(0, 0, e.ClipRectangle.Width - 1, e.ClipRectangle.Height - 1);
|
||||
var path = rect.CreateRoundedRectanglePath(2);
|
||||
e.Graphics.DrawPath(new Pen(new SolidBrush(LineColors.Light)), path);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the size of the items.
|
||||
/// </summary>
|
||||
/// <param name="items">The items.</param>
|
||||
/// <returns>Size.</returns>
|
||||
private Size GetItemsSize(NavigationMenuItem[] items)
|
||||
{
|
||||
Size size = Size.Empty;
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
using (var g = this.CreateGraphics())
|
||||
{
|
||||
foreach (NavigationMenuItem item in items)
|
||||
{
|
||||
var s = g.MeasureString(item.Text, Font);
|
||||
if (s.Width + 25 > size.Width)
|
||||
{
|
||||
size.Width = (int)s.Width + 25;
|
||||
}
|
||||
if (s.Height + 10 > size.Height)
|
||||
{
|
||||
size.Height = (int)s.Height + 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Paint event of the lbl control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
|
||||
void lbl_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
if (lbl.Tag != null)
|
||||
{
|
||||
var menu = (NavigationMenuItem)lbl.Tag;
|
||||
e.Graphics.SetGDIHigh();
|
||||
if (menu.ParentItem == null)//顶级节点支持图标和角标
|
||||
{
|
||||
if (menu.ShowTip)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(menu.TipText))
|
||||
{
|
||||
var rect = new Rectangle(lbl.Width - 25, lbl.Height / 2 - 10, 20, 20);
|
||||
var path = rect.CreateRoundedRectanglePath(5);
|
||||
e.Graphics.FillPath(new SolidBrush(tipColor), path);
|
||||
e.Graphics.DrawString(menu.TipText, new Font("微软雅黑", 8f), new SolidBrush(Color.White), rect, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.FillEllipse(new SolidBrush(tipColor), new Rectangle(lbl.Width - 20, lbl.Height / 2 - 10, 10, 10));
|
||||
}
|
||||
}
|
||||
if (menu.Icon != null)
|
||||
{
|
||||
e.Graphics.DrawImage(menu.Icon, new Rectangle(1, (lbl.Height - 25) / 2, 25, 25), 0, 0, menu.Icon.Width, menu.Icon.Height, GraphicsUnit.Pixel);
|
||||
}
|
||||
}
|
||||
if (menu.ParentItem != null && menu.Items != null && menu.Items.Length > 0)
|
||||
{
|
||||
ControlHelper.PaintTriangle(e.Graphics, new SolidBrush(this.BackColor), new Point(lbl.Width - 11, (lbl.Height - 5) / 2), 5, GraphDirection.Rightward);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
48
UsingControl/HZHControls/Controls/NavigationMenu/UCNavigationMenuExt.Designer.cs
generated
Normal file
48
UsingControl/HZHControls/Controls/NavigationMenu/UCNavigationMenuExt.Designer.cs
generated
Normal file
@@ -0,0 +1,48 @@
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
partial class UCNavigationMenuExt
|
||||
{
|
||||
/// <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.SuspendLayout();
|
||||
//
|
||||
// UCNavigationMenuExt
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(57)))), ((int)(((byte)(61)))), ((int)(((byte)(73)))));
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 11F);
|
||||
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.Name = "UCNavigationMenuExt";
|
||||
this.Padding = new System.Windows.Forms.Padding(20, 0, 0, 0);
|
||||
this.Size = new System.Drawing.Size(529, 60);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-10-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCNavigationMenuExt.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;
|
||||
using HZH_Controls.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCNavigationMenuExt.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[DefaultEvent("ClickItemed")]
|
||||
public partial class UCNavigationMenuExt : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [click itemed].
|
||||
/// </summary>
|
||||
[Description("点击节点事件"), Category("自定义")]
|
||||
|
||||
public event EventHandler ClickItemed;
|
||||
/// <summary>
|
||||
/// The select item
|
||||
/// </summary>
|
||||
private NavigationMenuItemExt selectItem = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the select item.
|
||||
/// </summary>
|
||||
/// <value>The select item.</value>
|
||||
[Description("选中的节点"), Category("自定义")]
|
||||
public NavigationMenuItemExt SelectItem
|
||||
{
|
||||
get { return selectItem; }
|
||||
private set { selectItem = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The items
|
||||
/// </summary>
|
||||
NavigationMenuItemExt[] items;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the items.
|
||||
/// </summary>
|
||||
/// <value>The items.</value>
|
||||
[Description("节点列表"), Category("自定义")]
|
||||
public NavigationMenuItemExt[] Items
|
||||
{
|
||||
get { return items; }
|
||||
set
|
||||
{
|
||||
items = value;
|
||||
ReloadMenu();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The tip color
|
||||
/// </summary>
|
||||
private Color tipColor = Color.FromArgb(255, 87, 34);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the tip.
|
||||
/// </summary>
|
||||
/// <value>The color of the tip.</value>
|
||||
[Description("角标颜色"), Category("自定义")]
|
||||
public Color TipColor
|
||||
{
|
||||
get { return tipColor; }
|
||||
set { tipColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override System.Drawing.Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
foreach (Control c in this.Controls)
|
||||
{
|
||||
c.ForeColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
foreach (Control c in this.Controls)
|
||||
{
|
||||
c.Font = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m LST anchors
|
||||
/// </summary>
|
||||
Dictionary<NavigationMenuItemExt, FrmAnchor> m_lstAnchors = new Dictionary<NavigationMenuItemExt, FrmAnchor>();
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCNavigationMenuExt"/> class.
|
||||
/// </summary>
|
||||
public UCNavigationMenuExt()
|
||||
{
|
||||
InitializeComponent();
|
||||
items = new NavigationMenuItemExt[0];
|
||||
if (ControlHelper.IsDesignMode())
|
||||
{
|
||||
items = new NavigationMenuItemExt[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
items[i] = new NavigationMenuItemExt()
|
||||
{
|
||||
Text = "菜单" + (i + 1),
|
||||
AnchorRight = i >= 2
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the menu.
|
||||
/// </summary>
|
||||
private void ReloadMenu()
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
this.Controls.Clear();
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
var menu = (NavigationMenuItemExt)item;
|
||||
Label lbl = new Label();
|
||||
lbl.AutoSize = false;
|
||||
lbl.TextAlign = ContentAlignment.MiddleCenter;
|
||||
lbl.Width = menu.ItemWidth;
|
||||
lbl.Text = menu.Text;
|
||||
|
||||
lbl.Font = Font;
|
||||
lbl.ForeColor = ForeColor;
|
||||
|
||||
lbl.Paint += lbl_Paint;
|
||||
lbl.MouseEnter += lbl_MouseEnter;
|
||||
lbl.Tag = menu;
|
||||
lbl.Click += lbl_Click;
|
||||
if (menu.AnchorRight)
|
||||
{
|
||||
lbl.Dock = DockStyle.Right;
|
||||
}
|
||||
else
|
||||
{
|
||||
lbl.Dock = DockStyle.Left;
|
||||
}
|
||||
this.Controls.Add(lbl);
|
||||
|
||||
lbl.BringToFront();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Click event of the lbl 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 lbl_Click(object sender, EventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
if (lbl.Tag != null)
|
||||
{
|
||||
var menu = (NavigationMenuItemExt)lbl.Tag;
|
||||
if (menu.ShowControl == null)
|
||||
{
|
||||
selectItem = menu;
|
||||
|
||||
if (ClickItemed != null)
|
||||
{
|
||||
ClickItemed(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles the MouseEnter event of the lbl 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 lbl_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
var menu = lbl.Tag as NavigationMenuItemExt;
|
||||
foreach (var item in m_lstAnchors)
|
||||
{
|
||||
m_lstAnchors[item.Key].Hide();
|
||||
}
|
||||
if (menu.ShowControl != null)
|
||||
{
|
||||
if (!m_lstAnchors.ContainsKey(menu))
|
||||
{
|
||||
m_lstAnchors[menu] = new FrmAnchor(lbl, menu.ShowControl);
|
||||
}
|
||||
m_lstAnchors[menu].Show(this);
|
||||
m_lstAnchors[menu].Size = menu.ShowControl.Size;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles the Paint event of the lbl control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="PaintEventArgs" /> instance containing the event data.</param>
|
||||
void lbl_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
if (lbl.Tag != null)
|
||||
{
|
||||
var menu = (NavigationMenuItemExt)lbl.Tag;
|
||||
e.Graphics.SetGDIHigh();
|
||||
|
||||
if (menu.ShowTip)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(menu.TipText))
|
||||
{
|
||||
var rect = new Rectangle(lbl.Width - 25, lbl.Height / 2 - 10, 20, 20);
|
||||
var path = rect.CreateRoundedRectanglePath(5);
|
||||
e.Graphics.FillPath(new SolidBrush(tipColor), path);
|
||||
e.Graphics.DrawString(menu.TipText, new Font("微软雅黑", 8f), new SolidBrush(Color.White), rect, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.FillEllipse(new SolidBrush(tipColor), new Rectangle(lbl.Width - 20, lbl.Height / 2 - 10, 10, 10));
|
||||
}
|
||||
}
|
||||
if (menu.Icon != null)
|
||||
{
|
||||
e.Graphics.DrawImage(menu.Icon, new Rectangle(1, (lbl.Height - 25) / 2, 25, 25), 0, 0, menu.Icon.Width, menu.Icon.Height, GraphicsUnit.Pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
72
UsingControl/HZHControls/Controls/NavigationMenu/UCNavigationMenuOffice.Designer.cs
generated
Normal file
72
UsingControl/HZHControls/Controls/NavigationMenu/UCNavigationMenuOffice.Designer.cs
generated
Normal file
@@ -0,0 +1,72 @@
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
partial class UCNavigationMenuOffice
|
||||
{
|
||||
/// <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.panMenu = new System.Windows.Forms.Panel();
|
||||
this.panChilds = new System.Windows.Forms.Panel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panMenu
|
||||
//
|
||||
this.panMenu.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panMenu.Location = new System.Drawing.Point(0, 0);
|
||||
this.panMenu.MaximumSize = new System.Drawing.Size(0, 25);
|
||||
this.panMenu.MinimumSize = new System.Drawing.Size(0, 25);
|
||||
this.panMenu.Name = "panMenu";
|
||||
this.panMenu.Size = new System.Drawing.Size(441, 25);
|
||||
this.panMenu.TabIndex = 0;
|
||||
//
|
||||
// panChilds
|
||||
//
|
||||
this.panChilds.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panChilds.Location = new System.Drawing.Point(0, 25);
|
||||
this.panChilds.Name = "panChilds";
|
||||
this.panChilds.Size = new System.Drawing.Size(441, 100);
|
||||
this.panChilds.TabIndex = 1;
|
||||
//
|
||||
// UCNavigationMenuOffice
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(57)))), ((int)(((byte)(61)))), ((int)(((byte)(73)))));
|
||||
this.Controls.Add(this.panChilds);
|
||||
this.Controls.Add(this.panMenu);
|
||||
this.Font = new System.Drawing.Font("微软雅黑", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
|
||||
this.Name = "UCNavigationMenuOffice";
|
||||
this.Size = new System.Drawing.Size(441, 125);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panMenu;
|
||||
private System.Windows.Forms.Panel panChilds;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,428 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-10-12
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCNavigationMenuOffice.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;
|
||||
using HZH_Controls.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCNavigationMenuOffice.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public partial class UCNavigationMenuOffice : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The main menu height
|
||||
/// </summary>
|
||||
private int mainMenuHeight = 25;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height of the main menu.
|
||||
/// </summary>
|
||||
/// <value>The height of the main menu.</value>
|
||||
[Description("主菜单高度,大于20的值"), Category("自定义")]
|
||||
public int MainMenuHeight
|
||||
{
|
||||
get { return mainMenuHeight; }
|
||||
set
|
||||
{
|
||||
if (value < 20)
|
||||
return;
|
||||
mainMenuHeight = value;
|
||||
this.panMenu.Height = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The expand height
|
||||
/// </summary>
|
||||
private int expandHeight = 125;
|
||||
/// <summary>
|
||||
/// Gets or sets the height of the expand.
|
||||
/// </summary>
|
||||
/// <value>The height of the expand.</value>
|
||||
[Description("展开后高度"), Category("自定义")]
|
||||
public int ExpandHeight
|
||||
{
|
||||
get { return expandHeight; }
|
||||
set { expandHeight = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The is expand
|
||||
/// </summary>
|
||||
private bool isExpand = true;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is expand.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is expand; otherwise, <c>false</c>.</value>
|
||||
[Description("是否展开"), Category("自定义")]
|
||||
public bool IsExpand
|
||||
{
|
||||
get { return isExpand; }
|
||||
set
|
||||
{
|
||||
isExpand = value;
|
||||
if (value)
|
||||
{
|
||||
this.Height = expandHeight;
|
||||
ResetChildControl();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Height = this.panMenu.Height;
|
||||
this.panChilds.Controls.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when [click itemed].
|
||||
/// </summary>
|
||||
[Description("点击节点事件"), Category("自定义")]
|
||||
|
||||
public event EventHandler ClickItemed;
|
||||
/// <summary>
|
||||
/// The select item
|
||||
/// </summary>
|
||||
private NavigationMenuItemExt selectItem = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the select item.
|
||||
/// </summary>
|
||||
/// <value>The select item.</value>
|
||||
[Description("选中的节点"), Category("自定义")]
|
||||
public NavigationMenuItemExt SelectItem
|
||||
{
|
||||
get { return selectItem; }
|
||||
private set { selectItem = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The items
|
||||
/// </summary>
|
||||
NavigationMenuItemExt[] items;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the items.
|
||||
/// </summary>
|
||||
/// <value>The items.</value>
|
||||
[Description("节点列表"), Category("自定义")]
|
||||
public NavigationMenuItemExt[] Items
|
||||
{
|
||||
get { return items; }
|
||||
set
|
||||
{
|
||||
items = value;
|
||||
ReloadMenu();
|
||||
if (value != null && value.Length > 0)
|
||||
{
|
||||
selectItem = value[0];
|
||||
ResetChildControl();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The tip color
|
||||
/// </summary>
|
||||
private Color tipColor = Color.FromArgb(255, 87, 34);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the tip.
|
||||
/// </summary>
|
||||
/// <value>The color of the tip.</value>
|
||||
[Description("角标颜色"), Category("自定义")]
|
||||
public Color TipColor
|
||||
{
|
||||
get { return tipColor; }
|
||||
set { tipColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override System.Drawing.Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
foreach (Control c in this.Controls)
|
||||
{
|
||||
c.ForeColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
foreach (Control c in this.Controls)
|
||||
{
|
||||
c.Font = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m LST anchors
|
||||
/// </summary>
|
||||
Dictionary<NavigationMenuItemExt, FrmAnchor> m_lstAnchors = new Dictionary<NavigationMenuItemExt, FrmAnchor>();
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCNavigationMenuOffice"/> class.
|
||||
/// </summary>
|
||||
public UCNavigationMenuOffice()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.SizeChanged += UCNavigationMenuOffice_SizeChanged;
|
||||
items = new NavigationMenuItemExt[0];
|
||||
if (ControlHelper.IsDesignMode())
|
||||
{
|
||||
items = new NavigationMenuItemExt[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
items[i] = new NavigationMenuItemExt()
|
||||
{
|
||||
Text = "菜单" + (i + 1),
|
||||
AnchorRight = i >= 2
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCNavigationMenuOffice 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 UCNavigationMenuOffice_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (isExpand)
|
||||
{
|
||||
expandHeight = this.Height;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the child control.
|
||||
/// </summary>
|
||||
public void ResetChildControl()
|
||||
{
|
||||
if (isExpand)
|
||||
{
|
||||
if (selectItem != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
this.panChilds.Controls.Clear();
|
||||
if (selectItem.ShowControl != null)
|
||||
{
|
||||
HZH_Controls.Controls.UCSplitLine_H split = new UCSplitLine_H();
|
||||
split.BackColor = Color.FromArgb(50, 197, 197, 197);
|
||||
split.Dock = DockStyle.Top;
|
||||
this.panChilds.Controls.Add(split);
|
||||
split.BringToFront();
|
||||
this.panChilds.Controls.Add(selectItem.ShowControl);
|
||||
selectItem.ShowControl.Dock = DockStyle.Fill;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the menu.
|
||||
/// </summary>
|
||||
private void ReloadMenu()
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
this.panMenu.Controls.Clear();
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
var menu = (NavigationMenuItemExt)item;
|
||||
Label lbl = new Label();
|
||||
lbl.AutoSize = false;
|
||||
lbl.TextAlign = ContentAlignment.MiddleCenter;
|
||||
lbl.Width = menu.ItemWidth;
|
||||
lbl.Text = menu.Text;
|
||||
|
||||
lbl.Font = Font;
|
||||
lbl.ForeColor = ForeColor;
|
||||
|
||||
lbl.Paint += lbl_Paint;
|
||||
lbl.MouseEnter += lbl_MouseEnter;
|
||||
lbl.Tag = menu;
|
||||
lbl.Click += lbl_Click;
|
||||
lbl.DoubleClick += lbl_DoubleClick;
|
||||
if (menu.AnchorRight)
|
||||
{
|
||||
lbl.Dock = DockStyle.Right;
|
||||
}
|
||||
else
|
||||
{
|
||||
lbl.Dock = DockStyle.Left;
|
||||
}
|
||||
this.panMenu.Controls.Add(lbl);
|
||||
|
||||
lbl.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the DoubleClick event of the lbl 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 lbl_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
IsExpand = !IsExpand;
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles the Click event of the lbl 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 lbl_Click(object sender, EventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
if (lbl.Tag != null)
|
||||
{
|
||||
var menu = (NavigationMenuItemExt)lbl.Tag;
|
||||
if (menu.ShowControl == null)
|
||||
{
|
||||
selectItem = menu;
|
||||
|
||||
if (ClickItemed != null)
|
||||
{
|
||||
ClickItemed(this, e);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsExpand)
|
||||
{
|
||||
selectItem = menu;
|
||||
ResetChildControl();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles the MouseEnter event of the lbl 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 lbl_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsExpand)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
var menu = lbl.Tag as NavigationMenuItemExt;
|
||||
foreach (var item in m_lstAnchors)
|
||||
{
|
||||
m_lstAnchors[item.Key].Hide();
|
||||
}
|
||||
if (menu.ShowControl != null)
|
||||
{
|
||||
if (!m_lstAnchors.ContainsKey(menu))
|
||||
{
|
||||
m_lstAnchors[menu] = new FrmAnchor(panMenu, menu.ShowControl, isNotFocus: false);
|
||||
|
||||
}
|
||||
m_lstAnchors[menu].BackColor = this.BackColor;
|
||||
m_lstAnchors[menu].Show(this);
|
||||
m_lstAnchors[menu].Size = new Size(this.panChilds.Width, expandHeight - mainMenuHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles the Paint event of the lbl control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="PaintEventArgs" /> instance containing the event data.</param>
|
||||
void lbl_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
if (lbl.Tag != null)
|
||||
{
|
||||
var menu = (NavigationMenuItemExt)lbl.Tag;
|
||||
e.Graphics.SetGDIHigh();
|
||||
|
||||
if (menu.ShowTip)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(menu.TipText))
|
||||
{
|
||||
var rect = new Rectangle(lbl.Width - 25, lbl.Height / 2 - 10, 20, 20);
|
||||
var path = rect.CreateRoundedRectanglePath(5);
|
||||
e.Graphics.FillPath(new SolidBrush(tipColor), path);
|
||||
e.Graphics.DrawString(menu.TipText, new Font("微软雅黑", 8f), new SolidBrush(Color.White), rect, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.FillEllipse(new SolidBrush(tipColor), new Rectangle(lbl.Width - 20, lbl.Height / 2 - 10, 10, 10));
|
||||
}
|
||||
}
|
||||
if (menu.Icon != null)
|
||||
{
|
||||
e.Graphics.DrawImage(menu.Icon, new Rectangle(1, (lbl.Height - 25) / 2, 25, 25), 0, 0, menu.Icon.Width, menu.Icon.Height, GraphicsUnit.Pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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