示例#1
0
 public SelectorModel(SelectorWindow window)
 {
     Highlight   = true;
     Directories = new ExtendedObservableCollection <treeelement>();
     this.window = window;
     Directories.ItemPropertyChanged += (sender, e) =>
     {
         NotifyPropertyChanged("json");
     };
 }
示例#2
0
        private void BtnSyncTree_Click(object sender, RoutedEventArgs e)
        {
            var currentNode = vm.Directories;

            vm.Highlight = false;
            for (var i = 1; i < vm.Selector.Count; i++)
            {
                var s = vm.Selector[i]; var found = false;
                foreach (var treenode in currentNode)
                {
                    if (vm.Plugin.Match(s, treenode.Element))
                    {
                        found = true;
                        treenode.IsExpanded = true;
                        treenode.IsSelected = true;
                        currentNode         = new ExtendedObservableCollection <treeelement>();
                        foreach (var subc in treenode.Children)
                        {
                            currentNode.Add(subc);
                        }
                        //currentNode = c.Children;
                        continue;
                    }
                }
                if (!found)
                {
                    foreach (var treenode in currentNode)
                    {
                        foreach (var subtreenode in treenode.Children)
                        {
                            if (vm.Plugin.Match(s, subtreenode.Element))
                            {
                                found = true;
                                subtreenode.IsExpanded = true;

                                subtreenode.IsSelected = true;
                                currentNode            = new ExtendedObservableCollection <treeelement>();
                                foreach (var subc in subtreenode.Children)
                                {
                                    currentNode.Add(subc);
                                }
                                //currentNode = c.Children;
                                continue;
                            }
                        }
                    }
                }
                if (!found)
                {
                    break;
                }
            }
            vm.Highlight = true;
        }
示例#3
0
 public SelectorModel(SelectorWindow window, Selector Selector, Selector Anchor = null)
 {
     Highlight     = true;
     this.Anchor   = Anchor;
     this.Selector = Selector;
     Directories   = new ExtendedObservableCollection <treeelement>();
     this.window   = window;
     Directories.ItemPropertyChanged += (sender, e) =>
     {
         _json = Selector.ToString();
         NotifyPropertyChanged("json");
     };
 }
示例#4
0
 private treeelement SearchTree(ExtendedObservableCollection <treeelement> item, SelectorItem s)
 {
     foreach (var treenode in item)
     {
         if (vm.Plugin.Match(s, treenode.Element))
         {
             return(treenode);
         }
         var currentNode = new ExtendedObservableCollection <treeelement>();
         foreach (var subc in treenode.Children)
         {
             currentNode.Add(subc); if (subc.Children.Count() == 0)
             {
                 subc.AddSubElements();
             }
         }
         var res = SearchTree(currentNode, s);
         if (res != null)
         {
             return(res);
         }
     }
     return(null);
 }
示例#5
0
        private void BtnSyncTree_Click(object sender, RoutedEventArgs e)
        {
            var currentNode = vm.Directories;

            vm.Highlight = false;
            var found = false;

            if (vm.Selector.Count > 1)
            {
                var s = vm.Selector[1];
                var p = s.Properties.Where(x => x.Name == "xpath").FirstOrDefault();
                if (p != null)
                {
                    var treenode = SearchTree(vm.Directories, s);
                    if (treenode != null)
                    {
                        ExpandToRoot(treenode);
                        found = true;
                        treenode.IsExpanded = true;
                        treenode.IsSelected = true;
                        currentNode         = new ExtendedObservableCollection <treeelement>();
                        foreach (var subc in treenode.Children)
                        {
                            currentNode.Add(subc);
                        }
                        //currentNode = c.Children;
                    }
                }
            }
            if (!found)
            {
                for (var i = 1; i < vm.Selector.Count; i++)
                {
                    found = false;
                    var s = vm.Selector[i];
                    foreach (var treenode in currentNode)
                    {
                        if (vm.Plugin.Match(s, treenode.Element))
                        {
                            found = true;
                            treenode.IsExpanded = true;
                            treenode.IsSelected = true;
                            currentNode         = new ExtendedObservableCollection <treeelement>();
                            foreach (var subc in treenode.Children)
                            {
                                currentNode.Add(subc);
                            }
                            //currentNode = c.Children;
                            continue;
                        }
                    }
                    if (!found)
                    {
                        foreach (var treenode in currentNode)
                        {
                            foreach (var subtreenode in treenode.Children)
                            {
                                if (vm.Plugin.Match(s, subtreenode.Element))
                                {
                                    found = true;
                                    subtreenode.IsExpanded = true;

                                    subtreenode.IsSelected = true;
                                    currentNode            = new ExtendedObservableCollection <treeelement>();
                                    foreach (var subc in subtreenode.Children)
                                    {
                                        currentNode.Add(subc);
                                    }
                                    //currentNode = c.Children;
                                    continue;
                                }
                            }
                        }
                    }
                    if (!found)
                    {
                        break;
                    }
                }
            }
            if (!found)
            {
                var last      = vm.Selector.Last();
                var _treenode = SearchTree(vm.Directories, last);
                if (_treenode != null)
                {
                    ExpandToRoot(_treenode);
                    found = true;
                    _treenode.IsExpanded = true;
                    _treenode.IsSelected = true;
                    currentNode          = new ExtendedObservableCollection <treeelement>();
                    foreach (var subc in _treenode.Children)
                    {
                        currentNode.Add(subc);
                    }
                }
            }

            vm.Highlight = true;
        }