/// <summary>
        /// Loads the folders in the "My files" view
        /// </summary>
        /// <param name="parentItemId">Folder to display the child folders and items of. If not provided or NULL, the root folder will be used.</param>
        public async Task LoadFolderItems(string parentItemId = null)
        {
            CloudLocationPicker.Items.Clear();

            // Check if there is a parent folder to display its children of
            OneDriveItemCollection itemCollection;

            if (parentItemId == null)
            {
                // No parent folder, get the items under the root
                itemCollection = await _oneDriveApi.GetDriveRootChildren();

                CloudLocationPath.Text            = "/drive/root:";
                UpButton.Enabled                  = false;
                GoToRootToolStripMenuItem.Enabled = false;
                CurrentMyOneDriveItem             = await _oneDriveApi.GetDriveRoot();
            }
            else
            {
                // Parent folder provided, get its children
                itemCollection = await _oneDriveApi.GetChildrenByFolderId(parentItemId);

                CurrentMyOneDriveItem = await _oneDriveApi.GetItemById(parentItemId);

                GoToRootToolStripMenuItem.Enabled = true;
                UpButton.Enabled       = CurrentMyOneDriveItem.ParentReference != null;
                UpButton.Tag           = CurrentMyOneDriveItem.ParentReference != null ? CurrentMyOneDriveItem.ParentReference.Id : null;
                CloudLocationPath.Text = CurrentMyOneDriveItem.ParentReference != null ? CurrentMyOneDriveItem.ParentReference.Path + "/" + CurrentMyOneDriveItem.Name : "";
            }

            foreach (var listViewItem in itemCollection.Collection.Select(oneDriveItem => new ListViewItem
            {
                Text = oneDriveItem.Name,
                Tag = oneDriveItem.RemoteItem != null ? oneDriveItem.RemoteItem.Id : oneDriveItem.Id,
                ImageKey = oneDriveItem.Folder != null ? "Folder" : oneDriveItem.RemoteItem != null ? "RemoteFolder" : "File"
            }))
            {
                CloudLocationPicker.Items.Add(listViewItem);
            }

            // Define if the OK button should be enabled
            FileNameTextBox_TextChanged(null, null);
        }
Example #2
0
        public async Task LoadFolderItems(string parentItemId = null)
        {
            CloudLocationPicker.Items.Clear();

            OneDriveItemCollection itemCollection;

            if (parentItemId == null)
            {
                itemCollection = await _oneDriveApi.GetDriveRootChildren();

                CloudLocationPath.Text = "/drive/root:";
                UpButton.Enabled       = false;
                CurrentOneDriveItem    = null;
                CurrentOneDriveItem    = await _oneDriveApi.GetDriveRoot();
            }
            else
            {
                itemCollection = await _oneDriveApi.GetChildrenByFolderId(parentItemId);

                CurrentOneDriveItem = await _oneDriveApi.GetItemById(parentItemId);

                UpButton.Enabled       = CurrentOneDriveItem.ParentReference != null;
                UpButton.Tag           = CurrentOneDriveItem.ParentReference != null ? CurrentOneDriveItem.ParentReference.Id : null;
                CloudLocationPath.Text = CurrentOneDriveItem.ParentReference != null ? CurrentOneDriveItem.ParentReference.Path + "/" + CurrentOneDriveItem.Name : "";
            }

            foreach (var listViewItem in itemCollection.Collection.Select(oneDriveItem => new ListViewItem
            {
                Text = oneDriveItem.Name,
                Tag = oneDriveItem.RemoteItem != null ? oneDriveItem.RemoteItem.Id : oneDriveItem.Id,
                ImageKey = oneDriveItem.Folder != null ? "Folder" : oneDriveItem.RemoteItem != null ? "RemoteFolder" : "File"
            }))
            {
                CloudLocationPicker.Items.Add(listViewItem);
            }
        }
Example #3
0
        /// <summary>
        /// Loads the folders in the "My files" view
        /// </summary>
        /// <param name="parentItemId">Folder to display the child folders and items of. If not provided or NULL, the root folder will be used.</param>
        public async Task LoadFolderItems(string parentItemId = null)
        {
            CloudLocationPicker.Items.Clear();

            // Check if there is a parent folder to display its children of
            OneDriveItemCollection itemCollection;

            if (parentItemId == null)
            {
                // No parent folder, get the items under the root
                itemCollection = await _oneDriveApi.GetDriveRootChildren();

                CloudLocationPath.Text            = "/drive/root:";
                UpButton.Enabled                  = false;
                GoToRootToolStripMenuItem.Enabled = false;
                CurrentMyOneDriveItem             = await _oneDriveApi.GetDriveRoot();
            }
            else
            {
                // Parent folder provided, get its children
                itemCollection = await _oneDriveApi.GetChildrenByFolderId(parentItemId);

                CurrentMyOneDriveItem = await _oneDriveApi.GetItemById(parentItemId);

                GoToRootToolStripMenuItem.Enabled = true;
                UpButton.Enabled       = CurrentMyOneDriveItem.ParentReference != null;
                UpButton.Tag           = CurrentMyOneDriveItem.ParentReference != null ? CurrentMyOneDriveItem.ParentReference.Id : null;
                CloudLocationPath.Text = CurrentMyOneDriveItem.ParentReference != null ? CurrentMyOneDriveItem.ParentReference.Path + "/" + CurrentMyOneDriveItem.Name : "";
            }

            foreach (var oneDriveItem in itemCollection.Collection)
            {
                var oneDriveListViewItem = new ListViewItem
                {
                    Text     = oneDriveItem.Name,
                    Tag      = oneDriveItem.RemoteItem != null ? oneDriveItem.RemoteItem.Id : oneDriveItem.Id,
                    ImageKey = oneDriveItem.Folder != null ? "Folder" : oneDriveItem.RemoteItem != null ? "RemoteFolder" : "File"
                };

                if (oneDriveItem.Size > 0)
                {
                    oneDriveListViewItem.ToolTipText += string.Format("Size: {0:n0} bytes", oneDriveItem.Size) + Environment.NewLine;
                }
                else if (oneDriveItem.RemoteItem != null && oneDriveItem.RemoteItem.Size > 0)
                {
                    oneDriveListViewItem.ToolTipText += string.Format("Size: {0:n0} bytes", oneDriveItem.RemoteItem.Size) + Environment.NewLine;
                }
                if (oneDriveItem.CreatedDateTime != null)
                {
                    oneDriveListViewItem.ToolTipText += string.Format("Created: {0:d MMMM yyyy HH:mm:ss}", oneDriveItem.CreatedDateTime) + Environment.NewLine;
                }
                if (oneDriveItem.LastModifiedDateTime != null)
                {
                    oneDriveListViewItem.ToolTipText += string.Format("Last modified: {0:d MMMM yyyy HH:mm:ss}", oneDriveItem.LastModifiedDateTime) + Environment.NewLine;
                }

                CloudLocationPicker.Items.Add(oneDriveListViewItem);
            }

            // Define if the OK button should be enabled
            FileNameTextBox_TextChanged(null, null);
        }
Example #4
0
        /// <summary>
        /// Gets the items in the OneDrive folder with the ID 'E499210E61A71FF3!3635'
        /// </summary>
        private async void GetByIdButton_Click(object sender, EventArgs e)
        {
            var data1 = await OneDriveApi.GetChildrenByFolderId("E499210E61A71FF3!3635");

            JsonResultTextBox.Text = data1 != null ? data1.OriginalJson : "Not found";
        }