annotate FrmArmyTree.cs @ 60:c283545d2d0b

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