-
Notifications
You must be signed in to change notification settings - Fork 0
/
MenuHandler.cs
44 lines (41 loc) · 1.36 KB
/
MenuHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using CefSharp;
using CefSharp.Handler;
using CefSharp.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BlocklyMirai
{
class MenuHandler : ContextMenuHandler
{
MainWindow mw;
public MenuHandler(MainWindow mw)
{
this.mw = mw;
}
protected override void OnBeforeContextMenu(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model)
{
model.Clear();
if (!mw.Config["debug"].ToBool()) return;
model.AddItem(CefMenuCommand.Reload, "重新加载");
model.AddItem(CefMenuCommand.ViewSource, "打开 开发者工具");
}
protected override bool OnContextMenuCommand(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags)
{
if (!mw.Config["debug"].ToBool()) return false;
if (commandId == CefMenuCommand.Reload)
{
browser.Reload();
return true;
}
if(commandId == CefMenuCommand.ViewSource)
{
browser.ShowDevTools();
return true;
}
return false;
}
}
}