Ejemplo n.º 1
0
 /// <summary>
 ///     子节点挂载到Root节点
 /// </summary>
 /// <param name="root"></param>
 /// <param name="fullPath"></param>
 /// <param name="tag"></param>
 public static void AddToRootNode(CTreeNode root, string fullPath, object tag = null)
 {
     //分割路径
     var pathArray = fullPath.Split(".".ToCharArray());
     var searchNode = root;
     var newPath = string.Empty;
     for (var i = 0; i < pathArray.Length; i++)
     {
         //寻找当前SearchNode的Children里面是否有相关Node
         //1.在Root节点的时候,则Seg1.Seg2.Seg3 寻找Root的Children里面是否有Seg1
         newPath += i == 0 ? pathArray[i] : "." + pathArray[i];
         var hitNode = searchNode.IsChildContains(pathArray[i]);
         if (hitNode == null)
         {
             var newChild = new CTreeNode(newPath);
             newChild.Parent = searchNode;
             searchNode.Children.Add(newChild);
             searchNode = newChild;
         }
         else
         {
             searchNode = hitNode;
         }
     }
     //给节点赋予Tag
     searchNode.Tag = tag;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 子节点挂载到Root节点
        /// </summary>
        /// <param name="FullPath"></param>
        public static void AddToRootNode(CTreeNode Root, string FullPath, object Tag = null)
        {
            //分割路径
            var       PathArray  = FullPath.Split(".".ToCharArray());
            CTreeNode SearchNode = Root;
            var       NewPath    = string.Empty;

            for (int i = 0; i < PathArray.Length; i++)
            {
                //寻找当前SearchNode的Children里面是否有相关Node
                //1.在Root节点的时候,则Seg1.Seg2.Seg3 寻找Root的Children里面是否有Seg1
                NewPath += (i == 0?PathArray[i]:"." + PathArray[i]);
                var HitNode = SearchNode.IsChildContains(PathArray[i]);
                if (HitNode == null)
                {
                    var NewChild = new CTreeNode(NewPath);
                    NewChild.Parent = SearchNode;
                    SearchNode.Children.Add(NewChild);
                    SearchNode = NewChild;
                }
                else
                {
                    SearchNode = HitNode;
                }
            }
            //给节点赋予Tag
            SearchNode.Tag = Tag;
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     子节点挂载到Root节点
        /// </summary>
        /// <param name="root"></param>
        /// <param name="fullPath"></param>
        /// <param name="tag"></param>
        public static void AddToRootNode(CTreeNode root, string fullPath, object tag = null)
        {
            //分割路径
            var pathArray  = fullPath.Split(".".ToCharArray());
            var searchNode = root;
            var newPath    = string.Empty;

            for (var i = 0; i < pathArray.Length; i++)
            {
                //寻找当前SearchNode的Children里面是否有相关Node
                //1.在Root节点的时候,则Seg1.Seg2.Seg3 寻找Root的Children里面是否有Seg1
                newPath += i == 0 ? pathArray[i] : "." + pathArray[i];
                var hitNode = searchNode.IsChildContains(pathArray[i]);
                if (hitNode == null)
                {
                    var newChild = new CTreeNode(newPath);
                    newChild.Parent = searchNode;
                    searchNode.Children.Add(newChild);
                    searchNode = newChild;
                }
                else
                {
                    searchNode = hitNode;
                }
            }
            //给节点赋予Tag
            searchNode.Tag = tag;
        }
Ejemplo n.º 4
0
 /// <summary>
 ///     数型目录的装配
 /// </summary>
 /// <param name="cRoot"></param>
 /// <param name="rootTreeNode"></param>
 private void FillTreeView(CTreeNode cRoot, TreeNode rootTreeNode)
 {
     foreach (var child in cRoot.Children)
     {
         var childTreeNode = new TreeNode(child.Text);
         if (child.Children.Count == 0)
         {
             childTreeNode.Tag = child.Path;
         }
         FillTreeView(child, childTreeNode);
         rootTreeNode.Nodes.Add(childTreeNode);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 ///     数型目录的装配
 /// </summary>
 /// <param name="CRoot"></param>
 /// <param name="RootTreeNode"></param>
 private void FillTreeView(CTreeNode CRoot, TreeNode RootTreeNode)
 {
     foreach (var child in CRoot.Children)
     {
         TreeNode ChildTreeNode = new TreeNode(child.Text);
         if (child.Children.Count == 0)
         {
             ChildTreeNode.Tag = child.Path;
         }
         FillTreeView(child, ChildTreeNode);
         RootTreeNode.Nodes.Add(ChildTreeNode);
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 ///     从外部文件中获取Options列表
 /// </summary>
 public static CTreeNode LoadDefines()
 {
     List<ConfigurationFileOption.Define> Definelist = new List<ConfigurationFileOption.Define>();
     Definelist = Utility.LoadObjFromXml<List<ConfigurationFileOption.Define>>(DefineFilename);
     Definelist.Sort((x, y) => { return x.Path.CompareTo(y.Path); });
     //Root Node
     var Root = new CTreeNode(string.Empty);
     foreach (var item in Definelist)
     {
         System.Diagnostics.Debug.WriteLine(item.Path);
         CTreeNode.AddToRootNode(Root, item.Path);
         ConfigurationItemDictionary.Add(item.Path, item);
     }
     return Root;
 }