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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
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
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
4
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
5 using System;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.Commands;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
7 using IBBoard.WarFoundry.API.Objects;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
8
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
9 namespace IBBoard.WarFoundry.API.Commands
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
10 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
11 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
12 /// Summary description for SetNameCommand.
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
13 /// </summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
14 public class SetNameCommand : Command
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
15 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
16 private WarFoundryObject obj;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
17 private string newName, oldName;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
18
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
19 public SetNameCommand(WarFoundryObject toRename, string name)
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
20 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
21 obj = toRename;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
22 newName = name;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
23 oldName = obj.Name;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
24 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
25
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
26 public override bool CanExecute()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
27 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
28 return (obj!=null && newName!=null && newName!="");
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
29 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
30
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
31 public override string Description
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
32 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
33 get { return "Rename "+oldName; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
34 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
35
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
36 public override string UndoDescription
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
37 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
38 get { return "Revert name of "+newName; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
39 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
40
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
41 public override bool Execute()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
42 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
43 this.Redo();
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
44 return true;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
45 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
46
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
47 public override void Redo()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
48 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
49 obj.Name = newName;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
50 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
51
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
52 public override void Undo()
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
53 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
54 obj.Name = oldName;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
55 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
56
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
57 public override string Name
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
58 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
59 get { return "Rename item"; }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
60 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
61 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
62 }