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)
{
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;
tPoint = tDevice.myLocation();
if (tPoint.X + tsize >= area.X && tPoint.Y +tsize >= area.Y)

View File

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

View File

@ -459,6 +459,14 @@ namespace EduNetworkBuilder
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)
{
isDNSServer = isDNS;