comparison FrmNewArmy.cs @ 0:7dd160dacb60

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 42cf06b8f897
comparison
equal deleted inserted replaced
-1:000000000000 0:7dd160dacb60
1 using System;
2 using System.Drawing;
3 using System.Collections;
4 using System.ComponentModel;
5 using System.Windows.Forms;
6 using IBBoard;
7 using IBBoard.Lang;
8 using IBBoard.Windows.Forms;
9 using IBBoard.WarFoundry.API;
10
11 namespace IBBoard.WarFoundry
12 {
13 /// <summary>
14 /// Summary description for FrmNewArmy.
15 /// </summary>
16 public class FrmNewArmy : IBBForm
17 {
18 /// <summary>
19 /// Required designer variable.
20 /// </summary>
21 private System.ComponentModel.Container components = null;
22 private IBBoard.Windows.Forms.IBBButton bttnCancel;
23 private IBBoard.Windows.Forms.IBBLabel lblRaceList;
24 private IBBoard.Windows.Forms.IBBButton bttnSelectRace;
25 private System.Windows.Forms.ListBox lstRaces;
26 private Race[] races;
27 private IBBoard.Windows.Forms.IBBLabel lblArmyName;
28 private IBBoard.Windows.Forms.IBBLabel lblArmySize;
29 private System.Windows.Forms.NumericUpDown armySize;
30 private System.Windows.Forms.TextBox txtArmyName;
31
32 public FrmNewArmy(GameSystem system, WarFoundryFactory factory)
33 {
34 InitializeComponent();
35
36 Translation.TranslateControl(this);
37
38 races = factory.GetRaces(system);
39
40 for (int i = 0; i<races.Length; i++)
41 {
42 lstRaces.Items.Add(races[i].Name);
43 }
44 }
45
46 /// <summary>
47 /// Clean up any resources being used.
48 /// </summary>
49 protected override void Dispose( bool disposing )
50 {
51 if( disposing )
52 {
53 if(components != null)
54 {
55 components.Dispose();
56 }
57 }
58 base.Dispose( disposing );
59 }
60
61 #region Windows Form Designer generated code
62 /// <summary>
63 /// Required method for Designer support - do not modify
64 /// the contents of this method with the code editor.
65 /// </summary>
66 private void InitializeComponent()
67 {
68 System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmNewArmy));
69 this.lstRaces = new System.Windows.Forms.ListBox();
70 this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
71 this.lblRaceList = new IBBoard.Windows.Forms.IBBLabel();
72 this.bttnSelectRace = new IBBoard.Windows.Forms.IBBButton();
73 this.lblArmyName = new IBBoard.Windows.Forms.IBBLabel();
74 this.txtArmyName = new System.Windows.Forms.TextBox();
75 this.lblArmySize = new IBBoard.Windows.Forms.IBBLabel();
76 this.armySize = new System.Windows.Forms.NumericUpDown();
77 ((System.ComponentModel.ISupportInitialize)(this.armySize)).BeginInit();
78 this.SuspendLayout();
79 //
80 // lstRaces
81 //
82 this.lstRaces.Location = new System.Drawing.Point(88, 8);
83 this.lstRaces.Name = "lstRaces";
84 this.lstRaces.Size = new System.Drawing.Size(272, 121);
85 this.lstRaces.TabIndex = 7;
86 this.lstRaces.SelectedIndexChanged += new System.EventHandler(this.lstRaces_SelectedIndexChanged);
87 //
88 // bttnCancel
89 //
90 this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
91 this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
92 this.bttnCancel.Location = new System.Drawing.Point(8, 200);
93 this.bttnCancel.Name = "bttnCancel";
94 this.bttnCancel.Size = new System.Drawing.Size(80, 24);
95 this.bttnCancel.TabIndex = 6;
96 this.bttnCancel.Text = "Cancel";
97 this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
98 //
99 // lblRaceList
100 //
101 this.lblRaceList.Location = new System.Drawing.Point(0, 8);
102 this.lblRaceList.Name = "lblRaceList";
103 this.lblRaceList.Size = new System.Drawing.Size(88, 80);
104 this.lblRaceList.TabIndex = 5;
105 this.lblRaceList.Text = "race list";
106 this.lblRaceList.TextAlign = System.Drawing.ContentAlignment.TopRight;
107 //
108 // bttnSelectRace
109 //
110 this.bttnSelectRace.Enabled = false;
111 this.bttnSelectRace.FlatStyle = System.Windows.Forms.FlatStyle.System;
112 this.bttnSelectRace.Location = new System.Drawing.Point(256, 200);
113 this.bttnSelectRace.Name = "bttnSelectRace";
114 this.bttnSelectRace.Size = new System.Drawing.Size(104, 24);
115 this.bttnSelectRace.TabIndex = 4;
116 this.bttnSelectRace.Text = "create race";
117 this.bttnSelectRace.Click += new System.EventHandler(this.bttnSelectRace_Click);
118 //
119 // lblArmyName
120 //
121 this.lblArmyName.Location = new System.Drawing.Point(0, 136);
122 this.lblArmyName.Name = "lblArmyName";
123 this.lblArmyName.Size = new System.Drawing.Size(88, 32);
124 this.lblArmyName.TabIndex = 8;
125 this.lblArmyName.Text = "army name";
126 this.lblArmyName.TextAlign = System.Drawing.ContentAlignment.TopRight;
127 //
128 // txtArmyName
129 //
130 this.txtArmyName.Location = new System.Drawing.Point(88, 136);
131 this.txtArmyName.Name = "txtArmyName";
132 this.txtArmyName.Size = new System.Drawing.Size(272, 20);
133 this.txtArmyName.TabIndex = 9;
134 this.txtArmyName.Text = "";
135 this.txtArmyName.TextChanged += new System.EventHandler(this.txtArmyName_TextChanged);
136 //
137 // lblArmySize
138 //
139 this.lblArmySize.Location = new System.Drawing.Point(0, 168);
140 this.lblArmySize.Name = "lblArmySize";
141 this.lblArmySize.Size = new System.Drawing.Size(88, 32);
142 this.lblArmySize.TabIndex = 10;
143 this.lblArmySize.Text = "army size";
144 this.lblArmySize.TextAlign = System.Drawing.ContentAlignment.TopRight;
145 //
146 // armySize
147 //
148 this.armySize.Increment = new System.Decimal(new int[] {
149 50,
150 0,
151 0,
152 0});
153 this.armySize.Location = new System.Drawing.Point(88, 168);
154 this.armySize.Maximum = new System.Decimal(new int[] {
155 1000000,
156 0,
157 0,
158 0});
159 this.armySize.Name = "armySize";
160 this.armySize.TabIndex = 11;
161 this.armySize.ThousandsSeparator = true;
162 this.armySize.Value = new System.Decimal(new int[] {
163 2000,
164 0,
165 0,
166 0});
167 //
168 // FrmNewArmy
169 //
170 this.AcceptButton = this.bttnSelectRace;
171 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
172 this.CancelButton = this.bttnCancel;
173 this.ClientSize = new System.Drawing.Size(370, 228);
174 this.Controls.Add(this.armySize);
175 this.Controls.Add(this.lblArmySize);
176 this.Controls.Add(this.txtArmyName);
177 this.Controls.Add(this.lblArmyName);
178 this.Controls.Add(this.bttnCancel);
179 this.Controls.Add(this.lblRaceList);
180 this.Controls.Add(this.bttnSelectRace);
181 this.Controls.Add(this.lstRaces);
182 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
183 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
184 this.MaximizeBox = false;
185 this.MinimizeBox = false;
186 this.Name = "FrmNewArmy";
187 this.ShowInTaskbar = false;
188 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
189 this.Text = "FrmNewArmy";
190 ((System.ComponentModel.ISupportInitialize)(this.armySize)).EndInit();
191 this.ResumeLayout(false);
192
193 }
194 #endregion
195
196 public Race SelectedRace
197 {
198 get { return races[lstRaces.SelectedIndex]; }
199 }
200
201 public string ArmyName
202 {
203 get { return txtArmyName.Text; }
204 }
205
206 public int ArmySize
207 {
208 get { return (int)armySize.Value; }
209 }
210
211 private void bttnCancel_Click(object sender, System.EventArgs e)
212 {
213 DialogResult = DialogResult.Cancel;
214 this.Close();
215 }
216
217 private void bttnSelectRace_Click(object sender, System.EventArgs e)
218 {
219 DialogResult = DialogResult.OK;
220 this.Close();
221 }
222
223 private void txtArmyName_TextChanged(object sender, System.EventArgs e)
224 {
225 setSelectRaceEnabledVal();
226 }
227
228 private void setSelectRaceEnabledVal()
229 {
230 bttnSelectRace.Enabled = (lstRaces.SelectedIndex>-1 && txtArmyName.Text.Trim()!="" && armySize.Value > 0);
231 }
232
233 private void lstRaces_SelectedIndexChanged(object sender, System.EventArgs e)
234 {
235 setSelectRaceEnabledVal();
236 }
237 }
238 }