void SetupCombobox() { comboBox.RemoveAll(); var currentItems = Equalizer.Shared.Presets.Select(x => new NSString(x.Name)).ToArray(); comboBox.Add(currentItems); var current = EqualizerManager.Shared.GetCurrent(); comboBox.Select(new NSString(current.Name)); }
public MacToolbarWindow(IInspectDelegate inspectDelegate, CGRect frame) : base(frame, NSWindowStyle.Titled | NSWindowStyle.FullSizeContentView, NSBackingStore.Buffered, false) { this.inspectDelegate = inspectDelegate; //BackgroundColor = NSColor.Clear; IsOpaque = false; TitlebarAppearsTransparent = true; TitleVisibility = NSWindowTitleVisibility.Hidden; ShowsToolbarButton = false; MovableByWindowBackground = false; NSStackView verticalStackView; ContentView = verticalStackView = NativeViewHelper.CreateVerticalStackView(MenuItemSeparation); stackView = NativeViewHelper.CreateHorizontalStackView(MenuItemSeparation); verticalStackView.AddArrangedSubview(stackView); stackView.LeftAnchor.ConstraintEqualToAnchor(verticalStackView.LeftAnchor, 10).Active = true; stackView.RightAnchor.ConstraintEqualToAnchor(verticalStackView.RightAnchor, 10).Active = true; secondStackView = NativeViewHelper.CreateHorizontalStackView(MenuItemSeparation); verticalStackView.AddArrangedSubview(secondStackView); secondStackView.LeftAnchor.ConstraintEqualToAnchor(verticalStackView.LeftAnchor, 10).Active = true; secondStackView.RightAnchor.ConstraintEqualToAnchor(verticalStackView.RightAnchor, 10).Active = true; //Visual issues view var actualImage = (NSImage)inspectDelegate.GetImageResource("overlay-actual.png").NativeObject; var keyViewLoopButton = new ToggleButton() { Image = actualImage }; keyViewLoopButton.ToolTip = "Shows current focused item"; AddButton(keyViewLoopButton); keyViewLoopButton.Activated += (s, e) => { KeyViewLoop?.Invoke(this, keyViewLoopButton.IsToggled); }; var previousImage = (NSImage)inspectDelegate.GetImageResource("overlay-previous.png").NativeObject; var prevKeyViewLoopButton = new ToggleButton() { Image = previousImage }; prevKeyViewLoopButton.ToolTip = "Shows previous view item"; AddButton(prevKeyViewLoopButton); prevKeyViewLoopButton.Activated += (s, e) => { PreviousKeyViewLoop?.Invoke(this, prevKeyViewLoopButton.IsToggled); }; var nextImage = (NSImage)inspectDelegate.GetImageResource("overlay-next.png").NativeObject; var nextKeyViewLoopButton = new ToggleButton() { Image = nextImage }; nextKeyViewLoopButton.ToolTip = "Shows next view item"; AddButton(nextKeyViewLoopButton); nextKeyViewLoopButton.Activated += (s, e) => { NextKeyViewLoop?.Invoke(this, nextKeyViewLoopButton.IsToggled); }; AddSeparator(); var rescanImage = (NSImage)inspectDelegate.GetImageResource("rescan-16.png").NativeObject; toolkitButton = new ToggleButton { Image = rescanImage }; toolkitButton.ToolTip = "Change beetween Toolkits"; AddButton(toolkitButton); toolkitButton.Activated += ToolkitButton_Activated;; rescanSeparator = AddSeparator(); var themeImage = (NSImage)inspectDelegate.GetImageResource("style-16.png").NativeObject; var themeButton = new ToggleButton { Image = themeImage }; themeButton.ToolTip = "Change Style Theme"; AddButton(themeButton); themeButton.Activated += ThemeButton_Activated; AddSeparator(); var deleteImage = (NSImage)inspectDelegate.GetImageResource("delete-16.png").NativeObject; deleteButton = new ImageButton(); deleteButton.Image = deleteImage; deleteButton.ToolTip = "Delete selected item"; AddButton(deleteButton); deleteButton.Activated += (s, e) => { ItemDeleted?.Invoke(this, EventArgs.Empty); }; var changeImg = (NSImage)inspectDelegate.GetImageResource("image-16.png").NativeObject; changeImage = new ImageButton(); changeImage.Image = changeImg; changeImage.ToolTip = "Change image from selected item"; AddButton(changeImage); changeImage.Activated += (s, e) => { ItemImageChanged?.Invoke(this, EventArgs.Empty); }; AddSeparator(); languagesComboBox = new NSComboBox() { TranslatesAutoresizingMaskIntoConstraints = false }; languagesComboBox.ToolTip = "Change font from selected item"; cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures); var culturesStr = new NSString[cultureInfos.Length]; NSString selected = null; for (int i = 0; i < cultureInfos.Length; i++) { culturesStr[i] = new NSString(cultureInfos[i].DisplayName); if (i == 0 || cultureInfos[i] == Thread.CurrentThread.CurrentUICulture) { selected = culturesStr[i]; } } languagesComboBox.Add(culturesStr); stackView.AddArrangedSubview(languagesComboBox); languagesComboBox.Select(selected); languagesComboBox.Activated += LanguagesComboBox_SelectionChanged; languagesComboBox.SelectionChanged += LanguagesComboBox_SelectionChanged; languagesComboBox.WidthAnchor.ConstraintLessThanOrEqualToConstant(220).Active = true; //FONTS fontsCombobox = new NSComboBox() { TranslatesAutoresizingMaskIntoConstraints = false }; fontsCombobox.ToolTip = "Change font from selected item"; fonts = NSFontManager.SharedFontManager.AvailableFonts .Select(s => new NSString(s)) .ToArray(); fontsCombobox.Add(fonts); fontsCombobox.WidthAnchor.ConstraintGreaterThanOrEqualToConstant(220).Active = true; fontSizeTextView = new NSTextField() { TranslatesAutoresizingMaskIntoConstraints = false }; fontSizeTextView.ToolTip = "Change font size from selected item"; fontSizeTextView.WidthAnchor.ConstraintEqualToConstant(40).Active = true; fontsCombobox.SelectionChanged += (s, e) => { OnFontChanged(); }; fontSizeTextView.Activated += (s, e) => { OnFontChanged(); }; endSpace = new NSView() { TranslatesAutoresizingMaskIntoConstraints = false }; //stackView.AddArrangedSubview(new NSView() { TranslatesAutoresizingMaskIntoConstraints = false }); }