public Relation(Node parent, Anchor parentAnchor, Node child, Anchor childAnchor, bool update) { this.parent = parent; this.parentAnchor = parentAnchor; this.child = child; this.childAnchor = childAnchor; child.AddParent(parent, update); parent.AddChild(child); this.ArrowEnds = ArrowEnds.End; this.IsArrowClosed = true; this.Stroke = Brushes.Blue; this.StrokeThickness = 3; ContextMenu contextMenu = new ContextMenu(); tryTurn = new MenuItem(); tryTurn.Header = "Try Turning"; tryTurn.Click += TryTurning; tryTurn.IsEnabled = MDiagram.Evaluating; contextMenu.Items.Add(tryTurn); deleteItem = new MenuItem(); deleteItem.Header = "Remove"; deleteItem.Click += DeleteItem_Click; contextMenu.Items.Add(deleteItem); this.ContextMenu = contextMenu; this.SetBinding(ArrowLine.X1Property, new Binding() { Source = parentAnchor, Path = new PropertyPath(Anchor.AnchorX1Property) }); this.SetBinding(ArrowLine.Y1Property, new Binding() { Source = parentAnchor, Path = new PropertyPath(Anchor.AnchorY1Property) }); this.SetBinding(ArrowLine.X2Property, new Binding() { Source = childAnchor, Path = new PropertyPath(Anchor.AnchorX1Property) }); this.SetBinding(ArrowLine.Y2Property, new Binding() { Source = childAnchor, Path = new PropertyPath(Anchor.AnchorY1Property) }); MainWindow.GetCanvas.Children.Add(this); MDiagram.AddRelation(this); }
public Relation(SerialRelation serial) { foreach (Node node in MDiagram.Nodes) { if (node.ID == serial.Parent) { parent = node; } else if (node.ID == serial.Child) { child = node; } } foreach (Anchor anchor in parent.Anchors) { if (anchor.Name == serial.ParentAnchor) { parentAnchor = anchor; } } foreach (Anchor anchor in child.Anchors) { if (anchor.Name == serial.ChildAnchor) { childAnchor = anchor; } } child.AddParent(parent, false); parent.AddChild(child); this.ArrowEnds = ArrowEnds.End; this.IsArrowClosed = true; this.Stroke = Brushes.Blue; this.StrokeThickness = 3; ContextMenu contextMenu = new ContextMenu(); tryTurn = new MenuItem(); tryTurn.Header = "Try Turning"; tryTurn.Click += TryTurning; tryTurn.IsEnabled = MDiagram.Evaluating; contextMenu.Items.Add(tryTurn); deleteItem = new MenuItem(); deleteItem.Header = "Remove"; deleteItem.Click += DeleteItem_Click; contextMenu.Items.Add(deleteItem); this.ContextMenu = contextMenu; this.SetBinding(ArrowLine.X1Property, new Binding() { Source = parentAnchor, Path = new PropertyPath(Anchor.AnchorX1Property) }); this.SetBinding(ArrowLine.Y1Property, new Binding() { Source = parentAnchor, Path = new PropertyPath(Anchor.AnchorY1Property) }); this.SetBinding(ArrowLine.X2Property, new Binding() { Source = childAnchor, Path = new PropertyPath(Anchor.AnchorX1Property) }); this.SetBinding(ArrowLine.Y2Property, new Binding() { Source = childAnchor, Path = new PropertyPath(Anchor.AnchorY1Property) }); MainWindow.GetCanvas.Children.Add(this); MDiagram.AddRelation(this); }