mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 09:17:36 +13:00
Code refactoring
This commit is contained in:
parent
e814747957
commit
1031e0b462
4 changed files with 20 additions and 29 deletions
|
@ -239,7 +239,7 @@ private void tsmiImportFile_Click(object sender, EventArgs e)
|
|||
|
||||
private async void tsmiImportURL_Click(object sender, EventArgs e)
|
||||
{
|
||||
string url = InputBox.GetInputText(Resources.ExportImportControl_tsmiImportURL_Click_URL_to_download_settings_from);
|
||||
string url = InputBox.Show(Resources.ExportImportControl_tsmiImportURL_Click_URL_to_download_settings_from);
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
|
|
|
@ -33,19 +33,32 @@ public class InputBox : Form
|
|||
{
|
||||
public string InputText { get; private set; }
|
||||
|
||||
public InputBox(string title = null, string inputText = null, string okText = null, string cancelText = null)
|
||||
private InputBox(string title, string inputText = null, string okText = null, string cancelText = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
ShareXResources.ApplyTheme(this);
|
||||
|
||||
InputText = inputText;
|
||||
|
||||
if (!string.IsNullOrEmpty(title)) Text = title;
|
||||
Text = "ShareX - " + title;
|
||||
if (!string.IsNullOrEmpty(InputText)) txtInputText.Text = InputText;
|
||||
if (!string.IsNullOrEmpty(okText)) btnOK.Text = okText;
|
||||
if (!string.IsNullOrEmpty(cancelText)) btnCancel.Text = cancelText;
|
||||
}
|
||||
|
||||
public static string Show(string title, string inputText = null, string okText = null, string cancelText = null)
|
||||
{
|
||||
using (InputBox form = new InputBox(title, inputText, okText, cancelText))
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
return form.InputText;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void InputBox_Shown(object sender, EventArgs e)
|
||||
{
|
||||
this.ForceActivate();
|
||||
|
@ -69,19 +82,6 @@ private void btnCancel_Click(object sender, EventArgs e)
|
|||
Close();
|
||||
}
|
||||
|
||||
public static string GetInputText(string title = null, string inputText = null, string okText = null, string cancelText = null)
|
||||
{
|
||||
using (InputBox form = new InputBox(title, inputText, okText, cancelText))
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
return form.InputText;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
|
|
@ -24,7 +24,6 @@ You should have received a copy of the GNU General Public License
|
|||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.UploadersLib
|
||||
{
|
||||
|
@ -42,7 +41,7 @@ public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] pa
|
|||
string title = "Input";
|
||||
string defaultText = "";
|
||||
|
||||
if (parameters.Length > 0)
|
||||
if (parameters != null && parameters.Length > 0)
|
||||
{
|
||||
title = parameters[0];
|
||||
|
||||
|
@ -52,15 +51,7 @@ public override string Call(ShareXCustomUploaderSyntaxParser parser, string[] pa
|
|||
}
|
||||
}
|
||||
|
||||
using (InputBox inputBox = new InputBox(title, defaultText))
|
||||
{
|
||||
if (inputBox.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
return inputBox.InputText;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultText;
|
||||
return InputBox.Show(title, defaultText);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -334,7 +334,7 @@ public static void UploadURL(TaskSettings taskSettings = null)
|
|||
inputText = text;
|
||||
}
|
||||
|
||||
string url = InputBox.GetInputText("ShareX - " + Resources.UploadManager_UploadURL_URL_to_download_from_and_upload, inputText);
|
||||
string url = InputBox.Show(Resources.UploadManager_UploadURL_URL_to_download_from_and_upload, inputText);
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
|
@ -355,7 +355,7 @@ public static void ShowShortenURLDialog(TaskSettings taskSettings = null)
|
|||
inputText = text;
|
||||
}
|
||||
|
||||
string url = InputBox.GetInputText("ShareX - " + Resources.UploadManager_ShowShortenURLDialog_ShortenURL, inputText,
|
||||
string url = InputBox.Show(Resources.UploadManager_ShowShortenURLDialog_ShortenURL, inputText,
|
||||
Resources.UploadManager_ShowShortenURLDialog_Shorten);
|
||||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
|
|
Loading…
Reference in a new issue