Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
comparison FrmEditArmy.cs @ 139:d4b726cec12c
Fixes #326: Make army names and sizes modifiable after creation
* Only invoke command on change
* Make use of new "generate default name" function for consistency
* Commit missed auto-generated code file
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 12 Oct 2011 20:36:02 +0100 |
parents | 33962c2ef550 |
children |
comparison
equal
deleted
inserted
replaced
138:33962c2ef550 | 139:d4b726cec12c |
---|---|
21 txtArmyName.Text = army.Name; | 21 txtArmyName.Text = army.Name; |
22 sbPointsValue.Value = army.MaxPoints; | 22 sbPointsValue.Value = army.MaxPoints; |
23 Translate(); | 23 Translate(); |
24 } | 24 } |
25 | 25 |
26 protected void OnButtonOkClicked (object sender, System.EventArgs e) | |
27 { | |
28 if (IsChanged()) | |
29 { | |
30 DoUpdate(); | |
31 } | |
32 Respond(Gtk.ResponseType.Ok); | |
33 } | |
34 | |
35 private bool IsChanged() | |
36 { | |
37 string trimmedName = txtArmyName.Text.Trim(); | |
38 return army.MaxPoints != sbPointsValue.Value || army.Name != trimmedName; | |
39 } | |
40 | |
26 private void DoUpdate() | 41 private void DoUpdate() |
27 { | 42 { |
28 EditArmyCommand command = new EditArmyCommand(army); | 43 EditArmyCommand command = new EditArmyCommand(army); |
29 command.NewName = txtArmyName.Text; | 44 command.NewName = txtArmyName.Text; |
30 command.NewSize = (int)sbPointsValue.Value; | 45 command.NewSize = (int)sbPointsValue.Value; |
31 stack.Execute(command); | 46 stack.Execute(command); |
32 } | |
33 | |
34 protected void OnButtonOkClicked (object sender, System.EventArgs e) | |
35 { | |
36 DoUpdate(); | |
37 Respond(Gtk.ResponseType.Ok); | |
38 } | 47 } |
39 | 48 |
40 protected void OnButtonCancelClicked (object sender, System.EventArgs e) | 49 protected void OnButtonCancelClicked (object sender, System.EventArgs e) |
41 { | 50 { |
42 Respond(Gtk.ResponseType.Cancel); | 51 Respond(Gtk.ResponseType.Cancel); |