private async void searchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormInputDialog dialog = new FormInputDialog("Search", "Search for:");

            var result = dialog.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(dialog.InputText))
            {
                return;
            }

            try
            {
                ShowWork(true);
                var results = await Connection.SearchForItemsAsync(ODConnection.ItemReferenceForItemId("root"), dialog.InputText, ItemRetrievalOptions.Default);

                var form = new FormSyncResults(Connection, results);
                form.Show();
            }
            catch (ODException exception)
            {
                PresentOneDriveException(exception);
            }
            ShowWork(false);
        }
Esempio n. 2
0
        private async void renameSelectedItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var itemToRename = this.SelectedItem;

            FormInputDialog dialog = new FormInputDialog("Rename selected item", "New item name");

            dialog.InputText = itemToRename.Name;

            var result = dialog.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            ODItem changes = new ODItem {
                Name = dialog.InputText
            };

            try
            {
                var renamedItem = await Connection.PatchItemAsync(itemToRename.ItemReference(), changes);

                UpdateItemInFolderContents(itemToRename, renamedItem);
            }
            catch (ODException ex)
            {
                PresentOneDriveException(ex);
            }
        }
        private async void toPathToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filename;
            var    stream = GetFileStreamForUpload("Path", out filename);

            if (null == stream)
            {
                return;
            }

            FormInputDialog dialog = new FormInputDialog("Type Path", "Path to store file:");

            dialog.InputText = this.CurrentFolder.Path() + "/" + filename;

            var result = dialog.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(dialog.InputText))
            {
                return;
            }

            string path = dialog.InputText;

            try
            {
                var newItemReference = ODConnection.ItemReferenceForDrivePath(path);
                var newItem          = await Connection.PutContentsAsync(newItemReference, stream, ItemUploadOptions.Default);

                AddItemToFolderContents(newItem);
            }
            catch (ODException exception)
            {
                PresentOneDriveException(exception);
            }
        }
        private async void createFolderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormInputDialog dialog = new FormInputDialog("Create Folder", "New folder name:");
            var             result = dialog.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(dialog.InputText))
            {
                string folderName = dialog.InputText;
                await CreateChildFolderInCurrentFolder(folderName);
            }
        }
        private async void fromURLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormInputDialog dialog = new FormInputDialog("Upload from URL", "Type the URL to save to this folder in OneDrive:");
            var             result = dialog.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            Uri remoteUrl = new Uri(dialog.InputText);
            var filename  = System.IO.Path.GetFileName(remoteUrl.AbsolutePath);
            var job       = await Connection.UploadFromUrlAsync(CurrentFolder.ItemReference(), dialog.InputText, filename);

            JobStatusForm.PendingJobs.Add(job);
            ShowJobStatus();
        }
Esempio n. 6
0
        private async void renameSelectedItemToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var itemToRename = this.SelectedItem;

            FormInputDialog dialog = new FormInputDialog("Rename selected item", "New item name");
            dialog.InputText = itemToRename.Name;

            var result = dialog.ShowDialog();
            if (result != System.Windows.Forms.DialogResult.OK)
                return;

            ODItem changes = new ODItem { Name = dialog.InputText };
            try
            {
                var renamedItem = await Connection.PatchItemAsync(itemToRename.ItemReference(), changes);
                UpdateItemInFolderContents(itemToRename, renamedItem);
            }
            catch (ODException ex)
            {
                PresentOneDriveException(ex);
            }
        }
Esempio n. 7
0
        private async void largeFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string filename;
            var stream = GetFileStreamForUpload("Path", out filename);
            if (null == stream)
                return;

            FormInputDialog dialog = new FormInputDialog("Type Path", "Path to store file:");
            dialog.InputText = this.CurrentFolder.Path() + "/" + filename;

            var result = dialog.ShowDialog();
            if (result != System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(dialog.InputText))
            {
                return;
            }

            string path = dialog.InputText;
            try
            {
                var newItemReference = ODConnection.ItemReferenceForDrivePath(path);
                
                FormUploadProgress uploadForm = new FormUploadProgress(filename);
                var uploadOptions = ItemUploadOptions.Default;
                uploadOptions.ProgressReporter = uploadForm.UpdateProgress;

                uploadForm.Show();
                var newItem = await Connection.UploadLargeFileAsync(newItemReference, stream, uploadOptions);
                if (null != newItem)
                {
                    AddItemToFolderContents(newItem);
                }
                uploadForm.Close();
            }
            catch (ODException exception)
            {
                PresentOneDriveException(exception);
            }
        }
Esempio n. 8
0
        private async void searchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormInputDialog dialog = new FormInputDialog("Search", "Search for:");

            var result = dialog.ShowDialog();
            if (result != System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(dialog.InputText))
            {
                return;
            }

            try
            {
                ShowWork(true);
                var results = await Connection.SearchForItemsAsync(ODConnection.ItemReferenceForItemId("root"), dialog.InputText, ItemRetrievalOptions.Default);
                var form = new FormSyncResults(Connection, results);
                form.Show();
            }
            catch (ODException exception)
            {
                PresentOneDriveException(exception);
            }
            ShowWork(false);
        }
Esempio n. 9
0
        private async void fromURLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormInputDialog dialog = new FormInputDialog("Upload from URL", "Type the URL to save to this folder in OneDrive:");
            var result = dialog.ShowDialog();
            if (result != System.Windows.Forms.DialogResult.OK)
                return;

            Uri remoteUrl = new Uri(dialog.InputText);
            var filename = System.IO.Path.GetFileName(remoteUrl.AbsolutePath);
            var job = await Connection.UploadFromUrlAsync(CurrentFolder.ItemReference(), dialog.InputText, filename);
            JobStatusForm.PendingJobs.Add(job);
            ShowJobStatus();
        }
Esempio n. 10
0
 private async void createFolderToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FormInputDialog dialog = new FormInputDialog("Create Folder", "New folder name:");
     var result = dialog.ShowDialog();
     if (result == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(dialog.InputText))
     {
         string folderName = dialog.InputText;
         await CreateChildFolderInCurrentFolder(folderName);
     }
 }