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 wrap: on
line diff
--- a/FrmUnit.cs	Tue Sep 15 20:08:23 2009 +0000
+++ b/FrmUnit.cs	Wed Sep 16 19:41:27 2009 +0000
@@ -370,6 +370,7 @@
 			this.Name = "FrmUnit";
 			this.ShowInTaskbar = false;
 			this.Text = "FrmUnit";
+			this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmUnit_FormClosing);
 			((System.ComponentModel.ISupportInitialize)(this.statsGrid)).EndInit();
 			((System.ComponentModel.ISupportInitialize)(this.unitSize)).EndInit();
 			this.ResumeLayout(false);
@@ -385,18 +386,18 @@
 
 		private void tbUnitName_Leave(object sender, System.EventArgs e)
 		{
-			updateUnitName();
+			UpdateUnitName();
 		}
 
 		private void tbUnitName_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 		{
 			if (e.KeyCode == Keys.Enter)
 			{
-				updateUnitName();
+				UpdateUnitName();
 			}
 		}
 
-		private void updateUnitName()
+		private void UpdateUnitName()
 		{
 			if (unit.Name != tbUnitName.Text)
 			{
@@ -406,18 +407,18 @@
 
 		private void unitSize_Leave(object sender, System.EventArgs e)
 		{
-			updateUnitSize();
+			UpdateUnitSize();
 		}
 
 		private void unitSize_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 		{
 			if (e.KeyCode == Keys.Enter)
 			{
-				updateUnitSize();
+				UpdateUnitSize();
 			}
 		}
 
-		private void updateUnitSize()
+		private void UpdateUnitSize()
 		{
 			if (unit.Size != unitSize.Value)
 			{
@@ -535,5 +536,11 @@
 			FrmReplaceUnitEquipment replace = new FrmReplaceUnitEquipment(unit, ((UnitEquipmentChoice) reqdList.SelectedItem).Item, commandStack);
 			replace.ShowDialog(this);
 		}
+
+		private void FrmUnit_FormClosing(object sender, FormClosingEventArgs e)
+		{
+			UpdateUnitName();
+			UpdateUnitSize();
+		}
 	}
 }
\ No newline at end of file