Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
comparison FrmArmyTree.cs @ 190:1ca23c47345a
Re #327: Point names used in the GUI
author | snowblizz |
---|---|
date | Mon, 24 Jan 2011 16:50:31 +0000 |
parents | 964f946d3cac |
children | eaa7b639d390 |
comparison
equal
deleted
inserted
replaced
189:cb86380cbf61 | 190:1ca23c47345a |
---|---|
35 private ToolBar toolBar; | 35 private ToolBar toolBar; |
36 private IBBToolBarButton bttnEdit; | 36 private IBBToolBarButton bttnEdit; |
37 private IBBToolBarButton bttnDelete; | 37 private IBBToolBarButton bttnDelete; |
38 private ImageList imageList; | 38 private ImageList imageList; |
39 private CommandStack commandStack; | 39 private CommandStack commandStack; |
40 public GameSystem CurrentGameSystem | |
41 { | |
42 get { return WarFoundryCore.CurrentGameSystem; } | |
43 set { WarFoundryCore.CurrentGameSystem = value; } | |
44 } | |
40 | 45 |
41 public FrmArmyTree(CommandStack cmdStack) | 46 public FrmArmyTree(CommandStack cmdStack) |
42 { | 47 { |
43 commandStack = cmdStack; | 48 commandStack = cmdStack; |
44 InitializeComponent(); | 49 InitializeComponent(); |
63 ControlTranslator.TranslateComponent(comp); | 68 ControlTranslator.TranslateComponent(comp); |
64 } | 69 } |
65 | 70 |
66 foreach (IBBMenuItem mi in contextMenu.MenuItems) | 71 foreach (IBBMenuItem mi in contextMenu.MenuItems) |
67 { | 72 { |
68 ControlTranslator.TranslateComponent(mi); | 73 ControlTranslator.TranslateComponent(mi); |
69 } | 74 } |
75 foreach (TreeNode node in nodes.Values) | |
76 { | |
77 node.Text = CreateNodeName((ICostedWarFoundryObject)node.Tag); | |
78 } | |
70 } | 79 } |
71 | 80 |
72 /// <summary> | 81 /// <summary> |
73 /// Clean up any resources being used. | 82 /// Clean up any resources being used. |
74 /// </summary> | 83 /// </summary> |
91 /// Required method for Designer support - do not modify | 100 /// Required method for Designer support - do not modify |
92 /// the contents of this method with the code editor. | 101 /// the contents of this method with the code editor. |
93 /// </summary> | 102 /// </summary> |
94 private void InitializeComponent() | 103 private void InitializeComponent() |
95 { | 104 { |
96 this.components = new System.ComponentModel.Container(); | 105 this.components = new System.ComponentModel.Container(); |
97 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmArmyTree)); | 106 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmArmyTree)); |
98 this.contextMenu = new System.Windows.Forms.ContextMenu(); | 107 this.contextMenu = new System.Windows.Forms.ContextMenu(); |
99 this.miEditUnit = new IBBoard.Windows.Forms.IBBMenuItem(); | 108 this.miEditUnit = new IBBoard.Windows.Forms.IBBMenuItem(); |
100 this.miDeleteUnit = new IBBoard.Windows.Forms.IBBMenuItem(); | 109 this.miDeleteUnit = new IBBoard.Windows.Forms.IBBMenuItem(); |
101 this.imageList = new System.Windows.Forms.ImageList(this.components); | 110 this.imageList = new System.Windows.Forms.ImageList(this.components); |
102 this.toolBar = new System.Windows.Forms.ToolBar(); | 111 this.toolBar = new System.Windows.Forms.ToolBar(); |
103 this.bttnEdit = new IBBoard.Windows.Forms.IBBToolBarButton(); | 112 this.bttnEdit = new IBBoard.Windows.Forms.IBBToolBarButton(); |
104 this.bttnDelete = new IBBoard.Windows.Forms.IBBToolBarButton(); | 113 this.bttnDelete = new IBBoard.Windows.Forms.IBBToolBarButton(); |
105 this.treeView = new System.Windows.Forms.TreeView(); | 114 this.treeView = new System.Windows.Forms.TreeView(); |
106 this.SuspendLayout(); | 115 this.SuspendLayout(); |
107 // | 116 // |
108 // contextMenu | 117 // contextMenu |
109 // | 118 // |
110 this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { | 119 this.contextMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { |
111 this.miEditUnit, | 120 this.miEditUnit, |
112 this.miDeleteUnit}); | 121 this.miDeleteUnit}); |
113 this.contextMenu.Popup += new System.EventHandler(this.contextMenu_Popup); | 122 this.contextMenu.Popup += new System.EventHandler(this.contextMenu_Popup); |
114 // | 123 // |
115 // miEditUnit | 124 // miEditUnit |
116 // | 125 // |
117 this.miEditUnit.Index = 0; | 126 this.miEditUnit.Index = 0; |
118 this.miEditUnit.Text = "&edit unit"; | 127 this.miEditUnit.Text = "&edit unit"; |
119 this.miEditUnit.Click += new System.EventHandler(this.miEdit_Click); | 128 this.miEditUnit.Click += new System.EventHandler(this.miEdit_Click); |
120 this.miEditUnit.Name = "miEditUnit"; | 129 // |
121 // | 130 // miDeleteUnit |
122 // miDeleteUnit | 131 // |
123 // | 132 this.miDeleteUnit.Index = 1; |
124 this.miDeleteUnit.Index = 1; | 133 this.miDeleteUnit.Text = "&delete unit"; |
125 this.miDeleteUnit.Text = "&delete unit"; | 134 this.miDeleteUnit.Click += new System.EventHandler(this.miDelete_Click); |
126 this.miDeleteUnit.Click += new System.EventHandler(this.miDelete_Click); | 135 // |
127 this.miDeleteUnit.Name = "miDeleteUnit"; | 136 // imageList |
128 // | 137 // |
129 // imageList | 138 this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream"))); |
130 // | 139 this.imageList.TransparentColor = System.Drawing.Color.Transparent; |
131 this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer) (resources.GetObject("imageList.ImageStream"))); | 140 this.imageList.Images.SetKeyName(0, "gtk-edit.png"); |
132 this.imageList.TransparentColor = System.Drawing.Color.Transparent; | 141 this.imageList.Images.SetKeyName(1, "edit-delete.png"); |
133 this.imageList.Images.SetKeyName(0, "gtk-edit.png"); | 142 // |
134 this.imageList.Images.SetKeyName(1, "edit-delete.png"); | 143 // toolBar |
135 // | 144 // |
136 // toolBar | 145 this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { |
137 // | |
138 this.toolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] { | |
139 this.bttnEdit, | 146 this.bttnEdit, |
140 this.bttnDelete}); | 147 this.bttnDelete}); |
141 this.toolBar.ButtonSize = new System.Drawing.Size(16, 16); | 148 this.toolBar.ButtonSize = new System.Drawing.Size(16, 16); |
142 this.toolBar.DropDownArrows = true; | 149 this.toolBar.DropDownArrows = true; |
143 this.toolBar.ImageList = this.imageList; | 150 this.toolBar.ImageList = this.imageList; |
144 this.toolBar.Location = new System.Drawing.Point(0, 0); | 151 this.toolBar.Location = new System.Drawing.Point(0, 0); |
145 this.toolBar.Name = "toolBar"; | 152 this.toolBar.Name = "toolBar"; |
146 this.toolBar.ShowToolTips = true; | 153 this.toolBar.ShowToolTips = true; |
147 this.toolBar.Size = new System.Drawing.Size(240, 28); | 154 this.toolBar.Size = new System.Drawing.Size(240, 28); |
148 this.toolBar.TabIndex = 3; | 155 this.toolBar.TabIndex = 3; |
149 this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick); | 156 this.toolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar_ButtonClick); |
150 // | 157 // |
151 // bttnEdit | 158 // bttnEdit |
152 // | 159 // |
153 this.bttnEdit.Enabled = false; | 160 this.bttnEdit.Enabled = false; |
154 this.bttnEdit.ImageIndex = 0; | 161 this.bttnEdit.ImageIndex = 0; |
155 this.bttnEdit.Name = "bttnEdit"; | 162 this.bttnEdit.Name = "bttnEdit"; |
156 // | 163 // |
157 // bttnDelete | 164 // bttnDelete |
158 // | 165 // |
159 this.bttnDelete.Enabled = false; | 166 this.bttnDelete.Enabled = false; |
160 this.bttnDelete.ImageIndex = 1; | 167 this.bttnDelete.ImageIndex = 1; |
161 this.bttnDelete.Name = "bttnDelete"; | 168 this.bttnDelete.Name = "bttnDelete"; |
162 // | 169 // |
163 // treeView | 170 // treeView |
164 // | 171 // |
165 this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles) ((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | 172 this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) |
166 | System.Windows.Forms.AnchorStyles.Left) | 173 | System.Windows.Forms.AnchorStyles.Left) |
167 | System.Windows.Forms.AnchorStyles.Right))); | 174 | System.Windows.Forms.AnchorStyles.Right))); |
168 this.treeView.ContextMenu = this.contextMenu; | 175 this.treeView.ContextMenu = this.contextMenu; |
169 this.treeView.FullRowSelect = true; | 176 this.treeView.FullRowSelect = true; |
170 this.treeView.Location = new System.Drawing.Point(0, 28); | 177 this.treeView.ImageIndex = 0; |
171 this.treeView.Name = "treeView"; | 178 this.treeView.ImageList = this.imageList; |
172 this.treeView.Size = new System.Drawing.Size(240, 250); | 179 this.treeView.Location = new System.Drawing.Point(0, 28); |
173 this.treeView.TabIndex = 0; | 180 this.treeView.Name = "treeView"; |
174 this.treeView.DoubleClick += new System.EventHandler(this.treeView_DoubleClick); | 181 this.treeView.SelectedImageIndex = 0; |
175 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect); | 182 this.treeView.Size = new System.Drawing.Size(240, 250); |
176 this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown); | 183 this.treeView.TabIndex = 0; |
177 // | 184 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect); |
178 // FrmArmyTree | 185 this.treeView.DoubleClick += new System.EventHandler(this.treeView_DoubleClick); |
179 // | 186 this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeView_MouseDown); |
180 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); | 187 // |
181 this.ClientSize = new System.Drawing.Size(240, 277); | 188 // FrmArmyTree |
182 this.ControlBox = false; | 189 // |
183 this.Controls.Add(this.toolBar); | 190 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); |
184 this.Controls.Add(this.treeView); | 191 this.ClientSize = new System.Drawing.Size(240, 277); |
185 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; | 192 this.ControlBox = false; |
186 this.MaximizeBox = false; | 193 this.Controls.Add(this.toolBar); |
187 this.MinimizeBox = false; | 194 this.Controls.Add(this.treeView); |
188 this.Name = "FrmArmyTree"; | 195 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow; |
189 this.Text = "FrmArmyTree"; | 196 this.MaximizeBox = false; |
190 this.ResumeLayout(false); | 197 this.MinimizeBox = false; |
191 this.PerformLayout(); | 198 this.Name = "FrmArmyTree"; |
199 this.Text = "FrmArmyTree"; | |
200 this.ResumeLayout(false); | |
201 this.PerformLayout(); | |
192 | 202 |
193 } | 203 } |
194 #endregion | 204 #endregion |
195 | 205 |
196 private void ClearArmy() | 206 private void ClearArmy() |
238 } | 248 } |
239 } | 249 } |
240 | 250 |
241 private string CreateNodeName(ICostedWarFoundryObject obj) | 251 private string CreateNodeName(ICostedWarFoundryObject obj) |
242 { | 252 { |
243 return Translation.GetTranslation("treeNodeText", "{0} ({1}pts)", obj.Name, obj.Points); | 253 return Translation.GetTranslation("treeNodeText", "{0} ({1} pts)", obj.Name, obj.Points, CurrentGameSystem.UsePointsAbbrev(obj.Points)); |
244 } | 254 } |
245 | 255 |
246 private void NodePointsValueChanged(WarFoundryObject obj, double oldValue, double newValue) | 256 private void NodePointsValueChanged(WarFoundryObject obj, double oldValue, double newValue) |
247 { | 257 { |
248 if (obj is ICostedWarFoundryObject) | 258 if (obj is ICostedWarFoundryObject) |