public RatioEditorControl(IHostResourceProvider hostResources) : base(hostResources) { base.TranslatesAutoresizingMaskIntoConstraints = false; this.ratioEditor = new RatioEditor <T> (hostResources) { AllowNegativeValues = false, AllowRatios = true, BackgroundColor = NSColor.Clear, StringValue = string.Empty, TranslatesAutoresizingMaskIntoConstraints = false, }; // update the value on keypress this.ratioEditor.ValueChanged += (sender, e) => { if (e is RatioEditor <T> .RatioEventArgs ratioEventArgs) { ViewModel.ValueChanged(this.ratioEditor.StringValue, ratioEventArgs.CaretPosition, ratioEventArgs.SelectionLength, ratioEventArgs.IncrementValue); } }; AddSubview(this.ratioEditor); this.AddConstraints(new[] { NSLayoutConstraint.Create(this.ratioEditor, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0), NSLayoutConstraint.Create(this.ratioEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, 0), NSLayoutConstraint.Create(this.ratioEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, -6), }); }
public RatioEditorControl(IHostResourceProvider hostResources) : base(hostResources) { base.TranslatesAutoresizingMaskIntoConstraints = false; this.ratioEditor = new RatioEditor <T> (hostResources); this.ratioEditor.ProxyResponder = new ProxyResponder(this, ProxyRowType.SingleView); this.ratioEditor.SetFormatter(null); // update the value on keypress this.ratioEditor.ValueChanged += (sender, e) => { if (e is RatioEditor <T> .RatioEventArgs ratioEventArgs) { ViewModel.ValueChanged(this.ratioEditor.StringValue, ratioEventArgs.CaretPosition, ratioEventArgs.SelectionLength, ratioEventArgs.IncrementValue); } }; AddSubview(this.ratioEditor); this.AddConstraints(new[] { NSLayoutConstraint.Create(this.ratioEditor, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1f, 0), NSLayoutConstraint.Create(this.ratioEditor, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, 0), NSLayoutConstraint.Create(this.ratioEditor, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1, -6), }); }