Beispiel #1
0
        public BasePointEditorControl()
        {
            XLabel = new UnfocusableTextField();

            XEditor = new NumericSpinEditor <T> ();
            XEditor.BackgroundColor = NSColor.Clear;
            XEditor.Value           = 0.0f;
            XEditor.ValueChanged   += OnInputUpdated;

            YLabel = new UnfocusableTextField();

            YEditor = new NumericSpinEditor <T> ();
            YEditor.BackgroundColor = NSColor.Clear;
            YEditor.Value           = 0.0f;
            YEditor.ValueChanged   += OnInputUpdated;

            AddSubview(XLabel);
            AddSubview(XEditor);
            AddSubview(YLabel);
            AddSubview(YEditor);

            this.DoConstraints(new[] {
                XEditor.ConstraintTo(this, (xe, c) => xe.Width == 90),
                XEditor.ConstraintTo(this, (xe, c) => xe.Height == DefaultControlHeight),
                YEditor.ConstraintTo(this, (ye, c) => ye.Width == 90),
                YEditor.ConstraintTo(this, (ye, c) => ye.Height == DefaultControlHeight),
            });

            UpdateTheme();
        }
        public NumericEditorControl()
        {
            base.TranslatesAutoresizingMaskIntoConstraints = false;

            NumericEditor = new NumericSpinEditor <T> ();
            NumericEditor.ValueChanged += OnValueChanged;

            var t = typeof(T);

            if (t.Name == PropertyViewModel <T> .NullableName)
            {
                underlyingType = Nullable.GetUnderlyingType(t);
                t = underlyingType;
            }
            TypeCode code = Type.GetTypeCode(t);

            switch (code)
            {
            case TypeCode.Double:
            case TypeCode.Single:
            case TypeCode.Decimal:
                NumberStyle = NSNumberFormatterStyle.Decimal;
                Formatter.UsesGroupingSeparator = false;
                Formatter.MaximumFractionDigits = 15;
                break;

            default:
                NumberStyle = NSNumberFormatterStyle.None;
                break;
            }

            AddSubview(NumericEditor);

            this.DoConstraints(new[] {
                NumericEditor.ConstraintTo(this, (n, c) => n.Top == c.Top + 1),
                NumericEditor.ConstraintTo(this, (n, c) => n.Left == c.Left + 4),
                NumericEditor.ConstraintTo(this, (n, c) => n.Width == c.Width - 33),
            });
        }