changeset 52:4a56900936aa

Fixes #165: Closing unit dialog that has unit name/size changes loses the changes * Attach a method on closing that calls the "set name" and "set size" methods in case they have changed
author IBBoard <dev@ibboard.co.uk>
date Wed, 16 Sep 2009 19:41:27 +0000
parents 53a18feb2370
children e6d0d9eababf
files FrmUnit.cs
diffstat 1 files changed, 13 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/FrmUnit.cs	Tue Sep 15 20:08:23 2009 +0000
     1.2 +++ b/FrmUnit.cs	Wed Sep 16 19:41:27 2009 +0000
     1.3 @@ -370,6 +370,7 @@
     1.4  			this.Name = "FrmUnit";
     1.5  			this.ShowInTaskbar = false;
     1.6  			this.Text = "FrmUnit";
     1.7 +			this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmUnit_FormClosing);
     1.8  			((System.ComponentModel.ISupportInitialize)(this.statsGrid)).EndInit();
     1.9  			((System.ComponentModel.ISupportInitialize)(this.unitSize)).EndInit();
    1.10  			this.ResumeLayout(false);
    1.11 @@ -385,18 +386,18 @@
    1.12  
    1.13  		private void tbUnitName_Leave(object sender, System.EventArgs e)
    1.14  		{
    1.15 -			updateUnitName();
    1.16 +			UpdateUnitName();
    1.17  		}
    1.18  
    1.19  		private void tbUnitName_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    1.20  		{
    1.21  			if (e.KeyCode == Keys.Enter)
    1.22  			{
    1.23 -				updateUnitName();
    1.24 +				UpdateUnitName();
    1.25  			}
    1.26  		}
    1.27  
    1.28 -		private void updateUnitName()
    1.29 +		private void UpdateUnitName()
    1.30  		{
    1.31  			if (unit.Name != tbUnitName.Text)
    1.32  			{
    1.33 @@ -406,18 +407,18 @@
    1.34  
    1.35  		private void unitSize_Leave(object sender, System.EventArgs e)
    1.36  		{
    1.37 -			updateUnitSize();
    1.38 +			UpdateUnitSize();
    1.39  		}
    1.40  
    1.41  		private void unitSize_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
    1.42  		{
    1.43  			if (e.KeyCode == Keys.Enter)
    1.44  			{
    1.45 -				updateUnitSize();
    1.46 +				UpdateUnitSize();
    1.47  			}
    1.48  		}
    1.49  
    1.50 -		private void updateUnitSize()
    1.51 +		private void UpdateUnitSize()
    1.52  		{
    1.53  			if (unit.Size != unitSize.Value)
    1.54  			{
    1.55 @@ -535,5 +536,11 @@
    1.56  			FrmReplaceUnitEquipment replace = new FrmReplaceUnitEquipment(unit, ((UnitEquipmentChoice) reqdList.SelectedItem).Item, commandStack);
    1.57  			replace.ShowDialog(this);
    1.58  		}
    1.59 +
    1.60 +		private void FrmUnit_FormClosing(object sender, FormClosingEventArgs e)
    1.61 +		{
    1.62 +			UpdateUnitName();
    1.63 +			UpdateUnitSize();
    1.64 +		}
    1.65  	}
    1.66  }
    1.67 \ No newline at end of file