annotate FrmNewUnitEquipment.cs @ 110:39b93ca5fb9c

Fixes #234: Invalid data file doesn't stop load * Refactor army change code * Only set CurrentArmy value once we know it is safe and properly loaded * Separate out smaller methods with sensible names * Make CurrentGameSystem and CurrentArmy non-static Also: * Use parameter in FrmNewArmy constructor instead of ignoring it
author IBBoard <dev@ibboard.co.uk>
date Sat, 19 Dec 2009 15:45:21 +0000
parents 0bb9f40d44eb
children c1a3993297b1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
1 // This file (FrmNewUnitEquipment.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2008, 2009 IBBoard.
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
2 //
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
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.
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
4
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
5 using System;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
6 using System.Drawing;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
7 using System.ComponentModel;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
8 using System.Windows.Forms;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
9 using IBBoard;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
10 using IBBoard.Commands;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
11 using IBBoard.Lang;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
12 using IBBoard.WarFoundry.API;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
13 using IBBoard.WarFoundry.API.Commands;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
14 using IBBoard.WarFoundry.API.Objects;
76
f2006db02ad9 Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 75
diff changeset
15 using IBBoard.WarFoundry.API.Util;
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
16 using IBBoard.WarFoundry.GUI.WinForms.Util;
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
17 using IBBoard.Windows.Forms;
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
18 using IBBoard.Windows.Forms.I18N;
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
19
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
20 namespace IBBoard.WarFoundry.GUI.WinForms
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
21 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
22 /// <summary>
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
23 /// Summary description for FrmNewUnitEquipment.
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
24 /// </summary>
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
25 public class FrmNewUnitEquipment : IBBForm
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
26 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
27 private Unit unit;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
28 private CommandStack commandStack;
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
29 private IBBLabel lblAmount;
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
30 private IBBButton bttnCancel;
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
31 private IBBButton bttnOkay;
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
32 private IBBLabel lblItem;
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
33 private System.Windows.Forms.ListBox listItems;
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
34 private IBBoard.WarFoundry.GUI.WinForms.UI.EquipmentAmountControl equipmentAmount;
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
35 /// <summary>
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
36 /// Required designer variable.
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
37 /// </summary>
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
38 private System.ComponentModel.Container components = null;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
39
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
40 public FrmNewUnitEquipment(Unit unit, CommandStack stack)
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
41 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
42 commandStack = stack;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
43 this.unit = unit;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
44 InitializeComponent();
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
45 ControlTranslator.TranslateControl(this);
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
46 this.Text = Translation.GetTranslation("FrmNewUnitEquipment", "new equipment for {0}", unit.Name);
76
f2006db02ad9 Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 75
diff changeset
47 object[] items = Arrays.Subtract(UnitEquipmentUtil.GetAllowedEquipmentItems(unit), unit.GetEquipment());
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
48 listItems.Items.AddRange(items);
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
49 equipmentAmount.SetUnit(unit);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
50 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
51
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
52 /// <summary>
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
53 /// Clean up any resources being used.
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
54 /// </summary>
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
55 protected override void Dispose( bool disposing )
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
56 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
57 if( disposing )
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
58 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
59 if(components != null)
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
60 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
61 components.Dispose();
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
62 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
63 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
64 base.Dispose( disposing );
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
65 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
66
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
67 #region Windows Form Designer generated code
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
68 /// <summary>
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
69 /// Required method for Designer support - do not modify
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
70 /// the contents of this method with the code editor.
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
71 /// </summary>
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
72 private void InitializeComponent()
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
73 {
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
74 this.lblAmount = new IBBoard.Windows.Forms.IBBLabel();
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
75 this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
76 this.bttnOkay = new IBBoard.Windows.Forms.IBBButton();
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
77 this.lblItem = new IBBoard.Windows.Forms.IBBLabel();
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
78 this.listItems = new System.Windows.Forms.ListBox();
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
79 this.equipmentAmount = new IBBoard.WarFoundry.GUI.WinForms.UI.EquipmentAmountControl();
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
80 this.SuspendLayout();
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
81 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
82 // lblAmount
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
83 //
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
84 this.lblAmount.Location = new System.Drawing.Point(12, 80);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
85 this.lblAmount.Name = "lblAmount";
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
86 this.lblAmount.Size = new System.Drawing.Size(68, 77);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
87 this.lblAmount.TabIndex = 2;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
88 this.lblAmount.Text = "amount";
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
89 this.lblAmount.TextAlign = System.Drawing.ContentAlignment.TopRight;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
90 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
91 // bttnCancel
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
92 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
93 this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
94 this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
95 this.bttnCancel.Location = new System.Drawing.Point(158, 162);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
96 this.bttnCancel.Name = "bttnCancel";
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
97 this.bttnCancel.Size = new System.Drawing.Size(75, 23);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
98 this.bttnCancel.TabIndex = 3;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
99 this.bttnCancel.Text = "cancel";
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
100 this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
101 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
102 // bttnOkay
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
103 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
104 this.bttnOkay.Enabled = false;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
105 this.bttnOkay.FlatStyle = System.Windows.Forms.FlatStyle.System;
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
106 this.bttnOkay.Location = new System.Drawing.Point(12, 162);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
107 this.bttnOkay.Name = "bttnOkay";
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
108 this.bttnOkay.Size = new System.Drawing.Size(75, 23);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
109 this.bttnOkay.TabIndex = 4;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
110 this.bttnOkay.Text = "okay";
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
111 this.bttnOkay.Click += new System.EventHandler(this.bttnOkay_Click);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
112 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
113 // lblItem
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
114 //
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
115 this.lblItem.Location = new System.Drawing.Point(12, 8);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
116 this.lblItem.Name = "lblItem";
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 76
diff changeset
117 this.lblItem.Size = new System.Drawing.Size(68, 69);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
118 this.lblItem.TabIndex = 6;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
119 this.lblItem.Text = "item";
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
120 this.lblItem.TextAlign = System.Drawing.ContentAlignment.TopRight;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
121 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
122 // listItems
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
123 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
124 this.listItems.Location = new System.Drawing.Point(88, 8);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
125 this.listItems.Name = "listItems";
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
126 this.listItems.Size = new System.Drawing.Size(145, 69);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
127 this.listItems.TabIndex = 7;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
128 this.listItems.SelectedIndexChanged += new System.EventHandler(this.listItems_SelectedIndexChanged);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
129 //
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
130 // equipmentAmount
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
131 //
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
132 this.equipmentAmount.Location = new System.Drawing.Point(88, 80);
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
133 this.equipmentAmount.Name = "equipmentAmount";
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
134 this.equipmentAmount.Size = new System.Drawing.Size(155, 77);
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
135 this.equipmentAmount.TabIndex = 8;
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
136 this.equipmentAmount.ValueChanged += new System.EventHandler(this.equipmentAmount_ValueChanged);
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
137 //
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
138 // FrmNewUnitEquipment
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
139 //
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
140 this.AcceptButton = this.bttnOkay;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
141 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
142 this.CancelButton = this.bttnCancel;
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
143 this.ClientSize = new System.Drawing.Size(245, 190);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
144 this.ControlBox = false;
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
145 this.Controls.Add(this.equipmentAmount);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
146 this.Controls.Add(this.listItems);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
147 this.Controls.Add(this.lblItem);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
148 this.Controls.Add(this.bttnOkay);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
149 this.Controls.Add(this.bttnCancel);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
150 this.Controls.Add(this.lblAmount);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
151 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
152 this.Name = "FrmNewUnitEquipment";
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
153 this.ShowInTaskbar = false;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
154 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
155 this.Text = "FrmEditUnitEquipment";
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
156 this.ResumeLayout(false);
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
157
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
158 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
159 #endregion
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
160
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
161 private void bttnOkay_Click(object sender, System.EventArgs e)
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
162 {
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
163 SetValue();
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
164 this.Close();
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
165 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
166
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
167 private void SetValue()
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
168 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
169 UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem;
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
170
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
171 if (equipmentAmount.IsRatioEquipmentAmount)
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
172 {
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
173 commandStack.Execute(new SetUnitEquipmentRatioAmountCommand(unit, equipItem, equipmentAmount.EquipmentAmount));
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
174 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
175 else
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
176 {
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
177 //Just cast here - we should be returned a whole number anyway
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
178 commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, equipItem, (int) equipmentAmount.EquipmentAmount));
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
179 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
180 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
181
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
182 private void bttnCancel_Click(object sender, System.EventArgs e)
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
183 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
184 this.Close();
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
185 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
186
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
187 private void listItems_SelectedIndexChanged(object sender, System.EventArgs e)
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
188 {
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
189 if (listItems.SelectedIndex > -1)
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
190 {
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
191 equipmentAmount.SetUnitEquipmentItem((UnitEquipmentItem)listItems.SelectedItem);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
192 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
193 else
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
194 {
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
195 equipmentAmount.SetUnitEquipmentItem(null);
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
196 }
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
197
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
198 setOkayButton();
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
199 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
200
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
201 private void setOkayButton()
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
202 {
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
203 double equipAmount = equipmentAmount.EquipmentAmount;
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
204 bttnOkay.Enabled = listItems.SelectedIndex > -1 && (equipAmount > 0 || equipAmount == WarFoundryCore.INFINITY);
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
205 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
206
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
207 private void equipmentAmount_ValueChanged(object sender, EventArgs e)
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
208 {
34
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
209 setOkayButton();
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
210 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
211 }
3ceb0efd261f Re #118: Allow equipment amounts of "ratio" equipment to be define as absolute or ratio amounts
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
212 }