Mercurial > repos > snowblizz-super-API-ideas
annotate api/Commands/SetNameCommand.cs @ 213:c6713a1b4c0d
* Line ending changes
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 21 Nov 2009 20:06:36 +0000 |
parents | 2f3cafb69799 |
children | 391446c9b250 |
rev | line source |
---|---|
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
diff
changeset
|
1 // This file (SetNameCommand.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard. |
15 | 2 // |
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
82
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. |
15 | 4 |
82 | 5 using System; |
0 | 6 using IBBoard.Commands; |
82 | 7 using IBBoard.WarFoundry.API.Objects; |
8 | |
9 namespace IBBoard.WarFoundry.API.Commands | |
10 { | |
11 /// <summary> | |
12 /// Summary description for SetNameCommand. | |
13 /// </summary> | |
14 public class SetNameCommand : Command | |
15 { | |
16 private WarFoundryObject obj; | |
17 private string newName, oldName; | |
18 | |
19 public SetNameCommand(WarFoundryObject toRename, string name) | |
20 { | |
21 obj = toRename; | |
22 newName = name; | |
23 oldName = obj.Name; | |
24 } | |
25 | |
26 public override bool CanExecute() | |
27 { | |
28 return (obj!=null && newName!=null && newName!=""); | |
29 } | |
30 | |
31 public override string Description | |
32 { | |
33 get { return "Rename "+oldName; } | |
34 } | |
35 | |
36 public override string UndoDescription | |
37 { | |
38 get { return "Revert name of "+newName; } | |
39 } | |
40 | |
41 public override bool Execute() | |
42 { | |
43 this.Redo(); | |
44 return true; | |
45 } | |
46 | |
47 public override void Redo() | |
48 { | |
49 obj.Name = newName; | |
50 } | |
51 | |
52 public override void Undo() | |
53 { | |
54 obj.Name = oldName; | |
55 } | |
56 | |
57 public override string Name | |
58 { | |
59 get { return "Rename item"; } | |
60 } | |
61 } | |
62 } |