# HG changeset patch # User IBBoard # Date 1253130087 0 # Node ID 4a56900936aa7c213724bbf0d75d14396372ec9c # Parent 53a18feb237091068ca4544b5d11e116a68db516 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 diff -r 53a18feb2370 -r 4a56900936aa FrmUnit.cs --- 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