annotate FrmArmyTree.cs @ 71:74d3efaac800

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