示例#1
0
        public static void UploadURL(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

            string inputText = null;

            if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (!string.IsNullOrEmpty(text) && URLHelpers.IsValidURLRegex(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);
            }
        }
示例#2
0
        private void CheckClipboard()
        {
            if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

                if (!string.IsNullOrEmpty(text) && URLHelpers.IsValidURLRegex(text))
                {
                    txtURL.Text = text;
                }
            }
        }
示例#3
0
        public QRCodeForm(string text = null)
        {
            InitializeComponent();
            Icon       = ShareXResources.Icon;
            ClientSize = new Size(400, 400);

            if (!string.IsNullOrEmpty(text))
            {
                qrMain.Dock   = DockStyle.Fill;
                qrMain.Cursor = Cursors.Hand;
                Text         += ": " + text;
                qrMain.Text   = text;
            }
            else
            {
                EditMode          = true;
                txtQRCode.Visible = true;

                if (Clipboard.ContainsText())
                {
                    text = Clipboard.GetText();

                    if (!string.IsNullOrEmpty(text) && URLHelpers.IsValidURLRegex(text))
                    {
                        txtQRCode.Text = text;
                    }
                    else
                    {
                        SetDefaultText();
                    }
                }
                else
                {
                    SetDefaultText();
                }

                txtQRCode.SelectAll();
            }
        }
示例#4
0
        public static void ClipboardUpload(TaskSettings taskSettings = null)
        {
            if (taskSettings == null)
            {
                taskSettings = TaskSettings.GetDefaultTaskSettings();
            }

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

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

                    RunImageTask(img, taskSettings);
                }
            }
            else if (Clipboard.ContainsFileDropList())
            {
                string[] files = Clipboard.GetFileDropList().Cast <string>().ToArray();
                UploadFile(files, taskSettings);
            }
            else if (Clipboard.ContainsText())
            {
                string text = Clipboard.GetText();

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

                    if (URLHelpers.IsValidURLRegex(url))
                    {
                        if (taskSettings.UploadSettings.ClipboardUploadURLContents)
                        {
                            string filename = URLHelpers.GetFileName(url, true);

                            if (!string.IsNullOrEmpty(filename))
                            {
                                DownloadAndUploadFile(url, filename, 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);
                    }
                }
            }
        }