0
|
1 using System;
|
|
2 using IBBoard.Commands;
|
|
3 using IBBoard.WarFoundry.API.Objects;
|
|
4
|
|
5 namespace IBBoard.WarFoundry.API.Commands
|
|
6 {
|
|
7 /// <summary>
|
|
8 /// Summary description for SetNameCommand.
|
|
9 /// </summary>
|
|
10 public class SetUnitSizeCommand : Command
|
|
11 {
|
|
12 private Unit unit;
|
|
13 private int newSize, oldSize;
|
|
14
|
|
15 public SetUnitSizeCommand(Unit toResize, int size)
|
|
16 {
|
|
17 unit = toResize;
|
|
18 newSize = size;
|
|
19 oldSize = unit.Size;
|
|
20 }
|
|
21
|
|
22 public override bool CanExecute()
|
|
23 {
|
|
24 return (unit!=null && newSize >0 && oldSize > 0);
|
|
25 }
|
|
26
|
|
27 public override string Description
|
|
28 {
|
|
29 get { return "Change size of "+unit.Name; }
|
|
30 }
|
|
31
|
|
32 public override string UndoDescription
|
|
33 {
|
|
34 get { return "Revert size of "+unit.Name; }
|
|
35 }
|
|
36
|
|
37 public override bool Execute()
|
|
38 {
|
|
39 this.Redo();
|
|
40 return true;
|
|
41 }
|
|
42
|
|
43 public override void Redo()
|
|
44 {
|
|
45 unit.Size = newSize;
|
|
46 }
|
|
47
|
|
48 public override void Undo()
|
|
49 {
|
|
50 unit.Size = oldSize;
|
|
51 }
|
|
52
|
|
53 public override string Name
|
|
54 {
|
|
55 get { return "Change unit size"; }
|
|
56 }
|
|
57 }
|
|
58 }
|