• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IWebBrowser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IWebBrowser的典型用法代码示例。如果您正苦于以下问题:C# IWebBrowser类的具体用法?C# IWebBrowser怎么用?C# IWebBrowser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IWebBrowser类属于命名空间,在下文中一共展示了IWebBrowser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1:

 bool ILifeSpanHandler.DoClose(IWebBrowser browserControl, IBrowser browser)
 {
     //The default CEF behaviour (return false) will send a OS close notification (e.g. WM_CLOSE).
     //See the doc for this method for full details.
     //return true here to handle closing yourself (no WM_CLOSE will be sent).
     return true;
 }
开发者ID:intuilab,项目名称:CefSharp,代码行数:7,代码来源:LifeSpanHandler.cs


示例2: OnBeforeResourceLoad

        public bool OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)
        {
            /*
            * Called on the IO thread before a resource is loaded. To allow the resource to load normally return false.
            * To redirect the resource to a new url populate the |redirectUrl| value and return false.
            * To specify data for the resource return a CefStream object in |resourceStream|, use the |response| object to set mime type,
            * HTTP status code and optional header values, and return false. To cancel loading of the resource return true.
            * Any modifications to |request| will be observed. If the URL in |request| is changed and |redirectUrl| is also set,
            * the URL in |request| will be used.
            */
            if (requestResponse.Request.Url.StartsWith(m_InternalDomain))
            {
                var requestUri = requestResponse.Request.Url.Replace(m_InternalDomain, String.Empty);

                HttpResponseMessage response = m_Server(requestUri);

                //TODO: Copy to separate memory stream so we can dispose of parent HttpResponseMessage
                var responseContent = response.Content.ReadAsStreamAsync().Result;

                var responseHeaders = response.Headers.ToDictionary(x => x.Key, x => x.Value.First());

                var responseMime = response.IsSuccessStatusCode
                    ? response.Content.Headers.ContentType.MediaType
                    : "text/html"; //CEFSharp demands a MimeType of some kind...

                requestResponse.RespondWith(responseContent, responseMime, String.Empty, (int) response.StatusCode, responseHeaders);

            }

            return false;
        }
开发者ID:kevfromireland,项目名称:sql-scripts,代码行数:31,代码来源:InterceptingRequestHandler.cs


示例3: OnJSDialog

 public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, string acceptLang, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage)
 {
     switch (dialogType)
     {
         case CefJsDialogType.Alert:
             MessageBox.Show(messageText);
             suppressMessage = true;
             return false;
         case CefJsDialogType.Confirm:
             var dr = MessageBox.Show(messageText, "提示", MessageBoxButton.YesNo);
             if (dr == MessageBoxResult.Yes)
                 callback.Continue(true);
             else
                 callback.Continue(false);
             suppressMessage = false;
             return true;
         case CefJsDialogType.Prompt:
             MessageBox.Show("系统不支持prompt形式的提示框", "UTMP系统提示");
             break;
     }
     //如果suppressMessage被设置为true,并且函数返回值为false,将阻止页面打开JS的弹出窗口。
     //如果suppressMessage被设置为false,并且函数返回值也是false,页面将会打开这个JS弹出窗口。
     suppressMessage = true;
     return false;
 }
开发者ID:MagicWang,项目名称:WYJ,代码行数:25,代码来源:Window3.xaml.cs


示例4: Form

        void IDisplayHandler.OnFullscreenModeChange(IWebBrowser browserControl, IBrowser browser, bool fullscreen)
        {
            var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;

            chromiumWebBrowser.InvokeOnUiThreadIfRequired(() =>
            {
                if (fullscreen)
                {
                    parent = chromiumWebBrowser.Parent;

                    parent.Controls.Remove(chromiumWebBrowser);

                    fullScreenForm = new Form();
                    fullScreenForm.FormBorderStyle = FormBorderStyle.None;
                    fullScreenForm.WindowState = FormWindowState.Maximized;

                    fullScreenForm.Controls.Add(chromiumWebBrowser);

                    fullScreenForm.ShowDialog(parent.FindForm());
                }
                else
                {
                    fullScreenForm.Controls.Remove(chromiumWebBrowser);

                    parent.Controls.Add(chromiumWebBrowser);

                    fullScreenForm.Close();
                    fullScreenForm.Dispose();
                    fullScreenForm = null;
                }
            });
        }
开发者ID:Creo1402,项目名称:CefSharp,代码行数:32,代码来源:DisplayHandler.cs


示例5: OnBeforeResourceLoad

 public bool OnBeforeResourceLoad(IWebBrowser browser, IRequestResponse requestResponse)
 {
     Assembly asm = Assembly.GetExecutingAssembly();
     string MIME = "application/octet-stream";
     string requestURL = requestResponse.Request.Url, _lower = requestURL.ToLower();
     if ((_lower == manifestProtocol + "postdata" || _lower.StartsWith(manifestProtocol + "postdata?"))
         && PostContentReceived != null)
         PostContentReceived(browser, new ContentReceivedEventArgs(requestResponse.Request.Body));
     if (requestURL.Contains('?'))
         requestURL = requestURL.Substring(0, requestURL.IndexOf('?'));
     _lower = requestURL.ToLower();
     if (_lower.StartsWith(manifestProtocol)) {
         if (_lower.EndsWith(".html") || _lower.EndsWith(".htm"))
             MIME = "text/html";
         else if (_lower.EndsWith(".css"))
             MIME = "text/css";
         else if (_lower.EndsWith(".js"))
             MIME = "text/javascript";
         else if (_lower.EndsWith(".txt"))
             MIME = "text/plain";
         requestURL = requestURL.Substring(manifestProtocol.Length);
         if (requestURL == "res/lang.js")
             requestURL = strings.script_path;
         requestURL = requestURL.Replace('/', '.').Replace(' ', '_');
         try {
             requestResponse.RespondWith(asm.GetManifestResourceStream(asm.GetName().Name + "." + requestURL), MIME);
         } catch { }
     }
     return false;
 }
开发者ID:JLChnToZ,项目名称:BlockEditorTest,代码行数:30,代码来源:ManifestResourceHandler.cs


示例6: OnBeforePopup

        public bool OnBeforePopup(IWebBrowser rpBrowserControl, IBlinkBrowser rpBrowser, IFrame rpFrame, string rpTargetUrl, string rpTargetFrameName, WindowOpenDisposition rpTargetDisposition, bool rpUserGesture, IPopupFeatures rpPopupFeatures, IWindowInfo rpWindowInfo, IBrowserSettings rpBrowserSettings, ref bool rrpNoJavascriptAccess, out IWebBrowser ropNewBrowser)
        {
            rpBrowserControl.Load(rpTargetUrl);

            ropNewBrowser = rpBrowserControl;
            return true;
        }
开发者ID:amatukaze,项目名称:HeavenlyWind.Browser.Blink,代码行数:7,代码来源:BlinkLifeSpanHandler.cs


示例7: OnBeforeContextMenu

        public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
        {
            if (parameters.IsEditable)
                return true;

            return false;
        }
开发者ID:chances,项目名称:Animatum,代码行数:7,代码来源:ChromiumBrowserHandlers.cs


示例8: OnBeforeContextMenu

        public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
        {
            Console.WriteLine("Context menu opened");
            Console.WriteLine(parameters.MisspelledWord);

            return true;
        }
开发者ID:numbersint,项目名称:CefSharp,代码行数:7,代码来源:MenuHandler.cs


