Пример #1
0
        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
        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
        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
        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
        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
        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
        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
        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
        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);
                }
            }
        }