Exemplo n.º 1
0
        private void ValidateSocketsDatabase()
        {
            if (m_socketsDatabase == null)
            {
                return;
            }
            var invalidKeys = new List <string>(); //temp keys list

            foreach (string key in SocketsDatabase.Keys)
            {
                if (SocketsDatabase[key] == null)
                {
                    invalidKeys.Add(key); //null socket -> remove it
                    continue;
                }

                if (!NodesDatabase.ContainsKey(SocketsDatabase[key].NodeId))
                {
                    invalidKeys.Add(key);                                                          //null parent -> remove it
                }
            }

            foreach (string invalidKey in invalidKeys)
            {
                SocketsDatabase.Remove(invalidKey);                                        //remove invalid keys
            }
        }
        private void SelectNodes(IEnumerable <Node> nodes, bool addToCurrentSelection, bool recordUndo)
        {
            if (recordUndo)
            {
                RecordUndo(GraphAction.SelectNodes.ToString());               //record undo select nodes
            }
            if (!addToCurrentSelection)
            {
                WindowSettings.SelectedNodes.Clear();                         //if this is a new selection -> clear the previous one
            }
            //check if the GUI needs to get reconstructed
            bool needsToReconstructGraphGUI = false;

            foreach (Node node in nodes)
            {
                if (!NodesDatabase.ContainsKey(node.Id)) //found a node id not in the constructed database -> skip this entry and trigger a construct gui
                {
                    needsToReconstructGraphGUI = true;
                    continue;
                }

                if (WindowSettings.SelectedNodes.Contains(node))
                {
                    WindowSettings.SelectedNodes.Remove(node);
                    continue;
                }

                WindowSettings.SelectedNodes.Add(node);
            }

            if (needsToReconstructGraphGUI)
            {
                ConstructGraphGUI();
            }
            UpdateNodesSelectedState(WindowSettings.SelectedNodes);                        //update the currently selected nodes visual (normal style or selected style)
            DGUI.Utility.SelectObjectsInInspector(WindowSettings.SelectedNodes.ToArray()); //select the nodes in the Inspector view
        }