Get user to save when program closed

This commit is contained in:
Tim Young 2017-07-29 09:26:25 -05:00
parent 799cf1844a
commit 4415ca5944
4 changed files with 38 additions and 9 deletions

View File

@ -42,6 +42,7 @@
this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.undoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.changeLanguageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.changeLanguageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.classSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.allToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.allToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dHCPRequestToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dHCPRequestToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clearArpTableToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.clearArpTableToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -80,7 +81,7 @@
this.HelpPanel = new System.Windows.Forms.Panel(); this.HelpPanel = new System.Windows.Forms.Panel();
this.cbViewTitles = new System.Windows.Forms.CheckBox(); this.cbViewTitles = new System.Windows.Forms.CheckBox();
this.myProgressBar = new System.Windows.Forms.ProgressBar(); this.myProgressBar = new System.Windows.Forms.ProgressBar();
this.classSetupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.profileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.msMainMenuStrip.SuspendLayout(); this.msMainMenuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pbNetworkView)).BeginInit();
this.HelpPanel.SuspendLayout(); this.HelpPanel.SuspendLayout();
@ -158,7 +159,8 @@
this.undoToolStripMenuItem, this.undoToolStripMenuItem,
this.optionsToolStripMenuItem, this.optionsToolStripMenuItem,
this.changeLanguageToolStripMenuItem, this.changeLanguageToolStripMenuItem,
this.classSetupToolStripMenuItem}); this.classSetupToolStripMenuItem,
this.profileToolStripMenuItem});
this.editToolStripMenuItem.Name = "editToolStripMenuItem"; this.editToolStripMenuItem.Name = "editToolStripMenuItem";
this.editToolStripMenuItem.Size = new System.Drawing.Size(47, 24); this.editToolStripMenuItem.Size = new System.Drawing.Size(47, 24);
this.editToolStripMenuItem.Text = "Edit"; this.editToolStripMenuItem.Text = "Edit";
@ -201,6 +203,13 @@
this.changeLanguageToolStripMenuItem.Text = "Change Language"; this.changeLanguageToolStripMenuItem.Text = "Change Language";
this.changeLanguageToolStripMenuItem.Click += new System.EventHandler(this.changeLanguageToolStripMenuItem_Click); this.changeLanguageToolStripMenuItem.Click += new System.EventHandler(this.changeLanguageToolStripMenuItem_Click);
// //
// classSetupToolStripMenuItem
//
this.classSetupToolStripMenuItem.Name = "classSetupToolStripMenuItem";
this.classSetupToolStripMenuItem.Size = new System.Drawing.Size(203, 26);
this.classSetupToolStripMenuItem.Text = "Class Setup";
this.classSetupToolStripMenuItem.Click += new System.EventHandler(this.classSetupToolStripMenuItem_Click);
//
// allToolStripMenuItem // allToolStripMenuItem
// //
this.allToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.allToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@ -555,12 +564,12 @@
this.myProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous; this.myProgressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;
this.myProgressBar.TabIndex = 11; this.myProgressBar.TabIndex = 11;
// //
// classSetupToolStripMenuItem // profileToolStripMenuItem
// //
this.classSetupToolStripMenuItem.Name = "classSetupToolStripMenuItem"; this.profileToolStripMenuItem.Name = "profileToolStripMenuItem";
this.classSetupToolStripMenuItem.Size = new System.Drawing.Size(203, 26); this.profileToolStripMenuItem.Size = new System.Drawing.Size(203, 26);
this.classSetupToolStripMenuItem.Text = "Class Setup"; this.profileToolStripMenuItem.Text = "Profile";
this.classSetupToolStripMenuItem.Click += new System.EventHandler(this.classSetupToolStripMenuItem_Click); this.profileToolStripMenuItem.Click += new System.EventHandler(this.profileToolStripMenuItem_Click);
// //
// BuilderWindow // BuilderWindow
// //
@ -650,6 +659,7 @@
private System.Windows.Forms.ToolStripMenuItem VLANToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem VLANToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem SolvedVLANToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem SolvedVLANToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem classSetupToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem classSetupToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem profileToolStripMenuItem;
} }
} }

