annotate FrmEditUnitEquipment.cs @ 183:75afd724a825

* Increase WarFoundry WinForms version numbers to 0.1 in preparation for first WinForms release no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Mon, 18 Oct 2010 20:00:01 +0000
parents d3f498514122
children
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 (FrmEditUnitEquipment.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
2 //
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.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
4
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
5 using System;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
6 using System.Drawing;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
7 using System.ComponentModel;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
8 using System.Windows.Forms;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
9 using IBBoard.Commands;
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
10 using IBBoard.Lang;
80
c243b043aa62 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
11 using IBBoard.Windows.Forms;
c243b043aa62 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
12 using IBBoard.Windows.Forms.I18N;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
13 using IBBoard.WarFoundry.API;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
14 using IBBoard.WarFoundry.API.Commands;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
15 using IBBoard.WarFoundry.API.Objects;
101
3e78af88ceb3 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
16 using IBBoard.WarFoundry.API.Util;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
17
42
d06c2e390a14 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
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
19 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
20 /// <summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
21 /// Summary description for FrmEditUnitEquipment.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
22 /// </summary>
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
23 public class FrmEditUnitEquipment : IBBForm
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
24 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
25 private Unit unit;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
26 private UnitEquipmentItem equipItem;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
27 private CommandStack commandStack;
80
c243b043aa62 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
28 private IBBLabel lblAmount;
c243b043aa62 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
29 private IBBButton bttnCancel;
c243b043aa62 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 77
diff changeset
30 private IBBButton bttnOkay;
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
31 private IBBoard.WarFoundry.GUI.WinForms.UI.EquipmentAmountControl equipmentAmount;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
32 /// <summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
33 /// Required designer variable.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
34 /// </summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
35 private System.ComponentModel.Container components = null;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
37 public FrmEditUnitEquipment(Unit unit, UnitEquipmentItem equipItem, CommandStack stack)
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
38 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
39 commandStack = stack;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
40 this.unit = unit;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
41 this.equipItem = equipItem;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
42 InitializeComponent();
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
43 ControlTranslator.TranslateControl(this);
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
44 this.Text = Translation.GetTranslation("FrmEditUnitEquipment", "edit {0} for {1}", equipItem.Name, unit.Name);
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
45 equipmentAmount.SetUnit(unit);
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
46 equipmentAmount.SetUnitEquipmentItem(equipItem);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
47 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
48
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
49 /// <summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
50 /// Clean up any resources being used.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
51 /// </summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
52 protected override void Dispose( bool disposing )
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
53 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
54 if( disposing )
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
55 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
56 if(components != null)
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
57 {
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
58 components.Dispose();
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
59 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
60 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
61 base.Dispose( disposing );
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
62 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
63
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
64 #region Windows Form Designer generated code
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
65 /// <summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
66 /// Required method for Designer support - do not modify
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
67 /// the contents of this method with the code editor.
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
68 /// </summary>
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
69 private void InitializeComponent()
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
70 {
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
71 this.lblAmount = new IBBoard.Windows.Forms.IBBLabel();
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
72 this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
73 this.bttnOkay = new IBBoard.Windows.Forms.IBBButton();
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
74 this.equipmentAmount = new IBBoard.WarFoundry.GUI.WinForms.UI.EquipmentAmountControl();
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
75 this.SuspendLayout();
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
76 //
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
77 // lblAmount
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
78 //
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
79 this.lblAmount.Location = new System.Drawing.Point(12, 8);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
80 this.lblAmount.Name = "lblAmount";
85
0bb9f40d44eb Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents: 80
diff changeset
81 this.lblAmount.Size = new System.Drawing.Size(68, 74);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
82 this.lblAmount.TabIndex = 2;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
83 this.lblAmount.Text = "amount";
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
84 this.lblAmount.TextAlign = System.Drawing.ContentAlignment.TopRight;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
85 //
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
86 // bttnCancel
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
87 //
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
88 this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
89 this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
90 this.bttnCancel.Location = new System.Drawing.Point(153, 95);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
91 this.bttnCancel.Name = "bttnCancel";
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
92 this.bttnCancel.Size = new System.Drawing.Size(75, 23);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
93 this.bttnCancel.TabIndex = 3;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
94 this.bttnCancel.Text = "cancel";
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
95 this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
96 //
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
97 // bttnOkay
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
98 //
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
99 this.bttnOkay.Enabled = false;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
100 this.bttnOkay.FlatStyle = System.Windows.Forms.FlatStyle.System;
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
101 this.bttnOkay.Location = new System.Drawing.Point(12, 95);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
102 this.bttnOkay.Name = "bttnOkay";
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
103 this.bttnOkay.Size = new System.Drawing.Size(75, 23);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
104 this.bttnOkay.TabIndex = 4;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
105 this.bttnOkay.Text = "okay";
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
106 this.bttnOkay.Click += new System.EventHandler(this.bttnOkay_Click);
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
107 //
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
108 // equipmentAmount
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
109 //
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
110 this.equipmentAmount.Location = new System.Drawing.Point(88, 5);
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
111 this.equipmentAmount.Name = "equipmentAmount";
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
112 this.equipmentAmount.Size = new System.Drawing.Size(155, 77);
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
113 this.equipmentAmount.TabIndex = 5;
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
114 this.equipmentAmount.ValueChanged += new System.EventHandler(this.equipmentAmount_ValueChanged);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
115 //
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
116 // FrmEditUnitEquipment
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
117 //
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
118 this.AcceptButton = this.bttnOkay;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
119 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
120 this.CancelButton = this.bttnCancel;
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
121 this.ClientSize = new System.Drawing.Size(240, 130);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
122 this.ControlBox = false;
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
123 this.Controls.Add(this.equipmentAmount);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
124 this.Controls.Add(this.bttnOkay);
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
125 this.Controls.Add(this.bttnCancel);
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
126 this.Controls.Add(this.lblAmount);
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
127 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
128 this.Name = "FrmEditUnitEquipment";
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
129 this.ShowInTaskbar = false;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
130 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
131 this.Text = "FrmEditUnitEquipment";
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
132 this.ResumeLayout(false);
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
133
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
134 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
135 #endregion
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
136
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
137 private void bttnOkay_Click(object sender, System.EventArgs e)
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
138 {
43
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
139 if (SetValue())
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
140 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
141 this.Close();
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
142 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
143 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
144
43
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
145 private bool SetValue()
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
146 {
43
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
147 bool setValue = true;
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
148 double amount = equipmentAmount.EquipmentAmount;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
149
43
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
150 if (amount == 0)
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
151 {
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
152 if (equipItem.IsRequired)
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
153 {
156
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
154 string requiredText = "this item is required and cannot be removed - it must exist or be replaced";
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
155 string requiredTitle = "required item";
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
156 requiredText = Translation.GetTranslation("removeRequiredEquipmentText", requiredText);
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
157 requiredTitle = Translation.GetTranslation("removeRequiredEquipmentTitle", requiredTitle);
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
158 MessageBox.Show(this, requiredText, requiredTitle, MessageBoxButtons.OK, MessageBoxIcon.Warning);
43
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
159 setValue = false;
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
160 }
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
161 else
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
162 {
156
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
163 string removeEquipText = "remove equipment item from unit?";
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
164 string removeEquipTitle = "confirm removing equipment";
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
165 removeEquipText = Translation.GetTranslation("removeEquipmentText", removeEquipText);
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
166 removeEquipTitle = Translation.GetTranslation("removeEquipmentTitle", removeEquipTitle);
d3f498514122 Fixes #283: "Confirm Remove" for equipment dialog isn't translatable
IBBoard <dev@ibboard.co.uk>
parents: 101
diff changeset
167 DialogResult dr = MessageBox.Show(this, removeEquipText, removeEquipTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
168
43
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
169 if (dr != DialogResult.Yes)
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
170 {
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
171 setValue = false;
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
172 }
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
173 }
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
174 }
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
175
101
3e78af88ceb3 Re #179: Make sure that translations are used throughout UI
IBBoard <dev@ibboard.co.uk>
parents: 98
diff changeset
176 double oldAmount = UnitEquipmentUtil.GetEquipmentAmount(unit, equipItem);
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
177
43
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
178 if (setValue && oldAmount != amount)
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
179 {
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
180 if (equipmentAmount.IsRatioEquipmentAmount)
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
181 {
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
182 commandStack.Execute(new SetUnitEquipmentRatioAmountCommand(unit, equipItem, amount));
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
183 }
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
184 else
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
185 {
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
186 commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, equipItem, (int)amount));
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
187 }
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
188 }
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
189
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
190 return setValue;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
191 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
192
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
193 private void bttnCancel_Click(object sender, System.EventArgs e)
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
194 {
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
195 this.Close();
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
196 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
197
98
c7afc7824f50 Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
198 private void SetOkayButton()
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
199 {
43
7ace7d2249ac Fixes #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 42
diff changeset
200 double equipAmount = equipmentAmount.EquipmentAmount;
98
c7afc7824f50 Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
201 bttnOkay.Enabled = equipAmount > 0 || !equipItem.IsRequired;
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
202 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
203
42
d06c2e390a14 Re #117: Add percentage and number boxes to equipment item dialogs
IBBoard <dev@ibboard.co.uk>
parents: 36
diff changeset
204 private void equipmentAmount_ValueChanged(object sender, EventArgs e)
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
205 {
98
c7afc7824f50 Fixes #218: "Amount too high" warning can result in negative items
IBBoard <dev@ibboard.co.uk>
parents: 85
diff changeset
206 SetOkayButton();
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
207 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
208 }
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 34
diff changeset
209 }