annotate FrmNewUnitEquipment.cs @ 76:f2006db02ad9

Re #192: Improve "clean coding" practice * Use new methods in WinForms UI
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Oct 2009 14:24:52 +0000
parents bdd10c56a917
children 0bb9f40d44eb
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;
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
17
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
18 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
19 {
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
20 /// <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
21 /// 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
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 public class FrmNewUnitEquipment : System.Windows.Forms.Form
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 {
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
25 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
26 private CommandStack commandStack;
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 System.Windows.Forms.Label 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
28 private System.Windows.Forms.Button 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
29 private System.Windows.Forms.Button 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
30 private System.Windows.Forms.Label 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
31 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
32 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
33 /// <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
34 /// 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
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 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
37
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 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
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 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 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
42 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
43 this.Text = "New equipment for " + unit.Name;
76
f2006db02ad9 Re #192: Improve "clean coding" practice
IBBoard <dev@ibboard.co.uk>
parents: 75
diff changeset
44 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
45 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
46 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
47 }
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
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
49 /// <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
50 /// 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
51 /// </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
52 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
53 {
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 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
55 {
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 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
57 {
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 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
59 }
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 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
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 #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
65 /// <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
66 /// 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
67 /// 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
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 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
70 {
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 this.lblAmount = new System.Windows.Forms.Label();
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 this.bttnCancel = new System.Windows.Forms.Button();
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 this.bttnOkay = new System.Windows.Forms.Button();
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
74 this.lblItem = new System.Windows.Forms.Label();
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
75 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
76 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
77 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
78 //
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
79 // 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
80 //
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 this.lblAmount.Location = new System.Drawing.Point(8, 80);
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 this.lblAmount.Name = "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 this.lblAmount.Size = new System.Drawing.Size(72, 23);
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
84 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
85 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
86 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
87 //
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 // 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
89 //
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 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98 //
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 // 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
100 //
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 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 //
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 // 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
111 //
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 this.lblItem.Location = new System.Drawing.Point(0, 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
113 this.lblItem.Name = "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 this.lblItem.Size = new System.Drawing.Size(80, 23);
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
115 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
116 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
117 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
118 //
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 // 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
120 //
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 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
122 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
123 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
124 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
125 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
126 //
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
127 // equipmentAmount
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
128 //
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
129 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
130 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
131 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
132 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
133 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
134 //
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
135 // 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
136 //
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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150 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
151 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
152 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
153 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
154
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 }
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 #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
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 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
159 {
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
160 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
161 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
162 }
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
163
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
164 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
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 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
167
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
168 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
169 {
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
170 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
171 }
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 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
173 {
40
740350673006 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
174 //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
175 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
176 }
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
177 }
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
178
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 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
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 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
182 }
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 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
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 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
187 {
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
188 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
189 }
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 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
191 {
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
192 equipmentAmount.SetUnitEquipmentItem(null);
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
193 }
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
194
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
195 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
196 }
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
197
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
198 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
199 {
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
200 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
201 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
202 }
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
203
41
4fc87d6e6119 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 40
diff changeset
204 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
205 {
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
206 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
207 }
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
208 }
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 }