예제 #1
0
 private void PopulateGrid(ITreeNodeContainer folderNode)
 {
     if (folderNode != null)
     {
         var cts = new CancellationTokenSource();
         ListViewModel.SetFolderAsync(folderNode, cts.Token, BusyStatusReceiver);
     }
 }
예제 #2
0
        protected TreeNode(object dataItem, ITreeNodeContainer parent, ITreeNodesOperation treeNodesOperation)
        {
            _dataItem           = dataItem;
            _parent             = parent;
            _treeNodesOperation = treeNodesOperation;

            _name = _dataItem is IDisplayItem ? ((IDisplayItem)_dataItem).DisplayName : _dataItem.ToString();
        }
예제 #3
0
        private ITreeNode CreateTreeNode(IFile f, ITreeNodeContainer parent)
        {
            if (f is IFolder)
            {
                return(CreateContainerNode(f, parent));
            }

            return(CreateDataNode(f, parent));
        }
 protected static void DisplayTree(string title, ITreeNodeContainer<string> tree)
 {
     Debug.WriteLine(title);
     var lines = tree.ToMultilineString().ToArray();
     foreach (var line in lines)
     {
         Debug.WriteLine(line);
     }
 }
예제 #5
0
        public async Task <IReadOnlyCollection <TFile> > SetFolderAsync(ITreeNodeContainer folderNode, CancellationToken ct = default(CancellationToken), IProgress <string> progress = null)
        {
            CurrentFolderNode = folderNode;
            var folder = (TFolder)folderNode.DataItem;

            CurrentFolder = folder;

            var result = await PopulateFolderAsync(folderNode, ct, progress);

            return(result);
        }
        public static bool TryRemoveNode(this ITreeNodeContainer container, ITreeNode node)
        {
            var index = container.IndexOf(n => ReferenceEquals(n, node));

            if (index < 0)
            {
                return(false);
            }

            return(container.TryRemoveNodeAt(index));
        }
예제 #7
0
        private async Task <IReadOnlyCollection <TFile> > GetFilesAsync(ITreeNodeContainer folderNode, CancellationToken ct = default(CancellationToken))
        {
            if (ShouldUseChildrenTask(folderNode))
            {
                var children    = await folderNode.ChildrenTask;
                var loadedFiles = children.Select(i => i.DataItem.CastTo <TFile>()).ToArray();
                return(loadedFiles);
            }

            var folder = (TFolder)folderNode.DataItem;
            var files  = await folder.GetFilesAsync(ct : ct).ConfigureAwait(true);

            var result = files.Cast <TFile>().ToArray();

            return(result);
        }
예제 #8
0
        private async Task <ITreeNode> DoCreateRootAsync(bool isSingleRoot)
        {
            var root = _root = await CreateRootNodeAsync();

            await root.ExpandAsync().ConfigureAwait(true);

            if (isSingleRoot)
            {
                Items.Add(root);
            }
            else
            {
                Items.AddRange(root.Children);
            }

            return(root);
        }
예제 #9
0
        public async Task <IReadOnlyCollection <TFile> > SetFilesAsync(ITreeNodeContainer folderNode, Func <CancellationToken, Task <IReadOnlyCollection <IFile> > > fileFunc, CancellationToken ct = default(CancellationToken), IProgress <string> progress = null)
        {
            CurrentFolderNode = folderNode;
            var folder = (TFolder)folderNode.DataItem;

            CurrentFolder = folder;

            Items.Clear();
            var files = await fileFunc(ct);

            var result = files.Cast <TFile>().ToArray();

            Items.AddRange(result);

            RaiseFilesPopulated();

            return(result);
        }
예제 #10
0
        protected override TreeNodeContainer CreateContainerNode(IFile f, ITreeNodeContainer parent)
        {
            var result = new TreeNodeContainer(f, parent, this);

            if (Equals(f, _myDriveFolder) || Equals(f, _teamDriveFolder))
            {
                if (UpdateFrequentFolder)
                {
                    result.CustomSort = new CompositeComparer <TreeNodeContainer>(new[] { FavoriteFileComparer, FileNameComparer });
                }
                else
                {
                    result.CustomSort = (IComparer)FileNameComparer;
                }
            }

            return(result);
        }
예제 #11
0
 protected virtual TreeNodeData CreateDataNode(IFile f, ITreeNodeContainer parent)
 {
     return(new TreeNodeData(f, parent, this));
 }
