private void CalculateStartAndEnd()
{
// Find the preferred size of the slider area by combining the separator and dockspace
Size dockspacePreferred = _page.AutoHiddenSlideSize;
Size separatorPreferred = _separator.GetPreferredSize(_control.Size);
Size slideSize = new Size(separatorPreferred.Width + dockspacePreferred.Width,
separatorPreferred.Height + dockspacePreferred.Height);
// Find the maximum allowed size based on the owning control client area reduced by a sensible minimum
Size innerSize = _control.ClientRectangle.Size;
innerSize.Width -= CLIENT_MINIMUM;
innerSize.Height -= CLIENT_MINIMUM;
// Adjust for any showing auto hidden panels at the edges
foreach (Control child in _control.Controls)
{
if (child.Visible && child is KryptonAutoHiddenPanel)
{
switch (child.Dock)
{
case DockStyle.Left:
case DockStyle.Right:
innerSize.Width -= child.Width;
break;
case DockStyle.Top:
case DockStyle.Bottom:
innerSize.Height -= child.Height;
break;
}
}
}
// Enforce a sensible minimum and upper maximum equal to size of the control area
slideSize.Width = Math.Min(Math.Max(SLIDE_MINIMUM, slideSize.Width), innerSize.Width);
slideSize.Height = Math.Min(Math.Max(SLIDE_MINIMUM, slideSize.Height), innerSize.Height);
// Actual start/end rectangles are calculated based on the docking edge
switch (_edge)
{
case DockingEdge.Left:
_startRect = new Rectangle(_panel.Width, _panel.Top, 0, _panel.Height);
_endRect = new Rectangle(_panel.Width, _panel.Height, slideSize.Width, _panel.Height);
break;
case DockingEdge.Right:
_startRect = new Rectangle(_panel.Left, _panel.Top, 0, _panel.Height);
_endRect = new Rectangle(_panel.Left - slideSize.Width, _panel.Height, slideSize.Width, _panel.Height);
break;
case DockingEdge.Top:
_startRect = new Rectangle(_panel.Left, _panel.Height, _panel.Width, 0);
_endRect = new Rectangle(_panel.Left, _panel.Height, _panel.Width, slideSize.Height);
break;
case DockingEdge.Bottom:
_startRect = new Rectangle(_panel.Left, _panel.Top, _panel.Width, 0);
_endRect = new Rectangle(_panel.Left, _panel.Top - slideSize.Height, _panel.Width, slideSize.Height);
break;
}
}