Beispiel #1
0
            /// <inheritdoc />
            public override void OnSurfaceLoaded()
            {
                base.OnSurfaceLoaded();

                var   upperLeft      = GetBox(0).BottomLeft;
                var   upperRight     = GetBox(1).BottomRight;
                float gradientMargin = 20.0f;

                _gradient = new Gradient
                {
                    Node   = this,
                    Bounds = new Rectangle(upperLeft + new Vector2(gradientMargin, 10.0f), upperRight.X - upperLeft.X - gradientMargin * 2.0f, 40.0f),
                    Parent = this,
                };

                var controlsLevel = _gradient.Bottom + 4.0f + 20.0f + 40.0f;

                _labelValue = new Label(_gradient.Left, controlsLevel - 20.0f, 70.0f, 20.0f)
                {
                    Text = "Selected:",
                    VerticalAlignment   = TextAlignment.Center,
                    HorizontalAlignment = TextAlignment.Near,
                    Parent = this
                };

                _timeValue = new FloatValueBox(0.0f, _gradient.Left, controlsLevel, 100.0f, 0.0f, 1.0f, 0.001f)
                {
                    Parent = this
                };
                _timeValue.ValueChanged += OnTimeValueChanged;

                _colorValue = new ColorValueBox(Color.Black, _timeValue.Right + 4.0f, controlsLevel)
                {
                    Height = _timeValue.Height,
                    Parent = this
                };
                _colorValue.ValueChanged += OnColorValueChanged;

                _removeButton = new Button(_colorValue.Right + 4.0f, controlsLevel, 20, 20)
                {
                    Text        = "-",
                    TooltipText = "Remove selected gradient stop",
                    Parent      = this
                };
                _removeButton.Clicked += OnRemoveButtonClicked;

                _addButton = new Button(_gradient.Right - 20.0f, controlsLevel, 20, 20)
                {
                    Text        = "+",
                    TooltipText = "Add gradient stop",
                    Parent      = this
                };
                _addButton.Clicked += OnAddButtonClicked;

                UpdateStops();
            }
Beispiel #2
0
        public Control Create(InputBox box, ref Rectangle bounds)
        {
            var value   = GetValue(box);
            var control = new ColorValueBox(value, bounds.X, bounds.Y)
            {
                Height = bounds.Height,
                Parent = box.Parent,
                Tag    = box,
            };

            control.ColorValueChanged += OnColorValueChanged;
            return(control);
        }
Beispiel #3
0
        private void OnColorValueChanged(ColorValueBox control)
        {
            var box = (InputBox)control.Tag;

            box.Value = control.Value;
        }
Beispiel #4
0
        private void OnColorValueChanged(ColorValueBox control)
        {
            var box = (InputBox)control.Tag;

            box.ParentNode.SetValue(box.Archetype.ValueIndex, control.Value);
        }