When dragging a shape off canvas, SumRectangles() is
called to recalculate the extents of the drawing,
growing this rectangle (causing scrollbars) as
necessary to have it reflect the maximum extents of the
drawing.
It has a strange side effect though.
Place two shapes on the canvas (restrictToCanvas = false).
Drag one shape far to the right and notice how the
scrollbars appear as expected.
Scroll over to to see the shape you dragged. If you
try to drag it back to the right, the canvas size
dynamically shrinks, while making it appear that the
shape you're dragging is "attached to the right edge of
the canvas. It appears that all the other shapes are
actually moving over to meet it.
It would seem reasonable that when dragging, that we
only grow this rectangle. ie: SumRectangles() returns
the MAX of either the current rectangle, or the newly
calculated one.
The next time this is called when nothing is selected,
the proper extents are calculated and the scrollbars
synchronize with the current size.
The following demonstrates one simple fix to the problem.
In GraphAbstract.cs:
Added>>> private RectangleF mTempRectangleSum =
RectangleF.Empty;
GraphAbstract:SumRectangles()
// for each shape in mShapes of the abstract
foreach (Shape shape in mShapes)
{
r = RectangleF.Union(r,shape.Rectangle);
if( shape.Tracker != null )
{
RectangleF a = shape.Tracker.Grip(new Point(-1, -1));
RectangleF b = shape.Tracker.Grip(new Point(+1, +1));
r = RectangleF.Union(r,RectangleF.Union(a, b));
Added>>> if (mTempRectangleSum.Width > r.Width)
r.Width = mTempRectangleSum.Width;
Added>>> if (mTempRectangleSum.Height > r.Height)
r.Height = mTempRectangleSum.Height;
}
}
-Jeff