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