Get reload to work properly

This commit is contained in:
Tim Young 2018-10-23 07:57:02 -05:00
parent e6e6328eca
commit c8c66970d0

View File

@ -26,6 +26,7 @@ namespace EduNetworkBuilder
// public DebugPausePoint DebugSetting = DebugPausePoint.all | DebugPausePoint.dump; // public DebugPausePoint DebugSetting = DebugPausePoint.all | DebugPausePoint.dump;
public Network myNetwork = new Network(""); public Network myNetwork = new Network("");
private Network InvisibleNetwork = null; private Network InvisibleNetwork = null;
private Network OrigNetworkAfterLoad = null;
private List<Control> Buttons = new List<Control>(); private List<Control> Buttons = new List<Control>();
private string selectedButton = ""; private string selectedButton = "";
ToolTip myTooltip = new ToolTip(); ToolTip myTooltip = new ToolTip();
@ -532,7 +533,7 @@ namespace EduNetworkBuilder
public void UpdateMenu() public void UpdateMenu()
{ {
if (myNetwork.NetworkFilename != "" || storedNetworkStates.Count > 0) if (myNetwork.NetworkFilename != "" || OrigNetworkAfterLoad != null)
{ {
reloadToolStripMenuItem.Enabled = true; reloadToolStripMenuItem.Enabled = true;
} }
@ -2035,13 +2036,10 @@ namespace EduNetworkBuilder
} }
else else
{ {
if(storedNetworkStates.Count > 0) if(OrigNetworkAfterLoad != null)
{ {
Network theNet = storedNetworkStates[storedNetworkStates.Count -1];
storedNetworkStates.Clear();
ForwardstoredNetworkStates.Clear();
PrepForLoad(); PrepForLoad();
LoadNetworkFromNetwork(theNet); LoadNetworkFromNetwork(OrigNetworkAfterLoad);
} }
} }
if(OurSettings.ReplayMode) if(OurSettings.ReplayMode)
@ -2212,6 +2210,7 @@ namespace EduNetworkBuilder
xmlDoc.LoadXml(myString); xmlDoc.LoadXml(myString);
PrepForLoad(); PrepForLoad();
myNetwork.Load(xmlDoc, resource, true, SkipOpeningWindows);//Load it from resource. Set the bool saying it was from resource myNetwork.Load(xmlDoc, resource, true, SkipOpeningWindows);//Load it from resource. Set the bool saying it was from resource
RegisterRecentlyLoadedNet(myNetwork);
StoreNetworkState(myNetwork); //Store a clean state StoreNetworkState(myNetwork); //Store a clean state
UpdateMenu(); UpdateMenu();
UpdateForm(); UpdateForm();
@ -2224,6 +2223,7 @@ namespace EduNetworkBuilder
PrepForLoad(); PrepForLoad();
Network.Clone(NewNet, myNetwork); //Push the settings Network.Clone(NewNet, myNetwork); //Push the settings
myNetwork.OpenHelpIfNeeded(false); //Open it up, not skipping the help file (open help if the puzzle wants it) myNetwork.OpenHelpIfNeeded(false); //Open it up, not skipping the help file (open help if the puzzle wants it)
RegisterRecentlyLoadedNet(myNetwork);
myNetwork.DoAllMarkAsLinked(); myNetwork.DoAllMarkAsLinked();
UpdateMenu(); UpdateMenu();
UpdateLinks(); UpdateLinks();
@ -2241,10 +2241,16 @@ namespace EduNetworkBuilder
LoadNetworkFromResource(what); LoadNetworkFromResource(what);
StoreNetworkState(myNetwork); //Store a clean state StoreNetworkState(myNetwork); //Store a clean state
myNetwork.OverrideFromResources(); myNetwork.OverrideFromResources();
RegisterRecentlyLoadedNet(myNetwork);
UpdateForm(); UpdateForm();
UpdateMessages(); UpdateMessages();
} }
public void RegisterRecentlyLoadedNet(Network ToRegister)
{
OrigNetworkAfterLoad = Network.DeepClone(ToRegister);
}
private void LoadUnsolvedResource(string what) private void LoadUnsolvedResource(string what)
{ {
//Load the puzzle & everything we need to do with it //Load the puzzle & everything we need to do with it
@ -2253,6 +2259,7 @@ namespace EduNetworkBuilder
myNetwork.DoAllClearIPs(); myNetwork.DoAllClearIPs();
myNetwork.OverrideFromResources(); myNetwork.OverrideFromResources();
StoreNetworkState(myNetwork); //Store a clean state StoreNetworkState(myNetwork); //Store a clean state
RegisterRecentlyLoadedNet(myNetwork);
UpdateForm(); UpdateForm();
UpdateMessages(); UpdateMessages();
} }