Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
changeset 113:c1a3993297b1
Re #115: Typing number for equipment amount doesn't update Okay button
* Switch to using ControlTranslator for the EquipmentAmountControl to resolve issues with the VisualStudio form designer erroring out because the translations aren't initialised (they still won't be, but it seems to be happy now)
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Thu, 24 Dec 2009 10:52:03 +0000 |
parents | d9b027f80e03 |
children | 727c1b0e49a6 |
files | FrmNewUnitEquipment.cs UI/EquipmentAmountControl.Designer.cs UI/EquipmentAmountControl.cs |
diffstat | 3 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/FrmNewUnitEquipment.cs Mon Dec 21 20:38:51 2009 +0000 +++ b/FrmNewUnitEquipment.cs Thu Dec 24 10:52:03 2009 +0000 @@ -13,6 +13,7 @@ using IBBoard.WarFoundry.API.Commands; using IBBoard.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Util; +using IBBoard.WarFoundry.GUI.WinForms.UI; using IBBoard.WarFoundry.GUI.WinForms.Util; using IBBoard.Windows.Forms; using IBBoard.Windows.Forms.I18N; @@ -31,7 +32,7 @@ private IBBButton bttnOkay; private IBBLabel lblItem; private System.Windows.Forms.ListBox listItems; - private IBBoard.WarFoundry.GUI.WinForms.UI.EquipmentAmountControl equipmentAmount; + private EquipmentAmountControl equipmentAmount; /// <summary> /// Required designer variable. /// </summary>
--- a/UI/EquipmentAmountControl.Designer.cs Mon Dec 21 20:38:51 2009 +0000 +++ b/UI/EquipmentAmountControl.Designer.cs Thu Dec 24 10:52:03 2009 +0000 @@ -93,6 +93,7 @@ this.percentage.Size = new System.Drawing.Size(105, 20); this.percentage.TabIndex = 4; this.percentage.ValueChanged += new System.EventHandler(this.percentage_ValueChanged); + this.percentage.KeyDown += new System.Windows.Forms.KeyEventHandler(this.percentage_KeyDown); // // lblPercentSign //
--- a/UI/EquipmentAmountControl.cs Mon Dec 21 20:38:51 2009 +0000 +++ b/UI/EquipmentAmountControl.cs Thu Dec 24 10:52:03 2009 +0000 @@ -9,6 +9,7 @@ using IBBoard.CustomMath; using IBBoard.Lang; using IBBoard.Limits; +using IBBoard.Windows.Forms.I18N; using IBBoard.WarFoundry.API; using IBBoard.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Util; @@ -25,7 +26,7 @@ public EquipmentAmountControl() { InitializeComponent(); - rbEquipAll.Text = Translation.GetTranslation("rbEquipAll", "equip all"); + ControlTranslator.TranslateControl(this); } public void SetUnit(Unit equipUnit) @@ -159,12 +160,27 @@ private void percentage_ValueChanged(object sender, EventArgs e) { + PerformPercentageValueChanged(); + } + + private void PerformPercentageValueChanged() + { log.Debug("Percentage value changed"); SetNumericValueFromPercentage(); rbEquipAll.Checked = (percentage.Value == 100 && !rbNumeric.Checked); OnValueChanged(); } + private void percentage_KeyDown(object sender, KeyEventArgs e) + { + Console.WriteLine("Keycode: "+e.KeyCode); + + if (e.KeyCode == Keys.Enter) + { + PerformPercentageValueChanged(); + } + } + private void SetNumericValueFromPercentage() { numeric.ValueChanged -= numeric_ValueChanged;