Beispiel #1
0
        /// <summary>
        /// Creates the default value editor control.
        /// </summary>
        private void CreateDefaultEditor()
        {
            if (_defaultValueEditor != null || Archetype.ValueIndex == -1)
            {
                return;
            }

            var   style  = Style.Current;
            float x      = X + Width + 8 + style.FontSmall.MeasureText(Archetype.Text).X;
            float y      = Y;
            float height = Height;

            switch (CurrentType)
            {
            case ConnectionType.Bool:
            {
                bool value   = BoolValue.Get(ParentNode, Archetype);
                var  control = new CheckBox(x, y, value, height)
                {
                    Parent = Parent
                };
                control.StateChanged += OnCheckBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Integer:
            case ConnectionType.UnsignedInteger:
            {
                int value   = IntegerValue.Get(ParentNode, Archetype);
                var control = new IntValueBox(value, x, y, 40, CurrentType == ConnectionType.UnsignedInteger ? 0 : int.MinValue, int.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnIntValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Float:
            {
                float value   = FloatValue.Get(ParentNode, Archetype);
                var   control = new FloatValueBox(value, x, y, 40, float.MinValue, float.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnFloatValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Vector2:
            {
                Vector2 value   = GetValueVector2(ParentNode, Archetype);
                var     control = new ContainerControl(x, y, 22 * 2 - 2, height)
                {
                    ClipChildren = false,
                    AutoFocus    = false,
                    Parent       = Parent
                };
                var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatX.ValueChanged += OnVector2ValueChanged;
                var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatY.ValueChanged += OnVector2ValueChanged;
                _defaultValueEditor  = control;
                break;
            }

            case ConnectionType.Vector3:
            {
                Vector3 value   = GetValueVector3(ParentNode, Archetype);
                var     control = new ContainerControl(x, y, 22 * 3 - 2, height)
                {
                    ClipChildren = false,
                    AutoFocus    = false,
                    Parent       = Parent
                };
                var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatX.ValueChanged += OnVector3ValueChanged;
                var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatY.ValueChanged += OnVector3ValueChanged;
                var floatZ = new FloatValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatZ.ValueChanged += OnVector3ValueChanged;
                _defaultValueEditor  = control;
                break;
            }

            case ConnectionType.Vector4:
            {
                Vector4 value   = GetValueVector4(ParentNode, Archetype);
                var     control = new ContainerControl(x, y, 22 * 4 - 2, height)
                {
                    ClipChildren = false,
                    AutoFocus    = false,
                    Parent       = Parent
                };
                var floatX = new FloatValueBox(value.X, 0, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatX.ValueChanged += OnVector4ValueChanged;
                var floatY = new FloatValueBox(value.Y, 22, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatY.ValueChanged += OnVector4ValueChanged;
                var floatZ = new FloatValueBox(value.Z, 44, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatZ.ValueChanged += OnVector4ValueChanged;
                var floatW = new FloatValueBox(value.W, 66, 0, 20, float.MinValue, float.MaxValue, 0.0f)
                {
                    Height = height,
                    Parent = control
                };
                floatW.ValueChanged += OnVector4ValueChanged;
                _defaultValueEditor  = control;
                break;
            }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates the default value editor control.
        /// </summary>
        private void CreateDefaultEditor()
        {
            if (_defaultValueEditor != null || Archetype.ValueIndex == -1)
            {
                return;
            }

            var   style  = Style.Current;
            float x      = X + Width + 8 + style.FontSmall.MeasureText(Archetype.Text).X;
            float y      = Y;
            float height = Height;

            switch (CurrentType)
            {
            case ConnectionType.Bool:
            {
                bool value   = BoolValue.Get(ParentNode, Archetype);
                var  control = new CheckBox(x, y, value, height)
                {
                    Parent = Parent
                };
                control.StateChanged += OnCheckBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Integer:
            {
                int value   = IntegerValue.Get(ParentNode, Archetype);
                var control = new IntValueBox(value, x, y, 40, int.MinValue, int.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnIntValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Float:
            {
                float value   = FloatValue.Get(ParentNode, Archetype);
                var   control = new FloatValueBox(value, x, y, 40, float.MinValue, float.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnFloatValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }

            case ConnectionType.Vector2:
            case ConnectionType.Vector3:
            case ConnectionType.Vector4:
            case ConnectionType.Vector:
            {
                float value   = FloatValue.Get(ParentNode, Archetype);
                var   control = new FloatValueBox(value, x, y, 40, float.MinValue, float.MaxValue, 0.01f)
                {
                    Height = height,
                    Parent = Parent
                };
                control.ValueChanged += OnVectorValueBoxChanged;
                _defaultValueEditor   = control;
                break;
            }
            }
        }
Beispiel #3
0
        private void OnNodeValuesChanged()
        {
            if (_defaultValueEditor == null)
            {
                return;
            }

            switch (CurrentType)
            {
            case ConnectionType.Bool:
                if (_defaultValueEditor is CheckBox checkBox)
                {
                    checkBox.Checked = BoolValue.Get(ParentNode, Archetype);
                }
                break;

            case ConnectionType.Integer:
            case ConnectionType.UnsignedInteger:
                if (_defaultValueEditor is IntValueBox intValue)
                {
                    intValue.Value = IntegerValue.Get(ParentNode, Archetype);
                }
                break;

            case ConnectionType.Float:
                if (_defaultValueEditor is FloatValueBox floatValue)
                {
                    floatValue.Value = FloatValue.Get(ParentNode, Archetype);
                }
                break;

            case ConnectionType.Vector2:
            {
                if (_defaultValueEditor is ContainerControl vec2 &&
                    vec2.ChildrenCount == 2 &&
                    vec2.Children[0] is FloatValueBox x &&
                    vec2.Children[1] is FloatValueBox y)
                {
                    Vector2 value = GetValueVector2(ParentNode, Archetype);
                    x.Value = value.X;
                    y.Value = value.Y;
                }
                break;
            }

            case ConnectionType.Vector3:
            {
                if (_defaultValueEditor is ContainerControl vec3 &&
                    vec3.ChildrenCount == 3 &&
                    vec3.Children[0] is FloatValueBox x &&
                    vec3.Children[1] is FloatValueBox y &&
                    vec3.Children[2] is FloatValueBox z)
                {
                    Vector3 value = GetValueVector3(ParentNode, Archetype);
                    x.Value = value.X;
                    y.Value = value.Y;
                    z.Value = value.Z;
                }
                break;
            }

            case ConnectionType.Vector4:
            {
                if (_defaultValueEditor is ContainerControl vec4 &&
                    vec4.ChildrenCount == 4 &&
                    vec4.Children[0] is FloatValueBox x &&
                    vec4.Children[1] is FloatValueBox y &&
                    vec4.Children[2] is FloatValueBox z &&
                    vec4.Children[3] is FloatValueBox w)
                {
                    Vector4 value = GetValueVector4(ParentNode, Archetype);
                    x.Value = value.X;
                    y.Value = value.Y;
                    z.Value = value.Z;
                    w.Value = value.W;
                }
                break;
            }
            }
        }