From 49be222b5d9123e7e23588a0f3799a44f53595e7 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 14 Jun 2017 14:15:58 -0500 Subject: [PATCH] Make it so we can add items. Had broken it when we made the ability to drag / select a big box of stuff. --- EduNetworkBuilder/NetworkBuilder.cs | 57 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index f8bd97b..1c7bea3 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -982,8 +982,34 @@ namespace EduNetworkBuilder //Do we have something selected that we should add? TimeSpan duration; duration = DateTime.Now - LastClick; - - if(e.Button == System.Windows.Forms.MouseButtons.Right) + + //Track size of area for the click/drag + int sx; + int sy; + int swidth; + int sheight; + if (ClickedImageLocation.X > e.Location.X) + { + sx = e.Location.X; + swidth = ClickedImageLocation.X - sx; + } + else + { + sx = ClickedImageLocation.X; + swidth = e.Location.X - sx; + } + if (ClickedImageLocation.Y > e.Location.Y) + { + sy = e.Location.Y; + sheight = ClickedImageLocation.Y - sy; + } + else + { + sy = ClickedImageLocation.Y; + sheight = e.Location.Y - sy; + } + + if (e.Button == System.Windows.Forms.MouseButtons.Right) { pbNetworkView_RightMouseUp(ReleasedOn, e); return; @@ -1004,35 +1030,12 @@ namespace EduNetworkBuilder UpdateVisuals(); return; } - if (MouseIsDown && ItemClickedOn == null) + if (MouseIsDown && ItemClickedOn == null && (swidth > 4 || sheight>4)) { //We just finished dragging a select box //Put them all into the drag box. ItemsSelected.Clear(); - int sx; - int sy; - int swidth; - int sheight; - if (ClickedImageLocation.X > e.Location.X) - { - sx = e.Location.X; - swidth = ClickedImageLocation.X - sx; - } - else - { - sx = ClickedImageLocation.X; - swidth = e.Location.X - sx; - } - if (ClickedImageLocation.Y > e.Location.Y) - { - sy = e.Location.Y; - sheight = ClickedImageLocation.Y - sy; - } - else - { - sy = ClickedImageLocation.Y; - sheight = e.Location.Y - sy; - } + //Now we have a rectangle, but need to exchange numbers for numbers on the image Point topCorner = myNetwork.clickedPos(new Point(sx, sy)); Point botCorner = myNetwork.clickedPos(new Point(sx + swidth, sy + sheight));