📄 dockcontainer.cs
字号:
internal DockPanelExtender.IAutoHideStripFactory AutoHideStripFactory
{
get { return Extender.AutoHideStripFactory; }
}
private DockPaneCollection m_panes;
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="Panes"]/*' />
[Browsable(false)]
public DockPaneCollection Panes
{
get { return m_panes; }
}
internal Rectangle DockArea
{
get
{
return new Rectangle(DockPadding.Left, DockPadding.Top,
ClientRectangle.Width - DockPadding.Left - DockPadding.Right,
ClientRectangle.Height - DockPadding.Top - DockPadding.Bottom);
}
}
private double m_dockBottomPortion = 0.25;
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="DockBottomPortion"]/*' />
[LocalizedCategory("Category.Docking")]
[LocalizedDescription("DockPanel.DockBottomPortion.Description")]
[DefaultValue(0.25)]
public double DockBottomPortion
{
get { return m_dockBottomPortion; }
set
{
if (value <= 0 || value >= 1)
throw new ArgumentOutOfRangeException();
if (value == m_dockBottomPortion)
return;
m_dockBottomPortion = value;
if (m_dockTopPortion + m_dockBottomPortion > 1)
m_dockTopPortion = 1 - m_dockBottomPortion;
PerformLayout();
}
}
private double m_dockLeftPortion = 0.25;
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="DockLeftPortion"]/*' />
[LocalizedCategory("Category.Docking")]
[LocalizedDescription("DockPanel.DockLeftPortion.Description")]
[DefaultValue(0.25)]
public double DockLeftPortion
{
get { return m_dockLeftPortion; }
set
{
if (value <= 0 || value >= 1)
throw new ArgumentOutOfRangeException();
if (value == m_dockLeftPortion)
return;
m_dockLeftPortion = value;
if (m_dockLeftPortion + m_dockRightPortion > 1)
m_dockRightPortion = 1 - m_dockLeftPortion;
PerformLayout();
}
}
private double m_dockRightPortion = 0.25;
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="DockRightPortion"]/*' />
[LocalizedCategory("Category.Docking")]
[LocalizedDescription("DockPanel.DockRightPortion.Description")]
[DefaultValue(0.25)]
public double DockRightPortion
{
get { return m_dockRightPortion; }
set
{
if (value <= 0 || value >= 1)
throw new ArgumentOutOfRangeException();
if (value == m_dockRightPortion)
return;
m_dockRightPortion = value;
if (m_dockLeftPortion + m_dockRightPortion > 1)
m_dockLeftPortion = 1 - m_dockRightPortion;
PerformLayout();
}
}
private double m_dockTopPortion = 0.25;
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="DockTopPortion"]/*' />
[LocalizedCategory("Category.Docking")]
[LocalizedDescription("DockPanel.DockTopPortion.Description")]
[DefaultValue(0.25)]
public double DockTopPortion
{
get { return m_dockTopPortion; }
set
{
if (value <= 0 || value >= 1)
throw new ArgumentOutOfRangeException();
if (value == m_dockTopPortion)
return;
m_dockTopPortion = value;
if (m_dockTopPortion + m_dockBottomPortion > 1)
m_dockBottomPortion = 1 - m_dockTopPortion;
PerformLayout();
}
}
private DockWindowCollection m_dockWindows;
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="DockWindows"]/*' />
[Browsable(false)]
public DockWindowCollection DockWindows
{
get { return m_dockWindows; }
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="Documents"]/*' />
[Browsable(false)]
public IDockableWindow[] Documents
{
get { return Contents.Select(DockAreas.Document); }
}
private Rectangle DocumentRectangle
{
get
{
Rectangle rect = DockArea;
if (DockWindows[DockState.DockLeft].DisplayingList.Count != 0)
{
rect.X += (int)(DockArea.Width * DockLeftPortion);
rect.Width -= (int)(DockArea.Width * DockLeftPortion);
}
if (DockWindows[DockState.DockRight].DisplayingList.Count != 0)
rect.Width -= (int)(DockArea.Width * DockRightPortion);
if (DockWindows[DockState.DockTop].DisplayingList.Count != 0)
{
rect.Y += (int)(DockArea.Height * DockTopPortion);
rect.Height -= (int)(DockArea.Height * DockTopPortion);
}
if (DockWindows[DockState.DockBottom].DisplayingList.Count != 0)
rect.Height -= (int)(DockArea.Height * DockBottomPortion);
return rect;
}
}
private DragHandler m_dragHandler;
internal DragHandler DragHandler
{
get { return m_dragHandler; }
}
private Control m_dummyControl = null;
internal Control DummyControl
{
get { return m_dummyControl; }
}
private FloatWindowCollection m_floatWindows;
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="FloatWindows"]/*' />
[Browsable(false)]
public FloatWindowCollection FloatWindows
{
get { return m_floatWindows; }
}
private DocumentStyles m_documentStyle = DocumentStyles.DockingMdi;
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Property[@name="DocumentStyle"]/*' />
[LocalizedCategory("Category.Docking")]
[LocalizedDescription("DockPanel.DocumentStyle.Description")]
[DefaultValue(DocumentStyles.DockingMdi)]
public DocumentStyles DocumentStyle
{
get { return m_documentStyle; }
set
{
if (value == m_documentStyle)
return;
if (!Enum.IsDefined(typeof(DocumentStyles), value))
throw new InvalidEnumArgumentException();
if (value == DocumentStyles.SystemMdi && DockWindows[DockState.Document].DisplayingList.Count > 0)
throw new InvalidEnumArgumentException();
m_documentStyle = value;
SuspendLayout(true);
SetMdiClient();
UpdateWindowRegion();
foreach (IDockableWindow content in Contents)
{
if (content.DockHandler.DockState == DockState.Document)
{
content.DockHandler.SetPane(content.DockHandler.Pane);
content.DockHandler.SetVisible();
}
}
if (MdiClientController.MdiClient != null)
MdiClientController.MdiClient.PerformLayout();
ResumeLayout(true, true);
}
}
/// <exclude/>
protected override void OnLayout(LayoutEventArgs levent)
{
SuspendLayout(true);
AutoHideStripControl.Bounds = ClientRectangle;
CalculateDockPadding();
int width = ClientRectangle.Width - DockPadding.Left - DockPadding.Right;
int height = ClientRectangle.Height - DockPadding.Top - DockPadding.Bottom;
int dockLeftSize = (int)(width * m_dockLeftPortion);
int dockRightSize = (int)(width * m_dockRightPortion);
int dockTopSize = (int)(height * m_dockTopPortion);
int dockBottomSize = (int)(height * m_dockBottomPortion);
if (dockLeftSize < MeasurePane.MinSize)
dockLeftSize = MeasurePane.MinSize;
if (dockRightSize < MeasurePane.MinSize)
dockRightSize = MeasurePane.MinSize;
if (dockTopSize < MeasurePane.MinSize)
dockTopSize = MeasurePane.MinSize;
if (dockBottomSize < MeasurePane.MinSize)
dockBottomSize = MeasurePane.MinSize;
DockWindows[DockState.DockLeft].Width = dockLeftSize;
DockWindows[DockState.DockRight].Width = dockRightSize;
DockWindows[DockState.DockTop].Height = dockTopSize;
DockWindows[DockState.DockBottom].Height = dockBottomSize;
AutoHideWindow.Bounds = AutoHideWindowBounds;
DockWindows[DockState.Document].BringToFront();
AutoHideWindow.BringToFront();
base.OnLayout(levent);
if (DocumentStyle == DocumentStyles.SystemMdi && MdiClientController.MdiClient != null)
{
MdiClientController.MdiClient.Bounds = SystemMdiClientBounds;
UpdateWindowRegion();
}
if (Parent != null)
Parent.ResumeLayout();
ResumeLayout(true, true);
}
internal Rectangle GetTabStripRectangle(DockState dockState)
{
return AutoHideStripControl.GetTabStripRectangle(dockState);
}
/// <exclude/>
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Graphics g = e.Graphics;
g.FillRectangle(SystemBrushes.AppWorkspace, ClientRectangle);
}
internal void AddContent(IDockableWindow content)
{
if (content == null)
throw(new ArgumentNullException());
if (!Contents.Contains(content))
{
Contents.Add(content);
OnContentAdded(new DockContentEventArgs(content));
}
}
internal void AddPane(DockPane pane)
{
if (Panes.Contains(pane))
return;
Panes.Add(pane);
}
internal void AddFloatWindow(FloatWindow floatWindow)
{
if (FloatWindows.Contains(floatWindow))
return;
FloatWindows.Add(floatWindow);
}
private void CalculateDockPadding()
{
DockPadding.All = 0;
int height = AutoHideStripControl.MeasureHeight();
if (AutoHideStripControl.GetPanes(DockState.DockLeftAutoHide).Count > 0)
DockPadding.Left = height;
if (AutoHideStripControl.GetPanes(DockState.DockRightAutoHide).Count > 0)
DockPadding.Right = height;
if (AutoHideStripControl.GetPanes(DockState.DockTopAutoHide).Count > 0)
DockPadding.Top = height;
if (AutoHideStripControl.GetPanes(DockState.DockBottomAutoHide).Count > 0)
DockPadding.Bottom = height;
}
internal Rectangle AutoHideWindowBounds
{
get
{
DockState state = AutoHideWindow.DockState;
Rectangle rectDockArea = DockArea;
if (ActiveAutoHideContent == null)
return Rectangle.Empty;
if (Parent == null)
return Rectangle.Empty;
Rectangle rect = Rectangle.Empty;
if (state == DockState.DockLeftAutoHide)
{
int autoHideSize = (int)(rectDockArea.Width * ActiveAutoHideContent.DockHandler.AutoHidePortion);
rect.X = rectDockArea.X;
rect.Y = rectDockArea.Y;
rect.Width = autoHideSize;
rect.Height = rectDockArea.Height;
}
else if (state == DockState.DockRightAutoHide)
{
int autoHideSize = (int)(rectDockArea.Width * ActiveAutoHideContent.DockHandler.AutoHidePortion);
rect.X = rectDockArea.X + rectDockArea.Width - autoHideSize;
rect.Y = rectDockArea.Y;
rect.Width = autoHideSize;
rect.Height = rectDockArea.Height;
}
else if (state == DockState.DockTopAutoHide)
{
int autoHideSize = (int)(rectDockArea.Height * ActiveAutoHideContent.DockHandler.AutoHidePortion);
rect.X = rectDockArea.X;
rect.Y = rectDockArea.Y;
rect.Width = rectDockArea.Width;
rect.Height = autoHideSize;
}
else if (state == DockState.DockBottomAutoHide)
{
int autoHideSize = (int)(rectDockArea.Height * ActiveAutoHideContent.DockHandler.AutoHidePortion);
rect.X = rectDockArea.X;
rect.Y = rectDockArea.Y + rectDockArea.Height - autoHideSize;
rect.Width = rectDockArea.Width;
rect.Height = autoHideSize;
}
if (Parent == null)
return Rectangle.Empty;
else
return new Rectangle(Parent.PointToClient(PointToScreen(rect.Location)), rect.Size);
}
}
internal void RefreshActiveWindow()
{
InRefreshingActiveWindow = true;
SetActivePane();
SetActiveContent();
SetActiveDocumentPane();
SetActiveDocument();
AutoHideWindow.RefreshActivePane();
InRefreshingActiveWindow = false;
}
internal void ReCreateAutoHideStripControl()
{
if (m_autoHideStripControl != null)
{
m_autoHideStripControl.Dispose();
m_autoHideStripControl = null;
}
}
internal void RefreshAutoHideStrip()
{
AutoHideStripControl.RefreshChanges();
}
private void OnChangingDocumentStyle(DocumentStyles oldValue)
{
}
internal void RemoveContent(IDockableWindow content)
{
if (content == null)
throw(new ArgumentNullException());
if (Contents.Contains(content))
{
Contents.Remove(content);
OnContentRemoved(new DockContentEventArgs(content));
}
}
internal void RemovePane(DockPane pane)
{
if (!Panes.Contains(pane))
return;
Panes.Remove(pane);
}
internal void RemoveFloatWindow(FloatWindow floatWindow)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -