Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
changeset 251: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 wrap: on
line diff
--- a/FrmMain.cs Sun Aug 26 11:26:50 2012 +0100 +++ b/FrmMain.cs Sat Sep 01 16:12:48 2012 +0100 @@ -54,6 +54,7 @@ public StringValChangedDelegate ArmyNameChangedMethod; public DoubleValChangedDelegate PointsValueChangedMethod; public IntValChangedDelegate MaxPointsValueChangedMethod; + public MethodInvoker ArmyCompositionChangedMethod; private FrmArmyTree armyTree; private string loadedFilePath; @@ -156,6 +157,7 @@ ArmyNameChangedMethod = new StringValChangedDelegate(FrmMain_ArmyNameChangedMethod); PointsValueChangedMethod = new DoubleValChangedDelegate(FrmMain_PointsValueChangedMethod); MaxPointsValueChangedMethod = new IntValChangedDelegate(FrmMain_MaxPointsValueChangedMethod); + ArmyCompositionChangedMethod = FrmMain_ArmyCompositionChanged; sbErrorPanel.Color = Color.Red; SetPointsPanelToolTipText(); @@ -935,13 +937,14 @@ private void FrmMain_ArmyChanged(Army oldArmy, Army newArmy) { + IgnoreArmy(oldArmy); + ListenToArmy(newArmy); CommandStack.Reset(); ValidateArmy(); loadedFilePath = null; miSaveArmy.Enabled = false; bttnSaveArmy.Enabled = false; miEditArmy.Enabled = (CurrentArmy != null); - //TODO: Subscribe to an "army changed" event here SetPointsPanelText(); SetAppTitle(); } @@ -974,6 +977,7 @@ oldArmy.NameChanged -= ArmyNameChangedMethod; oldArmy.PointsValueChanged -= PointsValueChangedMethod; oldArmy.MaxPointsValueChanged -= MaxPointsValueChangedMethod; + oldArmy.ArmyCompositionChanged -= ArmyCompositionChangedMethod; } } @@ -998,6 +1002,7 @@ newArmy.NameChanged += ArmyNameChangedMethod; newArmy.PointsValueChanged += PointsValueChangedMethod; newArmy.MaxPointsValueChanged += MaxPointsValueChangedMethod; + newArmy.ArmyCompositionChanged += ArmyCompositionChangedMethod; } } @@ -1328,6 +1333,11 @@ OpenArmy(); } + private void FrmMain_ArmyCompositionChanged() + { + ValidateArmy(); + } + private void FrmMain_ArmyNameChangedMethod(WarFoundryObject obj, string oldString, string newString) { SetAppTitle();