Get invisible Network to complet auto dhcp request at beginning

This commit is contained in:
Tim Young 2017-08-16 10:47:08 -05:00
parent 04782b2456
commit 00f886080f
3 changed files with 67 additions and 4 deletions

View File

@ -410,8 +410,23 @@ namespace EduNetworkBuilder
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"]; BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
if (myWin == null) return null; if (myWin == null) return null;
if (myWin.GameRandomGen == null) return null; if (myWin.GameRandomGen == null) return null;
return myWin.myNetwork; return myWin.GetNetwork();
} }
public static void RegisterInvisibleNetwork(Network ToRegister)
{
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
if (myWin == null) return;
myWin.RegisterInisibleNet(ToRegister);
}
public static void UnregisterInvisibleNetwork()
{
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];
if (myWin == null) return;
myWin.UnregisterInvisibleNet();
}
public static void MarkToUpdate() public static void MarkToUpdate()
{ {
BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"]; BuilderWindow myWin = (BuilderWindow)Application.OpenForms["BuilderWindow"];

View File

@ -1772,6 +1772,16 @@ namespace EduNetworkBuilder
return b; return b;
} }
public void DumpInvisibleNetMessages()
{
List<string> messages = GetMessageStrings();
foreach(string one in messages)
{
Console.WriteLine(one);
}
myMessages.Clear();
}
/// <summary> /// <summary>
/// This func tries to non-visually process all the tests, seeing if the network is /// This func tries to non-visually process all the tests, seeing if the network is
/// "solved." This is for homework that is "submitted." /// "solved." This is for homework that is "submitted."
@ -1779,13 +1789,34 @@ namespace EduNetworkBuilder
public HomeworkSolvedStatus CheckThatHomeworkIsSolved() public HomeworkSolvedStatus CheckThatHomeworkIsSolved()
{ {
bool HadIssues = false; bool HadIssues = false;
NB.RegisterInvisibleNetwork(this);
DoAllMarkAsLinked();
//do dhcp request on everything.
DoAllDHCP();
NonVisualProcessPacketsOnce(); //loop until we "timeout" or all packets are done.
DumpInvisibleNetMessages();
foreach (NetTest NT in NetTests) foreach (NetTest NT in NetTests)
{ {
//Here we test it.
} }
NB.UnregisterInvisibleNetwork();
if(HadIssues) if(HadIssues)
return HomeworkSolvedStatus.CheckedFailed; return HomeworkSolvedStatus.CheckedFailed;
return HomeworkSolvedStatus.CheckedSucceeded; return HomeworkSolvedStatus.NeverChecked; //for now. We want to change this later. Just so we keep re-testing
}
public void NonVisualProcessPacketsOnce()
{
int counter = 0;
while(counter < 1000 && myPackets.Count >0)
{
Tick(true); //Skip visuals
counter++;
}
} }
} }

View File

@ -25,6 +25,7 @@ namespace EduNetworkBuilder
public DebugPausePoint DebugSetting = DebugPausePoint.none; public DebugPausePoint DebugSetting = DebugPausePoint.none;
// 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 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();
@ -2136,5 +2137,21 @@ namespace EduNetworkBuilder
//rebuild menu //rebuild menu
UpdateMenu(); UpdateMenu();
} }
public Network GetNetwork()
{
if (InvisibleNetwork != null) return InvisibleNetwork;
return myNetwork;
}
public void RegisterInisibleNet(Network toRegister)
{
InvisibleNetwork = toRegister;
}
public void UnregisterInvisibleNet()
{
InvisibleNetwork = null;
}
} }
} }