码迷,mamicode.com
首页 > 其他好文 > 详细

CefSharp F12打开DevTools查看console

时间:2018-11-19 11:20:03      阅读:2089      评论:0      收藏:0      [点我收藏+]

标签:www   rom   map   arp   controls   return   实例化   views   modifier   

winform嵌入chrome浏览器

1.nuget安装cefsharp

2.实例化浏览器

private void Form1_Load(object sender, EventArgs e)
{
ChromiumWebBrowser b = new ChromiumWebBrowser("http://localhost:57531/views/Map/scene.html");
this.Controls.Add(b);
b.Dock = DockStyle.Fill;
b.KeyboardHandler = new CEFKeyBoardHander();
}

3.响应F12打开控制台console

public class CEFKeyBoardHander : IKeyboardHandler
{//https://bbs.csdn.net/topics/392375553
public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
{
if (type == KeyType.KeyUp && Enum.IsDefined(typeof(Keys), windowsKeyCode))
{
var key = (Keys)windowsKeyCode;
switch (key)
{
case Keys.F12:
browser.ShowDevTools();
break;

case Keys.F5:

if (modifiers == CefEventFlags.ControlDown)
{
//MessageBox.Show("ctrl+f5");
browser.Reload(true); //强制忽略缓存

}
else
{
//MessageBox.Show("f5");
browser.Reload();
}
break;


}
}
return false;
}

public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
{
return false;
}
}

From: https://www.cnblogs.com/xuejianxiyang/p/9981398.html

CefSharp F12打开DevTools查看console

标签:www   rom   map   arp   controls   return   实例化   views   modifier   

原文地址:https://www.cnblogs.com/xuejianxiyang/p/9981398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!