📄 dockcontainer.cs
字号:
{
if (!FloatWindows.Contains(floatWindow))
return;
FloatWindows.Remove(floatWindow);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SetPaneIndex(DockPane, int)"]/*'/>
public void SetPaneIndex(DockPane pane, int index)
{
int oldIndex = Panes.IndexOf(pane);
if (oldIndex == -1)
throw(new ArgumentException(ResourceHelper.GetString("DockPanel.SetPaneIndex.InvalidPane")));
if (index < 0 || index > Panes.Count - 1)
if (index != -1)
throw(new ArgumentOutOfRangeException(ResourceHelper.GetString("DockPanel.SetPaneIndex.InvalidIndex")));
if (oldIndex == index)
return;
if (oldIndex == Panes.Count - 1 && index == -1)
return;
Panes.Remove(pane);
if (index == -1)
Panes.Add(pane);
else if (oldIndex < index)
Panes.AddAt(pane, index - 1);
else
Panes.AddAt(pane, index);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SuspendLayout(bool)"]/*'/>
public void SuspendLayout(bool allWindows)
{
SuspendLayout();
if (allWindows)
{
AutoHideWindow.SuspendLayout();
if (MdiClientController.MdiClient != null)
MdiClientController.MdiClient.SuspendLayout();
foreach (DockWindow dockWindow in DockWindows)
dockWindow.SuspendLayout();
}
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="ResumeLayout(bool, bool)"]/*'/>
public void ResumeLayout(bool performLayout, bool allWindows)
{
ResumeLayout(performLayout);
if (allWindows)
{
AutoHideWindow.ResumeLayout(performLayout);
foreach (DockWindow dockWindow in DockWindows)
dockWindow.ResumeLayout(performLayout);
if (MdiClientController.MdiClient != null)
MdiClientController.MdiClient.ResumeLayout(performLayout);
}
}
/// <exclude/>
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_REFRESHACTIVEWINDOW)
RefreshActiveWindow();
else if (m.Msg == (int)Win32.Msgs.WM_WINDOWPOSCHANGING)
{
int offset = (int)Marshal.OffsetOf(typeof(Win32.WINDOWPOS), "flags");
int flags = Marshal.ReadInt32(m.LParam, offset);
Marshal.WriteInt32(m.LParam, offset, flags | (int)Win32.FlagsSetWindowPos.SWP_NOCOPYBITS);
}
base.WndProc (ref m);
}
internal Form ParentForm
{
get
{
if (!IsParentFormValid())
throw new InvalidOperationException();
return MdiClientController.ParentForm;
}
}
private bool IsParentFormValid()
{
if (DocumentStyle == DocumentStyles.DockingSdi || DocumentStyle == DocumentStyles.DockingWindow)
return true;
return (MdiClientController.MdiClient != null);
}
/// <exclude/>
protected override void OnParentChanged(EventArgs e)
{
AutoHideWindow.Parent = this.Parent;
MdiClientController.ParentForm = (this.Parent as Form);
AutoHideWindow.BringToFront();
base.OnParentChanged (e);
}
/// <exclude/>
protected override void OnVisibleChanged(EventArgs e)
{
base.OnVisibleChanged (e);
if (Visible)
SetMdiClient();
}
private Rectangle SystemMdiClientBounds
{
get
{
if (!IsParentFormValid() || !Visible)
return Rectangle.Empty;
Point location = ParentForm.PointToClient(PointToScreen(DocumentWindowBounds.Location));
Size size = DocumentWindowBounds.Size;
return new Rectangle(location, size);
}
}
internal Rectangle DocumentWindowBounds
{
get
{
Rectangle rectDocumentBounds = DisplayRectangle;
if (DockWindows[DockState.DockLeft].Visible)
{
rectDocumentBounds.X += DockWindows[DockState.DockLeft].Width;
rectDocumentBounds.Width -= DockWindows[DockState.DockLeft].Width;
}
if (DockWindows[DockState.DockRight].Visible)
rectDocumentBounds.Width -= DockWindows[DockState.DockRight].Width;
if (DockWindows[DockState.DockTop].Visible)
{
rectDocumentBounds.Y += DockWindows[DockState.DockTop].Height;
rectDocumentBounds.Height -= DockWindows[DockState.DockTop].Height;
}
if (DockWindows[DockState.DockBottom].Visible)
rectDocumentBounds.Height -= DockWindows[DockState.DockBottom].Height;
return rectDocumentBounds;
}
}
private void SetMdiClient()
{
if (this.DocumentStyle == DocumentStyles.DockingMdi)
{
MdiClientController.AutoScroll = false;
MdiClientController.BorderStyle = BorderStyle.None;
if (MdiClientController.MdiClient != null)
MdiClientController.MdiClient.Dock = DockStyle.Fill;
}
else if (DocumentStyle == DocumentStyles.DockingSdi || DocumentStyle == DocumentStyles.DockingWindow)
{
MdiClientController.AutoScroll = true;
MdiClientController.BorderStyle = BorderStyle.Fixed3D;
if (MdiClientController.MdiClient != null)
MdiClientController.MdiClient.Dock = DockStyle.Fill;
}
else if (this.DocumentStyle == DocumentStyles.SystemMdi)
{
MdiClientController.AutoScroll = true;
MdiClientController.BorderStyle = BorderStyle.Fixed3D;
if (MdiClientController.MdiClient != null)
{
MdiClientController.MdiClient.Dock = DockStyle.None;
MdiClientController.MdiClient.Bounds = SystemMdiClientBounds;
}
}
}
private void UpdateWindowRegion()
{
if (DesignMode)
return;
if (this.DocumentStyle == DocumentStyles.DockingMdi)
UpdateWindowRegion_ClipContent();
else if (this.DocumentStyle == DocumentStyles.DockingSdi ||
this.DocumentStyle == DocumentStyles.DockingWindow)
UpdateWindowRegion_FullDocumentArea();
else if (this.DocumentStyle == DocumentStyles.SystemMdi)
UpdateWindowRegion_EmptyDocumentArea();
}
private void UpdateWindowRegion_FullDocumentArea()
{
SetRegion(null);
}
private void UpdateWindowRegion_EmptyDocumentArea()
{
Rectangle rect = DocumentWindowBounds;
SetRegion(new Rectangle[] { rect });
}
private void UpdateWindowRegion_ClipContent()
{
int count = 0;
foreach (DockPane pane in this.Panes)
{
if (pane.DockState != DockState.Document)
continue;
count ++;
}
Rectangle[] rects = new Rectangle[count];
int i = 0;
foreach (DockPane pane in this.Panes)
{
if (pane.DockState != DockState.Document)
continue;
Size size = pane.ContentRectangle.Size;
Point location = PointToClient(pane.PointToScreen(pane.ContentRectangle.Location));
rects[i] = new Rectangle(location, size);
i++;
}
SetRegion(rects);
}
private Rectangle[] m_clipRects = null;
private void SetRegion(Rectangle[] clipRects)
{
if (!IsClipRectsChanged(clipRects))
return;
m_clipRects = clipRects;
if (m_clipRects == null || m_clipRects.GetLength(0) == 0)
Region = null;
else
{
Region region = new Region(new Rectangle(0, 0, this.Width, this.Height));
foreach (Rectangle rect in m_clipRects)
region.Exclude(rect);
Region = region;
}
}
private bool IsClipRectsChanged(Rectangle[] clipRects)
{
if (clipRects == null && m_clipRects == null)
return false;
else if ((clipRects == null) != (m_clipRects == null))
return true;
foreach (Rectangle rect in clipRects)
{
bool matched = false;
foreach (Rectangle rect2 in m_clipRects)
{
if (rect == rect2)
{
matched = true;
break;
}
}
if (!matched)
return true;
}
foreach (Rectangle rect2 in m_clipRects)
{
bool matched = false;
foreach (Rectangle rect in clipRects)
{
if (rect == rect2)
{
matched = true;
break;
}
}
if (!matched)
return true;
}
return false;
}
internal Point PointToMdiClient(Point p)
{
if (MdiClientController.MdiClient == null)
return Point.Empty;
else
return MdiClientController.MdiClient.PointToClient(p);
}
private static readonly object ActiveDocumentChangedEvent = new object();
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Event[@name="ActiveDocumentChanged"]/*' />
[LocalizedCategory("Category.PropertyChanged")]
[LocalizedDescription("DockPanel.ActiveDocumentChanged.Description")]
public event EventHandler ActiveDocumentChanged
{
add { Events.AddHandler(ActiveDocumentChangedEvent, value); }
remove { Events.RemoveHandler(ActiveDocumentChangedEvent, value); }
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="OnActiveDocumentChanged(EventArgs)"]/*' />
protected virtual void OnActiveDocumentChanged(EventArgs e)
{
EventHandler handler = (EventHandler)Events[ActiveDocumentChangedEvent];
if (handler != null)
handler(this, e);
}
private static readonly object ActiveContentChangedEvent = new object();
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Event[@name="ActiveContentChanged"]/*' />
[LocalizedCategory("Category.PropertyChanged")]
[LocalizedDescription("DockPanel.ActiveContentChanged.Description")]
public event EventHandler ActiveContentChanged
{
add { Events.AddHandler(ActiveContentChangedEvent, value); }
remove { Events.RemoveHandler(ActiveContentChangedEvent, value); }
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="OnActiveContentChanged(EventArgs)"]/*' />
protected virtual void OnActiveContentChanged(EventArgs e)
{
EventHandler handler = (EventHandler)Events[ActiveContentChangedEvent];
if (handler != null)
handler(this, e);
}
private static readonly object ActivePaneChangedEvent = new object();
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Event[@name="ActivePaneChanged"]/*' />
[LocalizedCategory("Category.PropertyChanged")]
[LocalizedDescription("DockPanel.ActivePaneChanged.Description")]
public event EventHandler ActivePaneChanged
{
add { Events.AddHandler(ActivePaneChangedEvent, value); }
remove { Events.RemoveHandler(ActivePaneChangedEvent, value); }
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="OnActivePaneChanged(EventArgs)"]/*' />
protected virtual void OnActivePaneChanged(EventArgs e)
{
EventHandler handler = (EventHandler)Events[ActivePaneChangedEvent];
if (handler != null)
handler(this, e);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Delegate[@name="DockContentEventHandler"]/*'/>
public delegate void DockContentEventHandler(object sender, DockContentEventArgs e);
private static readonly object ContentAddedEvent = new object();
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Event[@name="ContentAdded"]/*' />
[LocalizedCategory("Category.DockingNotification")]
[LocalizedDescription("DockPanel.ContentAdded.Description")]
public event DockContentEventHandler ContentAdded
{
add { Events.AddHandler(ContentAddedEvent, value); }
remove { Events.RemoveHandler(ContentAddedEvent, value); }
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="OnContentAdded(DockContentEventArgs)"]/*' />
protected virtual void OnContentAdded(DockContentEventArgs e)
{
DockContentEventHandler handler = (DockContentEventHandler)Events[ContentAddedEvent];
if (handler != null)
handler(this, e);
}
private static readonly object ContentRemovedEvent = new object();
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Event[@name="ContentRemoved"]/*' />
[LocalizedCategory("Category.DockingNotification")]
[LocalizedDescription("DockPanel.ContentRemoved.Description")]
public event DockContentEventHandler ContentRemoved
{
add { Events.AddHandler(ContentRemovedEvent, value); }
remove { Events.RemoveHandler(ContentRemovedEvent, value); }
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="OnContentRemoved(DockContentEventArgs)"]/*' />
protected virtual void OnContentRemoved(DockContentEventArgs e)
{
DockContentEventHandler handler = (DockContentEventHandler)Events[ContentRemovedEvent];
if (handler != null)
handler(this, e);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SaveAsXml"]/*'/>
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SaveAsXml(string)"]/*'/>
public void SaveAsXml(string filename)
{
DockPanelPersist.SaveAsXml(this, filename);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SaveAsXml(string, Encoding)"]/*'/>
public void SaveAsXml(string filename, Encoding encoding)
{
DockPanelPersist.SaveAsXml(this, filename, encoding);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SaveAsXml(Stream, Encoding)"]/*'/>
public void SaveAsXml(Stream stream, Encoding encoding)
{
DockPanelPersist.SaveAsXml(this, stream, encoding);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="SaveAsXml(Stream, Encoding, bool)"]/*'/>
public void SaveAsXml(Stream stream, Encoding encoding, bool upstream)
{
DockPanelPersist.SaveAsXml(this, stream, encoding, upstream);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="LoadFromXml"]/*'/>
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="LoadFromXml(string, DeserializeDockContent)"]/*'/>
public void LoadFromXml(string filename, DeserializeDockContent deserializeContent)
{
DockPanelPersist.LoadFromXml(this, filename, deserializeContent);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="LoadFromXml(Stream, DeserializeDockContent)"]/*'/>
public void LoadFromXml(Stream stream, DeserializeDockContent deserializeContent)
{
DockPanelPersist.LoadFromXml(this, stream, deserializeContent);
}
/// <include file='CodeDoc\DockPanel.xml' path='//CodeDoc/Class[@name="DockPanel"]/Method[@name="LoadFromXml(Stream, DeserializeDockContent, bool)"]/*'/>
public void LoadFromXml(Stream stream, DeserializeDockContent deserializeContent, bool closeStream)
{
DockPanelPersist.LoadFromXml(this, stream, deserializeContent, closeStream);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -