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(); }
protected BasePointEditorControl(IHostResourceProvider hostResources) : base(hostResources) { XLabel = new UnfocusableTextField { Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize), TranslatesAutoresizingMaskIntoConstraints = false, }; XEditor = new NumericSpinEditor <T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; XEditor.ProxyResponder = new ProxyResponder(this, ProxyRowType.FirstView); XEditor.ValueChanged += OnInputUpdated; YLabel = new UnfocusableTextField { Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize), TranslatesAutoresizingMaskIntoConstraints = false, }; YEditor = new NumericSpinEditor <T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; YEditor.ProxyResponder = new ProxyResponder(this, ProxyRowType.LastView); YEditor.ValueChanged += OnInputUpdated; AddSubview(XLabel); AddSubview(XEditor); AddSubview(YLabel); AddSubview(YEditor); const float editorHeight = 18; this.AddConstraints(new[] { NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 3f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, YEditor, NSLayoutAttribute.Left, 1f, -10f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, editorHeight), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, XEditor, NSLayoutAttribute.Bottom, 1f, -4f), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, editorHeight), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 3f), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, XEditor, NSLayoutAttribute.Width, 1f, 0f), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, editorHeight), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, XLabel, NSLayoutAttribute.Top, 1f, 0f), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, editorHeight), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, XEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, YEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), }); AppearanceChanged(); }
public NumericEditorControl(IHostResourceProvider hostResources) : base(hostResources) { base.TranslatesAutoresizingMaskIntoConstraints = false; NumericEditor = new NumericSpinEditor <T> (hostResources) { ProxyResponder = new ProxyResponder(this, ProxyRowType.SingleView) }; NumericEditor.ValueChanged += OnValueChanged; var t = typeof(T); if (t.Name == PropertyViewModel <T> .NullableName) { this.underlyingType = Nullable.GetUnderlyingType(t); t = this.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.editorRightConstraint = NSLayoutConstraint.Create(NumericEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0); this.AddConstraints(new[] { NSLayoutConstraint.Create(NumericEditor, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0), NSLayoutConstraint.Create(NumericEditor, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1, 0), this.editorRightConstraint, NSLayoutConstraint.Create(NumericEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, -6), }); }
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), }); }
internal static void SetFormatter(this NumericSpinEditor control, NSFormatter formatter) { IntPtr pointer = formatter != null ? formatter.Handle : IntPtr.Zero; void_objc_msgSend_intptr(control.NumericEditor.Handle, selSetFormatter_Handle, pointer); }
protected BaseRectangleEditorControl(IHostResourceProvider hostResources) : base(hostResources) { XLabel = new UnfocusableTextField { Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize), TranslatesAutoresizingMaskIntoConstraints = false, }; XEditor = new NumericSpinEditor <T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; XEditor.ValueChanged += OnInputUpdated; YLabel = new UnfocusableTextField { Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize), TranslatesAutoresizingMaskIntoConstraints = false, }; YEditor = new NumericSpinEditor <T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; YEditor.ValueChanged += OnInputUpdated; WidthLabel = new UnfocusableTextField { Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize), TranslatesAutoresizingMaskIntoConstraints = false, }; WidthEditor = new NumericSpinEditor <T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; WidthEditor.ValueChanged += OnInputUpdated; HeightLabel = new UnfocusableTextField { Font = NSFont.FromFontName(DefaultFontName, DefaultDescriptionLabelFontSize), TranslatesAutoresizingMaskIntoConstraints = false, }; HeightEditor = new NumericSpinEditor <T> (hostResources) { BackgroundColor = NSColor.Clear, Value = 0.0f }; HeightEditor.ValueChanged += OnInputUpdated; AddSubview(XLabel); AddSubview(XEditor); AddSubview(YLabel); AddSubview(YEditor); AddSubview(WidthLabel); AddSubview(WidthEditor); AddSubview(HeightLabel); AddSubview(HeightEditor); this.AddConstraints(new[] { NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 3f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, YEditor, NSLayoutAttribute.Left, 1f, -10f), NSLayoutConstraint.Create(XEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, XEditor, NSLayoutAttribute.Bottom, 1f, -4f), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 3f), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, XEditor, NSLayoutAttribute.Width, 1f, 0f), NSLayoutConstraint.Create(YEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, XLabel, NSLayoutAttribute.Top, 1f, 0f), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), NSLayoutConstraint.Create(WidthEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1f, 33f), NSLayoutConstraint.Create(WidthEditor, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1f, 0f), NSLayoutConstraint.Create(WidthEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, HeightEditor, NSLayoutAttribute.Left, 1f, -10f), NSLayoutConstraint.Create(WidthEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), NSLayoutConstraint.Create(WidthLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, WidthEditor, NSLayoutAttribute.Bottom, 1f, -4f), NSLayoutConstraint.Create(WidthLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), NSLayoutConstraint.Create(HeightEditor, NSLayoutAttribute.Top, NSLayoutRelation.Equal, WidthEditor, NSLayoutAttribute.Top, 1f, 0f), NSLayoutConstraint.Create(HeightEditor, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0), NSLayoutConstraint.Create(HeightEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, WidthEditor, NSLayoutAttribute.Width, 1f, 0f), NSLayoutConstraint.Create(HeightEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), NSLayoutConstraint.Create(HeightLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, WidthLabel, NSLayoutAttribute.Top, 1f, 0f), NSLayoutConstraint.Create(HeightLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 18), NSLayoutConstraint.Create(XLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, XEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), NSLayoutConstraint.Create(YLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, YEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), NSLayoutConstraint.Create(WidthLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, WidthEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), NSLayoutConstraint.Create(HeightLabel, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, HeightEditor.Subviews[0], NSLayoutAttribute.CenterX, 1f, 0), }); ViewDidChangeEffectiveAppearance(); }