void ClearSubmenuItems(NSMenu submenu) { foreach (var item in menuItems) { submenu.RemoveItem(item); } }
/// <summary> /// Populates the film menu items with all screenings of the current film. /// </summary> /// <param name="menu">Menu.</param> /// private void PopulateFilmScreeningsMenuItems(NSMenu menu) { // Remove the existing screening items from the menu. foreach (string title in _filmScreeningByMenuItemTitle.Keys) { menu.RemoveItem(menu.ItemWithTitle(title)); } // Add the screenings with same film to the Screening menu. int screeningNumber = 0; var mask = NSEventModifierMask.AlternateKeyMask | NSEventModifierMask.CommandKeyMask; _filmScreeningByMenuItemTitle = new Dictionary <string, Screening> { }; _FilmScreeningEnabledByTag = new Dictionary <nint, bool> { }; var screenings = _screeningProvider.Screenings; foreach (var screening in screenings) { screeningNumber += 1; string itemTitle = screening.ToMenuItemString(); NSMenuItem item = new NSMenuItem(itemTitle) { Action = new Selector("NavigateFilmScreening:"), Tag = _filmMenuHeaderItemTag + screeningNumber, State = NSCellStateValue.Off }; if (screeningNumber <= 9) { item.KeyEquivalent = screeningNumber.ToString(); item.KeyEquivalentModifierMask = mask; } menu.AddItem(item); bool enabled = AnalyserViewRunning() || screening != Screening; _FilmScreeningEnabledByTag.Add(item.Tag, enabled); _filmScreeningByMenuItemTitle.Add(itemTitle, screening); } }
private void PopulateFestivalDaysMenu(NSMenu menu) { // Delete existing festival day menu items. foreach (var menuItem in _dayItems) { menu.RemoveItem(menuItem); } // Loop through the festival days _dayItems = new List <NSMenuItem> { }; var plan = _controller.Plan; var tag = _FirstFestivalDaysMenuItemTag; foreach (var day in ScreeningsPlan.FestivalDays) { var item = new NSMenuItem(ItemTitle(day)); item.Tag = tag++; item.Enabled = day != plan.CurrDay; item.Activated += (sender, e) => _controller.GoToDay(day); menu.AddItem(item); _dayItems.Add(item); } }
public void Remove(MenuItem item) { nsmenu.RemoveItem(item); items.Remove(item); }