예제 #12
0
 protected virtual bool ShouldUseChildrenTask(ITreeNodeContainer node)
 {
     return(true);
 }
예제 #13
0
 public TreeNodeData(object dataItem, ITreeNodeContainer parent, ITreeNodesOperation treeNodesOperation) : base(dataItem, parent, treeNodesOperation)
 {
 }
예제 #14
0
 async Task <IReadOnlyCollection <IFile> > IFileSystemCollectionViewModel.SetFilesAsync(ITreeNodeContainer folderNode, Func <CancellationToken, Task <IReadOnlyCollection <IFile> > > fileFunc, CancellationToken ct)
 {
     return(await SetFilesAsync(folderNode, fileFunc, ct).ConfigureAwait(false));
 }
 public abstract void ToTree(ITreeNodeContainer<string> tree);
예제 #16
0
        protected Task <ITreeNode> DoCreateChildAsync(object childDataItem, ITreeNodeContainer parent)
        {
            var file = (IFile)childDataItem;

            return(Task.FromResult(CreateTreeNode(file, parent)));
        }
예제 #17
0
        protected virtual async Task <IReadOnlyCollection <TFile> > PopulateFolderAsync(ITreeNodeContainer folderNode, CancellationToken ct, IProgress <string> progress)
        {
            Items.Clear();
            var result = await GetFilesAsync(folderNode, ct);

            Items.AddRange(result);

            RaiseFilesPopulated();

            return(result);
        }
예제 #18
0
        protected override bool ShouldUseChildrenTask(ITreeNodeContainer node)
        {
            var folder = (IGoogleDriveFolder)node.DataItem;

            return(folder.File.IsNot <GoogleAdhocDrive>() && folder.File.IsNot <GoogleSearchResultDrive>());
        }
 public static bool TryAddNode(this ITreeNodeContainer container, ITreeNode node)
 {
     return(container.TryInsertNode(container.Nodes.Count, node));
 }
예제 #20
0
 public Task <IReadOnlyCollection <ITreeNode> > CreateChildrenAsync(object parentDataItem, ITreeNodeContainer parent)
 {
     return(DoCreateChildrenAsync(parentDataItem, parent));
 }
예제 #21
0
 public Task <ITreeNode> CreateChildAsync(object childDataItem, ITreeNodeContainer parent)
 {
     return(DoCreateChildAsync(childDataItem, parent));
 }
예제 #22
0
        protected override Task <IReadOnlyCollection <IGoogleDriveFile> > PopulateFolderAsync(ITreeNodeContainer folderNode, CancellationToken ct, IProgress <string> progress)
        {
            if (!folderNode.ChildrenTask.IsCompleted)
            {
                var parent = folderNode.CastTo <TreeNodeContainer>().DataItem.CastTo <IGoogleDriveFolder>();
                if (parent.IsMyDriveFile() || (parent.File.IsNot <GoogleTeamDrive>() && parent.IsTeamDriveFile()))
                {
                    Items.Clear();

                    var observable = _gService.GetChildFilesObservable(parent, ct: ct);
                    observable.Buffer(TimeSpan.FromMilliseconds(400))
                    .ObserveOn(SynchronizationContext.Current)
                    .Subscribe(lf => Items.AddRange(lf.SelectMany(i => i)), RaiseFilesPopulated);

                    return(Task.FromResult(Empty));
                }
            }

            return(base.PopulateFolderAsync(folderNode, ct, progress));
        }
예제 #23
0
        protected async Task <IReadOnlyCollection <ITreeNode> > DoCreateChildrenAsync(object parentItem, ITreeNodeContainer parent)
        {
            var folder = parentItem as IFolder;

            if (folder != null)
            {
                var files = await folder.GetFilesAsync().ConfigureAwait(true);

                return(files.Select(f => CreateTreeNode(f, parent)).ToArray());
            }

            return(new ITreeNode[0]);
        }
 public override void ToTree(ITreeNodeContainer<string> tree)
 {
     var node = tree.Add(ToString());
     Elements.Lhs.ToTree(node);
     Elements.Rhs.ToTree(node);
 }
예제 #25
0
 public TreeNodeContainer(object dataItem, ITreeNodeContainer parent, ITreeNodesOperation shellItemsOperation) : base(dataItem, parent, shellItemsOperation)
 {
     Children.Add(DummyChild);
 }