/// <ToBeCompleted></ToBeCompleted> public void DeleteShapes(Diagram diagram, IEnumerable<Shape> shapes, bool withModelObjects) { if (diagram == null) throw new ArgumentNullException("diagram"); if (shapes == null) throw new ArgumentNullException("shapes"); if (withModelObjects) { foreach (Shape s in shapes) { if (!diagram.Shapes.Contains(s)) throw new NShapeException("One of the given shapes is not part of the given diagram."); if (s.ModelObject != null && s.ModelObject.ShapeCount > 1) { string messageText = string.Format("{0} '{1}' can not be deleted while more than one shapes refer to it.", s.ModelObject.Type.Name, s.ModelObject.Name); throw new NShapeException(messageText); } } } ICommand cmd = new DeleteShapesCommand(diagram, shapes, withModelObjects); Project.ExecuteCommand(cmd); }
/// <ToBeCompleted></ToBeCompleted> public void Cut(Diagram source, IEnumerable<Shape> shapes, bool withModelObjects, Point startPos) { if (source == null) throw new ArgumentNullException("source"); if (shapes == null) throw new ArgumentNullException("shapes"); editBuffer.Clear(); editBuffer.action = EditAction.Cut; editBuffer.withModelObjects = withModelObjects; editBuffer.initialMousePos = startPos; editBuffer.shapes.AddRange(shapes); // Store all connections of *active* shapes to other shapes that were also cut foreach (Shape s in editBuffer.shapes) { foreach (ShapeConnectionInfo ci in s.GetConnectionInfos(ControlPointId.Any, null)) { // Skip shapes that are not the active shapes if (s.HasControlPointCapability(ci.OwnPointId, ControlPointCapabilities.Glue)) continue; // Skip connections to shapes that were not cut if (!editBuffer.shapes.Contains(ci.OtherShape)) continue; ShapeConnection conn = ShapeConnection.Empty; conn.ConnectorShape = s; conn.GluePointId = ci.OwnPointId; conn.TargetShape = ci.OtherShape; conn.TargetPointId = ci.OtherPointId; editBuffer.connections.Add(conn); } } ICommand cmd = new DeleteShapesCommand(source, editBuffer.shapes, withModelObjects); project.ExecuteCommand(cmd); }
private void DeleteShapes(IEnumerable<Shape> labels) { DeleteShapesCommand cmdLbl = new DeleteShapesCommand(Repository, TableDiagram, labels, false); cmdLbl.Execute(); }