Пример #1
0
        public void RemoveInput_AddAndRemoveInput_OperatorDoesNotContainNewInput()
        {
            const string newInputName = "newTestInput";
            var          newInput     = new MetaInput(Guid.NewGuid(), newInputName, BasicMetaTypes.FloatMeta, new Float(0.0f), false);

            _operator.Definition.AddInput(newInput);
            var inputToRemove      = _operator.Inputs.Find(input => input.Name == newInputName);
            var removeInputCommand = new RemoveInputCommand(_operator, inputToRemove);

            removeInputCommand.Do();
            Assert.IsNull(_operator.Inputs.Find(input => input.Name == newInputName));
        }
Пример #2
0
        private void TypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SetDefaultValue();

            int idx           = _operator.Inputs.IndexOf(_operatorPart);
            var removeCommand = new RemoveInputCommand(_operator, _operatorPart);

            _metaInput.OpPart = BasicMetaTypes.GetMetaOperatorPartOf((FunctionType)TypeComboBox.SelectedIndex);

            // set default value
            switch ((FunctionType)TypeComboBox.SelectedIndex)
            {
            case FunctionType.Float:
                _defaultValue = new Float(0.0f);
                break;

            case FunctionType.Text:
                _defaultValue = new Text(String.Empty);
                break;

            case FunctionType.Scene:
                _defaultValue = new Core.Scene();
                break;

            case FunctionType.Generic:
                _defaultValue = new Generic();
                break;

            case FunctionType.Dynamic:
                _defaultValue = new Dynamic();
                break;

            case FunctionType.Mesh:
                _defaultValue = new Core.MeshValue();
                break;

            default:
                Logger.Error("InputParameterView.TypeComboBox_SelectionChanged: Unknown 'FunctionType' with value {0}", TypeComboBox.SelectedIndex);
                break;
            }
            _metaInput.DefaultValue = _defaultValue;
            var command = new AddInputCommand(_operator, _metaInput);

            ICommand[] commands = { removeCommand, command };

            App.Current.UndoRedoStack.AddAndExecute(new MacroCommand("Changed Input Type", commands));
            App.Current.UpdateRequiredAfterUserInteraction = true;
        }
Пример #3
0
        public void RemoveInput_AddAndRemoveInputSerializeCommand_CommandIsUndoableAfterDeserialisation()
        {
            const string newInputName = "newTestInput";
            var          newInput     = new MetaInput(Guid.NewGuid(), newInputName, BasicMetaTypes.FloatMeta, new Float(0.0f), false);

            _operator.Definition.AddInput(newInput);
            var inputToRemove      = _operator.Inputs.Find(input => input.Name == newInputName);
            var removeInputCommand = new RemoveInputCommand(_operator, inputToRemove);

            removeInputCommand.Do();

            var jsonString = SerializeCommand(removeInputCommand);
            var command    = JsonConvert.DeserializeObject <PersistentCommand>(jsonString, _serializerSettings);

            command.Command.Undo();

            Assert.IsNotNull(_operator.Inputs.Find(input => input.Name == newInputName));
        }
Пример #4
0
        public void RemoveInput_AddAndRemoveInputWithInGoingConnection_ConnectionsAreRestoredAfterUndo()
        {
            const string newInputName = "newTestInput";
            var          newInput     = new MetaInput(Guid.NewGuid(), newInputName, BasicMetaTypes.FloatMeta, new Float(0.0f), false);

            _operator.Definition.AddInput(newInput);

            var internalOp    = _parentOperator.InternalOps.Find(op => op.Definition.ID == _operator.Definition.ID);
            var internalInput = _operator.Definition.Inputs.Find(input => input.Name == newInputName);
            var inputToRemove = _operator.Inputs.Find(input => input.Name == newInputName);

            _operator.Definition.Connections       = new[] { new MetaConnection(Guid.Empty, internalInput.ID, Guid.Empty, _operator.Definition.Outputs[0].ID) }.ToList();
            _parentOperator.Definition.Connections = new[] { (new MetaConnection(Guid.Empty, _parentOperator.Definition.Inputs[0].ID, internalOp.ID, internalInput.ID)) }.ToList();

            var removeInputCommand = new RemoveInputCommand(_operator, inputToRemove);

            removeInputCommand.Do();
            removeInputCommand.Undo();

            Assert.IsNotNull(_operator.Definition.Connections.Find(connection => connection.SourceOpPartID == internalInput.ID && connection.TargetOpPartID == _operator.Definition.Outputs[0].ID));
            Assert.IsNotNull(_parentOperator.Definition.Connections.Find(connection => connection.TargetOpID == internalOp.ID && connection.TargetOpPartID == internalInput.ID));
        }