Example #1
0
        /// <summary>
        /// 获取子节点
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public ListResult <DicNode> GetChildNodes(string name = "")
        {
            var list  = dal.List();
            var nodes = new List <DicNode>();

            foreach (var i in list)
            {
                if (!string.IsNullOrEmpty(name) && !i.Name.Contains(name))
                {
                    continue;
                }
                var node = new DicNode
                {
                    Code       = i.Code,
                    Comment    = i.Comment,
                    expandable = false,
                    expanded   = false,
                    ID         = i.ID,
                    id         = i.ID,
                    leaf       = true,
                    Name       = i.Name,
                    Sort       = i.Sort,
                    Status     = i.Status,
                    text       = i.Name + "[" + i.Code + "]",
                    TypeID     = i.Type == null ? 0 : i.Type.ID,
                    TypeName   = i.Type == null ? "" : i.Type.Name
                };
                nodes.Add(node);
            }
            return(new ListResult <DicNode>(200, "获取数据成功!", nodes.Count(), nodes));
        }
Example #2
0
        public DicNode ArrayToDicNode(String[] strs)
        {
            DicNode node = new DicNode('\0');

            foreach (String str in strs)
            {
                StrToDicNode(node, str, 0);
            }
            return(node);
        }
Example #3
0
        public void StrToDicNode(DicNode node, String str, Int32 index)
        {
            if (index >= str.Length)
            {
                return;
            }
            DicNode nextNode = node.Nexts.FirstOrDefault(n => n.Letter == str[index]);

            if (nextNode == null)
            {
                nextNode = new DicNode(str[index]);
                node.Nexts.Add(nextNode);
            }
            StrToDicNode(nextNode, str, ++index);
        }
Example #4
0
        /// <summary>
        /// 控制节点选中
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeViewWorkload_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            //VS2019的核心组件,必选
            if (e.Node.Name == "CoreEditor")
            {
                if (!e.Node.Checked)
                {
                    e.Node.Checked = true;
                }
            }
            else
            {
                if (e.Node.Nodes.Count > 0)
                {
                    foreach (TreeNode node in e.Node.Nodes)
                    {
                        node.Checked = e.Node.Checked;
                    }

                    List <DicNode> tempcomponentList = componentList.Where(a => a.parentName == e.Node.Name).ToList();

                    foreach (DicNode node in tempcomponentList)
                    {
                        node.isChecked = e.Node.Checked;
                    }
                }

                if (e.Node.Parent != null)
                {
                    int childCount   = e.Node.Parent.Nodes.Count;
                    int checkedCount = 0;

                    foreach (TreeNode node in e.Node.Parent.Nodes)
                    {
                        if (node.Checked)
                        {
                            checkedCount++;
                        }
                    }

                    if (childCount == checkedCount)
                    {
                        e.Node.Parent.Checked = true;
                    }
                    else
                    {
                        e.Node.Parent.Checked = false;
                    }
                }

                DicNode dicNode = workloadList.Find(a => a.name == e.Node.Name);

                if (dicNode != null)
                {
                    dicNode.isChecked = e.Node.Checked;
                }

                dicNode = componentList.Find(a => a.name == e.Node.Name);

                if (dicNode != null)
                {
                    dicNode.isChecked = e.Node.Checked;
                }
            }
        }