예제 #1
0
        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);
                }
            }
        }
예제 #2
0
        private void AddElementToList(string parentId, OneDriveFilesTreeElement element)
        {
            OneDriveFilesTreeElement parent;

            if (FilesTreeElements.TryGetValue(parentId, out parent))
            {
                parent.SetChild(element);
            }

            FilesTreeElements.Add(element.Id, element);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
 public void SetChild(OneDriveFilesTreeElement child)
 {
     this.Childs.Add(child);
 }
예제 #6
0
 public OneDriveFilesTreeElement(string id, ElementType type, OneDriveFilesTreeElement child, string name, int indent)
     : this(id, type, name, indent)
 {
     this.Childs.Add(child);
 }