public override void Layout(ViewLayoutContext context)
{
Debug.Assert(context != null);
// Validate incoming reference
if (context == null) throw new ArgumentNullException("context");
// We take on all the available display area
ClientRectangle = context.DisplayRectangle;
// Ensure that child elements have correct palette state
CheckPaletteState(context);
// Let base class perform usual processing
base.Layout(context);
// Extend the split border so it is not restricted by the content size
Rectangle splitClientRect = _drawSplitBorder.ClientRectangle;
if (_drawSplitBorder.Orientation == System.Windows.Forms.Orientation.Vertical)
splitClientRect = new Rectangle(splitClientRect.X, ClientRectangle.Y, splitClientRect.Width, ClientHeight);
else
splitClientRect = new Rectangle(ClientRectangle.X, splitClientRect.Y, ClientWidth, splitClientRect.Height);
_drawSplitBorder.ClientRectangle = splitClientRect;
// Calculate the split and non-split area
_nonSplitRectangle = ClientRectangle;
if (_dropDown && _splitter)
{
// Splitter rectangle depends on drop down position
switch (_dropDownPosition)
{
case VisualOrientation.Top:
_splitRectangle = ClientRectangle;
_splitRectangle.Height = _drawSplitBorder.ClientRectangle.Bottom;
_nonSplitRectangle.Height = ClientHeight - _splitRectangle.Height;
_nonSplitRectangle.Y = _splitRectangle.Bottom;
break;
case VisualOrientation.Bottom:
_splitRectangle = ClientRectangle;
_splitRectangle.Height = _splitRectangle.Bottom - _drawSplitBorder.ClientRectangle.Top;
_splitRectangle.Y = ClientRectangle.Bottom - _splitRectangle.Height;
_nonSplitRectangle.Height = ClientHeight - _splitRectangle.Height;
break;
case VisualOrientation.Left:
_splitRectangle = ClientRectangle;
_splitRectangle.Width = _drawSplitBorder.ClientRectangle.Right;
_nonSplitRectangle.Width = ClientWidth - _splitRectangle.Width;
_nonSplitRectangle.X = _splitRectangle.Right;
break;
case VisualOrientation.Right:
_splitRectangle = ClientRectangle;
_splitRectangle.Width = _splitRectangle.Right - _drawSplitBorder.ClientRectangle.Left;
_splitRectangle.X = ClientRectangle.Right - _splitRectangle.Width;
_nonSplitRectangle.Width = ClientWidth - _splitRectangle.Width;
break;
}
}
else
_splitRectangle = CommonHelper.NullRectangle;
// Update canvas with the rectangle to use for drawing the split area and the non-split area
_drawCanvas.SplitRectangle = _splitRectangle;
_drawCanvas.NonSplitRectangle = _nonSplitRectangle;
}