?? dockingmanager.cs
字號:
}
}
}
public void ResetColors()
{
_backColor = SystemColors.Control;
_inactiveTextColor = SystemColors.ControlText;
_activeColor = SystemColors.ActiveCaption;
_activeTextColor = SystemColors.ActiveCaptionText;
_resizeBarColor = SystemColors.Control;
_defaultBackColor = true;
_defaultActiveColor = true;
_defaultActiveTextColor = true;
_defaultInactiveTextColor = true;
_defaultResizeBarColor = true;
PropogateNameValue(PropogateName.BackColor, (object)_backColor);
PropogateNameValue(PropogateName.ActiveColor, (object)_activeColor);
PropogateNameValue(PropogateName.ActiveTextColor, (object)_activeTextColor);
PropogateNameValue(PropogateName.InactiveTextColor, (object)_inactiveTextColor);
PropogateNameValue(PropogateName.ResizeBarColor, (object)_resizeBarColor);
}
public void UpdateInsideFill()
{
// Is inside fill ability enabled?
if (_insideFill)
{
// Reduce flicker
_container.SuspendLayout();
// Ensure correct zone has the Fill style
RemoveAnyFillStyle();
AddInnerFillStyle();
_container.ResumeLayout();
}
}
public virtual bool ShowContent(Content c)
{
// Validate the incoming Content instance is a valid reference
// and is a current instance within our internal collection
if ((c == null) || !_contents.Contains(c))
return false;
// Remove it from view by removing from current WindowContent container
if (!c.Visible)
{
// Do not generate hiding/hidden/shown events
_surpressVisibleEvents++;
// Manageing Zones should remove display AutoHide windows
RemoveShowingAutoHideWindows();
// Use the assigned restore object to position the Content appropriately
if (c.Docked)
{
if (c.AutoHidden)
c.AutoHideRestore.PerformRestore(this);
else
c.DockingRestore.PerformRestore(this);
}
else
c.FloatingRestore.PerformRestore(this);
// Enable generation hiding/hidden/shown events
_surpressVisibleEvents--;
// Generate event
OnContentShown(c);
return true;
}
else
return false;
}
public virtual void ShowAllContents()
{
_container.SuspendLayout();
foreach(Content c in _contents)
ShowContent(c);
UpdateInsideFill();
_container.ResumeLayout();
}
public virtual void HideContent(Content c)
{
HideContent(c, true, true);
}
public virtual void HideContent(Content c, bool record, bool reorder)
{
// Remove it from view by removing from current WindowContent container
if (c.Visible)
{
// Do not generate hiding/hidden/shown events
_surpressVisibleEvents++;
// Manageing Zones should remove display AutoHide windows
RemoveShowingAutoHideWindows();
if (record)
{
// Tell the Content to create a new Restore object to record its current location
c.RecordRestore();
}
if (c.AutoHidden)
{
// Remove it from its current AutoHidePanel
c.AutoHidePanel.RemoveContent(c);
}
else
{
// Remove the Content from its current WindowContent
c.ParentWindowContent.Contents.Remove(c);
}
if (reorder)
{
// Move the Content to the start of the list
_contents.SetIndex(0, c);
}
UpdateInsideFill();
// Enable generation hiding/hidden/shown events
_surpressVisibleEvents--;
// Generate event
OnContentHidden(c);
}
}
public virtual void HideAllContents()
{
_container.SuspendLayout();
int count = _contents.Count;
// Hide in reverse order so that a ShowAll in forward order gives accurate restore
for(int index=count-1; index>=0; index--)
{
// Cannot hide something already hidden
if (_contents[index].Visible)
{
// Generate event
if (!OnContentHiding(_contents[index]))
{
HideContent(_contents[index], true, false);
}
}
}
UpdateInsideFill();
_container.ResumeLayout();
}
public virtual Window CreateWindowForContent(Content c)
{
return CreateWindowForContent(c, new EventHandler(OnContentClose),
new EventHandler(OnRestore),
new EventHandler(OnInvertAutoHide),
new ContextHandler(OnShowContextMenu));
}
public virtual Window CreateWindowForContent(Content c,
EventHandler contentClose,
EventHandler restore,
EventHandler invertAutoHide,
ContextHandler showContextMenu)
{
// Create new instance with correct style
WindowContent wc = new WindowContentTabbed(this, _visualStyle);
WindowDetailCaption wdc;
// Create a style specific caption detail
if (_visualStyle == VisualStyle.IDE)
wdc = new WindowDetailCaptionIDE(this, contentClose, restore,
invertAutoHide, showContextMenu);
else
wdc = new WindowDetailCaptionPlain(this, contentClose, restore,
invertAutoHide, showContextMenu);
// Add the caption to the window display
wc.WindowDetails.Add(wdc);
if (c != null)
{
// Add provided Content to this instance
wc.Contents.Add(c);
}
return wc;
}
public virtual Zone CreateZoneForContent(State zoneState)
{
return CreateZoneForContent(zoneState, _container);
}
protected virtual Zone CreateZoneForContent(State zoneState, ContainerControl destination)
{
DockStyle ds;
Direction direction;
// Find relevant values dependant on required state
ValuesFromState(zoneState, out ds, out direction);
// Create a new ZoneSequence which can host Content
ZoneSequence zs = new ZoneSequence(this, zoneState, _visualStyle, direction, _zoneMinMax);
// Set the appropriate docking style
zs.Dock = ds;
if (destination != null)
{
// Add this Zone to the display
destination.Controls.Add(zs);
}
return zs;
}
public WindowContent AddContentWithState(Content c, State newState)
{
// Validate the incoming Content instance is a valid reference
// and is a current instance within our internal collection
if ((c == null) || !_contents.Contains(c))
return null;
// Do not generate hiding/hidden/shown events
_surpressVisibleEvents++;
// Manageing Zones should remove display AutoHide windows
RemoveShowingAutoHideWindows();
// Is the window already part of a WindowContent?
if (c.ParentWindowContent != null)
{
// If it used to be in a floating mode, then record state change
if (c.ParentWindowContent.ParentZone.State == State.Floating)
c.ContentLeavesFloating();
// Remove the Content from its current WindowContent
c.ParentWindowContent.Contents.Remove(c);
}
// Create a new Window instance appropriate for hosting a Content object
Window w = CreateWindowForContent(c);
ContainerControl destination = null;
if (newState != State.Floating)
{
destination = _container;
destination.SuspendLayout();
}
// Create a new Zone capable of hosting a WindowContent
Zone z = CreateZoneForContent(newState, destination);
if (newState == State.Floating)
{
// Content is not in the docked state
c.Docked = false;
// destination a new floating form
destination = new FloatingForm(this, z, new ContextHandler(OnShowContextMenu));
// Define its location
destination.Location = c.DisplayLocation;
// ...and its size, add the height of the caption bar to the requested content size
destination.Size = new Size(c.FloatingSize.Width,
c.FloatingSize.Height + SystemInformation.ToolWindowCaptionHeight);
}
// Add the Window to the Zone
z.Windows.Add(w);
if (newState != State.Floating)
{
// Set the Zone to be the least important of our Zones
ReorderZoneToInnerMost(z);
UpdateInsideFill();
destination.ResumeLayout();
}
else
destination.Show();
// Enable generation hiding/hidden/shown events
_surpressVisibleEvents--;
// Generate event to indicate content is now visible
OnContentShown(c);
return w as WindowContent;
}
public WindowContent AddContentToWindowContent(Content c, WindowContent wc)
{
// Validate the incoming Content instance is a valid reference
// and is a current instance within our internal collection
if ((c == null) || !_contents.Contains(c))
return null;
// Validate the incoming WindowContent instance is a valid reference
if (wc == null)
return null;
// Is Content already part of given Window then nothing to do
if (c.ParentWindowContent == wc)
return wc;
else
{
// Do not generate hiding/hidden/shown events
_surpressVisibleEvents++;
// Manageing Zones should remove display AutoHide windows
RemoveShowingAutoHideWindows();
if (c.ParentWindowContent != null)
{
// Is there a change in docking state?
if (c.ParentWindowContent.ParentZone.State != wc.ParentZone.State)
{
// If it used to be in a floating mode, then record state change
if (c.ParentWindowContent.ParentZone.State == State.Floating)
c.ContentLeavesFloating();
else
c.ContentBecomesFloating();
}
// Remove the Content from its current WindowContent
c.ParentWindowContent.Contents.Remove(c);
}
else
{
// If adding to a floating window then it is not docked
if (wc.ParentZone.State == State.Floating)
c.Docked = false;
}
// Add the existing Content to this instance
wc.Contents.Add(c);
// Enable generation hiding/hidden/shown events
_surpressVisibleEvents--;
// Generate event to indicate content is now visible
OnContentShown(c);
return wc;
}
}
public Window AddContentToZone(Content c, Zone z, int index)
{
// Validate the incoming Content instance is a valid reference
// and is a current instance within our internal collection
if ((c == null) || !_contents.Contains(c))
return null;
// Validate the incoming Zone instance is a valid reference
if (z == null)
return null;
// Do not generate hiding/hidden/shown events
_surpressVisibleEvents++;
// Manageing Zones should remove display AutoHide windows
RemoveShowingAutoHideWindows();
// Is the window already part of a WindowContent?
if (c.ParentWindowContent != null)
{
// Is there a change in docking state?
if (c.ParentWindowContent.ParentZone.State != z.State)
{
// If it used to be in a floating mode, then record state change
if (c.ParentWindowContent.ParentZone.State == State.Floating)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -