Share

Netron Reloaded

Tracker: Patches

5 Layout, Simple Across and Down - ID: 1605291
Last Update: Tracker Item Submitted ( jflin5 )

For Each Shape
Put Each on the control, starting in top left corner
Continue Across the top, and if run out of room, move down
Note that the down movement is currently be the height of the LAST
control



Code to do it:
void Layout_SimpleAcrossAndDown(object sender, LayoutEventArgs e)
{
// For Each Shape
// Put Each on the control, starting in top left corner
// Continue Across the top, and if run out of room, move down
// Note that the down movement is currently be the height of the LAST
control
DiagramControlBase diagControl = e.AffectedComponent as
DiagramControlBase;
if (diagControl != null)
{
#region Placeholder info
#region Min/Max of X and Y
int DisplayMinX = 0;
int DisplayMinY = 0;
int DisplayMaxX = diagControl.Width;
int DisplayMaxY = diagControl.Height;
#endregion
int iSpacerX = 20;
int iSpacerY = 20;
int iNextPlacementX = DisplayMinX;
int iNextPlacementY = DisplayMinY;
#endregion
// Loop through all shapes
foreach (ShapeBase shp in diagControl.Controller.Model.Shapes)
{
#region Deal with going past end of control, with this shape
(Placing NOT totally inside)
if ((iNextPlacementX + shp.Width) >= DisplayMaxX)
{
iNextPlacementX = DisplayMinX;
iNextPlacementY += shp.Height + iSpacerY;
}
#endregion
// Move to Next X,Y coords
shp.Move(new Point(iNextPlacementX, iNextPlacementY));
#region Advance Draw Point to next position
iNextPlacementX += shp.Width + iSpacerX;
#region Deal with going past end of control
if (iNextPlacementX >= DisplayMaxX)
{
iNextPlacementX = DisplayMinX;
iNextPlacementY += shp.Height + iSpacerY;
}
#endregion
#endregion
// make sure shape knows it needs to be re-drawn
shp.Invalidate();
}
}
}


Jim ( jflin5 ) - 2006-11-29 14:44

5

Open

None

Nobody/Anonymous

None

None

Public


Comments




Log in to comment.

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.