Impose a small delay in centering items. Makes it work smoother when simply right-clicking to do a menu or something.

This commit is contained in:
Tim Young 2017-08-17 17:27:22 -05:00
parent 4e9399f9b5
commit d63452813a

View File

@ -33,6 +33,7 @@ namespace EduNetworkBuilder
private Point ClickedLocation;
private Point ClickedImageLocation;
DateTime LastClick = DateTime.Now;
DateTime LastMouseDown = DateTime.Now;
private string LastPath = "";
private bool processing = false;
private List<PuzzleInfo> PuzzleList = new List<PuzzleInfo>();
@ -1273,6 +1274,7 @@ namespace EduNetworkBuilder
//See if we have clicked on something
ItemClickedOn = myNetwork.ItemAtPosition(location);
MouseIsDown = true;
LastMouseDown = DateTime.UtcNow;
//Make a duplicate of the old background image.
LastBackgroundImage = new Bitmap(pbNetworkView.BackgroundImage);
}
@ -1330,7 +1332,9 @@ namespace EduNetworkBuilder
else if (MouseIsDown && LastBackgroundImage != null && ItemClickedOn != null && ItemsSelected.Count == 0) //We are trying to drag something
{
//find where we are
DragItemToNewLocation(ItemClickedOn, CenteredLocation);
TimeSpan HowLong = DateTime.UtcNow - LastMouseDown;
if(HowLong.TotalMilliseconds > 100)
DragItemToNewLocation(ItemClickedOn, CenteredLocation);
}
else if (MouseIsDown && ItemsSelected.Count >0) //dragging multiple items around
{