Esempio n. 1
0
        /// <summary>
        /// Executes CreateAndConnectNodeCommand to create DoubleSlider and
        /// connect it's output port to the input port of the node.
        /// </summary>
        /// <param name="outputPortIndex">index of output port of slider</param>
        /// <param name="inputPortIndex">index of input port of the node.</param>
        /// <returns>New slider node</returns>
        protected NodeModel CreateAndConnectInputNode(int outputPortIndex, int inputPortIndex)
        {
            var loc = ComputeInputNodeLocation(inputPortIndex);

            // Create number slider node and connect to Point node
            var inputNodeGuid = Guid.NewGuid();

            var command = new DynamoModel.CreateAndConnectNodeCommand(inputNodeGuid, Node.GUID,
                                                                      "CoreNodeModels.Input.DoubleSlider", outputPortIndex, inputPortIndex, loc.Item1, loc.Item2, false, false);

            CommandExecutive.ExecuteCommand(command, UniqueId, ExtensionName);

            var inputNode = WorkspaceModel.Nodes.FirstOrDefault(node => node.GUID == command.ModelGuid) as DoubleSlider;

            if (inputNode != null)
            {
                // Assign the input slider to the default value of the node's input port
                var doubleNode = Node.InPorts[inputPortIndex].DefaultValue as DoubleNode;
                if (doubleNode != null)
                {
                    inputNode.Value = doubleNode.Value;
                }
            }
            return(inputNode);
        }
        public void CreateAndConnectNodeImplTest()
        {
            //Arrange
            Guid newNodeGuid = Guid.NewGuid();
            //This guid belongs to a CoreNodeModels.CreateList node inside the .dyn file
            Guid   existingNodeGuid = new Guid("81c94fd0-35a0-4680-8535-00aff41192d3");
            double x = 100;
            double y = 190;

            string openPath = Path.Combine(TestDirectory, @"core\DetailedPreviewMargin_Test.dyn");

            RunModel(openPath);

            //This command is created with CreateAsDownstreamNode flag as true
            var cmdOne = new DynamoModel.CreateAndConnectNodeCommand(newNodeGuid, existingNodeGuid,
                                                                     "CoreNodeModels.CreateList", 0, 0, x, y, true, false);

            //This command is created with CreateAsDownstreamNode flag as false
            var cmdTwo = new DynamoModel.CreateAndConnectNodeCommand(newNodeGuid, existingNodeGuid,
                                                                     "CoreNodeModels.CreateList", 0, 0, x, y, false, false);

            //Act
            //This will execute the method CreateAndConnectNodeImpl for both commands
            CurrentDynamoModel.ExecuteCommand(cmdOne);
            CurrentDynamoModel.ExecuteCommand(cmdTwo);

            //Assert
            Assert.IsNotNull(cmdOne);
            Assert.IsNotNull(cmdTwo);
        }
Esempio n. 3
0
        /// <summary>
        /// Executes CreateAndConnectNodeCommand to create DoubleSlider and
        /// connect it's output port to the input port of the node.
        /// </summary>
        /// <param name="outputPortIndex">index of output port of slider</param>
        /// <param name="inputPortIndex">index of input port of the node.</param>
        /// <returns>New slider node</returns>
        protected NodeModel CreateAndConnectInputNode(int outputPortIndex, int inputPortIndex)
        {
            var loc = ComputeInputNodeLocation(inputPortIndex);

            // Create number slider node and connect to Point node
            var inputNodeGuid = Guid.NewGuid();

            var command = new DynamoModel.CreateAndConnectNodeCommand(inputNodeGuid, Node.GUID,
                                                                      "DSCoreNodesUI.Input.DoubleSlider", outputPortIndex, inputPortIndex, loc.Item1, loc.Item2, false, false);

            CommandExecutive.ExecuteCommand(command, UniqueId, ExtensionName);

            var inputNode = WorkspaceModel.Nodes.FirstOrDefault(node => node.GUID == command.ModelGuid) as DoubleSlider;

            return(inputNode);
        }
        public void CreateAndConnectNodeCommand_ExecuteCore()
        {
            //Arrange
            Guid   newNodeGuid      = Guid.NewGuid();
            Guid   existingNodeGuid = Guid.NewGuid();
            double x = 100;
            double y = 190;

            var cmdOne = new DynamoModel.CreateAndConnectNodeCommand(newNodeGuid, existingNodeGuid,
                                                                     "CoreNodeModels.Input.DoubleSlider", 0, 1, x, y, false, false);

            //Act
            //This will execute the method ExecuteCore(DynamoModel dynamoModel)
            CurrentDynamoModel.ExecuteCommand(cmdOne);

            //Assert
            Assert.IsNotNull(cmdOne);
        }