annotate FrmArmyTree.cs @ 242:ea5cb50ebe5e

Fixes #384: Validation warnings don't get cleared when creating new armies * Check whether army is valid when it changes (also means we validate on load as well as clearing on close)
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Jan 2012 16:51:07 +0000
parents c06d0865ff27
children 2c3474d652e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
1 using System;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
2 using System.Collections.Generic;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
3 using System.ComponentModel;
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
4 using System.Data;
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
5 using System.Drawing;
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
6 using System.Text;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
7 using System.Windows.Forms;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
8 using IBBoard.Commands;
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
9 using IBBoard.WarFoundry.API.Objects;
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
10 using IBBoard.WarFoundry.API;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
11 using IBBoard.Lang;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
12 using IBBoard.Windows.Forms.I18N;
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
13 using IBBoard.WarFoundry.API.Commands;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
14 using IBBoard.Windows.Forms;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
15
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
16 namespace IBBoard.WarFoundry.GUI.WinForms
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
17 {
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
18 public partial class FrmArmyTree : IBBoard.Windows.Forms.IBBForm
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
19 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
20 private Dictionary<string, TreeNode> nodes;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
21 private ObjectAddDelegate UnitAddedMethod;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
22 private ObjectRemoveDelegate UnitRemovedMethod;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
23 private StringValChangedDelegate UnitNameChangedMethod, ArmyNameChangedMethod, TreeNameChangedMethod;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
24 private CommandStack commandStack;
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
25 public GameSystem CurrentGameSystem
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
26 {
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
27 get { return WarFoundryCore.CurrentGameSystem; }
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
28 set { WarFoundryCore.CurrentGameSystem = value; }
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
29 }
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
30
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
31 public FrmArmyTree(CommandStack cmdStack)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
32 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
33 commandStack = cmdStack;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
34 InitializeComponent();
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
35 UnitAddedMethod = new ObjectAddDelegate(UnitAdded);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
36 UnitRemovedMethod = new ObjectRemoveDelegate(UnitRemoved);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
37 UnitNameChangedMethod = new StringValChangedDelegate(UpdateUnitName);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
38 ArmyNameChangedMethod = new StringValChangedDelegate(UpdateArmyName);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
39 TreeNameChangedMethod = new StringValChangedDelegate(FrmArmyTree_TreeNameChanged);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
40 nodes = new Dictionary<string, TreeNode>();
226
4ada3252d1ea Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 225
diff changeset
41 this.Name = "ArmyTree";
4ada3252d1ea Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 225
diff changeset
42 miDeleteUnit.Name = "miDeleteUnit";
4ada3252d1ea Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 225
diff changeset
43 miEditUnit.Name = "miEditUnit";
4ada3252d1ea Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 225
diff changeset
44 miEditArmy.Name = "miEditArmy";
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
45 WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(FrmArmyTree_ArmyChanged);
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
46 TranslateForm();
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
47 Translation.TranslationChanged += new MethodInvoker(TranslateForm);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
48 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
49
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
50 private void TranslateForm()
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
51 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
52 ControlTranslator.TranslateControl(this);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
53
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
54 foreach (Component comp in components.Components)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
55 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
56 ControlTranslator.TranslateComponent(comp);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
57 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
58
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
59 foreach (IBBToolStripMenuItem mi in contextMenuStrip.Items)
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
60 {
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
61 ControlTranslator.TranslateComponent(mi);
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
62 }
226
4ada3252d1ea Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 225
diff changeset
63
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
64 foreach (TreeNode node in nodes.Values)
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
65 {
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
66 node.Text = CreateNodeName((ICostedWarFoundryObject)node.Tag);
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
67 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
68 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
69 private void ClearArmy()
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
70 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
71 nodes.Clear();
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
72 treeView.Nodes.Clear();
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
73 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
74
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
75 private void SetArmy(Army army)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
76 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
77 ClearArmy();
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
78
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
79 if (army != null)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
80 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
81 ArmyCategory[] cats = army.Categories;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
82 TreeNode[] catNodes = new TreeNode[cats.Length];
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
83 Unit[] units;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
84
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
85 for (int i = 0; i < cats.Length; i++)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
86 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
87 ArmyCategory cat = cats[i];
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
88 units = army.GetUnits(cat);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
89 cat.NameChanged += TreeNameChangedMethod;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
90 cat.PointsValueChanged += NodePointsValueChanged;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
91 TreeNode[] unitNodes = new TreeNode[units.Length];
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
92 TreeNode temp;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
93
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
94 for (int j = 0; j < units.Length; j++)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
95 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
96 unitNodes[j] = CreateTreeNode(units[j]);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
97 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
98
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
99 temp = new TreeNode(CreateNodeName(cat), unitNodes);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
100 temp.Tag = cat;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
101 catNodes[i] = temp;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
102 nodes[cat.ID] = temp;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
103 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
104
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
105 TreeNode root = new TreeNode(CreateNodeName(army), catNodes);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
106 root.Tag = army;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
107 army.PointsValueChanged += NodePointsValueChanged;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
108 nodes[army.ID] = root;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
109 treeView.Nodes.Add(root);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
110 root.ExpandAll();
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
111 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
112 }
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
113
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
114 private string CreateNodeName(ICostedWarFoundryObject obj)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
115 {
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
116 return Translation.GetTranslation("treeNodeText", "{0} ({1} pts)", obj.Name, obj.Points, CurrentGameSystem.GetPointsAbbrev(obj.Points));
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
117 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
118
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
119 private void NodePointsValueChanged(WarFoundryObject obj, double oldValue, double newValue)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
120 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
121 if (obj is ICostedWarFoundryObject)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
122 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
123 SetNodeName(obj);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
124 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
125 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
126
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
127 private void SetNodeName(WarFoundryObject obj)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
128 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
129 TreeNode node = nodes[obj.ID];
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
130
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
131 if (node != null)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
132 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
133 node.Text = CreateNodeName((ICostedWarFoundryObject)obj);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
134 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
135 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
136
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
137 private TreeNode CreateTreeNode(Unit unit)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
138 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
139 TreeNode temp = new TreeNode(CreateNodeName(unit));
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
140 temp.Tag = unit;
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
141 unit.NameChanged += UnitNameChangedMethod;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
142 unit.PointsValueChanged += NodePointsValueChanged;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
143 nodes[unit.ID] = temp;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
144 return temp;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
145 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
146
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
147 public void FrmArmyTree_ArmyChanged(Army oldArmy, Army newArmy)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
148 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
149 if (oldArmy != null)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
150 {
226
4ada3252d1ea Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 225
diff changeset
151 oldArmy.NameChanged -= ArmyNameChangedMethod;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
152 oldArmy.UnitAdded -= UnitAddedMethod;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
153 oldArmy.UnitRemoved -= UnitRemovedMethod;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
154 oldArmy.PointsValueChanged -= NodePointsValueChanged;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
155 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
156
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
157 if (newArmy != null)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
158 {
226
4ada3252d1ea Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 225
diff changeset
159 newArmy.NameChanged += ArmyNameChangedMethod;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
160 newArmy.UnitAdded += UnitAddedMethod;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
161 newArmy.UnitRemoved += UnitRemovedMethod;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
162 newArmy.PointsValueChanged += NodePointsValueChanged;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
163 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
164
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
165 SetArmy(newArmy);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
166 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
167
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
168 private void UnitAdded(WarFoundryObject obj)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
169 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
170 if (obj is Unit)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
171 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
172 Unit unit = (Unit)obj;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
173 ArmyCategory cat = unit.Category;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
174 TreeNode parent = nodes[cat.ID];
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
175 TreeNode unitNode = CreateTreeNode(unit);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
176 parent.Nodes.Add(unitNode);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
177 parent.Expand(); //make sure it's expanded
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
178 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
179 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
180
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
181 public new FrmMain MdiParent
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
182 {
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
183 get { return (FrmMain)base.MdiParent; }
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
184 set { base.MdiParent = value; }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
185 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
186
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
187 private void UnitRemoved(WarFoundryObject obj)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
188 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
189 if (obj is Unit)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
190 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
191 Unit unit = (Unit)obj;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
192 RemoveUnitFromTree(unit);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
193 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
194 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
195
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
196 private void RemoveUnitFromTree(Unit unit)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
197 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
198 TreeNode unitNode = nodes[unit.ID];
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
199 unit.NameChanged -= UnitNameChangedMethod;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
200
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
201 if (unitNode != null)
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
202 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
203 unitNode.Remove();
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
204 nodes.Remove(unit.ID);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
205 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
206 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
207
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
208 private void treeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
209 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
210 if (e.Button == MouseButtons.Right)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
211 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
212 TreeNode tn = treeView.GetNodeAt(e.X, e.Y);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
213
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
214 if (tn != null)
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
215 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
216 treeView.SelectedNode = tn;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
217 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
218 else
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
219 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
220 treeView.SelectedNode = null;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
221 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
222 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
223 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
224
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
225 private void miDelete_Click(object sender, System.EventArgs e)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
226 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
227 DeleteUnit();
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
228 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
229
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
230 private void DeleteUnit()
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
231 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
232
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
233 TreeNode selected = treeView.SelectedNode;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
234
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
235 if (selected.Tag != null && selected.Tag is Unit)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
236 {
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
237 Unit unit = (Unit)selected.Tag;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
238 commandStack.Execute(new RemoveUnitCommand(unit));
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
239 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
240 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
241
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
242 private void miEdit_Click(object sender, System.EventArgs e)
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
243 {
225
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
244 EditTreeItem();
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
245 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
246
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
247 private void treeView_DoubleClick(object sender, System.EventArgs e)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
248 {
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
249 EditTreeItem();
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
250 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
251
225
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
252 private void EditTreeItem()
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
253 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
254 TreeNode selected = treeView.SelectedNode;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
255 object tagData = selected.Tag;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
256
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
257 if (tagData is Unit)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
258 {
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
259 Unit unit = (Unit)tagData;
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
260 MdiParent.OpenUnitDialog(unit);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
261 }
225
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
262 else if (tagData is Army)
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
263 {
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
264 EditArmy((Army)tagData);
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
265 }
239
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
266 else if (tagData is ArmyCategory)
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
267 {
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
268 AddUnitFromCategory((ArmyCategory)tagData);
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
269 }
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
270 }
239
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
271
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
272 private void UpdateUnitName(WarFoundryObject obj, string oldValue, string newValue)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
273 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
274 if (obj is ICostedWarFoundryObject)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
275 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
276 SetNodeName(obj);
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
277 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
278 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
279
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
280 private void UpdateArmyName(WarFoundryObject obj, string oldValue, string newValue)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
281 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
282 if (obj is Army)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
283 {
226
4ada3252d1ea Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 225
diff changeset
284 SetNodeName((Army)obj);
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
285 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
286 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
287
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
288 private void FrmArmyTree_TreeNameChanged(WarFoundryObject obj, string oldValue, string newValue)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
289 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
290 TreeNode node = nodes[obj.ID];
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
291
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
292 if (node != null)
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
293 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
294 node.Text = obj.Name;
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
295 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
296 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
297
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
298 private void treeView_AfterSelect(object sender, TreeViewEventArgs e)
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
299 {
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
300 TreeNode node = treeView.SelectedNode;
239
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
301 bttnAdd.Enabled = (node != null && node.Tag is ArmyCategory);
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
302 bttnDelete.Enabled = (node != null && node.Tag is Unit);
225
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
303 bttnEdit.Enabled = (node != null && (node.Tag is Unit || node.Tag is Army));
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
304 }
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
305
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
306 private void miEditArmy_Click(object sender, EventArgs e)
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
307 {
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
308 Army army = treeView.SelectedNode.Tag as Army;
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
309 EditArmy(army);
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
310 }
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
311
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
312 private void EditArmy(Army army)
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
313 {
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
314 FrmEditArmy editForm = new FrmEditArmy(commandStack, army);
5233147ca7e4 Re #101: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 198
diff changeset
315 editForm.ShowDialog(this.ParentForm);
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
316 }
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
317
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
318 private void bttnEdit_Click(object sender, EventArgs e)
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
319 {
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
320 EditTreeItem();
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
321 }
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
322
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
323 private void bttnDelete_Click(object sender, EventArgs e)
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
324 {
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
325 DeleteUnit();
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
326 }
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
327
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
328 private void contextMenuStrip_Opening(object sender, CancelEventArgs e)
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
329 {
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
330 TreeNode node = treeView.SelectedNode;
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
331 Object tag = (node != null) ? node.Tag : null;
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
332 bool tagIsUnit = (tag is Unit);
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
333 bool tagIsArmy = (tag is Army);
239
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
334 bool tagIsCategory = (tag is ArmyCategory);
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
335
239
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
336 if (!tagIsUnit && !tagIsArmy && !tagIsCategory)
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
337 {
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
338 e.Cancel = true;
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
339 }
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
340 else
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
341 {
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
342 miDeleteUnit.Visible = tagIsUnit;
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
343 miEditUnit.Visible = tagIsUnit;
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
344 miEditArmy.Visible = tagIsArmy;
239
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
345 miAddUnit.Visible = tagIsCategory;
234
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
346 }
870877498db9 Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents: 226
diff changeset
347 }
239
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
348
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
349 private void miAddUnit_Click(object sender, EventArgs e)
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
350 {
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
351 AddUnit();
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
352 }
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
353
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
354 private void AddUnit()
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
355 {
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
356 ArmyCategory tagData = treeView.SelectedNode.Tag as ArmyCategory;
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
357 AddUnitFromCategory(tagData);
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
358 }
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
359
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
360 private void AddUnitFromCategory(ArmyCategory tagData)
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
361 {
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
362 MdiParent.AddUnitFromCategory(tagData.Category);
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
363 }
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
364
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
365 private void bttnAdd_Click(object sender, EventArgs e)
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
366 {
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
367 AddUnit();
c06d0865ff27 Fixes #388: Add "Add unit" options to army tree
IBBoard <dev@ibboard.co.uk>
parents: 234
diff changeset
368 }
190
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
369 }
1ca23c47345a Re #327: Point names used in the GUI
snowblizz
parents: 159
diff changeset
370 }