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 Network myNetwork = new Network("");
private Network InvisibleNetwork = null;
private Network OrigNetworkAfterLoad = null;
private List<Control> Buttons = new List<Control>();
private string selectedButton = "";
ToolTip myTooltip = new ToolTip();
@ -532,7 +533,7 @@ namespace EduNetworkBuilder
public void UpdateMenu()
{
if (myNetwork.NetworkFilename != "" || storedNetworkStates.Count > 0)
if (myNetwork.NetworkFilename != "" || OrigNetworkAfterLoad != null)
{
reloadToolStripMenuItem.Enabled = true;
}
@ -2035,13 +2036,10 @@ namespace EduNetworkBuilder
}
else
{
if(storedNetworkStates.Count > 0)
if(OrigNetworkAfterLoad != null)
{
Network theNet = storedNetworkStates[storedNetworkStates.Count -1];
storedNetworkStates.Clear();
ForwardstoredNetworkStates.Clear();
PrepForLoad();
LoadNetworkFromNetwork(theNet);
LoadNetworkFromNetwork(OrigNetworkAfterLoad);
}
}
if(OurSettings.ReplayMode)
@ -2212,6 +2210,7 @@ namespace EduNetworkBuilder
xmlDoc.LoadXml(myString);
PrepForLoad();
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
UpdateMenu();
UpdateForm();
@ -2224,6 +2223,7 @@ namespace EduNetworkBuilder
PrepForLoad();
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)
RegisterRecentlyLoadedNet(myNetwork);
myNetwork.DoAllMarkAsLinked();
UpdateMenu();
UpdateLinks();
@ -2241,10 +2241,16 @@ namespace EduNetworkBuilder
LoadNetworkFromResource(what);
StoreNetworkState(myNetwork); //Store a clean state
myNetwork.OverrideFromResources();
RegisterRecentlyLoadedNet(myNetwork);
UpdateForm();
UpdateMessages();
}
public void RegisterRecentlyLoadedNet(Network ToRegister)
{
OrigNetworkAfterLoad = Network.DeepClone(ToRegister);
}
private void LoadUnsolvedResource(string what)
{
//Load the puzzle & everything we need to do with it
@ -2253,6 +2259,7 @@ namespace EduNetworkBuilder
myNetwork.DoAllClearIPs();
myNetwork.OverrideFromResources();
StoreNetworkState(myNetwork); //Store a clean state
RegisterRecentlyLoadedNet(myNetwork);
UpdateForm();
UpdateMessages();
}