diff --git a/ShareX.HelpersLib/Forms/InputBox.cs b/ShareX.HelpersLib/Forms/InputBox.cs
index 3a9e57e6a..b970b2f4c 100644
--- a/ShareX.HelpersLib/Forms/InputBox.cs
+++ b/ShareX.HelpersLib/Forms/InputBox.cs
@@ -30,19 +30,19 @@ namespace ShareX.HelpersLib
{
public class InputBox : Form
{
- public string Title { get; set; }
- public string InputText { get; set; }
+ public string InputText { get; private set; }
- public InputBox(string title = null, string inputText = null)
+ public InputBox(string title = null, string inputText = null, string okText = null, string cancelText = null)
{
InitializeComponent();
Icon = ShareXResources.Icon;
- Title = title;
InputText = inputText;
- if (!string.IsNullOrEmpty(Title)) Text = Title;
+ if (!string.IsNullOrEmpty(title)) Text = title;
if (!string.IsNullOrEmpty(InputText)) txtInputText.Text = InputText;
+ if (!string.IsNullOrEmpty(okText)) btnOK.Text = okText;
+ if (!string.IsNullOrEmpty(cancelText)) btnCancel.Text = cancelText;
}
private void InputBox_Shown(object sender, EventArgs e)
@@ -66,9 +66,9 @@ private void btnCancel_Click(object sender, EventArgs e)
Close();
}
- public static string GetInputText(string title = null, string inputText = null)
+ public static string GetInputText(string title = null, string inputText = null, string okText = null, string cancelText = null)
{
- using (InputBox form = new InputBox(title, inputText))
+ using (InputBox form = new InputBox(title, inputText, okText, cancelText))
{
if (form.ShowDialog() == DialogResult.OK)
{
@@ -132,6 +132,7 @@ private void InitializeComponent()
this.MinimizeBox = false;
this.Name = "InputBox";
this.ShowInTaskbar = false;
+ this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.TopMost = true;
this.Shown += new System.EventHandler(this.InputBox_Shown);
this.ResumeLayout(false);
diff --git a/ShareX.HelpersLib/Forms/InputBox.resx b/ShareX.HelpersLib/Forms/InputBox.resx
index 6dd58f6b4..51b4c90f2 100644
--- a/ShareX.HelpersLib/Forms/InputBox.resx
+++ b/ShareX.HelpersLib/Forms/InputBox.resx
@@ -123,10 +123,10 @@
- 208, 32
+ 228, 32
- 72, 24
+ 120, 24
@@ -151,10 +151,10 @@
Top, Right
- 288, 32
+ 356, 32
- 72, 24
+ 120, 24
2
@@ -181,7 +181,7 @@
8, 8
- 352, 20
+ 468, 20
0
@@ -205,7 +205,7 @@
6, 13
- 368, 63
+ 484, 63
1000, 102
diff --git a/ShareX/Forms/MainForm.cs b/ShareX/Forms/MainForm.cs
index df1989099..70faf3bb2 100644
--- a/ShareX/Forms/MainForm.cs
+++ b/ShareX/Forms/MainForm.cs
@@ -1394,7 +1394,7 @@ private void tsbClipboardUpload_Click(object sender, EventArgs e)
private void tsmiUploadText_Click(object sender, EventArgs e)
{
- UploadManager.TextUpload();
+ UploadManager.ShowTextUploadDialog();
}
private void tsmiUploadURL_Click(object sender, EventArgs e)
@@ -1409,6 +1409,7 @@ private void tsbDragDropUpload_Click(object sender, EventArgs e)
private void tsmiShortenURL_Click(object sender, EventArgs e)
{
+ UploadManager.ShowShortenURLDialog();
}
private void tsmiColorPicker_Click(object sender, EventArgs e)
diff --git a/ShareX/Forms/TextUploadForm.Designer.cs b/ShareX/Forms/TextUploadForm.Designer.cs
index 7ba258944..c03fc5ae3 100644
--- a/ShareX/Forms/TextUploadForm.Designer.cs
+++ b/ShareX/Forms/TextUploadForm.Designer.cs
@@ -49,7 +49,7 @@ private void InitializeComponent()
this.btnUpload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnUpload.Location = new System.Drawing.Point(376, 488);
this.btnUpload.Name = "btnUpload";
- this.btnUpload.Size = new System.Drawing.Size(123, 24);
+ this.btnUpload.Size = new System.Drawing.Size(120, 24);
this.btnUpload.TabIndex = 1;
this.btnUpload.Text = "Upload";
this.btnUpload.UseVisualStyleBackColor = true;
@@ -60,7 +60,7 @@ private void InitializeComponent()
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.Location = new System.Drawing.Point(504, 488);
this.btnCancel.Name = "btnCancel";
- this.btnCancel.Size = new System.Drawing.Size(123, 24);
+ this.btnCancel.Size = new System.Drawing.Size(120, 24);
this.btnCancel.TabIndex = 2;
this.btnCancel.Text = "Cancel";
this.btnCancel.UseVisualStyleBackColor = true;
@@ -78,6 +78,7 @@ private void InitializeComponent()
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ShareX - Text upload";
+ this.Shown += new System.EventHandler(this.TextUploadForm_Shown);
this.ResumeLayout(false);
this.PerformLayout();
diff --git a/ShareX/Forms/TextUploadForm.cs b/ShareX/Forms/TextUploadForm.cs
index 9dcc77d45..fadb8ab0c 100644
--- a/ShareX/Forms/TextUploadForm.cs
+++ b/ShareX/Forms/TextUploadForm.cs
@@ -25,12 +25,6 @@ You should have received a copy of the GNU General Public License
using ShareX.HelpersLib;
using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
using System.Windows.Forms;
namespace ShareX
@@ -56,9 +50,15 @@ public TextUploadForm(string content = null)
}
}
+ private void TextUploadForm_Shown(object sender, EventArgs e)
+ {
+ this.ForceActivate();
+ }
+
private void btnUpload_Click(object sender, EventArgs e)
{
Content = txtContent.Text;
+
DialogResult = DialogResult.OK;
Close();
}
diff --git a/ShareX/UploadManager.cs b/ShareX/UploadManager.cs
index e547cd033..387fb6db9 100644
--- a/ShareX/UploadManager.cs
+++ b/ShareX/UploadManager.cs
@@ -245,7 +245,7 @@ public static void ClipboardUploadMainWindow(TaskSettings taskSettings = null)
}
}
- public static void TextUpload(TaskSettings taskSettings = null)
+ public static void ShowTextUploadDialog(TaskSettings taskSettings = null)
{
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
@@ -308,6 +308,30 @@ public static void UploadURL(TaskSettings taskSettings = null)
}
}
+ 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 RunImageTask(Image img, TaskSettings taskSettings, bool skipQuickTaskMenu = false, bool skipAfterCaptureWindow = false)
{
ImageInfo imageInfo = new ImageInfo(img);