コード例 #1
0
ファイル: UploadManager.cs プロジェクト: zyandu/ShareX
        public static void ClipboardUpload(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            if (Clipboard.ContainsImage())
            {
                Image img = ClipboardHelpers.GetImage();

                ProcessImageUpload(img, taskSettings);
            }
            else if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                ProcessTextUpload(text, taskSettings);
            }
            else if (Clipboard.ContainsFileDropList())
            {
                string[] files = Clipboard.GetFileDropList().OfType <string>().ToArray();

                ProcessFilesUpload(files, taskSettings);
            }
        }
コード例 #2
0
ファイル: TaskHelpers.cs プロジェクト: RavenZZ/ShareX
        public static void OpenImageEditor(string filePath = null)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                if (Clipboard.ContainsImage() &&
                    MessageBox.Show(Resources.TaskHelpers_OpenImageEditor_Your_clipboard_contains_image,
                                    Resources.TaskHelpers_OpenImageEditor_Image_editor___How_to_load_image_, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    using (Image img = ClipboardHelpers.GetImage())
                    {
                        if (img != null)
                        {
                            AnnotateImage(img, null);
                            return;
                        }
                    }
                }

                filePath = ImageHelpers.OpenImageFileDialog();
            }

            if (!string.IsNullOrEmpty(filePath))
            {
                AnnotateImage(filePath);
            }
        }
コード例 #3
0
ファイル: EditorStartupForm.cs プロジェクト: zz110/ShareX
        private void btnLoadImageFromClipboard_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsImage())
            {
                Image = ClipboardHelpers.GetImage();

                if (Image != null)
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
            else if (Clipboard.ContainsFileDropList())
            {
                string[] files = Clipboard.GetFileDropList().OfType <string>().Where(x => Helpers.IsImageFile(x)).ToArray();

                if (files.Length > 0)
                {
                    LoadImageFile(files[0]);
                }
            }
            else
            {
                MessageBox.Show(Resources.EditorStartupForm_ClipboardDoesNotContainAnImage, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #4
0
        private void PasteFromClipboard()
        {
            if (Clipboard.ContainsImage())
            {
                Image img = ClipboardHelpers.GetImage();

                if (img != null)
                {
                    CurrentShapeType = ShapeType.DrawingImage;
                    ImageDrawingShape shape = (ImageDrawingShape)CreateShape(ShapeType.DrawingImage);
                    shape.StartPosition = shape.EndPosition = InputManager.MousePosition0Based;
                    shape.SetImage(img, true);
                    AddShape(shape);
                    SelectCurrentShape();
                }
            }
            else if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (!string.IsNullOrEmpty(text))
                {
                    CurrentShapeType = ShapeType.DrawingTextBackground;
                    TextDrawingShape shape = (TextDrawingShape)CreateShape(ShapeType.DrawingTextBackground);
                    shape.StartPosition = shape.EndPosition = InputManager.MousePosition0Based;
                    shape.Text          = text.Trim();
                    shape.AutoSize(true);
                    AddShape(shape);
                    SelectCurrentShape();
                }
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
0
ファイル: TaskHelpers.cs プロジェクト: marcthomas/ShareX
        public static void AnnotateImage(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            if (Clipboard.ContainsImage() && MessageBox.Show(Resources.TaskHelpers_OpenImageEditor_Your_clipboard_contains_image,
                                                             Resources.TaskHelpers_OpenImageEditor_Image_editor___How_to_load_image_, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                using (Image img = ClipboardHelpers.GetImage())
                {
                    if (img != null)
                    {
                        if (taskSettings.AdvancedSettings.UseShareXForAnnotation)
                        {
                            AnnotateImageUsingShareX(img, null, taskSettings);
                        }
                        else
                        {
                            AnnotateImageUsingGreenshot(img, null);
                        }

                        return;
                    }
                }
            }

            string filePath = ImageHelpers.OpenImageFileDialog();

            AnnotateImage(filePath, taskSettings);
        }
コード例 #7
0
ファイル: EditorStartupForm.cs プロジェクト: McoreD/ShareX
        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);
            }
        }
コード例 #8
0
        private void PasteFromClipboard()
        {
            if (Clipboard.ContainsImage())
            {
                Image img = ClipboardHelpers.GetImage();

                if (img != null)
                {
                    CurrentTool = ShapeType.DrawingImage;
                    ImageDrawingShape shape = (ImageDrawingShape)CreateShape(ShapeType.DrawingImage);
                    Point             pos   = InputManager.ClientMousePosition;
                    shape.Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
                    shape.SetImage(img, true);
                    AddShape(shape);
                    SelectCurrentShape();
                }
            }
            else if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (!string.IsNullOrEmpty(text))
                {
                    CurrentTool = ShapeType.DrawingTextBackground;
                    TextDrawingShape shape = (TextDrawingShape)CreateShape(ShapeType.DrawingTextBackground);
                    Point            pos   = InputManager.ClientMousePosition;
                    shape.Rectangle = new Rectangle(pos.X, pos.Y, 1, 1);
                    shape.Text      = text.Trim();
                    shape.AutoSize(true);
                    AddShape(shape);
                    SelectCurrentShape();
                }
            }
        }
コード例 #9
0
ファイル: ClipboardUploadForm.cs プロジェクト: huruiyi/ShareX
        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);
        }
