Line | |
---|
1 | using System;
|
---|
2 | using System.Drawing;
|
---|
3 | namespace Netron.Diagramming.Core {
|
---|
4 | /// <summary>
|
---|
5 | /// ICommand implementation of the AddConnection action
|
---|
6 | /// </summary>
|
---|
7 | class AddConnectionCommand : Command {
|
---|
8 | IConnection connection;
|
---|
9 |
|
---|
10 | public IConnection Connection {
|
---|
11 | get { return connection; }
|
---|
12 | }
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 | public AddConnectionCommand(IController controller, IConnection connection)
|
---|
17 | : base(controller) {
|
---|
18 | if (connection == null)
|
---|
19 | throw new ArgumentNullException("The connection is 'null' and cannot be inserted.");
|
---|
20 | this.Text = "Add " + connection.EntityName;
|
---|
21 | this.connection = connection;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override void Redo() {
|
---|
25 | Controller.Model.AddConnection(connection);
|
---|
26 |
|
---|
27 | //connection.Location = location;
|
---|
28 | Rectangle rec = connection.Rectangle;
|
---|
29 | rec.Inflate(20, 20);
|
---|
30 | Controller.View.Invalidate(rec);
|
---|
31 | }
|
---|
32 |
|
---|
33 | public override void Undo() {
|
---|
34 | Rectangle rec = connection.Rectangle;
|
---|
35 | rec.Inflate(20, 20);
|
---|
36 | Controller.Model.Remove(connection);
|
---|
37 | Controller.View.Invalidate(rec);
|
---|
38 |
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 | }
|
---|
43 |
|
---|
44 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.