View File

@ -391,9 +391,11 @@ namespace EduNetworkBuilder
if (CurrentUser == null) if (CurrentUser == null)
{ {
classSetupToolStripMenuItem.Visible = true; classSetupToolStripMenuItem.Visible = true;
profileToolStripMenuItem.Visible = false;
} }
else else
{ {
profileToolStripMenuItem.Visible = true;
classSetupToolStripMenuItem.Visible = false; classSetupToolStripMenuItem.Visible = false;
this.Text = "EduNetworkBuilder : " + CurrentUser.FullName; this.Text = "EduNetworkBuilder : " + CurrentUser.FullName;
} }
@ -1499,6 +1501,8 @@ namespace EduNetworkBuilder
} }
OurSettings.Save(NB.IsRunningOnMono()); OurSettings.Save(NB.IsRunningOnMono());
if (CurrentUser != null)
CurrentUser.Save();
} }
private void dHCPRequestToolStripMenuItem_Click(object sender, EventArgs e) private void dHCPRequestToolStripMenuItem_Click(object sender, EventArgs e)
@ -1834,5 +1838,13 @@ namespace EduNetworkBuilder
CurrentUser = PPF.Edit(); CurrentUser = PPF.Edit();
UpdateMenu(); UpdateMenu();
} }
private void profileToolStripMenuItem_Click(object sender, EventArgs e)
{
if (CurrentUser == null) return;
PersonProfileForm PPF = new PersonProfileForm(CurrentUser);
CurrentUser = PPF.Edit();
UpdateMenu();
}
} }
} }

View File

@ -17,6 +17,7 @@ namespace EduNetworkBuilder
/// The username of the person. Will be used as a filename. Cannot be changed once it is set /// The username of the person. Will be used as a filename. Cannot be changed once it is set
/// </summary> /// </summary>
public string UserName { get { return _UserName; } } public string UserName { get { return _UserName; } }
public string FileName { get { return UserName + ".enbu"; } }
/// <summary> /// <summary>
/// The full name of the person. Can have spaces and punctuation. Can change as one wants it changed. /// The full name of the person. Can have spaces and punctuation. Can change as one wants it changed.
@ -122,6 +123,12 @@ namespace EduNetworkBuilder
} }
} }
public void Save()
{
//Save to our pre-existing / pre-defined file
string filename = Path.Combine(filepath, FileName);
Save(filename);
}
public void Save(string filename) public void Save(string filename)
{ {
@ -133,7 +140,7 @@ namespace EduNetworkBuilder
//Now we write the file: //Now we write the file:
writer.WriteStartDocument(); writer.WriteStartDocument();
writer.WriteStartElement("EduNetworkBuilder"); writer.WriteStartElement("EduNetworkBuilder");
writer.WriteComment("This is a network file for EduNetworkBuilder."); writer.WriteComment("This is a user file for EduNetworkBuilder.");
Save(writer); Save(writer);
writer.WriteEndElement(); writer.WriteEndElement();
writer.WriteEndDocument(); writer.WriteEndDocument();

View File

@ -70,7 +70,7 @@ namespace EduNetworkBuilder
OFD.CheckPathExists = true; OFD.CheckPathExists = true;
OFD.FileName = NB.Translate("PPF_SelectThisFolder"); OFD.FileName = NB.Translate("PPF_SelectThisFolder");
OFD.ShowDialog(); OFD.ShowDialog();
Console.WriteLine(Path.GetDirectoryName(OFD.FileName)); CurrentUser.filepath = Path.GetDirectoryName(OFD.FileName);
} }
else if (CurrentUser == null) else if (CurrentUser == null)
{ {