コード例 #10
0
        private void tsmiLoadImageFromClipboard_Click(object sender, EventArgs e)
        {
            Image img = ClipboardHelpers.GetImage();

            if (img != null)
            {
                if (DefaultImage != null)
                {
                    DefaultImage.Dispose();
                }
                DefaultImage = img;
                UpdatePreview();
            }
        }
コード例 #11
0
ファイル: ImageEffectsForm.cs プロジェクト: lmeeng/ShareX
        private void tsmiLoadImageFromClipboard_Click(object sender, EventArgs e)
        {
            Bitmap bmp = ClipboardHelpers.GetImage();

            if (bmp != null)
            {
                if (PreviewImage != null)
                {
                    PreviewImage.Dispose();
                }
                PreviewImage = bmp;
                FilePath     = null;
                UpdatePreview();
            }
        }
コード例 #12
0
ファイル: MainForm.cs プロジェクト: yj490732088/Dithering
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap image;

            image = ClipboardHelpers.GetImage();

            if (image == null)
            {
                SystemSounds.Exclamation.Play();
            }
            else
            {
                this.OpenImage(image);
            }
        }
コード例 #13
0
        private void btnLoadImageFromClipboard_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsImage())
            {
                Image = ClipboardHelpers.GetImage();

                if (Image != null)
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Clipboard does not contains an image.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #14
0
        private void btnLoadImageFromClipboard_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsImage())
            {
                Image = ClipboardHelpers.GetImage();

                if (Image != null)
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
            else
            {
                MessageBox.Show(Resources.EditorStartupForm_ClipboardDoesNotContainAnImage, "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #15
0
ファイル: UploadManager.cs プロジェクト: yuqi-sy/ShareX
        public static void ClipboardUpload(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            if (Clipboard.ContainsImage())
            {
                Image img = ClipboardHelpers.GetImage();

                if (img != null)
                {
                    if (!taskSettings.AdvancedSettings.ProcessImagesDuringClipboardUpload)
                    {
                        taskSettings.AfterCaptureJob = AfterCaptureTasks.UploadImageToHost;
                    }

                    RunImageTask(img, taskSettings);
                }
            }
            else if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (!string.IsNullOrEmpty(text))
                {
                    string url = text.Trim();

                    if (URLHelpers.IsValidURL(url))
                    {
                        if (taskSettings.UploadSettings.ClipboardUploadURLContents)
                        {
                            DownloadAndUploadFile(url, taskSettings);
                            return;
                        }

                        if (taskSettings.UploadSettings.ClipboardUploadShortenURL)
                        {
                            ShortenURL(url, taskSettings);
                            return;
                        }

                        if (taskSettings.UploadSettings.ClipboardUploadShareURL)
                        {
                            ShareURL(url, taskSettings);
                            return;
                        }
                    }

                    if (taskSettings.UploadSettings.ClipboardUploadAutoIndexFolder && text.Length <= 260 && Directory.Exists(text))
                    {
                        IndexFolder(text, taskSettings);
                    }
                    else
                    {
                        UploadText(text, taskSettings, true);
                    }
                }
            }
            else if (Clipboard.ContainsFileDropList())
            {
                string[] files = Clipboard.GetFileDropList().OfType <string>().ToArray();

                if (files.Length > 0)
                {
                    UploadFile(files, taskSettings);
                }
            }
        }