annotate FrmArmyTree.cs @ 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
62
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
1 // This file (FrmArmyTree.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
2 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
3 // 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.
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
4
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
5 using System;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
6 using System.Drawing;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
7 using System.Collections.Generic;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
8 using System.ComponentModel;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
9 using System.Windows.Forms;
33
67c283ea77a7 * Code cleanup (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
10 using IBBoard.Commands;
62
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
11 using IBBoard.Lang;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
12 using IBBoard.Windows.Forms.I18N;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
13 using IBBoard.Windows.Forms;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
14 using IBBoard.WarFoundry.API;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
15 using IBBoard.WarFoundry.API.Commands;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
16 using IBBoard.WarFoundry.API.Objects;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
17
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
18 namespace IBBoard.WarFoundry.GUI.WinForms
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
19 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
20 /// <summary>
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
21 /// Summary description for FrmArmyTree.
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
22 /// </summary>
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
23 public class FrmArmyTree : IBBoard.Windows.Forms.IBBForm
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
24 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
25 private System.Windows.Forms.TreeView treeView;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
26 private IContainer components;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
27 private Dictionary<string, TreeNode> nodes;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
28 private System.Windows.Forms.ContextMenu contextMenu;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
29 private IBBMenuItem miDelete;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
30 private IBBMenuItem miEdit;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
31
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
32 private ObjectAddDelegate UnitAddedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
33 private ObjectRemoveDelegate UnitRemovedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
34 private StringValChangedDelegate UnitNameChangedMethod, ArmyNameChangedMethod, TreeNameChangedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
35 private ToolBar toolBar;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
36 private IBBToolBarButton bttnEdit;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
37 private IBBToolBarButton bttnDelete;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
38 private ImageList imageList;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
39 private CommandStack commandStack;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
40
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
41 public FrmArmyTree(CommandStack cmdStack)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
42 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
43 commandStack = cmdStack;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
44 InitializeComponent();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
45 UnitAddedMethod = new ObjectAddDelegate(UnitAdded);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
46 UnitRemovedMethod = new ObjectRemoveDelegate(UnitRemoved);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
47 UnitNameChangedMethod = new StringValChangedDelegate(UpdateUnitName);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
48 ArmyNameChangedMethod = new StringValChangedDelegate(UpdateArmyName);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
49 TreeNameChangedMethod = new StringValChangedDelegate(FrmArmyTree_TreeNameChanged);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
50 nodes = new Dictionary<string, TreeNode>();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
51 this.Name = "ArmyTree";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
52 WarFoundryCore.ArmyChanged+= new ArmyChangedDelegate(FrmArmyTree_ArmyChanged);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
53
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
54 foreach (Control ctrl in Controls)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
55 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
56 ControlTranslator.TranslateControl(ctrl);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
57 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
58
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
59 foreach (Component comp in components.Components)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
60 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
61 ControlTranslator.TranslateComponent(comp);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
62 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
63
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
64 foreach (IBBMenuItem mi in contextMenu.MenuItems)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
65 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
66 ControlTranslator.TranslateComponent(mi);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
67 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
68 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
69
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
70 /// <summary>
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
71 /// Clean up any resources being used.
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
72 /// </summary>
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
73 protected override void Dispose( bool disposing )
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
74 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
75 if( disposing )
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
76 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
77 if(components != null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
78 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
79 components.Dispose();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
80 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
81 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
82 base.Dispose( disposing );
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
83 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
84
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
85 #region Windows Form Designer generated code
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
86 /// <summary>
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
87 /// Required method for Designer support - do not modify
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
88 /// the contents of this method with the code editor.
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
89 /// </summary>
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
90 private void InitializeComponent()
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
91 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
92 this.components = new System.ComponentModel.Container();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
93 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmArmyTree));
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
94 this.contextMenu = new System.Windows.Forms.ContextMenu();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
95 this.miEdit = new IBBoard.Windows.Forms.IBBMenuItem();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
96 this.miDelete = new IBBoard.Windows.Forms.IBBMenuItem();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
97 this.imageList = new System.Windows.Forms.ImageList(this.components);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
98 this.toolBar = new System.Windows.Forms.ToolBar();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
99 this.bttnEdit = new IBBoard.Windows.Forms.IBBToolBarButton();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
100 this.bttnDelete = new IBBoard.Windows.Forms.IBBToolBarButton();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
101 this.treeView = new System.Windows.Forms.TreeView();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
102 this.SuspendLayout();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
103 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
104 // contextMenu
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
105 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
106 this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
107 this.miEdit,
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
108 this.miDelete});
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
109 this.contextMenu.Popup += new System.EventHandler(this.contextMenu_Popup);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
110 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
111 // miEdit
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
112 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
113 this.miEdit.Index = 0;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
114 this.miEdit.Text = "&edit unit";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
115 this.miEdit.Click += new System.EventHandler(this.miEdit_Click);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
116 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
117 // miDelete
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
118 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
119 this.miDelete.Index = 1;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
120 this.miDelete.Text = "&delete unit";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
121 this.miDelete.Click += new System.EventHandler(this.miDelete_Click);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
122 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
123 // imageList
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
124 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
125 this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer) (resources.GetObject("imageList.ImageStream")));
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
126 this.imageList.TransparentColor = System.Drawing.Color.Transparent;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
127 this.imageList.Images.SetKeyName(0, "gtk-edit.png");
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
128 this.imageList.Images.SetKeyName(1, "edit-delete.png");
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
129 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
130 // toolBar
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
131 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
132 this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
133 this.bttnEdit,
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
134 this.bttnDelete});
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
135 this.toolBar.ButtonSize = new System.Drawing.Size(16, 16);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
136 this.toolBar.DropDownArrows = true;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
137 this.toolBar.ImageList = this.imageList;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
138 this.toolBar.Location = new System.Drawing.Point(0, 0);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
139 this.toolBar.Name = "toolBar";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
140 this.toolBar.ShowToolTips = true;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
141 this.toolBar.Size = new System.Drawing.Size(240, 28);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
142 this.toolBar.TabIndex = 3;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
143 this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
144 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
145 // bttnEdit
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
146 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
147 this.bttnEdit.Enabled = false;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
148 this.bttnEdit.ImageIndex = 0;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
149 this.bttnEdit.Name = "bttnEdit";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
150 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
151 // bttnDelete
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
152 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
153 this.bttnDelete.Enabled = false;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
154 this.bttnDelete.ImageIndex = 1;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
155 this.bttnDelete.Name = "bttnDelete";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
156 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
157 // treeView
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
158 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
159 this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles) ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
160 | System.Windows.Forms.AnchorStyles.Left)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
161 | System.Windows.Forms.AnchorStyles.Right)));
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
162 this.treeView.ContextMenu = this.contextMenu;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
163 this.treeView.FullRowSelect = true;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
164 this.treeView.Location = new System.Drawing.Point(0, 28);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
165 this.treeView.Name = "treeView";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
166 this.treeView.Size = new System.Drawing.Size(240, 250);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
167 this.treeView.TabIndex = 0;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
168 this.treeView.DoubleClick += new System.EventHandler(this.treeView_DoubleClick);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
169 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
170 this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
171 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
172 // FrmArmyTree
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
173 //
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
174 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
175 this.ClientSize = new System.Drawing.Size(240, 277);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
176 this.ControlBox = false;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
177 this.Controls.Add(this.toolBar);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
178 this.Controls.Add(this.treeView);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
179 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
180 this.MaximizeBox = false;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
181 this.MinimizeBox = false;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
182 this.Name = "FrmArmyTree";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
183 this.Text = "FrmArmyTree";
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
184 this.ResumeLayout(false);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
185 this.PerformLayout();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
186
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
187 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
188 #endregion
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
189
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
190 private void ClearArmy()
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
191 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
192 nodes.Clear();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
193 treeView.Nodes.Clear();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
194 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
195
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
196 private void SetArmy(Army army)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
197 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
198 ClearArmy();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
199
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
200 if (army != null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
201 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
202 ArmyCategory[] cats = army.Categories;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
203 TreeNode[] catNodes = new TreeNode[cats.Length];
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
204 Unit[] units;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
205
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
206 for (int i = 0; i < cats.Length; i++)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
207 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
208 ArmyCategory cat = cats[i];
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
209 units = army.GetUnits(cat);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
210 cat.NameChanged += TreeNameChangedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
211 cat.PointsValueChanged += NodePointsValueChanged;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
212 TreeNode[] unitNodes = new TreeNode[units.Length];
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
213 TreeNode temp;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
214
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
215 for (int j = 0; j < units.Length; j++)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
216 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
217 unitNodes[j] = CreateTreeNode(units[j]);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
218 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
219
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
220 temp = new TreeNode(CreateNodeName(cat), unitNodes);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
221 temp.Tag = cat;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
222 catNodes[i] = temp;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
223 nodes[cat.ID] = temp;
33
67c283ea77a7 * Code cleanup (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
224 }
67c283ea77a7 * Code cleanup (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
225
62
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
226 TreeNode root = new TreeNode(CreateNodeName(army), catNodes);
33
67c283ea77a7 * Code cleanup (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
227 root.Tag = army;
62
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
228 army.PointsValueChanged += NodePointsValueChanged;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
229 nodes[army.ID] = root;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
230 treeView.Nodes.Add(root);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
231 root.ExpandAll();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
232 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
233 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
234
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
235 private string CreateNodeName(ICostedWarFoundryObject obj)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
236 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
237 return Translation.GetTranslation("treeNodeText", "{0} ({1}pts)", obj.Name, obj.Points);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
238 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
239
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
240 private void NodePointsValueChanged(WarFoundryObject obj, double oldValue, double newValue)
61
a0ec03c24cd9 Fixes #171: Open unit form when unit is created
IBBoard <dev@ibboard.co.uk>
parents: 57
diff changeset
241 {
62
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
242 if (obj is ICostedWarFoundryObject)
33
67c283ea77a7 * Code cleanup (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
243 {
62
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
244 nodes[obj.ID].Text = CreateNodeName((ICostedWarFoundryObject)obj);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
245 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
246 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
247
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
248 private TreeNode CreateTreeNode(Unit unit)
33
67c283ea77a7 * Code cleanup (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
249 {
62
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
250 TreeNode temp = new TreeNode(CreateNodeName(unit));
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
251 temp.Tag = unit;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
252 unit.NameChanged+= UnitNameChangedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
253 unit.PointsValueChanged += NodePointsValueChanged;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
254 nodes[unit.ID] = temp;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
255 return temp;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
256 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
257
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
258 public void FrmArmyTree_ArmyChanged(Army oldArmy, Army newArmy)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
259 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
260 if (oldArmy != null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
261 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
262 oldArmy.UnitAdded -= UnitAddedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
263 oldArmy.UnitRemoved -= UnitRemovedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
264 oldArmy.PointsValueChanged -= NodePointsValueChanged;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
265 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
266
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
267 if (newArmy != null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
268 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
269 newArmy.UnitAdded += UnitAddedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
270 newArmy.UnitRemoved += UnitRemovedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
271 newArmy.PointsValueChanged += NodePointsValueChanged;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
272 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
273
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
274 SetArmy(newArmy);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
275 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
276
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
277 private void UnitAdded(WarFoundryObject obj)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
278 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
279 if (obj is Unit)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
280 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
281 Unit unit = (Unit)obj;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
282 ArmyCategory cat = unit.Category;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
283 TreeNode parent = nodes[cat.ID];
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
284 TreeNode unitNode = CreateTreeNode(unit);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
285 parent.Nodes.Add(unitNode);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
286 parent.Expand(); //make sure it's expanded
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
287 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
288 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
289
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
290 public new FrmMain MdiParent
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
291 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
292 get { return (FrmMain) base.MdiParent; }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
293 set { base.MdiParent = value; }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
294 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
295
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
296 private void UnitRemoved(WarFoundryObject obj)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
297 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
298 if (obj is Unit)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
299 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
300 Unit unit = (Unit)obj;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
301 RemoveUnitFromTree(unit);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
302 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
303 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
304
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
305 private void RemoveUnitFromTree(Unit unit)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
306 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
307 TreeNode unitNode = nodes[unit.ID];
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
308 unit.NameChanged-= UnitNameChangedMethod;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
309
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
310 if (unitNode!=null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
311 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
312 unitNode.Remove();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
313 nodes.Remove(unit.ID);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
314 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
315 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
316
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
317
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
318 private void contextMenu_Popup(object sender, System.EventArgs e)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
319 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
320 TreeNode node = treeView.SelectedNode;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
321
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
322 if (node!=null && node.Tag is Unit)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
323 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
324 foreach(MenuItem item in contextMenu.MenuItems)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
325 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
326 item.Visible = true;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
327 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
328 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
329 else
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
330 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
331 foreach(MenuItem item in contextMenu.MenuItems)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
332 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
333 item.Visible = false;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
334 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
335 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
336 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
337
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
338 private void treeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
339 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
340 if (e.Button == MouseButtons.Right)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
341 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
342 TreeNode tn = treeView.GetNodeAt(e.X, e.Y);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
343
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
344 if (tn!=null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
345 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
346 treeView.SelectedNode = tn;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
347 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
348 else
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
349 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
350 treeView.SelectedNode = null;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
351 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
352 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
353 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
354
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
355 private void miDelete_Click(object sender, System.EventArgs e)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
356 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
357 DeleteUnit();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
358 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
359
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
360 private void DeleteUnit()
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
361 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
362
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
363 TreeNode selected = treeView.SelectedNode;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
364
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
365 if (selected.Tag != null && selected.Tag is Unit)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
366 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
367 Unit unit = (Unit) selected.Tag;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
368 commandStack.Execute(new RemoveUnitCommand(unit));
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
369 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
370 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
371
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
372 private void miEdit_Click(object sender, System.EventArgs e)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
373 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
374 EditUnit();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
375 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
376
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
377 private void treeView_DoubleClick(object sender, System.EventArgs e)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
378 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
379 EditUnit();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
380 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
381
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
382 private void EditUnit()
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
383 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
384 TreeNode selected = treeView.SelectedNode;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
385 object tagData = selected.Tag;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
386
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
387 if (tagData is Unit)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
388 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
389 Unit unit = (Unit) tagData;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
390 MdiParent.OpenUnitDialog(unit);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
391 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
392 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
393
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
394 private void UpdateUnitName(WarFoundryObject obj, string oldValue, string newValue)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
395 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
396 if (obj is Unit)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
397 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
398 Unit unit = (Unit)obj;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
399 TreeNode node = nodes[unit.ID];
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
400
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
401 if (node!=null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
402 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
403 node.Text = unit.Name;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
404 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
405 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
406 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
407
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
408 private void UpdateArmyName(WarFoundryObject obj, string oldValue, string newValue)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
409 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
410 if (obj is Army)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
411 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
412 Army army = (Army)obj;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
413 TreeNode node = treeView.Nodes[0];
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
414
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
415 if (node!=null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
416 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
417 node.Text = army.Name;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
418 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
419 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
420 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
421
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
422 private void FrmArmyTree_TreeNameChanged(WarFoundryObject obj, string oldValue, string newValue)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
423 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
424 TreeNode node = nodes[obj.ID];
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
425
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
426 if (node!=null)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
427 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
428 node.Text = obj.Name;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
429 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
430 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
431
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
432 private void toolBar_ButtonClick(object sender, ToolBarButtonClickEventArgs e)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
433 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
434 if (e.Button == bttnDelete)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
435 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
436 DeleteUnit();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
437 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
438 else if (e.Button == bttnEdit)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
439 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
440 EditUnit();
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
441 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
442 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
443
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
444 private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
445 {
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
446 TreeNode node = treeView.SelectedNode;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
447
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
448 bttnDelete.Enabled = (node != null && node.Tag is Unit);
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
449 bttnEdit.Enabled = bttnDelete.Enabled;
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
450 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
451 }
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
452 }