Exemplo n.º 1
0
        private void ToggleIsUpstreamVisible(object parameter)
        {
            // Invert the visibility before setting the value
            var visibility = (!nodeLogic.IsUpstreamVisible).ToString();
            var command = new DynamoModel.UpdateModelValueCommand(Guid.Empty,
                new[] { nodeLogic.GUID }, "IsUpstreamVisible", visibility);

            DynamoViewModel.Model.ExecuteCommand(command);
            DynamoViewModel.RaiseCanExecuteUndoRedo();
        }
Exemplo n.º 2
0
        public override int Mutate(NodeModel node)
        {
            string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*(),./[];=-:<\\>?";
            Random random = new Random();
            string value = new string(Enumerable.Repeat(chars, 10).Select(s => s[random.Next(s.Length)]).ToArray());

            DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
            {
                DynamoModel.UpdateModelValueCommand updateValue =
                    new DynamoModel.UpdateModelValueCommand(System.Guid.Empty, node.GUID, "Value", value);

                DynamoViewModel.ExecuteCommand(updateValue);
            }));

            return 1;
        }        
Exemplo n.º 3
0
        private void ToggleIsFrozen(object parameters)
        {
            var node = this.nodeLogic;
            if (node != null)
            {
                var oldFrozen = (!node.isFrozenExplicitly).ToString();
                var command = new DynamoModel.UpdateModelValueCommand(Guid.Empty,
                    new[] { node.GUID }, "IsFrozen", oldFrozen);

                DynamoViewModel.Model.ExecuteCommand(command);
            }
            else if (DynamoSelection.Instance.Selection.Any())
            {
                node = DynamoSelection.Instance.Selection.Cast<NodeModel>().First();
                node.IsFrozen = !node.IsFrozen;
            }

            RaisePropertyChanged("IsFrozenExplicitly");
            RaisePropertyChanged("CanToggleFrozen");
            RaisePropertyChanged("IsFrozen");
        }
Exemplo n.º 4
0
        private void SetArgumentLacing(object parameter)
        {
            var modelGuids = DynamoSelection.Instance.Selection.
                OfType<NodeModel>().Select(n => n.GUID);

            if (!modelGuids.Any())
                return;

            var command = new DynamoModel.UpdateModelValueCommand(Guid.Empty,
                modelGuids, "ArgumentLacing", (string) parameter);

            DynamoViewModel.Model.ExecuteCommand(command);
            RaisePropertyChanged("SelectionArgumentLacing");
        }
Exemplo n.º 5
0
        public override int Mutate(NodeModel node)
        {
            string assemblyPath = Assembly.GetExecutingAssembly().Location;

            DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
            {
                DynamoModel.UpdateModelValueCommand updateValue =
                    new DynamoModel.UpdateModelValueCommand(System.Guid.Empty, node.GUID, "Value", assemblyPath);

                DynamoViewModel.ExecuteCommand(updateValue);
            }));

            return 1;
        }        
Exemplo n.º 6
0
        public override int Mutate(NodeModel node)
        {
            Random rand = new Random(1);
            string value = rand.Next(100).ToString();

            DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
            {
                DynamoModel.UpdateModelValueCommand updateValue =
                    new DynamoModel.UpdateModelValueCommand(node.GUID, "Value", value);

                DynamoViewModel.ExecuteCommand(updateValue);
            }));

            return 1;
        }        
Exemplo n.º 7
0
        private void ShowHideAllUpstreamPreview(object parameter)
        {
            var modelGuids = DynamoSelection.Instance.Selection.
                OfType<NodeModel>().Select(n => n.GUID);

            if (!modelGuids.Any())
                return;

            var command = new DynamoModel.UpdateModelValueCommand(Guid.Empty,
                modelGuids, "IsUpstreamVisible", (string) parameter);

            DynamoViewModel.Model.ExecuteCommand(command);
            RefreshViewOnSelectionChange();
        }
Exemplo n.º 8
0
        private void KeepListStructure(object parameter)
        {
            bool keepListStructure = (bool)parameter;
            var command = new DynamoModel.UpdateModelValueCommand(
                Guid.Empty, _node.NodeLogic.GUID, "KeepListStructure", string.Format("{0}:{1}", _port.Index, keepListStructure));

            _node.WorkspaceViewModel.DynamoViewModel.ExecuteCommand(command);
        }
Exemplo n.º 9
0
        private void ChangeLevel(int level)
        {
            var command = new DynamoModel.UpdateModelValueCommand(
                            Guid.Empty, _node.NodeLogic.GUID, "ChangeLevel", string.Format("{0}:{1}", _port.Index, level));

            _node.WorkspaceViewModel.DynamoViewModel.ExecuteCommand(command);
        }
