private void AddSpeckleMenu(object sender, ElapsedEventArgs e) { if (Grasshopper.Instances.DocumentEditor == null) { return; } if (MenuHasBeenAdded) { loadTimer.Stop(); return; } var speckleMenu = new ToolStripMenuItem("Speckle"); speckleMenu.DropDown.Items.Add("Speckle Account Manager", null, (s, a) => { var signInWindow = new SpecklePopup.SignInWindow(false); var helper = new System.Windows.Interop.WindowInteropHelper(signInWindow); helper.Owner = Rhino.RhinoApp.MainWindowHandle(); signInWindow.Show(); }); speckleMenu.DropDown.Items.Add(new ToolStripSeparator()); speckleMenu.DropDown.Items.Add("Speckle Home", null, (s, a) => { Process.Start(@"https://speckle.works"); }); speckleMenu.DropDown.Items.Add("Speckle Documentation", null, (s, a) => { Process.Start(@"https://speckle.works/docs/essentials/start"); }); speckleMenu.DropDown.Items.Add("Speckle Forum", null, (s, a) => { Process.Start(@"https://discourse.speckle.works"); }); try { var mainMenu = Grasshopper.Instances.DocumentEditor.MainMenuStrip; Grasshopper.Instances.DocumentEditor.Invoke(new Action(() => { mainMenu.Items.Insert(mainMenu.Items.Count - 2, speckleMenu); })); MenuHasBeenAdded = true; loadTimer.Stop(); } catch (Exception err) { Debug.WriteLine(err.Message); } }
public void Loaded(ViewLoadedParams viewLoadedParams) { //new node manager var nodeManagerViewModel = new NodeManagerViewModel(viewLoadedParams); _nodeManager = new NodeManager { Owner = viewLoadedParams.DynamoWindow, DataContext = nodeManagerViewModel }; var speckleMenu = new MenuItem { Header = "Speckle" }; var speckleAccountsMenu = new MenuItem { Header = "Manage Accounts" }; var speckleNodeManagerMenu = new MenuItem { Header = "Manage Speckle Nodes" }; var speckleSendReceiveNodesMenu = new MenuItem { Header = "Send/Receive nodes (experimental)" }; var speckleNodeSender = new MenuItem { Header = "Node Sender" }; var speckleNodeReceiver = new MenuItem { Header = "Node Receiver" }; //accounts speckleAccountsMenu.Click += (sender, args) => { //var viewModel = new SampleWindowViewModel(p); var window = new SpecklePopup.SignInWindow() { Owner = viewLoadedParams.DynamoWindow, WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner }; window.Show(); }; //node manager speckleNodeManagerMenu.Click += (sender, args) => { _nodeManager.Show(); }; //node sender click speckleNodeSender.Click += (sender, args) => { var viewModel = new SenderViewModel(viewLoadedParams); var window = new Sender() { Owner = viewLoadedParams.DynamoWindow, DataContext = viewModel }; window.ForceSend.Click += viewModel.Send_Click; window.Show(); }; //node receiver click speckleNodeReceiver.Click += (receiver, args) => { var viewModel = new ReceiverViewModel(viewLoadedParams); var window = new Receiver() { Owner = viewLoadedParams.DynamoWindow, DataContext = viewModel, }; window.StreamChanged += viewModel.StreamChanged; window.Show(); }; //sub menus speckleSendReceiveNodesMenu.Items.Add(speckleNodeReceiver); speckleSendReceiveNodesMenu.Items.Add(speckleNodeSender); //top level menus speckleMenu.Items.Add(speckleAccountsMenu); speckleMenu.Items.Add(speckleNodeManagerMenu); speckleMenu.Items.Add(speckleSendReceiveNodesMenu); viewLoadedParams.dynamoMenu.Items.Insert(viewLoadedParams.dynamoMenu.Items.Count - 1, speckleMenu); }