comparison api/Commands/SetNameCommand.cs @ 298:483b491d18f4

Fixes #337: Merge API v0.1.1 changes into v0.2 * Merge translation-related changes from v0.1.1 branch
author IBBoard <dev@ibboard.co.uk>
date Mon, 17 Jan 2011 20:02:41 +0000
parents 391446c9b250
children
comparison
equal deleted inserted replaced
297:349e521785c1 298:483b491d18f4
14 /// </summary> 14 /// </summary>
15 public class SetNameCommand : Command 15 public class SetNameCommand : Command
16 { 16 {
17 private WarFoundryObject obj; 17 private WarFoundryObject obj;
18 private string newName, oldName; 18 private string newName, oldName;
19 private string description;
20 private string undoDescription;
21 19
22 public SetNameCommand(WarFoundryObject toRename, string name) 20 public SetNameCommand(WarFoundryObject toRename, string name)
23 { 21 {
24 obj = toRename; 22 obj = toRename;
25 newName = name; 23 newName = name;
26 oldName = obj.Name; 24 oldName = obj.Name;
27 } 25 }
28 26
29 public override bool CanExecute() 27 public override bool CanExecute()
30 { 28 {
31 return (obj!=null && newName!=null && newName!=""); 29 return (obj != null && newName != null && newName != "");
32 } 30 }
33 31
34 public override string Description 32 public override string Description
35 { 33 {
36 get 34 get
37 { 35 {
38 if (description == null) 36 return Translation.GetTranslation("setUnitNameCommandDescription", "rename \"{0}\" to \"{1}\"", oldName, newName);
39 {
40 description = Translation.GetTranslation("setUnitNameCommandDescription", "rename \"{0}\" to \"{1}\"", oldName, newName);
41 }
42
43 return description;
44 } 37 }
45 } 38 }
46 39
47 public override string UndoDescription 40 public override string UndoDescription
48 { 41 {
49 get 42 get
50 { 43 {
51 if (undoDescription == null) 44 return Translation.GetTranslation("setUnitNameCommandUndoDescription", "rename \"{0}\" to \"{1}\"", newName, oldName);
52 {
53 undoDescription = Translation.GetTranslation("setUnitNameCommandUndoDescription", "rename \"{0}\" to \"{1}\"", newName, oldName);
54 }
55
56 return undoDescription;
57 } 45 }
58 } 46 }
59 47
60 public override bool Execute() 48 public override bool Execute()
61 { 49 {