Skip to content

Commit

Permalink
Merge pull request #1603 from specklesystems/hotfix/gh/duplicate-top-…
Browse files Browse the repository at this point in the history
…menu

fix(gh): Unload top-menu if it exists before loading
  • Loading branch information
AlanRynne authored Sep 9, 2022
1 parent b95647e commit 1bda247
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ConnectorGrasshopper/ConnectorGrasshopper/Loader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -120,8 +120,12 @@ private void HandleKitSelectedEvent(object sender, EventArgs args)
private void AddSpeckleMenu(object sender, ElapsedEventArgs e)
{
if (Grasshopper.Instances.DocumentEditor == null || MenuHasBeenAdded) return;
var mainMenu = Grasshopper.Instances.DocumentEditor.MainMenuStrip;
var menuName = "Speckle 2";
if (mainMenu.Items.ContainsKey(menuName))
mainMenu.Items.RemoveByKey(menuName);

speckleMenu = new ToolStripMenuItem("Speckle 2");
speckleMenu = new ToolStripMenuItem(menuName);

var kitHeader = speckleMenu.DropDown.Items.Add("Select the converter you want to use.");
kitHeader.Enabled = false;
Expand Down Expand Up @@ -173,7 +177,6 @@ private void AddSpeckleMenu(object sender, ElapsedEventArgs e)

try
{
var mainMenu = Grasshopper.Instances.DocumentEditor.MainMenuStrip;
Grasshopper.Instances.DocumentEditor.Invoke(new Action(() =>
{
if (!MenuHasBeenAdded)
Expand Down

0 comments on commit 1bda247

Please sign in to comment.