Esempio n. 1
0
        static void CreateItemizedNode(State state, VSGraphModel graphModel, ref IPortModel outputPortModel)
        {
            ItemizeOptions currentItemizeOptions = state.Preferences.CurrentItemizeOptions;

            // automatically itemize, i.e. duplicate variables as they get connected
            if (!outputPortModel.Connected || currentItemizeOptions == ItemizeOptions.Nothing)
            {
                return;
            }

            INodeModel nodeToConnect = outputPortModel.NodeModel;

            bool itemizeContant = currentItemizeOptions.HasFlag(ItemizeOptions.Constants) &&
                                  nodeToConnect is ConstantNodeModel;
            bool itemizeVariable = currentItemizeOptions.HasFlag(ItemizeOptions.Variables) &&
                                   (nodeToConnect is VariableNodeModel || nodeToConnect is ThisNodeModel);
            bool itemizeSystemConstant = currentItemizeOptions.HasFlag(ItemizeOptions.SystemConstants) &&
                                         nodeToConnect is SystemConstantNodeModel;

            if (itemizeContant || itemizeVariable || itemizeSystemConstant)
            {
                Vector2 offset = Vector2.up * k_NodeOffset;
                nodeToConnect   = graphModel.DuplicateUnstackedNode(outputPortModel.NodeModel, new Dictionary <INodeModel, NodeModel>(), offset);
                outputPortModel = nodeToConnect.OutputsById[outputPortModel.UniqueId];
            }
        }