Disable Options menu when we loaded a puzzle from a resource. Cleaned up the load system a little bit.

This commit is contained in:
Tim Young 2017-07-20 14:50:03 -05:00
parent 66db081eab
commit 437bb2601e
2 changed files with 48 additions and 29 deletions

View File

@ -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<NetworkComponent> NetComponents = new List<NetworkComponent>();
@ -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;
}
/// <summary>
/// For solved puzzles. We can add options to them
/// </summary>
public void OverrideFromResources()
{
LoadedFromResource = false;
}
public void DoAllClearArp()
{
NetworkDevice nd;

View File

@ -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)