private void Delete(IEnumerable <PropertyPaletteNodeViewModel> selectedNodes)
 {
     // Have to delete individually as multiple deletion only removes the first one
     // TODO: Investigate why the workspace's NodeRemoved even is not fired.
     foreach (var node in selectedNodes)
     {
         var command = new DynamoModel.DeleteModelCommand(node.NodeModel.GUID);
         viewLoadedParams.CommandExecutive.ExecuteCommand(command, Constants.ExtensionUniqueId, Constants.ExtensionName);
     }
 }
Ejemplo n.º 2
0
        public override int Mutate(NodeModel node)
        {
            DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
            {
                DynamoModel.DeleteModelCommand delCommand =
                    new DynamoModel.DeleteModelCommand(node.GUID);

                DynamoViewModel.ExecuteCommand(delCommand);
            }));

            return(1);
        }
Ejemplo n.º 3
0
        public override int Mutate(NodeModel node)
        {
            this.DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
            {
                DynamoModel.DeleteModelCommand delCommand =
                    new DynamoModel.DeleteModelCommand(node.GUID);

                DynamoViewModel.ExecuteCommand(delCommand);
            }));

            //We've performed a single delete
            return(1);
        }
Ejemplo n.º 4
0
        public void Rebinding_NodeDeletedBeforeRun()
        {
            var model = OpenElementBindingWorkspace("RebindingSingleDimension.dyn");

            var refPtNode = model.CurrentWorkspace.FirstNodeFromWorkspace <DSFunction>();
            var command   = new DynamoModel.DeleteModelCommand(refPtNode.GUID);

            ViewModel.ExecuteCommand(command);
            RunCurrentModel();

            var doc    = DocumentManager.Instance.CurrentDBDocument;
            var refPts = Utils.AllElementsOfType <ReferencePoint>(doc);

            Assert.AreEqual(refPts.Count(), 0);
        }
Ejemplo n.º 5
0
        public void MAGN9434_DeleteCodeBlockNode()
        {
            OpenVisualizationTest("CreatePoint.dyn");
            Assert.AreEqual(1, BackgroundPreviewGeometry.TotalPoints());
            var codeBlockNode = ViewModel.CurrentSpace.NodeFromWorkspace <CodeBlockNodeModel>(Guid.Parse("7883d92a-ef8b-4e05-8c7d-46cfc627c994"));

            var command = new DynamoModel.UpdateModelValueCommand(Guid.Empty, codeBlockNode.GUID, "Code", "p2 = Point.ByCoordinates();");

            ViewModel.Model.ExecuteCommand(command);
            Assert.AreEqual(1, BackgroundPreviewGeometry.TotalPoints());

            var deleteCommand = new DynamoModel.DeleteModelCommand(codeBlockNode.GUID);

            ViewModel.Model.ExecuteCommand(deleteCommand);
            Assert.AreEqual(0, BackgroundPreviewGeometry.TotalPoints());
        }
Ejemplo n.º 6
0
        public void CPythonClassCanBeReturnedAndSafelyDisposedInDownStreamNode()
        {
            // open test graph
            var examplePath = Path.Combine(TestDirectory, @"core\python", "cpythoncustomclass_modified.dyn");

            ViewModel.OpenCommand.Execute(examplePath);

            var classdef    = ViewModel.Model.CurrentWorkspace.Nodes.First(x => x.Name == "classdef");
            var downstream1 = ViewModel.Model.CurrentWorkspace.Nodes.First(x => x.Name == "downstream1");
            var downstream2 = ViewModel.Model.CurrentWorkspace.Nodes.First(x => x.Name == "downstream2");

            ViewModel.HomeSpace.Run();
            AssertPreviewValue(downstream2.GUID.ToString(), "joe");
            Assert.AreEqual(2, DynamoCPythonHandle.HandleCountMap.First(x => x.ToString().Contains("myClass")).Value);


            ViewModel.Model.CurrentWorkspace.Nodes.OfType <CodeBlockNodeModel>().First().UpdateValue(new UpdateValueParams("Code", "\"foo\";"));

            ViewModel.HomeSpace.Run();
            AssertPreviewValue(downstream2.GUID.ToString(), "foo");
            Assert.AreEqual(2, DynamoCPythonHandle.HandleCountMap.First(x => x.ToString().Contains("myClass")).Value);

            ViewModel.Model.CurrentWorkspace.Nodes.OfType <CodeBlockNodeModel>().First().UpdateValue(new UpdateValueParams("Code", "\"bar\";"));

            ViewModel.HomeSpace.Run();
            AssertPreviewValue(downstream2.GUID.ToString(), "bar");

            var deleteCmd = new DynamoModel.DeleteModelCommand(downstream1.GUID);

            ViewModel.Model.ExecuteCommand(deleteCmd);

            Assert.AreEqual(1, DynamoCPythonHandle.HandleCountMap.First(x => x.ToString().Contains("myClass")).Value);

            var deleteCmd2 = new DynamoModel.DeleteModelCommand(classdef.GUID);

            ViewModel.Model.ExecuteCommand(deleteCmd2);

            Assert.IsEmpty(DynamoCPythonHandle.HandleCountMap.Where(x => x.ToString().Contains("myClass")));
        }
