changeset 79:e3488dd61a21 WarFoundry_v0.1beta4_Winforms

Fixes #199: armytree unit point costs don't always show after update * Extract common node text setting method and use on unit name update
author IBBoard <dev@ibboard.co.uk>
date Sun, 11 Oct 2009 19:57:13 +0000
parents 431cc3ace26c
children c243b043aa62
files FrmArmyTree.cs
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line diff
     1.1 --- a/FrmArmyTree.cs	Tue Oct 06 13:39:50 2009 +0000
     1.2 +++ b/FrmArmyTree.cs	Sun Oct 11 19:57:13 2009 +0000
     1.3 @@ -241,7 +241,17 @@
     1.4  		{
     1.5  			if (obj is ICostedWarFoundryObject)
     1.6  			{
     1.7 -				nodes[obj.ID].Text = CreateNodeName((ICostedWarFoundryObject)obj);
     1.8 +				SetNodeName(obj);
     1.9 +			}
    1.10 +		}
    1.11 +
    1.12 +		private void SetNodeName(WarFoundryObject obj)
    1.13 +		{
    1.14 +			TreeNode node = nodes[obj.ID];
    1.15 +
    1.16 +			if (node != null)
    1.17 +			{
    1.18 +				node.Text = CreateNodeName((ICostedWarFoundryObject)obj);
    1.19  			}
    1.20  		}
    1.21  
    1.22 @@ -393,15 +403,9 @@
    1.23  
    1.24  		private void UpdateUnitName(WarFoundryObject obj, string oldValue, string newValue)
    1.25  		{
    1.26 -			if (obj is Unit)
    1.27 +			if (obj is ICostedWarFoundryObject)
    1.28  			{
    1.29 -				Unit unit = (Unit)obj;
    1.30 -				TreeNode node = nodes[unit.ID];
    1.31 -				
    1.32 -				if (node!=null)
    1.33 -				{
    1.34 -					node.Text = unit.Name;
    1.35 -				}
    1.36 +				SetNodeName(obj);
    1.37  			}
    1.38  		}
    1.39