Exemplo n.º 10
0
        private void UseLevel(object parameter)
        {
            var useLevel = (bool)parameter;
            var command = new DynamoModel.UpdateModelValueCommand(
                Guid.Empty, _node.NodeLogic.GUID, "UseLevels", string.Format("{0}:{1}", _port.Index, useLevel));

            _node.WorkspaceViewModel.DynamoViewModel.ExecuteCommand(command);
        }
Exemplo n.º 11
0
        public void MAGN9434_DisablePreview()
        {
            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 disableCommand = new DynamoModel.UpdateModelValueCommand(Guid.Empty, codeBlockNode.GUID, "IsVisible", "false");
            ViewModel.Model.ExecuteCommand(disableCommand);
            Assert.AreEqual(0, BackgroundPreviewGeometry.TotalPoints() - BackgroundPreviewGeometry.NumberOfInvisiblePoints());
        }
Exemplo n.º 12
0
        public override int Mutate(NodeModel node)
        {
            string assemblyPass = Environment.CurrentDirectory + "\\nodes\\CoreNodeModels.dll";
            Assembly assembly = Assembly.LoadFile(assemblyPass);
            Type type = assembly.GetType("Dynamo.Nodes.DoubleSlider");
            
            PropertyInfo propInfo = type.GetProperty("Min");
            dynamic propertyMin = propInfo.GetValue(node, null);
            propInfo = type.GetProperty("Max");
            dynamic propertyMax = propInfo.GetValue(node, null);

            double min = 0;
            double max = 0;
            int returnCode = 0;
            Random rand = new Random(1);

            if (double.TryParse(propertyMin.ToString(), out min) &&
                double.TryParse(propertyMax.ToString(), out max))
            {
                string value = (min + (max - min) * rand.NextDouble()).ToString();

                DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                {
                    DynamoModel.UpdateModelValueCommand updateValue =
                        new DynamoModel.UpdateModelValueCommand(System.Guid.Empty, node.GUID, "Value", value);
                    DynamoViewModel.ExecuteCommand(updateValue);
                }));

                returnCode = 1;
            }

            return returnCode;
        }
Exemplo n.º 13
0
        public override int Mutate(NodeModel node)
        {
            string assemblyPath = Assembly.GetExecutingAssembly().Location;
            string assemblyDir = Path.GetDirectoryName(assemblyPath);
            string pathToNodesDll = assemblyDir + "\\nodes\\DSCoreNodesUI.dll";
            Assembly assembly = Assembly.LoadFile(pathToNodesDll);

            Type type = assembly.GetType("Dynamo.Nodes.IntegerSlider");

            PropertyInfo propInfo = type.GetProperty("Min");
            dynamic propertyMin = propInfo.GetValue(node, null);
            propInfo = type.GetProperty("Max");
            dynamic propertyMax = propInfo.GetValue(node, null);

            int min = 0;
            int max = 0;
            int returnCode = 0;
            Random rand = new Random();

            if (Int32.TryParse(propertyMin.ToString(), out min) &&
                Int32.TryParse(propertyMax.ToString(), out max))
            {
                string value = (rand.Next(min, max)).ToString();

                DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                {
                    DynamoModel.UpdateModelValueCommand updateValue =
                        new DynamoModel.UpdateModelValueCommand(System.Guid.Empty, node.GUID, "Value", value);
                    DynamoViewModel.ExecuteCommand(updateValue);
                }));

                returnCode = 1;
            }

            return returnCode;
        }        
Exemplo n.º 14
0
        public override int Mutate(NodeModel node)
        {
            Random Rand = new Random(1);

            this.DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
                {
                    string code = ((CodeBlockNodeModel)node).Code;

                    if (code.Length == 0)
                        code = "";

                    string replacement;

                    if (Rand.NextDouble() <= 0.5)
                    {
                        //Strategy 1: Replacement with simplest minimal replacement

                        replacement = "1;";
                    }
                    else
                    {
                        //Strategy 2: Noise injection

                        replacement = code;

                        while (Rand.NextDouble() > 0.5)
                        {
                            int locat = Rand.Next(code.Length);
                            const string junk = "<>:L/;'\\/[=+-";

                            replacement = code.Substring(0, locat) + junk[Rand.Next(junk.Length)] +
                                          code.Substring(locat);
                        }
                    }

                    var cmd = new DynamoModel.UpdateModelValueCommand(System.Guid.Empty, node.GUID, "Code", replacement);

                    this.DynamoViewModel.ExecuteCommand(cmd);
                }));

            //We've performed a single edit from the perspective of undo
            return 1;
        }