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 wrap: on
line diff
--- a/FrmArmyTree.cs	Tue Oct 06 13:39:50 2009 +0000
+++ b/FrmArmyTree.cs	Sun Oct 11 19:57:13 2009 +0000
@@ -241,7 +241,17 @@
 		{
 			if (obj is ICostedWarFoundryObject)
 			{
-				nodes[obj.ID].Text = CreateNodeName((ICostedWarFoundryObject)obj);
+				SetNodeName(obj);
+			}
+		}
+
+		private void SetNodeName(WarFoundryObject obj)
+		{
+			TreeNode node = nodes[obj.ID];
+
+			if (node != null)
+			{
+				node.Text = CreateNodeName((ICostedWarFoundryObject)obj);
 			}
 		}
 
@@ -393,15 +403,9 @@
 
 		private void UpdateUnitName(WarFoundryObject obj, string oldValue, string newValue)
 		{
-			if (obj is Unit)
+			if (obj is ICostedWarFoundryObject)
 			{
-				Unit unit = (Unit)obj;
-				TreeNode node = nodes[unit.ID];
-				
-				if (node!=null)
-				{
-					node.Text = unit.Name;
-				}
+				SetNodeName(obj);
 			}
 		}