Have a move location action
This commit is contained in:
parent
2efca90da1
commit
51087c1119
@ -107,10 +107,41 @@ namespace EduNetworkBuilder
|
||||
|
||||
public class ActionClass
|
||||
{
|
||||
public int SourceID = -1;
|
||||
public int DestID = -1;
|
||||
public Point Location;
|
||||
public NetworkComponentType newItemType = NetworkComponentType.none;
|
||||
public NBAction Action = NBAction.none;
|
||||
public int SourceID = -1; //used for basically everything
|
||||
public int DestID = -1; //used for pinging, arp, traceroute
|
||||
public HostNicID SourceNIC; //used for links
|
||||
public HostNicID DestNic; //Used for links
|
||||
public Point Location; //Used when making a new device or moving an old device
|
||||
public NetworkComponentType newItemType = NetworkComponentType.none; //Making new device
|
||||
public NetworkDevice ChangedDevice = null;
|
||||
|
||||
public void DoAction()
|
||||
{
|
||||
Network myNet = NB.GetNetwork();
|
||||
NetworkDevice source = myNet.GetDeviceFromID(SourceID);
|
||||
NetworkDevice dest = myNet.GetDeviceFromID(DestID);
|
||||
|
||||
switch (Action)
|
||||
{
|
||||
case NBAction.changedevice:
|
||||
break;
|
||||
case NBAction.changelocation:
|
||||
if (source != null) source.ChangeLocation(Location);
|
||||
break;
|
||||
case NBAction.deletecomponent:
|
||||
break;
|
||||
case NBAction.newdevice:
|
||||
break;
|
||||
case NBAction.dhcp:
|
||||
break;
|
||||
case NBAction.arp:
|
||||
break;
|
||||
case NBAction.ping:
|
||||
break;
|
||||
case NBAction.traceroute:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1359,6 +1359,28 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ActionFunctions
|
||||
public static void RegisterAction(ActionClass What)
|
||||
{
|
||||
if (What == null) return;
|
||||
NBSettings mySettings = GetSettings();
|
||||
if (mySettings == null) return;
|
||||
mySettings.RegisterActionDone(What);
|
||||
}
|
||||
|
||||
public static void DoActionMoveDevice(int HostID, Point Location)
|
||||
{
|
||||
//Make an action for the location, register the action, and do the action
|
||||
ActionClass AC = new ActionClass();
|
||||
AC.Action = NBAction.changelocation;
|
||||
AC.SourceID = HostID;
|
||||
AC.Location = Location;
|
||||
|
||||
RegisterAction(AC);
|
||||
|
||||
AC.DoAction();
|
||||
}
|
||||
#endregion ActionFunctions
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user