/// <summary> /// Import data from the clipboard to upload. /// </summary> private void ButtonImport(object sender, EventArgs e) { if (Clipboard.ContainsFileDropList()) { StringCollection files = Clipboard.GetFileDropList(); Uploader.Upload((from string file in files select new UploadFile { Path = file }).ToArray()); } else if (Clipboard.ContainsImage()) { Uploader.UploadImage(Clipboard.GetImage()); } else if (Clipboard.ContainsText()) { Uploader.UploadText(Clipboard.GetText()); } else { IDataObject dataObject = Clipboard.GetDataObject(); if (dataObject != null) { Misc.HandleError(new ArgumentException(String.Format(Resources.CannotHandleContentTypes, String.Join(",", dataObject.GetFormats()))), Resources.Import); } else { Misc.HandleError(new ArgumentException(Resources.UnsupportedData), Resources.Import); } } }
/// <summary> /// Select file(s) to upload. /// </summary> private void ButtonFile(object sender, EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { Uploader.Upload(openFileDialog.FileNames.Select(fileName => new UploadFile { Path = fileName }).ToArray()); } }