changeset 62:0e7c257ca8d6 WarFoundry_v0.1beta2_Winforms

Fixes #164: Show unit cost in army tree * Add points value in army tree for units, category and army (aggregating as it goes up the tree) * Add code to update tree node text as points values change * Remove references to now deprecated points-related properties Also: * Add rolling log file appender to logging config
author IBBoard <dev@ibboard.co.uk>
date Sat, 19 Sep 2009 19:44:45 +0000
parents a0ec03c24cd9
children 4db2c1086a85
files FrmArmyTree.cs FrmMain.cs FrmUnit.cs WarFoundry.exe.log4net
diffstat 4 files changed, 474 insertions(+), 444 deletions(-) [+]
line diff
     1.1 --- a/FrmArmyTree.cs	Sat Sep 19 16:01:43 2009 +0000
     1.2 +++ b/FrmArmyTree.cs	Sat Sep 19 19:44:45 2009 +0000
     1.3 @@ -1,431 +1,452 @@
     1.4 -// This file (FrmArmyTree.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
     1.5 -//
     1.6 -// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
     1.7 -
     1.8 -using System;
     1.9 -using System.Drawing;
    1.10 -using System.Collections.Generic;
    1.11 -using System.ComponentModel;
    1.12 -using System.Windows.Forms;
    1.13 +// This file (FrmArmyTree.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
    1.14 +//
    1.15 +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
    1.16 +
    1.17 +using System;
    1.18 +using System.Drawing;
    1.19 +using System.Collections.Generic;
    1.20 +using System.ComponentModel;
    1.21 +using System.Windows.Forms;
    1.22  using IBBoard.Commands;
    1.23 -using IBBoard.Windows.Forms.I18N;
    1.24 -using IBBoard.Windows.Forms;
    1.25 -using IBBoard.WarFoundry.API;
    1.26 -using IBBoard.WarFoundry.API.Commands;
    1.27 -using IBBoard.WarFoundry.API.Objects;
    1.28 -
    1.29 -namespace IBBoard.WarFoundry.GUI.WinForms
    1.30 -{
    1.31 -	/// <summary>
    1.32 -	/// Summary description for FrmArmyTree.
    1.33 -	/// </summary>
    1.34 -	public class FrmArmyTree : IBBoard.Windows.Forms.IBBForm
    1.35 -	{
    1.36 -		private System.Windows.Forms.TreeView treeView;
    1.37 -		private IContainer components;
    1.38 -		private Dictionary<string, TreeNode> nodes;
    1.39 -		private System.Windows.Forms.ContextMenu contextMenu;
    1.40 -		private IBBMenuItem miDelete;
    1.41 -		private IBBMenuItem miEdit;
    1.42 -		
    1.43 -		private ObjectAddDelegate UnitAddedMethod;
    1.44 -		private ObjectRemoveDelegate UnitRemovedMethod;
    1.45 -		private StringValChangedDelegate UnitNameChangedMethod, ArmyNameChangedMethod, TreeNameChangedMethod;
    1.46 -		private ToolBar toolBar;
    1.47 -		private IBBToolBarButton bttnEdit;
    1.48 -		private IBBToolBarButton bttnDelete;
    1.49 -		private ImageList imageList;
    1.50 -		private CommandStack commandStack;
    1.51 -
    1.52 -		public FrmArmyTree(CommandStack cmdStack)
    1.53 -		{
    1.54 -			commandStack = cmdStack;
    1.55 -			InitializeComponent();
    1.56 -			UnitAddedMethod = new ObjectAddDelegate(UnitAdded);
    1.57 -			UnitRemovedMethod = new ObjectRemoveDelegate(UnitRemoved);
    1.58 -			UnitNameChangedMethod = new StringValChangedDelegate(UpdateUnitName);
    1.59 -			ArmyNameChangedMethod = new StringValChangedDelegate(UpdateArmyName);
    1.60 -			TreeNameChangedMethod = new StringValChangedDelegate(FrmArmyTree_TreeNameChanged);
    1.61 -			nodes = new Dictionary<string, TreeNode>();
    1.62 -			this.Name = "ArmyTree";			
    1.63 -			WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(FrmArmyTree_ArmyChanged);
    1.64 -
    1.65 -			foreach (Control ctrl in Controls)
    1.66 -			{
    1.67 -				ControlTranslator.TranslateControl(ctrl);
    1.68 -			}
    1.69 -
    1.70 -			foreach (Component comp in components.Components)
    1.71 -			{
    1.72 -				ControlTranslator.TranslateComponent(comp);
    1.73 -			}
    1.74 -
    1.75 -			foreach (IBBMenuItem mi in contextMenu.MenuItems)
    1.76 -			{
    1.77 -				ControlTranslator.TranslateComponent(mi);
    1.78 -			}
    1.79 -		}
    1.80 -
    1.81 -		/// <summary>
    1.82 -		/// Clean up any resources being used.
    1.83 -		/// </summary>
    1.84 -		protected override void Dispose( bool disposing )
    1.85 -		{
    1.86 -			if( disposing )
    1.87 -			{
    1.88 -				if(components != null)
    1.89 -				{
    1.90 -					components.Dispose();
    1.91 -				}
    1.92 -			}
    1.93 -			base.Dispose( disposing );
    1.94 -		}
    1.95 -
    1.96 -		#region Windows Form Designer generated code
    1.97 -		/// <summary>
    1.98 -		/// Required method for Designer support - do not modify
    1.99 -		/// the contents of this method with the code editor.
   1.100 -		/// </summary>
   1.101 -		private void InitializeComponent()
   1.102 -		{
   1.103 -			this.components = new System.ComponentModel.Container();
   1.104 -			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmArmyTree));
   1.105 -			this.contextMenu = new System.Windows.Forms.ContextMenu();
   1.106 -			this.miEdit = new IBBoard.Windows.Forms.IBBMenuItem();
   1.107 -			this.miDelete = new IBBoard.Windows.Forms.IBBMenuItem();
   1.108 -			this.imageList = new System.Windows.Forms.ImageList(this.components);
   1.109 -			this.toolBar = new System.Windows.Forms.ToolBar();
   1.110 -			this.bttnEdit = new IBBoard.Windows.Forms.IBBToolBarButton();
   1.111 -			this.bttnDelete = new IBBoard.Windows.Forms.IBBToolBarButton();
   1.112 -			this.treeView = new System.Windows.Forms.TreeView();
   1.113 -			this.SuspendLayout();
   1.114 -			// 
   1.115 -			// contextMenu
   1.116 -			// 
   1.117 -			this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
   1.118 -            this.miEdit,
   1.119 -            this.miDelete});
   1.120 -			this.contextMenu.Popup += new System.EventHandler(this.contextMenu_Popup);
   1.121 -			// 
   1.122 -			// miEdit
   1.123 -			// 
   1.124 -			this.miEdit.Index = 0;
   1.125 -			this.miEdit.Text = "&edit unit";
   1.126 -			this.miEdit.Click += new System.EventHandler(this.miEdit_Click);
   1.127 -			// 
   1.128 -			// miDelete
   1.129 -			// 
   1.130 -			this.miDelete.Index = 1;
   1.131 -			this.miDelete.Text = "&delete unit";
   1.132 -			this.miDelete.Click += new System.EventHandler(this.miDelete_Click);
   1.133 -			// 
   1.134 -			// imageList
   1.135 -			// 
   1.136 -			this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer) (resources.GetObject("imageList.ImageStream")));
   1.137 -			this.imageList.TransparentColor = System.Drawing.Color.Transparent;
   1.138 -			this.imageList.Images.SetKeyName(0, "gtk-edit.png");
   1.139 -			this.imageList.Images.SetKeyName(1, "edit-delete.png");
   1.140 -			// 
   1.141 -			// toolBar
   1.142 -			// 
   1.143 -			this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
   1.144 -            this.bttnEdit,
   1.145 -            this.bttnDelete});
   1.146 -			this.toolBar.ButtonSize = new System.Drawing.Size(16, 16);
   1.147 -			this.toolBar.DropDownArrows = true;
   1.148 -			this.toolBar.ImageList = this.imageList;
   1.149 -			this.toolBar.Location = new System.Drawing.Point(0, 0);
   1.150 -			this.toolBar.Name = "toolBar";
   1.151 -			this.toolBar.ShowToolTips = true;
   1.152 -			this.toolBar.Size = new System.Drawing.Size(240, 28);
   1.153 -			this.toolBar.TabIndex = 3;
   1.154 -			this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick);
   1.155 -			// 
   1.156 -			// bttnEdit
   1.157 -			// 
   1.158 -			this.bttnEdit.Enabled = false;
   1.159 -			this.bttnEdit.ImageIndex = 0;
   1.160 -			this.bttnEdit.Name = "bttnEdit";
   1.161 -			// 
   1.162 -			// bttnDelete
   1.163 -			// 
   1.164 -			this.bttnDelete.Enabled = false;
   1.165 -			this.bttnDelete.ImageIndex = 1;
   1.166 -			this.bttnDelete.Name = "bttnDelete";
   1.167 -			// 
   1.168 -			// treeView
   1.169 -			// 
   1.170 -			this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles) ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
   1.171 -						| System.Windows.Forms.AnchorStyles.Left)
   1.172 -						| System.Windows.Forms.AnchorStyles.Right)));
   1.173 -			this.treeView.ContextMenu = this.contextMenu;
   1.174 -			this.treeView.FullRowSelect = true;
   1.175 -			this.treeView.Location = new System.Drawing.Point(0, 28);
   1.176 -			this.treeView.Name = "treeView";
   1.177 -			this.treeView.Size = new System.Drawing.Size(240, 250);
   1.178 -			this.treeView.TabIndex = 0;
   1.179 -			this.treeView.DoubleClick += new System.EventHandler(this.treeView_DoubleClick);
   1.180 -			this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
   1.181 -			this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown);
   1.182 -			// 
   1.183 -			// FrmArmyTree
   1.184 -			// 
   1.185 -			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
   1.186 -			this.ClientSize = new System.Drawing.Size(240, 277);
   1.187 -			this.ControlBox = false;
   1.188 -			this.Controls.Add(this.toolBar);
   1.189 -			this.Controls.Add(this.treeView);
   1.190 -			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
   1.191 -			this.MaximizeBox = false;
   1.192 -			this.MinimizeBox = false;
   1.193 -			this.Name = "FrmArmyTree";
   1.194 -			this.Text = "FrmArmyTree";
   1.195 -			this.ResumeLayout(false);
   1.196 -			this.PerformLayout();
   1.197 -
   1.198 -		}
   1.199 -		#endregion
   1.200 -
   1.201 -		private void ClearArmy()
   1.202 -		{
   1.203 -			nodes.Clear();
   1.204 -			treeView.Nodes.Clear();
   1.205 -		}
   1.206 -
   1.207 -		private void SetArmy(Army army)
   1.208 -		{
   1.209 -			ClearArmy();
   1.210 -
   1.211 -			if (army != null)
   1.212 -			{
   1.213 -				ArmyCategory[] cats = army.Categories;
   1.214 -				TreeNode[] catNodes = new TreeNode[cats.Length];
   1.215 -				Unit[] units;
   1.216 -
   1.217 -				for (int i = 0; i < cats.Length; i++)
   1.218 -				{
   1.219 -					units = army.GetUnits(cats[i]);
   1.220 -					cats[i].NameChanged += TreeNameChangedMethod;
   1.221 -					TreeNode[] unitNodes = new TreeNode[units.Length];
   1.222 -					TreeNode temp;
   1.223 -
   1.224 -					for (int j = 0; j < units.Length; j++)
   1.225 -					{
   1.226 -						unitNodes[j] = CreateTreeNode(units[j]);
   1.227 -					}
   1.228 -
   1.229 -					temp = new TreeNode(cats[i].Name, unitNodes);
   1.230 -					temp.Tag = cats[i];
   1.231 -					catNodes[i] = temp;
   1.232 -					nodes[cats[i].ID] = temp;
   1.233 +using IBBoard.Lang;
   1.234 +using IBBoard.Windows.Forms.I18N;
   1.235 +using IBBoard.Windows.Forms;
   1.236 +using IBBoard.WarFoundry.API;
   1.237 +using IBBoard.WarFoundry.API.Commands;
   1.238 +using IBBoard.WarFoundry.API.Objects;
   1.239 +
   1.240 +namespace IBBoard.WarFoundry.GUI.WinForms
   1.241 +{
   1.242 +	/// <summary>
   1.243 +	/// Summary description for FrmArmyTree.
   1.244 +	/// </summary>
   1.245 +	public class FrmArmyTree : IBBoard.Windows.Forms.IBBForm
   1.246 +	{
   1.247 +		private System.Windows.Forms.TreeView treeView;
   1.248 +		private IContainer components;
   1.249 +		private Dictionary<string, TreeNode> nodes;
   1.250 +		private System.Windows.Forms.ContextMenu contextMenu;
   1.251 +		private IBBMenuItem miDelete;
   1.252 +		private IBBMenuItem miEdit;
   1.253 +		
   1.254 +		private ObjectAddDelegate UnitAddedMethod;
   1.255 +		private ObjectRemoveDelegate UnitRemovedMethod;
   1.256 +		private StringValChangedDelegate UnitNameChangedMethod, ArmyNameChangedMethod, TreeNameChangedMethod;
   1.257 +		private ToolBar toolBar;
   1.258 +		private IBBToolBarButton bttnEdit;
   1.259 +		private IBBToolBarButton bttnDelete;
   1.260 +		private ImageList imageList;
   1.261 +		private CommandStack commandStack;
   1.262 +
   1.263 +		public FrmArmyTree(CommandStack cmdStack)
   1.264 +		{
   1.265 +			commandStack = cmdStack;
   1.266 +			InitializeComponent();
   1.267 +			UnitAddedMethod = new ObjectAddDelegate(UnitAdded);
   1.268 +			UnitRemovedMethod = new ObjectRemoveDelegate(UnitRemoved);
   1.269 +			UnitNameChangedMethod = new StringValChangedDelegate(UpdateUnitName);
   1.270 +			ArmyNameChangedMethod = new StringValChangedDelegate(UpdateArmyName);
   1.271 +			TreeNameChangedMethod = new StringValChangedDelegate(FrmArmyTree_TreeNameChanged);
   1.272 +			nodes = new Dictionary<string, TreeNode>();
   1.273 +			this.Name = "ArmyTree";			
   1.274 +			WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(FrmArmyTree_ArmyChanged);
   1.275 +
   1.276 +			foreach (Control ctrl in Controls)
   1.277 +			{
   1.278 +				ControlTranslator.TranslateControl(ctrl);
   1.279 +			}
   1.280 +
   1.281 +			foreach (Component comp in components.Components)
   1.282 +			{
   1.283 +				ControlTranslator.TranslateComponent(comp);
   1.284 +			}
   1.285 +
   1.286 +			foreach (IBBMenuItem mi in contextMenu.MenuItems)
   1.287 +			{
   1.288 +				ControlTranslator.TranslateComponent(mi);
   1.289 +			}
   1.290 +		}
   1.291 +
   1.292 +		/// <summary>
   1.293 +		/// Clean up any resources being used.
   1.294 +		/// </summary>
   1.295 +		protected override void Dispose( bool disposing )
   1.296 +		{
   1.297 +			if( disposing )
   1.298 +			{
   1.299 +				if(components != null)
   1.300 +				{
   1.301 +					components.Dispose();
   1.302 +				}
   1.303 +			}
   1.304 +			base.Dispose( disposing );
   1.305 +		}
   1.306 +
   1.307 +		#region Windows Form Designer generated code
   1.308 +		/// <summary>
   1.309 +		/// Required method for Designer support - do not modify
   1.310 +		/// the contents of this method with the code editor.
   1.311 +		/// </summary>
   1.312 +		private void InitializeComponent()
   1.313 +		{
   1.314 +			this.components = new System.ComponentModel.Container();
   1.315 +			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmArmyTree));
   1.316 +			this.contextMenu = new System.Windows.Forms.ContextMenu();
   1.317 +			this.miEdit = new IBBoard.Windows.Forms.IBBMenuItem();
   1.318 +			this.miDelete = new IBBoard.Windows.Forms.IBBMenuItem();
   1.319 +			this.imageList = new System.Windows.Forms.ImageList(this.components);
   1.320 +			this.toolBar = new System.Windows.Forms.ToolBar();
   1.321 +			this.bttnEdit = new IBBoard.Windows.Forms.IBBToolBarButton();
   1.322 +			this.bttnDelete = new IBBoard.Windows.Forms.IBBToolBarButton();
   1.323 +			this.treeView = new System.Windows.Forms.TreeView();
   1.324 +			this.SuspendLayout();
   1.325 +			// 
   1.326 +			// contextMenu
   1.327 +			// 
   1.328 +			this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
   1.329 +            this.miEdit,
   1.330 +            this.miDelete});
   1.331 +			this.contextMenu.Popup += new System.EventHandler(this.contextMenu_Popup);
   1.332 +			// 
   1.333 +			// miEdit
   1.334 +			// 
   1.335 +			this.miEdit.Index = 0;
   1.336 +			this.miEdit.Text = "&edit unit";
   1.337 +			this.miEdit.Click += new System.EventHandler(this.miEdit_Click);
   1.338 +			// 
   1.339 +			// miDelete
   1.340 +			// 
   1.341 +			this.miDelete.Index = 1;
   1.342 +			this.miDelete.Text = "&delete unit";
   1.343 +			this.miDelete.Click += new System.EventHandler(this.miDelete_Click);
   1.344 +			// 
   1.345 +			// imageList
   1.346 +			// 
   1.347 +			this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer) (resources.GetObject("imageList.ImageStream")));
   1.348 +			this.imageList.TransparentColor = System.Drawing.Color.Transparent;
   1.349 +			this.imageList.Images.SetKeyName(0, "gtk-edit.png");
   1.350 +			this.imageList.Images.SetKeyName(1, "edit-delete.png");
   1.351 +			// 
   1.352 +			// toolBar
   1.353 +			// 
   1.354 +			this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
   1.355 +            this.bttnEdit,
   1.356 +            this.bttnDelete});
   1.357 +			this.toolBar.ButtonSize = new System.Drawing.Size(16, 16);
   1.358 +			this.toolBar.DropDownArrows = true;
   1.359 +			this.toolBar.ImageList = this.imageList;
   1.360 +			this.toolBar.Location = new System.Drawing.Point(0, 0);
   1.361 +			this.toolBar.Name = "toolBar";
   1.362 +			this.toolBar.ShowToolTips = true;
   1.363 +			this.toolBar.Size = new System.Drawing.Size(240, 28);
   1.364 +			this.toolBar.TabIndex = 3;
   1.365 +			this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick);
   1.366 +			// 
   1.367 +			// bttnEdit
   1.368 +			// 
   1.369 +			this.bttnEdit.Enabled = false;
   1.370 +			this.bttnEdit.ImageIndex = 0;
   1.371 +			this.bttnEdit.Name = "bttnEdit";
   1.372 +			// 
   1.373 +			// bttnDelete
   1.374 +			// 
   1.375 +			this.bttnDelete.Enabled = false;
   1.376 +			this.bttnDelete.ImageIndex = 1;
   1.377 +			this.bttnDelete.Name = "bttnDelete";
   1.378 +			// 
   1.379 +			// treeView
   1.380 +			// 
   1.381 +			this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles) ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
   1.382 +						| System.Windows.Forms.AnchorStyles.Left)
   1.383 +						| System.Windows.Forms.AnchorStyles.Right)));
   1.384 +			this.treeView.ContextMenu = this.contextMenu;
   1.385 +			this.treeView.FullRowSelect = true;
   1.386 +			this.treeView.Location = new System.Drawing.Point(0, 28);
   1.387 +			this.treeView.Name = "treeView";
   1.388 +			this.treeView.Size = new System.Drawing.Size(240, 250);
   1.389 +			this.treeView.TabIndex = 0;
   1.390 +			this.treeView.DoubleClick += new System.EventHandler(this.treeView_DoubleClick);
   1.391 +			this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
   1.392 +			this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown);
   1.393 +			// 
   1.394 +			// FrmArmyTree
   1.395 +			// 
   1.396 +			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
   1.397 +			this.ClientSize = new System.Drawing.Size(240, 277);
   1.398 +			this.ControlBox = false;
   1.399 +			this.Controls.Add(this.toolBar);
   1.400 +			this.Controls.Add(this.treeView);
   1.401 +			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
   1.402 +			this.MaximizeBox = false;
   1.403 +			this.MinimizeBox = false;
   1.404 +			this.Name = "FrmArmyTree";
   1.405 +			this.Text = "FrmArmyTree";
   1.406 +			this.ResumeLayout(false);
   1.407 +			this.PerformLayout();
   1.408 +
   1.409 +		}
   1.410 +		#endregion
   1.411 +
   1.412 +		private void ClearArmy()
   1.413 +		{
   1.414 +			nodes.Clear();
   1.415 +			treeView.Nodes.Clear();
   1.416 +		}
   1.417 +
   1.418 +		private void SetArmy(Army army)
   1.419 +		{
   1.420 +			ClearArmy();
   1.421 +
   1.422 +			if (army != null)
   1.423 +			{
   1.424 +				ArmyCategory[] cats = army.Categories;
   1.425 +				TreeNode[] catNodes = new TreeNode[cats.Length];
   1.426 +				Unit[] units;
   1.427 +
   1.428 +				for (int i = 0; i < cats.Length; i++)
   1.429 +				{
   1.430 +					ArmyCategory cat = cats[i];
   1.431 +					units = army.GetUnits(cat);
   1.432 +					cat.NameChanged += TreeNameChangedMethod;
   1.433 +					cat.PointsValueChanged += NodePointsValueChanged;
   1.434 +					TreeNode[] unitNodes = new TreeNode[units.Length];
   1.435 +					TreeNode temp;
   1.436 +
   1.437 +					for (int j = 0; j < units.Length; j++)
   1.438 +					{
   1.439 +						unitNodes[j] = CreateTreeNode(units[j]);
   1.440 +					}
   1.441 +
   1.442 +					temp = new TreeNode(CreateNodeName(cat), unitNodes);
   1.443 +					temp.Tag = cat;
   1.444 +					catNodes[i] = temp;
   1.445 +					nodes[cat.ID] = temp;
   1.446  				}
   1.447  
   1.448 -				TreeNode root = new TreeNode(army.Name, catNodes);
   1.449 +				TreeNode root = new TreeNode(CreateNodeName(army), catNodes);
   1.450  				root.Tag = army;
   1.451 -				treeView.Nodes.Add(root);
   1.452 -				root.ExpandAll();
   1.453 -			}
   1.454 -		}
   1.455 -
   1.456 -		private TreeNode CreateTreeNode(Unit unit)
   1.457 +				army.PointsValueChanged += NodePointsValueChanged;
   1.458 +				nodes[army.ID] = root;
   1.459 +				treeView.Nodes.Add(root);
   1.460 +				root.ExpandAll();
   1.461 +			}
   1.462 +		}
   1.463 +		
   1.464 +		private string CreateNodeName(ICostedWarFoundryObject obj)
   1.465 +		{
   1.466 +			return Translation.GetTranslation("treeNodeText", "{0} ({1}pts)", obj.Name, obj.Points);
   1.467 +		}
   1.468 +
   1.469 +		private void NodePointsValueChanged(WarFoundryObject obj, double oldValue, double newValue)
   1.470  		{
   1.471 -			TreeNode temp = new TreeNode(unit.Name);
   1.472 -			temp.Tag = unit;
   1.473 -			unit.NameChanged+= UnitNameChangedMethod;
   1.474 -			nodes[unit.ID] = temp;
   1.475 -			return temp;
   1.476 -		}
   1.477 -
   1.478 -		public void FrmArmyTree_ArmyChanged(Army oldArmy, Army newArmy)
   1.479 +			if (obj is ICostedWarFoundryObject)
   1.480 +			{
   1.481 +				nodes[obj.ID].Text = CreateNodeName((ICostedWarFoundryObject)obj);
   1.482 +			}
   1.483 +		}
   1.484 +
   1.485 +		private TreeNode CreateTreeNode(Unit unit)
   1.486  		{
   1.487 -			if (oldArmy != null)
   1.488 -			{
   1.489 -				oldArmy.UnitAdded -= UnitAddedMethod;
   1.490 -				oldArmy.UnitRemoved -= UnitRemovedMethod;
   1.491 -			}
   1.492 -
   1.493 -			if (newArmy != null)
   1.494 -			{
   1.495 -				newArmy.UnitAdded += UnitAddedMethod;
   1.496 -				newArmy.UnitRemoved += UnitRemovedMethod;
   1.497 -			}
   1.498 -
   1.499 -			SetArmy(newArmy);
   1.500 -		}
   1.501 -
   1.502 -		private void UnitAdded(WarFoundryObject obj)
   1.503 -		{
   1.504 -			if (obj is Unit)
   1.505 -			{
   1.506 -				Unit unit = (Unit)obj;
   1.507 -				ArmyCategory cat = unit.Category;
   1.508 -				TreeNode parent = nodes[cat.ID];
   1.509 -				TreeNode unitNode = CreateTreeNode(unit);
   1.510 -				parent.Nodes.Add(unitNode);
   1.511 -				parent.Expand(); //make sure it's expanded
   1.512 -			}
   1.513 -		}
   1.514 -
   1.515 -		public new FrmMain MdiParent
   1.516 -		{
   1.517 -			get { return (FrmMain) base.MdiParent; }
   1.518 -			set { base.MdiParent = value; }
   1.519 -		}
   1.520 -
   1.521 -		private void UnitRemoved(WarFoundryObject obj)
   1.522 -		{
   1.523 -			if (obj is Unit)
   1.524 -			{
   1.525 -				Unit unit = (Unit)obj;
   1.526 -				RemoveUnitFromTree(unit);
   1.527 -			}
   1.528 -		}
   1.529 -
   1.530 -		private void RemoveUnitFromTree(Unit unit)
   1.531 -		{
   1.532 -			TreeNode unitNode = nodes[unit.ID];
   1.533 -			unit.NameChanged-= UnitNameChangedMethod;
   1.534 -
   1.535 -			if (unitNode!=null)
   1.536 -			{
   1.537 -				unitNode.Remove();
   1.538 -				nodes.Remove(unit.ID);
   1.539 -			}
   1.540 -		}
   1.541 -
   1.542 -
   1.543 -		private void contextMenu_Popup(object sender, System.EventArgs e)
   1.544 -		{
   1.545 -			TreeNode node = treeView.SelectedNode;
   1.546 -
   1.547 -			if (node!=null && node.Tag is Unit)
   1.548 -			{
   1.549 -				foreach(MenuItem item in contextMenu.MenuItems)
   1.550 -				{
   1.551 -					item.Visible = true;
   1.552 -				}
   1.553 -			}
   1.554 -			else
   1.555 -			{
   1.556 -				foreach(MenuItem item in contextMenu.MenuItems)
   1.557 -				{
   1.558 -					item.Visible = false;
   1.559 -				}
   1.560 -			}
   1.561 -		}
   1.562 -
   1.563 -		private void treeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   1.564 -		{
   1.565 -			if (e.Button == MouseButtons.Right)
   1.566 -			{
   1.567 -				TreeNode tn = treeView.GetNodeAt(e.X, e.Y);
   1.568 -
   1.569 -				if (tn!=null)
   1.570 -				{
   1.571 -					treeView.SelectedNode = tn;
   1.572 -				}
   1.573 -				else
   1.574 -				{
   1.575 -					treeView.SelectedNode = null;
   1.576 -				}
   1.577 -			}
   1.578 -		}
   1.579 -
   1.580 -		private void miDelete_Click(object sender, System.EventArgs e)
   1.581 -		{
   1.582 -			DeleteUnit();
   1.583 -		}
   1.584 -
   1.585 -		private void DeleteUnit()
   1.586 -		{
   1.587 -
   1.588 -			TreeNode selected = treeView.SelectedNode;
   1.589 -
   1.590 -			if (selected.Tag != null && selected.Tag is Unit)
   1.591 -			{
   1.592 -				Unit unit = (Unit) selected.Tag;
   1.593 -				commandStack.Execute(new RemoveUnitCommand(unit));
   1.594 -			}
   1.595 -		}
   1.596 -
   1.597 -		private void miEdit_Click(object sender, System.EventArgs e)
   1.598 -		{	
   1.599 -			EditUnit();
   1.600 -		}
   1.601 -
   1.602 -		private void treeView_DoubleClick(object sender, System.EventArgs e)
   1.603 -		{
   1.604 -			EditUnit();			
   1.605 -		}
   1.606 -
   1.607 -		private void EditUnit()
   1.608 -		{
   1.609 -			TreeNode selected = treeView.SelectedNode;
   1.610 -			object tagData = selected.Tag;
   1.611 -
   1.612 -			if (tagData is Unit)
   1.613 -			{
   1.614 -				Unit unit = (Unit) tagData;
   1.615 -				MdiParent.OpenUnitDialog(unit);
   1.616 -			}
   1.617 -		}
   1.618 -
   1.619 -		private void UpdateUnitName(WarFoundryObject obj, string oldValue, string newValue)
   1.620 -		{
   1.621 -			if (obj is Unit)
   1.622 -			{
   1.623 -				Unit unit = (Unit)obj;
   1.624 -				TreeNode node = nodes[unit.ID];
   1.625 -				
   1.626 -				if (node!=null)
   1.627 -				{
   1.628 -					node.Text = unit.Name;
   1.629 -				}
   1.630 -			}
   1.631 -		}
   1.632 -
   1.633 -		private void UpdateArmyName(WarFoundryObject obj, string oldValue, string newValue)
   1.634 -		{
   1.635 -			if (obj is Army)
   1.636 -			{
   1.637 -				Army army = (Army)obj;
   1.638 -				TreeNode node = treeView.Nodes[0];
   1.639 -				
   1.640 -				if (node!=null)
   1.641 -				{
   1.642 -					node.Text = army.Name;
   1.643 -				}
   1.644 -			}
   1.645 -		}
   1.646 -
   1.647 -		private void FrmArmyTree_TreeNameChanged(WarFoundryObject obj, string oldValue, string newValue)
   1.648 -		{
   1.649 -			TreeNode node = nodes[obj.ID];
   1.650 -
   1.651 -			if (node!=null)
   1.652 -			{
   1.653 -				node.Text = obj.Name;
   1.654 -			}
   1.655 -		}
   1.656 -
   1.657 -		private void toolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
   1.658 -		{
   1.659 -			if (e.Button == bttnDelete)
   1.660 -			{
   1.661 -				DeleteUnit();
   1.662 -			}
   1.663 -			else if (e.Button == bttnEdit)
   1.664 -			{
   1.665 -				EditUnit();
   1.666 -			}
   1.667 -		}
   1.668 -
   1.669 -		private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
   1.670 -		{
   1.671 -			TreeNode node = treeView.SelectedNode;
   1.672 -
   1.673 -			bttnDelete.Enabled = (node != null && node.Tag is Unit);
   1.674 -			bttnEdit.Enabled = bttnDelete.Enabled;
   1.675 -		}
   1.676 -	}
   1.677 -}
   1.678 +			TreeNode temp = new TreeNode(CreateNodeName(unit));
   1.679 +			temp.Tag = unit;
   1.680 +			unit.NameChanged+= UnitNameChangedMethod;
   1.681 +			unit.PointsValueChanged += NodePointsValueChanged;
   1.682 +			nodes[unit.ID] = temp;
   1.683 +			return temp;
   1.684 +		}
   1.685 +
   1.686 +		public void FrmArmyTree_ArmyChanged(Army oldArmy, Army newArmy)
   1.687 +		{
   1.688 +			if (oldArmy != null)
   1.689 +			{
   1.690 +				oldArmy.UnitAdded -= UnitAddedMethod;
   1.691 +				oldArmy.UnitRemoved -= UnitRemovedMethod;
   1.692 +				oldArmy.PointsValueChanged -= NodePointsValueChanged;
   1.693 +			}
   1.694 +
   1.695 +			if (newArmy != null)
   1.696 +			{
   1.697 +				newArmy.UnitAdded += UnitAddedMethod;
   1.698 +				newArmy.UnitRemoved += UnitRemovedMethod;
   1.699 +				newArmy.PointsValueChanged += NodePointsValueChanged;
   1.700 +			}
   1.701 +
   1.702 +			SetArmy(newArmy);
   1.703 +		}
   1.704 +
   1.705 +		private void UnitAdded(WarFoundryObject obj)
   1.706 +		{
   1.707 +			if (obj is Unit)
   1.708 +			{
   1.709 +				Unit unit = (Unit)obj;
   1.710 +				ArmyCategory cat = unit.Category;
   1.711 +				TreeNode parent = nodes[cat.ID];
   1.712 +				TreeNode unitNode = CreateTreeNode(unit);
   1.713 +				parent.Nodes.Add(unitNode);
   1.714 +				parent.Expand(); //make sure it's expanded
   1.715 +			}
   1.716 +		}
   1.717 +
   1.718 +		public new FrmMain MdiParent
   1.719 +		{
   1.720 +			get { return (FrmMain) base.MdiParent; }
   1.721 +			set { base.MdiParent = value; }
   1.722 +		}
   1.723 +
   1.724 +		private void UnitRemoved(WarFoundryObject obj)
   1.725 +		{
   1.726 +			if (obj is Unit)
   1.727 +			{
   1.728 +				Unit unit = (Unit)obj;
   1.729 +				RemoveUnitFromTree(unit);
   1.730 +			}
   1.731 +		}
   1.732 +
   1.733 +		private void RemoveUnitFromTree(Unit unit)
   1.734 +		{
   1.735 +			TreeNode unitNode = nodes[unit.ID];
   1.736 +			unit.NameChanged-= UnitNameChangedMethod;
   1.737 +
   1.738 +			if (unitNode!=null)
   1.739 +			{
   1.740 +				unitNode.Remove();
   1.741 +				nodes.Remove(unit.ID);
   1.742 +			}
   1.743 +		}
   1.744 +
   1.745 +
   1.746 +		private void contextMenu_Popup(object sender, System.EventArgs e)
   1.747 +		{
   1.748 +			TreeNode node = treeView.SelectedNode;
   1.749 +
   1.750 +			if (node!=null && node.Tag is Unit)
   1.751 +			{
   1.752 +				foreach(MenuItem item in contextMenu.MenuItems)
   1.753 +				{
   1.754 +					item.Visible = true;
   1.755 +				}
   1.756 +			}
   1.757 +			else
   1.758 +			{
   1.759 +				foreach(MenuItem item in contextMenu.MenuItems)
   1.760 +				{
   1.761 +					item.Visible = false;
   1.762 +				}
   1.763 +			}
   1.764 +		}
   1.765 +
   1.766 +		private void treeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
   1.767 +		{
   1.768 +			if (e.Button == MouseButtons.Right)
   1.769 +			{
   1.770 +				TreeNode tn = treeView.GetNodeAt(e.X, e.Y);
   1.771 +
   1.772 +				if (tn!=null)
   1.773 +				{
   1.774 +					treeView.SelectedNode = tn;
   1.775 +				}
   1.776 +				else
   1.777 +				{
   1.778 +					treeView.SelectedNode = null;
   1.779 +				}
   1.780 +			}
   1.781 +		}
   1.782 +
   1.783 +		private void miDelete_Click(object sender, System.EventArgs e)
   1.784 +		{
   1.785 +			DeleteUnit();
   1.786 +		}
   1.787 +
   1.788 +		private void DeleteUnit()
   1.789 +		{
   1.790 +
   1.791 +			TreeNode selected = treeView.SelectedNode;
   1.792 +
   1.793 +			if (selected.Tag != null && selected.Tag is Unit)
   1.794 +			{
   1.795 +				Unit unit = (Unit) selected.Tag;
   1.796 +				commandStack.Execute(new RemoveUnitCommand(unit));
   1.797 +			}
   1.798 +		}
   1.799 +
   1.800 +		private void miEdit_Click(object sender, System.EventArgs e)
   1.801 +		{	
   1.802 +			EditUnit();
   1.803 +		}
   1.804 +
   1.805 +		private void treeView_DoubleClick(object sender, System.EventArgs e)
   1.806 +		{
   1.807 +			EditUnit();			
   1.808 +		}
   1.809 +
   1.810 +		private void EditUnit()
   1.811 +		{
   1.812 +			TreeNode selected = treeView.SelectedNode;
   1.813 +			object tagData = selected.Tag;
   1.814 +
   1.815 +			if (tagData is Unit)
   1.816 +			{
   1.817 +				Unit unit = (Unit) tagData;
   1.818 +				MdiParent.OpenUnitDialog(unit);
   1.819 +			}
   1.820 +		}
   1.821 +
   1.822 +		private void UpdateUnitName(WarFoundryObject obj, string oldValue, string newValue)
   1.823 +		{
   1.824 +			if (obj is Unit)
   1.825 +			{
   1.826 +				Unit unit = (Unit)obj;
   1.827 +				TreeNode node = nodes[unit.ID];
   1.828 +				
   1.829 +				if (node!=null)
   1.830 +				{
   1.831 +					node.Text = unit.Name;
   1.832 +				}
   1.833 +			}
   1.834 +		}
   1.835 +
   1.836 +		private void UpdateArmyName(WarFoundryObject obj, string oldValue, string newValue)
   1.837 +		{
   1.838 +			if (obj is Army)
   1.839 +			{
   1.840 +				Army army = (Army)obj;
   1.841 +				TreeNode node = treeView.Nodes[0];
   1.842 +				
   1.843 +				if (node!=null)
   1.844 +				{
   1.845 +					node.Text = army.Name;
   1.846 +				}
   1.847 +			}
   1.848 +		}
   1.849 +
   1.850 +		private void FrmArmyTree_TreeNameChanged(WarFoundryObject obj, string oldValue, string newValue)
   1.851 +		{
   1.852 +			TreeNode node = nodes[obj.ID];
   1.853 +
   1.854 +			if (node!=null)
   1.855 +			{
   1.856 +				node.Text = obj.Name;
   1.857 +			}
   1.858 +		}
   1.859 +
   1.860 +		private void toolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
   1.861 +		{
   1.862 +			if (e.Button == bttnDelete)
   1.863 +			{
   1.864 +				DeleteUnit();
   1.865 +			}
   1.866 +			else if (e.Button == bttnEdit)
   1.867 +			{
   1.868 +				EditUnit();
   1.869 +			}
   1.870 +		}
   1.871 +
   1.872 +		private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
   1.873 +		{
   1.874 +			TreeNode node = treeView.SelectedNode;
   1.875 +
   1.876 +			bttnDelete.Enabled = (node != null && node.Tag is Unit);
   1.877 +			bttnEdit.Enabled = bttnDelete.Enabled;
   1.878 +		}
   1.879 +	}
   1.880 +}
     2.1 --- a/FrmMain.cs	Sat Sep 19 16:01:43 2009 +0000
     2.2 +++ b/FrmMain.cs	Sat Sep 19 19:44:45 2009 +0000
     2.3 @@ -1160,9 +1160,9 @@
     2.4  			}
     2.5  			else 
     2.6  			{
     2.7 -				sbPointsPanel.Text = String.Format(Translation.GetTranslation("statusPanelPoints"), CurrentArmy.PointsTotal, CurrentArmy.MaxPoints);
     2.8 +				sbPointsPanel.Text = String.Format(Translation.GetTranslation("statusPanelPoints"), CurrentArmy.Points, CurrentArmy.MaxPoints);
     2.9  
    2.10 -				if (CurrentArmy.PointsTotal>CurrentArmy.MaxPoints)
    2.11 +				if (CurrentArmy.Points>CurrentArmy.MaxPoints)
    2.12  				{
    2.13  					sbPointsPanel.Color = Color.Red;
    2.14  				}
     3.1 --- a/FrmUnit.cs	Sat Sep 19 16:01:43 2009 +0000
     3.2 +++ b/FrmUnit.cs	Sat Sep 19 19:44:45 2009 +0000
     3.3 @@ -84,7 +84,7 @@
     3.4  
     3.5  		private void SetPointsValueText()
     3.6  		{
     3.7 -			lblPoints.Text = "(" + unit.PointsValue + " pts)";
     3.8 +			lblPoints.Text = "(" + unit.Points + " pts)";
     3.9  		}
    3.10  
    3.11  		private void SetStats()
     4.1 --- a/WarFoundry.exe.log4net	Sat Sep 19 16:01:43 2009 +0000
     4.2 +++ b/WarFoundry.exe.log4net	Sat Sep 19 19:44:45 2009 +0000
     4.3 @@ -1,16 +1,25 @@
     4.4 -<?xml version="1.0" encoding="utf-8" ?>
     4.5 -<!-- This section contains the log4net configuration settings -->
     4.6 -<log4net>
     4.7 -    <!-- Define some output appenders -->	
     4.8 -    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
     4.9 -        <layout type="log4net.Layout.PatternLayout">
    4.10 -            <param name="ConversionPattern" value="%-5p [%d{HH:MM:ss}]: %C{1}.%M() - Line: %L - %m%n" />
    4.11 -        </layout>
    4.12 -    </appender>
    4.13 -    <!-- Setup the root category, add the appenders and set the default priority -->
    4.14 -    <root>
    4.15 -        <level value="DEBUG" />
    4.16 -        <appender-ref ref="ConsoleAppender" />
    4.17 -    </root>
    4.18 -</log4net>
    4.19 -
    4.20 +<?xml version="1.0" encoding="utf-8" ?>
    4.21 +<!-- This section contains the log4net configuration settings -->
    4.22 +<log4net>
    4.23 +	<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
    4.24 +		<layout type="log4net.Layout.PatternLayout">
    4.25 +			<param name="ConversionPattern" value="%-5p [%d{HH:MM:ss}]: %C{1}.%M() - Line: %L - %m%n" />
    4.26 +		</layout>
    4.27 +	</appender>
    4.28 +	<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    4.29 +		<file value="logfile.txt" />
    4.30 +		<appendToFile value="false" />
    4.31 +		<rollingStyle value="Size" />
    4.32 +		<maxSizeRollBackups value="-1" />
    4.33 +		<maximumFileSize value="100MB" />
    4.34 +		<layout type="log4net.Layout.PatternLayout">
    4.35 +			<conversionPattern value="%-5p [%d{HH:MM:ss}]: %C{1}.%M() - Line: %L - %m%n" />
    4.36 +		</layout>
    4.37 +	</appender>
    4.38 +	<root>
    4.39 +		<level value="DEBUG" />
    4.40 +		<appender-ref ref="ConsoleAppender" />
    4.41 +		<appender-ref ref="RollingLogFileAppender" />
    4.42 +	</root>
    4.43 +</log4net>
    4.44 +