private void EndAddElement(Rectangle selectionRectangle) { BaseElement el; switch (Document.ElementType) { case ElementType.Rectangle: el = new RectangleElement(selectionRectangle); break; case ElementType.RectangleNode: el = new RectangleNode(selectionRectangle); break; case ElementType.Ellipse: el = new EllipseElement(selectionRectangle); break; case ElementType.EllipseNode: el = new EllipseNode(selectionRectangle); break; case ElementType.CommentBox: el = new CommentBoxElement(selectionRectangle); break; default: el = new RectangleNode(selectionRectangle); break; } Document.AddElement(el); Document.Action = DesignerAction.Select; }
public void CreateDocument(DomainDocument domainDocument) { Document = new Document { Id = domainDocument.Id, Name = domainDocument.Name, WindowSize = Size }; foreach (var node in domainDocument.Nodes) { var rectangle = new Rectangle(node.X, node.Y, node.Width, node.Height); switch (node.Type) { case NodeType.Concept: var rectangleNode = new RectangleNode(rectangle) { Id = node.Id, Label = new LabelElement { Text = node.Label } }; rectangleNode.Label.PositionBySite(rectangleNode); Document.AddElement(rectangleNode); break; case NodeType.Relation: var ellipseNode = new EllipseNode(rectangle) { Id = node.Id, Label = new LabelElement { Text = node.Label } }; ellipseNode.Label.PositionBySite(ellipseNode); Document.AddElement(ellipseNode); break; case NodeType.Comment: var commentBoxElement = new CommentBoxElement(rectangle) { Id = node.Id, Label = new LabelElement { Text = node.Label } }; commentBoxElement.Label.PositionBySite(commentBoxElement); Document.AddElement(commentBoxElement); break; } } foreach (var link in domainDocument.Links) { ConnectorElement startConnectorElement, endConnectorElement; GetConnectors(link, out startConnectorElement, out endConnectorElement); if (startConnectorElement != null && endConnectorElement != null) { var linkElement = new StraightLinkElement(startConnectorElement, endConnectorElement) { Id = link.Id, Label = new LabelElement { Text = link.Label } }; linkElement.Label.Size = EditLabelAction.GetTextSize(linkElement); linkElement.Label.PositionBySite(linkElement); Document.Elements.Add(linkElement); } } Document.SetCurrentId(); RecreateEventsHandlers(); }