public bool AdjustHeight()
{
CheckDisposed();
if (RootBox == null)
return false; // nothing useful we can do.
// Ideally we want to be about 5 pixels bigger than the root. This suppresses the scroll bar
// and makes everything neat. (Anything smaller leaves us with a scroll bar.)
int desiredHeight = RootBox.Height + 8;
// But we're not the main event. Let's not use more than half the window.
if (this.Parent != null)
desiredHeight = Math.Min(desiredHeight, Parent.Height / 2);
// On the other hand, we'd better have SOME space.
desiredHeight = Math.Max(5, desiredHeight);
// But not MORE than the parent.
if (this.Parent != null)
desiredHeight = Math.Min(desiredHeight, Parent.Height);
if (this.Height != desiredHeight)
{
this.Height = desiredHeight;
return true;
}
return false;
}