public BooleanEditorControl() { BooleanEditor = new NSButton { AllowsMixedState = true, ControlSize = NSControlSize.Small, Font = NSFont.FromFontName(DefaultFontName, DefaultFontSize), Title = string.Empty, TranslatesAutoresizingMaskIntoConstraints = false, }; BooleanEditor.SetButtonType(NSButtonType.Switch); // update the value on 'enter' BooleanEditor.Activated += (sender, e) => { switch (BooleanEditor.State) { case NSCellStateValue.Off: ViewModel.Value = false; break; case NSCellStateValue.On: ViewModel.Value = true; break; } }; AddSubview(BooleanEditor); this.DoConstraints(new[] { BooleanEditor.ConstraintTo(this, (cb, c) => cb.Width == c.Width), BooleanEditor.ConstraintTo(this, (cb, c) => cb.Top == c.Top + 5), BooleanEditor.ConstraintTo(this, (cb, c) => cb.Left == c.Left + 4), }); UpdateTheme(); }
public BaseEditorControl() { propertyButton = new NSButton { Bordered = false, Enabled = false, AlternateImage = NSImage.ImageNamed("property-button-default-mac-active-10"), Cell = { HighlightsBy = 1, }, ImageScaling = NSImageScale.AxesIndependently, Title = string.Empty, TranslatesAutoresizingMaskIntoConstraints = false, }; #if DESIGNER_DEBUG propertyButton.Image = NSImage.ImageNamed("property-button-default-mac-10"); #endif propertyButton.Activated += (object sender, EventArgs e) => { NotifyPropertyButtonClicked(); }; AddSubview(propertyButton); actionButton = new NSButton { Bordered = false, Enabled = false, ImageScaling = NSImageScale.AxesIndependently, Title = string.Empty, TranslatesAutoresizingMaskIntoConstraints = false, }; #if DESIGNER_DEBUG actionButton.Image = NSImage.ImageNamed("action-warning-16"); #endif actionButton.Activated += (object sender, EventArgs e) => { if (errorList != null) { var Container = new ErrorMessageView(errorList) { Frame = new CGRect(CGPoint.Empty, new CGSize(320, 200)) }; var errorMessagePopUp = new NSPopover { Behavior = NSPopoverBehavior.Semitransient, ContentViewController = new NSViewController(null, null) { View = Container }, }; errorMessagePopUp.Show(default(CGRect), actionButton, NSRectEdge.MinYEdge); } NotifyActioButtonClicked(); }; AddSubview(actionButton); this.DoConstraints(new[] { propertyButton.ConstraintTo(this, (ab, c) => ab.Width == DefaultPropertyButtonSize), propertyButton.ConstraintTo(this, (ab, c) => ab.Height == DefaultPropertyButtonSize), propertyButton.ConstraintTo(this, (ab, c) => ab.Top == c.Top + 6), // TODO: Better centering based on the icon height propertyButton.ConstraintTo(this, (ab, c) => ab.Left == c.Right - 28), actionButton.ConstraintTo(this, (eb, c) => eb.Width == DefaultActioButtonSize), actionButton.ConstraintTo(this, (eb, c) => eb.Height == DefaultActioButtonSize), actionButton.ConstraintTo(propertyButton, (eb, ab) => eb.Left == ab.Left + 10), actionButton.ConstraintTo(this, (eb, c) => eb.Top == c.Top + 3), // TODO: Better centering based on the icon height }); PropertyEditorPanel.ThemeManager.ThemeChanged += ThemeManager_ThemeChanged; }