public static void ShowShortenURLDialog(TaskSettings taskSettings = null) { if (taskSettings == null) { taskSettings = TaskSettings.GetDefaultTaskSettings(); } string inputText = null; if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); 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); } }
public void AddNewsItem(NewsItem item) { int index = dgvNews.Rows.Add(); DataGridViewRow row = dgvNews.Rows[index]; row.Tag = item; row.Cells[1].Value = item.DateTime.ToShortDateString(); string dateTimeTooltip; double days = (DateTime.Now - item.DateTime).TotalDays; if (days < 1) { dateTimeTooltip = "Today."; } else if (days < 2) { dateTimeTooltip = "Yesterday."; } else { dateTimeTooltip = (int)days + " days ago."; } row.Cells[1].ToolTipText = dateTimeTooltip; row.Cells[2].Value = item.Text; if (URLHelpers.IsValidURL(item.URL)) { row.Cells[2].ToolTipText = item.URL; } }
public static void ShowShortenURLDialog(TaskSettings taskSettings = null) { if (taskSettings == null) { taskSettings = TaskSettings.GetDefaultTaskSettings(); } string inputText = null; if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); if (URLHelpers.IsValidURL(text)) { inputText = text; } } string url = InputBox.GetInputText("ShareX - " + "Shorten URL", inputText, "Shorten"); if (!string.IsNullOrEmpty(url)) { ShortenURL(url, taskSettings); } }
public static void UploadURL(TaskSettings taskSettings = null) { if (taskSettings == null) { taskSettings = TaskSettings.GetDefaultTaskSettings(); } string inputText = null; if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); 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); } }
private void B2UpdateCustomDomainPreview() { string uploadPath = NameParser.Parse(NameParserType.FolderPath, Config.B2UploadPath); if (cbB2CustomUrl.Checked) { string customUrl = NameParser.Parse(NameParserType.FolderPath, Config.B2CustomUrl); if (URLHelpers.IsValidURL(customUrl)) { txtB2UrlPreview.Text = customUrl + uploadPath + "example.png"; } else { txtB2UrlPreview.Text = "invalid custom URL"; } } else { string bucket = string.IsNullOrEmpty(Config.B2BucketName) ? "[bucket]" : URLHelpers.URLEncode(Config.B2BucketName); string url = $"https://f001.backblazeb2.com/file/{bucket}/{uploadPath}example.png"; txtB2UrlPreview.Text = url; } }
public async Task UseCommandLineArgs(List <CLICommand> commands) { TaskSettings taskSettings = FindCLITask(commands); foreach (CLICommand command in commands) { DebugHelper.WriteLine("CommandLine: " + command); if (command.IsCommand) { if (CheckCustomUploader(command) || CheckImageEffect(command) || await CheckCLIHotkey(command) || await CheckCLIWorkflow(command) || CheckNativeMessagingInput(command)) { } continue; } if (URLHelpers.IsValidURL(command.Command)) { UploadManager.DownloadAndUploadFile(command.Command, taskSettings); } else { UploadManager.UploadFile(command.Command, taskSettings); } } }
private void dgvNews_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Left && e.ColumnIndex == 2) { DataGridViewRow row = dgvNews.Rows[e.RowIndex]; NewsItem newsItem = row.Tag as NewsItem; if (newsItem != null && URLHelpers.IsValidURL(newsItem.URL)) { URLHelpers.OpenURL(newsItem.URL); } } }
private void CheckClipboardURL() { if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); if (URLHelpers.IsValidURL(text)) { txtURL.Text = text; } } }
public override UploadResult UploadText(string text, string fileName) { UploadResult ur = new UploadResult(); if (!string.IsNullOrEmpty(text) && Settings != null) { Dictionary <string, string> args = new Dictionary <string, string>(); args.Add("api_dev_key", APIKey); // which is your unique API Developers Key args.Add("api_option", "paste"); // set as 'paste', this will indicate you want to create a new paste args.Add("api_paste_code", text); // this is the text that will be written inside your paste // Optional args args.Add("api_paste_name", Settings.Title); // this will be the name / title of your paste args.Add("api_paste_format", Settings.TextFormat); // this will be the syntax highlighting value args.Add("api_paste_private", GetPrivacy(Settings.Exposure)); // this makes a paste public or private, public = 0, private = 1 args.Add("api_paste_expire_date", GetExpiration(Settings.Expiration)); // this sets the expiration date of your paste if (!string.IsNullOrEmpty(Settings.UserKey)) { args.Add("api_user_key", Settings.UserKey); // this paramater is part of the login system } ur.Response = SendRequestMultiPart("https://pastebin.com/api/api_post.php", args); if (URLHelpers.IsValidURL(ur.Response)) { if (Settings.RawURL) { string id = URLHelpers.GetFileName(ur.Response); ur.URL = "https://pastebin.com/raw/" + id; } else { ur.URL = ur.Response; } } else { Errors.Add(ur.Response); } } return(ur); }
public QRCodeForm(string text = null) { InitializeComponent(); Icon = ShareXResources.Icon; if (!string.IsNullOrEmpty(text)) { txtQRCode.Text = text; } else { if (Clipboard.ContainsText()) { text = Clipboard.GetText(); if (URLHelpers.IsValidURL(text)) { txtQRCode.Text = text; } } } }
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 (URLHelpers.IsValidURL(text)) { txtQRCode.Text = text; } else { SetDefaultText(); } } else { SetDefaultText(); } txtQRCode.SelectAll(); } }
private static void ProcessTextUpload(string text, TaskSettings taskSettings) { 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); } } }
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); } } }
public void AddNewsItem(NewsItem item) { RowStyle style = new RowStyle(SizeType.AutoSize); tlpMain.RowStyles.Add(style); int index = tlpMain.RowCount++ - 1; Label lblDateTime = new Label() { Anchor = AnchorStyles.Left | AnchorStyles.Right, AutoSize = true, BackColor = Color.Transparent, Font = new Font("Arial", 10), Margin = new Padding(0), Padding = new Padding(10, 8, 5, 8), Text = item.DateTime.ToShortDateString() }; string dateTimeTooltip; double days = (DateTime.Now - item.DateTime).TotalDays; if (days < 1) { dateTimeTooltip = "Today."; } else if (days < 2) { dateTimeTooltip = "Yesterday."; } else { dateTimeTooltip = (int)days + " days ago."; } tooltip.SetToolTip(lblDateTime, dateTimeTooltip); tlpMain.Controls.Add(lblDateTime, 0, index); Label lblText = new Label() { Anchor = AnchorStyles.Left | AnchorStyles.Right, AutoSize = true, BackColor = Color.Transparent, Font = new Font("Arial", 10), Margin = new Padding(0), Padding = new Padding(5, 8, 5, 8), Text = item.Text }; if (URLHelpers.IsValidURL(item.URL)) { tooltip.SetToolTip(lblText, item.URL); lblText.Cursor = Cursors.Hand; lblText.MouseEnter += (sender, e) => lblText.ForeColor = Color.Blue; lblText.MouseLeave += (sender, e) => lblText.ForeColor = SystemColors.ControlText; lblText.MouseClick += (sender, e) => { if (e.Button == MouseButtons.Left) { URLHelpers.OpenURL(item.URL); } }; } tlpMain.Controls.Add(lblText, 1, index); }