Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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 = ClipboardHelpers.GetText();

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

                ProcessFilesUpload(files, taskSettings);
            }
        }
Exemplo n.º 3
0
        public static QRCodeForm EncodeClipboard()
        {
            string text = ClipboardHelpers.GetText(true);

            if (!string.IsNullOrEmpty(text) && TaskHelpers.CheckQRCodeContent(text))
            {
                return(new QRCodeForm(text));
            }

            return(new QRCodeForm());
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public TextUploadForm(string content = null)
        {
            InitializeComponent();
            ShareXResources.ApplyTheme(this);

            if (string.IsNullOrEmpty(content) && Clipboard.ContainsText())
            {
                content = ClipboardHelpers.GetText();
            }

            if (!string.IsNullOrEmpty(content))
            {
                txtContent.Text = content;
                txtContent.SelectAll();
            }
        }
Exemplo n.º 6
0
        public static void ShowScreenColorPickerDialog(RegionCaptureOptions options, bool checkClipboard = true)
        {
            Color color = Color.Red;

            if (checkClipboard)
            {
                string text = ClipboardHelpers.GetText(true);

                if (!string.IsNullOrEmpty(text) && ColorHelpers.ParseColor(text, out Color clipboardColor))
                {
                    color = clipboardColor;
                }
            }

            ColorPickerForm colorPickerForm = new ColorPickerForm(color, true);

            colorPickerForm.EnableScreenColorPickerButton(() => GetPointInfo(options));
            colorPickerForm.Show();
        }
Exemplo n.º 7
0
        public static void UploadURL(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            string inputText = null;

            string text = ClipboardHelpers.GetText(true);

            if (URLHelpers.IsValidURL(text))
            {
                inputText = text;
            }

            string url = InputBox.GetInputText("ShareX - " + Resources.UploadManager_UploadURL_URL_to_download_from_and_upload, inputText);

            if (!string.IsNullOrEmpty(url))
            {
                DownloadAndUploadFile(url, taskSettings);
            }
        }
Exemplo n.º 8
0
        public static void ShowShortenURLDialog(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            string inputText = null;

            string text = ClipboardHelpers.GetText(true);

            if (URLHelpers.IsValidURL(text))
            {
                inputText = text;
            }

            string url = InputBox.GetInputText("ShareX - " + ShareX.Properties.Resources.UploadManager_ShowShortenURLDialog_ShortenURL, inputText, ShareX.Properties.Resources.UploadManager_ShowShortenURLDialog_Shorten);

            if (!string.IsNullOrEmpty(url))
            {
                ShortenURL(url, taskSettings);
            }
        }