Allow creating empty text box

This commit is contained in:
Jaex 2017-10-30 10:43:21 +03:00
parent 21ef3a4d1a
commit 255f9f99e2

View file

@ -26,6 +26,7 @@ You should have received a copy of the GNU General Public License
using ShareX.HelpersLib;
using System.Drawing;
using System.Drawing.Text;
using System.Windows.Forms;
namespace ShareX.ScreenCaptureLib
{
@ -96,15 +97,13 @@ public override void OnCreating()
{
StartPosition = EndPosition = InputManager.MousePosition0Based;
ShowTextInputBox();
if (string.IsNullOrEmpty(Text))
if (ShowTextInputBox())
{
Remove();
OnCreated();
}
else
{
OnCreated();
Remove();
}
}
@ -119,27 +118,38 @@ public override void OnDoubleClicked()
ShowTextInputBox();
}
private void ShowTextInputBox()
private bool ShowTextInputBox()
{
bool result;
Manager.PauseForm();
using (TextDrawingInputBox inputBox = new TextDrawingInputBox(Text, TextOptions))
{
inputBox.ShowDialog();
result = inputBox.ShowDialog() == DialogResult.OK;
Text = inputBox.InputText;
OnConfigSave();
}
Manager.ResumeForm();
return result;
}
public void AutoSize(bool center)
{
Size size;
using (Font font = new Font(TextOptions.Font, TextOptions.Size, TextOptions.Style))
if (!string.IsNullOrEmpty(Text))
{
size = Helpers.MeasureText(Text, font).Offset(15, 20);
using (Font font = new Font(TextOptions.Font, TextOptions.Size, TextOptions.Style))
{
size = Helpers.MeasureText(Text, font).Offset(15, 20);
}
}
else
{
size = new Size(100, 60);
}
Point location;