NShape Concepts

<< Click to Display Table of Contents >>

Navigation:  Concepts >

NShape Concepts

Previous pageReturn to chapter overviewNext page

When manipulating shapes and diagrams, a program will usually use their methods and properties like in the following example.

shape.X = 50;
shape.Y = 30;
shape.Angle = 1800;

However, when the user edits a diagram, his actions must be checked against his permissions, all modifications must be notified to the repository and we want those operations to be undoable. These features are implemented in the command classes, which are used for implementing user actions. Using command objects, the above sequence looks like this:

project.Execute(new ShapeMoveToCommand(shape, 50, 50));
project.Execute(new ShapeRotateTo(Command(shape, 1800));

Every command object encapsulates all information necessary to execute the command. The Project.Execute method checks whether the current user has the required permissions, executes the command and adds it to the history for later redo.