Example #1
0
        private async void FillChildNodesCollections()
        {
            Task <string[]> fileTask = Task.Run(() => {
                try {
                    return(Directory.GetFiles(Value.ElementPath));
                } catch (IOException) { } catch (UnauthorizedAccessException) { };
                return(new string[0]);
            });

            Task <string[]> directoryTask = Task.Run(() => {
                try {
                    return(Directory.GetDirectories(Value.ElementPath));
                } catch (IOException) { } catch (UnauthorizedAccessException) { };
                return(new string[0]);
            });

            string[] files       = await fileTask;
            string[] directories = await directoryTask;
            await App.Current.Dispatcher.BeginInvoke((Action)(() => {
                foreach (var file in files)
                {
                    ChildFileNodes.Add(new FileTreeNode(Tree, this, new SFMFile(file)));
                }

                foreach (var directory in directories)
                {
                    ChildDirectoryNodes.Add(new FileTreeNode(Tree, this, new SFMDirectory(directory)));
                }
            }));
        }
Example #2
0
        private void AddChildToNode(IFileSystemElement element)
        {
            FileTreeNode nwNode = new FileTreeNode(Tree, this, element);

            if (nwNode.IsDirectory)
            {
                ChildDirectoryNodes?.Add(nwNode);
            }
            else
            {
                ChildFileNodes?.Add(nwNode);
            }
        }
Example #3
0
 internal async void AddElementsInDispatcher(IFileSystemElement[] element)
 {
     await App.Current.Dispatcher.BeginInvoke((Action)(() => {
         foreach (var elem in element)
         {
             if (elem.ElementType == FileSystemFacade.ElementType.Directory)
             {
                 ChildDirectoryNodes.Add(new SearchNode(Tree as SearchTree, this, elem));
             }
             else
             {
                 ChildFileNodes.Add(new SearchNode(Tree as SearchTree, this, elem));
             }
         }
     }));
 }
Example #4
0
        internal void UpdateSelf()
        {
            if (!IsDirectory)
            {
                return;
            }
            ChildrenInitialized = false;

            foreach (var child in ChildDirectoryNodes)
            {
                child.Dispose();
            }
            ChildDirectoryNodes.Clear();

            foreach (var child in ChildFileNodes)
            {
                child.Dispose();
            }
            ChildFileNodes.Clear();

            LoadChildren();
        }
Example #5
0
        internal void DisposeObservableCollections()
        {
            if (ChildDirectoryNodes != null)
            {
                foreach (var child in ChildDirectoryNodes)
                {
                    child.Dispose();
                }
                try {
                    ChildDirectoryNodes.Clear();
                } catch (NotSupportedException) { }
            }

            if (ChildFileNodes != null)
            {
                foreach (var child in ChildFileNodes)
                {
                    child.Dispose();
                }
                try {
                    ChildFileNodes.Clear();
                } catch (NotSupportedException) { }
            }
        }