Ejemplo n.º 7
0
        public void ModificationUITesting()
        {
            // Re-use code for creating a custom node
            CanCreateAndPlaceNewCustomNode();

            var instance = CurrentDynamoModel.CurrentWorkspace.Nodes.First() as Function;

            SelectTabByGuid(instance.Definition.FunctionId);

            var currentInPortAmt  = 0;
            var currentOutPortAmt = 0;

            #region Adding
            Func <string, Symbol> addInput = label =>
            {
                var node = new Symbol();
                CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateNodeCommand(node, 0, 0, true, true));
                node.InputSymbol = label;

                Assert.AreEqual(++currentInPortAmt, instance.InPorts.Count);
                Assert.AreEqual(label, instance.InPorts.Last().Name);

                return(node);
            };

            Func <string, Output> addOutput = label =>
            {
                var node = new Output();

                CurrentDynamoModel.ExecuteCommand(new DynamoModel.CreateNodeCommand(node, 0, 0, true, true));
                node.Symbol = label;

                Assert.AreEqual(++currentOutPortAmt, instance.OutPorts.Count);
                Assert.AreEqual(label, instance.OutPorts.Last().Name);

                return(node);
            };
            #endregion

            #region Renaming
            Action <Symbol, int, string> renameInput = (input, idx, s) =>
            {
                input.InputSymbol = s;
                Assert.AreEqual(s, instance.InPorts[idx].Name);
            };

            Action <Output, int, string> renameOutput = (output, idx, s) =>
            {
                output.Symbol = s;
                Assert.AreEqual(s, instance.OutPorts[idx].Name);
            };
            #endregion

            #region Deleting
            Action <NodeModel> deleteNode = nodeModel =>
            {
                DynamoSelection.Instance.ClearSelection();
                CurrentDynamoModel.AddToSelection(nodeModel);
                var command = new DynamoModel.DeleteModelCommand(Guid.Empty);
                CurrentDynamoModel.ExecuteCommand(command);
            };

            Action <Symbol> deleteInput = input =>
            {
                deleteNode(input);
                Assert.AreEqual(--currentInPortAmt, instance.InPorts.Count);
            };

            Action <Output> deleteOutput = output =>
            {
                deleteNode(output);
                Assert.AreEqual(--currentOutPortAmt, instance.OutPorts.Count);
            };
            #endregion

            //Add some outputs
            var out1 = addOutput("output1");
            var out2 = addOutput("output2");

            //Add some inputs
            var in1 = addInput("input1");
            var in2 = addInput("input2");

            //Change some names
            renameInput(in1, 0, "test");
            renameOutput(out2, 1, "something");

            //Delete some ports
            deleteInput(in2);
            deleteOutput(out1);
        }
Ejemplo n.º 8
0
        private void DeleteNodeAndItsConnectors(object parameter)
        {
            var command = new DynamoModel.DeleteModelCommand(nodeLogic.GUID);

            DynamoViewModel.ExecuteCommand(command);
        }