private void btnLoadImageFromClipboard_Click(object sender, EventArgs e) { if (ClipboardHelpers.ContainsImage()) { Image = ClipboardHelpers.GetImage(); if (Image != null) { DialogResult = DialogResult.OK; Close(); } } else if (ClipboardHelpers.ContainsFileDropList()) { string[] files = ClipboardHelpers.GetFileDropList(); if (files != null) { string imageFilePath = files.FirstOrDefault(x => FileHelpers.IsImageFile(x)); LoadImageFile(imageFilePath); } } else { MessageBox.Show(Resources.EditorStartupForm_ClipboardDoesNotContainAnImage, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
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); }