Load/save person class and schoolwork class
This commit is contained in:
parent
338a28d9fa
commit
799cf1844a
@ -74,6 +74,8 @@ namespace EduNetworkBuilder
|
||||
NetTitle = new LanguageStrings("title"); //Do not translate this string "title". It is an important word
|
||||
}
|
||||
|
||||
public Network() { } //simple constructor
|
||||
|
||||
private bool isDirty()
|
||||
{
|
||||
if (_isDirty) return true;
|
||||
@ -137,6 +139,9 @@ namespace EduNetworkBuilder
|
||||
case "network":
|
||||
Load(Individual,PuzzleName, FromResource);
|
||||
break;
|
||||
case "puzzlename":
|
||||
PuzzleName = Individual.InnerText;
|
||||
break;
|
||||
case "showlabels":
|
||||
bool.TryParse(Individual.InnerText, out OptionShowLabels);
|
||||
ShowLabelsHere = OptionShowLabels;
|
||||
@ -278,7 +283,7 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
|
||||
|
||||
public void Save(XmlWriter writer)
|
||||
public void Save(XmlWriter writer, bool StraightToFile = true)
|
||||
{
|
||||
//Save the language name
|
||||
//save the number of items
|
||||
@ -296,6 +301,8 @@ namespace EduNetworkBuilder
|
||||
writer.WriteElementString("startinghelplevel", StartingHelpLevel.ToString());
|
||||
writer.WriteElementString("vlansenabled", VLANsEnabled.ToString());
|
||||
writer.WriteElementString("VLANPacketColors", VLANPacketColors.ToString());
|
||||
if(!StraightToFile)
|
||||
writer.WriteElementString("PuzzleName", PuzzleName);
|
||||
//Save all the devices
|
||||
for (int loop = 0; loop < NetComponents.Count; loop++)
|
||||
{
|
||||
|
@ -76,11 +76,6 @@ namespace EduNetworkBuilder
|
||||
|
||||
#region Load and Save
|
||||
//Load and save functions
|
||||
public void Load()
|
||||
{
|
||||
Load(@"C:\Users\tyoung\Desktop\Test.enbx");
|
||||
}
|
||||
|
||||
public void Load(string filename)
|
||||
{
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
@ -128,11 +123,6 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
|
||||
|
||||
public void Save()
|
||||
{
|
||||
Save(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Test.enbx"));
|
||||
}
|
||||
|
||||
public void Save(string filename)
|
||||
{
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
@ -168,7 +158,7 @@ namespace EduNetworkBuilder
|
||||
//Save all the devices
|
||||
foreach (SchoolworkClass One in Projects)
|
||||
{
|
||||
//One.Save(writer);
|
||||
One.Save(writer);
|
||||
}
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace EduNetworkBuilder
|
||||
{
|
||||
@ -34,5 +35,70 @@ namespace EduNetworkBuilder
|
||||
|
||||
bool IsSumbitted = false; //Is the student submitting this? If so, date-stamp it and lock it.
|
||||
DateTime SaveDate; //The date this file was saved.
|
||||
|
||||
public SchoolworkClass(XmlNode TheNode)
|
||||
{
|
||||
Load(TheNode);
|
||||
}
|
||||
|
||||
#region Load and Save
|
||||
//Load and save functions
|
||||
public void Load(XmlNode TheNode)
|
||||
{
|
||||
foreach (XmlNode Individual in TheNode.ChildNodes)
|
||||
{
|
||||
XmlNodeType myNodetype = Individual.NodeType;
|
||||
if (myNodetype == XmlNodeType.Element)
|
||||
{
|
||||
switch (Individual.Name.ToLower())
|
||||
{
|
||||
case "name":
|
||||
Name = Individual.InnerText;
|
||||
break;
|
||||
case "description":
|
||||
Description = Individual.InnerText;
|
||||
break;
|
||||
case "class":
|
||||
Class = Individual.InnerText;
|
||||
break;
|
||||
case "duedate":
|
||||
DateTime.TryParse(Individual.InnerText, out DueDate);
|
||||
break;
|
||||
case "savedate":
|
||||
DateTime.TryParse(Individual.InnerText, out SaveDate);
|
||||
break;
|
||||
case "ismaster":
|
||||
bool.TryParse(Individual.InnerText, out isMaster);
|
||||
break;
|
||||
case "issubmitted":
|
||||
bool.TryParse(Individual.InnerText, out IsSumbitted);
|
||||
break;
|
||||
case "network":
|
||||
theProject = new Network();
|
||||
theProject.Load(Individual, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Save(XmlWriter writer)
|
||||
{
|
||||
//Save the language name
|
||||
//save the number of items
|
||||
//Save all the items
|
||||
writer.WriteStartElement("project");
|
||||
writer.WriteElementString("Name", Name);
|
||||
writer.WriteElementString("Description", Description);
|
||||
writer.WriteElementString("Class", Class);
|
||||
writer.WriteElementString("DueDate", DueDate.ToString());
|
||||
writer.WriteElementString("SaveDate", SaveDate.ToString());
|
||||
writer.WriteElementString("IsMaster", isMaster.ToString());
|
||||
writer.WriteElementString("IsSubmitted", IsSumbitted.ToString());
|
||||
if (theProject != null) theProject.Save(writer);
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user