comparison API/Commands/SetNameCommand.cs @ 337:3c4a6403a88c

* Fix capitalisation so that new files are in the namespace no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sun, 03 Apr 2011 18:50:32 +0000
parents
children
comparison
equal deleted inserted replaced
336:3631c1493c7f 337:3c4a6403a88c
1 // This file (SetNameCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
2 //
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.
4
5 using System;
6 using IBBoard.Commands;
7 using IBBoard.Lang;
8 using IBBoard.WarFoundry.API.Objects;
9
10 namespace IBBoard.WarFoundry.API.Commands
11 {
12 /// <summary>
13 /// Summary description for SetNameCommand.
14 /// </summary>
15 public class SetNameCommand : Command
16 {
17 private WarFoundryObject obj;
18 private string newName, oldName;
19
20 public SetNameCommand(WarFoundryObject toRename, string name)
21 {
22 obj = toRename;
23 newName = name;
24 oldName = obj.Name;
25 }
26
27 public override bool CanExecute()
28 {
29 return (obj != null && newName != null && newName != "");
30 }
31
32 public override string Description
33 {
34 get
35 {
36 return Translation.GetTranslation("setUnitNameCommandDescription", "rename \"{0}\" to \"{1}\"", oldName, newName);
37 }
38 }
39
40 public override string UndoDescription
41 {
42 get
43 {
44 return Translation.GetTranslation("setUnitNameCommandUndoDescription", "rename \"{0}\" to \"{1}\"", newName, oldName);
45 }
46 }
47
48 public override bool Execute()
49 {
50 this.Redo();
51 return true;
52 }
53
54 public override void Redo()
55 {
56 obj.Name = newName;
57 }
58
59 public override void Undo()
60 {
61 obj.Name = oldName;
62 }
63
64 public override string Name
65 {
66 get { return "Rename item"; }
67 }
68 }
69 }