Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
comparison FrmEditArmy.cs @ 225:5233147ca7e4
Re #101: Make army names and sizes modifiable after creation
* Add form for editing name and size
* Add edit options from army tree
* Add edit options from Edit menu
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 29 Aug 2011 20:06:54 +0100 |
parents | |
children | 4ada3252d1ea |
comparison
equal
deleted
inserted
replaced
224:467decfdde8e | 225:5233147ca7e4 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.ComponentModel; | |
4 using System.Data; | |
5 using System.Drawing; | |
6 using System.Text; | |
7 using System.Windows.Forms; | |
8 using IBBoard.Commands; | |
9 using IBBoard.WarFoundry.API.Commands; | |
10 using IBBoard.WarFoundry.API.Objects; | |
11 | |
12 namespace IBBoard.WarFoundry.GUI.WinForms | |
13 { | |
14 public partial class FrmEditArmy : Form | |
15 { | |
16 private Army army; | |
17 private CommandStack stack; | |
18 | |
19 public FrmEditArmy(CommandStack cmdStack, Army toEdit) | |
20 { | |
21 army = toEdit; | |
22 stack = cmdStack; | |
23 InitializeComponent(); | |
24 txtArmyName.Text = army.Name; | |
25 armySize.Value = army.MaxPoints; | |
26 } | |
27 | |
28 private void bttnOkay_Click(object sender, EventArgs e) | |
29 { | |
30 EditArmyCommand command = new EditArmyCommand(army); | |
31 command.NewName = txtArmyName.Text; | |
32 command.NewSize = (int)armySize.Value; | |
33 stack.Execute(command); | |
34 DialogResult = DialogResult.OK; | |
35 Close(); | |
36 } | |
37 | |
38 private void bttnCancel_Click(object sender, EventArgs e) | |
39 { | |
40 Close(); | |
41 } | |
42 | |
43 private void armySize_ValueChanged(object sender, EventArgs e) | |
44 { | |
45 SetOkayEnabled(); | |
46 } | |
47 | |
48 private void SetOkayEnabled() | |
49 { | |
50 string trimmedName = txtArmyName.Text.Trim(); | |
51 bttnOkay.Enabled = ((army.MaxPoints != armySize.Value || army.Name != trimmedName) && trimmedName != ""); | |
52 } | |
53 | |
54 private void txtArmyName_TextChanged(object sender, EventArgs e) | |
55 { | |
56 SetOkayEnabled(); | |
57 } | |
58 | |
59 private void armySize_KeyUp(object sender, KeyEventArgs e) | |
60 { | |
61 SetOkayEnabled(); | |
62 } | |
63 } | |
64 } |