private Rectangle2D isBoundsChange(Rectangle2D bounds, double referenceLength, Size referenceSize, out bool isIntersect, out bool isGetNewBounds)
{
//初始化要修改的范围
isIntersect = false;
isGetNewBounds = false;
var boundsCollection = (Layer as ElementsLayer).BoundsCollection.Values;
var radius = referenceLength * 0.7;
Rectangle2D newBounds = new Rectangle2D();
if (referenceSize.Width == 0 && referenceSize.Height == 0)
{
referenceSize.Width = bounds.Width;
referenceSize.Height = bounds.Height;
}
else
{
referenceSize.Width *= this.Resolution;
referenceSize.Height *= this.Resolution;
}
for (int i = 0; i < 8; i++)
{
switch (i)
{
case 0:
newBounds = new Rectangle2D(bounds.Left + referenceSize.Width / 2, bounds.Bottom + radius, bounds.Right + referenceSize.Width / 2, bounds.Top + radius);
break;
case 1:
newBounds = new Rectangle2D(bounds.Left + referenceSize.Width / 2 + radius, bounds.Bottom, bounds.Right + referenceSize.Width / 2 + radius, bounds.Top);
break;
case 2:
newBounds = new Rectangle2D(bounds.Left + referenceSize.Width / 2, bounds.Bottom - radius, bounds.Right + referenceSize.Width / 2, bounds.Top - radius);
break;
case 3:
newBounds = new Rectangle2D(bounds.Left, bounds.Bottom - radius, bounds.Right, bounds.Top - radius);
break;
case 4:
newBounds = new Rectangle2D(bounds.Left - referenceSize.Width / 2, bounds.Bottom - radius, bounds.Right - referenceSize.Width / 2, bounds.Top - radius);
break;
case 5:
newBounds = new Rectangle2D(bounds.Left - referenceSize.Width / 2 - radius, bounds.Bottom, bounds.Right - referenceSize.Width / 2 - radius, bounds.Top);
break;
case 6:
newBounds = new Rectangle2D(bounds.Left - referenceSize.Width / 2, bounds.Bottom + radius, bounds.Right - referenceSize.Width / 2, bounds.Top + radius);
break;
case 7:
newBounds = new Rectangle2D(bounds.Left, bounds.Bottom + radius, bounds.Right, bounds.Top + radius);
break;
}
if (computeIntersectWithAll(newBounds))
{
isIntersect = true;
if (i == 1 || i == 5)
{
continue;
}
newBounds.Update(newBounds.Left, newBounds.Bottom + referenceSize.Height, newBounds.Right, newBounds.Top + referenceSize.Height);
if (computeIntersectWithAll(newBounds))
{
newBounds.Update(newBounds.Left, newBounds.Bottom - 2 * referenceSize.Height, newBounds.Right, newBounds.Top - 2 * referenceSize.Height);
if (computeIntersectWithAll(newBounds))
{
continue;
}
else
{
isGetNewBounds = true;
return newBounds;
}
}
else
{
isGetNewBounds = true;
return newBounds;
}
}
else
{
isGetNewBounds = true;
return newBounds;
}
}
return bounds;
}