private void LoadPjtType() { using (Entities context = new Entities()) { var query = from q in context.ProjectType select q; foreach (var q in query) { //建立容器 SideNavPanel snp = new SideNavPanel(); snp.Dock = System.Windows.Forms.DockStyle.Fill; //内部列表 ListBoxAdv listbox = new ListBoxAdv(); listbox.Dock = DockStyle.Fill; listbox.AutoScroll = true; listbox.ItemDoubleClick += Listbox_ItemDoubleClick; var pjtlistquery = from p in context.Project where p.projettype == q.projtype select p; listbox.DisplayMember = "projectname"; listbox.DataSource = pjtlistquery.ToList(); snp.Controls.Add(listbox); _ProjListAdvDic.Add(q.projtype, listbox); //建立边栏按钮 SideNavItem sin = new SideNavItem(); sin.Checked = false; sin.Panel = snp; sin.Text = q.projtype; sideNav1.Controls.Add(snp); sideNav1.Items.Add(sin); } } }
protected SideNavItem AddSideNavItem() { SideNavItem item = new SideNavItem(); SideNavPanel panel = new SideNavPanel(); panel.Dock = DockStyle.Fill; item.Panel = panel; mySideNav1.Controls.Add(panel); mySideNav1.Items.Add(item); return(item); }
private void Listbox_ItemDoubleClick(object sender, MouseEventArgs e) { sideNav2.Items.Clear(); _DocListAdvDic.Clear(); BaseItem bc = sender as BaseItem; using (Entities context = new Entities()) { var query = from q in context.Document where q.projname == bc.Text group q by q.doctypename into g select new { type = g.Key, doc = g }; foreach (var q in query) { //建立容器 SideNavPanel snp = new SideNavPanel(); snp.Dock = System.Windows.Forms.DockStyle.Fill; //内部列表 ListBoxAdv listbox = new ListBoxAdv(); listbox.Dock = DockStyle.Fill; listbox.AutoScroll = true; listbox.ItemDoubleClick += DocList_ItemDounleChick; listbox.ItemClick += Listbox_ItemCheck; var pjtlistquery = from p in context.Document where p.doctypename == q.type select p; listbox.DisplayMember = "docname"; listbox.DataSource = pjtlistquery.ToList(); snp.Controls.Add(listbox); _DocListAdvDic.Add(q.type, listbox); //建立边栏按钮 SideNavItem sin = new SideNavItem(); sin.Checked = false; sin.Panel = snp; sin.Text = q.type; sideNav2.Controls.Add(snp); sideNav2.Items.Add(sin); } } sideNav2.Refresh(); }
public async Task <SideNav> CreateSideNavUserAsync() { string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); List <Guid> listGroupId = new List <Guid>(); List <Guid> listAccount = new List <Guid>(); SideNav sidenav = new SideNav(); sidenav.items = new List <SideNavItem>(); foreach (var account in user.Accounts) { if (account.CurrentCharacter != null) { if (account.CurrentCharacter.Fk_Group != Guid.Empty && _groups.FindIndex(o => o.Key == account.CurrentCharacter.Fk_Group) != -1 && !listGroupId.Contains(account.CurrentCharacter.Fk_Group)) { listGroupId.Add(account.CurrentCharacter.Fk_Group); } else if (account.CurrentCharacter.Fk_Group == Guid.Empty) { SideNavItem item = new SideNavItem() { Id = account.CurrentCharacter.Key.ToString(), isGroup = false, Name = account.CurrentCharacter.Name, State = ControllersModel.Enum.SideNavState.CONNECTED }; sidenav.items.Add(item); } } } foreach (var groupId in listGroupId) { GroupDB group = _groups.Find(o => o.Key == groupId) as GroupDB; SideNavItem item = new SideNavItem() { Id = groupId.ToString(), Name = group.Name, isGroup = true, State = ControllersModel.Enum.SideNavState.CONNECTED, Children = new List <SideNavItem>() }; foreach (var account in user.Accounts) { if (account.CurrentCharacter != null) { if (account.CurrentCharacter.Fk_Group == groupId) { SideNavItem ChildItem = new SideNavItem() { Id = account.CurrentCharacter.Key.ToString(), isGroup = false, Name = account.CurrentCharacter.Name, State = ControllersModel.Enum.SideNavState.CONNECTED }; item.Children.Add(ChildItem); } } } sidenav.items.Add(item); } return(sidenav); }