本文整理汇总了C#中IWebBrowser类的典型用法代码示例。如果您正苦于以下问题:C# IWebBrowser类的具体用法?C# IWebBrowser怎么用?C# IWebBrowser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IWebBrowser类属于命名空间,在下文中一共展示了IWebBrowser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
});
}
示例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;
}
示例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;
}
示例7: OnBeforeContextMenu
public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
{
if (parameters.IsEditable)
return true;
return false;
}
示例8: OnBeforeContextMenu
public bool OnBeforeContextMenu(IWebBrowser browser, IContextMenuParams parameters)
{
Console.WriteLine("Context menu opened");
Console.WriteLine(parameters.MisspelledWord);
return true;
}
示例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));
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}