private static IList <MenuModel> GetMenuItems(IMenuModel model) { var menuItems = new List <MenuModel>(); for (var i = 0; i < model.Count; i++) { var type = model.GetTypeAt(i); bool?isChecked = null; if (type == MenuItemType.Check) { isChecked = model.IsCheckedAt(i); } var subItems = model.GetSubMenuAt(i); IList <MenuModel> subMenus = subItems == null ? null : GetMenuItems(subItems); var menuItem = new MenuModel { Label = model.GetLabelAt(i), CommandId = model.GetCommandIdAt(i), IsEnabled = model.IsEnabledAt(i), Type = type, IsSeperator = type == MenuItemType.Separator, IsChecked = isChecked, SubMenus = subMenus }; menuItems.Add(menuItem); } return(menuItems); }
//下面这个官网Example的Fun,读取已有菜单项列表时候,实现的IEnumerable,如果不需要,完全可以注释掉;不属于IContextMenuHandler接口规定的 private static IEnumerable <Tuple <string, CefMenuCommand, bool> > GetMenuItems(IMenuModel model) { for (var i = 0; i < model.Count; i++) { var header = model.GetLabelAt(i); var commandId = model.GetCommandIdAt(i); var isEnabled = model.IsEnabledAt(i); yield return(new Tuple <string, CefMenuCommand, bool>(header, commandId, isEnabled)); } }
protected static IEnumerable <(int index, string header, CefMenuCommand commandId, bool isEnable)> GetMenuItems(IMenuModel model) { for (var i = 0; i < model.Count; i++) { var header = model.GetLabelAt(i); var commandId = model.GetCommandIdAt(i); var isEnabled = model.IsEnabledAt(i); yield return(i, header, commandId, isEnabled); } }
private static IEnumerable <Tuple <string, CefMenuCommand> > GetMenuItems(IMenuModel model) { var list = new List <Tuple <string, CefMenuCommand> >(); for (var i = 0; i < model.Count; i++) { var header = model.GetLabelAt(i); var commandId = model.GetCommandIdAt(i); list.Add(new Tuple <string, CefMenuCommand>(header, commandId)); } return(list); }
private static IEnumerable<Tuple<string, CefMenuCommand>> GetMenuItems(IMenuModel model) { var list = new List<Tuple<string, CefMenuCommand>>(); for(var i = 0; i < model.Count; i++) { var header = model.GetLabelAt(i); var commandId = model.GetCommandIdAt(i); list.Add(new Tuple<string, CefMenuCommand>(header, commandId)); } return list; }