comparison api/Commands/SetNameCommand.cs @ 0:520818033bb6

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 306558904c2a
comparison
equal deleted inserted replaced
-1:000000000000 0:520818033bb6
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 SetNameCommand : Command
11 {
12 private WarFoundryObject obj;
13 private string newName, oldName;
14
15 public SetNameCommand(WarFoundryObject toRename, string name)
16 {
17 obj = toRename;
18 newName = name;
19 oldName = obj.Name;
20 }
21
22 public override bool CanExecute()
23 {
24 return (obj!=null && newName!=null && newName!="");
25 }
26
27 public override string Description
28 {
29 get { return "Rename "+oldName; }
30 }
31
32 public override string UndoDescription
33 {
34 get { return "Revert name of "+newName; }
35 }
36
37 public override bool Execute()
38 {
39 this.Redo();
40 return true;
41 }
42
43 public override void Redo()
44 {
45 obj.Name = newName;
46 }
47
48 public override void Undo()
49 {
50 obj.Name = oldName;
51 }
52
53 public override string Name
54 {
55 get { return "Rename item"; }
56 }
57 }
58 }