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

View File

@ -391,9 +391,11 @@ namespace EduNetworkBuilder
if (CurrentUser == null)
{
classSetupToolStripMenuItem.Visible = true;
profileToolStripMenuItem.Visible = false;
}
else
{
profileToolStripMenuItem.Visible = true;
classSetupToolStripMenuItem.Visible = false;
this.Text = "EduNetworkBuilder : " + CurrentUser.FullName;
}
@ -1499,6 +1501,8 @@ namespace EduNetworkBuilder
}
OurSettings.Save(NB.IsRunningOnMono());
if (CurrentUser != null)
CurrentUser.Save();
}
private void dHCPRequestToolStripMenuItem_Click(object sender, EventArgs e)
@ -1834,5 +1838,13 @@ namespace EduNetworkBuilder
CurrentUser = PPF.Edit();
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
/// </summary>
public string UserName { get { return _UserName; } }
public string FileName { get { return UserName + ".enbu"; } }
/// <summary>
/// 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)
{
@ -133,7 +140,7 @@ namespace EduNetworkBuilder
//Now we write the file:
writer.WriteStartDocument();
writer.WriteStartElement("EduNetworkBuilder");
writer.WriteComment("This is a network file for EduNetworkBuilder.");
writer.WriteComment("This is a user file for EduNetworkBuilder.");
Save(writer);
writer.WriteEndElement();
writer.WriteEndDocument();

View File

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