/// <summary> /// Method that is called when Dynamo has finished loading and the UI is ready to be interacted with. /// </summary> /// <param name="vlp"> /// Parameters that provide references to Dynamo commands, settings, events and /// Dynamo UI items like menus or the background preview. This object is supplied by Dynamo itself. /// </param> public void Loaded(ViewLoadedParams vlp) { // let's now create a completely top-level new menu item var extensionMenu = new MenuItem { Header = "DynaHub" }; // and now we add a new sub-menu item that says hello when clicked var loginMenuItem = new MenuItem { Header = "Login to GitHub" }; var browseMenuItem = new MenuItem { Header = "Browse GitHub" }; var VM = vlp.DynamoWindow.DataContext as DynamoViewModel; loginMenuItem.Click += (sender, args) => { // Create data tree to represent repo structure Views.Login l = new Views.Login(); l.ShowDialog(); }; browseMenuItem.Click += (sender, args) => { if (Views.Login.logged) { // Create data tree to represent repo structure Views.Browser b = new Views.Browser(Views.Login.repoFiles); b.ShowDialog(); // Open downloaded file - path received from Browser VM.OpenCommand.Execute(Views.Browser.toOpen); } else { MessageBox.Show("You'll need to login before trying to access your files!"); } }; // Add main menu to Dynamo vlp.dynamoMenu.Items.Add(extensionMenu); // Add sub-menus to main menu extensionMenu.Items.Add(loginMenuItem); extensionMenu.Items.Add(browseMenuItem); }
/// <summary> /// Method that is called when Dynamo has finished loading and the UI is ready to be interacted with. /// </summary> /// <param name="vlp"> /// Parameters that provide references to Dynamo commands, settings, events and /// Dynamo UI items like menus or the background preview. This object is supplied by Dynamo itself. /// </param> public void Loaded(ViewLoadedParams vlp) { // let's now create a completely top-level new menu item MenuItem extensionMenu = new MenuItem { Header = "DynaHub" }; // and now we add a new sub-menu item that says hello when clicked loginMenuItem = new MenuItem { Header = "Login to GitHub" }; var browseMenuItem = new MenuItem { Header = "Browse GitHub" }; var packagesMenuItem = new MenuItem { Header = "Get packages" }; var logoutMenuItem = new MenuItem { Header = "Logout" }; var VM = vlp.DynamoWindow.DataContext as DynamoViewModel; // Define Login menu option loginMenuItem.Click += (sender, args) => { if (!GlobalSettings.logged) { // Create data tree to represent repo structure Views.Login l = new Views.Login(); l.ShowDialog(); } else { Helpers.ErrorMessage("You are already logged in."); } }; // Define Browse menu option browseMenuItem.Click += (sender, args) => { if (GlobalSettings.logged) { // Create data tree to represent repo structure Views.Browser b = new Views.Browser(); b.ShowDialog(); // Open downloaded file - path received from Browser VM.OpenCommand.Execute(Views.Browser.toOpen); } else { Helpers.ErrorMessage("You'll need to login before trying to access your files!"); } }; // Define Get Packages menu option packagesMenuItem.Click += (sender, args) => { if (GlobalSettings.logged) { // Download packages to Dynamo's packages folder Views.Packages p = new Views.Packages(vlp); p.ShowDialog(); } else { Helpers.ErrorMessage("You'll need to login before downloading the packages!"); } }; // Define Get Packages menu option logoutMenuItem.Click += (sender, args) => { if (GlobalSettings.logged) { // Logout of current GitHub login GitHubConnection.Logout(); //Views.Packages o = new Views.Packages(vlp); //o.ShowDialog(); } else { Helpers.ErrorMessage("You can't logout if you're not logged in"); } }; // Add main menu to Dynamo vlp.dynamoMenu.Items.Add(extensionMenu); // Add sub-menus to main menu extensionMenu.Items.Add(loginMenuItem); extensionMenu.Items.Add(browseMenuItem); extensionMenu.Items.Add(packagesMenuItem); extensionMenu.Items.Add(logoutMenuItem); }