-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathRevitWv2EventHandler.cs
48 lines (42 loc) · 1.43 KB
/
RevitWv2EventHandler.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
45
46
47
48
using System.Diagnostics;
using Autodesk.Revit.UI;
namespace RevitWebView2Demo
{
public class RevitWv2EventHandler : IExternalEventHandler
{
public enum RevitWv2ActionsEnum
{
Invalid = -1,
CreateSheet
}
private readonly ExternalEvent _externalEvent;
private RevitWv2ActionsEnum _currentRevitWv2Actions;
public RevitWv2EventHandler()
{
_externalEvent = ExternalEvent.Create(this);
}
public void Execute(UIApplication app)
{
switch (_currentRevitWv2Actions)
{
case RevitWv2ActionsEnum.CreateSheet:
WebView2EventHandlers.HandleCreateSheet(app.ActiveUIDocument);
break;
default:
Debug.WriteLine("RevitWv2EventHandler action not defined");
break;
}
/* this shit wont work if its asynchronous ; but revit has an event queue I suppose*/
_currentRevitWv2Actions = RevitWv2ActionsEnum.Invalid;
}
public string GetName()
{
return nameof(RevitWv2EventHandler);
}
public ExternalEventRequest Raise(RevitWv2ActionsEnum revitWv2ActionsName)
{
_currentRevitWv2Actions = revitWv2ActionsName;
return _externalEvent.Raise();
}
}
}