?? dockingmanager.cs
字號(hào):
{
WindowContent newWC = copy[0].ParentWindowContent;
if (newWC != null)
{
// Transfer each one to its new location
for(int index=1; index<copyCount; index++)
{
HideContent(copy[index], false, true);
newWC.Contents.Add(copy[index]);
}
}
}
}
}
AddInnerFillStyle();
}
}
protected void AddInnerFillStyle()
{
if (_insideFill)
{
// Find the innermost Zone which must be the first one in the collection
foreach(Control c in _container.Controls)
{
Zone z = c as Zone;
// Only interested in our Zones
if (z != null)
{
// Make it fill all remaining space
z.Dock = DockStyle.Fill;
// Exit
break;
}
}
}
}
protected void RemoveAnyFillStyle()
{
// Check each Zone in the container
foreach(Control c in _container.Controls)
{
Zone z = c as Zone;
if (z != null)
{
// Only interested in ones with the Fill dock style
if (z.Dock == DockStyle.Fill)
{
DockStyle ds;
Direction direction;
// Find relevant values dependant on required state
ValuesFromState(z.State, out ds, out direction);
// Reassign its correct Dock style
z.Dock = ds;
}
}
}
}
protected void OnFormLoaded(object sender, EventArgs e)
{
// A Form can cause the child controls to be reordered after the initialisation
// but before the Form.Load event. To handle this we reorder the auto hide panels
// on the Form.Load event to ensure they are correctly positioned.
ReorderAutoHidePanels();
}
protected void ReorderAutoHidePanels()
{
if (_outerControl == null)
{
int count = _container.Controls.Count;
// Position the AutoHidePanel's at end of controls
_container.Controls.SetChildIndex(_ahpLeft, count - 1);
_container.Controls.SetChildIndex(_ahpRight, count - 1);
_container.Controls.SetChildIndex(_ahpTop, count - 1);
_container.Controls.SetChildIndex(_ahpBottom, count - 1);
}
else
{
// Position the AutoHidePanel's as last items before OuterControl
RepositionControlBefore(_outerControl, _ahpBottom);
RepositionControlBefore(_outerControl, _ahpTop);
RepositionControlBefore(_outerControl, _ahpRight);
RepositionControlBefore(_outerControl, _ahpLeft);
}
}
protected void OnContainerResized(object sender, EventArgs e)
{
if (_autoResize)
{
Rectangle inner = InnerResizeRectangle(null);
// Shrink by the minimum size
inner.Width -= _innerMinimum.Width;
inner.Height -= _innerMinimum.Height;
Form f = _container as Form;
// If the container is a Form then ignore resizing because of becoming Minimized
if ((f == null) || ((f != null) && (f.WindowState != FormWindowState.Minimized)))
{
if ((inner.Width < 0) || (inner.Height < 0))
{
_container.SuspendLayout();
ZoneCollection zcLeft = new ZoneCollection();
ZoneCollection zcRight = new ZoneCollection();
ZoneCollection zcTop = new ZoneCollection();
ZoneCollection zcBottom = new ZoneCollection();
// Construct a list of the docking windows on the left and right edges
foreach(Control c in _container.Controls)
{
Zone z = c as Zone;
if (z != null)
{
switch(z.State)
{
case State.DockLeft:
zcLeft.Add(z);
break;
case State.DockRight:
zcRight.Add(z);
break;
case State.DockTop:
zcTop.Add(z);
break;
case State.DockBottom:
zcBottom.Add(z);
break;
}
}
}
if (inner.Width < 0)
ResizeDirection(-inner.Width, zcLeft, zcRight, Direction.Horizontal);
if (inner.Height < 0)
ResizeDirection(-inner.Height, zcTop, zcBottom, Direction.Vertical);
_container.ResumeLayout();
}
}
}
}
protected void ResizeDirection(int remainder, ZoneCollection zcAlpha, ZoneCollection zcBeta, Direction dir)
{
bool alter;
int available;
int half1, half2;
// Keep going till all space found or nowhere to get it from
while((remainder > 0) && ((zcAlpha.Count > 0) || (zcBeta.Count > 0)))
{
if (dir == Direction.Horizontal)
{
_firstHalfWidth = (_firstHalfWidth != true);
alter = _firstHalfWidth;
}
else
{
_firstHalfHeight = (_firstHalfHeight != true);
alter = _firstHalfHeight;
}
// Alternate between left and right getting the remainder
if (alter)
{
half1 = (remainder / 2) + 1;
half2 = remainder - half1;
}
else
{
half2 = (remainder / 2) + 1;
half1 = remainder - half2;
}
// Any Zone of the left to use?
if (zcAlpha.Count > 0)
{
Zone z = zcAlpha[0];
// Find how much space it can offer up
if (dir == Direction.Horizontal)
available = z.Width - z.MinimumWidth;
else
available = z.Height - z.MinimumHeight;
if (available > 0)
{
// Only take away the maximum we need
if (available > half1)
available = half1;
else
zcAlpha.Remove(z);
// Resize the control accordingly
if (dir == Direction.Horizontal)
z.Width = z.Width - available;
else
z.Height = z.Height - available;
// Reduce total amount left to allocate
remainder -= available;
}
else
zcAlpha.Remove(z);
}
// Any Zone of the left to use?
if (zcBeta.Count > 0)
{
Zone z = zcBeta[0];
// Find how much space it can offer up
if (dir == Direction.Horizontal)
available = z.Width - z.MinimumWidth;
else
available = z.Height - z.MinimumHeight;
if (available > 0)
{
// Only take away the maximum we need
if (available > half2)
available = half2;
else
zcBeta.Remove(z);
// Resize the control accordingly
if (dir == Direction.Horizontal)
z.Width = z.Width - available;
else
z.Height = z.Height - available;
// Reduce total amount left to allocate
remainder -= available;
}
else
zcBeta.Remove(z);
}
}
}
protected void OnPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
{
if (_defaultBackColor)
{
_backColor = SystemColors.Control;
PropogateNameValue(PropogateName.BackColor, (object)SystemColors.Control);
}
if (_defaultActiveColor)
{
_activeColor = SystemColors.ActiveCaption;
PropogateNameValue(PropogateName.ActiveColor, (object)SystemColors.ActiveCaption);
}
if (_defaultActiveTextColor)
{
_activeTextColor = SystemColors.ActiveCaptionText;
PropogateNameValue(PropogateName.ActiveTextColor, (object)SystemColors.ActiveCaptionText);
}
if (_defaultInactiveTextColor)
{
_inactiveTextColor = SystemColors.ControlText;
PropogateNameValue(PropogateName.InactiveTextColor, (object)SystemColors.ControlText);
}
if (_defaultResizeBarColor)
{
_resizeBarColor = SystemColors.Control;
PropogateNameValue(PropogateName.ResizeBarColor, (object)SystemColors.Control);
}
if (_defaultCaptionFont)
{
_captionFont = SystemInformation.MenuFont;
PropogateNameValue(PropogateName.CaptionFont, (object)SystemInformation.MenuFont);
}
if (_defaultTabControlFont)
{
_tabControlFont = SystemInformation.MenuFont;
PropogateNameValue(PropogateName.TabControlFont, (object)SystemInformation.MenuFont);
}
}
public virtual void OnShowContextMenu(Point screenPos)
{
PopupMenu context = new PopupMenu();
// The order of Content displayed in the context menu is not the same as
// the order of Content in the _contents collection. The latter has its
// ordering changed to enable Restore functionality to work.
ContentCollection temp = new ContentCollection();
foreach(Content c in _contents)
{
int count = temp.Count;
int index = 0;
// Find best place to add into the temp collection
for(; index<count; index++)
{
if (c.Order < temp[index].Order)
break;
}
temp.Insert(index, c);
}
// Create a context menu entry per Content
foreach(Content t in temp)
{
MenuCommand mc = new MenuCommand(t.Title, new EventHandler(OnToggleContentVisibility));
mc.Checked = t.Visible;
mc.Tag = t;
context.MenuCommands.Add(mc);
}
// Add a separator
context.MenuCommands.Add(new MenuCommand("-"));
// Add fixed entries to end to effect all content objects
context.MenuCommands.Add(new MenuCommand("Show All", new EventHandler(OnShowAll)));
context.MenuCommands.Add(new MenuCommand("Hide All", new EventHandler(OnHideAll)));
// Ensure menu has same style as the docking windows
context.Style = _visualStyle;
if (OnContextMenu(context))
{
// Show it!
context.TrackPopup(screenPos);
}
}
protected bool OnContextMenu(PopupMenu context)
{
CancelEventArgs cea = new CancelEventArgs();
if (ContextMenu != null)
ContextMenu(context, cea);
return !cea.Cancel;
}
protected void OnToggleContentVisibility(object sender, EventArgs e)
{
MenuCommand mc = sender as MenuCommand;
if (mc != null)
{
Content c = mc.Tag as Content;
if (c != null)
{
if (c.Visible)
HideContent(c);
else
ShowContent(c);
}
}
}
protected void OnShowAll(object sender, EventArgs e)
{
ShowAllContents();
}
protected void OnHideAll(object sender, EventArgs e)
{
HideAllContents();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -