Repository navigation
Expand file tree
/
Copy pathRhinoModifiersPlugin.cs
More file actions
88 lines (74 loc) · 2.7 KB
/
Copy pathRhinoModifiersPlugin.cs
File metadata and controls
88 lines (74 loc) · 2.7 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using Rhino;
using Rhino.PlugIns;
using Rhino.UI;
using RhinoModifiers.Runtime;
using RhinoModifiers.UI;
namespace RhinoModifiers
{
///<summary>
/// <para>Every RhinoCommon .rhp assembly must have one and only one PlugIn-derived
/// class. DO NOT create instances of this class yourself. It is the
/// responsibility of Rhino to create an instance of this class.</para>
/// <para>To complete plug-in information, please also see all PlugInDescription
/// attributes in AssemblyInfo.cs (you might need to click "Project" ->
/// "Show All Files" to see it in the "Solution Explorer" window).</para>
///</summary>
public class RhinoModifiersPlugin : PlugIn
{
private bool _openedPropertiesOnStartup;
public RhinoModifiersPlugin()
{
Instance = this;
}
///<summary>Gets the only instance of the RhinoModifiersPlugin plug-in.</summary>
public static RhinoModifiersPlugin Instance { get; private set; } = null!;
public override PlugInLoadTime LoadTime => PlugInLoadTime.AtStartup;
internal ModifierEngine Engine { get; private set; } = null!;
protected override LoadReturnCode OnLoad(ref string errorMessage)
{
Engine = new ModifierEngine();
RhinoApp.Initialized += OnRhinoInitialized;
RhinoApp.Idle += OnRhinoIdle;
return LoadReturnCode.Success;
}
protected override void OnShutdown()
{
RhinoApp.Initialized -= OnRhinoInitialized;
RhinoApp.Idle -= OnRhinoIdle;
Engine.Dispose();
base.OnShutdown();
}
protected override void ObjectPropertiesPages(ObjectPropertiesPageCollection collection)
{
collection.Add(new ModifierObjectPropertiesPage());
}
private void OnRhinoInitialized(object? sender, EventArgs e)
{
RhinoApp.Initialized -= OnRhinoInitialized;
RhinoApp.InvokeOnUiThread(OpenPropertiesPanelOnStartup);
}
private void OnRhinoIdle(object? sender, EventArgs e)
{
if (_openedPropertiesOnStartup)
{
RhinoApp.Idle -= OnRhinoIdle;
return;
}
RhinoApp.Idle -= OnRhinoIdle;
OpenPropertiesPanelOnStartup();
}
private void OpenPropertiesPanelOnStartup()
{
if (_openedPropertiesOnStartup)
{
return;
}
_openedPropertiesOnStartup = true;
if (!Panels.IsPanelVisible(PanelIds.ObjectProperties))
{
Panels.OpenPanel(PanelIds.ObjectProperties);
}
}
}
}