mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 10:47:02 -07:00
Fix for #303 where the combobox is editable, it does change the drawing a bit. [skip ci]
This commit is contained in:
parent
c1886da940
commit
42d8fdd15e
2 changed files with 33 additions and 28 deletions
29
src/Greenshot/Forms/ResizeSettingsForm.Designer.cs
generated
29
src/Greenshot/Forms/ResizeSettingsForm.Designer.cs
generated
|
@ -19,6 +19,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Base.Controls;
|
||||
|
||||
namespace Greenshot.Forms {
|
||||
|
@ -65,7 +66,7 @@ namespace Greenshot.Forms {
|
|||
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonOK.TabIndex = 6;
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
this.buttonOK.Click += new System.EventHandler(this.ButtonOK_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
|
@ -108,8 +109,8 @@ namespace Greenshot.Forms {
|
|||
this.textbox_height.Name = "textbox_height";
|
||||
this.textbox_height.Size = new System.Drawing.Size(69, 20);
|
||||
this.textbox_height.TabIndex = 3;
|
||||
this.textbox_height.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textbox_KeyUp);
|
||||
this.textbox_height.Validating += new System.ComponentModel.CancelEventHandler(this.textbox_Validating);
|
||||
this.textbox_height.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Textbox_KeyUp);
|
||||
this.textbox_height.Validating += new System.ComponentModel.CancelEventHandler(this.Textbox_Validating);
|
||||
//
|
||||
// textbox_width
|
||||
//
|
||||
|
@ -117,8 +118,8 @@ namespace Greenshot.Forms {
|
|||
this.textbox_width.Name = "textbox_width";
|
||||
this.textbox_width.Size = new System.Drawing.Size(69, 20);
|
||||
this.textbox_width.TabIndex = 1;
|
||||
this.textbox_width.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textbox_KeyUp);
|
||||
this.textbox_width.Validating += new System.ComponentModel.CancelEventHandler(this.textbox_Validating);
|
||||
this.textbox_width.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Textbox_KeyUp);
|
||||
this.textbox_width.Validating += new System.ComponentModel.CancelEventHandler(this.Textbox_Validating);
|
||||
//
|
||||
// combobox_width
|
||||
//
|
||||
|
@ -127,19 +128,21 @@ namespace Greenshot.Forms {
|
|||
this.combobox_width.Name = "combobox_width";
|
||||
this.combobox_width.Size = new System.Drawing.Size(65, 21);
|
||||
this.combobox_width.TabIndex = 2;
|
||||
//
|
||||
// combobox_height
|
||||
//
|
||||
this.combobox_height.FormattingEnabled = true;
|
||||
this.combobox_width.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
//
|
||||
// combobox_height
|
||||
//
|
||||
this.combobox_height.FormattingEnabled = true;
|
||||
this.combobox_height.ItemHeight = 13;
|
||||
this.combobox_height.Location = new System.Drawing.Point(165, 38);
|
||||
this.combobox_height.Name = "combobox_height";
|
||||
this.combobox_height.Size = new System.Drawing.Size(65, 21);
|
||||
this.combobox_height.TabIndex = 4;
|
||||
//
|
||||
// ResizeSettingsForm
|
||||
//
|
||||
this.AcceptButton = this.buttonOK;
|
||||
this.combobox_height.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
//
|
||||
// ResizeSettingsForm
|
||||
//
|
||||
this.AcceptButton = this.buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.CancelButton = this.buttonCancel;
|
||||
|
|
|
@ -53,15 +53,16 @@ namespace Greenshot.Forms
|
|||
textbox_height.Text = effect.Height.ToString();
|
||||
_newWidth = effect.Width;
|
||||
_newHeight = effect.Height;
|
||||
combobox_width.SelectedIndexChanged += combobox_SelectedIndexChanged;
|
||||
combobox_height.SelectedIndexChanged += combobox_SelectedIndexChanged;
|
||||
combobox_width.SelectedIndexChanged += Combobox_SelectedIndexChanged;
|
||||
combobox_height.SelectedIndexChanged += Combobox_SelectedIndexChanged;
|
||||
|
||||
checkbox_aspectratio.Checked = effect.MaintainAspectRatio;
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
private void ButtonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_newWidth != _effect.Width || _newHeight != _effect.Height)
|
||||
const double tolerance = 3 * double.Epsilon;
|
||||
if (Math.Abs(_newWidth - _effect.Width) > tolerance || Math.Abs(_newHeight - _effect.Height) > tolerance)
|
||||
{
|
||||
_effect.Width = (int) _newWidth;
|
||||
_effect.Height = (int) _newHeight;
|
||||
|
@ -72,16 +73,17 @@ namespace Greenshot.Forms
|
|||
|
||||
private static bool Validate(object sender)
|
||||
{
|
||||
if (sender is TextBox textbox)
|
||||
if (sender is not TextBox textBox)
|
||||
{
|
||||
if (!double.TryParse(textbox.Text, out var numberEntered))
|
||||
{
|
||||
textbox.BackColor = Color.Red;
|
||||
return false;
|
||||
}
|
||||
|
||||
textbox.BackColor = Color.White;
|
||||
return true;
|
||||
}
|
||||
if (!double.TryParse(textBox.Text, out _))
|
||||
{
|
||||
textBox.BackColor = Color.Red;
|
||||
return false;
|
||||
}
|
||||
|
||||
textBox.BackColor = Color.White;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -116,7 +118,7 @@ namespace Greenshot.Forms
|
|||
textbox_height.Text = ((int) displayValue).ToString();
|
||||
}
|
||||
|
||||
private void textbox_KeyUp(object sender, KeyEventArgs e)
|
||||
private void Textbox_KeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (!Validate(sender))
|
||||
{
|
||||
|
@ -186,7 +188,7 @@ namespace Greenshot.Forms
|
|||
}
|
||||
}
|
||||
|
||||
private void textbox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void Textbox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
Validate(sender);
|
||||
}
|
||||
|
@ -196,7 +198,7 @@ namespace Greenshot.Forms
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void combobox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
private void Combobox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (Validate(textbox_width))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue