private void PopulateGrid(ITreeNodeContainer folderNode) { if (folderNode != null) { var cts = new CancellationTokenSource(); ListViewModel.SetFolderAsync(folderNode, cts.Token, BusyStatusReceiver); } }
protected TreeNode(object dataItem, ITreeNodeContainer parent, ITreeNodesOperation treeNodesOperation) { _dataItem = dataItem; _parent = parent; _treeNodesOperation = treeNodesOperation; _name = _dataItem is IDisplayItem ? ((IDisplayItem)_dataItem).DisplayName : _dataItem.ToString(); }
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); } }
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)); }
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); }
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); }
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); }
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); }
protected virtual TreeNodeData CreateDataNode(IFile f, ITreeNodeContainer parent) { return(new TreeNodeData(f, parent, this)); }
protected virtual bool ShouldUseChildrenTask(ITreeNodeContainer node) { return(true); }
public TreeNodeData(object dataItem, ITreeNodeContainer parent, ITreeNodesOperation treeNodesOperation) : base(dataItem, parent, treeNodesOperation) { }
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);
protected Task <ITreeNode> DoCreateChildAsync(object childDataItem, ITreeNodeContainer parent) { var file = (IFile)childDataItem; return(Task.FromResult(CreateTreeNode(file, parent))); }
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); }
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)); }
public Task <IReadOnlyCollection <ITreeNode> > CreateChildrenAsync(object parentDataItem, ITreeNodeContainer parent) { return(DoCreateChildrenAsync(parentDataItem, parent)); }
public Task <ITreeNode> CreateChildAsync(object childDataItem, ITreeNodeContainer parent) { return(DoCreateChildAsync(childDataItem, parent)); }
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)); }
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); }
public TreeNodeContainer(object dataItem, ITreeNodeContainer parent, ITreeNodesOperation shellItemsOperation) : base(dataItem, parent, shellItemsOperation) { Children.Add(DummyChild); }