Ejemplo n.º 1
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method</summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services</param>
        /// <param name="value">The object to edit</param>
        /// <returns>The new value of the object. If the value of the object has not changed, this should return the same object it was passed.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService =
                provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;

            if (editorService != null)
            {
                if (!(value is float))
                {
                    value = m_min;
                }

                FloatInputControl floatInputControl = new FloatInputControl((float)value, m_min, m_max);
                editorService.DropDownControl(floatInputControl);
                // be careful to return the same object if the value didn't change
                if (!floatInputControl.Value.Equals(value))
                {
                    value = floatInputControl.Value;
                }
            }

            return(value);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Edits the specified object's value using the editor style indicated by the <see cref="M:System.Drawing.Design.UITypeEditor.GetEditStyle"></see> method</summary>
        /// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext"></see> that can be used to gain additional context information</param>
        /// <param name="provider">An <see cref="T:System.IServiceProvider"></see> that this editor can use to obtain services</param>
        /// <param name="value">The object to edit</param>
        /// <returns>The new value of the object. If the value of the object has not changed, this should return the same object it was passed.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService editorService =
                provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
            if (editorService != null)
            {
                if (!(value is float))
                    value = m_min;

                FloatInputControl floatInputControl = new FloatInputControl((float)value, m_min, m_max);
                editorService.DropDownControl(floatInputControl);
                // be careful to return the same object if the value didn't change
                if (!floatInputControl.Value.Equals(value))
                    value = floatInputControl.Value;
            }

            return value;
        }