-
Notifications
You must be signed in to change notification settings - Fork 331
/
Interop.cs
42 lines (37 loc) · 1.13 KB
/
Interop.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
using CefSharp;
using CefSharp.WinForms;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SampleRhinoInsideCEF
{
public class Interop
{
public static ChromiumWebBrowser Browser;
static SampleRhinoInsideJavascriptTaskManagerLib.RhinoTaskManager rtm;
public Interop(ChromiumWebBrowser browser)
{
Browser = browser;
rtm = new SampleRhinoInsideJavascriptTaskManagerLib.RhinoTaskManager();
}
public void ShowDev()
{
Browser.ShowDevTools();
}
public async Task<object> startGrasshopper()
{
Func<object, Task<object>> cb = (data) => PushPreview(data.ToString());
dynamic input = new ExpandoObject();
input.cb = cb;
return await rtm.StartGrasshopperTask(input);
}
public async Task<object> PushPreview(string data)
{
await Browser?.GetMainFrame().EvaluateScriptAsync("onGhObjectAdded(" + data + ");");
return "Pushed data";
}
}
}