annotate FrmNewUnit.cs @ 99:acaea18ac0a1

Fixes #220: Make percentage and numeric amounts more obvious * Differentiate between "free" and costed and build up a new string with more options * Make use of translations for all of the parts of the line Re #179: Make sure that translations are used throughout UI * Add new translations to file
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Nov 2009 16:41:28 +0000
parents 1576f669b3eb
children 1bcd7ea857c4
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: 24
diff changeset
1 // This file (FrmNewUnit.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard.
24
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
2 //
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 24
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.
24
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
4
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
5 using System;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
6 using System.Drawing;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
7 using System.ComponentModel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
8 using System.Windows.Forms;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
9 using IBBoard;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
10 using IBBoard.Lang;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
11 using IBBoard.Windows.Forms;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
12 using IBBoard.WarFoundry.API;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
13 using IBBoard.WarFoundry.API.Objects;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
14 using IBBoard.Windows.Forms.I18N;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
15
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
16 namespace IBBoard.WarFoundry
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
17 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
18 /// <summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
19 /// Summary description for FrmNewUnit.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
20 /// </summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
21 public class FrmNewUnit : IBBForm
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
22 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
23 private System.ComponentModel.IContainer components;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
24 private IBBoard.Windows.Forms.IBBButton bttnCancel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
25 private IBBoard.Windows.Forms.IBBLabel lblUnitList;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
26 private IBBoard.Windows.Forms.IBBButton bttnSelectUnit;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
27 private System.Windows.Forms.ListBox lstUnits;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
28 private UnitType[] units;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
29 private Army army;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
30 private System.Windows.Forms.ImageList imageList;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
31 private System.Windows.Forms.Label lblNewUnitWarning;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
32 private System.Windows.Forms.Label lblWarningIcon;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
33 private bool[] allowed;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
34
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
35 public FrmNewUnit(Race race, Category cat, Army army)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
36 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
37 InitializeComponent();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
38
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
39 ControlTranslator.TranslateControl(this, cat.Name);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
40 units = race.GetUnitTypes(cat);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
41 allowed = new bool[units.Length];
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
42 this.army = army;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
43
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
44 for (int i = 0; i<units.Length; i++)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
45 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
46 allowed[i] = army.CanAddUnitType(units[i]).Count == 0;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
47 lstUnits.Items.Add(units[i].Name);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
48 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
49 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
50
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
51 /// <summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
52 /// Clean up any resources being used.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
53 /// </summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
54 protected override void Dispose( bool disposing )
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
55 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
56 if( disposing )
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
57 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
58 if(components != null)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
59 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
60 components.Dispose();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
61 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
62 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
63 base.Dispose( disposing );
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
64 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
65
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
66 #region Windows Form Designer generated code
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
67 /// <summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
68 /// Required method for Designer support - do not modify
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
69 /// the contents of this method with the code editor.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
70 /// </summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
71 private void InitializeComponent()
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
72 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
73 this.components = new System.ComponentModel.Container();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
74 System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmNewUnit));
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
75 this.lstUnits = new System.Windows.Forms.ListBox();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
76 this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
77 this.lblUnitList = new IBBoard.Windows.Forms.IBBLabel();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
78 this.bttnSelectUnit = new IBBoard.Windows.Forms.IBBButton();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
79 this.lblNewUnitWarning = new System.Windows.Forms.Label();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
80 this.imageList = new System.Windows.Forms.ImageList(this.components);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
81 this.lblWarningIcon = new System.Windows.Forms.Label();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
82 this.SuspendLayout();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
83 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
84 // lstUnits
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
85 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
86 this.lstUnits.Location = new System.Drawing.Point(88, 8);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
87 this.lstUnits.Name = "lstUnits";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
88 this.lstUnits.Size = new System.Drawing.Size(272, 121);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
89 this.lstUnits.TabIndex = 7;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
90 this.lstUnits.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstUnits_MouseDown);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
91 this.lstUnits.DoubleClick += new System.EventHandler(this.lstUnits_DoubleClick);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
92 this.lstUnits.SelectedIndexChanged += new System.EventHandler(this.lstUnits_SelectedIndexChanged);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
93 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
94 // bttnCancel
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
95 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
96 this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
97 this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
98 this.bttnCancel.Location = new System.Drawing.Point(8, 168);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
99 this.bttnCancel.Name = "bttnCancel";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
100 this.bttnCancel.Size = new System.Drawing.Size(80, 24);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
101 this.bttnCancel.TabIndex = 6;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
102 this.bttnCancel.Text = "Cancel";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
103 this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
104 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
105 // lblUnitList
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
106 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
107 this.lblUnitList.Location = new System.Drawing.Point(0, 8);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
108 this.lblUnitList.Name = "lblUnitList";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
109 this.lblUnitList.Size = new System.Drawing.Size(88, 80);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
110 this.lblUnitList.TabIndex = 5;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
111 this.lblUnitList.Text = "unit list";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
112 this.lblUnitList.TextAlign = System.Drawing.ContentAlignment.TopRight;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
113 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
114 // bttnSelectUnit
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
115 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
116 this.bttnSelectUnit.Enabled = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
117 this.bttnSelectUnit.FlatStyle = System.Windows.Forms.FlatStyle.System;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
118 this.bttnSelectUnit.Location = new System.Drawing.Point(256, 168);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
119 this.bttnSelectUnit.Name = "bttnSelectUnit";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
120 this.bttnSelectUnit.Size = new System.Drawing.Size(104, 24);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
121 this.bttnSelectUnit.TabIndex = 4;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
122 this.bttnSelectUnit.Text = "create unit";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
123 this.bttnSelectUnit.Click += new System.EventHandler(this.bttnSelectUnit_Click);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
124 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
125 // lblNewUnitWarning
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
126 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
127 this.lblNewUnitWarning.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
128 this.lblNewUnitWarning.ImageList = this.imageList;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
129 this.lblNewUnitWarning.Location = new System.Drawing.Point(48, 136);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
130 this.lblNewUnitWarning.Name = "lblNewUnitWarning";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
131 this.lblNewUnitWarning.Size = new System.Drawing.Size(312, 32);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
132 this.lblNewUnitWarning.TabIndex = 9;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
133 this.lblNewUnitWarning.Text = "label1";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
134 this.lblNewUnitWarning.TextAlign = System.Drawing.ContentAlignment.TopRight;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
135 this.lblNewUnitWarning.Visible = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
136 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
137 // imageList
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
138 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
139 this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
140 this.imageList.ImageSize = new System.Drawing.Size(32, 32);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
141 this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
142 this.imageList.TransparentColor = System.Drawing.Color.Transparent;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
143 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
144 // lblWarningIcon
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
145 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
146 this.lblWarningIcon.ImageIndex = 0;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
147 this.lblWarningIcon.ImageList = this.imageList;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
148 this.lblWarningIcon.Location = new System.Drawing.Point(8, 136);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
149 this.lblWarningIcon.Name = "lblWarningIcon";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
150 this.lblWarningIcon.Size = new System.Drawing.Size(40, 32);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
151 this.lblWarningIcon.TabIndex = 10;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
152 this.lblWarningIcon.Visible = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
153 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
154 // FrmNewUnit
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
155 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
156 this.AcceptButton = this.bttnSelectUnit;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
157 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
158 this.CancelButton = this.bttnCancel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
159 this.ClientSize = new System.Drawing.Size(370, 196);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
160 this.Controls.Add(this.lblWarningIcon);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
161 this.Controls.Add(this.lblNewUnitWarning);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
162 this.Controls.Add(this.bttnCancel);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
163 this.Controls.Add(this.lblUnitList);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
164 this.Controls.Add(this.bttnSelectUnit);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
165 this.Controls.Add(this.lstUnits);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
166 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
167 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
168 this.MaximizeBox = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
169 this.MinimizeBox = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
170 this.Name = "FrmNewUnit";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
171 this.ShowInTaskbar = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
172 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
173 this.Text = "FrmNewUni";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
174 this.ResumeLayout(false);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
175
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
176 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
177 #endregion
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
178
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
179 public UnitType SelectedUnit
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
180 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
181 get { return units[lstUnits.SelectedIndex]; }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
182 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
183
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
184 private void bttnCancel_Click(object sender, System.EventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
185 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
186 DialogResult = DialogResult.Cancel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
187 this.Close();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
188 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
189
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
190 private void bttnSelectUnit_Click(object sender, System.EventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
191 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
192 selectUnit();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
193 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
194
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
195 private void selectUnit()
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
196 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
197 DialogResult = DialogResult.OK;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
198 this.Close();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
199 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
200
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
201 private void setSelectUnitEnabledVal()
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
202 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
203 if (lstUnits.SelectedIndex>-1)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
204 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
205 bttnSelectUnit.Enabled = true;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
206 lblNewUnitWarning.Visible = !allowed[lstUnits.SelectedIndex];
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
207 lblWarningIcon.Visible = lblNewUnitWarning.Visible;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
208
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
209 if (lblNewUnitWarning.Visible)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
210 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
211 //lblNewUnitWarning.Text = army.GetFailedAddRequirement(units[lstUnits.SelectedIndex]).Description;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
212 //FIXME: Add failed requirement text
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
213 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
214 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
215 else
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
216 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
217 bttnSelectUnit.Enabled = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
218 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
219 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
220
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
221 private void lstUnits_SelectedIndexChanged(object sender, System.EventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
222 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
223 setSelectUnitEnabledVal();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
224 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
225
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
226 private void lstUnits_DoubleClick(object sender, EventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
227 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
228 if (lstUnits.SelectedIndex>-1)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
229 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
230 selectUnit();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
231 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
232 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
233
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
234 private void lstUnits_MouseDown(object sender, MouseEventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
235 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
236 //make sure no item is selected when a click is made outside a unit
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
237 int index = lstUnits.IndexFromPoint(e.X, e.Y);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
238 lstUnits.SelectedIndex = index;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
239 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
240 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
241 }