Working on recent file load system

This commit is contained in:
Tim Young 2017-07-31 13:39:46 -05:00
parent a6dc99253f
commit b7b5525413
2 changed files with 45 additions and 1 deletions

View File

@ -173,6 +173,24 @@ namespace EduNetworkBuilder
} }
} }
public List<string> GetRecentFiles()
{
//If we do not have a user and are not using mono, grab the settings from properties.settings
//Otherwise, we grab the settings from this settings object
List<string> TheFiles = new List<string>();
if(NB.GetUser() == null && !NB.IsRunningOnMono())
{
foreach (string one in Properties.Settings.Default.RecentFiles)
TheFiles.Add(one);
}
else
{
//This is the repository of recent files. Use it
TheFiles.AddRange(RecentFiles);
}
return TheFiles;
}
public void Save() public void Save()
{ {
Save(NB.IsRunningOnMono()); Save(NB.IsRunningOnMono());

View File

@ -404,6 +404,21 @@ namespace EduNetworkBuilder
addToClassworkToolStripMenuItem.Visible = false; addToClassworkToolStripMenuItem.Visible = false;
else else
addToClassworkToolStripMenuItem.Visible = true; addToClassworkToolStripMenuItem.Visible = true;
List<string> tLoadList = new List<string>();
loadToolStripMenuItem.DropDownItems.Clear();
if(OurSettings != null)
{
foreach (string one in OurSettings.GetRecentFiles())
{
if (tLoadList.Contains(one)) continue;
string JustFile = Path.GetFileName(one);
int i = loadToolStripMenuItem.DropDownItems.Count;
loadToolStripMenuItem.DropDownItems.Add(JustFile, null, loadRecentFilename);
loadToolStripMenuItem.DropDownItems[i].Name = one;
tLoadList.Add(one);
}
}
} }
public void UpdateLinks() public void UpdateLinks()
@ -1666,18 +1681,29 @@ namespace EduNetworkBuilder
} else if(extension == ".enbu") } else if(extension == ".enbu")
{ {
CurrentUser = new PersonClass(filename); CurrentUser = new PersonClass(filename);
OurSettings = NB.GetSettings(); //Grab the new settings from the user
UpdateMenu(); UpdateMenu();
//Now, open a new window to edit them. //Now, open a new window to edit them.
PersonProfileForm PPF = new PersonProfileForm(CurrentUser); PersonProfileForm PPF = new PersonProfileForm(CurrentUser);
CurrentUser = PPF.Edit(); CurrentUser = PPF.Edit(); //This does the form as dialog. When we come back, update the menu.
UpdateMenu(); UpdateMenu();
} }
else else
{ {
MessageBox.Show(NB.Translate("NB_InvalidFile")); MessageBox.Show(NB.Translate("NB_InvalidFile"));
Close(); Close();
return; //We return here so we do not register the filename...
} }
if (OurSettings != null) OurSettings.RegisterFileAsLoaded(filename);
}
private void loadRecentFilename(object sender, EventArgs e)
{
//find the full filename & load that.
ToolStripDropDownItem TSDDI = (ToolStripDropDownItem)sender;
LoadInitialFile(TSDDI.Name);
UpdateMenu();
} }
private void BuilderWindow_Load(object sender, EventArgs e) private void BuilderWindow_Load(object sender, EventArgs e)