mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Allow creating empty text box
This commit is contained in:
parent
21ef3a4d1a
commit
255f9f99e2
1 changed files with 19 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue