Ejemplo n.º 1
0
        private void IsMultiInputComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var changeEntry = new UpdateInputParameterCommand.Entry(_metaInput)
            {
                IsMultiInput = IsMultiInputComboBox.SelectedIndex == 1
            };
            var command = new UpdateInputParameterCommand(_operator, _metaInput.ID, changeEntry);

            App.Current.UndoRedoStack.AddAndExecute(command);
            App.Current.UpdateRequiredAfterUserInteraction = true;
        }
        public void UpdateInputParameter_AddNewInputToOperatorThenChangeInputRelevancy_NewInputHasNewRelevancy()
        {
            const string newInputName = "newTestInput";
            var          newInput     = new MetaInput(Guid.NewGuid(), newInputName, BasicMetaTypes.FloatMeta, new Float(0.0f), false);

            _operator.Definition.AddInput(newInput);
            var newRelevancy = MetaInput.RelevanceType.Required;
            var changes      = new UpdateInputParameterCommand.Entry(newInput)
            {
                Relevance = newRelevancy
            };
            var updateInputCommand = new UpdateInputParameterCommand(_operator, newInput.ID, changes);

            updateInputCommand.Do();

            Assert.IsTrue(_operator.Definition.Inputs.Find(input => input.Name == newInputName).Relevance == newRelevancy);
        }
Ejemplo n.º 3
0
        public InputParameterView(Operator op, OperatorPart opPart)
        {
            InitializeComponent();

            _operator     = op;
            _operatorPart = opPart;

            _metaInput = _operator.GetMetaInput(_operatorPart);

            var command = new UpdateInputParameterCommand(_operator, _metaInput.ID, new UpdateInputParameterCommand.Entry(_metaInput));

            NameTextBox.Text                   = _metaInput.Name;
            TypeComboBox.SelectedIndex         = (int)_metaInput.OpPart.Type;
            IsMultiInputComboBox.SelectedIndex = _metaInput.IsMultiInput ? 1 : 0;
            _defaultValue = _metaInput.DefaultValue.Clone();
            RelevanceComboBox.SelectedIndex     = (int)_metaInput.Relevance;
            RelevanceComboBox.SelectionChanged += (o, e) =>
            {
                var entry = new UpdateInputParameterCommand.Entry(_metaInput)
                {
                    Relevance = (MetaInput.RelevanceType)RelevanceComboBox.SelectedIndex
                };
                command = new UpdateInputParameterCommand(_operator, _metaInput.ID, entry);
                App.Current.UndoRedoStack.AddAndExecute(command);
            };
            SetDefaultValue();

            NameTextBox.TextChanged += (sender, args) => command = new UpdateInputParameterCommand(_operator, _metaInput.ID, new UpdateInputParameterCommand.Entry(_metaInput)
            {
                Name = NameTextBox.Text
            });
            NameTextBox.LostFocus += (sender, args) =>
            {
                App.Current.UndoRedoStack.AddAndExecute(command);
                App.Current.UpdateRequiredAfterUserInteraction = true;
            };
            TypeComboBox.SelectionChanged         += TypeComboBox_SelectionChanged;
            IsMultiInputComboBox.SelectionChanged += IsMultiInputComboBox_SelectionChanged;

            bool showFloatParams = (opPart.Type == FunctionType.Float);

            if (showFloatParams)
            {
                Min.Value              = _metaInput.Min;
                Min.ClampToMin         = false;
                Min.ClampToMax         = false;
                Min.ValueChangedEvent += (newVal) => command = new UpdateInputParameterCommand(_operator, _metaInput.ID, new UpdateInputParameterCommand.Entry(_metaInput)
                {
                    Min = newVal
                });
                Min.EditingEndedEvent += () =>
                {
                    App.Current.UndoRedoStack.AddAndExecute(command);
                    App.Current.UpdateRequiredAfterUserInteraction = true;
                };

                Max.Value              = _metaInput.Max;
                Max.ClampToMin         = false;
                Max.ClampToMax         = false;
                Max.ValueChangedEvent += (newVal) => command = new UpdateInputParameterCommand(_operator, _metaInput.ID, new UpdateInputParameterCommand.Entry(_metaInput)
                {
                    Max = newVal
                });
                Max.EditingEndedEvent += () =>
                {
                    App.Current.UndoRedoStack.AddAndExecute(command);
                    App.Current.UpdateRequiredAfterUserInteraction = true;
                };

                Scale.Value              = _metaInput.Scale;
                Scale.ClampToMin         = false;
                Scale.ClampToMax         = false;
                Scale.Min                = 0.001f;
                Scale.Scale              = 0.01f;;
                Scale.ValueChangedEvent += (newVal) => command = new UpdateInputParameterCommand(_operator, _metaInput.ID, new UpdateInputParameterCommand.Entry(_metaInput)
                {
                    Scale = newVal
                });
                Scale.EditingEndedEvent += () =>
                {
                    App.Current.UndoRedoStack.AddAndExecute(command);
                    App.Current.UpdateRequiredAfterUserInteraction = true;
                };

                ScaleTypeComboBox.SelectedIndex     = (int)_metaInput.ScaleType;
                ScaleTypeComboBox.SelectionChanged += (o, e) =>
                {
                    command = new UpdateInputParameterCommand(_operator, _metaInput.ID, new UpdateInputParameterCommand.Entry(_metaInput)
                    {
                        ScaleType = (MetaInput.Scaling)ScaleTypeComboBox.SelectedIndex
                    });
                    App.Current.UndoRedoStack.AddAndExecute(command);
                    App.Current.UpdateRequiredAfterUserInteraction = true;
                };
                SetVisibilityForFloatParams(Visibility.Visible);

                XIsEnumComboBox.SelectedIndex     = _metaInput.EnumValues.Count > 0 ? 1 : 0;
                XIsEnumComboBox.SelectionChanged += XIsEnumComboBox_SelectionChanged;
                BuildEnumEntries();
            }
            else
            {
                SetVisibilityForFloatParams(Visibility.Hidden);
            }

            DescriptionDoc              = new TextDocument(_metaInput.Description);
            DescriptionDoc.TextChanged += HandleDescriptionChange;
            DescriptionEdit.Document    = DescriptionDoc;
            DescriptionEdit.Foreground  = Brushes.Gray;
            DescriptionEdit.Margin      = new Thickness(4, 6, 4, 4);
            DescriptionEdit.MinHeight   = 40;
            DescriptionEdit.FontSize    = 13;
        }