Esempio n. 1
0
        public ButtonBar(IEnumerable <IButtonBarButton> buttons)
        {
            Cell = new DarkThemeSegmentedCell(this);

            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]);
                };
                button.TitleChanged += (o, e) => {
                    if (!indexMap.ContainsKey(_button))
                    {
                        return;
                    }
                    SetLabel(_button.Title, indexMap [_button]);
                };
            }
            Activated += (sender, e) => {
                foreach (var item in indexMap.ToArray())
                {
                    if (item.Value == SelectedSegment)
                    {
                        item.Key.NotifyPushed();
                    }
                }
            };

            RebuildSegments();
            SegmentStyle      = NSSegmentStyle.TexturedRounded;
            Cell.TrackingMode = NSSegmentSwitchTracking.Momentary;
        }
Esempio n. 2
0
		public ButtonBar (IEnumerable<IButtonBarButton> buttons)
		{
			Cell = new DarkThemeSegmentedCell ();

			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;
		}