Launch a network from homework

This commit is contained in:
Tim Young 2017-07-31 17:01:03 -05:00
parent 60a062757a
commit 746e9edb36
4 changed files with 27 additions and 2 deletions

View File

@ -66,6 +66,11 @@ namespace EduNetworkBuilder
private List<Image> PacketImages = new List<Image>(); private List<Image> PacketImages = new List<Image>();
private List<PingTestStatus> PingTestStats = new List<PingTestStatus>(); private List<PingTestStatus> PingTestStats = new List<PingTestStatus>();
/// <summary>
/// WhatFrom: If we are launched from a homework, we remember it here.
/// </summary>
public SchoolworkClass WhatFrom = null;
public Network(string Name) public Network(string Name)
{ {
TheNetImage = new Bitmap(myWidth, myHeight); TheNetImage = new Bitmap(myWidth, myHeight);
@ -113,6 +118,7 @@ namespace EduNetworkBuilder
dest.PacketColors = source.PacketColors; dest.PacketColors = source.PacketColors;
dest.PuzzleName = source.PuzzleName; dest.PuzzleName = source.PuzzleName;
dest.NetMessage = new LanguageStrings(source.NetMessage); dest.NetMessage = new LanguageStrings(source.NetMessage);
dest.WhatFrom = source.WhatFrom; //We remember the schoolwork class we came from.
} }
public Network Clone() public Network Clone()

View File

@ -1579,6 +1579,17 @@ namespace EduNetworkBuilder
UpdateForm(); UpdateForm();
} }
public void LoadLetworkFromNetwork(Network NewNet)
{
if (NewNet != null)
{
PrepForLoad();
Network.Clone(NewNet, myNetwork); //Push the settings
UpdateMenu();
UpdateForm();
}
}
private void LoadSolvedResource(string what) private void LoadSolvedResource(string what)
{ {
LoadNetworkFromResource(what); LoadNetworkFromResource(what);

View File

@ -306,6 +306,7 @@ namespace EduNetworkBuilder
dtpHWDue.Visible = false; dtpHWDue.Visible = false;
lblHWDue.Visible = false; lblHWDue.Visible = false;
btnHWDelete.Visible = false; btnHWDelete.Visible = false;
btnLaunch.Visible = false;
return; return;
} }
tbHWClass.Text = ViewedSchoolwork.Class; tbHWClass.Text = ViewedSchoolwork.Class;
@ -328,6 +329,7 @@ namespace EduNetworkBuilder
dtpHWDue.Value = ViewedSchoolwork.DueDate; dtpHWDue.Value = ViewedSchoolwork.DueDate;
if(CurrentUser != null && CurrentUser.isAdmin) if(CurrentUser != null && CurrentUser.isAdmin)
btnHWDelete.Visible = true; //Only the teacher can delete the homework btnHWDelete.Visible = true; //Only the teacher can delete the homework
btnLaunch.Visible = true;
} }
private void btnHWDelete_Click(object sender, EventArgs e) private void btnHWDelete_Click(object sender, EventArgs e)
@ -348,7 +350,13 @@ namespace EduNetworkBuilder
private void btLaunch_Click(object sender, EventArgs e) private void btLaunch_Click(object sender, EventArgs e)
{ {
BuilderWindow BW = NB.GetBuilderWin();
if(BW != null && ViewedSchoolwork != null && ViewedSchoolwork.theProject != null)
{
ViewedSchoolwork.theProject.WhatFrom = ViewedSchoolwork; //Store the homework info. Used for pushing it back
BW.LoadLetworkFromNetwork(ViewedSchoolwork.theProject);
Close(); //Exit out of the profile
}
} }
} }
} }

View File

@ -13,7 +13,7 @@ namespace EduNetworkBuilder
/// </summary> /// </summary>
public class SchoolworkClass public class SchoolworkClass
{ {
Network theProject = null; public Network theProject = null;
/// <summary> /// <summary>
/// The name of the project. Homework3, Quiz 4, etc. /// The name of the project. Homework3, Quiz 4, etc.
/// </summary> /// </summary>