示例#1
0
 bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags)
 {
     return(false);
 }
 bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags)
 {
     //throw new NotImplementedException();
     return(false);
 }
        public bool OnContextMenuCommand(CefSharp.IWebBrowser chromiumWebBrowser, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags)
        {
            switch (commandId)
            {
            case CefSharp.CefMenuCommand.ViewSource:
                if (ViewSource != null)
                {
                    ViewSource(this, new EventArgs());
                }
                return(true);

            case (CefSharp.CefMenuCommand)OpenLink:
            case (CefSharp.CefMenuCommand)OpenLinkSource:
            {
                if (OpenLinkOrSource != null)
                {
                    OpenLinkOrSource(this, new OpenLinkOrSourceArgs(parameters.LinkUrl, commandId == (CefSharp.CefMenuCommand)OpenLinkSource));
                }
            }
                return(true);

            case (CefSharp.CefMenuCommand)CopyImage:
            {
                if (CopyImageToClipboard != null)
                {
                    CopyImageToClipboard(this, new CopyImageEventArgs(parameters.SourceUrl));
                }
            }
                return(true);

            case (CefSharp.CefMenuCommand)OpenDevTool:
            {
                if (ShowDevTool != null)
                {
                    ShowDevTool(this, new EventArgs());
                }
            }
                return(true);

            case (CefSharp.CefMenuCommand)CopyLink:
            {
                Clipboard.SetText(parameters.LinkUrl);
            }
                return(true);

            case (CefSharp.CefMenuCommand)OpenLoadScript:
            {
                if (LoadScript != null)
                {
                    LoadScript(this, new EventArgs());
                }
            }
                return(true);

            default:
                break;
            }
            return(false);
        }