protected override void OnStartDrag(object sender, PInputEventArgs e) { DObj.MoveToBack(); e.Handled = true; PNode p1 = ((PNode)sender).Parent; PNode p2 = (PNode)sender; var edge = new DiagEdEdge(); if (p1.Tag == null) { p1.Tag = new List <DiagEdEdge>(); } if (p2.Tag == null) { p2.Tag = new List <DiagEdEdge>(); } ((List <DiagEdEdge>)p1.Tag).Add(edge); ((List <DiagEdEdge>)p2.Tag).Add(edge); edge.start = p1; edge.end = p2; edge.originator = DObj; ConvGraphEditor.addEdge(edge); base.OnStartDrag(sender, e); draggingOutlink = true; }
public void RecreateConnections(IList <DObj> objects) { foreach (OutputLink outLink in Outlinks) { foreach (int link in outLink.Links) { foreach (DiagNode destAction in objects.OfType <DiagNode>()) { if (destAction.NodeID == link) { PPath p1 = outLink.node; var edge = new DiagEdEdge(); if (p1.Tag == null) { p1.Tag = new List <DiagEdEdge>(); } ((List <DiagEdEdge>)p1.Tag).Add(edge); destAction.InputEdges.Add(edge); edge.Pen = new Pen(getColor(outLink.RCat)); edge.start = p1; edge.end = destAction; edge.originator = this; edge.inputIndex = outLink.InputIndices; g.addEdge(edge); outLink.Edges.Add(edge); destAction.RefreshInputLinks(); } } } } }
public static void UpdateEdge(DiagEdEdge edge) { // Note that the node's "FullBounds" must be used (instead of just the "Bound") // because the nodes have non-identity transforms which must be included when // determining their position. PNode node1 = edge.start; PNode node2 = edge.end; PointF start = node1.GlobalBounds.Location; PointF end = node2.GlobalBounds.Location; float h1x, h1y, h2x, h2y; start.X += node1.GlobalBounds.Width; start.Y += node1.GlobalBounds.Height * 0.5f; end.Y += node2.GlobalBounds.Height * 0.5f; h1x = h2x = end.X > start.X ? 200 * (float)Math.Log10((end.X - start.X) / 200 + 1) : 200 * (float)Math.Log10((start.X - end.X) / 100 + 1); if (h1x < 15) { h1x = h2x = 15; } h1y = h2y = 0; edge.Reset(); edge.AddBezier(start.X, start.Y, start.X + h1x, start.Y + h1y, end.X - h2x, end.Y - h2y, end.X, end.Y); }
public void RemoveOutlink(DiagEdEdge edge) { for (int i = 0; i < Outlinks.Count; i++) { OutputLink outLink = Outlinks[i]; for (int j = 0; j < outLink.Edges.Count; j++) { DiagEdEdge DiagEdEdge = outLink.Edges[j]; if (DiagEdEdge == edge) { RemoveOutlink(i, j); return; } } } }
protected override void OnEndDrag(object sender, PInputEventArgs e) { DiagEdEdge edge = ((List <DiagEdEdge>)((PNode)sender).Tag)[0]; ((PNode)sender).SetOffset(0, 0); ((List <DiagEdEdge>)((PNode)sender).Parent.Tag).Remove(edge); ConvGraphEditor.edgeLayer.RemoveChild(edge); ((List <DiagEdEdge>)((PNode)sender).Tag).RemoveAt(0); base.OnEndDrag(sender, e); draggingOutlink = false; if (dragTarget != null) { DObj.CreateOutlink(((PPath)sender).Parent, dragTarget); dragTarget = null; } }
public void addEdge(DiagEdEdge p) { edgeLayer.AddChild(p); UpdateEdge(p); }