Added $input$ and $input:default value$ syntax to custom uploader parser

This commit is contained in:
Jaex 2018-10-09 14:25:27 +03:00
parent 472f885b41
commit ab6d3af1ad

View file

@ -31,6 +31,7 @@ You should have received a copy of the GNU General Public License
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml.XPath; using System.Xml.XPath;
namespace ShareX.UploadersLib namespace ShareX.UploadersLib
@ -152,6 +153,14 @@ private string ParseSyntax(string syntax)
{ {
return ParseSyntaxSelect(syntax.Substring(7)); return ParseSyntaxSelect(syntax.Substring(7));
} }
else if (syntax.Equals("input", StringComparison.InvariantCultureIgnoreCase)) // Example: $input$
{
return ParseSyntaxInput();
}
else if (syntax.StartsWith("input:", StringComparison.InvariantCultureIgnoreCase)) // Example: $input:default value$
{
return ParseSyntaxInput(syntax.Substring(6));
}
// Invalid syntax // Invalid syntax
return null; return null;
@ -271,5 +280,18 @@ private string ParseSyntaxSelect(string syntax)
return null; return null;
} }
private string ParseSyntaxInput(string defaultValue = null)
{
using (InputBox inputBox = new InputBox("ShareX - Input", defaultValue))
{
if (inputBox.ShowDialog() == DialogResult.OK)
{
return inputBox.InputText;
}
}
return defaultValue;
}
} }
} }