예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        private bool CheckClipboardContents()
        {
            pbClipboard.Visible = txtClipboard.Visible = lbClipboard.Visible = false;

            if (Clipboard.ContainsImage())
            {
                using (Bitmap bmp = ClipboardHelpers.GetImage())
                {
                    if (bmp != null)
                    {
                        ClipboardContentType = EClipboardContentType.Image;
                        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 (Clipboard.ContainsText())
            {
                string text = ClipboardHelpers.GetText();

                if (!string.IsNullOrEmpty(text))
                {
                    ClipboardContentType = EClipboardContentType.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 (Clipboard.ContainsFileDropList())
            {
                string[] files = ClipboardHelpers.GetFileDropList();

                if (files != null && files.Length > 0)
                {
                    ClipboardContentType = EClipboardContentType.Files;
                    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);
        }