internal Content AddShelfView(ShelfView shelfView, Control control, string title, ShelfDisplayHint hint, MemoryStream shelfRestoreStream)
{
// Forcing this makes the control resize *before* adding it to the DotNetMagic control,
// so the shelf will be the correct size. This would be done automatically when the
// control gets added - we're just doing it a bit prematurely in order to get the correct size.
control.Font = _form.DockingManager.TabControlFont;
var displaySize = control.Size;
var content = _form.DockingManager.Contents.Add(control, title);
content.Tag = shelfView;
if (shelfRestoreStream != null)
{
content.LoadContentFromStream(shelfRestoreStream);
// #4183 - the shelf restore stream includes the shelf title, which is supposed to be determined by the model/localization and not persisted
content.Title = content.FullTitle = title;
_form.DockingManager.ShowContent(content);
if (content.IsAutoHidden && hint != ShelfDisplayHint.HideOnWorkspaceOpen)
_form.DockingManager.BringAutoHideIntoView(content);
return content;
}
content.DisplaySize = displaySize;
content.AutoHideSize = displaySize;
content.FloatingSize = displaySize;
if ((hint & ShelfDisplayHint.DockAutoHide) != 0)
_form.DockingManager.Container.SuspendLayout();
// Dock the window on the correct edge
if ((hint & ShelfDisplayHint.DockTop) != 0)
{
_form.DockingManager.AddContentWithState(content, State.DockTop);
}
else if ((hint & ShelfDisplayHint.DockBottom) != 0)
{
_form.DockingManager.AddContentWithState(content, State.DockBottom);
}
else if ((hint & ShelfDisplayHint.DockLeft) != 0)
{
_form.DockingManager.AddContentWithState(content, State.DockLeft);
}
else if ((hint & ShelfDisplayHint.DockRight) != 0)
{
_form.DockingManager.AddContentWithState(content, State.DockRight);
}
else
{
if ((hint & ShelfDisplayHint.ShowNearMouse) == ShelfDisplayHint.ShowNearMouse)
{
content.DisplayLocation = Control.MousePosition;
}
_form.DockingManager.AddContentWithState(content, State.Floating);
}
if ((hint & ShelfDisplayHint.DockAutoHide) != 0)
{
_form.DockingManager.ToggleContentAutoHide(content);
_form.DockingManager.Container.ResumeLayout();
_form.DockingManager.BringAutoHideIntoView(content);
}
return content;
}