Example #1
0
        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 #2
0
 public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
 {
     for (int i = 0; i < model.Count; i++)
     {
         var commandId = model.GetCommandIdAt(i);
         if (commandId == CefMenuCommand.Print)
         {
             model.RemoveAt(i);
             i--;
             continue;
         }
         if (commandId == CefMenuCommand.Back)
         {
             model.RemoveAt(i);
             i--;
             continue;
         }
         if (commandId == CefMenuCommand.Forward)
         {
             model.RemoveAt(i);
             i--;
             continue;
         }
         if (commandId == CefMenuCommand.ViewSource)
         {
             model.RemoveAt(i);
             i--;
             continue;
             model.AddItem((CefMenuCommand)26501, "开发者工具(F12)");
             model.AddItem((CefMenuCommand)26502, "全屏(F11)");
             continue;
         }
     }
     while (true)
     {
         if (model.Count > 0 && model.GetCommandIdAt(0) == CefMenuCommand.NotFound)
         {
             model.RemoveAt(0);
         }
         else
         {
             break;
         }
     }
 }
Example #3
0
        private static CefMenuCommand[] GetMenuItems(IMenuModel model)
        {
            var result = new CefMenuCommand[model.Count];

            for (var i = 0; i < model.Count; i++)
            {
                result[i] = model.GetCommandIdAt(i);
            }
            return(result);
        }
Example #4
0
 //下面这个官网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));
     }
 }
Example #5
0
 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);
     }
 }
Example #6
0
        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);
        }
Example #7
0
        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;
        }