Make it so we can add items. Had broken it when we made the ability to drag / select a big box of stuff.

This commit is contained in:
Tim Young 2017-06-14 14:15:58 -05:00
parent d129fdc1a4
commit 49be222b5d

View File

@ -983,7 +983,33 @@ namespace EduNetworkBuilder
TimeSpan duration; TimeSpan duration;
duration = DateTime.Now - LastClick; 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); pbNetworkView_RightMouseUp(ReleasedOn, e);
return; return;
@ -1004,35 +1030,12 @@ namespace EduNetworkBuilder
UpdateVisuals(); UpdateVisuals();
return; return;
} }
if (MouseIsDown && ItemClickedOn == null) if (MouseIsDown && ItemClickedOn == null && (swidth > 4 || sheight>4))
{ {
//We just finished dragging a select box //We just finished dragging a select box
//Put them all into the drag box. //Put them all into the drag box.
ItemsSelected.Clear(); 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 //Now we have a rectangle, but need to exchange numbers for numbers on the image
Point topCorner = myNetwork.clickedPos(new Point(sx, sy)); Point topCorner = myNetwork.clickedPos(new Point(sx, sy));
Point botCorner = myNetwork.clickedPos(new Point(sx + swidth, sy + sheight)); Point botCorner = myNetwork.clickedPos(new Point(sx + swidth, sy + sheight));