public override void Layout(ViewLayoutContext context)
{
Debug.Assert(context != null);
// Prevent recreate of the control
if (!IsDisposed && !_removing)
{
// We take on all the available display area
ClientRectangle = context.DisplayRectangle;
// Are we allowed to layout child controls?
if (!context.ViewManager.DoNotLayoutControls)
{
// Make sure the scrollbar has actually been created
CreateScrollBar(context.Control);
// If we need to hide/disable the control then do it before position changes
if (!Visible) _scrollBar.Hide();
if (!Enabled) _scrollBar.Enabled = false;
// Should the scrollbar is shorter than then the entire client area?
if (ShortSize)
{
if (Vertical)
_scrollBar.SetBounds(ClientLocation.X, ClientLocation.Y,
ClientWidth, ClientHeight - SystemInformation.HorizontalScrollBarHeight);
else
_scrollBar.SetBounds(ClientLocation.X, ClientLocation.Y,
ClientWidth - SystemInformation.VerticalScrollBarWidth, ClientHeight);
}
else
{
// Position the ScrollBar in the entire requested area
_scrollBar.SetBounds(ClientLocation.X, ClientLocation.Y,
ClientWidth, ClientHeight);
}
// If we need to show/enable control then do it after position changes
if (Visible) _scrollBar.Show();
if (Enabled) _scrollBar.Enabled = true;
}
}
}