private void SpaceVert(double offset, bool absolute)
{
if (!(this.ctlExpressG.Selection is DocDefinition))
return;
// find extents
DocRectangle dc = ((DocDefinition)this.ctlExpressG.Selection).DiagramRectangle;
double min = dc.Y;
double max = dc.Y + dc.Height;
double thick = 0.0;
SortedList<double, DocDefinition> sortlist = new SortedList<double, DocDefinition>();
foreach (DocDefinition docDef in this.ctlExpressG.Multiselection)
{
DocRectangle rcEach = docDef.DiagramRectangle;
if (min > rcEach.Y)
min = rcEach.Y;
if (max < rcEach.Y + rcEach.Height)
max = rcEach.Y + rcEach.Height;
thick += rcEach.Height;
sortlist.Add(rcEach.Y, docDef);
}
double spacing = (max - min - thick) / (this.ctlExpressG.Multiselection.Count - 1);
if (absolute)
{
spacing = offset;
}
else
{
spacing += offset;
}
double pos = min;
foreach (DocDefinition docDef in sortlist.Values)
{
if (pos != min) // skip the first one
{
docDef.DiagramRectangle.Y = pos;
}
pos += docDef.DiagramRectangle.Height + spacing;
this.ctlExpressG.LayoutDefinition(docDef);
}
this.ctlExpressG.Redraw();
}