Finish locking items in location. Can no longer move them if they are locked.

This commit is contained in:
Tim Young 2018-03-01 17:25:07 -06:00
parent 1ada144423
commit 56b680e057
3 changed files with 18 additions and 7 deletions

View File

@ -575,7 +575,7 @@ namespace EduNetworkBuilder
if (tItem is NetworkDevice) if (tItem is NetworkDevice)
{ {
tDevice = (NetworkDevice)tItem; tDevice = (NetworkDevice)tItem;
if (tDevice.GetNetType() == NetworkComponentType.tree) continue; //Cannot select trees if (tDevice.IsLockedInLocation()) continue; //some items cannot be moved
int tsize = tDevice.Size; int tsize = tDevice.Size;
tPoint = tDevice.myLocation(); tPoint = tDevice.myLocation();
if (tPoint.X + tsize >= area.X && tPoint.Y +tsize >= area.Y) if (tPoint.X + tsize >= area.X && tPoint.Y +tsize >= area.Y)

View File

@ -1661,10 +1661,13 @@ namespace EduNetworkBuilder
{ {
if (Math.Abs(ClickedLocation.X - ClickLocation.X) > 5 || Math.Abs(ClickedLocation.Y - ClickLocation.Y) > 5) if (Math.Abs(ClickedLocation.X - ClickLocation.X) > 5 || Math.Abs(ClickedLocation.Y - ClickLocation.Y) > 5)
{ {
ItemClickedOn.ChangeLocation(CenteredLocation); if (!ItemClickedOn.IsLockedInLocation())
ItemClickedOn.UnHide(); //If it was hidden, unhide it {
UpdateLinks(); ItemClickedOn.ChangeLocation(CenteredLocation);
UpdateVisuals(); ItemClickedOn.UnHide(); //If it was hidden, unhide it
UpdateLinks();
UpdateVisuals();
}
} }
} }
} }
@ -1769,7 +1772,7 @@ namespace EduNetworkBuilder
{ {
//find where we are //find where we are
TimeSpan HowLong = DateTime.UtcNow - LastMouseDown; TimeSpan HowLong = DateTime.UtcNow - LastMouseDown;
if(HowLong.TotalMilliseconds > 100) if(HowLong.TotalMilliseconds > 100 && !ItemClickedOn.IsLockedInLocation())
DragItemToNewLocation(ItemClickedOn, CenteredLocation); DragItemToNewLocation(ItemClickedOn, CenteredLocation);
} }
else if (MouseIsDown && ItemsSelected.Count >0) //dragging multiple items around else if (MouseIsDown && ItemsSelected.Count >0) //dragging multiple items around

View File

@ -459,6 +459,14 @@ namespace EduNetworkBuilder
writer.WriteEndElement(); writer.WriteEndElement();
} }
public bool IsLockedInLocation()
{
if (myType == NetworkComponentType.tree) return true; //Trees are always stationary
Network myNet = NB.GetNetwork();
if (myNet.ItemHasTest(hostname, NetTestType.LockLocation)) return true;
return false;
}
public void SetDNSServer(bool isDNS) public void SetDNSServer(bool isDNS)
{ {
isDNSServer = isDNS; isDNSServer = isDNS;