//Handle right click event for the TableView public override NSMenu MenuForEvent (NSEvent theEvent) { CGPoint pt = this.ConvertPointFromView (theEvent.LocationInWindow, null); _selectedRow = this.GetRow (pt); NSTableViewDataSource ds = (NSTableViewDataSource)this.DataSource; NSMenu menu = new NSMenu (); if (_selectedRow >= (nint)0) { if (ds is NodesListView) { DirectoryNode node = ((ds as NodesListView).Entries [(int)_selectedRow] as DirectoryNode); if (node != null) { if (node.NodeType == DirectoryNode.DirectoryNodeType.User) { NSMenuItem ResetPassword = new NSMenuItem ("Set Password", node.RestUserPassword); menu.AddItem (ResetPassword); NSMenuItem delete = new NSMenuItem ("Delete", node.Delete); menu.AddItem (delete); NSMenuItem Properties = new NSMenuItem ("Properties", node.ViewProperties); menu.AddItem (Properties); } else if (node.NodeType == DirectoryNode.DirectoryNodeType.Groups) { NSMenuItem addUser = new NSMenuItem ("Add user to group", node.AddUserToGroup); menu.AddItem (addUser); } } } } NSMenu.PopUpContextMenu (menu, theEvent, theEvent.Window.ContentView); return base.MenuForEvent (theEvent); }
public override void DidFinishLaunching (NSNotification notification) { var menu = new NSMenu (); var menuItem = new NSMenuItem (); menu.AddItem (menuItem); var appMenu = new NSMenu (); var quitItem = new NSMenuItem ("Quit", "q", (s, e) => NSApplication.SharedApplication.Terminate (menu)); appMenu.AddItem (quitItem); menuItem.Submenu = appMenu; NSApplication.SharedApplication.MainMenu = menu; m_window = new NSWindow ( new CGRect (0, 0, 1024, 720), NSWindowStyle.Closable | NSWindowStyle.Miniaturizable | NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.TexturedBackground, NSBackingStore.Buffered, false) { Title = "Bluebird WkBrowser", ReleasedWhenClosed = false, ContentMinSize = new CGSize (1024, 600), CollectionBehavior = NSWindowCollectionBehavior.FullScreenPrimary }; m_window.Center (); m_window.MakeKeyAndOrderFront (null); var viewController = new ViewController (); m_window.ContentView = viewController.View; m_window.ContentViewController = viewController; viewController.View.Frame = m_window.ContentView.Bounds; }
public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { Enabled = true; Hidden = Submenu != NSApplication.SharedApplication.ServicesMenu; if (!Hidden) MDMenu.ShowLastSeparator (ref lastSeparator); }
public override void WindowControllerDidLoadNib(NSWindowController windowController) { base.WindowControllerDidLoadNib(windowController); // Add code to here after the controller has loaded the document window // Populate the popup menu NSMenu menu = popup.Menu; NSViewController vc = viewControllers.GetItem<NSViewController>(0); NSMenuItem mi = new NSMenuItem(vc.Title, null, ""); // Set CMD-B as the key equvialent // NSMenuItem mi = new NSMenuItem(vc.Title, null, "b"); // mi.KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask; menu.AddItem(mi); vc = viewControllers.GetItem<NSViewController>(1); mi = new NSMenuItem(vc.Title, null, ""); // Set CMD-A as the key equvialent // mi = new NSMenuItem(vc.Title, null, "a"); // mi.KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask; menu.AddItem(mi); // Initially show the first controller. popup.SelectItem(0); DisplayViewController(viewControllers.GetItem<NSViewController>(0)); }
public override void DidFinishLaunching (NSNotification notification) { // Create a Status Bar Menu NSStatusBar statusBar = NSStatusBar.SystemStatusBar; var item = statusBar.CreateStatusItem (NSStatusItemLength.Variable); item.Title = "Text"; item.HighlightMode = true; item.Menu = new NSMenu ("Text"); var address = new NSMenuItem ("Address"); address.Activated += (sender, e) => { phrasesAddress(address); }; item.Menu.AddItem (address); var date = new NSMenuItem ("Date"); date.Activated += (sender, e) => { phrasesDate(date); }; item.Menu.AddItem (date); var greeting = new NSMenuItem ("Greeting"); greeting.Activated += (sender, e) => { phrasesGreeting(greeting); }; item.Menu.AddItem (greeting); var signature = new NSMenuItem ("Signature"); signature.Activated += (sender, e) => { phrasesSignature(signature); }; item.Menu.AddItem (signature); }
public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { if (ces.AutoHide) { ((MDMenu)Submenu).UpdateCommands (); Hidden = Submenu.ItemArray ().All (item => item.Hidden); } if (!Hidden) { MDMenu.ShowLastSeparator (ref lastSeparator); } }
public void PopulateGoMenu () { for (int i = 0; i < PresentationViewController.NumberOfSlides; i++) { var slideName = PresentationViewController.ClassOfSlide (i).ToString(); var splitedString = slideName.Split ('.'); var title = i + " " + splitedString[1].Substring(5); var item = new NSMenuItem (title, new Selector("GoTo"), ""); item.RepresentedObject = new NSNumber (i); GoMenu.AddItem (item); } }
public void Run (NSMenuItem sender) { var a = sender as MDExpandedArrayItem; //if the command opens a modal subloop, give cocoa a chance to unhighlight the menu item GLib.Timeout.Add (1, () => { if (a != null) { manager.DispatchCommand (ce.CommandId, a.Info.DataItem, initialCommandTarget, commandSource); } else { manager.DispatchCommand (ce.CommandId, null, initialCommandTarget, commandSource); } return false; }); }
public void DepartmentSelected(NSMenuItem sender) { Console.WriteLine("Department Selected: {0}, Index: {1}, Handle: {2}", sender.Title, sender.Menu.IndexOf(sender), sender.Handle); Employee emp = DataStore.Employees[(int)EmployeesTableView.SelectedRow]; // If Employee was manager of the old department, remove them as manager of the old deparment. if (emp.DepartmentName != "") { Department dep = DataStore.Departments.Find(x => x.Name == emp.DepartmentName); if (dep.ManagerName == emp.FullName) { dep.ManagerName = ""; } } emp.DepartmentName = sender.Title; }
public override NSMenu MenuForEvent (NSEvent theEvent) { CGPoint pt = this.ConvertPointFromView (theEvent.LocationInWindow, null); _selectedRow = this.GetRow (pt); NSTableViewDataSource ds = (NSTableViewDataSource)this.DataSource; NSMenu menu = new NSMenu (); if (_selectedRow >= (nint)0) { if (ds is NodesListView) { string data = (ds as NodesListView).Entries [(int)_selectedRow].DisplayName; switch (data) { case "Private Entities": NSMenuItem addPrivateEntity = new NSMenuItem ("Add Private Entity", ((ds as NodesListView).Entries [(int)_selectedRow] as VecsPrivateKeysNode).AddPrivateKeyHandler); menu.AddItem (addPrivateEntity); break; case "Secret Keys": NSMenuItem createCertificate = new NSMenuItem ("Add Secret Key", ((ds as NodesListView).Entries [(int)_selectedRow] as VecsSecretKeysNode).AddSecretKey); menu.AddItem (createCertificate); break; case "Trusted Certs": NSMenuItem createSigningRequest = new NSMenuItem ("Create Certificate", ((ds as NodesListView).Entries [(int)_selectedRow] as VecsTrustedCertsNode).AddCertificate); menu.AddItem (createSigningRequest); break; default: break; } } else if (ds is CertificateDetailsListView) { CertificateDetailsListView lw = ds as CertificateDetailsListView; CertDTO cert = lw.Entries [(int)_selectedRow]; NSMenuItem showCert = new NSMenuItem ("Show Certificate", (object sender, EventArgs e) => CertificateService.DisplayX509Certificate2 (this, cert.Cert)); menu.AddItem (showCert); NSMenuItem deleteEntry = new NSMenuItem ("Delete", (object sender, EventArgs e) => { UIErrorHelper.CheckedExec (delegate() { if (UIErrorHelper.ConfirmDeleteOperation ("Are you sure?") == true) { using (var session = new VecsStoreSession (lw.ServerDto.VecsClient, lw.Store, "")) { session.DeleteCertificate (cert.Alias); } lw.Entries.Remove (cert); UIErrorHelper.ShowAlert ("", "Successfully deleted the entry."); NSNotificationCenter.DefaultCenter.PostNotificationName ("ReloadServerData", this); } }); }); menu.AddItem (deleteEntry); } NSMenu.PopUpContextMenu (menu, theEvent, theEvent.Window.ContentView); } return base.MenuForEvent (theEvent); }
public override void DidFinishLaunching(NSNotification notification) { var menu = new NSMenu(); var menuItem = new NSMenuItem(); menu.AddItem(menuItem); var appMenu = new NSMenu(); var quitItem = new NSMenuItem("Quit " + NSProcessInfo.ProcessInfo.ProcessName, "q", (s, e) => NSApplication.SharedApplication.Terminate(menu)); appMenu.AddItem(quitItem); menuItem.Submenu = appMenu; NSApplication.SharedApplication.MainMenu = menu; mainWindowController = new MainWindowController(); mainWindowController.Window.MakeKeyAndOrderFront(this); }
public bool ValidateMenuItem (NSMenuItem item) { // Take action based on the Menu Item type // (As specified in its Tag) switch (item.Tag) { case 1: // Wrap menu items should only be available if // a range of text is selected return (TextEditor.SelectedRange.Length > 0); case 2: // Quote menu items should only be available if // a range is NOT selected. return (TextEditor.SelectedRange.Length == 0); } return true; }
public override void DidFinishLaunching(NSNotification notification) { var version = "1.0.0"; var appName = "Lotta love for the Windows Apps user group!"; Xamarin.Insights.Initialize(Core.Keys.XamarinInsightsKey, version, appName, null); var menu = new NSMenu(); var menuItem = new NSMenuItem(); menu.AddItem(menuItem); var appMenu = new NSMenu(); var quitItem = new NSMenuItem("Quit " + NSProcessInfo.ProcessInfo.ProcessName, "q", (s, e) => NSApplication.SharedApplication.Terminate(menu)); appMenu.AddItem(quitItem); menuItem.Submenu = appMenu; NSApplication.SharedApplication.MainMenu = menu; }
public override void FinishedLaunching (NSObject notification) { plotWindowController = new PlotWindowController (); var menu = new NSMenu (); var appMenu = new NSMenu (); appMenu.AddItem (new NSMenuItem ("Next example", "n", (s, e) => this.NextExample (1))); appMenu.AddItem (new NSMenuItem ("Previous example", "p", (s, e) => this.NextExample (-1))); appMenu.AddItem (NSMenuItem.SeparatorItem); appMenu.AddItem (new NSMenuItem ("Quit", "q", (s, e) => NSApplication.SharedApplication.Terminate (menu))); menu.AddItem (new NSMenuItem { Submenu = appMenu }); var fileMenu = new NSMenu ("File"); fileMenu.AddItem (new NSMenuItem ("Export", "e")); menu.AddItem (new NSMenuItem { Submenu = fileMenu }); var editMenu = new NSMenu ("Edit"); editMenu.AddItem (new NSMenuItem ("Copy", "c")); menu.AddItem (new NSMenuItem { Submenu = editMenu }); var examplesMenu = new NSMenu ("Examples"); exampleList = Examples.GetList (); var categories = exampleList.Select (e => e.Category).Distinct ().OrderBy (c => c).ToArray (); var categoryMenus = new Dictionary<string,NSMenu> (); foreach (var category in categories) { var categoryMenu = new NSMenu (category); examplesMenu.AddItem (new NSMenuItem (category) { Submenu = categoryMenu }); categoryMenus.Add (category, categoryMenu); } foreach (var example in exampleList) { var item = new NSMenuItem (example.Title, (s, e) => this.SetExample (example)); var categoryMenu = categoryMenus [example.Category]; categoryMenu.AddItem (item); } menu.AddItem (new NSMenuItem { Submenu = examplesMenu }); this.SetExample (exampleList.First ()); plotWindowController.Window.MakeKeyAndOrderFront (this); NSApplication.SharedApplication.MainMenu = menu; }
public override NSMenu MenuForEvent (NSEvent theEvent) { CGPoint pt = this.ConvertPointFromView (theEvent.LocationInWindow, null); nint row = this.GetRow (pt); if (row >= (nint)0) { NSObject obj = this.ItemAtRow (row); if (obj != null) { NSMenu menu = new NSMenu (); if (obj is VecsStoresNode) { VecsStoresNode node = obj as VecsStoresNode; NSMenuItem createStore = new NSMenuItem ("Create Store", node.CreateStore); menu.AddItem (createStore); } else if (obj is VecsPrivateKeysNode) { VecsPrivateKeysNode node = obj as VecsPrivateKeysNode; NSMenuItem addPrivate = new NSMenuItem ("Add Private Key", node.AddPrivateKeyHandler); menu.AddItem (addPrivate); } else if (obj is VecsSecretKeysNode) { VecsSecretKeysNode node = obj as VecsSecretKeysNode; NSMenuItem addSecret = new NSMenuItem ("Add Secret Key", node.AddSecretKey); menu.AddItem (addSecret); } else if (obj is VecsTrustedCertsNode) { VecsTrustedCertsNode node = obj as VecsTrustedCertsNode; NSMenuItem createCertificate = new NSMenuItem ("Add Certificate", node.AddCertificate); menu.AddItem (createCertificate); } else if (obj is VecsStoreNode) { VecsStoreNode node = obj as VecsStoreNode; NSMenuItem deleteStore = new NSMenuItem ("Delete Store", node.DeleteStore); //disable delete option for the following three certstores. if (node.StoreName.Equals ("MACHINE_SSL_CERT") || node.StoreName.Equals ("TRUSTED_ROOTS") || node.StoreName.Equals ("TRUSTED_ROOT_CRLS")) deleteStore.Hidden = true; menu.AddItem (deleteStore); } NSMenu.PopUpContextMenu (menu, theEvent, theEvent.Window.ContentView); } } return base.MenuForEvent (theEvent); }
public override void DidFinishLaunching (NSNotification notification) { mainWindowController = new MainWindowController (); mainWindowController.Window.MakeKeyAndOrderFront (this); // Create a Status Bar Menu NSStatusBar statusBar = NSStatusBar.SystemStatusBar; var item = statusBar.CreateStatusItem (NSStatusItemLength.Variable); item.Title = "Phrases"; item.HighlightMode = true; item.Menu = new NSMenu ("Phrases"); var address = new NSMenuItem ("Address"); address.Activated += (sender, e) => { Console.WriteLine("Address Selected"); }; item.Menu.AddItem (address); var date = new NSMenuItem ("Date"); date.Activated += (sender, e) => { Console.WriteLine("Date Selected"); }; item.Menu.AddItem (date); var greeting = new NSMenuItem ("Greeting"); greeting.Activated += (sender, e) => { Console.WriteLine("Greetings Selected"); }; item.Menu.AddItem (greeting); var signature = new NSMenuItem ("Signature"); signature.Activated += (sender, e) => { Console.WriteLine("Signature Selected"); }; item.Menu.AddItem (signature); }
public SelectEncodingPopUpButton (bool showAutoDetected) { Cell.UsesItemFromMenu = false; if (showAutoDetected) { autoDetectedItem = new NSMenuItem { Title = GettextCatalog.GetString ("Auto Detected"), Tag = -1, Target = this, Action = itemActivationSel, }; } addRemoveItem = new NSMenuItem { Title = GettextCatalog.GetString ("Add or Remove..."), Tag = -20, Target = this, Action = addRemoveActivationSel, }; Populate (false); SelectedEncodingId = 0; }
//Right click menu event for the outlineview. public override NSMenu MenuForEvent (NSEvent theEvent) { int row = (int)this.SelectedRow; if (row >= (nint)0) { NSObject obj = this.ItemAtRow (row); if (obj != null) { NSMenu menu = new NSMenu (); if (obj is DirectoryNode) { DirectoryNode node = obj as DirectoryNode; if (node.NodeType == DirectoryNode.DirectoryNodeType.User) { NSMenuItem addUsertoGroup = new NSMenuItem ("Add to a Group", node.AddUserToGroup); menu.AddItem (addUsertoGroup); NSMenuItem resetPassword = new NSMenuItem ("Set Password", node.RestUserPassword); menu.AddItem (resetPassword); } else if (node.NodeType == DirectoryNode.DirectoryNodeType.Groups) { NSMenuItem addGrouptoGroup = new NSMenuItem ("Add to a Group", node.AddUserToGroup); menu.AddItem (addGrouptoGroup); } else { NSMenuItem addUser = new NSMenuItem ("Add User", node.AddUser); menu.AddItem (addUser); NSMenuItem addGroup = new NSMenuItem ("Add Group", node.AddGroup); menu.AddItem (addGroup); NSMenuItem add = new NSMenuItem ("Add Object", node.Add); menu.AddItem (add); } NSMenuItem delete = new NSMenuItem ("Delete", node.Delete); menu.AddItem (delete); NSMenuItem properties = new NSMenuItem ("Properties", node.ViewProperties); menu.AddItem (properties); NSMenuItem refresh = new NSMenuItem ("Refresh", node.RefreshNode); menu.AddItem (refresh); } NSMenu.PopUpContextMenu (menu, theEvent, theEvent.Window.ContentView); } } return base.MenuForEvent (theEvent); }
public override NSMenu MenuForEvent (NSEvent theEvent) { CGPoint pt = this.ConvertPointToView (theEvent.LocationInWindow, null); nint row = this.GetRow (pt); if (row >= (nint)0) { NSObject obj = this.ItemAtRow ((int)row); if (obj != null) { NSMenu menu = new NSMenu (); if (obj is VMCAServerNode) { VMCAServerNode serverNode = obj as VMCAServerNode; if (serverNode.IsLoggedIn) { NSMenuItem getVersion = new NSMenuItem ("Get Server Version", serverNode.GetServerVersion); menu.AddItem (getVersion); NSMenuItem showRoot = new NSMenuItem ("Show Root Certificate", serverNode.ShowRootCertificate); menu.AddItem (showRoot); NSMenuItem addCert = new NSMenuItem ("Add Root Certificate", serverNode.AddRootCertificate); menu.AddItem (addCert); } } else if (obj is VMCAKeyPairNode) { VMCAKeyPairNode node = obj as VMCAKeyPairNode; NSMenuItem createKeyPair = new NSMenuItem ("Create KeyPair", node.CreateKeyPair); menu.AddItem (createKeyPair); } else if (obj is VMCACSRNode) { VMCACSRNode node = obj as VMCACSRNode; NSMenuItem createSigningRequest = new NSMenuItem ("Create Signing Request", node.HandleSigningRequest); menu.AddItem (createSigningRequest); } else if (obj is VMCAPersonalCertificatesNode) { VMCAPersonalCertificatesNode node = obj as VMCAPersonalCertificatesNode; NSMenuItem createCertificate = new NSMenuItem ("Create Certificate", node.CreateCertificate); menu.AddItem (createCertificate); } NSMenu.PopUpContextMenu (menu, theEvent, theEvent.Window.ContentView); } } return base.MenuForEvent (theEvent); }
public MacMenuItemWrapper(NSMenuItem submenu) { this.submenu = submenu; }
static NSMenuItem CreateMenuItem (ContextMenuItem item) { if (item.IsSeparator) { return NSMenuItem.SeparatorItem; } var menuItem = new NSMenuItem (item.Label.Replace ("_",""), (s, e) => item.Click ()); menuItem.Hidden = !item.Visible; menuItem.Enabled = item.Sensitive; menuItem.Image = item.Image.ToNSImage (); if (item is RadioButtonContextMenuItem) { var radioItem = (RadioButtonContextMenuItem)item; menuItem.State = radioItem.Checked ? NSCellStateValue.On : NSCellStateValue.Off; } else if (item is CheckBoxContextMenuItem) { var checkItem = (CheckBoxContextMenuItem)item; menuItem.State = checkItem.Checked ? NSCellStateValue.On : NSCellStateValue.Off; } if (item.SubMenu != null && item.SubMenu.Items.Count > 0) { menuItem.Submenu = FromMenu (item.SubMenu, null); } return menuItem; }
partial void switchView(NSMenuItem sender) { Layer.AddSublayer(SwitchLayers()); }
private void CreateMenu() { if (MenuButton.Menu != null) { return; } MenuButton.Menu = new NSMenu(); var topLevelItems = new NSMenuItem[] { new NSMenuItem("Scan mac", async(s, e) => await _monitor.ScanForLocalRepositoriesAsync()), new NSMenuItem("Auto fetch") { Tag = MENU_AUTOFETCH }, NSMenuItem.SeparatorItem, new NSMenuItem("Ping back") { Tag = MENU_PINGBACK }, NSMenuItem.SeparatorItem, new NSMenuItem("Help", (s, e) => ShowHelp()), new NSMenuItem("Quit", (s, e) => Quit()) }; foreach (var item in topLevelItems) { MenuButton.Menu.AddItem(item); } var autoFetchItems = new NSMenuItem[] { new NSMenuItem(nameof(AutoFetchMode.Off), HandleAutoFetchChange) { Identifier = AutoFetchMode.Off.ToString() }, new NSMenuItem(nameof(AutoFetchMode.Discretely), HandleAutoFetchChange) { Identifier = AutoFetchMode.Discretely.ToString() }, new NSMenuItem(nameof(AutoFetchMode.Adequate), HandleAutoFetchChange) { Identifier = AutoFetchMode.Adequate.ToString() }, new NSMenuItem(nameof(AutoFetchMode.Aggresive), HandleAutoFetchChange) { Identifier = AutoFetchMode.Aggresive.ToString() } }; var autoFetchItem = MenuButton.Menu.ItemWithTag(MENU_AUTOFETCH); autoFetchItem.Submenu = new NSMenu(); foreach (var item in autoFetchItems) { autoFetchItem.Submenu.AddItem(item); } var pingbackItems = new NSMenuItem[] { new NSMenuItem("Star RepoZ on GitHub", (s, e) => Navigate("https://github.com/awaescher/RepoZ")), new NSMenuItem("Follow @Waescher", (s, e) => Navigate("https://twitter.com/Waescher")), NSMenuItem.SeparatorItem, new NSMenuItem("Buy me a coffee", (s, e) => Navigate("https://www.buymeacoffee.com/awaescher")) }; var pingbackItem = MenuButton.Menu.ItemWithTag(MENU_PINGBACK); pingbackItem.Submenu = new NSMenu(); foreach (var item in pingbackItems) { pingbackItem.Submenu.AddItem(item); } }
internal void PopUpContextMenu() { if (this.popUpContextMenu == null) { this.popUpContextMenu = new NSMenu(); if (this.viewModel.TargetPlatform.SupportsCustomExpressions) { var mi = new NSMenuItem(Properties.Resources.CustomExpressionEllipsis) { AttributedTitle = new Foundation.NSAttributedString( Properties.Resources.CustomExpressionEllipsis, new CoreText.CTStringAttributes { Font = new CoreText.CTFont(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1), }) }; mi.Activated += OnCustomExpression; this.popUpContextMenu.AddItem(mi); this.popUpContextMenu.AddItem(NSMenuItem.SeparatorItem); } if (this.viewModel.SupportsResources) { this.popUpContextMenu.AddItem(NSMenuItem.SeparatorItem); var mi2 = new NSMenuItem(Properties.Resources.ResourceEllipsis) { AttributedTitle = new Foundation.NSAttributedString( Properties.Resources.ResourceEllipsis, new CoreText.CTStringAttributes { Font = new CoreText.CTFont(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1), }) }; mi2.Activated += OnResourceRequested; this.popUpContextMenu.AddItem(mi2); } if (this.viewModel.SupportsBindings) { this.popUpContextMenu.AddItem(NSMenuItem.SeparatorItem); this.popUpContextMenu.AddItem(new CommandMenuItem(Properties.Resources.CreateDataBindingMenuItem, this.viewModel.RequestCreateBindingCommand) { AttributedTitle = new Foundation.NSAttributedString( Properties.Resources.CreateDataBindingMenuItem, new CoreText.CTStringAttributes { Font = new CoreText.CTFont(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1), }) }); } this.popUpContextMenu.AddItem(NSMenuItem.SeparatorItem); // TODO If we add more menu items consider making the Label/Command a dictionary that we can iterate over to populate everything. this.popUpContextMenu.AddItem(new CommandMenuItem(Properties.Resources.Reset, this.viewModel.ClearValueCommand) { AttributedTitle = new Foundation.NSAttributedString( Properties.Resources.Reset, new CoreText.CTStringAttributes { Font = new CoreText.CTFont(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize + 1), }) }); } FocusClickedRow(); var menuOrigin = this.Superview.ConvertPointToView(new CGPoint(Frame.Location.X - 1, Frame.Location.Y + Frame.Size.Height + 4), null); var popupMenuEvent = NSEvent.MouseEvent(NSEventType.LeftMouseDown, menuOrigin, (NSEventModifierMask)0x100, 0, this.Window.WindowNumber, this.Window.GraphicsContext, 0, 1, 1); NSMenu.PopUpContextMenu(popUpContextMenu, popupMenuEvent, this); }
private static void AddToolbarItem(NSMutableDictionary theDict, NSString identifier, NSString label, NSString paletteLabel, NSString toolTip, Id target, IntPtr settingSelector, Id itemContent, IntPtr action, NSMenu menu) { NSMenuItem mItem; // here we create the NSToolbarItem and setup its attributes in line with the parameters NSToolbarItem item = new NSToolbarItem(identifier); item.Autorelease(); item.Label = label; item.PaletteLabel = paletteLabel; item.ToolTip = toolTip; // the settingSelector parameter can either be @selector(setView:) or @selector(setImage:). Pass in the right // one depending upon whether your NSToolbarItem will have a custom view or an image, respectively // (in the itemContent parameter). Then this next line will do the right thing automatically. item.PerformSelectorWithObject(settingSelector, itemContent); item.Target = target; item.Action = action; // If this NSToolbarItem is supposed to have a menu "form representation" associated with it (for text-only mode), // we set it up here. Actually, you have to hand an NSMenuItem (not a complete NSMenu) to the toolbar item, // so we create a dummy NSMenuItem that has our real menu as a submenu. if (menu != null) { // we actually need an NSMenuItem here, so we construct one mItem = new NSMenuItem(); mItem.Autorelease(); mItem.Submenu = menu; mItem.Title = menu.Title; item.MenuFormRepresentation = mItem; } // Now that we've setup all the settings for this new toolbar item, we add it to the dictionary. // The dictionary retains the toolbar item for us, which is why we could autorelease it when we created // it (above). theDict[identifier] = item; }
public void OnColorMenuItemClicked(NSMenuItem sender) { viewModel.OnColorSelected(new Color(unchecked ((uint)sender.Tag))); }
void HandleActivated(object sender, EventArgs e) { NSMenuItem item = (NSMenuItem)sender; OpenNote(item.Title); }
public void MenuWillHighlightItem(NSMenu menu, NSMenuItem item) { }
public void CreateMenu() { this.menu = new NSMenu() { AutoEnablesItems = false }; this.state_item = new NSMenuItem() { Title = Controller.StateText, Enabled = false }; this.folder_item = new NSMenuItem() { Title = "SparkleShare", Enabled = true }; this.folder_item.Image = this.sparkleshare_image; this.folder_item.Image.Size = new SizeF(16, 16); this.add_item = new NSMenuItem() { Title = "Sync Remote Project…", Enabled = true }; this.recent_events_item = new NSMenuItem() { Title = "Recent Changes…", Enabled = Controller.RecentEventsItemEnabled }; this.link_code_item = new NSMenuItem(); this.link_code_item.Title = "Computer ID"; if (Controller.LinkCodeItemEnabled) { this.link_code_submenu = new NSMenu(); this.code_item = new NSMenuItem(); this.code_item.Title = SparkleShare.Controller.UserAuthenticationInfo.PublicKey.Substring(0, 20) + "..."; this.copy_item = new NSMenuItem(); this.copy_item.Title = "Copy to Clipboard"; this.copy_item.Activated += delegate { Controller.CopyToClipboardClicked(); }; this.link_code_submenu.AddItem(this.code_item); this.link_code_submenu.AddItem(NSMenuItem.SeparatorItem); this.link_code_submenu.AddItem(this.copy_item); this.link_code_item.Submenu = this.link_code_submenu; } this.about_item = new NSMenuItem() { Title = "About SparkleShare", Enabled = true }; this.quit_item = new NSMenuItem() { Title = "Quit", Enabled = Controller.QuitItemEnabled }; this.folder_menu_items = new NSMenuItem [Controller.Projects.Length]; this.try_again_menu_items = new NSMenuItem [Controller.Projects.Length]; this.pause_menu_items = new NSMenuItem [Controller.Projects.Length]; this.resume_menu_items = new NSMenuItem [Controller.Projects.Length]; this.state_menu_items = new NSMenuItem [Controller.Projects.Length]; if (Controller.Projects.Length > 0) { int i = 0; foreach (ProjectInfo project in Controller.Projects) { NSMenuItem item = new NSMenuItem() { Title = project.Name }; this.folder_menu_items [i] = item; item.Submenu = new NSMenu(); item.Image = this.folder_image; this.state_menu_items [i] = new NSMenuItem(project.StatusMessage); item.Submenu.AddItem(this.state_menu_items [i]); item.Submenu.AddItem(NSMenuItem.SeparatorItem); if (project.IsPaused) { if (project.UnsyncedChangesInfo.Count > 0) { foreach (KeyValuePair <string, string> pair in project.UnsyncedChangesInfo) { item.Submenu.AddItem(new NSMenuItem(pair.Key) { Image = NSImage.ImageNamed(pair.Value) }); } if (!string.IsNullOrEmpty(project.MoreUnsyncedChanges)) { item.Submenu.AddItem(new NSMenuItem(project.MoreUnsyncedChanges)); } item.Submenu.AddItem(NSMenuItem.SeparatorItem); this.resume_menu_items [i] = new NSMenuItem("Sync and Resume…"); } else { this.resume_menu_items [i] = new NSMenuItem("Resume"); } this.resume_menu_items [i].Activated += Controller.ResumeDelegate(project.Name); item.Submenu.AddItem(this.resume_menu_items [i]); } else { if (Controller.Projects [i].HasError) { item.Image = this.caution_image; this.try_again_menu_items [i] = new NSMenuItem(); this.try_again_menu_items [i].Title = "Retry Sync"; this.try_again_menu_items [i].Activated += Controller.TryAgainDelegate(project.Name); item.Submenu.AddItem(this.try_again_menu_items [i]); } else { this.pause_menu_items [i] = new NSMenuItem("Pause"); this.pause_menu_items [i].Activated += Controller.PauseDelegate(project.Name); item.Submenu.AddItem(this.pause_menu_items [i]); } } if (!Controller.Projects [i].HasError) { this.folder_menu_items [i].Activated += Controller.OpenFolderDelegate(project.Name); } item.Image.Size = new SizeF(16, 16); i++; } ; } if (Controller.RecentEventsItemEnabled) { this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked(); } } ; this.add_item.Activated += delegate { Controller.AddHostedProjectClicked(); }; this.about_item.Activated += delegate { Controller.AboutClicked(); }; this.quit_item.Activated += delegate { Controller.QuitClicked(); }; this.menu.AddItem(this.state_item); this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.folder_item); this.submenu = new NSMenu(); this.submenu.AddItem(this.recent_events_item); this.submenu.AddItem(this.add_item); this.submenu.AddItem(NSMenuItem.SeparatorItem); this.submenu.AddItem(link_code_item); this.submenu.AddItem(NSMenuItem.SeparatorItem); this.submenu.AddItem(this.about_item); this.folder_item.Submenu = this.submenu; foreach (NSMenuItem item in this.folder_menu_items) { this.menu.AddItem(item); } this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.quit_item); this.menu_delegate = new SparkleMenuDelegate(); this.menu.Delegate = this.menu_delegate; this.status_item.Menu = this.menu; }
/* * Auto generated code ends here. Let's have some fun! */ public override void AwakeFromNib() { // Set up delegates for the relevant events webView.FinishedLoad += delegate { loadTitle(); installClickHandlers(); }; webView.UIGetContextMenuItems = (sender, forElements, defaultItems) => { // Disable contextual (right click) menu for the webView return(null); }; webView.DrawsBackground = false; // Configure webView to let JavaScript talk to this object. webView.WindowScriptObject.SetValueForKey(this, new NSString("MainWindowController")); // can be any unique name you want /* * Notes: * 1. In JavaScript, you can now talk to this object using "window.MainWindowController". * * 2. You must explicitly allow methods to be called from JavaScript; * See the "public static bool IsSelectorExcludedFromWebScript(MonoMac.ObjCRuntime.Selector aSelector)" * method below for an example. * * 3. The method on this class which we call from JavaScript is showMessage: * To call it from JavaScript, we use window.AppController.showMessage_() <-- NOTE colon becomes underscore! * For more on method-name translation, see: * http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Tasks/ObjCFromJavaScript.html# */ // Load the HTML document var htmlPath = Path.Combine(NSBundle.MainBundle.ResourcePath, "index.html"); webView.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl(htmlPath))); // Setup the theme chooser themeChooser.RemoveAllItems(); DirectoryInfo resourceDir = new DirectoryInfo(NSBundle.MainBundle.ResourcePath); FileInfo[] cssFiles = resourceDir.GetFiles("*.css"); Array.Sort(cssFiles, delegate(FileInfo f1, FileInfo f2) { // Sort by name, GetFiles does not seem to use naming order. return(f1.Name.CompareTo(f2.Name)); }); foreach (var cssFile in cssFiles) { var themeName = cssFile.Name.Substring(0, cssFile.Name.IndexOf(".css")); var nsItem = new NSMenuItem(themeName, "", delegate { changeTheme(null); }) { RepresentedObject = new NSString(cssFile.Name) }; nsItemList.Add(nsItem); // Workaround bug #661500 if (themeName == "Default") { nsItem.State = NSCellStateValue.On; } themeChooser.Menu.AddItem(nsItem); } themeChooser.SelectItem("Default"); }
void PopupMenuForCell(NSPathComponentCell item) { var componentRect = ((NSPathCell)Cell).GetRect(item, Frame, this); int i = 0; NSMenuItem selectedItem = null; var menu = new NSMenu { AutoEnablesItems = false, ShowsStateColumn = true, Font = NSFont.MenuFontOfSize(12), }; if (item.Identifier == RunConfigurationIdentifier) { if (ActiveRunConfiguration == null) { return; } foreach (var configuration in RunConfigurationModel) { var _configuration = configuration; var menuitem = new NSMenuItem(configuration.DisplayString, (o2, e2) => { ActiveRunConfiguration = runConfigurationModel.First(c => c.OriginalId == _configuration.OriginalId); }) { Enabled = true, IndentationLevel = 1, }; menu.AddItem(menuitem); if (selectedItem == null && configuration.OriginalId == ActiveRunConfiguration.OriginalId) { selectedItem = menuitem; } } } else if (item.Identifier == ConfigurationIdentifier) { if (ActiveConfiguration == null) { return; } foreach (var configuration in ConfigurationModel) { var _configuration = configuration; var menuitem = new NSMenuItem(configuration.DisplayString, (o2, e2) => { ActiveConfiguration = configurationModel.First(c => c.OriginalId == _configuration.OriginalId); }) { Enabled = true, IndentationLevel = 1, }; menu.AddItem(menuitem); if (selectedItem == null && configuration.OriginalId == ActiveConfiguration.OriginalId) { selectedItem = menuitem; } } } else if (item.Identifier == RuntimeIdentifier) { if (ActiveRuntime == null) { return; } using (var activeMutableModel = ActiveRuntime.GetMutableModel()) { foreach (var runtime in RuntimeModel) { NSMenuItem menuitem = null; if (runtime.IsSeparator) { menu.AddItem(NSMenuItem.SeparatorItem); } else { menuitem = CreateMenuItem(menu, runtime); } using (var mutableModel = runtime.GetMutableModel()) { if (selectedItem == null && menuitem != null && mutableModel.DisplayString == activeMutableModel.DisplayString) { selectedItem = menuitem; } } ++i; } } } else { throw new NotSupportedException(); } LastSelectedCell = IndexFromIdentifier(item.Identifier); if (menu.Count > 1) { var offs = new CGPoint(componentRect.Left + 3, componentRect.Top + 3); if (Window?.Screen?.BackingScaleFactor == 2) { offs.Y += 0.5f; // fine tune menu position on retinas } menu.PopUpMenu(selectedItem, offs, this); } }
public override NSMenu MenuForEvent(NSEvent theEvent) { CGPoint pt = this.ConvertPointToView(theEvent.LocationInWindow, null); int row = (int)this.GetRow(pt); if (row >= 0) { NSObject obj = this.ItemAtRow(row); if (obj != null) { NSMenu menu = new NSMenu(); menu.Font = NSFont.UserFontOfSize((float)12.0); if (obj is ServerNode) { ServerNode serverNode = obj as ServerNode; if (serverNode.IsLoggedIn) { NSMenuItem addNewTenant = new NSMenuItem("Add New Tenant", serverNode.OnAddNewTenant); var image = NSImage.ImageNamed("NSAddTemplate"); addNewTenant.Image = image; addNewTenant.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(addNewTenant); NSMenuItem aboutServer = new NSMenuItem("About", serverNode.OnShowAbout); image = NSImage.ImageNamed("NSInfo"); aboutServer.Image = image; aboutServer.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(aboutServer); var enable = serverNode != null && serverNode.Children.Count > 0 && ((TenantNode)serverNode.Children [0]).IsSystemTenant; if (enable) { NSMenuItem getComputers = new NSMenuItem("Computers", serverNode.OnShowComputers); image = NSImage.ImageNamed("NSComputer"); getComputers.Image = image; getComputers.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(getComputers); } NSMenuItem tokenWizard = new NSMenuItem("Diagnostics", serverNode.ShowTokenWizard); image = NSImage.ImageNamed("NSSmartBadgeTemplate"); tokenWizard.Image = image; tokenWizard.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(tokenWizard); } } else if (obj is TenantNode) { TenantNode tenantNode = obj as TenantNode; NSMenuItem showConfig = new NSMenuItem("Tenant Configuration", tenantNode.ShowConfiguration); var image = NSImage.ImageNamed("config.png"); showConfig.Image = image; showConfig.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(showConfig); } else if (obj is IdentitySourcesNode) { IdentitySourcesNode identitySources = obj as IdentitySourcesNode; NSMenuItem refreshSource = new NSMenuItem("Refresh", identitySources.Refresh); var image = NSImage.ImageNamed("NSRefresh"); refreshSource.Image = image; refreshSource.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(refreshSource); } else if (obj is IdentitySourceNode) { IdentitySourceNode identitySourceNode = obj as IdentitySourceNode; NSMenuItem refreshSource = new NSMenuItem("Refresh", identitySourceNode.Refresh); var image = NSImage.ImageNamed("NSRefresh"); refreshSource.Image = image; refreshSource.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(refreshSource); if (!identitySourceNode.IsDefaultDomain) { NSMenuItem setAsDefault = new NSMenuItem("Set as default domain", identitySourceNode.SetAsDefault); menu.AddItem(setAsDefault); } } else if (obj is UsersNode) { UsersNode node = obj as UsersNode; NSMenuItem item = null; if (node.IsSystemDomain) { item = new NSMenuItem("Add New User", node.AddNewUser); var image1 = NSImage.ImageNamed("Add_User_64.png"); item.Image = image1; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } item = new NSMenuItem("Refresh", node.Refresh); var image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } else if (obj is SolutionUsersNode) { SolutionUsersNode node = obj as SolutionUsersNode; NSMenuItem item = null; if (node.IsSystemDomain) { item = new NSMenuItem("Add New Solution User", node.AddNewUser); var image1 = NSImage.ImageNamed("Add_User_64.png"); item.Image = image1; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } item = new NSMenuItem("Refresh", node.Refresh); var image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } else if (obj is GroupsNode) { GroupsNode node = obj as GroupsNode; NSMenuItem item = null; if (node.IsSystemDomain) { item = new NSMenuItem("Add New Group", node.AddNewGroup); var image1 = NSImage.ImageNamed("Add_Group_64.png"); item.Image = image1; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } item = new NSMenuItem("Refresh", node.Refresh); var image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } else if (obj is RelyingPartyNode) { RelyingPartyNode node = obj as RelyingPartyNode; NSMenuItem item = null; item = new NSMenuItem("Add Relying Party", node.AddRelyingParty); var image1 = NSImage.ImageNamed("NSAddTemplate"); item.Image = image1; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); item = new NSMenuItem("Refresh", node.Refresh); var image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } else if (obj is OidcClientNode) { OidcClientNode node = obj as OidcClientNode; NSMenuItem item = null; item = new NSMenuItem("Add OIDC Client", node.AddOidcClient); var image1 = NSImage.ImageNamed("NSAddTemplate"); item.Image = image1; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); item = new NSMenuItem("Refresh", node.Refresh); var image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } else if (obj is IdentityProvidersNode) { IdentityProvidersNode node = obj as IdentityProvidersNode; NSMenuItem item = null; item = new NSMenuItem("Add External Identity Provider", node.AddExternalIdentityProvider); menu.AddItem(item); item = new NSMenuItem("Refresh", node.Refresh); var image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } else if (obj is TrustedCertificateNode) { TrustedCertificateNode node = obj as TrustedCertificateNode; NSMenuItem item = null; item = new NSMenuItem("Add Certificate Chain", node.AddCertificateChain); var image = NSImage.ImageNamed("certificate.png"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); item = new NSMenuItem("Refresh", node.Refresh); image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } else if (obj is ExternalDomainsNode) { ExternalDomainsNode node = obj as ExternalDomainsNode; NSMenuItem item = null; item = new NSMenuItem("Add New External Domain", node.AddNewExternalDomain); var image1 = NSImage.ImageNamed("NSAddTemplate"); item.Image = image1; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); item = new NSMenuItem("Refresh", node.Refresh); var image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } else if (obj is ExternalDomainNode) { ExternalDomainNode node = obj as ExternalDomainNode; NSMenuItem item = null; item = new NSMenuItem("Refresh", node.Refresh); var image = NSImage.ImageNamed("NSRefresh"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); item = new NSMenuItem("Properties", node.View); image = NSImage.ImageNamed("config.png"); item.Image = image; item.Image.Size = new CGSize { Width = (float)16.0, Height = (float)16.0 }; menu.AddItem(item); } NSMenu.PopUpContextMenu(menu, theEvent, theEvent.Window.ContentView); } } return(base.MenuForEvent(theEvent)); }
public void Export(NSMenuItem menuItem) { NSSavePanel savePanel = NSSavePanel.SavePanel; savePanel.AllowedFileTypes = new string[] { "txt" }; savePanel.Title = "Export Titles"; Process.log?.WriteLine("\nExport Titles"); savePanel.BeginSheet(Window, (nint result) => { if (result == (int)NSModalResponse.OK) { using (var writer = new StreamWriter(savePanel.Url.Path)) { Window.BeginSheet(sheet, ProgressComplete); userCancelled = false; writer.WriteLine("{0} {1}", NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleName").ToString(), NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleShortVersionString").ToString()); writer.WriteLine("--------------------------------------------------------------\n"); writer.WriteLine("Export titles starts at {0}\n", String.Format("{0:F}", DateTime.Now)); uint index = 0, count = (uint)titles.Count; foreach (var title in titles) { if (userCancelled) { userCancelled = false; break; } message.StringValue = title.titleName ?? ""; progress.DoubleValue = 100f * index++ / count; writer.WriteLine("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{9}|{10}|{11}|{12}|{13}|{14}", title.titleID, title.titleName, title.displayVersion, title.versionString, title.latestVersionString, title.firmware, title.masterkeyString, title.filename, NSByteCountFormatter.Format(title.filesize, NSByteCountFormatterCountStyle.File), title.typeString, title.distribution, title.structureString, title.signatureString, title.permissionString, title.error); } writer.WriteLine("\n{0} of {1} titles exported", index, titles.Count); Process.log?.WriteLine("\n{0} of {1} titles exported", index, titles.Count); Window.EndSheet(sheet); } } }); }
public override NSMenu MenuForEvent (NSEvent theEvent) { UIErrorHelper.CheckedExec (delegate() { CGPoint pt = this.ConvertPointFromView (theEvent.LocationInWindow, null); _selectedRow = this.GetRow (pt); //get datasource and node information NSTableViewDataSource ds = (NSTableViewDataSource)this.DataSource; NSMenu menu = new NSMenu (); if (_selectedRow >= 0) { if (ds is NodesListView) { string data = (ds as NodesListView).Entries [(int)_selectedRow].DisplayName; switch (data) { case "Key Pairs": NSMenuItem createKeyPair = new NSMenuItem ("Create Key Pair", HandleKeyPairRequest); menu.AddItem (createKeyPair); break; case "Certificates": NSMenuItem createCertificate = new NSMenuItem ("Create Certificate", HandleCreateSelfSignedCertificate); menu.AddItem (createCertificate); break; case "Signing Requests": NSMenuItem createSigningRequest = new NSMenuItem ("Create SigningRequest", HandleCreateSigningRequest); menu.AddItem (createSigningRequest); break; default: break; } } else if (ds is CertificateDetailsListView || ds is PrivateCertsListView) { X509Certificate2 cert = null; if (ds is CertificateDetailsListView) { CertificateDetailsListView lw = ds as CertificateDetailsListView; cert = lw.Entries [(int)_selectedRow]; if (lw.CertificateState == (int)VMCA.CertificateState.Active) { NSMenuItem revokeCert = new NSMenuItem ("Revoke Certificate", (object sender, EventArgs e) => { UIErrorHelper.CheckedExec (delegate() { VMCACertificateService.RevokeCertificate (cert, lw.ServerDto); NSNotificationCenter.DefaultCenter.PostNotificationName ("ReloadAll", this); }); }); menu.AddItem (revokeCert); } } if (ds is PrivateCertsListView) { cert = CertificateExtensions.GetX509Certificate2FromString ((ds as PrivateCertsListView).Entries [(int)_selectedRow].Certificate); } NSMenuItem showCert = new NSMenuItem ("Show Certificate", (object sender, EventArgs e) => { CertificateService.DisplayX509Certificate2 (this, cert); }); menu.AddItem (showCert); NSMenuItem showCertString = new NSMenuItem ("Show Certificate String", (object sender, EventArgs e) => { UIHelper.ShowGenericWindowAsSheet (VMCACertificate.GetCertificateAsString (cert), "Certificate String", VMCAAppEnvironment.Instance.MainWindow); }); menu.AddItem (showCertString); /* if (lw.CertificateState == -1) { NSMenuItem deleteString = new NSMenuItem ("Delete Certificate", (object sender, EventArgs e) => { lw.ServerDto.PrivateCertificates.RemoveAll (x => x.Certificate.Equals (cert.ToString ())); NSNotificationCenter.DefaultCenter.PostNotificationName ("ReloadTableView", this); }); menu.AddItem (deleteString); }*/ } else if (ds is CSRDetailListView) { CSRDetailListView lw = ds as CSRDetailListView; var csr = lw.Entries [(int)_selectedRow].CSR; NSMenuItem showCert = new NSMenuItem ("Show CSR", (object sender, EventArgs e) => { UIHelper.ShowGenericWindowAsSheet (csr, "CSR", VMCAAppEnvironment.Instance.MainWindow); }); menu.AddItem (showCert); } else if (ds is KeyPairDetailListView) { KeyPairDetailListView lw = ds as KeyPairDetailListView; var privateKey = lw.Entries [(int)_selectedRow].PrivateKey; var publicKey = lw.Entries [(int)_selectedRow].PublicKey; KeyPairData keyPair = new KeyPairData (privateKey, publicKey); NSMenuItem showCert = new NSMenuItem ("Export KeyPair", (object sender, EventArgs e) => { VMCAKeyPairNode.SaveKeyData (keyPair); }); menu.AddItem (showCert); } NSMenu.PopUpContextMenu (menu, theEvent, theEvent.Window.ContentView); } }); return base.MenuForEvent (theEvent); }
void SetItemValues (NSMenuItem item, CommandInfo info, bool disabledVisible) { item.SetTitleWithMnemonic (GetCleanCommandText (info)); if (!string.IsNullOrEmpty (info.Description) && item.ToolTip != info.Description) item.ToolTip = info.Description; bool enabled = info.Enabled && (!IsGloballyDisabled || commandSource == CommandSource.ContextMenu); bool visible = info.Visible && (disabledVisible || info.Enabled); item.Enabled = enabled; item.Hidden = !visible; SetAccel (item, info.AccelKey); if (info.Checked) { item.State = NSCellStateValue.On; } else if (info.CheckedInconsistent) { item.State = NSCellStateValue.Mixed; } else { item.State = NSCellStateValue.Off; } }
/// <summary> /// Processes the providers. /// </summary> private void ProcessProviders() { string[] files = Directory.GetFiles("./Providers"); for (int i = 0; i < files.Length; i++) { //Time to read them yo dynamic provider = null; try{ provider = JSON.Json.JsonDecode(File.ReadAllText(files[i])); }catch (Exception ex) { #if DEBUG Console.WriteLine(ex); #endif return; } if (!provider.ContainsKey("RequestType") || !provider.ContainsKey("Name") || !provider.ContainsKey("RequestURL")) { continue; } if (provider ["RequestType"] == "POST") { if (provider.ContainsKey("FileFormName")) { //Fullscreen button NSMenuItem provFull = new NSMenuItem(provider ["Name"]); provFull.Activated += (object sender, EventArgs e) => { ProviderUpload(provider); }; //Region button NSMenuItem provRegion = new NSMenuItem(provider ["Name"]); provRegion.Activated += (object sender, EventArgs e) => { ProviderUpload(provider, true); }; NSMenuItem provWindow = new NSMenuItem(provider ["Name"]); provWindow.Activated += (object sender, EventArgs e) => { ProviderUpload(provider, false, true); }; //Add buttons if (!fullScreenshot.HasSubmenu) { fullScreenshot.Submenu = new NSMenu(); } fullScreenshot.Submenu.AddItem(provFull); if (!regionScreenshot.HasSubmenu) { regionScreenshot.Submenu = new NSMenu(); } regionScreenshot.Submenu.AddItem(provRegion); if (!windowScreenshot.HasSubmenu) { windowScreenshot.Submenu = new NSMenu(); } windowScreenshot.Submenu.AddItem(provWindow); } else { NSMenuItem tool = new NSMenuItem(provider ["Name"]); tool.Activated += (object sender, EventArgs e) => { ProviderPost(provider); }; if (!toolsItem.HasSubmenu) { toolsItem.Submenu = new NSMenu(); } toolsItem.Submenu.AddItem(tool); } } else if (provider ["RequestType"] == "GET") { NSMenuItem tool = new NSMenuItem(provider["Name"]); tool.Activated += (object sender, EventArgs e) => { ProviderGet(provider); }; if (!toolsItem.HasSubmenu) { toolsItem.Submenu = new NSMenu(); } toolsItem.Submenu.AddItem(tool); } } }
public SessionToolbarDelegate( ClientSession clientSession, MacClientSessionViewControllers viewControllers, NSToolbar toolbar) { if (clientSession == null) { throw new ArgumentNullException(nameof(clientSession)); } if (viewControllers == null) { throw new ArgumentNullException(nameof(viewControllers)); } if (toolbar == null) { throw new ArgumentNullException(nameof(toolbar)); } allowedItemIdentifiers = clientSession.SessionKind == ClientSessionKind.LiveInspection ? Identifiers.InspectorDefault : Identifiers.WorkbooksDefault; this.toolbar = toolbar; toolbar.Delegate = this; runAllItem = CreateButton( Identifiers.RunAll, "runAllSubmissions:", Catalog.GetString("Run All"), Catalog.GetString("Run the whole workbook from top to bottom"), "ToolbarRunTemplate"); refreshItem = CreateButton( Identifiers.Refresh, "refreshVisualTree:", Catalog.GetString("Refresh"), Catalog.GetString("Refresh the application's visual tree in Inspector"), "ToolbarRefreshTemplate"); inspectItem = CreateButton( Identifiers.Inspect, "inspectView:", Catalog.GetString("Inspect"), Catalog.GetString("Select a UI element to inspect in the running application"), "ToolbarInspectTemplate"); var targetSelector = new WorkbookTargetSelector( clientSession.ViewControllers.WorkbookTargets) { Font = NSFont.SystemFontOfSize(NSFont.SmallSystemFontSize) }; var targetSelectorItemMenu = new NSMenuItem(Catalog.GetString("Target")); targetSelectorItemMenu.Submenu = targetSelector.Menu; targetSelectorItem = new NSToolbarItem(Identifiers.TargetSelector) { View = targetSelector, MinSize = targetSelector.Frame.Size, MaxSize = targetSelector.Frame.Size, VisibilityPriority = -1000, MenuFormRepresentation = targetSelectorItemMenu }; targetSelector.Activated += (sender, e) => { var size = targetSelector.GetToolbarSize(); targetSelectorItem.MinSize = size; targetSelectorItem.MaxSize = size; centeringItem.UpdateWidth(); viewControllers.WindowTabs.SelectedTabViewItemIndex = 0; }; centeringItem = new CenteringToolbarItem(Identifiers.CenteringSpacer); statusItem = new StatusToolbarItem { View = viewControllers.Status.View }; tabViewItem = new NSToolbarItem(Identifiers.TabView) { PaletteLabel = Catalog.GetString("Views") }; tabViewItem.View = viewControllers.WindowTabs.ToolbarSegmentedControl; viewControllers.WindowTabs.ItemSelected += (sender, e) => { switch (viewControllers.WindowTabs.SelectedTabViewItemIndex) { case 0: RemoveItem(Identifiers.Inspect); RemoveItem(Identifiers.Refresh); if (clientSession.SessionKind != ClientSessionKind.LiveInspection) { toolbar.InsertItem(Identifiers.RunAll, 0); } ((XcbWorkbookPageView)clientSession.EvaluationService).DelayNewCodeCellFocus = false; break; case 1: RemoveItem(Identifiers.RunAll); toolbar.InsertItem(Identifiers.Inspect, 0); toolbar.InsertItem(Identifiers.Refresh, 0); ((XcbWorkbookPageView)clientSession.EvaluationService).DelayNewCodeCellFocus = true; break; } centeringItem.UpdateWidth(); }; NSWindow.Notifications.ObserveDidResize((sender, e) => { statusItem.UpdateSize(e.Notification.Object as NSWindow); centeringItem.UpdateWidth(); }); }
public void CreateMenu() { using (NSAutoreleasePool a = new NSAutoreleasePool()) { this.menu = new NSMenu(); this.menu.AutoEnablesItems = false; this.state_item = new NSMenuItem() { Title = Controller.StateText, Enabled = false }; this.folder_item = new NSMenuItem() { Title = "CmisSync" }; this.folder_item.Activated += delegate { Controller.CmisSyncClicked(); }; this.folder_item.Image = this.cmissync_image; this.folder_item.Image.Size = new SizeF(16, 16); this.folder_item.Enabled = true; this.add_item = new NSMenuItem() { Title = "Add Hosted Project…", Enabled = true }; this.add_item.Activated += delegate { Controller.AddHostedProjectClicked(); }; this.recent_events_item = new NSMenuItem() { Title = "Recent Changes…", Enabled = Controller.OpenRecentEventsItemEnabled }; if (Controller.Folders.Length > 0) { this.recent_events_item.Activated += delegate { Controller.OpenRecentEventsClicked(); }; } this.notify_item = new NSMenuItem() { Enabled = (Controller.Folders.Length > 0) }; if (Program.Controller.NotificationsEnabled) { this.notify_item.Title = "Turn Notifications Off"; } else { this.notify_item.Title = "Turn Notifications On"; } this.notify_item.Activated += delegate { Program.Controller.ToggleNotifications(); InvokeOnMainThread(delegate { if (Program.Controller.NotificationsEnabled) { this.notify_item.Title = "Turn Notifications Off"; } else { this.notify_item.Title = "Turn Notifications On"; } }); }; this.about_item = new NSMenuItem() { Title = "About CmisSync", Enabled = true }; this.about_item.Activated += delegate { Controller.AboutClicked(); }; this.quit_item = new NSMenuItem() { Title = "Quit", Enabled = Controller.QuitItemEnabled }; this.quit_item.Activated += delegate { Controller.QuitClicked(); }; this.menu.AddItem(this.state_item); this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.folder_item); this.folder_menu_items = new NSMenuItem [Controller.Folders.Length]; this.submenu_items = new NSMenuItem [Controller.OverflowFolders.Length]; if (Controller.Folders.Length > 0) { this.folder_tasks = new EventHandler [Controller.Folders.Length]; this.overflow_tasks = new EventHandler [Controller.OverflowFolders.Length]; int i = 0; foreach (string folder_name in Controller.Folders) { NSMenuItem item = new NSMenuItem(); item.Title = folder_name; if (Program.Controller.UnsyncedFolders.Contains(folder_name)) { item.Image = this.caution_image; } else { item.Image = this.folder_image; } item.Image.Size = new SizeF(16, 16); this.folder_tasks [i] = OpenFolderDelegate(folder_name); this.folder_menu_items [i] = item; this.folder_menu_items [i].Activated += this.folder_tasks [i]; i++; } ; i = 0; foreach (string folder_name in Controller.OverflowFolders) { NSMenuItem item = new NSMenuItem(); item.Title = folder_name; if (Program.Controller.UnsyncedFolders.Contains(folder_name)) { item.Image = this.caution_image; } else { item.Image = this.folder_image; } item.Image.Size = new SizeF(16, 16); this.overflow_tasks [i] = OpenFolderDelegate(folder_name); this.submenu_items [i] = item; this.submenu_items [i].Activated += this.overflow_tasks [i]; i++; } ; } foreach (NSMenuItem item in this.folder_menu_items) { this.menu.AddItem(item); } if (this.submenu_items.Length > 0) { this.submenu = new NSMenu(); foreach (NSMenuItem item in this.submenu_items) { this.submenu.AddItem(item); } this.more_item = new NSMenuItem() { Title = "More Projects", Submenu = this.submenu }; this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.more_item); } this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.add_item); this.menu.AddItem(this.recent_events_item); this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.notify_item); this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.about_item); this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.quit_item); this.menu.Delegate = new StatusIconMenuDelegate(); this.status_item.Menu = this.menu; } }
public void OpenSDCard(NSMenuItem menuItem) { if (Process.keyset?.SdSeed?.All(b => b == 0) ?? true) { string error = "sd_seed is missing from Console Keys"; Process.log?.WriteLine(error); var alert = new NSAlert() { InformativeText = String.Format("{0}.\nOpen SD Card will not be available.", error), MessageText = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(), }; alert.RunModal(); return; } if ((Process.keyset?.SdCardKekSource?.All(b => b == 0) ?? true) || (Process.keyset?.SdCardKeySources?[1]?.All(b => b == 0) ?? true)) { Process.log?.WriteLine("Keyfile missing required keys"); Process.log?.WriteLine(" - {0} ({1}exists)", "sd_card_kek_source", (bool)Process.keyset?.SdCardKekSource?.Any(b => b != 0) ? "" : "not "); Process.log?.WriteLine(" - {0} ({1}exists)", "sd_card_nca_key_source", (bool)Process.keyset?.SdCardKeySources?[1]?.Any(b => b != 0) ? "" : "not "); var alert = new NSAlert() { InformativeText = "sd_card_kek_source and sd_card_nca_key_source are missing from Keyfile.\nOpen SD Card will not be available.", MessageText = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(), }; alert.RunModal(); return; } if (backgroundWorker.IsBusy) { var alert = new NSAlert() { InformativeText = "Please wait until the current process is finished and try again.", MessageText = NSBundle.MainBundle.ObjectForInfoDictionary("CFBundleExecutable").ToString(), }; alert.RunModal(); return; } NSOpenPanel openPanel = NSOpenPanel.OpenPanel; openPanel.CanChooseFiles = false; openPanel.CanChooseDirectories = true; openPanel.DirectoryUrl = new NSUrl(!String.IsNullOrEmpty(Common.Settings.Default.SDCardDirectory) && Directory.Exists(Common.Settings.Default.SDCardDirectory) ? Common.Settings.Default.SDCardDirectory : Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)); openPanel.Title = "Open SD Card"; Process.log?.WriteLine("\nOpen SD Card"); openPanel.BeginSheet(Window, (nint result) => { if (result == (int)NSModalResponse.OK) { tableViewDataSource.Titles.Clear(); tableView.ReloadData(); Common.Settings.Default.SDCardDirectory = openPanel.Urls.First().Path; Common.Settings.Default.Save(); title.StringValue = String.Format("Opening SD card on {0}", openPanel.Urls.First().Path); message.StringValue = ""; progress.DoubleValue = 0; Process.log?.WriteLine("SD card selected"); Window.BeginSheet(sheet, ProgressComplete); backgroundWorker.RunWorkerAsync(openPanel.Urls.First().Path); } }); }
public void CreateMenu() { using (NSAutoreleasePool a = new NSAutoreleasePool()) { StatusItem.Image = AnimationFrames [0]; StatusItem.AlternateImage = AnimationFramesActive [0]; StatusItem.Image.Size = new SizeF(16, 16); StatusItem.AlternateImage.Size = new SizeF(16, 16); Menu = new NSMenu(); Menu.AutoEnablesItems = false; StateMenuItem = new NSMenuItem() { Title = StateText, Enabled = false }; Menu.AddItem(StateMenuItem); Menu.AddItem(NSMenuItem.SeparatorItem); FolderMenuItem = new NSMenuItem() { Title = "SparkleShare" }; FolderMenuItem.Activated += delegate { Program.Controller.OpenSparkleShareFolder(); }; FolderMenuItem.Image = SparkleShareImage; FolderMenuItem.Image.Size = new SizeF(16, 16); FolderMenuItem.Enabled = true; Menu.AddItem(FolderMenuItem); FolderMenuItems = new NSMenuItem [Program.Controller.Folders.Count]; if (Controller.Folders.Length > 0) { Tasks = new EventHandler [Program.Controller.Folders.Count]; int i = 0; foreach (string folder_name in Program.Controller.Folders) { NSMenuItem item = new NSMenuItem(); item.Title = folder_name; if (Program.Controller.UnsyncedFolders.Contains(folder_name)) { item.Image = CautionImage; } else { item.Image = FolderImage; } item.Image.Size = new SizeF(16, 16); Tasks [i] = OpenFolderDelegate(folder_name); FolderMenuItems [i] = item; FolderMenuItems [i].Activated += Tasks [i]; FolderMenuItem.Enabled = true; i++; } ; } else { FolderMenuItems = new NSMenuItem [1]; FolderMenuItems [0] = new NSMenuItem() { Title = "No projects yet", Enabled = false }; } foreach (NSMenuItem item in FolderMenuItems) { Menu.AddItem(item); } Menu.AddItem(NSMenuItem.SeparatorItem); SyncMenuItem = new NSMenuItem() { Title = "Add Hosted Project…", Enabled = true }; if (!Program.Controller.FirstRun) { SyncMenuItem.Activated += delegate { InvokeOnMainThread(delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); if (SparkleUI.Setup == null) { SparkleUI.Setup = new SparkleSetup(); SparkleUI.Setup.Controller.ShowAddPage(); } if (!SparkleUI.Setup.IsVisible) { SparkleUI.Setup.Controller.ShowAddPage(); } SparkleUI.Setup.OrderFrontRegardless(); SparkleUI.Setup.MakeKeyAndOrderFront(this); }); }; } Menu.AddItem(SyncMenuItem); Menu.AddItem(NSMenuItem.SeparatorItem); RecentEventsMenuItem = new NSMenuItem() { Title = "Open Recent Events", Enabled = true }; if (Controller.Folders.Length > 0) { RecentEventsMenuItem.Activated += delegate { InvokeOnMainThread(delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); if (SparkleUI.EventLog == null) { SparkleUI.EventLog = new SparkleEventLog(); } SparkleUI.EventLog.OrderFrontRegardless(); SparkleUI.EventLog.MakeKeyAndOrderFront(this); }); }; } Menu.AddItem(RecentEventsMenuItem); NotificationsMenuItem = new NSMenuItem() { Enabled = true }; if (Program.Controller.NotificationsEnabled) { NotificationsMenuItem.Title = "Turn Notifications Off"; } else { NotificationsMenuItem.Title = "Turn Notifications On"; } NotificationsMenuItem.Activated += delegate { Program.Controller.ToggleNotifications(); InvokeOnMainThread(delegate { if (Program.Controller.NotificationsEnabled) { NotificationsMenuItem.Title = "Turn Notifications Off"; } else { NotificationsMenuItem.Title = "Turn Notifications On"; } }); }; Menu.AddItem(NotificationsMenuItem); Menu.AddItem(NSMenuItem.SeparatorItem); AboutMenuItem = new NSMenuItem() { Title = "About SparkleShare", Enabled = true }; AboutMenuItem.Activated += delegate { InvokeOnMainThread(delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); if (SparkleUI.About == null) { SparkleUI.About = new SparkleAbout(); } else { SparkleUI.About.OrderFrontRegardless(); } }); }; Menu.AddItem(AboutMenuItem); StatusItem.Menu = Menu; StatusItem.Menu.Update(); } }
public override void MouseDown(NSEvent theEvent) { if (!Enabled) { return; } var locationInView = ConvertPointFromView(theEvent.LocationInWindow, null); var cellIdx = IndexOfCellAtX(locationInView.X); if (cellIdx == -1) { return; } var item = Cells [cellIdx]; if (item == null || !item.Enabled) { return; } var componentRect = ((NSPathCell)Cell).GetRect(item, Frame, this); int i = 0; NSMenuItem selectedItem = null; var menu = new NSMenu { AutoEnablesItems = false, ShowsStateColumn = false, Font = NSFont.MenuFontOfSize(12), }; if (cellIdx == RunConfigurationIdx) { if (ActiveRunConfiguration == null) { return; } foreach (var configuration in RunConfigurationModel) { var _configuration = configuration; var menuitem = new NSMenuItem(configuration.DisplayString, (o2, e2) => { ActiveRunConfiguration = runConfigurationModel.First(c => c.OriginalId == _configuration.OriginalId); }) { Enabled = true, IndentationLevel = 1, }; menu.AddItem(menuitem); if (selectedItem == null && configuration.OriginalId == ActiveRunConfiguration.OriginalId) { selectedItem = menuitem; } } } else if (cellIdx == ConfigurationIdx) { if (ActiveConfiguration == null) { return; } foreach (var configuration in ConfigurationModel) { var _configuration = configuration; var menuitem = new NSMenuItem(configuration.DisplayString, (o2, e2) => { ActiveConfiguration = configurationModel.First(c => c.OriginalId == _configuration.OriginalId); }) { Enabled = true, IndentationLevel = 1, }; menu.AddItem(menuitem); if (selectedItem == null && configuration.OriginalId == ActiveConfiguration.OriginalId) { selectedItem = menuitem; } } } else if (cellIdx == RuntimeIdx) { if (ActiveRuntime == null) { return; } using (var activeMutableModel = ActiveRuntime.GetMutableModel()) { foreach (var runtime in RuntimeModel) { if (runtime.HasParent) { continue; } NSMenuItem menuitem = null; if (runtime.IsSeparator) { menu.AddItem(NSMenuItem.SeparatorItem); } else { menuitem = CreateMenuItem(menu, runtime); } using (var mutableModel = runtime.GetMutableModel()) { if (selectedItem == null && menuitem != null && mutableModel.DisplayString == activeMutableModel.DisplayString) { selectedItem = menuitem; } } ++i; } } } else { throw new NotSupportedException(); } if (menu.Count > 1) { var offs = new CGPoint(componentRect.Left + 3, componentRect.Top + 3); if (Window?.Screen?.BackingScaleFactor == 2) { offs.Y += 0.5f; // fine tune menu position on retinas } menu.PopUpMenu(selectedItem, offs, this); } }
public static void Main(string[] args) { MaxOpenFiles(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.ApplicationExit += (object sender, EventArgs e) => { //UrlProtocol.Unregister(); }; //UrlProtocol.Register(); //Marshalling.Initialize(); //CefApp. var menuBar = new NSMenu(""); var appMenuItem = new NSMenuItem(""); var appMenu = new NSMenu("FormsTest"); var quitItem = new NSMenuItem("Quit") { KeyEquivalent = "q" }; quitItem.Activated += (sender, e) => { Terminate(); }; appMenu.AddItem(quitItem); menuBar.AddItem(appMenuItem); menuBar.SetSubmenu(appMenu, appMenuItem); var editMenuItem = new NSMenuItem(); var editMenu = new NSMenu("Edit"); var selectAllItem = new NSMenuItem("Select All") { Action = new ObjCRuntime.Selector("selectAll:"), KeyEquivalent = "a" }; editMenu.AddItem(selectAllItem); var copyItem = new NSMenuItem("Copy") { Action = new ObjCRuntime.Selector("copy:"), KeyEquivalent = "c" }; editMenu.AddItem(copyItem); var pasteItem = new NSMenuItem("Paste") { Action = new ObjCRuntime.Selector("paste:"), KeyEquivalent = "v" }; editMenu.AddItem(pasteItem); menuBar.AddItem(editMenuItem); menuBar.SetSubmenu(editMenu, editMenuItem); NSApplication.SharedApplication.Menu = menuBar; var f = new MainForm(); f.Show(); Application.Run(); var threads = Process.GetCurrentProcess().Threads; Terminate(); }
//strongly typed window accessor public override void AwakeFromNib() { // add the searchMenu to this control, allowing recent searches to be added. // // note that we could build this menu inside our nib, but for clarity we're // building the menu in code to illustrate the use of tags: // NSSearchFieldRecentsTitleMenuItemTag, NSSearchFieldNoRecentsMenuItemTag, etc. // if (searchField.RespondsToSelector(new Selector("setRecentSearches:"))) { NSMenu searchMenu = new NSMenu("Search Menu") { AutoEnablesItems = true }; var item = new NSMenuItem("Custom", "", (o, e) => actionMenuItem()); searchMenu.InsertItem(item, 0); var separator = NSMenuItem.SeparatorItem; searchMenu.InsertItem(separator, 1); var recentsTitleItem = new NSMenuItem("Recent Searches", ""); // tag this menu item so NSSearchField can use it and respond to it appropriately recentsTitleItem.Tag = NSSearchFieldRecentsTitleMenuItemTag; searchMenu.InsertItem(recentsTitleItem, 2); var norecentsTitleItem = new NSMenuItem("No recent searches", ""); // tag this menu item so NSSearchField can use it and respond to it appropriately norecentsTitleItem.Tag = NSSearchFieldNoRecentsMenuItemTag; searchMenu.InsertItem(norecentsTitleItem, 3); var recentsItem = new NSMenuItem("Recents", ""); // tag this menu item so NSSearchField can use it and respond to it appropriately recentsItem.Tag = NSSearchFieldRecentsMenuItemTag; searchMenu.InsertItem(recentsItem, 4); var separatorItem = NSMenuItem.SeparatorItem; // tag this menu item so NSSearchField can use it, by hiding/show it appropriately: separatorItem.Tag = NSSearchFieldRecentsTitleMenuItemTag; searchMenu.InsertItem(separatorItem, 5); var clearItem = new NSMenuItem("Clear", ""); // tag this menu item so NSSearchField can use it clearItem.Tag = NSSearchFieldClearRecentsMenuItemTag; searchMenu.InsertItem(clearItem, 6); var searchCell = searchField.Cell; searchCell.MaximumRecents = 20; searchCell.SearchMenuTemplate = searchMenu; // with lamda //searchField.ControlTextDidChange += (o,e) => controlTextDidChange((NSNotification)o); // or delegate searchField.Changed += delegate(object sender, EventArgs e) { handleTextDidChange((NSNotification)sender); }; searchField.DoCommandBySelector = handleCommandSelectors; searchField.GetCompletions = handleFilterCompletions; } // build the list of keyword strings for our type completion dropdown list in NSSearchField builtInKeywords = new List <string>() { "Favorite", "Favorite1", "Favorite11", "Favorite3", "Vacations1", "Vacations2", "Hawaii", "Family", "Important", "Important2", "Personal" }; }
// Creates the menu that is popped up when the // user clicks the status icon public void CreateMenu() { Menu = new NSMenu(); StateMenuItem = new NSMenuItem() { Title = StateText }; Menu.AddItem(StateMenuItem); Menu.AddItem(NSMenuItem.SeparatorItem); FolderMenuItem = new NSMenuItem() { Title = "SparkleShare" }; FolderMenuItem.Activated += delegate { SparkleShare.Controller.OpenSparkleShareFolder(); }; string folder_icon_path = Path.Combine(NSBundle.MainBundle.ResourcePath, "sparkleshare-mac.icns"); FolderMenuItem.Image = new NSImage(folder_icon_path); FolderMenuItem.Image.Size = new SizeF(16, 16); Menu.AddItem(FolderMenuItem); if (SparkleShare.Controller.Folders.Count > 0) { FolderMenuItems = new NSMenuItem [SparkleShare.Controller.Folders.Count]; Tasks = new EventHandler [SparkleShare.Controller.Folders.Count]; int i = 0; foreach (string path in SparkleShare.Controller.Folders) { // TODO // if (repo.HasUnsyncedChanges) // folder_action.IconName = "dialog-error"; NSMenuItem item = new NSMenuItem(); item.Title = System.IO.Path.GetFileName(path); item.Image = NSImage.ImageNamed("NSFolder"); item.Image.Size = new SizeF(16, 16); Tasks [i] = OpenEventLogDelegate(path); FolderMenuItems [i] = item; FolderMenuItems [i].Activated += Tasks [i]; Menu.AddItem(FolderMenuItems [i]); i++; } ; } else { FolderMenuItems = new NSMenuItem [1]; FolderMenuItems [0] = new NSMenuItem() { Title = "No Remote Folders Yet" }; Menu.AddItem(FolderMenuItems [0]); } Menu.AddItem(NSMenuItem.SeparatorItem); SyncMenuItem = new NSMenuItem() { Title = "Add Remote Folder…" }; if (!SparkleShare.Controller.FirstRun) { SyncMenuItem.Activated += delegate { InvokeOnMainThread(delegate { NSApplication.SharedApplication.ActivateIgnoringOtherApps(true); if (SparkleUI.Intro == null) { SparkleUI.Intro = new SparkleIntro(); SparkleUI.Intro.ShowServerForm(true); } if (!SparkleUI.Intro.IsVisible) { SparkleUI.Intro.ShowServerForm(true); } SparkleUI.Intro.OrderFrontRegardless(); SparkleUI.Intro.MakeKeyAndOrderFront(this); }); }; } Menu.AddItem(SyncMenuItem); Menu.AddItem(NSMenuItem.SeparatorItem); NotificationsMenuItem = new NSMenuItem(); if (SparkleShare.Controller.NotificationsEnabled) { NotificationsMenuItem.Title = "Turn Notifications Off"; } else { NotificationsMenuItem.Title = "Turn Notifications On"; } NotificationsMenuItem.Activated += delegate { SparkleShare.Controller.ToggleNotifications(); InvokeOnMainThread(delegate { if (SparkleShare.Controller.NotificationsEnabled) { NotificationsMenuItem.Title = "Turn Notifications Off"; } else { NotificationsMenuItem.Title = "Turn Notifications On"; } }); }; Menu.AddItem(NotificationsMenuItem); StatusItem.Menu = Menu; StatusItem.Menu.Update(); }
void CreateMenuItem (NSMenu menu, IRuntimeModel runtime) { NSMenuItem menuItem; string runtimeFullDisplayString; using (var mutableModel = runtime.GetMutableModel ()) { runtimeFullDisplayString = mutableModel.FullDisplayString; menuItem = new NSMenuItem { IndentationLevel = runtime.IsIndented ? 2 : 1, AttributedTitle = new NSAttributedString (mutableModel.DisplayString, new NSStringAttributes { Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont (menu.Font, NSFontTraitMask.Bold) : menu.Font, }), Enabled = mutableModel.Enabled, Hidden = !mutableModel.Visible, }; } var subMenu = CreateSubMenuForRuntime (runtime); if (subMenu != null) { menuItem.Submenu = subMenu; menuItem.Enabled = true; } else { menuItem.Activated += (o2, e2) => { string old; using (var activeMutableModel = ActiveRuntime.GetMutableModel ()) old = activeMutableModel.FullDisplayString; IRuntimeModel newRuntime = runtimeModel.FirstOrDefault (r => { using (var newRuntimeMutableModel = r.GetMutableModel ()) return newRuntimeMutableModel.FullDisplayString == runtimeFullDisplayString; }); if (newRuntime == null) return; ActiveRuntime = newRuntime; var ea = new HandledEventArgs (); if (RuntimeChanged != null) RuntimeChanged (o2, ea); if (ea.Handled) ActiveRuntime = runtimeModel.First (r => { using (var newRuntimeMutableModel = r.GetMutableModel ()) return newRuntimeMutableModel.FullDisplayString == old; }); }; } menu.AddItem (menuItem); }
public static string BindState(this NSMenuItem nsMenuItem) => MvxMacPropertyBinding.NSMenuItem_State;
public override NSMenuItem[] UIGetContextMenuItems (WebView sender, NSDictionary forElement, NSMenuItem[] defaultMenuItems) { return null; }
public MenuItemBackend(NSMenuItem item) { this.item = item; }
void CreateMenuItem (NSMenu menu, IRuntimeModel runtime) { var menuItem = new NSMenuItem { IndentationLevel = runtime.IsIndented ? 2 : 1, Enabled = runtime.Enabled, Hidden = !runtime.Visible, AttributedTitle = new NSAttributedString (runtime.DisplayString, new NSStringAttributes { Font = runtime.Notable ? NSFontManager.SharedFontManager.ConvertFont (menu.Font, NSFontTraitMask.Bold) : menu.Font, }), }; var subMenu = CreateSubMenuForRuntime (runtime); if (subMenu != null) { menuItem.Submenu = subMenu; menuItem.Enabled = true; } else { menuItem.Activated += (o2, e2) => { string old = ActiveRuntime.FullDisplayString; ActiveRuntime = runtimeModel.First (r => r.FullDisplayString == runtime.FullDisplayString); var ea = new HandledEventArgs (); if (RuntimeChanged != null) RuntimeChanged (o2, ea); if (ea.Handled) ActiveRuntime = runtimeModel.First (r => r.FullDisplayString == old); }; } menu.AddItem (menuItem); }
public override void FinishedLaunching(NSObject notification) { // Configure logger string path = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "log4net.config"); XmlConfigurator.ConfigureAndWatch(new FileInfo(path)); logger.Info("Ventriliquest 1.0 Starting up..."); // Get list of available audio out devices xamspeech ham = new xamspeech(); OutputDevices = ham.GetDevices(); // Setup UI statusMenu = new NSMenu(); statusItem = NSStatusBar.SystemStatusBar.CreateStatusItem(30); var outputItem = new NSMenuItem("Output Device", (a, b) => { }); var deviceList = new NSMenu(); outputItem.Submenu = deviceList; OutputDeviceUID = "Built-in Output"; foreach (var entry in OutputDevices) { var test = new NSMenuItem(entry.Key.ToString(), (a, b) => { foreach (NSMenuItem item in deviceList.ItemArray()) { item.State = NSCellStateValue.Off; } NSMenuItem theItem = (NSMenuItem)a; theItem.State = NSCellStateValue.On; config.OutputDevice = theItem.Title; foreach (var e in OutputDevices) { if (e.Key.ToString().Equals(theItem.Title)) { OutputDeviceUID = e.Value.ToString(); } } }); if (entry.Key.ToString().Equals(config.OutputDevice)) { test.State = NSCellStateValue.On; OutputDeviceUID = entry.Value.ToString(); } deviceList.AddItem(test); } var daItem = new NSMenuItem("Local Connections Only", (a, b) => { NSMenuItem theItem = (NSMenuItem)a; if (theItem.State == NSCellStateValue.On) { config.LocalOnly = false; theItem.State = NSCellStateValue.Off; } else { config.LocalOnly = true; theItem.State = NSCellStateValue.On; } }); if (config.LocalOnly) { daItem.State = NSCellStateValue.On; } var quitItem = new NSMenuItem("Quit", (a, b) => Shutdown()); var voiceconfigItem = new NSMenuItem("Voice Configuration", (a, b) => Process.Start("http://127.0.0.1:7888/config")); statusMenu.AddItem(new NSMenuItem("Version: 1.1")); statusMenu.AddItem(outputItem); statusMenu.AddItem(daItem); statusMenu.AddItem(voiceconfigItem); statusMenu.AddItem(quitItem); statusItem.Menu = statusMenu; statusItem.Image = NSImage.ImageNamed("tts-1.png"); statusItem.AlternateImage = NSImage.ImageNamed("tts-2.png"); statusItem.HighlightMode = true; speechdelegate.DidComplete += delegate { synthesis.Set(); }; sounddelegate.DidComplete += delegate { playback.Set(); IsSounding = false; IsSpeaking = false; sound.Dispose(); }; speech.Delegate = speechdelegate; queuetimer = new System.Timers.Timer(250); queuetimer.Elapsed += (object sender, ElapsedEventArgs e) => { TTSRequest r; if (Queue.TryDequeue(out r)) { if (r.Interrupt) { // stop current TTS NSApplication.SharedApplication.InvokeOnMainThread(delegate { if (IsSpeaking) { speech.StopSpeaking(); } if (IsSounding) { sound.Stop(); } }); // clear queue SpeechQueue.Clear(); } if (!r.Reset) { SpeechQueue.Enqueue(r); } RequestCount++; } var eventdata = new Hashtable(); eventdata.Add("ProcessedRequests", RequestCount); eventdata.Add("QueuedRequests", SpeechQueue.Count); eventdata.Add("IsSpeaking", IsSpeaking); InstrumentationEvent ev = new InstrumentationEvent(); ev.EventName = "status"; ev.Data = eventdata; NotifyGui(ev.EventMessage()); }; // when this timer fires, it will pull off of the speech queue and speak it // the 1000ms delay also adds a little pause between tts requests. speechtimer = new System.Timers.Timer(250); speechtimer.Elapsed += (object sender, ElapsedEventArgs e) => { if (IsSpeaking.Equals(false)) { if (SpeechQueue.Count > 0) { TTSRequest r = SpeechQueue.Dequeue(); IsSpeaking = true; speechtimer.Enabled = false; var oink = Path.Combine(audiopath, "temp.aiff"); NSApplication.SharedApplication.InvokeOnMainThread(delegate { ConfigureSpeechEngine(r); speech.StartSpeakingStringtoURL(r.Text, new NSUrl(oink, false)); }); synthesis.WaitOne(); NSApplication.SharedApplication.InvokeOnMainThread(delegate { IsSounding = true; sound = new NSSound(Path.Combine(audiopath, "temp.aiff"), false); sound.Delegate = sounddelegate; //if(OutputDeviceUID != "Default") { sound.PlaybackDeviceID = OutputDeviceUID; //} sound.Play(); }); playback.WaitOne(); IsSounding = false; speechtimer.Enabled = true; } } }; queuetimer.Enabled = true; queuetimer.Start(); speechtimer.Enabled = true; speechtimer.Start(); InitHTTPServer(); }
void PopulateArrayItems (CommandArrayInfo infos, NSMenu parent, ref NSMenuItem lastSeparator, ref int index) { if (infos == null) return; foreach (CommandInfo ci in infos) { if (ci.IsArraySeparator) { var n = NSMenuItem.SeparatorItem; n.Hidden = true; n.Target = this; lastSeparator = n; parent.InsertItem (n, index++); continue; } var item = new MDExpandedArrayItem { Info = ci, Target = this, Action = ActionSel, }; if (ci is CommandInfoSet) { item.Submenu = new NSMenu (); int i = 0; NSMenuItem sep = null; PopulateArrayItems (((CommandInfoSet)ci).CommandInfos, item.Submenu, ref sep, ref i); } SetItemValues (item, ci, true); if (!item.Hidden) MDMenu.ShowLastSeparator (ref lastSeparator); parent.InsertItem (item, index++); } }
public override void WillFinishLaunching(NSNotification notification) { MenuManager = new MenuManager(NSApplication.SharedApplication.MainMenu); if (ClientInfo.Flavor != ClientFlavor.Inspector) { ClientApp.SharedInstance.Updater.CheckForUpdatesPeriodicallyInBackground( update => UpdateHandler(null, update)); } var helpMenu = NSApplication.SharedApplication.HelpMenu; var appMenu = NSApplication.SharedApplication.MainMenu.ItemArray() [0].Submenu; if (ClientInfo.Flavor == ClientFlavor.Inspector) { // Update menu items in app/help menus foreach (var item in appMenu.ItemArray().Concat(helpMenu.ItemArray())) { item.Title = item.Title.Replace("Workbooks", "Inspector"); } applicationShouldOpenUntitledFile = false; } else { var checkForUpdatesMenuItem = new NSMenuItem( Catalog.GetString("Check for Updates…"), new Selector("checkForUpdates:"), string.Empty); appMenu.InsertItem(checkForUpdatesMenuItem, 1); var enableTerminalUsageMenuItem = new NSMenuItem( Catalog.GetString("Enable Terminal Usage…"), new Selector("installCommandLineTool:"), string.Empty); appMenu.InsertItem(enableTerminalUsageMenuItem, 2); var sampleWorkbooksMenuItem = new NSMenuItem(Catalog.GetString("Tutorials")); sampleWorkbooksMenuItem.Submenu = new NSMenu(); helpMenu.InsertItem(sampleWorkbooksMenuItem, 0); var workbookFiles = new FilePath(NSBundle.MainBundle.ResourcePath) .Combine("Workbooks") .EnumerateFiles("*.workbook", SearchOption.TopDirectoryOnly); foreach (var workbookFile in workbookFiles) { sampleWorkbooksMenuItem.Submenu.AddItem(new NSMenuItem( workbookFile.NameWithoutExtension, (sender, e) => NSWorkspace.SharedWorkspace.OpenFile(workbookFile))); } sampleWorkbooksMenuItem.Submenu.AddItem(NSMenuItem.SeparatorItem); sampleWorkbooksMenuItem.Submenu.AddItem(new NSMenuItem( ClientInfo.DownloadWorkbooksMenuLabel, (sender, e) => NSWorkspace.SharedWorkspace.OpenUrl( ClientInfo.DownloadWorkbooksUri))); } if (CommandLineTool.TestDriver.ShouldRun) { CommandLineTool.TestDriver.Run(NSApplication.SharedApplication.InvokeOnMainThread); } new SessionDocumentController(); }
static void SetAccel (NSMenuItem item, string accelKey) { uint modeKey; Gdk.ModifierType modeMod; uint key; Gdk.ModifierType mod; if (!KeyBindingManager.BindingToKeys (accelKey, out modeKey, out modeMod, out key, out mod)) { item.KeyEquivalent = ""; item.KeyEquivalentModifierMask = (NSEventModifierMask) 0; return; } if (modeKey != 0) { LoggingService.LogWarning ("Mac menu cannot display accelerators with mode keys ({0})", accelKey); item.KeyEquivalent = ""; item.KeyEquivalentModifierMask = (NSEventModifierMask) 0; return; } var keyEq = GetKeyEquivalent ((Gdk.Key) key); item.KeyEquivalent = keyEq; if (keyEq.Length == 0) { item.KeyEquivalentModifierMask = 0; } NSEventModifierMask outMod = 0; if ((mod & Gdk.ModifierType.Mod1Mask) != 0) { outMod |= NSEventModifierMask.AlternateKeyMask; mod ^= Gdk.ModifierType.Mod1Mask; } if ((mod & Gdk.ModifierType.ShiftMask) != 0) { outMod |= NSEventModifierMask.ShiftKeyMask; mod ^= Gdk.ModifierType.ShiftMask; } if ((mod & Gdk.ModifierType.ControlMask) != 0) { outMod |= NSEventModifierMask.ControlKeyMask; mod ^= Gdk.ModifierType.ControlMask; } if ((mod & Gdk.ModifierType.MetaMask) != 0) { outMod |= NSEventModifierMask.CommandKeyMask; mod ^= Gdk.ModifierType.MetaMask; } if (mod != 0) { LoggingService.LogWarning ("Mac menu cannot display accelerators with modifiers {0}", mod); } item.KeyEquivalentModifierMask = outMod; }
public void CreateMenu() { this.menu = new NSMenu() { AutoEnablesItems = false }; this.state_item = new NSMenuItem() { Title = Controller.StateText, Enabled = false }; this.folder_item = new NSMenuItem() { Title = "SparkleShare", Enabled = true }; this.folder_item.Image = this.sparkleshare_image; this.folder_item.Image.Size = new SizeF(16, 16); this.add_item = new NSMenuItem() { Title = "Add Hosted Project…", Enabled = true }; this.recent_events_item = new NSMenuItem() { Title = "Recent Changes…", Enabled = Controller.RecentEventsItemEnabled }; this.link_code_item = new NSMenuItem(); this.link_code_item.Title = "Client ID"; if (Controller.LinkCodeItemEnabled) { this.link_code_submenu = new NSMenu(); this.code_item = new NSMenuItem(); this.code_item.Title = Program.Controller.CurrentUser.PublicKey.Substring(0, 20) + "..."; this.copy_item = new NSMenuItem(); this.copy_item.Title = "Copy to Clipboard"; this.copy_item.Activated += delegate { Controller.CopyToClipboardClicked(); }; this.link_code_submenu.AddItem(this.code_item); this.link_code_submenu.AddItem(NSMenuItem.SeparatorItem); this.link_code_submenu.AddItem(this.copy_item); this.link_code_item.Submenu = this.link_code_submenu; } this.about_item = new NSMenuItem() { Title = "About SparkleShare", Enabled = true }; this.quit_item = new NSMenuItem() { Title = "Quit", Enabled = Controller.QuitItemEnabled }; this.folder_menu_items = new NSMenuItem [Controller.Folders.Length]; this.error_menu_items = new NSMenuItem [Controller.Folders.Length]; this.try_again_menu_items = new NSMenuItem [Controller.Folders.Length]; if (Controller.Folders.Length > 0) { int i = 0; foreach (string folder_name in Controller.Folders) { NSMenuItem item = new NSMenuItem() { Title = folder_name }; this.folder_menu_items [i] = item; if (!string.IsNullOrEmpty(Controller.FolderErrors [i])) { item.Image = this.caution_image; item.Submenu = new NSMenu(); this.error_menu_items [i] = new NSMenuItem(); this.error_menu_items [i].Title = Controller.FolderErrors [i]; this.try_again_menu_items [i] = new NSMenuItem(); this.try_again_menu_items [i].Title = "Try Again"; this.try_again_menu_items [i].Activated += Controller.TryAgainDelegate(folder_name);; item.Submenu.AddItem(this.error_menu_items [i]); item.Submenu.AddItem(NSMenuItem.SeparatorItem); item.Submenu.AddItem(this.try_again_menu_items [i]); } else { item.Image = this.folder_image; this.folder_menu_items [i].Activated += Controller.OpenFolderDelegate(folder_name); } item.Image.Size = new SizeF(16, 16); i++; } ; } if (Controller.RecentEventsItemEnabled) { this.recent_events_item.Activated += delegate { Controller.RecentEventsClicked(); } } ; this.add_item.Activated += delegate { Controller.AddHostedProjectClicked(); }; this.about_item.Activated += delegate { Controller.AboutClicked(); }; this.quit_item.Activated += delegate { Controller.QuitClicked(); }; this.menu.AddItem(this.state_item); this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.folder_item); this.submenu = new NSMenu(); this.submenu.AddItem(this.recent_events_item); this.submenu.AddItem(this.add_item); this.submenu.AddItem(NSMenuItem.SeparatorItem); this.submenu.AddItem(link_code_item); this.submenu.AddItem(NSMenuItem.SeparatorItem); this.submenu.AddItem(this.about_item); this.folder_item.Submenu = this.submenu; foreach (NSMenuItem item in this.folder_menu_items) { this.menu.AddItem(item); } this.menu.AddItem(NSMenuItem.SeparatorItem); this.menu.AddItem(this.quit_item); this.menu_delegate = new SparkleMenuDelegate(); this.menu.Delegate = this.menu_delegate; this.status_item.Menu = this.menu; }
public void Update (MDMenu parent, ref NSMenuItem lastSeparator, ref int index) { var info = manager.GetCommandInfo (ce.CommandId, new CommandTargetRoute (initialCommandTarget)); if (!isArrayItem) { SetItemValues (this, info, ce.DisabledVisible); if (!Hidden) MDMenu.ShowLastSeparator (ref lastSeparator); return; } Hidden = true; if (index < parent.Count - 1) { for (int i = index + 1; i < parent.Count; i++) { var nextItem = parent.ItemAt (i); if (nextItem == null || nextItem.Target != this) break; parent.RemoveItemAt (i); i--; } } PopulateArrayItems (info.ArrayInfo, parent, ref lastSeparator, ref index); }
static void SetAccel(NSMenuItem item, string accelKey) { uint modeKey; Gdk.ModifierType modeMod; uint key; Gdk.ModifierType mod; if (!KeyBindingManager.BindingToKeys(accelKey, out modeKey, out modeMod, out key, out mod)) { item.KeyEquivalent = ""; item.KeyEquivalentModifierMask = (NSEventModifierMask)0; return; } if (modeKey != 0) { LoggingService.LogWarning("Mac menu cannot display accelerators with mode keys ({0})", accelKey); item.KeyEquivalent = ""; item.KeyEquivalentModifierMask = (NSEventModifierMask)0; return; } var keyEq = GetKeyEquivalent((Gdk.Key)key); item.KeyEquivalent = keyEq; if (keyEq.Length == 0) { item.KeyEquivalentModifierMask = 0; } NSEventModifierMask outMod = 0; if ((mod & Gdk.ModifierType.Mod1Mask) != 0) { outMod |= NSEventModifierMask.AlternateKeyMask; mod ^= Gdk.ModifierType.Mod1Mask; } if ((mod & Gdk.ModifierType.ShiftMask) != 0) { outMod |= NSEventModifierMask.ShiftKeyMask; mod ^= Gdk.ModifierType.ShiftMask; } if ((mod & Gdk.ModifierType.ControlMask) != 0) { outMod |= NSEventModifierMask.ControlKeyMask; mod ^= Gdk.ModifierType.ControlMask; } if ((mod & Gdk.ModifierType.MetaMask) != 0) { outMod |= NSEventModifierMask.CommandKeyMask; mod ^= Gdk.ModifierType.MetaMask; } if (mod != 0) { LoggingService.LogWarning("Mac menu cannot display accelerators with modifiers {0}", mod); } item.KeyEquivalentModifierMask = outMod; }
public bool ValidateMenuItem(NSMenuItem menuItem) { if (menuItem.Action == ObjectiveCRuntime.Selector("changeFontStyle:")) { // If we got this far, then the menuItem is either a part of the font-style-toobar-item-custom-view's // (wow, say that six times fast) NSPopUp Button, or it's a part of the menuFormRepresentation's NSMenu. // If it's the former, then the menu item's state (whether there is a check next to it, etc.) is handled // for us, but if not, then we have to do it ourselves. The tags are changed on the menu so that they // match the fontStylePicked variable, unlike the popup button's, which don't. if (menuItem.Tag == this.fontStylePicked) { menuItem.State = NSCellStateValue.NSOnState; } } return true; }
public override void MenuWillHighlightItem(NSMenu menu, NSMenuItem item) { }
bool OnValidateMenuItem(NSMenuItem item) { return(true); }
void SetItemValues(NSMenuItem item, CommandInfo info, bool disabledVisible, string overrideLabel = null) { item.SetTitleWithMnemonic(GetCleanCommandText(info, overrideLabel)); bool enabled = info.Enabled && (!IsGloballyDisabled || commandSource == CommandSource.ContextMenu); bool visible = info.Visible && (disabledVisible || info.Enabled); item.Enabled = enabled; item.Hidden = !visible; string fileName = null; var doc = info.DataItem as Ide.Gui.Document; if (doc != null) { if (doc.IsFile) { fileName = doc.FileName; } else { // Designer documents have no file bound to them, but the document name // could be a valid path var docName = doc.Name; if (!string.IsNullOrEmpty(docName) && System.IO.Path.IsPathRooted(docName) && System.IO.File.Exists(docName)) { fileName = docName; } } } else if (info.DataItem is NavigationHistoryItem) { var navDoc = ((NavigationHistoryItem)info.DataItem).NavigationPoint as DocumentNavigationPoint; if (navDoc != null) { fileName = navDoc.FileName; } } else { var str = info.DataItem as string; if (str != null && System.IO.Path.IsPathRooted(str) && System.IO.File.Exists(str)) { fileName = str; } } if (!String.IsNullOrWhiteSpace(fileName)) { item.ToolTip = fileName; Xwt.Drawing.Image icon = null; if (!info.Icon.IsNull) { icon = Ide.ImageService.GetIcon(info.Icon, Gtk.IconSize.Menu); } if (icon == null) { icon = Ide.DesktopService.GetIconForFile(fileName, Gtk.IconSize.Menu); } if (icon != null) { var scale = GtkWorkarounds.GetScaleFactor(Ide.IdeApp.Workbench.RootWindow); if (NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle") == "Dark") { icon = icon.WithStyles("dark"); } else { icon = icon.WithStyles("-dark"); } item.Image = icon.ToBitmap(scale).ToNSImage(); item.Image.Template = true; } } SetAccel(item, info.AccelKey); if (info.Checked) { item.State = NSCellStateValue.On; } else if (info.CheckedInconsistent) { item.State = NSCellStateValue.Mixed; } else { item.State = NSCellStateValue.Off; } }