private void ChangeFocusedTreeNode(IFileSystemElement targetElement)
        {
            Task.Run(() => SearchTreeInstance.EndSearch());

            var nwTreeRoot = FileSystemFacade.Instance.CreateFileSystemTree(targetElement as SFMDirectory).Root;

            DynamicFileSystemTree.LoadNodesChildren(nwTreeRoot);

            FocusedTreeNode = nwTreeRoot;
        }
 private void EndSearch()
 {
     if (SearchTreeInstance.IsSearching)
     {
         SearchTreeInstance.EndSearch();
     }
     if (FocusedTreeNode is SearchNode)
     {
         ChangeFocusedTreeNode(directoryBeforeSearch);
     }
 }
        private void StartNewSearch(string request, SearchTree.SearchType searchType, bool considerContent, bool caseSensetive, bool isRegularExpression)
        {
            while (SearchTreeInstance.IsSearching)
            {
                SearchTreeInstance.EndSearch();
            }

            SetSearchArguments(request, searchType, considerContent, caseSensetive, isRegularExpression);

            if (!(FocusedTreeNode is SearchNode))
            {
                directoryBeforeSearch = new SFMDirectory(FocusedTreeNode.Value.ElementPath);

                if (!FileSystemTree.Contains(FocusedTreeNode))
                {
                    FocusedTreeNode.Tree.Dispose();
                }
            }

            FocusedTreeNode.DisposeObservableCollections();
            FocusedTreeNode = SearchTreeInstance.Root;

            SearchTreeInstance.StartSearch();
        }