Get Action list to save

This commit is contained in:
Tim Young 2018-05-14 08:05:56 -05:00
parent 048d461894
commit 76b87b0d18
11 changed files with 41 additions and 9 deletions

View File

@ -12,11 +12,7 @@ namespace EduNetworkBuilder
Network StartingState = null;
public List<NetworkAction> NetActions = new List<NetworkAction>();
NetworkAction CurrentNetAction = null;
bool _HasUnsavedChanges = false;
public bool HasUnsavedChanges {
get { return _HasUnsavedChanges; }
private set { _HasUnsavedChanges = value; }
}
public bool HasUnsavedChanges = false;
public Network GetNet { get { return StartingState; } }
public int GetActionCount { get { if (CurrentNetAction == null) return 0; return CurrentNetAction.Actions.Count; } }
@ -119,6 +115,7 @@ namespace EduNetworkBuilder
/// This tells us if it has been stored to the long-term action list.
/// </summary>
public bool HasBeenStored = false;
public NetworkAction() { }
public NetworkAction(string Name)
{
NetworkName = Name;

View File

@ -24,6 +24,7 @@ namespace EduNetworkBuilder
private IPAddress theNetmask;
private IPAddress theGateway;
public NB_IPAddress() { } //used for reflection
public NB_IPAddress(string ip, string mask, IPAddressType WhatType)
{
myType = WhatType;

View File

@ -297,6 +297,7 @@ namespace EduNetworkBuilder
public string Destination;
public FirewallRuleType Action;
public FirewallRule() { }
public FirewallRule(string source, string dest, FirewallRuleType action)
{
Source = source;

View File

@ -227,6 +227,16 @@ namespace EduNetworkBuilder
//return the id and increment it.
return NextID++;
}
/// <summary>
/// We are saving the ReplayActions. Right now, we are doing this for automatic testing
/// of the puzzles. Regression Testing
/// </summary>
public void SaveActions()
{
NB.WriteToXmlFile(@"c:\Users\TimYo\Desktop\EduNetworkReplay.xml", UserActions);
}
public void Save(bool UsingMono)
{
if(UsingMono)

View File

@ -23,6 +23,7 @@ namespace EduNetworkBuilder
public bool TaskWasDone = false;
public int PacketNumber = -1;
public NetTest() { }
public NetTest(string srcHost, string dstHost, NetTestType tTest)
{
sHost = srcHost;

View File

@ -2863,9 +2863,23 @@ namespace EduNetworkBuilder
StoreReplay();
}
void SaveReplayFile()
{
NBSettings ourSettings = NB.GetSettings();
if (OurSettings != null && OurSettings.ReplayMode)
{
ActionCollection AC = OurSettings.GetUserActionCollection();
if (AC.HasUnsavedChanges)
{
ourSettings.SaveActions();
}
}
}
private void saveReplayToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveReplayFile();
}
}
}

View File

@ -36,6 +36,8 @@ namespace EduNetworkBuilder
public int IFCount { get { return interfaces.Count; } }
public NetworkCard() { }
public NetworkCard(int index, int HostID, string hostname, NicType theType = NicType.eth)
{
myNicType = theType;

View File

@ -41,6 +41,7 @@ namespace EduNetworkBuilder
public int BadSprayCount = 0;
public List<int> PacketIDsPassedThrough = new List<int>();
public NetworkDevice() { }
public NetworkDevice(NetworkComponentType what, string tHostname, Point tLocation, NicType firstNic = NicType.eth)
{
hostname = tHostname;

View File

@ -17,6 +17,9 @@ namespace EduNetworkBuilder
public HostNicID AttachedToHostNic;
public List<VLANInfo> VLANs = new List<VLANInfo>() { new VLANInfo(1, VLANTagType.Untagged ) };
//We should have a feature: none, IP_in_IP_Tunnel, encrypted_vpn, vlan, etc
public NetworkInterface() { }
public NetworkInterface(string name, string IP, string Mask, HostNicID AttachedTo)
{
nic_name = name;

View File

@ -17,6 +17,8 @@ namespace EduNetworkBuilder
public LinkType theLinkType = LinkType.normal;
public bool isVisibleLink = true; //False for wireless. Skip drawing a line if it is there
public NetworkLink() { }
public NetworkLink(HostNicID source, HostNicID dest, LinkType type = LinkType.normal)
{
SrcNic = source;