Able to resize existing shapes

This commit is contained in:
2018-02-28 10:14:23 -06:00
parent 46bf7acee0
commit 4531e0526a
3 changed files with 64 additions and 3 deletions

View File

@ -485,6 +485,25 @@ namespace EduNetworkBuilder
return Dest;
}
/// <summary>
/// this is a reverse of clickedPos. Translate an image x/y to a picturebox location
/// </summary>
/// <param name="ImageLocation">The location on the backgroundimage</param>
/// <returns></returns>
public Point PictureBoxPoint(Point ImageLocation)
{
if (myPBox == null) return new Point(-1, -1);
double deltaX = (double)TheNetImage.Width / myPBox.Width;
double deltaY = (double)TheNetImage.Height / myPBox.Height;
Point Dest = new Point((int)(ImageLocation.X / deltaX), (int)(ImageLocation.Y / deltaY));
if (Dest.X > TheNetImage.Width) Dest = new Point(TheNetImage.Width, Dest.Y);
if (Dest.Y > TheNetImage.Height) Dest = new Point(Dest.X, TheNetImage.Height);
if (Dest.X < 0) Dest = new Point(0, Dest.Y);
if (Dest.Y < 0) Dest = new Point(Dest.X, 0);
return Dest;
}
public Point clickedPosCentered(Point pixelClickedOn)
{
Point NetPoint = clickedPos(pixelClickedOn);
@ -1120,6 +1139,16 @@ namespace EduNetworkBuilder
Shapes.Add(what);
}
public NetShape ShapeAtPoint(Point location)
{
foreach(NetShape shape in Shapes)
{
if (shape.CornersAreClickedOn(location))
return shape;
}
return null;
}
void KillAllExtraWindows(bool EvenRTF=false)
{
for(int i = Application.OpenForms.Count -1; i >=0; i--)