private async Task CreateDynamicFilesTree(LiveConnectClient client, IList <object> listedItems, int indent) { foreach (var listItem in listedItems) { string name = (listItem as dynamic).name; if ((listItem as dynamic).type == "folder" || (listItem as dynamic).type == "album") { OneDriveFilesTreeElement newElement = new OneDriveFilesTreeElement((listItem as dynamic).id, OneDriveFilesTreeElement.ElementType.Folder, name, indent); AddElementToList((listItem as dynamic).parent_id, newElement); string uri = (listItem as dynamic).id + "/files"; try { LiveOperationResult operationResult = await client.GetAsync(uri); dynamic result = (operationResult.Result as dynamic).data; CreateDynamicFilesTree(client, result, indent + 1); CreateFileExploreUI(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { OneDriveFilesTreeElement newElement = new OneDriveFilesTreeElement((listItem as dynamic).id, OneDriveFilesTreeElement.ElementType.File, name, indent); AddElementToList((listItem as dynamic).parent_id, newElement); } } }
private void AddElementToList(string parentId, OneDriveFilesTreeElement element) { OneDriveFilesTreeElement parent; if (FilesTreeElements.TryGetValue(parentId, out parent)) { parent.SetChild(element); } FilesTreeElements.Add(element.Id, element); }
public IList <OneDriveFilesTreeElement> GetChilds(OneDriveFilesTreeElement element) { List <OneDriveFilesTreeElement> result = new List <OneDriveFilesTreeElement>(); result.Add(element); foreach (OneDriveFilesTreeElement child in element.Childs) { result.AddRange(GetChilds(child)); } return(result); }
private void CreateTextBlock(OneDriveFilesTreeElement element) { TextBlock textBlock = new TextBlock(); textBlock.Name = element.Id; textBlock.TextWrapping = TextWrapping.Wrap; textBlock.Margin = new Thickness(element.Indent * 20, 5, 0, 5); textBlock.Text = element.Name; if (element.Type == OneDriveFilesTreeElement.ElementType.Folder) { textBlock.FontWeight = FontWeights.Bold; } else if (element.Type == OneDriveFilesTreeElement.ElementType.File) { textBlock.Tap += textBlock_Tap; } OneDriveExplorerPanel.Children.Add(textBlock); }
public void SetChild(OneDriveFilesTreeElement child) { this.Childs.Add(child); }
public OneDriveFilesTreeElement(string id, ElementType type, OneDriveFilesTreeElement child, string name, int indent) : this(id, type, name, indent) { this.Childs.Add(child); }