Пример #1
0
        private void AddTreeViewItem(CTreeView treeView, ItemCollection items, TreeViewImgItem selectedItem, LeftMenus leftMenus)
        {
            if (leftMenus.ParentId == 0)
            {
                treeView.Items.Add(GetSelectedTreeView().GenerateTreeViewItem(selectedItem));
                selectedItem.IsSelected = true;
                return;
            }

            foreach (var i in items)
            {
                var item = (TreeViewImgItem)i;
                if (((LeftMenus)item.DataContext).Id == leftMenus.ParentId)
                {
                    var treeViewMain = GetSelectedTreeView();
                    item.Items.Add(treeViewMain.GenerateTreeViewItem(selectedItem));
                    selectedItem.IsSelected = true;
                    item.IsExpanded         = true;

                    var requestModel = new LeftMenusUpdateSortRequestModel
                    {
                        DisplayName = leftMenus.DisplayName,
                        Sort        = int.MaxValue,
                        Timestamp   = _leftMenusManage.ServerTime.ToUnixTimestamp()
                    };
                    var result = _leftMenusManage.UpdateSort(leftMenus.Id, Timestamp, requestModel);
                    if (result.ResultStatus == ResultStatus.Success)
                    {
                        leftMenus.DisplayName = result.Data.DisplayName;
                        leftMenus.Sort        = result.Data.Sort;
                        leftMenus.Timestamp   = result.Data.Timestamp;
                    }
                    else
                    {
                        _metroWindow.ShowMessageAsync("更新节点排序失败", result.Message);
                    }
                    break;
                }

                if (item.HasItems)
                {
                    AddTreeViewItem(treeView, item.Items, selectedItem, leftMenus);
                }
            }
        }
Пример #2
0
        private void Init()
        {
            var navBarGroupsList = _barGroupsManage.GetAll().ToList();

            navBarGroupsList.ForEach(a => {
                var treeView = new CTreeView(a.Id, LeftMenusList)
                {
                    BorderThickness = new Thickness(0)
                };
                treeView.ChildItemSelected  += (sender, e) => ChildItemSelected?.Invoke(sender, e);
                treeView.ParentItemSelected += (sender, e) => ParentItemSelected?.Invoke(sender, e);
                var navBarGroup              = new NavBarGroup
                {
                    DisplayMode = DisplayMode.ImageAndText,
                    Header      = a.Name,
                    ImageSource = GetNavBarGroupImageSource(a.Ico),
                    DataContext = a
                };
                navBarGroup.Activate += (sender, e) => NavBarGroupActivate?.Invoke(sender, e);
                navBarGroup.Items.Add(treeView);
                NavBarControlMain.Groups.Add(navBarGroup);
            });
        }