示例9: ChatDocument

        public ChatDocument(IInlineUploadViewFactory factory, IWebBrowser browser, IPasteViewFactory pasteViewFactory)
        {
            _factory = factory;
            _browser = browser;
            _pasteViewFactory = pasteViewFactory;
            _handlers = new Dictionary<MessageType, Action<Message, User, Paragraph>>
                {
                    {MessageType.TextMessage, FormatUserMessage},
                    {MessageType.TimestampMessage, FormatTimestampMessage},
                    {MessageType.LeaveMessage, FormatLeaveMessage},
                    {MessageType.KickMessage, FormatKickMessage},
                    {MessageType.PasteMessage, FormatPasteMessage},
                    {MessageType.EnterMessage, FormatEnterMessage},
                    {MessageType.UploadMessage, FormatUploadMessage},
                    {MessageType.TweetMessage, FormatTweetMessage},
                    {MessageType.AdvertisementMessage, FormatAdvertisementMessage},
                    {MessageType.TopicChangeMessage, FormatTopicChangeMessage}

                };

            FontSize = 14;
            FontFamily = new FontFamily("Segoe UI");

            AddHandler(Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler(NavigateToLink));
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:25,代码来源:ChatDocument.cs


示例10: using

        bool IGeolocationHandler.OnRequestGeolocationPermission(IWebBrowser browserControl, IBrowser browser, string requestingUrl, int requestId, IGeolocationCallback callback)
        {
            //You can execute the callback inline
            //callback.Continue(true);
            //return true;

            //You can execute the callback in an `async` fashion
            //Open a message box on the `UI` thread and ask for user input.
            //You can open a form, or do whatever you like, just make sure you either
            //execute the callback or call `Dispose` as it's an `unmanaged` wrapper.
            var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;
            chromiumWebBrowser.Dispatcher.BeginInvoke((Action)(() =>
            {
                //Callback wraps an unmanaged resource, so we'll make sure it's Disposed (calling Continue will also Dipose of the callback, it's safe to dispose multiple times).
                using (callback)
                {
                    var result = MessageBox.Show(String.Format("{0} wants to use your computer's location.  Allow?  ** You must set your Google API key in CefExample.Init() for this to work. **", requestingUrl), "Geolocation", MessageBoxButton.YesNo);

                    //Execute the callback, to allow/deny the request.
                    callback.Continue(result == MessageBoxResult.Yes);
                }
            }));

            //Yes we'd like to hadle this request ourselves.
            return true;
        }
开发者ID:xeronith,项目名称:CefSharp,代码行数:26,代码来源:GeolocationHandler.cs


示例11: OnBeforePopup

            public bool OnBeforePopup(IWebBrowser c_web, string sourceUrl, string targetUrl, ref int x, ref int y, ref int width, ref int height)
            {
                if (targetUrl.Contains("create#instanceId") == false && Properties.Settings.Default.ctrlsetting == 0 && targetUrl.Contains("pages") == true || targetUrl.Contains("create#instanceId") == false && Properties.Settings.Default.ctrlsetting == 0 && targetUrl.Contains("numbers") == true || targetUrl.Contains("create#instanceId") == false && Properties.Settings.Default.ctrlsetting == 0 && targetUrl.Contains("keynote") == true)
                {
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        DelayAction(500, new Action(() =>
                        {
                            pressenter();
                        }));

                        DelayAction(600, new Action(() =>
                        {
                            var popupmain = new popupmain(targetUrl);
                            popupmain.Show();
                        }));
                    }));

                    return true;
                }
                else
                {
                    return false;
                }
            }
开发者ID:QuantumVectors,项目名称:WinCloud,代码行数:25,代码来源:MainWindow.xaml.cs


示例12: OnBeforeBrowse

 public bool OnBeforeBrowse(IWebBrowser browser, IRequest request, bool isRedirect)
 {
     if (request.Url.ToLower() != "http://www.google.com/")
     {
         try
         {
             if (PluginSettings.Instance.OpenInInternalBrowser)
             {
                 _parent.BeginInvoke((Action)(() =>
                 {
                     Utils.BasePlugin.Plugin p = Utils.PluginSupport.PluginByName(_core, "GlobalcachingApplication.Plugins.Browser.BrowserPlugin") as Utils.BasePlugin.Plugin;
                     if (p != null)
                     {
                         var m = p.GetType().GetMethod("OpenNewBrowser");
                         m.Invoke(p, new object[] { request.Url.ToString() });
                     }
                 }));
             }
             else
             {
                 System.Diagnostics.Process.Start(request.Url.ToString());
             }
             return true;
         }
         catch
         {
         }
     }
     return false;
 }
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:30,代码来源:GeocacheViewerForm.cs


示例13: OnBeforePopup

 public bool OnBeforePopup(IWebBrowser browser, string url, ref int x, ref int y, ref int width, ref int height)
 {
     try {
         Process.Start(url);
     } catch { }
     return true;
 }
开发者ID:JLChnToZ,项目名称:BlockEditorTest,代码行数:7,代码来源:ExternalLifeSpanHandler.cs


示例14:

 void IRequestHandler.OnResourceResponse(IWebBrowser browser, string url, int status, string statusText, string mimeType, WebHeaderCollection headers)
 {
     if (url.Contains("battlelog-web-plugins"))
     {
         this.InitUpdateWebPlugin(url);
     }
 }
开发者ID:nirvdrum,项目名称:Battlelogium,代码行数:7,代码来源:BattlelogBase.RequestHandler.cs


示例15: OnJSPrompt

        public bool OnJSPrompt(IWebBrowser browser, string url, string message, string defaultValue, out bool retval, out string result)
        {
            retval = false;
            result = null;

            return false;
        }
开发者ID:numbersint,项目名称:CefSharp,代码行数:7,代码来源:JsDialogHandler.cs


示例16: getBinding

		private static BindingInfo getBinding (IWebBrowser control)
		{
			if (!boundControls.ContainsKey (control))
				return null;
			BindingInfo info = boundControls[control] as BindingInfo;
			return info;
		}
开发者ID:REALTOBIZ,项目名称:mono,代码行数:7,代码来源:Base.cs


示例17: OpenInSystemBrowser

 bool IRequestHandler.OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request,
     bool isRedirect) {
     if (!frame.IsMain || CommonUrls.IsWithSixUrl(request.Url) || IsAuthUrl(new Uri(request.Url)))
         return false;
     OpenInSystemBrowser(request.Url);
     return true;
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:7,代码来源:SixWebControlBehavior.cs


示例18: Uri

        CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame,
            IRequest request, IRequestCallback callback) {
            if (CommonUrls.IsWithSixUrl(request.Url)) {
                var headers = request.Headers;
                headers[Common.ClientHeader] = DomainEvilGlobal.SecretData.UserInfo.ClientId.ToString();
                headers[Common.ClientHeaderV] = Common.App.ProductVersion;
                request.Headers = headers;
            }

            return CefReturnValue.Continue;
            //Example of how to set Referer
            // Same should work when setting any header
            // For this example only set Referer when using our custom scheme
            var url = new Uri(request.Url);
            if (url.Scheme == "customscheme") // CefSharpSchemeHandlerFactory.SchemeName
            {
                var headers = request.Headers;
                headers["Referer"] = "http://google.com";

                request.Headers = headers;
            }

            //NOTE: If you do not wish to implement this method returning false is the default behaviour
            // We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
            //callback.Dispose();
            //return false;

            //NOTE: When executing the callback in an async fashion need to check to see if it's disposed
            if (!callback.IsDisposed) {
                using (callback) {
                    if (request.Method == "POST") {
                        using (var postData = request.PostData) {
                            if (postData != null) {
                                var elements = postData.Elements;

                                var charSet = request.GetCharSet();

                                foreach (var element in elements) {
                                    if (element.Type == PostDataElementType.Bytes) {
                                        var body = element.GetBody(charSet);
                                    }
                                }
                            }
                        }
                    }

                    //Note to Redirect simply set the request Url
                    //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    request.Url = "https://github.com/";
                    //}

                    //Callback in async fashion
                    //callback.Continue(true);
                    //return CefReturnValue.ContinueAsync;
                }
            }

            return CefReturnValue.Continue;
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:60,代码来源:SixWebControlBehavior.cs


示例19: GetResourceHandler

        public IResourceHandler GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request)
        {
            // Every time we request the main GPM page allow another JS injection
            if (Regex.Match(request.Url, @"^http[s]?://play\.google\.com/music/listen", RegexOptions.IgnoreCase).Success)
            {
                firstJSOnly = true;
            }
            if (Regex.Match(request.Url, @"\.js", RegexOptions.IgnoreCase).Success && Regex.Match(request.Url, @"http", RegexOptions.IgnoreCase).Success && firstJSOnly)
            {
                firstJSOnly = false;
                using (WebClient webClient = new WebClient())
                {
                    // These are the JS files to inject into GPM
                    string custom_interface = Properties.Resources.custom_interface;

                    return ResourceHandler.FromStream(new MemoryStream(Encoding.UTF8.GetBytes(
                        webClient.DownloadString(request.Url) + ";window.onload=function(){csharpinterface.showApp();};document.addEventListener('DOMContentLoaded', function () {" +
                            "window.OBSERVER = setInterval(function() { if (document.getElementById('material-vslider')) { clearInterval(window.OBSERVER); " +
                            Properties.Resources.gmusic_min + Properties.Resources.gmusic_theme_min + Properties.Resources.gmusic_mini_player_min +
                            this.getInitCode() +
                            custom_interface +
                        "}}, 10);});")), webClient.ResponseHeaders["Content-Type"]);
                }
            }
            return null;
        }
开发者ID:ananthonline,项目名称:Google-Play-Music-Desktop-Player-UNOFFICIAL-,代码行数:26,代码来源:ResourceHandlerFactory.cs


示例20: using

        CefReturnValue IRequestHandler.OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
        {
            using (callback)
            {
                if (request.Method == "POST")
                {
                    using (var postData = request.PostData)
                    {
                        var elements = postData.Elements;

                        var charSet = request.GetCharSet();

                        foreach (var element in elements)
                        {
                            if (element.Type == PostDataElementType.Bytes)
                            {
                                var body = element.GetBody(charSet);
                            }
                        }
                    }
                }

                //Note to Redirect simply set the request Url
                //if (request.Url.StartsWith("https://www.google.com", StringComparison.OrdinalIgnoreCase))
                //{
                //    request.Url = "https://github.com/";
                //}

                //Callback in async fashion
                //callback.Continue(true);
                //return CefReturnValue.ContinueAsync;
            }
            
            return CefReturnValue.Continue;
        }
开发者ID:bjarteskogoy,项目名称:CefSharp,代码行数:35,代码来源:RequestHandler.cs



注:本文中的IWebBrowser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IWebBrowser2类代码示例发布时间:2022-05-24
下一篇:
C# IWebAgent类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap