mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added Shorten URL dialog to upload menu
This commit is contained in:
parent
d63b1f3419
commit
a38f720698
6 changed files with 50 additions and 23 deletions
|
@ -30,19 +30,19 @@ namespace ShareX.HelpersLib
|
||||||
{
|
{
|
||||||
public class InputBox : Form
|
public class InputBox : Form
|
||||||
{
|
{
|
||||||
public string Title { get; set; }
|
public string InputText { get; private set; }
|
||||||
public string InputText { get; set; }
|
|
||||||
|
|
||||||
public InputBox(string title = null, string inputText = null)
|
public InputBox(string title = null, string inputText = null, string okText = null, string cancelText = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Icon = ShareXResources.Icon;
|
Icon = ShareXResources.Icon;
|
||||||
|
|
||||||
Title = title;
|
|
||||||
InputText = inputText;
|
InputText = inputText;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Title)) Text = Title;
|
if (!string.IsNullOrEmpty(title)) Text = title;
|
||||||
if (!string.IsNullOrEmpty(InputText)) txtInputText.Text = InputText;
|
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)
|
private void InputBox_Shown(object sender, EventArgs e)
|
||||||
|
@ -66,9 +66,9 @@ private void btnCancel_Click(object sender, EventArgs e)
|
||||||
Close();
|
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)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
@ -132,6 +132,7 @@ private void InitializeComponent()
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "InputBox";
|
this.Name = "InputBox";
|
||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
this.Shown += new System.EventHandler(this.InputBox_Shown);
|
this.Shown += new System.EventHandler(this.InputBox_Shown);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
|
@ -123,10 +123,10 @@
|
||||||
</data>
|
</data>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="btnOK.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="btnOK.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>208, 32</value>
|
<value>228, 32</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="btnOK.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="btnOK.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>72, 24</value>
|
<value>120, 24</value>
|
||||||
</data>
|
</data>
|
||||||
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
<data name="btnOK.TabIndex" type="System.Int32, mscorlib">
|
<data name="btnOK.TabIndex" type="System.Int32, mscorlib">
|
||||||
|
@ -151,10 +151,10 @@
|
||||||
<value>Top, Right</value>
|
<value>Top, Right</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
|
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
|
||||||
<value>288, 32</value>
|
<value>356, 32</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>72, 24</value>
|
<value>120, 24</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="btnCancel.TabIndex" type="System.Int32, mscorlib">
|
<data name="btnCancel.TabIndex" type="System.Int32, mscorlib">
|
||||||
<value>2</value>
|
<value>2</value>
|
||||||
|
@ -181,7 +181,7 @@
|
||||||
<value>8, 8</value>
|
<value>8, 8</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="txtInputText.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="txtInputText.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>352, 20</value>
|
<value>468, 20</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="txtInputText.TabIndex" type="System.Int32, mscorlib">
|
<data name="txtInputText.TabIndex" type="System.Int32, mscorlib">
|
||||||
<value>0</value>
|
<value>0</value>
|
||||||
|
@ -205,7 +205,7 @@
|
||||||
<value>6, 13</value>
|
<value>6, 13</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>368, 63</value>
|
<value>484, 63</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="$this.MaximumSize" type="System.Drawing.Size, System.Drawing">
|
<data name="$this.MaximumSize" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>1000, 102</value>
|
<value>1000, 102</value>
|
||||||
|
|
|
@ -1394,7 +1394,7 @@ private void tsbClipboardUpload_Click(object sender, EventArgs e)
|
||||||
|
|
||||||
private void tsmiUploadText_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)
|
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)
|
private void tsmiShortenURL_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
UploadManager.ShowShortenURLDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tsmiColorPicker_Click(object sender, EventArgs e)
|
private void tsmiColorPicker_Click(object sender, EventArgs e)
|
||||||
|
|
5
ShareX/Forms/TextUploadForm.Designer.cs
generated
5
ShareX/Forms/TextUploadForm.Designer.cs
generated
|
@ -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.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.Location = new System.Drawing.Point(376, 488);
|
||||||
this.btnUpload.Name = "btnUpload";
|
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.TabIndex = 1;
|
||||||
this.btnUpload.Text = "Upload";
|
this.btnUpload.Text = "Upload";
|
||||||
this.btnUpload.UseVisualStyleBackColor = true;
|
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.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.Location = new System.Drawing.Point(504, 488);
|
||||||
this.btnCancel.Name = "btnCancel";
|
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.TabIndex = 2;
|
||||||
this.btnCancel.Text = "Cancel";
|
this.btnCancel.Text = "Cancel";
|
||||||
this.btnCancel.UseVisualStyleBackColor = true;
|
this.btnCancel.UseVisualStyleBackColor = true;
|
||||||
|
@ -78,6 +78,7 @@ private void InitializeComponent()
|
||||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||||
this.Text = "ShareX - Text upload";
|
this.Text = "ShareX - Text upload";
|
||||||
|
this.Shown += new System.EventHandler(this.TextUploadForm_Shown);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,6 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
using ShareX.HelpersLib;
|
||||||
using System;
|
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;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace ShareX
|
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)
|
private void btnUpload_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Content = txtContent.Text;
|
Content = txtContent.Text;
|
||||||
|
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
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)
|
public static void RunImageTask(Image img, TaskSettings taskSettings, bool skipQuickTaskMenu = false, bool skipAfterCaptureWindow = false)
|
||||||
{
|
{
|
||||||
ImageInfo imageInfo = new ImageInfo(img);
|
ImageInfo imageInfo = new ImageInfo(img);
|
||||||
|
|
Loading…
Reference in a new issue