예제 #1
0
        public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
        {
            //移除不需要的菜单
            model.Remove(CefMenuCommand.ViewSource);
            model.Remove(CefMenuCommand.Print);
            model.Remove(CefMenuCommand.AddToDictionary);
            model.Remove(CefMenuCommand.SpellCheckNoSuggestions);

            //修改菜单显示名称
            model.SetLabel(CefMenuCommand.Undo, "撤回");
            model.SetLabel(CefMenuCommand.Redo, "恢复");
            model.SetLabel(CefMenuCommand.Back, "返回");
            model.SetLabel(CefMenuCommand.Forward, "前进");
            model.SetLabel(CefMenuCommand.Cut, "剪切");
            model.SetLabel(CefMenuCommand.Copy, "复制");
            model.SetLabel(CefMenuCommand.Paste, "粘贴");
            model.SetLabel(CefMenuCommand.Delete, "删除");
            model.SetLabel(CefMenuCommand.SelectAll, "全选");
            model.SetLabel(CefMenuCommand.Reload, "重新加载");
        }
예제 #2
0
        void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
        {
            if (!string.IsNullOrWhiteSpace(parameters.SelectionText))
            {
                selectionTextQuery = parameters.SelectionText;
                model.AddItem((CefMenuCommand)SearchGoogle, $"Pesquisar \"{selectionTextQuery.Substring(0, Math.Min(selectionTextQuery.Length, 60))}\" no Google");
            }
            statusLabelLink = currentBrowserTab.statusLabel.Text;
            if (Uri.IsWellFormedUriString(statusLabelLink, UriKind.RelativeOrAbsolute) && !string.IsNullOrWhiteSpace(statusLabelLink))
            {
                model.Clear();
                model.AddItem((CefMenuCommand)OpenNewTab, "Abrir link em nova guia");
            }
            else
            {
                //model.SetLabel(CefMenuCommand.Redo, "Refazer");
                //model.SetLabel(CefMenuCommand.Undo, "Desfazer");

                model.Remove(CefMenuCommand.Redo);
                model.Remove(CefMenuCommand.Undo);

                model.SetLabel(CefMenuCommand.Forward, "Avançar");
                model.SetLabel(CefMenuCommand.Back, "Voltar");
                model.SetLabel(CefMenuCommand.Copy, "Copiar");
                //model.SetLabel(CefMenuCommand.AddToDictionary, "Adicionar ao dicionário");
                model.SetLabel(CefMenuCommand.Cut, "Cortar");
                model.SetLabel(CefMenuCommand.Delete, "Apagar");
                model.SetLabel(CefMenuCommand.Paste, "Colar");
                model.SetLabel(CefMenuCommand.SelectAll, "Selecionar tudo");
                model.SetLabel(CefMenuCommand.Print, "Imprimir");
                model.SetLabel(CefMenuCommand.Reload, "Recarregar");
                model.SetLabel(CefMenuCommand.ReloadNoCache, "Voltar");
                model.SetLabel(CefMenuCommand.ViewSource, "Exibir código fonte da página");
                model.AddSeparator(); //indexado
                model.AddItem((CefMenuCommand)ShowDevTools, "Inspecionar");
            }
        }
예제 #3
0
        void IContextMenuHandler.OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
        {
            //To disable the menu then call clear
            // model.Clear();

            //Removing existing menu item
            //bool removed = model.Remove(CefMenuCommand.ViewSource); // Remove "View Source" option

            //Add new custom menu items
            model.AddItem((CefMenuCommand)ShowDevTools, EmbeddedBrowserControlRes.Show_DevTools);
            model.AddItem((CefMenuCommand)CloseDevTools, EmbeddedBrowserControlRes.Close_DevTools);

            //BufferLink = null;
            if (string.IsNullOrEmpty(parameters.UnfilteredLinkUrl) == false)
            {
                //BufferLink = parameters.LinkUrl;
                model.AddItem((CefMenuCommand)OpenLinkInNewTab, EmbeddedBrowserControlRes.Open_Link_In_New_Tab);
            }


            if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection))
            {
                model.AddItem((CefMenuCommand)SearchSelectedText, EmbeddedBrowserControlRes.Search_selected_text_using_Google);
                model.AddItem((CefMenuCommand)SaveText, EmbeddedBrowserControlRes.Save_selected_text);
                model.AddSeparator();
            }


            if (parameters.TypeFlags.HasFlag(ContextMenuType.Media) && parameters.HasImageContents)
            {
                if (EmbeddedBrowserHelper.HasJpegExtension(parameters.SourceUrl))
                {
                    //model.AddItem((CefMenuCommand)ViewImageExifData, "View image EXIF data");
                }
                //model.AddItem((CefMenuCommand)MenuSaveImage, "Save image");
                model.AddItem((CefMenuCommand)CopyImgLocation, EmbeddedBrowserControlRes.Copy_image_location_to_clipboard);

                var sub = model.AddSubMenu((CefMenuCommand)ReverseImgSearchSubMenu, EmbeddedBrowserControlRes.Reverse_image_search_tools);
                sub.AddItem((CefMenuCommand)ReverseImageSearchTineye, EmbeddedBrowserControlRes.Reverse_image_search_using_TinEye);
                //sub.AddItem((CefMenuCommand)ReverseImageSearchYandex, EmbeddedBrowserControlRes.Reverse_image_search_using_Yandex);
                sub.AddItem((CefMenuCommand)ReverseImageSearchGoogle, EmbeddedBrowserControlRes.Reverse_image_search_using_Google);
                model.AddSeparator();
                //
            }
            if (EmbeddedBrowserHelper.IsOnYouTube(browserControl.Address))
            {
                //model.AddItem((CefMenuCommand)SaveYouTubeVideo, "Extract YouTube video");
            }
            if (EmbeddedBrowserHelper.IsOnFacebook(browserControl.Address))
            {
                //model.AddItem((CefMenuCommand)ViewFacebookId, "Show Facebook profile ID");
            }
            if (EmbeddedBrowserHelper.IsOnTwitter(browserControl.Address))
            {
                //model.AddItem((CefMenuCommand)ViewTwitterId, "Show Twitter profile ID");
            }

            //model.AddItem((CefMenuCommand)ViewSource, "*View page source");
            //model.AddItem((CefMenuCommand)ExtractAllLinks, "Extract all links on page");
            //model.AddItem((CefMenuCommand)Bookmark, "Add page to bookmarks");
            string s  = EmbeddedBrowserControlRes.View_source;
            string s2 = EmbeddedBrowserControlRes.Forward;

            model.SetLabel(CefMenuCommand.ViewSource, EmbeddedBrowserControlRes.View_source);
            model.SetLabel(CefMenuCommand.Print, EmbeddedBrowserControlRes.Print);
            model.SetLabel(CefMenuCommand.Undo, EmbeddedBrowserControlRes.Undo);
            model.SetLabel(CefMenuCommand.Redo, EmbeddedBrowserControlRes.Redo);
            model.SetLabel(CefMenuCommand.Forward, EmbeddedBrowserControlRes.Forward);
            model.SetLabel(CefMenuCommand.Back, EmbeddedBrowserControlRes.Back);

            /*
             * model.Remove(CefMenuCommand.ViewSource);
             * model.Remove(CefMenuCommand.Print);
             * model.Remove(CefMenuCommand.Undo);
             * model.Remove(CefMenuCommand.Redo);
             * model.Remove(CefMenuCommand.Forward);
             * model.Remove(CefMenuCommand.Back);
             */
        }