From 2efca90da19ec012e573090bdd458eb167c3ca65 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Thu, 3 May 2018 12:58:54 -0500 Subject: [PATCH] register network with ActionCollection when loaded --- EduNetworkBuilder/ActionClass.cs | 17 +++++++++++++++++ EduNetworkBuilder/NBSettings.cs | 14 ++++++++++++++ EduNetworkBuilder/Network.cs | 4 ++++ 3 files changed, 35 insertions(+) diff --git a/EduNetworkBuilder/ActionClass.cs b/EduNetworkBuilder/ActionClass.cs index 752ccb0..1fa0171 100644 --- a/EduNetworkBuilder/ActionClass.cs +++ b/EduNetworkBuilder/ActionClass.cs @@ -29,6 +29,23 @@ namespace EduNetworkBuilder CurrentNetAction.Add(What); } + /// + /// Take the current actionlist and save it to the stored actionlists. + /// We use this when we have successfully solved a network and want to store + /// this solution process + /// + public void PushActionToList() + { + //remove an old one if it exists + if (CurrentNetAction != null) + { + NetworkAction NA = GetActionlistFromName(CurrentNetAction.NetworkName); + if (NA != null) NetActions.Remove(NA); + } + //Add this one + NetActions.Add(CurrentNetAction); + } + /// /// Return true if we already have a solved state for this network /// diff --git a/EduNetworkBuilder/NBSettings.cs b/EduNetworkBuilder/NBSettings.cs index 9619190..520bc17 100644 --- a/EduNetworkBuilder/NBSettings.cs +++ b/EduNetworkBuilder/NBSettings.cs @@ -36,6 +36,7 @@ namespace EduNetworkBuilder public string LastTrans1Lang = ""; public string LastTrans2Lang = ""; public string FormLastTransDir = ""; + protected ActionCollection UserActions = new ActionCollection(); public NBSettings() { @@ -48,6 +49,19 @@ namespace EduNetworkBuilder Duplicate(fromSettings, this); } + public void RegisterNetAsStarted(Network newnet) + { + UserActions.RegisterNet(newnet); + } + public void RegisterActionDone(ActionClass What) + { + UserActions.Add(What); + } + public ActionCollection GetUserActionCollection() + { + return UserActions; + } + static void Duplicate(NBSettings FromClass, NBSettings ToClass) { if (FromClass == null) return; //Break if we are going to error out. diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index 829c43c..94560ee 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -421,6 +421,10 @@ namespace EduNetworkBuilder maxUI = nc.GetUniqueIdentifier; } if (maxUI <= UniqueIdentifier) UniqueIdentifier = maxUI + 1; + + //Register this in the user settings + NBSettings tSettings = NB.GetSettings(); + if (tSettings != null) tSettings.RegisterNetAsStarted(this); } public void OpenHelpIfNeeded(bool skipOpeningWindows)