diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index 79703b0..a5a9158 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -28,6 +28,11 @@ namespace EduNetworkBuilder public bool ShowLabelsHere = false; public bool VLANsEnabled = false; public bool VLANPacketColors = false; + private bool _LoadedFromResource = false; //If we are a puzzle that is built-into the program + public bool LoadedFromResource { + get { return _LoadedFromResource; } + private set { _LoadedFromResource = value; } + } public LanguageStrings NetMessage; public LanguageStrings NetTitle; List NetComponents = new List(); @@ -113,13 +118,14 @@ namespace EduNetworkBuilder } } - public void Load(XmlNode TheNode, string Name) + public void Load(XmlNode TheNode, string Name, bool FromResource=false) { _isDirty = true; NetworkDevice newND; NetworkLink newNL; int newUnique=-1; PuzzleName = Name; + LoadedFromResource = FromResource; foreach (XmlNode Individual in TheNode.ChildNodes) { XmlNodeType myNodetype = Individual.NodeType; @@ -129,7 +135,7 @@ namespace EduNetworkBuilder { case "edunetworkbuilder": case "network": - Load(Individual,PuzzleName); + Load(Individual,PuzzleName, FromResource); break; case "showlabels": bool.TryParse(Individual.InnerText, out OptionShowLabels); @@ -1522,6 +1528,14 @@ namespace EduNetworkBuilder return -1; } + /// + /// For solved puzzles. We can add options to them + /// + public void OverrideFromResources() + { + LoadedFromResource = false; + } + public void DoAllClearArp() { NetworkDevice nd; diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index c15c16d..780b727 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -400,6 +400,10 @@ namespace EduNetworkBuilder UpdateMenu(); UpdateMessages(); UpdateVisuals(); + if (myNetwork != null && myNetwork.LoadedFromResource) + optionsToolStripMenuItem.Visible = false; + else + optionsToolStripMenuItem.Visible = true; processing = true; cbViewTitles.Checked = myNetwork.ShowLabelsHere; Text = NB.Translate("NB_UpdteFrmName", OurSettings); @@ -1530,76 +1534,77 @@ namespace EduNetworkBuilder //myString = System.Text.Encoding.Default.GetString(item); xmlDoc.LoadXml(myString); PrepForLoad(); - myNetwork.Load(xmlDoc,resource); + myNetwork.Load(xmlDoc,resource, true);//Load it from resource. Set the bool saying it was from resource UpdateMenu(); UpdateForm(); } + private void LoadSolvedResource(string what) + { + LoadNetworkFromResource(what); + myNetwork.OverrideFromResources(); + UpdateForm(); + UpdateMessages(); + } + + private void LoadUnsolvedResource(string what) + { + //Load the puzzle & everything we need to do with it + LoadSolvedResource(what); + //Then "unsolve" it + myNetwork.DoAllClearIPs(); + } + private void oneNetworkToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("OneNet"); - UpdateMessages(); + LoadSolvedResource("OneNet"); } private void twoNetworksToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("TwoNets"); - UpdateMessages(); + LoadSolvedResource("TwoNets"); } private void dHCPToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("DHCP"); - UpdateMessages(); + LoadSolvedResource("DHCP"); } private void solvedOneNetworkToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("OneNet"); - myNetwork.DoAllClearIPs(); - UpdateMessages(); + LoadUnsolvedResource("OneNet"); } private void solvedTwoNetworksToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("TwoNets"); - myNetwork.DoAllClearIPs(); - UpdateMessages(); + LoadUnsolvedResource("TwoNets"); } private void solvedDHCPToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("DHCP"); - myNetwork.DoAllClearIPs(); - UpdateMessages(); + //Umm. The function name is solved, but we are doing the unsolved version? + LoadUnsolvedResource("DHCP"); } private void VLANToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("VLAN"); - UpdateMessages(); + LoadSolvedResource("VLAN"); } private void SolvedVLANToolStripMenuItem1_Click(object sender, EventArgs e) { - LoadNetworkFromResource("VLAN"); - myNetwork.DoAllClearIPs(); - UpdateMessages(); - UpdateVisuals(); + LoadUnsolvedResource("VLAN"); } private void threeNetworksToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("ThreeNets"); - UpdateMessages(); + LoadSolvedResource("ThreeNets"); } private void SolvedThreeNetworksToolStripMenuItem_Click(object sender, EventArgs e) { - LoadNetworkFromResource("ThreeNets"); - myNetwork.DoAllClearIPs(); - UpdateMessages(); + LoadUnsolvedResource("ThreeNets"); } private void newToolStripMenuItem_Click(object sender, EventArgs e)