Exemplo n.º 1
0
        /// <summary>
        /// Removes the script variable from the state. Also removes all its connections.
        /// </summary>
        public override void Remove()
        {
            // remove all connections
            foreach (BaseNode baseNode in State.Nodes)
            {
                Node node = baseNode as Node;
                if (node != null)
                {
                    foreach (NodeSocket nodeSocket in node.Sockets)
                    {
                        VariableNodeSocket variableNodeSocket = nodeSocket as VariableNodeSocket;
                        if (variableNodeSocket != null)
                        {
                            for (int i = 0; i < variableNodeSocket.Connections.Count; ++i)
                            {
                                if (variableNodeSocket.Connections[i] == this)
                                {
                                    variableNodeSocket.Connections.RemoveAt(i);
                                    --i;
                                }
                            }
                        }
                    }
                }
            }

            base.Remove();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the specified variable node socket.
        /// </summary>
        /// <param name="variableNodeSocket">The variable node socket.</param>
        /// <exception cref="ArgumentException">Argument is not variable node socket.</exception>
        public void AddVariableSocket(VariableNodeSocket variableNodeSocket)
        {
            if (variableNodeSocket.Type != NodeSocketType.VariableIn && variableNodeSocket.Type != NodeSocketType.VariableOut)
            {
                throw new ArgumentException("Argument is not variable node socket.");
            }

            variableSockets.Add(new VariableNodeSocketView(this, variableNodeSocket));

            UpdateGui();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the sockets defined at the <see cref="NodeData"/>.
        /// </summary>
        protected void CreateSockets()
        {
            _sockets = new NodeSocket[NodeData.Sockets.Count];

            for (int i = 0; i < NodeData.Sockets.Count; ++i)
            {
                if (NodeData.Sockets[i].Type == NodeSocketType.SignalIn || NodeData.Sockets[i].Type == NodeSocketType.SignalOut)
                {
                    _sockets[i] = new SignalNodeSocket(this, NodeData.Sockets[i]);
                }
                else
                {
                    _sockets[i] = new VariableNodeSocket(this, NodeData.Sockets[i]);
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VariableNodeSocketView"/> class.
        /// </summary>
        /// <param name="scriptNode">The view of the script node where the view of the node socket will be used.</param>
        /// <param name="variableNodeSocket">The variable node socket.</param>
        public VariableNodeSocketView(NodeView scriptNode, VariableNodeSocket variableNodeSocket)
            : base(scriptNode, variableNodeSocket)
        {
            _variableNodeSocket = variableNodeSocket;

            if (VariableNodeSocket.Type == NodeSocketType.VariableIn)
            {
                VariableNodeSocket.Value.ValueChanged += new EventHandler(Value_ValueChanged);
            }

            if (valueTextFormat == null)
            {
                valueTextFormat           = new StringFormat();
                valueTextFormat.Trimming  = StringTrimming.EllipsisCharacter;
                valueTextFormat.Alignment = StringAlignment.Center;
            }
        }