Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
annotate FrmArmyTree.cs @ 155:67b4b84f5674
Fixes #269: Handle multiple stat lines
* Reduce the width of the tables to only show a vertical scrollbar
* Make the width of the columns more proportional to how many there are
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 28 May 2010 19:49:34 +0000 |
parents | 4023a9bdcb8b |
children | 0ae6aff8c862 |
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 | 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); |
143
28105d9c2b25
Re #265: Add language preference UI
IBBoard <dev@ibboard.co.uk>
parents:
87
diff
changeset
|
53 TranslateForm(); |
28105d9c2b25
Re #265: Add language preference UI
IBBoard <dev@ibboard.co.uk>
parents:
87
diff
changeset
|
54 Translation.TranslationChanged+=new MethodInvoker(TranslateForm); |
28105d9c2b25
Re #265: Add language preference UI
IBBoard <dev@ibboard.co.uk>
parents:
87
diff
changeset
|
55 } |
63
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
56 |
143
28105d9c2b25
Re #265: Add language preference UI
IBBoard <dev@ibboard.co.uk>
parents:
87
diff
changeset
|
57 private void TranslateForm() |
28105d9c2b25
Re #265: Add language preference UI
IBBoard <dev@ibboard.co.uk>
parents:
87
diff
changeset
|
58 { |
144
4023a9bdcb8b
Re #265: Add language preference UI
IBBoard <dev@ibboard.co.uk>
parents:
143
diff
changeset
|
59 ControlTranslator.TranslateControl(this); |
63
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 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
|
62 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
63 ControlTranslator.TranslateComponent(comp); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
64 } |
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 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
|
67 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
68 ControlTranslator.TranslateComponent(mi); |
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 } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
71 |
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 /// 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
|
74 /// </summary> |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
75 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
|
76 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
77 if( disposing ) |
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 if(components != null) |
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 components.Dispose(); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
82 } |
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 base.Dispose( disposing ); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
85 } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
86 |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
87 #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
|
88 /// <summary> |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
89 /// 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
|
90 /// 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
|
91 /// </summary> |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
92 private void InitializeComponent() |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
93 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 this.SuspendLayout(); |
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 // contextMenu |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
107 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
108 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
|
109 this.miEditUnit, |
4c5c8f91937a
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
79
diff
changeset
|
110 this.miDeleteUnit}); |
63
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
111 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
|
112 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
113 // miEdit |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
114 // |
87
4c5c8f91937a
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
79
diff
changeset
|
115 this.miEditUnit.Index = 0; |
4c5c8f91937a
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
79
diff
changeset
|
116 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
|
117 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
|
118 this.miEditUnit.Name = "miEditUnit"; |
63
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
119 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
120 // miDelete |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
121 // |
87
4c5c8f91937a
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
79
diff
changeset
|
122 this.miDeleteUnit.Index = 1; |
4c5c8f91937a
Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents:
79
diff
changeset
|
123 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
|
124 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
|
125 this.miDeleteUnit.Name = "miDeleteUnit"; |
63
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 // imageList |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
128 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
129 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
|
130 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
|
131 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
|
132 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
|
133 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
134 // toolBar |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
135 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
136 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
|
137 this.bttnEdit, |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
138 this.bttnDelete}); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
139 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
|
140 this.toolBar.DropDownArrows = true; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
141 this.toolBar.ImageList = this.imageList; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
142 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
|
143 this.toolBar.Name = "toolBar"; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
144 this.toolBar.ShowToolTips = true; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
145 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
|
146 this.toolBar.TabIndex = 3; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
147 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
|
148 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
149 // 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 this.bttnEdit.Enabled = false; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
152 this.bttnEdit.ImageIndex = 0; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
153 this.bttnEdit.Name = "bttnEdit"; |
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 // 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 this.bttnDelete.Enabled = false; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
158 this.bttnDelete.ImageIndex = 1; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
159 this.bttnDelete.Name = "bttnDelete"; |
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 // treeView |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
162 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
163 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
|
164 | System.Windows.Forms.AnchorStyles.Left) |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
165 | System.Windows.Forms.AnchorStyles.Right))); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
166 this.treeView.ContextMenu = this.contextMenu; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
167 this.treeView.FullRowSelect = true; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
168 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
|
169 this.treeView.Name = "treeView"; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
170 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
|
171 this.treeView.TabIndex = 0; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
172 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
|
173 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
|
174 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
|
175 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
176 // FrmArmyTree |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
177 // |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
178 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
|
179 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
|
180 this.ControlBox = false; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
181 this.Controls.Add(this.toolBar); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
182 this.Controls.Add(this.treeView); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
183 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
|
184 this.MaximizeBox = false; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
185 this.MinimizeBox = false; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
186 this.Name = "FrmArmyTree"; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
187 this.Text = "FrmArmyTree"; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
188 this.ResumeLayout(false); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
189 this.PerformLayout(); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
190 |
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 #endregion |
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 private void ClearArmy() |
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 nodes.Clear(); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
197 treeView.Nodes.Clear(); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
198 } |
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 private void SetArmy(Army army) |
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 ClearArmy(); |
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 if (army != null) |
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 ArmyCategory[] cats = army.Categories; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
207 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
|
208 Unit[] units; |
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 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
|
211 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
212 ArmyCategory cat = cats[i]; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
213 units = army.GetUnits(cat); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
214 cat.NameChanged += TreeNameChangedMethod; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
215 cat.PointsValueChanged += NodePointsValueChanged; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
216 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
|
217 TreeNode temp; |
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 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
|
220 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
221 unitNodes[j] = CreateTreeNode(units[j]); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
222 } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
223 |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
224 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
|
225 temp.Tag = cat; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
226 catNodes[i] = temp; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
227 nodes[cat.ID] = temp; |
33 | 228 } |
229 | |
63
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
230 TreeNode root = new TreeNode(CreateNodeName(army), catNodes); |
33 | 231 root.Tag = army; |
63
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
232 army.PointsValueChanged += NodePointsValueChanged; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
233 nodes[army.ID] = root; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
234 treeView.Nodes.Add(root); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
235 root.ExpandAll(); |
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 } |
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 private string CreateNodeName(ICostedWarFoundryObject obj) |
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 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
|
242 } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
243 |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
244 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
|
245 { |
62
0e7c257ca8d6
Fixes #164: Show unit cost in army tree
IBBoard <dev@ibboard.co.uk>
parents:
61
diff
changeset
|
246 if (obj is ICostedWarFoundryObject) |
33 | 247 { |
79
e3488dd61a21
Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents:
63
diff
changeset
|
248 SetNodeName(obj); |
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 } |
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 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
|
253 { |
e3488dd61a21
Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents:
63
diff
changeset
|
254 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
|
255 |
e3488dd61a21
Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents:
63
diff
changeset
|
256 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
|
257 { |
e3488dd61a21
Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents:
63
diff
changeset
|
258 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
|
259 } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
260 } |
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 private TreeNode CreateTreeNode(Unit unit) |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
263 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
264 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
|
265 temp.Tag = unit; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
266 unit.NameChanged+= UnitNameChangedMethod; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
267 unit.PointsValueChanged += NodePointsValueChanged; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
268 nodes[unit.ID] = temp; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
269 return temp; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
270 } |
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 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
|
273 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
274 if (oldArmy != null) |
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 oldArmy.UnitAdded -= UnitAddedMethod; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
277 oldArmy.UnitRemoved -= UnitRemovedMethod; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
278 oldArmy.PointsValueChanged -= NodePointsValueChanged; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
279 } |
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 if (newArmy != null) |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
282 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
283 newArmy.UnitAdded += UnitAddedMethod; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
284 newArmy.UnitRemoved += UnitRemovedMethod; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
285 newArmy.PointsValueChanged += NodePointsValueChanged; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
286 } |
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 SetArmy(newArmy); |
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 |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
291 private void UnitAdded(WarFoundryObject obj) |
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 if (obj is Unit) |
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 Unit unit = (Unit)obj; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
296 ArmyCategory cat = unit.Category; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
297 TreeNode parent = nodes[cat.ID]; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
298 TreeNode unitNode = CreateTreeNode(unit); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
299 parent.Nodes.Add(unitNode); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
300 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
|
301 } |
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 public new FrmMain MdiParent |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
305 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
306 get { return (FrmMain) base.MdiParent; } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
307 set { base.MdiParent = value; } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
308 } |
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 private void UnitRemoved(WarFoundryObject obj) |
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 if (obj is Unit) |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
313 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
314 Unit unit = (Unit)obj; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
315 RemoveUnitFromTree(unit); |
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 |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
319 private void RemoveUnitFromTree(Unit unit) |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
320 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
321 TreeNode unitNode = nodes[unit.ID]; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
322 unit.NameChanged-= UnitNameChangedMethod; |
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 if (unitNode!=null) |
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 unitNode.Remove(); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
327 nodes.Remove(unit.ID); |
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 |
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 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
|
333 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
334 TreeNode node = treeView.SelectedNode; |
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 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
|
337 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
338 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
|
339 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
340 item.Visible = true; |
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 } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
343 else |
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 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
|
346 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
347 item.Visible = false; |
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 } |
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 private void treeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) |
33 | 353 { |
63
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
354 if (e.Button == MouseButtons.Right) |
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 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
|
357 |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
358 if (tn!=null) |
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 treeView.SelectedNode = tn; |
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 else |
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 treeView.SelectedNode = null; |
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 } |
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 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
|
370 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
371 DeleteUnit(); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
372 } |
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 private void DeleteUnit() |
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 TreeNode selected = treeView.SelectedNode; |
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 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
|
380 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
381 Unit unit = (Unit) selected.Tag; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
382 commandStack.Execute(new RemoveUnitCommand(unit)); |
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 } |
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 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
|
387 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
388 EditUnit(); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
389 } |
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 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
|
392 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
393 EditUnit(); |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
394 } |
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 private void EditUnit() |
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 TreeNode selected = treeView.SelectedNode; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
399 object tagData = selected.Tag; |
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 (tagData is Unit) |
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 Unit unit = (Unit) tagData; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
404 MdiParent.OpenUnitDialog(unit); |
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 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
|
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 if (obj is ICostedWarFoundryObject) |
63
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
411 { |
79
e3488dd61a21
Fixes #199: armytree unit point costs don't always show after update
IBBoard <dev@ibboard.co.uk>
parents:
63
diff
changeset
|
412 SetNodeName(obj); |
63
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 } |
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 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
|
417 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
418 if (obj is Army) |
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 Army army = (Army)obj; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
421 TreeNode node = treeView.Nodes[0]; |
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 if (node!=null) |
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 node.Text = army.Name; |
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 } |
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 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
|
431 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
432 TreeNode node = nodes[obj.ID]; |
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 (node!=null) |
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 node.Text = obj.Name; |
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 } |
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 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
|
441 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
442 if (e.Button == bttnDelete) |
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 DeleteUnit(); |
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 else if (e.Button == bttnEdit) |
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 EditUnit(); |
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 } |
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 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
|
453 { |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
454 TreeNode node = treeView.SelectedNode; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
455 |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
456 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
|
457 bttnEdit.Enabled = bttnDelete.Enabled; |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
458 } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
459 } |
4db2c1086a85
Re #173: Add WinForms UI for showing debugging messages
IBBoard <dev@ibboard.co.uk>
parents:
62
diff
changeset
|
460 } |