diff --git a/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.Designer.cs b/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.Designer.cs index 0c66626ba..e0fc0db59 100644 --- a/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.Designer.cs +++ b/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.Designer.cs @@ -52,6 +52,7 @@ private void InitializeComponent() this.tsmiAlignmentMiddle = new System.Windows.Forms.ToolStripMenuItem(); this.tsmiAlignmentBottom = new System.Windows.Forms.ToolStripMenuItem(); this.lblTip = new System.Windows.Forms.Label(); + this.btnCancel = new System.Windows.Forms.Button(); this.flpProperties.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudTextSize)).BeginInit(); this.cmsAlignmentHorizontal.SuspendLayout(); @@ -63,7 +64,6 @@ private void InitializeComponent() resources.ApplyResources(this.txtInput, "txtInput"); this.txtInput.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.txtInput.Name = "txtInput"; - this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged); this.txtInput.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyDown); this.txtInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyUp); // @@ -169,7 +169,7 @@ private void InitializeComponent() resources.ApplyResources(this.btnOK, "btnOK"); this.btnOK.Name = "btnOK"; this.btnOK.UseVisualStyleBackColor = true; - this.btnOK.Click += new System.EventHandler(this.btnClose_Click); + this.btnOK.Click += new System.EventHandler(this.btnOK_Click); // // cmsAlignmentHorizontal // @@ -236,11 +236,19 @@ private void InitializeComponent() resources.ApplyResources(this.lblTip, "lblTip"); this.lblTip.Name = "lblTip"; // + // btnCancel + // + resources.ApplyResources(this.btnCancel, "btnCancel"); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // // TextDrawingInputBox // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Window; + this.Controls.Add(this.btnCancel); this.Controls.Add(this.lblTip); this.Controls.Add(this.btnOK); this.Controls.Add(this.flpProperties); @@ -285,5 +293,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem tsmiAlignmentMiddle; private System.Windows.Forms.ToolStripMenuItem tsmiAlignmentBottom; private System.Windows.Forms.Label lblTip; + private System.Windows.Forms.Button btnCancel; } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.cs b/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.cs index be4ee0542..62a7ba30f 100644 --- a/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.cs +++ b/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.cs @@ -73,6 +73,18 @@ public TextDrawingInputBox(string text, TextDrawingOptions options) UpdateVerticalAlignmentImage(); } + private void Close(DialogResult result) + { + DialogResult = result; + + if (result == DialogResult.OK) + { + InputText = txtInput.Text; + } + + Close(); + } + private void TextDrawingInputBox_Shown(object sender, EventArgs e) { this.ForceActivate(); @@ -165,7 +177,7 @@ private void tsmiAlignmentBottom_Click(object sender, EventArgs e) private void txtInput_KeyDown(object sender, KeyEventArgs e) { - if (e.KeyData == Keys.Enter) + if (e.KeyData == Keys.Enter || e.KeyData == Keys.Escape) { e.SuppressKeyPress = true; } @@ -175,18 +187,22 @@ private void txtInput_KeyUp(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { - Close(); + Close(DialogResult.OK); + } + else if (e.KeyData == Keys.Escape) + { + Close(DialogResult.Cancel); } } - private void txtInput_TextChanged(object sender, EventArgs e) + private void btnOK_Click(object sender, EventArgs e) { - InputText = txtInput.Text; + Close(DialogResult.OK); } - private void btnClose_Click(object sender, EventArgs e) + private void btnCancel_Click(object sender, EventArgs e) { - Close(); + Close(DialogResult.Cancel); } private void UpdateInputBox() diff --git a/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.resx b/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.resx index 22c8776c2..4c5e8d95f 100644 --- a/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.resx +++ b/ShareX.ScreenCaptureLib/Forms/TextDrawingInputBox.resx @@ -148,7 +148,7 @@ $this - 5 + 6 Left @@ -180,6 +180,138 @@ Top, Left, Right + + lblFont + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 0 + + + cbFonts + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 1 + + + lblTextSize + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 2 + + + nudTextSize + + + System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 3 + + + cbBold + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 5 + + + cbItalic + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 6 + + + cbUnderline + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 7 + + + btnAlignmentHorizontal + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 8 + + + btnAlignmentVertical + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + flpProperties + + + 9 + + + 8, 5 + + + 518, 32 + + + 1 + + + False + + + flpProperties + + + System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + Left @@ -426,41 +558,17 @@ 9 - - 8, 5 - - - 518, 32 - - - 2 - - - False - - - flpProperties - - - System.Windows.Forms.FlowLayoutPanel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 4 - Bottom, Right - 422, 327 + 312, 328 - 104, 26 + 104, 24 - 3 + 2 OK @@ -475,11 +583,20 @@ $this - 3 + 4 17, 17 + + 110, 70 + + + cmsAlignmentHorizontal + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 109, 22 @@ -498,18 +615,18 @@ Right - - 110, 70 - - - cmsAlignmentHorizontal - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 203, 17 + + 115, 70 + + + cmsAlignmentVertical + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 114, 22 @@ -528,15 +645,6 @@ Bottom - - 115, 70 - - - cmsAlignmentVertical - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - True @@ -562,6 +670,33 @@ $this + 1 + + + Bottom, Right + + + 424, 328 + + + 104, 24 + + + 3 + + + Cancel + + + btnCancel + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0