public void DeleteItem_Click(object sender, RoutedEventArgs e) { child.RemoveParent(parent); parent.RemoveChild(child); MDiagram.RemoveRelation(this); MainWindow.GetCanvas.Children.Remove(this); }
private void Anchor_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { MDiagram.ShowAllAnchors(); MainWindow.GetMCanvas.AddToAnchorLine(node, this); MainWindow.GetMCanvas.DragSelection = "Anchor"; DragDrop.DoDragDrop(this, new DataObject(this), DragDropEffects.Move); }
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 Node(SerialNode serial) { type = serial.Type; definitions = serial.Definitions; id = serial.Id; name = serial.Name; switch (type) { case NodeType.Decision: control = new DecisionNode(this, serial); definitionControl = new NodeDefinition(this); control.PreviewMouseLeftButtonUp += Control_MouseLeftButtonUp; break; case NodeType.Event: control = new EventNode(this, serial); definitionControl = new NodeDefinition(this); probabilityControl = new PropertyEvent(control as EventNode); control.PreviewMouseLeftButtonUp += Control_MouseLeftButtonUp; break; case NodeType.Value: control = new ValueNode(this, serial); definitionControl = new ValueDefinition(this); outcomeControl = new PropertyValue(control as ValueNode); control.PreviewMouseLeftButtonUp += Control_MouseLeftButtonUp; break; } Point pos = serial.Position; MainWindow.GetCanvas.Children.Add(control); Canvas.SetLeft(control, pos.X - MDesigner.Instance.NodeSize / 2); Canvas.SetTop(control, pos.Y - MDesigner.Instance.NodeSize / 2); n = new Anchor(this, "North", Node.AnchorTopXProperty, Node.AnchorTopYProperty); s = new Anchor(this, "South", Node.AnchorBottomXProperty, Node.AnchorBottomYProperty); w = new Anchor(this, "West", Node.AnchorLeftXProperty, Node.AnchorLeftYProperty); e = new Anchor(this, "East", Node.AnchorRightXProperty, Node.AnchorRightYProperty); anchors = new Anchor[] { n, s, w, e }; MDiagram.AddNode(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); }
public void Turn() { MDiagram.TurnRelation(this); }
public void Unbundle() { MDiagram.UnbundleDecision(owner); }
public void Unbundle() { MDiagram.UnbundleEvent(owner); }
private void Anchor_Drop(object sender, DragEventArgs e) { MDiagram.HideAllAnchors(); MainWindow.GetMCanvas.AddToAnchorLine(node, this); }