diff FrmMain.cs @ 222:4ada3252d1ea

Re #101: Make army names and sizes modifiable after creation * Fix up translations * Correct enabling of menu item * Add translation text * Update army names in tree and app title when edited
author IBBoard <dev@ibboard.co.uk>
date Mon, 29 Aug 2011 20:53:53 +0100
parents 5233147ca7e4
children c06d0865ff27
line wrap: on
line diff
--- a/FrmMain.cs	Mon Aug 29 20:06:54 2011 +0100
+++ b/FrmMain.cs	Mon Aug 29 20:53:53 2011 +0100
@@ -49,7 +49,9 @@
 
 		public ObjectAddDelegate UnitAddedMethod;
 		public ObjectRemoveDelegate UnitRemovedMethod;
+		public StringValChangedDelegate ArmyNameChangedMethod;
 		public DoubleValChangedDelegate PointsValueChangedMethod;
+		public IntValChangedDelegate MaxPointsValueChangedMethod;
 
 		private FrmArmyTree armyTree;
 		private string loadedFilePath;
@@ -148,7 +150,9 @@
 			WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmMain_ArmyChanged);
 			UnitAddedMethod = new ObjectAddDelegate(FrmMain_UnitAddedMethod);
 			UnitRemovedMethod = new ObjectRemoveDelegate(FrmMain_UnitRemovedMethod);
+			ArmyNameChangedMethod = new StringValChangedDelegate(FrmMain_ArmyNameChangedMethod);
 			PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod);
+			MaxPointsValueChangedMethod = new IntValChangedDelegate(FrmMain_MaxPointsValueChangedMethod);
 
 			sbErrorPanel.Color = Color.Red;
 			SetPointsPanelToolTipText();
@@ -578,6 +582,7 @@
 			// 
 			// miEditArmy
 			// 
+			this.miEditArmy.Enabled = false;
 			this.miEditArmy.Name = "miEditArmy";
 			this.miEditArmy.Size = new System.Drawing.Size(152, 22);
 			this.miEditArmy.Text = "&edit army";
@@ -913,7 +918,7 @@
 			loadedFilePath = null;
 			miSaveArmy.Enabled = false;
 			bttnSaveArmy.Enabled = false;
-			miEditArmy.Enabled = (CurrentArmy == null);
+			miEditArmy.Enabled = (CurrentArmy != null);
             //TODO: Subscribe to an "army changed" event here
 			SetPointsPanelText();
 			SetAppTitle();
@@ -944,7 +949,9 @@
 			{
 				oldArmy.UnitAdded -= UnitAddedMethod;
 				oldArmy.UnitRemoved -= UnitRemovedMethod;
+				oldArmy.NameChanged -= ArmyNameChangedMethod;
 				oldArmy.PointsValueChanged -= PointsValueChangedMethod;
+				oldArmy.MaxPointsValueChanged -= MaxPointsValueChangedMethod;
 			}
 		}
 
@@ -966,7 +973,9 @@
 			{
 				newArmy.UnitAdded += UnitAddedMethod;
 				newArmy.UnitRemoved += UnitRemovedMethod;
+				newArmy.NameChanged += ArmyNameChangedMethod;
 				newArmy.PointsValueChanged += PointsValueChangedMethod;
+				newArmy.MaxPointsValueChanged += MaxPointsValueChangedMethod;
 			}
 		}
 
@@ -1297,6 +1306,11 @@
 			OpenArmy();
 		}
 
+		private void FrmMain_ArmyNameChangedMethod(WarFoundryObject obj, string oldString, string newString)
+		{
+			SetAppTitle();
+		}
+
 		private void FrmMain_PointsValueChangedMethod(WarFoundryObject obj, double oldVal, double newVal)
 		{
 			if (obj is Army)
@@ -1305,6 +1319,14 @@
 			}
 		}
 
+		private void FrmMain_MaxPointsValueChangedMethod(WarFoundryObject obj, int oldVal, int newVal)
+		{
+			if (obj is Army)
+			{
+				SetPointsPanelText();
+			}
+		}
+
         private void SetPointsPanelText()
 		{	
 			if (CurrentArmy==null)