Browse Source

Applied patch by John Simons: Closing an open file tab returns focus to the previously focused tab. Patch edited slightly to use generics & follow DockPane.cs naming conventions.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1078 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Alpert 20 years ago
parent
commit
56f82265dc
  1. 29
      src/Libraries/DockPanel_Src/WinFormsUI/Docking/DockPane.cs

29
src/Libraries/DockPanel_Src/WinFormsUI/Docking/DockPane.cs

@ -9,6 +9,7 @@
// ***************************************************************************** // *****************************************************************************
using System; using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
@ -174,6 +175,7 @@ namespace WeifenLuo.WinFormsUI
base.Dispose(disposing); base.Dispose(disposing);
} }
private Stack<DockContent> m_visitedTabs = new Stack<DockContent>();
private DockContent m_activeContent = null; private DockContent m_activeContent = null;
/// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Property[@name="ActiveContent"]/*'/> /// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Property[@name="ActiveContent"]/*'/>
public virtual DockContent ActiveContent public virtual DockContent ActiveContent
@ -202,6 +204,14 @@ namespace WeifenLuo.WinFormsUI
m_activeContent = value; m_activeContent = value;
if (m_activeContent != null && m_activeContent.DockState == DockState.Document)
{
if (!(m_visitedTabs.Count > 0 && m_visitedTabs.Peek() == m_activeContent))
{
m_visitedTabs.Push(m_activeContent);
}
}
if (FloatWindow != null) if (FloatWindow != null)
FloatWindow.SetText(); FloatWindow.SetText();
@ -810,6 +820,24 @@ namespace WeifenLuo.WinFormsUI
return; return;
DockContent prevVisible = null; DockContent prevVisible = null;
if (ActiveContent.DockState == DockState.Unknown)
{
while(m_visitedTabs.Count > 0)
{
prevVisible = m_visitedTabs.Pop();
if (prevVisible != null && !prevVisible.IsDisposed && prevVisible != ActiveContent)
break;
}
}
if (prevVisible != null)
{
ActiveContent = prevVisible;
}
else
{
for (int i=Contents.IndexOf(ActiveContent)-1; i>=0; i--) for (int i=Contents.IndexOf(ActiveContent)-1; i>=0; i--)
if (Contents[i].DockState == DockState) if (Contents[i].DockState == DockState)
{ {
@ -832,6 +860,7 @@ namespace WeifenLuo.WinFormsUI
else else
ActiveContent = null; ActiveContent = null;
} }
}
private static readonly object DockStateChangedEvent = new object(); private static readonly object DockStateChangedEvent = new object();
/// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Event[@name="DockStateChanged"]/*'/> /// <include file='CodeDoc\DockPane.xml' path='//CodeDoc/Class[@name="DockPane"]/Event[@name="DockStateChanged"]/*'/>

Loading…
Cancel
Save