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()
{
Save(NB.IsRunningOnMono());

View File

@ -404,6 +404,21 @@ namespace EduNetworkBuilder
addToClassworkToolStripMenuItem.Visible = false;
else
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()
@ -1666,18 +1681,29 @@ namespace EduNetworkBuilder
} else if(extension == ".enbu")
{
CurrentUser = new PersonClass(filename);
OurSettings = NB.GetSettings(); //Grab the new settings from the user
UpdateMenu();
//Now, open a new window to edit them.
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();
}
else
{
MessageBox.Show(NB.Translate("NB_InvalidFile"));
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)