protected void loaddata() { int x = 0; int y = 0; foreach (OrdInputDto dto in first) { MenuRender render = new MenuRender(); render.Text = dto.Name; render.Size = new System.Drawing.Size(84, 24); int xx = 0, yy = y + render.Size.Height; Second = this.model.getSrvOrdTplDO(dto.Id); if (Second != null) { render.IsParent = true; foreach (SrvOrdTplDO tpl in Second) { MenuRender render1 = new MenuRender(); render1.Text = tpl.Name; render1.Location = new Point(xx, yy); render1.Size = new System.Drawing.Size(render.Size.Width, render.Size.Height); // render1.DownButtonBrush = selectBrush; //render1.MoveButtonBrush = moveBrush; //render1.FontBrush =new SolidBrush( Color.White); yy = render1.Bound.Bottom; render.SubMenuList.Add(tpl.Id_srvortpl, render1); } } render.Location = new Point(x, y); render.DownButtonBrush = selectBrush; render.MoveButtonBrush = moveBrush; y = render.Bound.Bottom; Menulist.Add(render); this.pannel.AddRender(render); } }
void UpdateContentPanel(MenuRender menu) { if (selectMenu != menu) { SelectMenu = menu; DictionaryEventArgs args = new DictionaryEventArgs(); //if (SwitchFuncPage != null) // SwitchFuncPage(menu, args); this.Invalidate(); } }
/// <summary> /// 折叠或展开子菜单 /// </summary> /// <param name="index"></param> void UnFoldMenuPanel(int index) { MenuRender unfoldMenu = Menulist[index] as MenuRender; if (unfoldMenu.IsUnfold) { unfoldMenu.IsUnfold = false; foreach (MenuRender sub in unfoldMenu.SubMenuList.Values) { sub.Visible = false; this.pannel.RemoveRender(sub); } } else { unfoldMenu.IsUnfold = true; foreach (MenuRender sub in unfoldMenu.SubMenuList.Values) { sub.Visible = true; this.pannel.AddRender(sub); } } if (index < Menulist.Count - 1) { int x = 0; for (int j = index + 1; j < Menulist.Count; j++) { MenuRender t = Menulist[j] as MenuRender; if (Menulist[j - 1].SubMenuList.Count == 0 || !Menulist[j - 1].IsUnfold) { t.Location = new Point(x, Menulist[j - 1].Bound.Bottom); } else if (Menulist[j - 1].IsUnfold) { int count = Menulist[j - 1].SubMenuList.Count; t.Location = new Point(x, Menulist[j - 1].SubMenuList.Last().Value.Bound.Bottom); } if (t.IsUnfold) { int y = t.Bound.Bottom; foreach (MenuRender sub in t.SubMenuList.Values) { sub.Location = new Point(x, y); y = y + sub.Bound.Height; } } } } pannel.Invalidate(); }
void pannel_MouseClick(object sender, MouseEventArgs e) { for (int i = 0; i < Menulist.Count; i++) { MenuRender menu = Menulist[i]; if (menu.Bound.Contains(e.Location)) { foreach (OrderRender Ur in this.OrderRenderlist.Values) { this.pannel.RemoveRender(Ur); } this.OrderRenderlist.Clear(); #region 添加子菜单panel使用 if (menu.Contains(e.Location)) { UnFoldMenuPanel(i); } #endregion else { UpdateContentPanel(menu); } if (menu.IsUnfold) { foreach (var sub in menu.SubMenuList) { if (sub.Value.IsSelect) { foreach (OrderRender Ur in this.OrderRenderlist.Values) { this.pannel.RemoveRender(Ur); } this.OrderRenderlist.Clear(); UpdateContentPanel(sub.Value); Thread = Thread = this.model.getSrvOrTplItemDO(sub.Key); // Dictionary<string,string> dic=new Dictionary<string,string> (); int startX = 85; int startY = 10; OrderRender TMP = new OrderRender(this); foreach (SrvOrTplItemDO tpl in Thread) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add(tpl.Id_srv, tpl.Name_srv); OrderRender ThreadRender = new OrderRender(this); // ThreadRender.Datasource = dic; ThreadRender.Size = new Size(170, 40); if (startX + ThreadRender.Size.Width > this.Size.Width) { startX = 85; startY = TMP.Bound.Bottom; } ThreadRender.Location = new Point(startX, startY); startX += ThreadRender.Size.Width + 5; this.OrderRenderlist.Add(tpl.Id_srv, ThreadRender); this.pannel.AddRender(ThreadRender); TMP = ThreadRender; } this.pannel.Invalidate(); } } } return; } foreach (var sub in menu.SubMenuList) { if (sub.Value.Bound.Contains(e.Location)) { foreach (OrderRender Ur in this.OrderRenderlist.Values) { this.pannel.RemoveRender(Ur); } this.OrderRenderlist.Clear(); UpdateContentPanel(sub.Value); Thread = Thread = this.model.getSrvOrTplItemDO(sub.Key); // Dictionary<string,string> dic=new Dictionary<string,string> (); int startX = 85; int startY = 10; OrderRender TMP = new OrderRender(this); foreach (SrvOrTplItemDO tpl in Thread) { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add(tpl.Id_srv, tpl.Name_srv); OrderRender ThreadRender = new OrderRender(this); // ThreadRender.Datasource = dic; ThreadRender.Size = new Size(170, 40); if (startX + ThreadRender.Size.Width > this.Size.Width) { startX = 85; startY = TMP.Bound.Bottom; } ThreadRender.Location = new Point(startX, startY); startX += ThreadRender.Size.Width + 5; this.OrderRenderlist.Add(tpl.Id_srv, ThreadRender); this.pannel.AddRender(ThreadRender); TMP = ThreadRender; } this.pannel.Invalidate(); return; } } } }