public void Update(CustomNode node) { AddNode(node.Pair); foreach (CustomNode n in node.Childs) { Update(n); } //if (!Nodes.Contains(node)) // Nodes.Add(node); }
public double FindAngle(CustomNode node) { //if (node.Pair == null) // node.Pair = node.InitialPair; if (node.Pair.Root != null) { Point p1 = new Point(node.Pair.Root.OffsetX, node.Pair.Root.OffsetY); Point p2 = new Point(node.Pair.Child.OffsetX, node.Pair.Child.OffsetY); double dx = p2.X - p1.X; double dy = p2.Y - p1.Y; double ang = Math.Atan2(dy, dx) * 180 / Math.PI; return(ang); } else { return(0); } }
public void RemoveNode(CustomNode root) { if (root.Childs != null) { foreach (CustomNode node in root.Childs) { RemoveNode(node); } } if (!AllowUpdate & root.Pair.Root != null) { Animate(root, (root.Info as INodeInfo).ActualWidth, 0, "Width"); Animate(root, (root.Info as INodeInfo).ActualHeight, 0, "Height"); if (root.Pair.Root.OffsetX < root.OffsetX) { Animate(root, root.OffsetX, root.OffsetX - 100, "OffsetX"); } if (root.Pair.Root.OffsetX > root.OffsetX) { Animate(root, root.OffsetX, root.OffsetX + 100, "OffsetX"); } if (root.Pair.Root.OffsetY < root.OffsetY) { Animate(root, root.OffsetY, root.OffsetY - 100, "OffsetY"); } if (root.Pair.Root.OffsetY > root.OffsetY) { Animate(root, root.OffsetY, root.OffsetY + 100, "OffsetY"); } //Task.WaitAny(TimeSpan.FromMilliseconds(200)); if (root.Pair.Link != null) { Lines.Remove(root.Pair.Link); } Nodes.Remove(root); } else { root.OffsetX = 700; root.OffsetY = 350; } }
public Storyboard RepeatAnimate(CustomNode n, double from, double to, string property, bool complete, bool autoreverse) { Storyboard storyboard = new Storyboard(); // if (complete) // storyboard.Completed += storyboard_Completed; // DoubleAnimation doubleAnimation = new DoubleAnimation(); // doubleAnimation.From = from; // doubleAnimation.To = to; // if (autoreverse) // doubleAnimation.AutoReverse = true; // doubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200)); // doubleAnimation.RepeatBehavior = RepeatBehavior.Forever; // doubleAnimation.EnableDependentAnimation = true; // storyboard.Children.Add(doubleAnimation); //// Storyboard.SetTarget(doubleAnimation,n); // Storyboard.SetTargetProperty(doubleAnimation, property); // storyboard.Begin(); return(storyboard); }
public CustomNode RootNode() { CustomNode n = new CustomNode(); n.AllowDelete = false; n.InitialPair = new Nodepair(null, n, null); n.Childs = new ObservableCollection <CustomNode>(); n.OffsetX = 700; n.OffsetY = 350; n.UnitHeight = 40; n.UnitWidth = 75; //n.Constraints = n.Constraints ^ NodeConstraints.Draggable; n.ContentTemplate = App.Current.Resources["RNodeTemplate"] as DataTemplate; NodePort port = new NodePort(); NodePort port1 = new NodePort(); port.Visibility = Visibility.Collapsed; port1.Visibility = Visibility.Collapsed; port.NodeOffsetX = 0; port.NodeOffsetY = 0.5; port1.NodeOffsetX = 1; port1.NodeOffsetY = 0.5; n.NodePorts = new ObservableCollection <INodePort>() { port, port1 }; n.NodeAnnotations = new ObservableCollection <IAnnotation>() { new CustomLabel() { Content = "Root Node" } }; Nodes.Add(n); return(n); }
public bool ChildCheck(CustomNode node) { bool IsFound = false; if (node.Childs != null) { foreach (CustomNode n in node.Childs) { if (n == CheckingNode) { IsFound = true; } else { IsFound = ChildCheck(n); } if (IsFound) { break; } } } return(IsFound); }
private void Animate(CustomNode root, double from, double to, string name) { //root.From = from; //root.Pname = name; //root.To = to; }
public Nodepair(CustomNode Root, CustomNode Child, CustomConnector Link) { this.Root = Root; this.Child = Child; this.Link = Link; }