-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Plugin.cs
54 lines (47 loc) · 1.98 KB
/
Plugin.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
49
50
51
52
53
54
using System;
using System.Drawing;
using System.Windows.Forms;
using Grasshopper.Kernel;
namespace Sunglasses
{
public class SunglassesPriority : GH_AssemblyPriority
{
public override GH_LoadingInstruction PriorityLoad()
{
Grasshopper.Instances.CanvasCreated += Instances_CanvasCreated;
Grasshopper.Instances.CanvasDestroyed += Instances_CanvasDestroyed;
return GH_LoadingInstruction.Proceed;
}
private void Instances_CanvasCreated(Grasshopper.GUI.Canvas.GH_Canvas canvas)
{
Grasshopper.Instances.CanvasCreated -= Instances_CanvasCreated;
var editor = Grasshopper.Instances.DocumentEditor;
if (editor == null)
return;
var menu = editor.MainMenuStrip.Items.Find("mnuDisplay", false);
if (menu.Length==0)
{
Rhino.RhinoApp.WriteLine("Sunglasses cannot find Display menu.");
return;
}
var items = ((ToolStripMenuItem)menu[0]).DropDownItems;
if(items.Find("Sunglasses", false).Length == 0)
items.Insert(3, new SunglassesMenuItem());
}
private void Instances_CanvasDestroyed(Grasshopper.GUI.Canvas.GH_Canvas canvas)
{
Settings.Dispose();
}
}
public class SunglassesInfo : GH_AssemblyInfo
{
public override string Name => "Sunglasses";
public override Bitmap Icon => null;
public override string Description => "Draw the name above the component, so that it can be used in icon mode.";
public override Guid Id => new Guid("194607e9-d4d6-4e5a-836f-a65774231315");
public override string AuthorName => "Daniel Gonzalez Abalde";
public override string AuthorContact => "https://discord.gg/75tP9hBnk8";
public override GH_LibraryLicense License => GH_LibraryLicense.opensource;
public override string AssemblyVersion => base.AssemblyVersion;
}
}