Cleaning up select multiple and move system
This commit is contained in:
parent
693c77cfe0
commit
a99a9ed696
@ -348,6 +348,7 @@ namespace EduNetworkBuilder
|
||||
myPBox = What;
|
||||
myPBox.BackgroundImage = TheNetImageBackground;
|
||||
myPBox.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
myPBox.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||
Print();
|
||||
myPBox.Invalidate();
|
||||
}
|
||||
|
@ -940,11 +940,13 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MouseIsDown && ItemClickedOn == null && ItemsSelected.Count > 0)
|
||||
if (MouseIsDown && ItemsSelected.Count > 0)
|
||||
{
|
||||
//We were dragging stuff. All done now
|
||||
MouseIsDown = false;
|
||||
ItemsSelected.Clear(); //clear it so we stop moving these ones
|
||||
UpdateLinks();
|
||||
UpdateVisuals();
|
||||
return;
|
||||
}
|
||||
if (MouseIsDown && ItemClickedOn == null)
|
||||
@ -983,8 +985,10 @@ namespace EduNetworkBuilder
|
||||
Rectangle selectbox = new Rectangle(topCorner.X, topCorner.Y, botCorner.X - topCorner.X, botCorner.Y - topCorner.Y);
|
||||
|
||||
ItemsSelected.AddRange(myNetwork.DevicesInRectangle(selectbox));
|
||||
Console.WriteLine("Selected " + ItemsSelected.Count + " items");
|
||||
//Console.WriteLine("Selected " + ItemsSelected.Count + " items");
|
||||
MouseIsDown = false;
|
||||
DrawHighlightBoxes();
|
||||
pbNetworkView.Invalidate();
|
||||
return;
|
||||
}
|
||||
MouseIsDown = false;
|
||||
@ -1116,6 +1120,23 @@ namespace EduNetworkBuilder
|
||||
myNetwork.Invalidate(newrec);
|
||||
}
|
||||
|
||||
private void DrawHighlightBoxes()
|
||||
{
|
||||
Image tImage = new Bitmap(pbNetworkView.BackgroundImage.Width, pbNetworkView.BackgroundImage.Height);
|
||||
Graphics tGraphics = Graphics.FromImage(tImage);
|
||||
tGraphics.Clear(Color.Transparent); //erase the whole thing
|
||||
|
||||
Color tColor = Color.LightGreen;
|
||||
SolidBrush semiTransBrush = new SolidBrush(Color.FromArgb(128, tColor.R, tColor.G, tColor.B));
|
||||
foreach (NetworkDevice nd in ItemsSelected)
|
||||
{
|
||||
tGraphics.FillRectangle(semiTransBrush, nd.GetMyRectangle());
|
||||
}
|
||||
pbNetworkView.Image = tImage;
|
||||
pbNetworkView.Invalidate();
|
||||
|
||||
}
|
||||
|
||||
private void pbNetworkView_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
//Only do this 10 times a second
|
||||
@ -1156,25 +1177,25 @@ namespace EduNetworkBuilder
|
||||
int sy;
|
||||
int swidth;
|
||||
int sheight;
|
||||
if(ClickedImageLocation.X > e.Location.X )
|
||||
if(ClickedLocation.X > MouseLocation.X )
|
||||
{
|
||||
sx = e.Location.X;
|
||||
swidth = ClickedImageLocation.X - sx;
|
||||
sx = MouseLocation.X;
|
||||
swidth = ClickedLocation.X - sx;
|
||||
}
|
||||
else
|
||||
{
|
||||
sx = ClickedImageLocation.X;
|
||||
swidth = e.Location.X -sx;
|
||||
sx = ClickedLocation.X;
|
||||
swidth = MouseLocation.X - sx;
|
||||
}
|
||||
if (ClickedImageLocation.Y > e.Location.Y)
|
||||
if (ClickedLocation.Y > MouseLocation.Y)
|
||||
{
|
||||
sy = e.Location.Y;
|
||||
sheight = ClickedImageLocation.Y - sy;
|
||||
sy = MouseLocation.Y;
|
||||
sheight = ClickedLocation.Y - sy;
|
||||
}
|
||||
else
|
||||
{
|
||||
sy = ClickedImageLocation.Y;
|
||||
sheight = e.Location.Y - sy;
|
||||
sy = ClickedLocation.Y;
|
||||
sheight = MouseLocation.Y - sy;
|
||||
}
|
||||
Rectangle selectbox = new Rectangle(sx,sy,swidth,sheight);
|
||||
|
||||
|
@ -701,6 +701,11 @@ namespace EduNetworkBuilder
|
||||
return new Point(MyLocation.X + delta, MyLocation.Y + delta);
|
||||
}
|
||||
|
||||
public Rectangle GetMyRectangle()
|
||||
{
|
||||
return new Rectangle(MyLocation.X, MyLocation.Y, Size, Size);
|
||||
|
||||
}
|
||||
public void ChangeLocation(Point Location)
|
||||
{
|
||||
MyLocation = NB.GetSnapped(Location);
|
||||
|
Loading…
Reference in New Issue
Block a user