comparison FrmNewArmy.cs @ 188:bbf391b31b3e

Re #98: Default army size papercut Updated Winforms to use the default army size.
author snowblizz
date Sun, 12 Dec 2010 15:37:07 +0000
parents 3a561c3751f5
children 1ca23c47345a
comparison
equal deleted inserted replaced
187:3a561c3751f5 188:bbf391b31b3e
18 /// <summary> 18 /// <summary>
19 /// Summary description for FrmNewArmy. 19 /// Summary description for FrmNewArmy.
20 /// </summary> 20 /// </summary>
21 public class FrmNewArmy : IBBForm 21 public class FrmNewArmy : IBBForm
22 { 22 {
23
23 private IContainer components; 24 private IContainer components;
24 private IBBoard.Windows.Forms.IBBButton bttnCancel; 25 private IBBoard.Windows.Forms.IBBButton bttnCancel;
25 private IBBoard.Windows.Forms.IBBLabel lblRaceList; 26 private IBBoard.Windows.Forms.IBBLabel lblRaceList;
26 private IBBoard.Windows.Forms.IBBButton bttnSelectRace; 27 private IBBoard.Windows.Forms.IBBButton bttnSelectRace;
27 private System.Windows.Forms.ListBox lstRaces; 28 private System.Windows.Forms.ListBox lstRaces;
33 private System.Windows.Forms.TextBox txtArmyName; 34 private System.Windows.Forms.TextBox txtArmyName;
34 35
35 private GameSystem system; 36 private GameSystem system;
36 private Race race; 37 private Race race;
37 private string armyName; 38 private string armyName;
39 public bool isDefaultArmyName;
38 private ToolTip gameSystemToolTip; 40 private ToolTip gameSystemToolTip;
39 private int maxPoints; 41 private int maxPoints;
40 42
41 public FrmNewArmy(GameSystem system) 43 public FrmNewArmy(GameSystem system)
42 { 44 {
211 this.armySize.Value = new decimal(new int[] { 213 this.armySize.Value = new decimal(new int[] {
212 2000, 214 2000,
213 0, 215 0,
214 0, 216 0,
215 0}); 217 0});
216 // 218 this.armySize.ValueChanged += new System.EventHandler(this.armySize_ValueChanged);
219 //
217 // gameSystems 220 // gameSystems
218 // 221 //
219 this.gameSystems.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 222 this.gameSystems.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
220 | System.Windows.Forms.AnchorStyles.Right))); 223 | System.Windows.Forms.AnchorStyles.Right)));
221 this.gameSystems.DisplayMember = "Name"; 224 this.gameSystems.DisplayMember = "Name";
305 race = (Race) lstRaces.SelectedItem; 308 race = (Race) lstRaces.SelectedItem;
306 armyName = txtArmyName.Text; 309 armyName = txtArmyName.Text;
307 maxPoints = (int) armySize.Value; 310 maxPoints = (int) armySize.Value;
308 } 311 }
309 312
310 private GameSystem GetSelectedGameSystem() 313 private void armySize_ValueChanged(object sender, System.EventArgs e)
314 {
315 if (txtArmyName.Enabled && isDefaultArmyName)
316 {
317 setTxtArmyNameVal();
318 }
319 }
320
321 private GameSystem GetSelectedGameSystem()
311 { 322 {
312 return (GameSystem) gameSystems.SelectedItem; 323 return (GameSystem) gameSystems.SelectedItem;
313 } 324 }
314 325
315 private void txtArmyName_TextChanged(object sender, System.EventArgs e) 326 private void txtArmyName_TextChanged(object sender, System.EventArgs e)
316 { 327 {
317 setSelectRaceEnabledVal(); 328 isDefaultArmyName = false ;
329 setSelectRaceEnabledVal();
318 } 330 }
319 331
320 private void setSelectRaceEnabledVal() 332 private void setSelectRaceEnabledVal()
321 { 333 {
322 bttnSelectRace.Enabled = (lstRaces.SelectedIndex>-1 && txtArmyName.Text.Trim()!="" && armySize.Value > 0); 334 bttnSelectRace.Enabled = (lstRaces.SelectedIndex>-1 && txtArmyName.Text.Trim()!="" && armySize.Value > 0);
323 } 335 }
324 336
325 private void lstRaces_SelectedIndexChanged(object sender, System.EventArgs e) 337 private void setTxtArmyNameVal()
338 {
339 txtArmyName.Text = String.Format(race.ArmyDefaultName, Translation.GetTranslation("armySizePts", "{0}pt", armySize.Value));
340 isDefaultArmyName = true;
341 }
342
343 private void lstRaces_SelectedIndexChanged(object sender, System.EventArgs e)
326 { 344 {
327 setSelectRaceEnabledVal(); 345 setSelectRaceEnabledVal();
328 bool raceSelected = lstRaces.SelectedItem != null; 346 bool raceSelected = lstRaces.SelectedItem != null;
329 txtArmyName.Enabled = raceSelected; 347 txtArmyName.Enabled = raceSelected;
330 armySize.Enabled = raceSelected; 348 armySize.Enabled = raceSelected;
331 race = (Race)lstRaces.SelectedItem; 349 race = (Race)lstRaces.SelectedItem;
332 txtArmyName.Text = race.Name + " " + String.Format(race.ArmyDefaultName, Translation.GetTranslation("armySizePts", "{0}pt", armySize.Value)); 350 setTxtArmyNameVal();
333 } 351 }
334 352
335 private void gameSystems_SelectedValueChanged(object sender, EventArgs e) 353 private void gameSystems_SelectedValueChanged(object sender, EventArgs e)
336 { 354 {
337 GameSystem selected = GetSelectedGameSystem(); 355
338 lstRaces.Items.Clear(); 356 GameSystem selected = GetSelectedGameSystem();
339 357 txtArmyName.Text = "";
358 txtArmyName.Enabled = false;
359 lstRaces.Items.Clear();
360 armySize.Value = (decimal)selected.SystemArmyDefaultSize;
361
340 if (selected != null) 362 if (selected != null)
341 { 363 {
342 SetRaces(selected); 364 SetRaces(selected);
343 365
344 if (lstRaces.Items.Count == 1) 366 if (lstRaces.Items.Count == 1)