private async void newFoldertoolStripMenuItem_Click(object sender, EventArgs e)
        {
            var newFolderDialog = new OneDriveRequestInputDialog
            {
                FormTitle = "Create new folder"
            };

            newFolderDialog.ShowDialog(this);
            if (newFolderDialog.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                var newFolderServerRelativeUrl = await Providers.SharePointProvider.CreateFolder(newFolderDialog.InputValue, SelectedDocumentLibraryServerRelativeUrl, _httpClient);

                MessageBox.Show("Folder has been created", "New Folder", MessageBoxButtons.OK, MessageBoxIcon.Information);

                // Refresh the items shown
                refreshToolStripMenuItem_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Folder could not be created (" + ex.Message + ")", "New Folder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #2
0
        private async void NewFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var newFolderDialog = new OneDriveRequestInputDialog
            {
                FormTitle = "Create new folder"
            };

            newFolderDialog.ShowDialog(this);
            if (newFolderDialog.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                var newFolderItem = await _oneDriveApi.CreateFolder(CurrentMyOneDriveItem, newFolderDialog.InputValue);

                MessageBox.Show("Folder has been created", "New Folder", MessageBoxButtons.OK, MessageBoxIcon.Information);
                await LoadFolderItems(newFolderItem.Id);
            }
            catch (Exception)
            {
                MessageBox.Show("Folder could not be created", "New Folder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        private async void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SharePointDocumentLibraryPicker.SelectedItems.Count == 0 || SharePointDocumentLibraryPicker.SelectedItems[0].ImageKey == "DocLib")
            {
                return;
            }

            var selectedItem = SharePointDocumentLibraryPicker.SelectedItems[0];

            var renameItemDialog = new OneDriveRequestInputDialog
            {
                FormTitle  = "Enter new name",
                InputValue = selectedItem.Text
            };

            renameItemDialog.ShowDialog(this);
            if (renameItemDialog.DialogResult != DialogResult.OK)
            {
                return;
            }

            bool operationSuccessful = false;

            switch (selectedItem.ImageKey)
            {
            case "File":
                operationSuccessful = await Providers.SharePointProvider.RenameFile(renameItemDialog.InputValue, selectedItem.Tag.ToString(), _httpClient);

                break;

            case "Folder":
                operationSuccessful = await Providers.SharePointProvider.RenameFolder(renameItemDialog.InputValue, selectedItem.Tag.ToString(), _httpClient);

                break;

            default:
                MessageBox.Show("Item type '" + selectedItem.ImageKey + "' is not implemented for this operation.", "Rename item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (operationSuccessful)
            {
                MessageBox.Show(selectedItem.ImageKey + " has been renamed", "Rename item", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Unable to rename " + selectedItem.ImageKey.ToLowerInvariant(), "Rename item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            // Refresh the items shown
            refreshToolStripMenuItem_Click(sender, e);
        }
Example #4
0
        private async void RenameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (CloudLocationPicker.SelectedItems.Count == 0)
            {
                return;
            }
            if (CloudLocationPicker.SelectedItems[0].Tag == null)
            {
                return;
            }

            var renameItemDialog = new OneDriveRequestInputDialog
            {
                FormTitle  = "Enter new name",
                InputValue = CloudLocationPicker.SelectedItems[0].Text
            };

            renameItemDialog.ShowDialog(this);
            if (renameItemDialog.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                var oneDriveItemToRename = await _oneDriveApi.GetItemById(CloudLocationPicker.SelectedItems[0].Tag.ToString());

                var operationSuccessful = await _oneDriveApi.Rename(oneDriveItemToRename, renameItemDialog.InputValue);

                if (operationSuccessful)
                {
                    MessageBox.Show("Item has been renamed", "Rename item", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    await LoadFolderItems(CurrentMyOneDriveItem != null?CurrentMyOneDriveItem.Id : null);
                }
                else
                {
                    MessageBox.Show("Item could not be renamed", "Rename item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Item could not be renamed", "Rename item", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #5
0
        private void RenameEntry()
        {
            if (ConfigurationListView.SelectedItems.Count == 0)
            {
                return;
            }

            var selectedDatabaseText = ConfigurationListView.SelectedItems.Count == 1 ? ((KeyValuePair <string, Configuration>)ConfigurationListView.SelectedItems[0].Tag).Value.OneDriveName : string.Format("the selected {0} databases", ConfigurationListView.SelectedItems.Count);

            var renameItemDialog = new Forms.OneDriveRequestInputDialog
            {
                FormTitle  = string.Format("Enter new storage name name for {0}", selectedDatabaseText),
                InputValue = ConfigurationListView.SelectedItems.Count == 1 ? ((KeyValuePair <string, Configuration>)ConfigurationListView.SelectedItems[0].Tag).Value.OneDriveName : string.Empty
            };

            renameItemDialog.ShowDialog(this);
            if (renameItemDialog.DialogResult != DialogResult.OK)
            {
                return;
            }

            // Loop through all selected items to update their names
            foreach (ListViewItem configurationItem in ConfigurationListView.SelectedItems)
            {
                var configuration = (KeyValuePair <string, Configuration>)configurationItem.Tag;

                // Update the name in the configuration
                configuration.Value.OneDriveName = renameItemDialog.InputValue;

                // Update the name in the configuration list shown on the screen
                configurationItem.SubItems[1].Text = renameItemDialog.InputValue;
            }
            Configuration.Save();

            UpdateStatus("Storage Name has been changed");
        }