// *********************************************************************** // Assembly : HZH_Controls // Created : 08-15-2019 // // *********************************************************************** // // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // // // 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 { /// /// 子类节点 /// Implements the /// Implements the /// /// /// [ToolboxItem(false)] public partial class UCMenuChildrenItem : UserControl, IMenuItem { /// /// Occurs when [selected item]. /// public event EventHandler SelectedItem; /// /// The m data source /// private MenuItemEntity m_dataSource; /// /// Gets or sets the data source. /// /// The data source. public MenuItemEntity DataSource { get { return m_dataSource; } set { m_dataSource = value; if (value != null) { lblTitle.Text = value.Text; } } } /// /// Initializes a new instance of the class. /// public UCMenuChildrenItem() { InitializeComponent(); this.lblTitle.MouseDown += lblTitle_MouseDown; } /// /// Handles the MouseDown event of the lblTitle control. /// /// The source of the event. /// The instance containing the event data. void lblTitle_MouseDown(object sender, MouseEventArgs e) { if (SelectedItem != null) { SelectedItem(this, null); } } /// /// 设置样式 /// /// key:属性名称,value:属性值 /// 菜单元素设置样式异常 /// 菜单元素设置样式异常 public void SetStyle(Dictionary styles) { Type t = this.GetType(); foreach (var item in styles) { var pro = t.GetProperty(item.Key); if (pro != null && pro.CanWrite) { try { pro.SetValue(this, item.Value, null); } catch (Exception ex) { throw new Exception("菜单元素设置样式异常", ex); } } } } /// /// Sets the selected style. /// /// if set to true [BLN selected]. public void SetSelectedStyle(bool? blnSelected) { } } }