Exemple #1
0
        public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
        {
            // Remove any existent option using the Clear method of the model
            //
            //model.Clear();

            Console.WriteLine("Context menu opened !");

            // You can add a separator in case that there are more items on the list
            if (model.Count > 0)
            {
                model.AddSeparator();
            }


            // Add a new item to the list using the AddItem method of the model
            model.AddSubMenu((CefMenuCommand)initial_command, "Add to Target");
            IMenuModel target_menu = model.GetSubMenu((CefMenuCommand)initial_command);

            target_menu.AddItem((CefMenuCommand)initial_command + 1, "New");
            int i = 2;

            foreach (Target target in Main_Instance.Instance.Workspace.Targets)
            {
                target_menu.AddItem((CefMenuCommand)initial_command + i, target.Title);
                i++;
            }

            //model.AddItem((CefMenuCommand)26502, "Close DevTools");

            // Add a separator
            //model.AddSeparator();

            // Add another example item
            // model.AddItem((CefMenuCommand)26503, "Display alert message");
        }