Have a move location action

This commit is contained in:
Tim Young 2018-05-04 06:35:01 -05:00
parent 2efca90da1
commit 51087c1119
2 changed files with 57 additions and 4 deletions

View File

@ -107,10 +107,41 @@ namespace EduNetworkBuilder
public class ActionClass public class ActionClass
{ {
public int SourceID = -1; public NBAction Action = NBAction.none;
public int DestID = -1; public int SourceID = -1; //used for basically everything
public Point Location; public int DestID = -1; //used for pinging, arp, traceroute
public NetworkComponentType newItemType = NetworkComponentType.none; 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 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;
}
}
} }
} }

View File

@ -1359,6 +1359,28 @@ namespace EduNetworkBuilder
} }
#endregion #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
} }
} }