changeset 246:b57a7cf844f8

Fixes #426: Changing unit size doesn't trigger all validation * Hook validation in to army composition changed event * Make sure we're ignoring old armies and listening to the new one
author IBBoard <dev@ibboard.co.uk>
date Sat, 01 Sep 2012 16:12:48 +0100
parents 3aacaa74587f
children 4d25c42bbe7b
files FrmMain.cs
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/FrmMain.cs	Sun Aug 26 11:26:50 2012 +0100
     1.2 +++ b/FrmMain.cs	Sat Sep 01 16:12:48 2012 +0100
     1.3 @@ -54,6 +54,7 @@
     1.4  		public StringValChangedDelegate ArmyNameChangedMethod;
     1.5  		public DoubleValChangedDelegate PointsValueChangedMethod;
     1.6  		public IntValChangedDelegate MaxPointsValueChangedMethod;
     1.7 +		public MethodInvoker ArmyCompositionChangedMethod;
     1.8  
     1.9  		private FrmArmyTree armyTree;
    1.10  		private string loadedFilePath;
    1.11 @@ -156,6 +157,7 @@
    1.12  			ArmyNameChangedMethod = new StringValChangedDelegate(FrmMain_ArmyNameChangedMethod);
    1.13  			PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod);
    1.14  			MaxPointsValueChangedMethod = new IntValChangedDelegate(FrmMain_MaxPointsValueChangedMethod);
    1.15 +			ArmyCompositionChangedMethod = FrmMain_ArmyCompositionChanged;
    1.16  
    1.17  			sbErrorPanel.Color = Color.Red;
    1.18  			SetPointsPanelToolTipText();
    1.19 @@ -935,13 +937,14 @@
    1.20  
    1.21  		private void FrmMain_ArmyChanged(Army oldArmy, Army newArmy)
    1.22  		{
    1.23 +			IgnoreArmy(oldArmy);
    1.24 +			ListenToArmy(newArmy);
    1.25  			CommandStack.Reset();
    1.26  			ValidateArmy();
    1.27  			loadedFilePath = null;
    1.28  			miSaveArmy.Enabled = false;
    1.29  			bttnSaveArmy.Enabled = false;
    1.30  			miEditArmy.Enabled = (CurrentArmy != null);
    1.31 -            //TODO: Subscribe to an "army changed" event here
    1.32  			SetPointsPanelText();
    1.33  			SetAppTitle();
    1.34  		}
    1.35 @@ -974,6 +977,7 @@
    1.36  				oldArmy.NameChanged -= ArmyNameChangedMethod;
    1.37  				oldArmy.PointsValueChanged -= PointsValueChangedMethod;
    1.38  				oldArmy.MaxPointsValueChanged -= MaxPointsValueChangedMethod;
    1.39 +				oldArmy.ArmyCompositionChanged -= ArmyCompositionChangedMethod;
    1.40  			}
    1.41  		}
    1.42  
    1.43 @@ -998,6 +1002,7 @@
    1.44  				newArmy.NameChanged += ArmyNameChangedMethod;
    1.45  				newArmy.PointsValueChanged += PointsValueChangedMethod;
    1.46  				newArmy.MaxPointsValueChanged += MaxPointsValueChangedMethod;
    1.47 +				newArmy.ArmyCompositionChanged += ArmyCompositionChangedMethod;
    1.48  			}
    1.49  		}
    1.50  
    1.51 @@ -1328,6 +1333,11 @@
    1.52  			OpenArmy();
    1.53  		}
    1.54  
    1.55 +		private void FrmMain_ArmyCompositionChanged()
    1.56 +		{
    1.57 +			ValidateArmy();
    1.58 +		}
    1.59 +
    1.60  		private void FrmMain_ArmyNameChangedMethod(WarFoundryObject obj, string oldString, string newString)
    1.61  		{
    1.62  			SetAppTitle();