public ButtonBar(IEnumerable <IButtonBarButton> buttons) { Cell = new DarkSkinSegmentedCell(); this.buttons = buttons.ToList(); foreach (var button in buttons) { var _button = button; button.ImageChanged += (o, e) => { if (!indexMap.ContainsKey(_button)) { return; } LoadIcon(_button); SetNeedsDisplay(); }; button.EnabledChanged += (o, e) => { if (!indexMap.ContainsKey(_button)) { return; } LoadIcon(_button); SetEnabled(_button.Enabled, indexMap [_button]); SetNeedsDisplay(); }; button.VisibleChanged += (o, e) => RebuildSegments(); button.TooltipChanged += (o, e) => { if (!indexMap.ContainsKey(_button)) { return; } Cell.SetToolTip(_button.Tooltip, indexMap [_button]); }; } Activated += (sender, e) => indexMap.First(b => b.Value == SelectedSegment).Key.NotifyPushed(); RebuildSegments(); SegmentStyle = NSSegmentStyle.TexturedRounded; Cell.TrackingMode = NSSegmentSwitchTracking.Momentary; }
public ButtonBar (IEnumerable<IButtonBarButton> buttons) { Cell = new DarkSkinSegmentedCell (); this.buttons = buttons.ToList (); foreach (var button in buttons) { var _button = button; button.ImageChanged += (o, e) => { if (!indexMap.ContainsKey (_button)) return; LoadIcon (_button); SetNeedsDisplay (); }; button.EnabledChanged += (o, e) => { if (!indexMap.ContainsKey (_button)) return; LoadIcon (_button); SetEnabled (_button.Enabled, indexMap [_button]); SetNeedsDisplay (); }; button.VisibleChanged += (o, e) => RebuildSegments (); button.TooltipChanged += (o, e) => { if (!indexMap.ContainsKey (_button)) return; Cell.SetToolTip (_button.Tooltip, indexMap [_button]); }; } Activated += (sender, e) => indexMap.First (b => b.Value == SelectedSegment).Key.NotifyPushed (); RebuildSegments (); SegmentStyle = NSSegmentStyle.TexturedRounded; Cell.TrackingMode = NSSegmentSwitchTracking.Momentary; }