public void AddPredecessor(NodeVisualization nv) { object[] args = { nv.Node }; Node.GetType().GetMethod("AddPredecessor").Invoke(Node, args); nv.successors [this] = false; predecessors[nv] = false; }
public void RemoveNode(NodeVisualization node) { graph.GetType().GetMethod("RemoveNode").Invoke(graph, new[] { node.Node }); nodes.Remove(node); Console.WriteLine("RemoveNode"); Console.WriteLine(graph.ToString()); }
public void RemovePredecessor(NodeVisualization nv) { object[] args = { nv.Node }; Node.GetType().GetMethod("RemovePredecessor").Invoke(Node, args); nv.successors.Remove(this); predecessors.Remove(nv); }
public bool AddNode(NodeVisualization node) { List <string> names = nodes.Select(n => n.ToString()).ToList(); if (names.Contains(node.ToString())) { return(false); } graph.GetType().GetMethod("AddNode").Invoke(graph, new[] { node.Node }); nodes.Add(node); return(true); }
private void DrawEdge(Cairo.Context cx, NodeVisualization _from, NodeVisualization _to) { int beginX = _from.X + _from.Width / 2; int beginY = _from.Y + _from.Height / 2; int endX = _to.X + _to.Width / 2; int endY = _to.Y + _to.Height / 2; cx.Antialias = Antialias.Gray; cx.LineWidth = 3; if (!_from.successors.ContainsKey(_to) || _from.successors[_to] == false) { cx.SetSourceColor(new Color(0, 0, 0, 1)); } else { cx.SetSourceColor(new Color(0, 0.8, 0, 1)); } cx.LineCap = LineCap.Round; cx.MoveTo(beginX, beginY); cx.LineTo(endX, endY); cx.Stroke(); int tipX = ((2 * endX) + beginX) / 3; int tipY = ((2 * endY) + beginY) / 3; int arrowLength = 10; //can be adjusted int dx = endX - beginX; int dy = endY - beginY; double theta = Math.Atan2(dy, dx); double rad = 35 * Math.PI / 180; //35 angle double x = tipX - arrowLength * Math.Cos(theta + rad); double y = tipY - arrowLength * Math.Sin(theta + rad); double phi2 = -35 * Math.PI / 180; //-35 angle double x2 = tipX - arrowLength * Math.Cos(theta + phi2); double y2 = tipY - arrowLength * Math.Sin(theta + phi2); cx.MoveTo(tipX, tipY); cx.LineTo(x, y); cx.Stroke(); cx.MoveTo(tipX, tipY); cx.LineTo(x2, y2); cx.Stroke(); }
public void StartRemoveConnection(NodeVisualization nv) { removeConnection = true; predecessor = nv; }
public void StartConnection(NodeVisualization nv) { makeConnection = true; predecessor = nv; }