annotate FrmEditArmy.cs @ 150:7549ed1f4cb2

* Remove code that was made unnecessary by WarFoundryHacks class * Make shell script executable
author IBBoard <dev@ibboard.co.uk>
date Mon, 28 Nov 2011 20:05:22 +0000
parents d4b726cec12c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
138
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (FrmEditArmy.cs) is a part of the IBBoard.WarFoundry.GUI.GTK project and is copyright 2011 IBBoard
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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.
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using IBBoard.WarFoundry.API.Objects;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.Commands;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.WarFoundry.API.Commands;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 namespace IBBoard.WarFoundry.GUI.GTK
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 public partial class FrmEditArmy : IBBoard.GtkSharp.Translatable.TranslatableDialog
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 private Army army;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 private CommandStack stack;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public FrmEditArmy(CommandStack cmdStack, Army toEdit)
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 stack = cmdStack;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 army = toEdit;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 this.Build();
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 txtArmyName.Text = army.Name;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 sbPointsValue.Value = army.MaxPoints;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 Translate();
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 }
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25
139
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
26 protected void OnButtonOkClicked (object sender, System.EventArgs e)
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
27 {
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
28 if (IsChanged())
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
29 {
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
30 DoUpdate();
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
31 }
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
32 Respond(Gtk.ResponseType.Ok);
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
33 }
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
34
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
35 private bool IsChanged()
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
36 {
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
37 string trimmedName = txtArmyName.Text.Trim();
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
38 return army.MaxPoints != sbPointsValue.Value || army.Name != trimmedName;
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
39 }
d4b726cec12c Fixes #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents: 138
diff changeset
40
138
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 private void DoUpdate()
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 {
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 EditArmyCommand command = new EditArmyCommand(army);
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 command.NewName = txtArmyName.Text;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 command.NewSize = (int)sbPointsValue.Value;
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 stack.Execute(command);
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 }
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 protected void OnButtonCancelClicked (object sender, System.EventArgs e)
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 {
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 Respond(Gtk.ResponseType.Cancel);
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 }
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 }
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 }
33962c2ef550 Re #326: Make army names and sizes modifiable after creation
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55