예제 #1
0
        /// <summary>
        ///     Заполнение дерева подразделений
        /// </summary>
        public void FillTreeByDivision(Guid selectedDivision)
        {
            _selectedDivision = selectedDivision;
            if (selectedDivision != Guid.Empty)
            {
                _selectedNodeParentList = GetDivisionParents(_selectedDivision);
            }

            Nodes.Clear();
            foreach (var divisionState in GetDivisionState(Guid.Empty))
            {
                int currentDivisionLoadLevel = 1;
                //int currentDepartmentLoadLevel = 2;
                var divisionStateTreeNode = new CustomTreeNode
                {
                    Text  = divisionState.Value,
                    Value = divisionState.Key.ToString(),
                    Tag   = DepartmentTreeNodeType.DivisionState
                };
                if (!_selectedNodeParentList.ContainsKey(divisionState.Key))
                {
                    divisionStateTreeNode.Collapse();
                }
                Nodes.Add(divisionStateTreeNode);
                //Заполнение дерева DivisionState
                CreateDivisionStateTreeChildNodes(divisionStateTreeNode, divisionState.Key, ref currentDivisionLoadLevel,
                                                  true);
            }
        }
예제 #2
0
        /// <summary>
        ///     Создание элемента дерева
        /// </summary>
        /// <param name="treeNodeType">Тип элемента</param>
        /// <param name="Text">Текст</param>
        /// <param name="Value">Значение</param>
        /// <returns>Элемент дерева</returns>
        private CustomTreeNode CreateCustomTreeNode(DepartmentTreeNodeType treeNodeType, String Text, Guid Value)
        {
            var node = new CustomTreeNode
            {
                Text     = Text,
                Value    = Value.ToString(),
                Tag      = treeNodeType,
                ImageUrl =
                    treeNodeType == DepartmentTreeNodeType.DivisionState
                        ? _divisionTreeNodeTypeImageUrl
                        : _departmentTreeNodeTypeImageUrl
            };

            if ((_selectedNodeParentList.ContainsKey(Value)) && Value != _selectedDivision)
            {
                node.Expand();
            }

            else
            {
                //Если не вызвать то сработает событие Expand и загрузятся лишние элементы
                node.Collapse();
            }

            if (_selectedDivision != Guid.Empty && Value == _selectedDivision)
            {
                node.Selected       = true;
                CurrentSelectedNode = node;
            }
            return(node);
        }
예제 #3
0
 /// <summary>
 ///     Заполнение дерева подразделений
 /// </summary>
 public void FillTree(CustomTreeNode rootNode, CustomTreeNode selected)
 {
     Nodes.Clear();
     Nodes.Add(rootNode);
     if (selected != null)
     {
         selected.Selected = true;
     }
 }
예제 #4
0
        /// <summary>
        ///     Создание дерева для DepartmentState
        /// </summary>
        /// <param name="parent">Родительский элемент</param>
        /// <param name="parentDepartmentGuid">Идентификатор родительского элемента</param>
        /// <param name="currentLoadLevel">Текущий уровень загрузки</param>
        /// <param name="isLoadFirst"></param>
        private void CreateDepartmentStateTreeChildNodes(CustomTreeNode parent, Guid parentDepartmentGuid,
                                                         ref int currentLoadLevel, bool isLoadFirst)
        {
            //Ограничиваем глубину загрузки дерева
            if (!(_selectedNodeParentList.ContainsKey(parentDepartmentGuid)) && currentLoadLevel > _maxLoadLevelTree)
            {
                return;
            }

            //if (parent.isChildsLoaded==null || !(bool) parent.isChildsLoaded)
            //{
            List <CustomTreeNode> treeNodeChildNodesList = parent.ChildNodes.Cast <CustomTreeNode>().ToList();

            foreach (var departmentNode in GetDepartmentState(parentDepartmentGuid))
            {
                CustomTreeNode node =
                    treeNodeChildNodesList.FirstOrDefault(n => n.Value.Equals(departmentNode.Key.ToString()));
                if (node == null)
                {
                    node = CreateCustomTreeNode(DepartmentTreeNodeType.DepartmentState,
                                                departmentNode.Value,
                                                departmentNode.Key);
                    parent.ChildNodes.Add(node);
                }
                if (isLoadFirst && !_selectedNodeParentList.ContainsKey(parentDepartmentGuid))
                {
                    return;
                }

                bool hasChild = IsHasChilds(DepartmentTreeNodeType.DepartmentState, departmentNode.Key);

                if (hasChild)
                {
                    if ((_selectedNodeParentList.ContainsKey(parentDepartmentGuid)))
                    {
                        CreateDepartmentStateTreeChildNodes(node, departmentNode.Key, ref currentLoadLevel, false);
                    }
                    else
                    {
                        currentLoadLevel++;
                        CreateDepartmentStateTreeChildNodes(node, departmentNode.Key, ref currentLoadLevel, true);
                        currentLoadLevel--;
                    }
                }
            }
            //}
            //parent.isChildsLoaded = true;
        }
예제 #5
0
        /// <summary>
        ///     Создание дерева для DivisionState
        /// </summary>
        /// <param name="parent">Родительский элемент</param>
        /// <param name="parentDivisionStateGuid">Идентификатор родительского элемента</param>
        /// <param name="currentLoadLevel">Текущий уровень загрузки</param>
        private void CreateDivisionStateTreeChildNodes(CustomTreeNode parent, Guid parentDivisionStateGuid,
                                                       ref int currentLoadLevel, bool isLoadFirst)
        {
            //Ограничиваем глубину загрузки дерева
            if (!(_selectedNodeParentList.ContainsKey(parentDivisionStateGuid)) && currentLoadLevel > _maxLoadLevelTree)
            {
                return;
            }

            //Формируем дерево DivisionState для текущего DivisionState
            List <CustomTreeNode> childNodesList = parent.ChildNodes.Cast <CustomTreeNode>().ToList();

            foreach (var divisionStateNode in GetDivisionState(parentDivisionStateGuid))
            {
                CustomTreeNode node =
                    childNodesList.FirstOrDefault(n => n.Value.Equals(divisionStateNode.Key.ToString()));
                if (node == null)
                {
                    node = CreateCustomTreeNode(DepartmentTreeNodeType.DivisionState, divisionStateNode.Value,
                                                divisionStateNode.Key);
                    parent.ChildNodes.Add(node);
                }
                bool hasChild = IsHasChilds(DepartmentTreeNodeType.DivisionState, divisionStateNode.Key);

                if (hasChild)
                {
                    currentLoadLevel++;
                    CreateDivisionStateTreeChildNodes(node, divisionStateNode.Key, ref currentLoadLevel, isLoadFirst);
                    currentLoadLevel--;
                }
                else
                {
                    //Листовой элемент в дереве DivisionState
                    int currentDepartmentStateLoadLevel = 1;
                    //Формируем дерево DepartmentState для текущего DivisionState
                    CreateDivisionStateLeafDepartmentStateTreeChildNodes(node, divisionStateNode.Key,
                                                                         ref currentDepartmentStateLoadLevel, isLoadFirst);
                }
            }
        }