From 68bdd59727ecccf301e895c2fc80aa26599eba9d Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sat, 12 Aug 2017 10:34:43 -0500 Subject: [PATCH] Add the ability to log out --- EduNetworkBuilder/NetworkBuilder.Designer.cs | 64 +++++++++++-------- EduNetworkBuilder/NetworkBuilder.cs | 26 +++++++- .../Resources/languages/edustrings.resx | 4 ++ 3 files changed, 65 insertions(+), 29 deletions(-) diff --git a/EduNetworkBuilder/NetworkBuilder.Designer.cs b/EduNetworkBuilder/NetworkBuilder.Designer.cs index 8a26f59..a7822cb 100644 --- a/EduNetworkBuilder/NetworkBuilder.Designer.cs +++ b/EduNetworkBuilder/NetworkBuilder.Designer.cs @@ -45,6 +45,9 @@ this.classSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.profileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.addToClassworkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.updateClassworkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.submitHomeworkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.markAsGradedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.allToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dHCPRequestToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clearArpTableToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -83,9 +86,7 @@ this.HelpPanel = new System.Windows.Forms.Panel(); this.cbViewTitles = new System.Windows.Forms.CheckBox(); this.myProgressBar = new System.Windows.Forms.ProgressBar(); - this.updateClassworkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.submitHomeworkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.markAsGradedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.logoutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.msMainMenuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit(); this.HelpPanel.SuspendLayout(); @@ -114,6 +115,7 @@ this.loadToolStripMenuItem, this.reloadToolStripMenuItem, this.saveToolStripMenuItem, + this.logoutToolStripMenuItem, this.exitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(44, 24); @@ -122,35 +124,35 @@ // newToolStripMenuItem // this.newToolStripMenuItem.Name = "newToolStripMenuItem"; - this.newToolStripMenuItem.Size = new System.Drawing.Size(131, 26); + this.newToolStripMenuItem.Size = new System.Drawing.Size(181, 26); this.newToolStripMenuItem.Text = "New"; this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click); // // loadToolStripMenuItem // this.loadToolStripMenuItem.Name = "loadToolStripMenuItem"; - this.loadToolStripMenuItem.Size = new System.Drawing.Size(131, 26); + this.loadToolStripMenuItem.Size = new System.Drawing.Size(181, 26); this.loadToolStripMenuItem.Text = "Load"; this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click); // // reloadToolStripMenuItem // this.reloadToolStripMenuItem.Name = "reloadToolStripMenuItem"; - this.reloadToolStripMenuItem.Size = new System.Drawing.Size(131, 26); + this.reloadToolStripMenuItem.Size = new System.Drawing.Size(181, 26); this.reloadToolStripMenuItem.Text = "Reload"; this.reloadToolStripMenuItem.Click += new System.EventHandler(this.reloadToolStripMenuItem_Click); // // saveToolStripMenuItem // this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.Size = new System.Drawing.Size(131, 26); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(181, 26); this.saveToolStripMenuItem.Text = "Save"; this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); // // exitToolStripMenuItem // this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.Size = new System.Drawing.Size(131, 26); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(181, 26); this.exitToolStripMenuItem.Text = "Exit"; this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); // @@ -232,6 +234,27 @@ this.addToClassworkToolStripMenuItem.Text = "Add To Classwork"; this.addToClassworkToolStripMenuItem.Click += new System.EventHandler(this.addToClassworkToolStripMenuItem_Click); // + // updateClassworkToolStripMenuItem + // + this.updateClassworkToolStripMenuItem.Name = "updateClassworkToolStripMenuItem"; + this.updateClassworkToolStripMenuItem.Size = new System.Drawing.Size(208, 26); + this.updateClassworkToolStripMenuItem.Text = "Update Classwork"; + this.updateClassworkToolStripMenuItem.Click += new System.EventHandler(this.updateClassworkToolStripMenuItem_Click); + // + // submitHomeworkToolStripMenuItem + // + this.submitHomeworkToolStripMenuItem.Name = "submitHomeworkToolStripMenuItem"; + this.submitHomeworkToolStripMenuItem.Size = new System.Drawing.Size(208, 26); + this.submitHomeworkToolStripMenuItem.Text = "Submit Homework"; + this.submitHomeworkToolStripMenuItem.Click += new System.EventHandler(this.submitHomeworkToolStripMenuItem_Click); + // + // markAsGradedToolStripMenuItem + // + this.markAsGradedToolStripMenuItem.Name = "markAsGradedToolStripMenuItem"; + this.markAsGradedToolStripMenuItem.Size = new System.Drawing.Size(208, 26); + this.markAsGradedToolStripMenuItem.Text = "Mark As Graded"; + this.markAsGradedToolStripMenuItem.Click += new System.EventHandler(this.markAsGradedToolStripMenuItem_Click); + // // allToolStripMenuItem // this.allToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -586,26 +609,12 @@ this.myProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.myProgressBar.TabIndex = 11; // - // updateClassworkToolStripMenuItem + // logoutToolStripMenuItem // - this.updateClassworkToolStripMenuItem.Name = "updateClassworkToolStripMenuItem"; - this.updateClassworkToolStripMenuItem.Size = new System.Drawing.Size(208, 26); - this.updateClassworkToolStripMenuItem.Text = "Update Classwork"; - this.updateClassworkToolStripMenuItem.Click += new System.EventHandler(this.updateClassworkToolStripMenuItem_Click); - // - // submitHomeworkToolStripMenuItem - // - this.submitHomeworkToolStripMenuItem.Name = "submitHomeworkToolStripMenuItem"; - this.submitHomeworkToolStripMenuItem.Size = new System.Drawing.Size(208, 26); - this.submitHomeworkToolStripMenuItem.Text = "Submit Homework"; - this.submitHomeworkToolStripMenuItem.Click += new System.EventHandler(this.submitHomeworkToolStripMenuItem_Click); - // - // markAsGradedToolStripMenuItem - // - this.markAsGradedToolStripMenuItem.Name = "markAsGradedToolStripMenuItem"; - this.markAsGradedToolStripMenuItem.Size = new System.Drawing.Size(208, 26); - this.markAsGradedToolStripMenuItem.Text = "Mark As Graded"; - this.markAsGradedToolStripMenuItem.Click += new System.EventHandler(this.markAsGradedToolStripMenuItem_Click); + this.logoutToolStripMenuItem.Name = "logoutToolStripMenuItem"; + this.logoutToolStripMenuItem.Size = new System.Drawing.Size(181, 26); + this.logoutToolStripMenuItem.Text = "Logout"; + this.logoutToolStripMenuItem.Click += new System.EventHandler(this.logoutToolStripMenuItem_Click); // // BuilderWindow // @@ -700,6 +709,7 @@ private System.Windows.Forms.ToolStripMenuItem updateClassworkToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem submitHomeworkToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem markAsGradedToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem logoutToolStripMenuItem; } } diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index fdcdd02..8ec1597 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -397,12 +397,15 @@ namespace EduNetworkBuilder { classSetupToolStripMenuItem.Visible = true; profileToolStripMenuItem.Visible = false; + logoutToolStripMenuItem.Visible = false; + this.Text = NB.Translate("NB_Form", OurSettings); //From up above } else { + logoutToolStripMenuItem.Visible = true; profileToolStripMenuItem.Visible = true; classSetupToolStripMenuItem.Visible = false; - this.Text = "EduNetworkBuilder : " + CurrentUser.FullName; + this.Text = NB.Translate("NB_Form", OurSettings) + " : " + CurrentUser.FullName; } if (CurrentUser == null || !CurrentUser.isAdmin) { @@ -2064,6 +2067,25 @@ namespace EduNetworkBuilder PPF.Edit(); UpdateMenu(); } - + + private void logoutToolStripMenuItem_Click(object sender, EventArgs e) + { + if (CurrentUser == null) return; //Nobody to logout + + DialogResult answer = MessageBox.Show(NB.Translate("NB_Logout"), NB.Translate("NB_Logout"),MessageBoxButtons.YesNoCancel); + if (answer != DialogResult.Yes) return; + + //Save current user + CurrentUser.Save(true); //Save it and rotate it + + //Get rid of the current project. This way we keep them from logging out, and then exporting the homework + PrepForLoad(); + + //set current user to null + CurrentUser = null; + + //rebuild menu + UpdateMenu(); + } } } \ No newline at end of file diff --git a/EduNetworkBuilder/Resources/languages/edustrings.resx b/EduNetworkBuilder/Resources/languages/edustrings.resx index 8cfb0d5..a0d40b9 100644 --- a/EduNetworkBuilder/Resources/languages/edustrings.resx +++ b/EduNetworkBuilder/Resources/languages/edustrings.resx @@ -1881,6 +1881,10 @@ Name already exists. PC_HWHasName = Name already exists. + + Log out? + NB_Logout = Log out? + You have completed the homework. Would you like to submit it? If you want to clean it up and submit later, click No. Go to "Edit" -> "Submit" when you want to submit it. N_PromptToSubmit = You have completed the homework. Would you like to submit it? If you want to clean it up and submit later, click No. Go to "Edit" -> "Submit" when you want to submit it.