Example #1
0
 /// <summary>
 /// 添加子或孙类,默认为子类,
 /// </summary>
 /// <param name="menu"></param>
 /// <param name="childLevel">1:表示子类,2表示孙,以此类推</param>
 public void AddChild(SunMenu menu, int childLevel = 1)
 {
     menu.Level  = this.Level + childLevel;
     menu.Expand = menu.Expand && this.Expand;
     this.Children.Add(menu);
     menu.Parent = this;
 }
Example #2
0
 public void CloseLevel1Menu(SunMenu menu)
 {
     if (!menu.Expand)
     {
         return;
     }
     this.SunMenuList.ForEach(m =>
     {
         if (m.Expand && m != menu)
         {
             m.Toggle(false);
         }
     });
 }
Example #3
0
 /// <summary>
 /// 颜色改变事件
 /// </summary>
 /// <param name="menu"></param>
 public void SetButtonClick(SunMenu menu)
 {
     //加入二三级菜单的点击颜色变化事件
     if (menu.Level > 1 && menu.TitleButton != null)
     {
         menu.TitleButton.Click += (object sender, EventArgs e) =>
         {
             //恢复颜色
             if (this.CurrentTitleButton != null)
             {
                 CurrentTitleButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51)))));
             }
             CurrentTitleButton = (SunButton)sender;
             //设置点击后的颜色
             CurrentTitleButton.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(44)))), ((int)(((byte)(188)))), ((int)(((byte)(135)))));
         };
     }
     menu.Children.ForEach(c =>
     {
         SetButtonClick(c);
     });
 }