public void CanProperlyUndoRedoDeletionOfNewConnections() { classDiagram.CreateShapeAt(EntityType.Interface, new Point(0, 0)); classDiagram.CreateShapeAt(EntityType.Class, new Point(0, 0)); classDiagram.CreateShapeAt(EntityType.Interface, new Point(0, 0)); classDiagram.CreateShapeAt(EntityType.Class, new Point(0, 0)); var shapes = classDiagram.Shapes.ToArray(); // shapes is an elementlist, also everything is backwards var firstInterFace = (InterfaceShape)shapes[3]; var firstClass = (ClassShape)shapes[2]; Func <Relationship> _connectionFactory = () => classDiagram.AddAssociation(firstInterFace.TypeBase, firstClass.TypeBase); var command = new AddConnectionCommand(classDiagram, _connectionFactory); command.Execute(); classDiagram.TrackCommand(command); var secondInterFace = (InterfaceShape)shapes[1]; var secondClass = (ClassShape)shapes[0]; _connectionFactory = () => classDiagram.AddAssociation(secondInterFace.TypeBase, secondClass.TypeBase); command = new AddConnectionCommand(classDiagram, _connectionFactory); command.Execute(); classDiagram.TrackCommand(command); classDiagram.Undo(); classDiagram.Undo(); var oldCount = classDiagram.ConnectionCount; classDiagram.Redo(); classDiagram.Redo(); var newCount = classDiagram.ConnectionCount; oldCount.ShouldBe(0); newCount.ShouldBe(2); }
private void CreateCommentRelationship() { CommentShape shape1 = first as CommentShape; CommentShape shape2 = second as CommentShape; Func <Relationship> _connectionFactory; if (shape1 != null) { _connectionFactory = () => diagram.AddCommentRelationship(shape1.Comment, second.Entity); } else if (shape2 != null) { _connectionFactory = () => diagram.AddCommentRelationship(shape2.Comment, first.Entity); } else { MessageBox.Show(Strings.ErrorCannotCreateRelationship); return; } var command = new AddConnectionCommand(diagram, _connectionFactory); command.Execute(); diagram.TrackCommand(command); }
private void CreateExtends() { if (first is UseCaseShape shape1 && second is UseCaseShape shape2) { Func <Relationship> _connectionFactory = () => diagram.AddExtends(shape1.UseCase, shape2.UseCase); var command = new AddConnectionCommand(diagram, _connectionFactory); command.Execute(); diagram.TrackCommand(command); }
private void CreateAssociation() { if (first is TypeShape shape1 && second is TypeShape shape2) { Func <Relationship> _connectionFactory = () => diagram.AddAssociation(shape1.TypeBase, shape2.TypeBase); var command = new AddConnectionCommand(diagram, _connectionFactory); command.Execute(); diagram.TrackCommand(command); }
private void AddConnectionExecute([NotNull] object newObject) { if (newObject == null) { throw new Exception("Connection to add can't be null"); } if (newObject is ConnectionModel connectionModel) { AddConnectionCommand addConnectionCommand = new AddConnectionCommand(connectionModel, this); addConnectionCommand.Execute(); MyCommandManager.AddToList(addConnectionCommand); } }
public AddConnectionMiddleware(RequestDelegate next, ILogger <AddConnectionMiddleware> logger, AddConnectionCommand addConnectionCommand) : base(next, logger) { _addConnectionCommand = addConnectionCommand; }