public MacFlyoutMenu(NSButtonPlus button, NSGridView menu, NSBox menuBox, NSBox buttonBar, FlyoutAttachment attachment, float pointSize, bool fixedWidth, CGSize padding, NSColor nsMainButtonText, NSColor nsMainButtonDeselected, NSColor nsMainButtonSelected, NSColor nsMenuButtonText, NSColor nsMenuButtonDeselected, NSColor nsMenuButtonSelected) : base(button, nsMainButtonText, nsMainButtonDeselected, nsMainButtonSelected) { this.menu = menu; this.namedControls = new Dictionary <string, KButton>(); this.menu.RowSpacing = 1; this.menu.ColumnSpacing = 6; this.menuBox = menuBox; this.menuBox.BorderWidth = 1; // does not affect the origin this.menuBox.CornerRadius = 0; this.menuBox.BorderColor = NSColor.TertiaryLabelColor; this.buttonBar = buttonBar; this.autoClose = false; this.pointSize = pointSize; this.fixedWidth = fixedWidth; this.padding = padding; this.attachment = attachment; this.nsMenuButtonText = nsMenuButtonText; this.nsMenuButtonDeselected = nsMenuButtonDeselected; this.nsMenuButtonSelected = nsMenuButtonSelected; menuBox.FillColor = nsMenuButtonDeselected; menuBox.Hidden = true; MacControls.allMacFlyoutMenus.Add(this); }
public override IViewWrapper ConvertTo(FigmaNode currentNode, ProcessedNode parent) { var textField = new NSGridView(); textField.Configure(currentNode); return(new ViewWrapper(textField)); }
public void CreateWithNSViewArrayOfArrayCheckDifferentArrayLength() { NSView [][] nSViewsArrayOfArray = new NSView [2][]; nSViewsArrayOfArray [0] = new NSView [1] { new NSTextView() { Value = "0" } }; nSViewsArrayOfArray [1] = new NSView [2] { new NSTextView() { Value = "1" }, new NSTextView() { Value = "1bis" } }; NSGridView nSGridViewArrayOfArray = NSGridView.Create(nSViewsArrayOfArray); Assert.NotNull(nSGridViewArrayOfArray); Assert.AreEqual("0", ((NSTextView)(nSGridViewArrayOfArray.GetCell(0, 0)).ContentView).Value, "0,0"); Assert.AreEqual("1", ((NSTextView)(nSGridViewArrayOfArray.GetCell(0, 1)).ContentView).Value, "0,1"); Assert.AreEqual("1bis", ((NSTextView)(nSGridViewArrayOfArray.GetCell(1, 1)).ContentView).Value, "0,2"); }
public void CreateWithTwoDimensionalNSViewArrayNSTextView() { NSView [,] nSViewsTwoDim = new NSView [2, 2]; nSViewsTwoDim [0, 0] = new NSTextView() { Value = "0" }; nSViewsTwoDim [0, 1] = new NSTextView() { Value = "1" }; nSViewsTwoDim [1, 0] = new NSTextView() { Value = "2" }; nSViewsTwoDim [1, 1] = new NSTextView() { Value = "3" }; NSGridView nSGridViewTwoDimensionalArray = NSGridView.Create(nSViewsTwoDim); Assert.NotNull(nSGridViewTwoDimensionalArray); Assert.AreEqual("0", ((NSTextView)(nSGridViewTwoDimensionalArray.GetCell(0, 0)).ContentView).Value, "0,0"); Assert.AreEqual("1", ((NSTextView)(nSGridViewTwoDimensionalArray.GetCell(0, 1)).ContentView).Value, "0,1"); Assert.AreEqual("2", ((NSTextView)(nSGridViewTwoDimensionalArray.GetCell(1, 0)).ContentView).Value, "1,0"); Assert.AreEqual("3", ((NSTextView)(nSGridViewTwoDimensionalArray.GetCell(1, 1)).ContentView).Value, "1,1"); }
public void CreateWithNSViewArrayOfArrayCheckWithNullArray() { NSView [][] nSViewsArrayOfArray = new NSView [2][]; nSViewsArrayOfArray [0] = new NSView [1] { new NSTextView() { Value = "0" } }; nSViewsArrayOfArray [1] = null; Assert.Throws <ArgumentNullException> (() => NSGridView.Create(nSViewsArrayOfArray), "Broken Array #2"); }
public void AddMenuItems(KControl[] items) { NSGridView row = new NSGridView(); row.ColumnSpacing = 0; row.SetContentHuggingPriorityForOrientation(255, NSLayoutConstraintOrientation.Horizontal); for (int i = 0; i < items.Length; i++) { row.AddColumn(new NSView[1] { ((MacControl)items[i]).control }); } this.menu.AddRow(new NSView[1] { row }); this.menu.SetFrameOrigin(new CGPoint(0, 0)); // w.r.t. the menuBox }
public void CreateWithTwoDimensionalNSViewArrayWithNullCell() { NSView [,] nSViewsTwoDim = new NSView [2, 2]; nSViewsTwoDim [0, 0] = new NSTextView() { Value = "0" }; nSViewsTwoDim [0, 1] = new NSTextView() { Value = "1" }; nSViewsTwoDim [1, 0] = new NSTextView() { Value = "2" }; nSViewsTwoDim [1, 1] = null; Assert.Throws <ArgumentNullException> (() => NSGridView.Create(nSViewsTwoDim), "Broken Array #5"); }
public void CreateWithNSViewArrayOfArrayCheckNSTextView() { NSView [][] nSViewsArrayOfArray = new NSView [4][]; nSViewsArrayOfArray [0] = new NSView [1] { new NSTextView() { Value = "0" } }; nSViewsArrayOfArray [1] = new NSView [1] { new NSTextView() { Value = "1" } }; nSViewsArrayOfArray [2] = new NSView [1] { new NSTextView() { Value = "2" } }; nSViewsArrayOfArray [3] = new NSView [1] { new NSTextView() { Value = "3" } }; NSGridView nSGridViewArrayOfArray = NSGridView.Create(nSViewsArrayOfArray); Assert.NotNull(nSGridViewArrayOfArray); Assert.AreEqual("0", ((NSTextView)(nSGridViewArrayOfArray.GetCell(0, 0)).ContentView).Value, "0,0"); Assert.AreEqual("1", ((NSTextView)(nSGridViewArrayOfArray.GetCell(0, 1)).ContentView).Value, "0,1"); Assert.AreEqual("2", ((NSTextView)(nSGridViewArrayOfArray.GetCell(0, 2)).ContentView).Value, "0,2"); Assert.AreEqual("3", ((NSTextView)(nSGridViewArrayOfArray.GetCell(0, 3)).ContentView).Value, "0,3"); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.nsForm = NSObject.FromObject(this); this.texter = new PlatformTexter(); fonts = new Dictionary <float, NSFont>(); fontsFixed = new Dictionary <float, NSFont>(); // Register this Gui for platform-independent access via interface KGuiControl KGui.Register(this); // Register this Gui for platform-independent access via interface KControls macControls = new MacControls(); // set up platform-specific gui controls KGui.Register(new KControls(macControls)); // bind actions to them (non-platform specific) leftPanelClicker.Activated += (object sender, EventArgs e) => { KGui.kControls.CloseOpenMenu(); }; rightPanelClicker.Activated += (object sender, EventArgs e) => { KGui.kControls.CloseOpenMenu(); }; // Text Areas inputTextView.alwaysDisableIBeamCursor = false; // disable only when menus are up outputTextView.alwaysDisableIBeamCursor = true; (textInput.DocumentView as AppKit.NSTextView).Font = GetFont(12.0F, true); (textOutput.DocumentView as AppKit.NSTextView).Font = GetFont(12.0F, true); // Device { NSBox x = deviceBox; NSDeviceView y = kaemikaDevice; } // just checking: these are the Outlets from Main.storyboard through XCode // Score { NSBox x = scoreBox; NSScoreView y = kaemikaScore; } // just checking: these are the Outlets from Main.storyboard through XCode // Chart { NSChartView x = kaemikaChart; } // just checking: this is the Outlet from Main.storyboard through XCode SetChartTooltip("", new CGPoint(0, 0), new CGRect(0, 0, 0, 0)); // Legend { NSBox x = legendFlyoutBox; NSGridView y = legendFlyoutMenu; } // just checking: these are the Outlets from Main.storyboard through XCode // Saved state macControls.RestorePreferences(); //needs kControls initialized GuiRestoreInput(); // Dark Mode Detection var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle"); MacControls.darkMode = interfaceStyle == "Dark"; MacControls.SwitchMode(); NSDistributedNotificationCenter.GetDefaultCenter(). AddObserver(this, new ObjCRuntime.Selector("themeChanged:"), new NSString("AppleInterfaceThemeChangedNotification"), null); // Keyboard Events // https://stackoverflow.com/questions/32446978/swift-capture-keydown-from-nsviewcontroller // list of keycodes: // https://stackoverflow.com/questions/3202629/where-can-i-find-a-list-of-mac-virtual-key-codes // for modifier keys NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.FlagsChanged, (NSEvent e) => { try { if (MyModifiersChanged(e)) { return(null); } else { return(e); } } catch { return(e); } }); // for normal, unmodified, keys //NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown, // (NSEvent e) => { try { if (MyKeyDown(e)) return null; else return e; } catch { return e; } }); }
public MusicMenu(String _title) { //メニューの作成 NSStatusBar statusBar = NSStatusBar.SystemStatusBar; NSMenu menu = new NSMenu(_title); this.item = statusBar.CreateStatusItem(NSStatusItemLength.Variable); this.item.Title = "Music"; this.item.HighlightMode = true; this.item.Menu = menu; //itunesプレイヤー作成 itunes = new MusicPlayer("iTunes"); //再生停止項目追加 var menuItem2 = new NSMenuItem(); menuItem2.Title = "PlayPause"; menuItem2.Activated += (sender, e) => itunes.PlayPause(); menu.AddItem(menuItem2); /* * NSSlider slider = new NSSlider(new CGRect(10, 0, 100, 20)); * slider.MaxValue = 50.0F; * slider.MinValue = 0.0F; * slider.FloatValue = 25.0F; * slider.SetFrameSize(new CGSize(160, 16)); * sliderItem.View = slider; * menu.AddItem(sliderItem); */ //Pre、Nextボタン作成 var tableItem = new NSMenuItem(); tableItem.Title = "table"; NSGridView table = new NSGridView(new CGRect(0, 0, 90, 16)); NSButton [] text = { new NSButton(new CGRect(0, 0, 50, 10)), new NSButton(new CGRect(0, 0, 20, 10)) }; //NSTextField [] text = { new NSTextField(new CGRect(0, 0, 40, 10)), new NSTextField(new CGRect(0, 0, 20, 10)) }; text[0].Title = "Pre"; text[0].Alignment = NSTextAlignment.Center; //text[0].Bordered = false; text[0].Activated += (sender, e) => itunes.PreTrack(); text[1].Title = "Next"; text[1].Alignment = NSTextAlignment.Center; //text[1].Bordered = false; text[1].Activated += (sender, e) => itunes.NextTrack(); table.AddRow(text); tableItem.View = table; menu.AddItem(tableItem); //プレイリストをメニューに追加 var playlist = new NSMenuItem(); playlist.Title = "iTunes PlayList"; menu.AddItem(playlist); NSMenu playlistsubmenu = new NSMenu(); playlist.Submenu = playlistsubmenu; var playlist_name = itunes.playlist; for (int i = 0; i < playlist_name.Length; i++) { var playlistsubmenuitem = new NSMenuItem(); playlistsubmenuitem.Title = playlist_name[i]; //playlistmenu.Action = new ObjCRuntime.Selector("playlist:"); playlistsubmenuitem.Activated += (sender, e) => itunes.Playplaylist(itunes.name, playlistsubmenuitem.Title); playlistsubmenu.AddItem(playlistsubmenuitem); } menu.AddItem(NSMenuItem.SeparatorItem); //アプリ終了項目追加 var menuItem = new NSMenuItem(); menuItem.Title = "Quit"; menuItem.Action = new ObjCRuntime.Selector("quite:"); menu.AddItem(menuItem); var sliderItem = new NSMenuItem(); sliderItem.Title = "slider"; //itunesの監視者を作成 var center = (NSDistributedNotificationCenter)NSDistributedNotificationCenter.DefaultCenter;// as NSNotificationCenter; center.AddObserver(new NSString("com.apple.iTunes.playerInfo"), OnClockChange); }
public void CreateWithTwoDimensionalNSViewArrayCheckWithNull() { NSView[,] nSViewsTwoDim = null; Assert.Throws <ArgumentNullException> (() => NSGridView.Create(nSViewsTwoDim), "Broken Array #4"); }
public void CreateWithNSViewArrayOfArrayCheckWithNull() { NSView[][] nSViewsArrayOfArray = null; Assert.Throws <ArgumentNullException> (() => NSGridView.Create(nSViewsArrayOfArray), "Broken Array #3"); }