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 StrokeOnly_HitTest(double x, double y, bool inside) { var ellipseNode = new EllipseNode(Matrix.Identity, null, new ImmutablePen(Brushes.Black, 2), new Rect(0, 0, 100, 100), null); var point = new Point(x, y); Assert.Equal(inside, ellipseNode.HitTest(point)); }
public void FillOnly_HitTest(double x, double y, bool inside) { var ellipseNode = new EllipseNode(Matrix.Identity, Brushes.Black, null, new Rect(0, 0, 100, 100), null); var point = new Point(x, y); Assert.True(ellipseNode.HitTest(point) == inside); }
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(); }