Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextEditingElement&lt;CONTROLTYPE&gt;"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="control">The control.</param>
        protected TextEditingElement([NotNull] IPropertyAccessor property,
                                     [NotNull] CONTROLTYPE control)
            : base(property, control)
        {
            SetupEvents(control);

            if (CoercionUtility.IsNumeric(property.PropertyType))
            {
                SetRightAligned(control);
            }

            if (property.PropertyType == typeof(string))
            {
                int?length = MaximumStringLengthAttribute.GetLength(
                    property.InnerProperty);

                if (length.HasValue)
                {
                    SetMaximumLength(length.Value);
                }
            }

            _coercion = delegate(IPropertyAccessor accessor, string rawValue)
            {
                // default coercion
                return(CoercionUtility.Coerce(accessor, rawValue));
            };

            _format = delegate(object o) { return(o.ToString()); };
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TextEditingElement&lt;CONTROLTYPE&gt;"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="control">The control.</param>
        public KeyboardShortcutTextboxElement(IPropertyAccessor property,
                                              KeyboardShortcutTextbox control)
            : base(property, control)
        {
            WireEvents(control);

            // default coercion
            _coercion = (accessor, rawValue) => rawValue;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BooleanComboboxElement"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="control">The control.</param>
        public NullableBooleanComboboxElement([NotNull] IPropertyAccessor property,
                                              [NotNull] NullableBooleanCombobox control)
            : base(property, control)
        {
            WireEvents(control);

            // default coercion
            _coercion = (accessor, rawValue) => CoercionUtility.Coerce(accessor, rawValue);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BooleanComboboxElement"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="control">The control.</param>
        public BooleanComboboxElement([NotNull] IPropertyAccessor property,
                                      [NotNull] BooleanCombobox control)
            : base(property, control)
        {
            WireEvents(control);

            _coercion = delegate(IPropertyAccessor accessor, bool rawValue)
            {
                // default coercion
                return(CoercionUtility.Coerce(accessor, rawValue));
            };
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TextEditingElement&lt;CONTROLTYPE&gt;"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="control">The control.</param>
        public NumericUpDownElement([NotNull] IPropertyAccessor property,
                                    [NotNull] NumericUpDown control)
            : base(property, control)
        {
            WireEvents(control);

            object maxValue = LessThanOrEqualAttribute.GetMaximumValue(property.InnerProperty);

            if (maxValue != null)
            {
                // TODO control.Maximum = (decimal) maxValue;
            }

            _coercion = delegate(IPropertyAccessor accessor, decimal rawValue)
            {
                // default coercion
                return(CoercionUtility.Coerce(accessor, rawValue));
            };
        }