Пример #1
0
        /// <summary> Opens the string editor. </summary>
        /// <returns></returns>
        protected override IQOpResult <int> OpenEditor(int defaultValue, IQVarElementTarget target)
        {
            var editor = new IntegerValueEditor
            {
                //If a single select custom value is set, load that value.
                Value    = defaultValue,
                MinValue = MinValue,
                MaxValue = MaxValue
            };

            return((editor.ShowDialog() == DialogResult.OK)
                       ? new IQOpResult <int> {
                Result = OpResultEnum.Completed, Value = editor.Value
            }
                       : new IQOpResult <int> {
                Result = OpResultEnum.Cancelled
            });
        }
Пример #2
0
        public override IPropertyValueEditor CreateEditor(System.ComponentModel.PropertyDescriptor propertyDescriptor, object targetObject)
        {
            if (propertyDescriptor.PropertyType != typeof(int) && propertyDescriptor.PropertyType != typeof(int?) &&
                propertyDescriptor.PropertyType != typeof(byte) && propertyDescriptor.PropertyType != typeof(byte?))
                throw new InvalidOperationException("PropertyIntegerEditor works only with int or byte type properties");

            IntegerValueEditor editor = new IntegerValueEditor();
            editor.AutoBorderSize = 1;

            if (!string.IsNullOrEmpty(DisplayFormat))
            {
                editor.DisplayFormat = DisplayFormat;
            }
            editor.ShowUpDown = ShowUpDownButton;
            editor.Height = 14;
            editor.BackgroundStyle.Class = "";
            editor.BackgroundStyle.BackColor = Color.White;
            editor.AllowEmptyState = this.AllowEmptyState;
            if (propertyDescriptor.PropertyType == typeof(byte) || propertyDescriptor.PropertyType == typeof(byte?))
            {
                editor.MinValue = Math.Max(byte.MinValue, MinValue);
                editor.MaxValue = Math.Min(byte.MaxValue, MaxValue);
            }
            else
            {
                editor.MinValue = MinValue;
                editor.MaxValue = MaxValue;
            }

            return editor;
        }