view FrmUnit.cs @ 145:51463bc1fb21

Fixes #265: Add language preference UI * Make unit equipment lines refresh when language changes
author IBBoard <dev@ibboard.co.uk>
date Sun, 18 Apr 2010 14:22:10 +0000
parents 28105d9c2b25
children 0e3837170637
line source
1 // This file (FrmUnit.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard.
2 //
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.
5 using System;
6 using System.Drawing;
7 using System.Data;
8 using System.Collections.Generic;
9 using System.ComponentModel;
10 using System.Windows.Forms;
11 using IBBoard.Commands;
12 using IBBoard.Lang;
13 using IBBoard.Windows.Forms;
14 using IBBoard.Windows.Forms.I18N;
15 using IBBoard.WarFoundry.API;
16 using IBBoard.WarFoundry.API.Commands;
17 using IBBoard.WarFoundry.API.Objects;
18 using IBBoard.WarFoundry.GUI.WinForms.UI;
19 using IBBoard.WarFoundry.GUI.WinForms.Util;
21 namespace IBBoard.WarFoundry.GUI.WinForms
22 {
23 /// <summary>
24 /// Summary description for FrmUnit.
25 /// </summary>
26 public class FrmUnit : IBBoard.Windows.Forms.IBBForm
27 {
28 private Unit unit;
29 private Dictionary<UnitEquipmentItem, UnitEquipmentChoice> equipmentChoices = new Dictionary<UnitEquipmentItem, UnitEquipmentChoice>();
30 private CommandStack commandStack;
31 private System.Windows.Forms.DataGrid statsGrid;
32 private System.Windows.Forms.TextBox tbUnitName;
33 private System.Windows.Forms.NumericUpDown unitSize;
34 private IBBLabel lblUnitSize;
35 private IBBButton bttnAddWeapon;
36 private IBBButton bttnRemoveWeapon;
37 private IBBLabel lblEquip;
38 private System.Windows.Forms.ListBox equipmentList;
39 private IBBButton bttnReplaceWeapon;
40 private IBBButton bttnEditWeapon;
41 private Label lblPoints;
42 private IBBLabel lblNotes;
43 private TextBox notes;
44 private ListBox abilitiesList;
45 private IBBLabel lblAbilities;
46 /// <summary>
47 /// Required designer variable.
48 /// </summary>
49 private System.ComponentModel.Container components = null;
51 public FrmUnit(Unit toDisplay, CommandStack cmdStack)
52 {
53 unit = toDisplay;
54 commandStack = cmdStack;
55 //
56 // Required for Windows Form Designer support
57 //
58 InitializeComponent();
59 TranslateForm();
60 Translation.TranslationChanged += new MethodInvoker(TranslateForm);
61 unit.NameChanged += new StringValChangedDelegate(unit_NameChanged);
62 unit.UnitSizeChanged += new IntValChangedDelegate(unit_UnitSizeChanged);
63 unit.UnitEquipmentAmountChanged += new DoubleValChangedDelegate(unit_UnitEquipmentAmountChanged);
64 unit.PointsValueChanged += new DoubleValChangedDelegate(unit_PointsValueChanged);
66 unitSize.Value = unit.Size;
67 unitSize.Maximum = (unit.UnitType.MaxSize == WarFoundryCore.INFINITY ? int.MaxValue : unit.UnitType.MaxSize);
68 unitSize.Minimum = unit.UnitType.MinSize;
69 unitSize.Enabled = (unitSize.Maximum != unitSize.Minimum);
71 notes.Text = unit.UnitType.Notes;
72 abilitiesList.DataSource = new List<Ability>(unit.UnitType.GetRequiredAbilities());
73 abilitiesList.DisplayMember = "Name";
74 SetPointsValueText();
75 SetStats();
76 SetWeapons();
77 }
79 private void TranslateForm()
80 {
81 ControlTranslator.TranslateControl(this);
82 tbUnitName.Text = unit.Name;
83 Text = Translation.GetTranslation("FrmUnit", "{0}", unit.Name);
84 RefreshUnitEquipment();
85 }
87 void unit_PointsValueChanged(WarFoundryObject obj, double oldValue, double newValue)
88 {
89 SetPointsValueText();
90 }
92 private void SetPointsValueText()
93 {
94 lblPoints.Text = "(" + unit.Points + " pts)";
95 }
97 private void SetStats()
98 {
99 DataTable dt = new DataTable();
100 Stat[] stats = unit.UnitStatsArrayWithName;
101 int statsCount = stats.Length;
102 DataColumn[] dc = new DataColumn[statsCount];
104 DataGridTableStyle dgStyle = new DataGridTableStyle();
105 dgStyle.RowHeadersVisible = false;
107 Stat stat = stats[0];
108 DataColumn tempCol = new DataColumn(stat.ParentSlotName);
109 tempCol.DataType = stat.GetType();
111 for (int i = 0; i < statsCount; i++)
112 {
113 stat = stats[i];
114 tempCol = new DataColumn(stat.ParentSlotName);
115 tempCol.DataType = stat.GetType();
116 dc[i] = tempCol;
117 DataGridColumnStyle colStyle = new StatColumnStyle();
118 colStyle.Width = 40;
119 colStyle.MappingName = stat.ParentSlotName;
120 colStyle.HeaderText = stat.ParentSlotName;
121 colStyle.Alignment = HorizontalAlignment.Center;
122 colStyle.ReadOnly = true;
123 dgStyle.GridColumnStyles.Add(colStyle);
124 }
126 DataGridColumnStyle nameColStyle = dgStyle.GridColumnStyles[0];
127 nameColStyle.HeaderText = Translation.GetTranslation("UnitName", "Name");
128 nameColStyle.Alignment = HorizontalAlignment.Left;
129 nameColStyle.Width = statsGrid.ClientSize.Width - ((stats.Length - 1) * 40) - 4;
131 dt.Columns.AddRange(dc);
133 DataRow dr = dt.NewRow();
134 dr.ItemArray = stats;
135 dt.Rows.Add(dr);
136 statsGrid.DataSource = dt;
137 statsGrid.TableStyles.Add(dgStyle);
138 }
140 private void SetWeapons()
141 {
142 foreach (UnitEquipmentItem item in unit.GetEquipment())
143 {
144 equipmentList.Items.Add(GetEquipmentChoice(item));
145 }
146 }
148 private UnitEquipmentChoice GetEquipmentChoice(UnitEquipmentItem item)
149 {
150 UnitEquipmentChoice choice = null;
151 equipmentChoices.TryGetValue(item, out choice);
153 if (choice == null)
154 {
155 choice = new UnitEquipmentChoice(Unit, item);
156 equipmentChoices[item] = choice;
157 }
159 return choice;
160 }
162 /// <summary>
163 /// Clean up any resources being used.
164 /// </summary>
165 protected override void Dispose(bool disposing)
166 {
167 //remove our leave events so that disposing doesn't trigger them
168 tbUnitName.Leave -= new System.EventHandler(this.tbUnitName_Leave);
169 unitSize.Leave -= new System.EventHandler(this.unitSize_Leave);
171 if (disposing)
172 {
173 if (components != null)
174 {
175 components.Dispose();
176 }
177 }
178 base.Dispose(disposing);
179 }
181 #region Windows Form Designer generated code
182 /// <summary>
183 /// Required method for Designer support - do not modify
184 /// the contents of this method with the code editor.
185 /// </summary>
186 private void InitializeComponent()
187 {
188 this.statsGrid = new System.Windows.Forms.DataGrid();
189 this.tbUnitName = new System.Windows.Forms.TextBox();
190 this.unitSize = new System.Windows.Forms.NumericUpDown();
191 this.lblUnitSize = new IBBoard.Windows.Forms.IBBLabel();
192 this.lblEquip = new IBBoard.Windows.Forms.IBBLabel();
193 this.bttnAddWeapon = new IBBoard.Windows.Forms.IBBButton();
194 this.bttnRemoveWeapon = new IBBoard.Windows.Forms.IBBButton();
195 this.equipmentList = new System.Windows.Forms.ListBox();
196 this.bttnReplaceWeapon = new IBBoard.Windows.Forms.IBBButton();
197 this.bttnEditWeapon = new IBBoard.Windows.Forms.IBBButton();
198 this.lblPoints = new System.Windows.Forms.Label();
199 this.lblNotes = new IBBoard.Windows.Forms.IBBLabel();
200 this.notes = new System.Windows.Forms.TextBox();
201 this.abilitiesList = new System.Windows.Forms.ListBox();
202 this.lblAbilities = new IBBoard.Windows.Forms.IBBLabel();
203 ((System.ComponentModel.ISupportInitialize) (this.statsGrid)).BeginInit();
204 ((System.ComponentModel.ISupportInitialize) (this.unitSize)).BeginInit();
205 this.SuspendLayout();
206 //
207 // statsGrid
208 //
209 this.statsGrid.AllowNavigation = false;
210 this.statsGrid.AllowSorting = false;
211 this.statsGrid.AlternatingBackColor = System.Drawing.SystemColors.Control;
212 this.statsGrid.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
213 | System.Windows.Forms.AnchorStyles.Right)));
214 this.statsGrid.BackgroundColor = System.Drawing.SystemColors.Control;
215 this.statsGrid.CaptionVisible = false;
216 this.statsGrid.CausesValidation = false;
217 this.statsGrid.DataMember = "";
218 this.statsGrid.GridLineColor = System.Drawing.SystemColors.ControlDarkDark;
219 this.statsGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
220 this.statsGrid.Location = new System.Drawing.Point(8, 32);
221 this.statsGrid.Name = "statsGrid";
222 this.statsGrid.PreferredColumnWidth = 40;
223 this.statsGrid.ReadOnly = true;
224 this.statsGrid.RowHeadersVisible = false;
225 this.statsGrid.SelectionBackColor = System.Drawing.SystemColors.Control;
226 this.statsGrid.SelectionForeColor = System.Drawing.SystemColors.WindowText;
227 this.statsGrid.Size = new System.Drawing.Size(600, 88);
228 this.statsGrid.TabIndex = 0;
229 this.statsGrid.TabStop = false;
230 //
231 // tbUnitName
232 //
233 this.tbUnitName.Location = new System.Drawing.Point(8, 8);
234 this.tbUnitName.Name = "tbUnitName";
235 this.tbUnitName.Size = new System.Drawing.Size(344, 20);
236 this.tbUnitName.TabIndex = 1;
237 this.tbUnitName.Leave += new System.EventHandler(this.tbUnitName_Leave);
238 this.tbUnitName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbUnitName_KeyDown);
239 //
240 // unitSize
241 //
242 this.unitSize.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
243 this.unitSize.Location = new System.Drawing.Point(528, 8);
244 this.unitSize.Name = "unitSize";
245 this.unitSize.Size = new System.Drawing.Size(80, 20);
246 this.unitSize.TabIndex = 1;
247 this.unitSize.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
248 this.unitSize.Value = new decimal(new int[] {
249 1,
250 0,
251 0,
252 0});
253 this.unitSize.Leave += new System.EventHandler(this.unitSize_Leave);
254 this.unitSize.KeyDown += new System.Windows.Forms.KeyEventHandler(this.unitSize_KeyDown);
255 //
256 // lblUnitSize
257 //
258 this.lblUnitSize.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
259 this.lblUnitSize.Location = new System.Drawing.Point(426, 8);
260 this.lblUnitSize.Name = "lblUnitSize";
261 this.lblUnitSize.Size = new System.Drawing.Size(98, 23);
262 this.lblUnitSize.TabIndex = 0;
263 this.lblUnitSize.Text = "unit size";
264 this.lblUnitSize.TextAlign = System.Drawing.ContentAlignment.TopRight;
265 //
266 // lblEquip
267 //
268 this.lblEquip.Location = new System.Drawing.Point(15, 126);
269 this.lblEquip.Name = "lblEquip";
270 this.lblEquip.Size = new System.Drawing.Size(81, 108);
271 this.lblEquip.TabIndex = 3;
272 this.lblEquip.Text = "equipment";
273 this.lblEquip.TextAlign = System.Drawing.ContentAlignment.TopRight;
274 //
275 // bttnAddWeapon
276 //
277 this.bttnAddWeapon.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
278 this.bttnAddWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
279 this.bttnAddWeapon.Location = new System.Drawing.Point(516, 126);
280 this.bttnAddWeapon.Name = "bttnAddWeapon";
281 this.bttnAddWeapon.Size = new System.Drawing.Size(88, 22);
282 this.bttnAddWeapon.TabIndex = 4;
283 this.bttnAddWeapon.Text = "add";
284 this.bttnAddWeapon.Click += new System.EventHandler(this.bttnAddWeapon_Click);
285 //
286 // bttnRemoveWeapon
287 //
288 this.bttnRemoveWeapon.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
289 this.bttnRemoveWeapon.Enabled = false;
290 this.bttnRemoveWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
291 this.bttnRemoveWeapon.Location = new System.Drawing.Point(516, 210);
292 this.bttnRemoveWeapon.Name = "bttnRemoveWeapon";
293 this.bttnRemoveWeapon.Size = new System.Drawing.Size(88, 22);
294 this.bttnRemoveWeapon.TabIndex = 5;
295 this.bttnRemoveWeapon.Text = "remove";
296 this.bttnRemoveWeapon.Click += new System.EventHandler(this.bttnRemoveWeapon_Click);
297 //
298 // equipmentList
299 //
300 this.equipmentList.Anchor = ((System.Windows.Forms.AnchorStyles) (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
301 | System.Windows.Forms.AnchorStyles.Right)));
302 this.equipmentList.Location = new System.Drawing.Point(102, 126);
303 this.equipmentList.Name = "equipmentList";
304 this.equipmentList.Size = new System.Drawing.Size(408, 108);
305 this.equipmentList.TabIndex = 6;
306 this.equipmentList.DoubleClick += new System.EventHandler(this.equipmentList_DoubleClick);
307 this.equipmentList.SelectedIndexChanged += new System.EventHandler(this.equipmentList_SelectedIndexChanged);
308 //
309 // bttnReplaceWeapon
310 //
311 this.bttnReplaceWeapon.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
312 this.bttnReplaceWeapon.Enabled = false;
313 this.bttnReplaceWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
314 this.bttnReplaceWeapon.Location = new System.Drawing.Point(516, 182);
315 this.bttnReplaceWeapon.Name = "bttnReplaceWeapon";
316 this.bttnReplaceWeapon.Size = new System.Drawing.Size(88, 22);
317 this.bttnReplaceWeapon.TabIndex = 10;
318 this.bttnReplaceWeapon.Text = "replace";
319 this.bttnReplaceWeapon.Click += new System.EventHandler(this.bttnReplaceWeapon_Click);
320 //
321 // bttnEditWeapon
322 //
323 this.bttnEditWeapon.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
324 this.bttnEditWeapon.Enabled = false;
325 this.bttnEditWeapon.FlatStyle = System.Windows.Forms.FlatStyle.System;
326 this.bttnEditWeapon.Location = new System.Drawing.Point(516, 154);
327 this.bttnEditWeapon.Name = "bttnEditWeapon";
328 this.bttnEditWeapon.Size = new System.Drawing.Size(88, 22);
329 this.bttnEditWeapon.TabIndex = 11;
330 this.bttnEditWeapon.Text = "edit";
331 this.bttnEditWeapon.Click += new System.EventHandler(this.bttnEditWeapon_Click);
332 //
333 // lblPoints
334 //
335 this.lblPoints.Location = new System.Drawing.Point(358, 8);
336 this.lblPoints.Name = "lblPoints";
337 this.lblPoints.Size = new System.Drawing.Size(77, 21);
338 this.lblPoints.TabIndex = 12;
339 this.lblPoints.Text = "(points)";
340 //
341 // lblNotes
342 //
343 this.lblNotes.Location = new System.Drawing.Point(13, 317);
344 this.lblNotes.Name = "lblNotes";
345 this.lblNotes.Size = new System.Drawing.Size(84, 62);
346 this.lblNotes.TabIndex = 13;
347 this.lblNotes.Text = "notes";
348 this.lblNotes.TextAlign = System.Drawing.ContentAlignment.TopRight;
349 //
350 // notes
351 //
352 this.notes.Location = new System.Drawing.Point(102, 317);
353 this.notes.Multiline = true;
354 this.notes.Name = "notes";
355 this.notes.ReadOnly = true;
356 this.notes.Size = new System.Drawing.Size(408, 62);
357 this.notes.TabIndex = 14;
358 //
359 // abilitiesList
360 //
361 this.abilitiesList.FormattingEnabled = true;
362 this.abilitiesList.Location = new System.Drawing.Point(102, 240);
363 this.abilitiesList.Name = "abilitiesList";
364 this.abilitiesList.Size = new System.Drawing.Size(408, 69);
365 this.abilitiesList.TabIndex = 15;
366 //
367 // lblAbilities
368 //
369 this.lblAbilities.Location = new System.Drawing.Point(13, 240);
370 this.lblAbilities.Name = "lblAbilities";
371 this.lblAbilities.Size = new System.Drawing.Size(84, 62);
372 this.lblAbilities.TabIndex = 16;
373 this.lblAbilities.Text = "abilities";
374 this.lblAbilities.TextAlign = System.Drawing.ContentAlignment.TopRight;
375 //
376 // FrmUnit
377 //
378 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
379 this.ClientSize = new System.Drawing.Size(616, 391);
380 this.Controls.Add(this.lblAbilities);
381 this.Controls.Add(this.abilitiesList);
382 this.Controls.Add(this.notes);
383 this.Controls.Add(this.lblNotes);
384 this.Controls.Add(this.lblPoints);
385 this.Controls.Add(this.bttnEditWeapon);
386 this.Controls.Add(this.bttnReplaceWeapon);
387 this.Controls.Add(this.equipmentList);
388 this.Controls.Add(this.bttnRemoveWeapon);
389 this.Controls.Add(this.bttnAddWeapon);
390 this.Controls.Add(this.lblEquip);
391 this.Controls.Add(this.lblUnitSize);
392 this.Controls.Add(this.unitSize);
393 this.Controls.Add(this.tbUnitName);
394 this.Controls.Add(this.statsGrid);
395 this.Name = "FrmUnit";
396 this.ShowIcon = false;
397 this.ShowInTaskbar = false;
398 this.Text = "FrmUnit";
399 this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmUnit_FormClosing);
400 ((System.ComponentModel.ISupportInitialize) (this.statsGrid)).EndInit();
401 ((System.ComponentModel.ISupportInitialize) (this.unitSize)).EndInit();
402 this.ResumeLayout(false);
403 this.PerformLayout();
405 }
406 #endregion
408 public Unit Unit
409 {
410 get { return unit; }
411 }
413 private void tbUnitName_Leave(object sender, System.EventArgs e)
414 {
415 UpdateUnitName();
416 }
418 private void tbUnitName_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
419 {
420 if (e.KeyCode == Keys.Enter)
421 {
422 UpdateUnitName();
423 }
424 }
426 private void UpdateUnitName()
427 {
428 if (unit.Name != tbUnitName.Text)
429 {
430 commandStack.Execute(new SetNameCommand(unit, tbUnitName.Text));
431 }
432 }
434 private void unitSize_Leave(object sender, System.EventArgs e)
435 {
436 UpdateUnitSize();
437 }
439 private void unitSize_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
440 {
441 if (e.KeyCode == Keys.Enter)
442 {
443 UpdateUnitSize();
444 }
445 }
447 private void UpdateUnitSize()
448 {
449 if (unit.Size != unitSize.Value)
450 {
451 commandStack.Execute(new SetUnitSizeCommand(unit, (int) unitSize.Value));
452 }
453 }
455 private void unit_NameChanged(WarFoundryObject obj, string oldValue, string newValue)
456 {
457 if (obj is Unit && obj.Equals(unit))
458 {
459 Unit u = (Unit) obj;
460 tbUnitName.Text = obj.Name;
461 Text = obj.Name;
462 }
463 }
465 private void unit_UnitSizeChanged(WarFoundryObject obj, int oldValue, int newValue)
466 {
467 if (obj is Unit && obj.Equals(unit))
468 {
469 unitSize.Value = newValue;
471 RefreshUnitEquipment();
472 }
473 }
475 private void RefreshUnitEquipment()
476 {
477 foreach (UnitEquipmentChoice choice in equipmentChoices.Values)
478 {
479 SetEquipmentListValue(choice);
480 }
481 }
483 private void equipmentList_SelectedIndexChanged(object sender, System.EventArgs e)
484 {
485 SetButtonsEnabledState();
486 }
488 private void SetButtonsEnabledState()
489 {
491 UnitEquipmentItem equipItem = GetSelectedUnitEquipmentItem();
492 bttnReplaceWeapon.Enabled = (equipItem != null && equipItem.HasAlternatives());
493 bttnEditWeapon.Enabled = (equipItem != null);
494 bttnRemoveWeapon.Enabled = (equipItem != null && !equipItem.IsRequired);
495 }
497 private void unit_UnitEquipmentAmountChanged(WarFoundryObject obj, double oldValue, double newValue)
498 {
499 if (obj is UnitEquipmentItem)
500 {
501 UnitEquipmentItem equip = (UnitEquipmentItem) obj;
502 UnitEquipmentChoice equipChoice = GetEquipmentChoice(equip);
504 if (newValue == 0)
505 {
506 equipmentList.Items.Remove(equipChoice);
507 }
508 else
509 {
510 SetEquipmentListValue(equipChoice);
511 }
512 }
513 }
515 private void SetEquipmentListValue(UnitEquipmentChoice equipChoice)
516 {
517 int idx = equipmentList.Items.IndexOf(equipChoice);
519 if (idx > -1)
520 {
521 equipmentList.Items[idx] = equipChoice;
522 }
523 else
524 {
525 equipmentList.Items.Add(equipChoice);
526 }
527 }
529 private void EditWeapon()
530 {
531 UnitEquipmentItem item = GetSelectedUnitEquipmentItem();
533 if (item != null)
534 {
535 FrmEditUnitEquipment editEquip = new FrmEditUnitEquipment(Unit, item, commandStack);
536 editEquip.ShowDialog(this);
537 }
538 }
540 private UnitEquipmentItem GetSelectedUnitEquipmentItem()
541 {
542 UnitEquipmentChoice selectedItem = GetSelectedUnitEquipmentChoice();
543 UnitEquipmentItem equipItem = null;
545 if (selectedItem!=null)
546 {
547 equipItem = selectedItem.Item;
548 }
550 return equipItem;
551 }
553 private UnitEquipmentChoice GetSelectedUnitEquipmentChoice()
554 {
555 return (UnitEquipmentChoice) equipmentList.SelectedItem;
556 }
558 private void bttnEditWeapon_Click(object sender, System.EventArgs e)
559 {
560 EditWeapon();
561 }
563 private void equipmentList_DoubleClick(object sender, System.EventArgs e)
564 {
565 EditWeapon();
566 }
568 private void AddWeapon()
569 {
570 FrmNewUnitEquipment newEquip = new FrmNewUnitEquipment(Unit, commandStack);
571 newEquip.ShowDialog(this);
572 }
574 private void bttnAddWeapon_Click(object sender, System.EventArgs e)
575 {
576 AddWeapon();
577 }
579 private void RemoveWeapon()
580 {
581 commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, GetSelectedUnitEquipmentItem(), 0));
582 }
584 private void bttnRemoveWeapon_Click(object sender, System.EventArgs e)
585 {
586 RemoveWeapon();
587 }
589 private void bttnReplaceWeapon_Click(object sender, System.EventArgs e)
590 {
591 FrmReplaceUnitEquipment replace = new FrmReplaceUnitEquipment(unit, GetSelectedUnitEquipmentItem(), commandStack);
592 replace.ShowDialog(this);
593 }
595 private void FrmUnit_FormClosing(object sender, FormClosingEventArgs e)
596 {
597 UpdateUnitName();
598 UpdateUnitSize();
599 }
600 }