annotate FrmArmyTree.cs @ 108:6871c9788ce1

Re #203: Translate WarFoundry * Add initial Russian translation (contributed by Lord_Archaon and fixed through Google Chrome and gEdit by IBBoard) * Change English and Swedish translations to use UTF-8 for consistency * Remove unneccessary xmln:xsi declaration
author IBBoard <dev@ibboard.co.uk>
date Sun, 13 Dec 2009 20:15:26 +0000
parents 4c5c8f91937a
children 28105d9c2b25
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;
87
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
29 private IBBMenuItem miDeleteUnit;
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
30 private IBBMenuItem miEditUnit;
63
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();
87
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
95 this.miEditUnit = new IBBoard.Windows.Forms.IBBMenuItem();
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
96 this.miDeleteUnit = new IBBoard.Windows.Forms.IBBMenuItem();
63
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[] {
87
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
107 this.miEditUnit,
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
108 this.miDeleteUnit});
63
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 //
87
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
113 this.miEditUnit.Index = 0;
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
114 this.miEditUnit.Text = "&edit unit";
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
115 this.miEditUnit.Click += new System.EventHandler(this.miEdit_Click);
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
116 this.miEditUnit.Name = "miEditUnit";
63
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
117 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
118 // miDelete
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
119 //
87
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
120 this.miDeleteUnit.Index = 1;
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
121 this.miDeleteUnit.Text = "&delete unit";
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
122 this.miDeleteUnit.Click += new System.EventHandler(this.miDelete_Click);
4c5c8f91937a Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 79
diff changeset
123 this.miDeleteUnit.Name = "miDeleteUnit";
63
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 // imageList
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
126 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
127 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
128 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
129 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
130 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
131 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
132 // toolBar
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
133 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
134 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
135 this.bttnEdit,
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
136 this.bttnDelete});
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
137 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
138 this.toolBar.DropDownArrows = true;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
139 this.toolBar.ImageList = this.imageList;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
140 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
141 this.toolBar.Name = "toolBar";
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
142 this.toolBar.ShowToolTips = true;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
143 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
144 this.toolBar.TabIndex = 3;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
145 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
146 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
147 // bttnEdit
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
148 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
149 this.bttnEdit.Enabled = false;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
150 this.bttnEdit.ImageIndex = 0;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
151 this.bttnEdit.Name = "bttnEdit";
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 // bttnDelete
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
154 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
155 this.bttnDelete.Enabled = false;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
156 this.bttnDelete.ImageIndex = 1;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
157 this.bttnDelete.Name = "bttnDelete";
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 // treeView
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
160 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
161 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
162 | System.Windows.Forms.AnchorStyles.Left)
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
163 | System.Windows.Forms.AnchorStyles.Right)));
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
164 this.treeView.ContextMenu = this.contextMenu;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
165 this.treeView.FullRowSelect = true;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
166 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
167 this.treeView.Name = "treeView";
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
168 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
169 this.treeView.TabIndex = 0;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
170 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
171 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
172 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
173 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
174 // FrmArmyTree
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
175 //
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
176 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
177 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
178 this.ControlBox = false;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
179 this.Controls.Add(this.toolBar);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
180 this.Controls.Add(this.treeView);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
181 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
182 this.MaximizeBox = false;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
183 this.MinimizeBox = false;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
184 this.Name = "FrmArmyTree";
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
185 this.Text = "FrmArmyTree";
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
186 this.ResumeLayout(false);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
187 this.PerformLayout();
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
188
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 #endregion
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 private void ClearArmy()
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
193 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
194 nodes.Clear();
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
195 treeView.Nodes.Clear();
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
196 }
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 private void SetArmy(Army army)
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 ClearArmy();
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 if (army != null)
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
203 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
204 ArmyCategory[] cats = army.Categories;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
205 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
206 Unit[] units;
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 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
209 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
210 ArmyCategory cat = cats[i];
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
211 units = army.GetUnits(cat);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
212 cat.NameChanged += TreeNameChangedMethod;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
213 cat.PointsValueChanged += NodePointsValueChanged;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
214 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
215 TreeNode temp;
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 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
218 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
219 unitNodes[j] = CreateTreeNode(units[j]);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
220 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
221
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
222 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
223 temp.Tag = cat;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
224 catNodes[i] = temp;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
225 nodes[cat.ID] = temp;
33
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
63
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
228 TreeNode root = new TreeNode(CreateNodeName(army), catNodes);
33
67c283ea77a7 * Code cleanup (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
229 root.Tag = army;
63
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
230 army.PointsValueChanged += NodePointsValueChanged;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
231 nodes[army.ID] = root;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
232 treeView.Nodes.Add(root);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
233 root.ExpandAll();
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 }
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 private string CreateNodeName(ICostedWarFoundryObject obj)
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 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
240 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
241
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
242 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
243 {
62
0e7c257ca8d6 Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents: 61
diff changeset
244 if (obj is ICostedWarFoundryObject)
33
67c283ea77a7 * Code cleanup (line endings)
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
245 {
79
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
246 SetNodeName(obj);
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
247 }
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
248 }
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
249
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
250 private void SetNodeName(WarFoundryObject obj)
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
251 {
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
252 TreeNode node = nodes[obj.ID];
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
253
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
254 if (node != null)
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
255 {
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
256 node.Text = CreateNodeName((ICostedWarFoundryObject)obj);
63
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 }
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 private TreeNode CreateTreeNode(Unit unit)
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 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
263 temp.Tag = unit;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
264 unit.NameChanged+= UnitNameChangedMethod;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
265 unit.PointsValueChanged += NodePointsValueChanged;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
266 nodes[unit.ID] = temp;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
267 return temp;
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
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
270 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
271 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
272 if (oldArmy != null)
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 oldArmy.UnitAdded -= UnitAddedMethod;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
275 oldArmy.UnitRemoved -= UnitRemovedMethod;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
276 oldArmy.PointsValueChanged -= NodePointsValueChanged;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
277 }
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 (newArmy != null)
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 newArmy.UnitAdded += UnitAddedMethod;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
282 newArmy.UnitRemoved += UnitRemovedMethod;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
283 newArmy.PointsValueChanged += NodePointsValueChanged;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
284 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
285
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
286 SetArmy(newArmy);
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 private void UnitAdded(WarFoundryObject obj)
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
290 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
291 if (obj is Unit)
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
292 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
293 Unit unit = (Unit)obj;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
294 ArmyCategory cat = unit.Category;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
295 TreeNode parent = nodes[cat.ID];
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
296 TreeNode unitNode = CreateTreeNode(unit);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
297 parent.Nodes.Add(unitNode);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
298 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
299 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
300 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
301
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
302 public new FrmMain MdiParent
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 get { return (FrmMain) base.MdiParent; }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
305 set { base.MdiParent = value; }
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
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
308 private void UnitRemoved(WarFoundryObject obj)
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 (obj is Unit)
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 Unit unit = (Unit)obj;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
313 RemoveUnitFromTree(unit);
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 private void RemoveUnitFromTree(Unit unit)
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
318 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
319 TreeNode unitNode = nodes[unit.ID];
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
320 unit.NameChanged-= UnitNameChangedMethod;
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 (unitNode!=null)
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 unitNode.Remove();
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
325 nodes.Remove(unit.ID);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
326 }
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
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
330 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
331 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
332 TreeNode node = treeView.SelectedNode;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
333
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
334 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
335 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
336 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
337 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
338 item.Visible = true;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
339 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
340 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
341 else
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
342 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
343 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
344 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
345 item.Visible = false;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
346 }
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 }
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 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
351 {
63
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
352 if (e.Button == MouseButtons.Right)
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 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
355
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
356 if (tn!=null)
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
357 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
358 treeView.SelectedNode = tn;
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 else
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 treeView.SelectedNode = null;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
363 }
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 }
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 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
368 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
369 DeleteUnit();
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 DeleteUnit()
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
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
375 TreeNode selected = treeView.SelectedNode;
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 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
378 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
379 Unit unit = (Unit) selected.Tag;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
380 commandStack.Execute(new RemoveUnitCommand(unit));
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 }
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 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
385 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
386 EditUnit();
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
387 }
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 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
390 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
391 EditUnit();
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 EditUnit()
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 TreeNode selected = treeView.SelectedNode;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
397 object tagData = selected.Tag;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
398
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
399 if (tagData is Unit)
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 Unit unit = (Unit) tagData;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
402 MdiParent.OpenUnitDialog(unit);
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
403 }
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 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
407 {
79
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
408 if (obj is ICostedWarFoundryObject)
63
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
409 {
79
e3488dd61a21 Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents: 63
diff changeset
410 SetNodeName(obj);
63
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 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
413
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
414 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
415 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
416 if (obj is Army)
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
417 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
418 Army army = (Army)obj;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
419 TreeNode node = treeView.Nodes[0];
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 if (node!=null)
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
422 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
423 node.Text = army.Name;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
424 }
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 }
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 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
429 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
430 TreeNode node = nodes[obj.ID];
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 if (node!=null)
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 node.Text = obj.Name;
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 }
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 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
439 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
440 if (e.Button == bttnDelete)
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 DeleteUnit();
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 else if (e.Button == bttnEdit)
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 EditUnit();
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 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
449
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
450 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
451 {
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
452 TreeNode node = treeView.SelectedNode;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
453
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
454 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
455 bttnEdit.Enabled = bttnDelete.Enabled;
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
456 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
457 }
4db2c1086a85 Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents: 62
diff changeset
458 }