Exemplo n.º 1
0
 /// <summary>
 /// 选中所有子项菜单事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void menuSelectAllChild_Click(object sender, RoutedEventArgs e)
 {
     if (tvZsmTree.SelectedItem != null)
     {
         Model.TreeModel tree = (Model.TreeModel)tvZsmTree.SelectedItem;
         tree.IsChecked = true;
         tree.SetChildrenChecked(true);
     }
 }
Exemplo n.º 2
0
        private void ReadStdOutputAction(string result)
        {
            if (result.Length > 8 && result.Substring(0, 8) == "[Normal]")
            {
                string[] FileArray = result.Remove(0, 30).Split('\\');
                if (FileArray.Length > 0)
                {
                    for (int i = 0; i < FileArray.Length; i++)
                    {
                        if (i == 0)
                        {
                            var tempTree = treeList.Where((num, index) => num.Id == FileArray[i]);
                            if (tempTree.Count() == 0)
                            {
                                Model.TreeModel tree = new Model.TreeModel();
                                tree.Id         = FileArray[i];
                                tree.Name       = FileArray[i];
                                tree.IsExpanded = true;
                                if (FileArray.Length != 1)
                                {
                                    tree.Type = "dir";
                                }
                                else
                                {
                                    tree.Type = "file";
                                    tree.File = result.Remove(0, 30);
                                }

                                treeList.Add(tree);
                            }
                        }
                        else
                        {
                            //根目录
                            var ParentTree = treeList.Where((num, index) => num.Id == FileArray[0]).FirstOrDefault();

                            //遍历除了根外的目录或文件
                            for (int l = 1; l <= i; l++)
                            {
                                //获取子集中的下一个目录
                                var tempParentTree = ParentTree.Children.Where((num, index) => num.Id == FileArray[l]);
                                if (tempParentTree.Count() != 0)
                                {
                                    ParentTree = tempParentTree.FirstOrDefault();
                                }
                                else
                                {
                                    Model.TreeModel child = new Model.TreeModel();
                                    child.Id     = FileArray[l];
                                    child.Name   = FileArray[l];
                                    child.Parent = ParentTree;
                                    if (l != FileArray.Length - 1)
                                    {
                                        child.Type = "dir";
                                    }
                                    else
                                    {
                                        child.Type = "file";
                                        child.File = result.Remove(0, 30);
                                    }
                                    ParentTree.Children.Add(child);
                                    tempParentTree = ParentTree.Children.Where((num, index) => num.Id == FileArray[l]);

                                    if (tempParentTree.Count() != 0)
                                    {
                                        ParentTree = tempParentTree.FirstOrDefault();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }