/// <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 = (bool)ParentNode.Values[Archetype.ValueIndex]; 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; } } }
public Control Create(InputBox box, ref Rectangle bounds) { var value = IntegerValue.Get(box.ParentNode, box.Archetype, box.Value); var control = new IntValueBox(value, bounds.X, bounds.Y, 40, int.MinValue, int.MaxValue, 0.01f) { Height = bounds.Height, Parent = box.Parent, Tag = box, }; control.BoxValueChanged += OnIntValueBoxChanged; return(control); }
/// <summary> /// Initializes a new instance of the <see cref="IntegerValueElement"/> class. /// </summary> public IntegerValueElement() { IntValue = new IntValueBox(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; } } }