public SearchView(TreenodeViewModel root)
        {
            InitializeComponent();

            SearchViewModel svm = new SearchViewModel(root);
            svm.UIAction = ((uiaction) => Dispatcher.BeginInvoke(uiaction));

            this.DataContext = svm;
        }
        public TreenodeViewModel(Treenode node, TreenodeViewModel parent)
        {
            this.Treenode = node;

            this.Parent = parent;
            foreach (Treenode n in Treenode.Children.Cast<Treenode>()) {
                children.Add(new TreenodeViewModel(n, this));
            }
        }
        public SearchViewModel(TreenodeViewModel root)
        {
            RootNode = root;

            searchWorker = new BackgroundWorker() {
                WorkerReportsProgress = true,
                WorkerSupportsCancellation = false
            };
            searchWorker.DoWork += new DoWorkEventHandler(SearchWorker_DoWork);
            searchWorker.ProgressChanged += new ProgressChangedEventHandler(SearchWorker_ProgressChanged);
            searchWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(searchWorker_RunWorkerCompleted);

            progressUpdateTimer.Elapsed += new ElapsedEventHandler(ProgressUpdateTimer_Elapsed);

            SearchCommand = new _SearchCommand(this);

            searchDpt = new DepthFirstSearch(TreenodeViewModel.GetTreenode(root));
            predicate = ((_SearchCommand)SearchCommand).SearchPredicate;
        }
 internal static void Write(TreenodeViewModel rootNode, FileStream fs)
 {
     throw new NotImplementedException();
 }
        // TODO Remove this duplication of code from Treenode.cs
        public static TreenodeViewModel NodeFromPath(string path, TreenodeViewModel relativeTo)
        {
            if (path == null) throw new ArgumentException("path");
            if (relativeTo == null) throw new ArgumentException("relativeTo");

            string[] parts = path.Split(new char[] { '/' });

            if (parts.Length < 1 || parts[1] != relativeTo.Title) {
                // The root node of the search differs
                return null;
            }

            TreenodeViewModel node = relativeTo;

            // Start on 2 because of the leading forward slash giving an empty string and the starting nodes being the same
            for (int p = 2; p < parts.Length && node != null; p++) {
                node = node.Children.FirstOrDefault(s => s.Title == parts[p]);
            }
            return node;
        }
 public static Treenode GetTreenode(TreenodeViewModel vm)
 {
     return vm.Treenode;
 }