Get network links to use Actions
This commit is contained in:
parent
8b82150bbe
commit
617c5e2dc3
@ -146,7 +146,7 @@ namespace EduNetworkBuilder
|
|||||||
public HostNicID DestNic; //Used for links
|
public HostNicID DestNic; //Used for links
|
||||||
public Point Location; //Used when making a new device or moving an old device
|
public Point Location; //Used when making a new device or moving an old device
|
||||||
public NetworkComponentType newItemType = NetworkComponentType.none; //Making new device
|
public NetworkComponentType newItemType = NetworkComponentType.none; //Making new device
|
||||||
public NetworkDevice ChangedDevice = null;
|
public NetworkComponent ChangedComponent = null;
|
||||||
|
|
||||||
public void DoAction()
|
public void DoAction()
|
||||||
{
|
{
|
||||||
@ -156,7 +156,21 @@ namespace EduNetworkBuilder
|
|||||||
|
|
||||||
switch (Action)
|
switch (Action)
|
||||||
{
|
{
|
||||||
case NBAction.changedevice:
|
case NBAction.changecomponent:
|
||||||
|
//This could be a link or a device we are changing.
|
||||||
|
if(ChangedComponent is NetworkDevice)
|
||||||
|
{
|
||||||
|
source.UpdateFromComponent(ChangedComponent); //Copy any changes across
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ //It is a link. Delete the old, make the new. Mark as linked
|
||||||
|
if(source != null)
|
||||||
|
myNet.RemoveComponent(source);
|
||||||
|
NetworkLink NL = (NetworkLink)ChangedComponent;
|
||||||
|
myNet.MarkAsLinked(NL.Src, NL.GetUniqueIdentifier);
|
||||||
|
myNet.MarkAsLinked(NL.Dst, NL.GetUniqueIdentifier);
|
||||||
|
myNet.AddItem(ChangedComponent);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NBAction.changelocation:
|
case NBAction.changelocation:
|
||||||
if (source != null)
|
if (source != null)
|
||||||
@ -195,7 +209,7 @@ namespace EduNetworkBuilder
|
|||||||
Point TopRight = new Point(TopLeft.X + myNet.itemsize, TopLeft.Y);
|
Point TopRight = new Point(TopLeft.X + myNet.itemsize, TopLeft.Y);
|
||||||
Point BottomRight = new Point(TopLeft.X + myNet.itemsize, TopLeft.Y + myNet.itemsize);
|
Point BottomRight = new Point(TopLeft.X + myNet.itemsize, TopLeft.Y + myNet.itemsize);
|
||||||
Point BottomLeft = new Point(TopLeft.X, TopLeft.Y + myNet.itemsize);
|
Point BottomLeft = new Point(TopLeft.X, TopLeft.Y + myNet.itemsize);
|
||||||
ChangedDevice = null; //if we cannot place it, this = null for reference
|
ChangedComponent = null; //if we cannot place it, this = null for reference
|
||||||
if (myNet.BlockedByTree(Location)) CanDo = false;
|
if (myNet.BlockedByTree(Location)) CanDo = false;
|
||||||
if (myNet.BlockedByTree(TopLeft)) CanDo = false;
|
if (myNet.BlockedByTree(TopLeft)) CanDo = false;
|
||||||
if (myNet.BlockedByTree(TopRight)) CanDo = false;
|
if (myNet.BlockedByTree(TopRight)) CanDo = false;
|
||||||
@ -203,7 +217,7 @@ namespace EduNetworkBuilder
|
|||||||
if (myNet.BlockedByTree(BottomLeft)) CanDo = false;
|
if (myNet.BlockedByTree(BottomLeft)) CanDo = false;
|
||||||
if (CanDo)
|
if (CanDo)
|
||||||
{
|
{
|
||||||
ChangedDevice = (NetworkDevice)myNet.AddItem(newItemType, Location);
|
ChangedComponent = (NetworkDevice)myNet.AddItem(newItemType, Location);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -228,11 +228,17 @@ namespace EduNetworkBuilder
|
|||||||
if(EditingLink != null)
|
if(EditingLink != null)
|
||||||
{
|
{
|
||||||
Net.RemoveComponent(EditingLink); //get rid of the old one and put the new one in
|
Net.RemoveComponent(EditingLink); //get rid of the old one and put the new one in
|
||||||
EditingLink = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkLink newLink = NewLinkFromSettings();
|
NetworkLink newLink = NewLinkFromSettings();
|
||||||
Net.AddItem(newLink);
|
//Net.AddItem(newLink);
|
||||||
|
int OldLinkID = -1;
|
||||||
|
if (EditingLink != null) OldLinkID = EditingLink.GetUniqueIdentifier;
|
||||||
|
NB.DoActionChangeComponent(OldLinkID,newLink);
|
||||||
|
if (EditingLink != null)
|
||||||
|
{
|
||||||
|
EditingLink = null;
|
||||||
|
}
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ namespace EduNetworkBuilder
|
|||||||
public enum HowToBreak { PowerOff, EthernetBreak, EthernetCorrupt, EthernetRemoveLink, LockOutSwitch,
|
public enum HowToBreak { PowerOff, EthernetBreak, EthernetCorrupt, EthernetRemoveLink, LockOutSwitch,
|
||||||
WirelessBreakSSID, WirelessBreakKey, DeviceChangeIP, DeviceChangeGW, StaticRouteClear,
|
WirelessBreakSSID, WirelessBreakKey, DeviceChangeIP, DeviceChangeGW, StaticRouteClear,
|
||||||
StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey, BreakDevice }
|
StaticRouteCorrupt, VLANChange, VPNChangeEndpoint, VPNChangeKey, BreakDevice }
|
||||||
public enum NBAction { none, newdevice, changelocation, changedevice, deletecomponent,
|
public enum NBAction { none, newdevice, changelocation, changecomponent, deletecomponent,
|
||||||
|
|
||||||
ping, traceroute, arp, cleararp, dhcp }
|
ping, traceroute, arp, cleararp, dhcp }
|
||||||
|
|
||||||
@ -1408,7 +1408,7 @@ namespace EduNetworkBuilder
|
|||||||
|
|
||||||
AC.DoAction();
|
AC.DoAction();
|
||||||
|
|
||||||
return AC.ChangedDevice;
|
return AC.ChangedComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoActionPingDevice(int HostID, NB_IPAddress Destination)
|
public static void DoActionPingDevice(int HostID, NB_IPAddress Destination)
|
||||||
@ -1469,6 +1469,18 @@ namespace EduNetworkBuilder
|
|||||||
|
|
||||||
AC.DoAction();
|
AC.DoAction();
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void DoActionChangeComponent(int HostID, NetworkComponent Changed)
|
||||||
|
{
|
||||||
|
ActionClass AC = new ActionClass();
|
||||||
|
AC.Action = NBAction.changecomponent;
|
||||||
|
AC.SourceID = HostID;
|
||||||
|
AC.ChangedComponent = Changed;
|
||||||
|
|
||||||
|
RegisterAction(AC);
|
||||||
|
|
||||||
|
AC.DoAction();
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion ActionFunctions
|
#endregion ActionFunctions
|
||||||
|
|
||||||
|
@ -815,6 +815,7 @@ namespace EduNetworkBuilder
|
|||||||
|
|
||||||
public void RemoveComponent(NetworkComponent tItem)
|
public void RemoveComponent(NetworkComponent tItem)
|
||||||
{
|
{
|
||||||
|
if (tItem == null) return; //Exit early if we are not removing anything
|
||||||
for (int i = NetComponents.Count -1; i >= 0; i--)
|
for (int i = NetComponents.Count -1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (NetComponents[i] == tItem)
|
if (NetComponents[i] == tItem)
|
||||||
|
Loading…
Reference in New Issue
Block a user