getting ready to load homework

This commit is contained in:
Tim Young 2017-08-05 19:22:36 -05:00
parent 8fe0cf2df7
commit 6467013f52
3 changed files with 35 additions and 2 deletions

View File

@ -1760,6 +1760,7 @@ namespace EduNetworkBuilder
MessageBox.Show(NB.Translate("NB_LoadUserFirst"));
return;
}
//Here we would load a homework file
}
else
{

View File

@ -853,9 +853,20 @@ namespace EduNetworkBuilder
index++;
}
MessageBox.Show(HWClassList.Count.ToString() + " selected");
//Choose a file
OpenFileDialog mydialog = new OpenFileDialog();
mydialog.AddExtension = true;
//If we have a user loaded, we can open homework files
string filter = "EduNetworkBuilder Homework File (*.enbh)|*.enbh;";
mydialog.Filter = filter;
mydialog.Multiselect = false;
mydialog.ShowHelp = true;
mydialog.CheckFileExists = true;
mydialog.CheckPathExists = true;
DialogResult result = mydialog.ShowDialog();
if (result == System.Windows.Forms.DialogResult.Cancel) return; //Choose a file
//save that list in that file
}
private void btnReadAllStudentHomework_Click(object sender, EventArgs e)

View File

@ -168,6 +168,27 @@ namespace EduNetworkBuilder
writer.Close();
}
public static void Save(List<SchoolworkClass> homeworks, string filename)
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.NewLineOnAttributes = true;
XmlWriter writer = XmlWriter.Create(filename, settings);
//Now we write the file:
writer.WriteStartDocument();
writer.WriteStartElement("EduNetworkBuilderSchoolwork");
writer.WriteComment("This is a schoolwork file for EduNetworkBuilder.");
foreach (SchoolworkClass swc in homeworks)
{
swc.Save(writer);
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
writer.Close();
}
public void Save(XmlWriter writer)
{
//Save the language name