diff FrmMain.cs @ 248:19a88383dfa7

Re #354: Single-button Add Unit * Pull out re-usable method for adding unit * Make double-click add unit
author IBBoard <dev@ibboard.co.uk>
date Sat, 20 Aug 2011 16:12:15 +0100
parents 53d79e1be712
children 694f23814ec2
line wrap: on
line diff
--- a/FrmMain.cs	Tue Aug 16 21:01:45 2011 +0100
+++ b/FrmMain.cs	Sat Aug 20 16:12:15 2011 +0100
@@ -1202,12 +1202,19 @@
 
 			if (dr == DialogResult.OK)
 			{
-				CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(newUnit.SelectedUnit, CurrentArmy.GetCategory(cat));
-				commandStack.Execute(cmd);
-				OpenUnitDialog(cmd.Unit);
+                UnitType unitType = newUnit.SelectedUnit;
+                CreateUnitInCategory(unitType, cat);
 			}
 		}
 
+        internal void CreateUnitInCategory(UnitType unitType, Category cat)
+        {
+            ArmyCategory armyCat = CurrentArmy.GetCategory(cat);
+            CreateAndAddUnitCommand cmd = new CreateAndAddUnitCommand(unitType, armyCat);
+            commandStack.Execute(cmd);
+            OpenUnitDialog(cmd.Unit);
+        }
+
 		internal void OpenUnitDialog(Unit unit)
 		{
 			string unitID = unit.ID;