Ejemplo n.º 1
0
 private void OnClickDegroup(SubWindows.Group g)
 {
     foreach (var n in g.nodes)
     {
         n.inPoint.onClickConnectionPoint  = OnClickInPoint;
         n.outPoint.onClickConnectionPoint = OnClickOutPoint;
         n.ResetStyle();
     }
     foreach (var c in g.InterConnections)
     {
         c.onClickRemoveConnection = OnClickRemoveConnection;
     }
     nodes.AddRange(g.nodes);
     connections.AddRange(g.InterConnections);
     nodes.Remove(g);
     connections = (from c in connections
                    where c.inPoint.masterNode != g && c.outPoint.masterNode != g
                    select c).ToList();
     Save();
 }
Ejemplo n.º 2
0
        private KeyValuePair <List <NodeWindow>, List <Connection> > GetSystem(List <ScriptTree.Node> rawNodes)
        {
            List <NodeWindow> nodes = new List <NodeWindow>();
            List <Connection> conns = new List <Connection>();

            foreach (var rn in rawNodes)
            {
                NodeWindow node;
                if (rn.Base == "")
                {
                    var p = GetSystem(rn.Members);
                    SubWindows.Group g = new SubWindows.Group(p.Key, p.Value, rn.Name, new Vector2((float)rn.Position.X, (float)rn.Position.Y), 250, inPointStyle, outPointStyle,
                                                              OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, OnClickGroup,
                                                              Events, OnClickDegroup, Save, GetNewName, SelectedNodes, SelectedConnections);
                    var start = g.nodes.Find(n => n.nodeName == rn.StartMember);
                    var end   = g.nodes.Find(n => n.nodeName == rn.EndMember);
                    if (start != null)
                    {
                        var startConn = new Connection(start.inPoint, g.startPoint, null, null);
                        g.connections.Add(startConn);
                    }
                    if (end != null)
                    {
                        var endConn = new Connection(g.endPoint, end.outPoint, null, null);
                        g.connections.Add(endConn);
                    }
                    node = g;
                }
                else
                {
                    node = new NodeWindow(rn.Base, rn.Name, new Vector2((float)rn.Position.X, (float)rn.Position.Y),
                                          250, inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, OnClickGroup, GetNewName, SelectedNodes, SelectedConnections);
                    node.paramPairs = rn.Params.ToList();
                    node.nodeName   = rn.Name;
                }
                nodes.Add(node);
            }

            foreach (var rn in rawNodes)
            {
                var startNode = nodes.Find(n => n.nodeName == rn.Name);
                Debug.Assert(startNode != null);
                if (rn.Succ != null)
                {
                    foreach (var succ in rn.Succ)
                    {
                        var destNode = nodes.Find(n => n.nodeName == succ.Dest);
                        Debug.Assert(destNode != null);

                        var conn = new Connection(destNode.inPoint, startNode.outPoint, OnClickRemoveConnection, Events);
                        foreach (var cond in succ.Condition)
                        {
                            conn.conditions.Add(nodes.Find(n => n.nodeName == cond));
                        }
                        conn.stopPrev = succ.EndPrev;
                        conns.Add(conn);
                    }
                }
            }
            return(new KeyValuePair <List <NodeWindow>, List <Connection> >(nodes, conns));
        }