示例#1
0
        /// <inheritdoc />
        public override void Initialize(LayoutElementsContainer layout)
        {
            element = null;

            // Try get limit attribute for value min/max range setting and slider speed
            if (Values.Info != null)
            {
                var attributes = Values.Info.GetCustomAttributes(true);
                var range      = attributes.FirstOrDefault(x => x is RangeAttribute);
                if (range != null)
                {
                    // Use slider
                    var slider = layout.Slider();
                    slider.SetLimits((RangeAttribute)range);
                    slider.Slider.ValueChanged += () => SetValue(element.Value);
                    element = slider;
                }
                var limit = attributes.FirstOrDefault(x => x is LimitAttribute);
                if (limit != null)
                {
                    // Use float value editor with limit
                    var floatValue = layout.FloatValue();
                    floatValue.SetLimits((LimitAttribute)limit);
                    floatValue.FloatValue.ValueChanged += () => SetValue(element.Value);
                    element = floatValue;
                }
            }
            if (element == null)
            {
                // Use float value editor
                var floatValue = layout.FloatValue();
                floatValue.FloatValue.ValueChanged += () => SetValue(element.Value);
                element = floatValue;
            }
        }
示例#2
0
        /// <inheritdoc />
        public override void Initialize(LayoutElementsContainer layout)
        {
            _element = null;

            // Try get limit attribute for value min/max range setting and slider speed
            var attributes = Values.GetAttributes();

            if (attributes != null)
            {
                var range = attributes.FirstOrDefault(x => x is RangeAttribute);
                if (range != null)
                {
                    // Use slider
                    var slider = layout.Slider();
                    slider.SetLimits((RangeAttribute)range);
                    slider.Slider.ValueChanged += OnValueChanged;
                    slider.Slider.SlidingEnd   += ClearToken;
                    _element = slider;
                    return;
                }
                var limit = attributes.FirstOrDefault(x => x is LimitAttribute);
                if (limit != null)
                {
                    // Use float value editor with limit
                    var floatValue = layout.FloatValue();
                    floatValue.SetLimits((LimitAttribute)limit);
                    floatValue.FloatValue.ValueChanged += OnValueChanged;
                    floatValue.FloatValue.SlidingEnd   += ClearToken;
                    _element = floatValue;
                    return;
                }
            }
            if (_element == null)
            {
                // Use float value editor
                var floatValue = layout.FloatValue();
                floatValue.FloatValue.ValueChanged += OnValueChanged;
                floatValue.FloatValue.SlidingEnd   += ClearToken;
                _element = floatValue;
            }
        }