Esempio n. 1
0
        private void UpdateConnections(Vector2 mousePos, NodeBase newNode)
        {
            if (newNode == null)
            {
                return;
            }

            if (myPointerState == PointerState.TwoWay && selectedNode != null && selectedNode != newNode)
            {
                myMementos.Add(myNodeCollection.CreateConnectionMemento(new List <NodeBase> {
                    selectedNode, newNode
                }));
                if (selectedNode.myConnections.Contains(newNode) && newNode.myConnections.Contains(selectedNode))
                {
                    selectedNode.RemoveConnection(newNode);
                    newNode.RemoveConnection(selectedNode);
                }
                else
                {
                    if (!selectedNode.myConnections.Contains(newNode))
                    {
                        selectedNode.CreateConnection(newNode);
                    }
                    if (!newNode.myConnections.Contains(selectedNode))
                    {
                        newNode.CreateConnection(selectedNode);
                    }
                }

                SaveManager.Dirty = true;

                UncheckStateBoxes();
            }
            else if (myPointerState == PointerState.OneWay && selectedNode != null && selectedNode != newNode)
            {
                myMementos.Add(myNodeCollection.CreateConnectionMemento(selectedNode));
                if (!selectedNode.myConnections.Contains(newNode))
                {
                    selectedNode.CreateConnection(newNode);
                }
                else
                {
                    selectedNode.RemoveConnection(newNode);
                }

                SaveManager.Dirty = true;

                UncheckStateBoxes();
            }
            else
            {
                PickUpNode(newNode, (mousePos - TranslateVector(newNode.myPos)) / ZoomScale);
            }
        }