示例#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);
        }
示例#3
0
        private void SetDefaultValue()
        {
            DefaultValue.Children.Clear();

            if (TypeComboBox.SelectedIndex == (int)FunctionType.Float)
            {
                float value        = 0.0f;
                var   currentFloat = _defaultValue as Float;
                if (currentFloat != null)
                {
                    value = currentFloat.Val;
                }
                _defaultValue = new Float(value);
                var edit = new FloatEditButton()
                {
                    Value = value
                };
                edit.Scale   = _metaInput.Scale;
                edit.Min     = _metaInput.Min;
                edit.Max     = _metaInput.Max;
                edit.Default = value;
                var command = new UpdateInputParameterCommand(_operator, _metaInput.ID, new UpdateInputParameterCommand.Entry(_metaInput));
                edit.ValueChangedEvent += (v) =>
                {
                    _defaultValue = new Float(v);
                    command.ChangeEntry.DefaultValue = _defaultValue;
                };
                edit.EditingEndedEvent += () =>
                {
                    App.Current.UndoRedoStack.AddAndExecute(command);
                    App.Current.UpdateRequiredAfterUserInteraction = true;
                };
                DefaultValue.Children.Add(edit);
            }
            else if (TypeComboBox.SelectedIndex == (int)FunctionType.Text)
            {
                var value       = String.Empty;
                var currentText = _defaultValue as Text;
                if (currentText != null)
                {
                    value = currentText.Val;
                }
                var edit = new TextBox();
                edit.Text     = value;
                _defaultValue = new Text(value);
                var command = new UpdateInputParameterCommand(_operator, _metaInput.ID, new UpdateInputParameterCommand.Entry(_metaInput));
                edit.TextChanged += (o, e) =>
                {
                    _defaultValue = new Text(edit.Text);
                    command.ChangeEntry.DefaultValue = _defaultValue;
                };
                edit.LostFocus += delegate
                {
                    App.Current.UndoRedoStack.AddAndExecute(command);
                    App.Current.UpdateRequiredAfterUserInteraction = true;
                };
                DefaultValue.Children.Add(edit);
            }
            else if (TypeComboBox.SelectedIndex == (int)FunctionType.Scene)
            {
                _defaultValue = new Core.Scene();
            }
            else if (TypeComboBox.SelectedIndex == (int)FunctionType.Generic)
            {
                _defaultValue = new Core.Generic();
            }
            else if (TypeComboBox.SelectedIndex == (int)FunctionType.Dynamic)
            {
                _defaultValue = new Core.Dynamic();
            }
            else if (TypeComboBox.SelectedIndex == (int)FunctionType.Mesh)
            {
                _defaultValue = new Core.MeshValue();
            }
        }
示例#4
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;
        }