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