public static void ClipboardUpload(TaskSettings taskSettings = null) { if (taskSettings == null) { taskSettings = TaskSettings.GetDefaultTaskSettings(); } if (ClipboardHelpers.ContainsImage()) { Bitmap bmp = ClipboardHelpers.GetImage(); ProcessImageUpload(bmp, taskSettings); } else if (ClipboardHelpers.ContainsText()) { string text = ClipboardHelpers.GetText(); ProcessTextUpload(text, taskSettings); } else if (ClipboardHelpers.ContainsFileDropList()) { string[] files = ClipboardHelpers.GetFileDropList(); ProcessFilesUpload(files, taskSettings); } }
private bool CheckClipboardContent() { pbClipboard.Visible = txtClipboard.Visible = lbClipboard.Visible = false; if (ClipboardHelpers.ContainsImage()) { using (Bitmap bmp = ClipboardHelpers.GetImage()) { if (bmp != null) { ClipboardContent = bmp.Clone(); pbClipboard.LoadImage(bmp); pbClipboard.Visible = true; lblQuestion.Text = string.Format(Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_content__Image__Size___0_x_1__, bmp.Width, bmp.Height); return(true); } } } else if (ClipboardHelpers.ContainsText()) { string text = ClipboardHelpers.GetText(); if (!string.IsNullOrEmpty(text)) { ClipboardContent = text; txtClipboard.Text = text; txtClipboard.Visible = true; lblQuestion.Text = string.Format(Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_content__Text__Length___0__, text.Length); return(true); } } else if (ClipboardHelpers.ContainsFileDropList()) { string[] files = ClipboardHelpers.GetFileDropList(); if (files != null && files.Length > 0) { ClipboardContent = files; lbClipboard.Items.AddRange(files); lbClipboard.Visible = true; lblQuestion.Text = string.Format(Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_content__File__Count___0__, files.Length); return(true); } } lblQuestion.Text = Resources.ClipboardContentViewer_ClipboardContentViewer_Load_Clipboard_is_empty_or_contains_unknown_data_; return(false); }
public TextUploadForm(string content = null) { InitializeComponent(); ShareXResources.ApplyTheme(this); if (string.IsNullOrEmpty(content) && ClipboardHelpers.ContainsText()) { content = ClipboardHelpers.GetText(); } if (!string.IsNullOrEmpty(content)) { txtContent.Text = content; txtContent.SelectAll(); } }
private void ThreadDoWork() { CreateTaskReferenceHelper(); try { StopRequested = !DoThreadJob(); OnImageReady(); if (!StopRequested) { if (Info.IsUploadJob && TaskHelpers.IsUploadAllowed()) { DoUploadJob(); } else { Info.Result.IsURLExpected = false; } } } finally { KeepImage = Image != null && Info.TaskSettings.GeneralSettings.ShowToastNotificationAfterTaskCompleted; Dispose(); if (EarlyURLCopied && (StopRequested || Info.Result == null || string.IsNullOrEmpty(Info.Result.URL)) && ClipboardHelpers.ContainsText()) { ClipboardHelpers.Clear(); } if ((Info.Job == TaskJob.Job || (Info.Job == TaskJob.FileUpload && Info.TaskSettings.AdvancedSettings.UseAfterCaptureTasksDuringFileUpload)) && Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.DeleteFile) && !string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath)) { File.Delete(Info.FilePath); } } if (!StopRequested && Info.Result != null && Info.Result.IsURLExpected && !Info.Result.IsError) { if (string.IsNullOrEmpty(Info.Result.URL)) { AddErrorMessage(Resources.UploadTask_ThreadDoWork_URL_is_empty_); } else { DoAfterUploadJobs(); } } }