* UITabControl: 修改删除页面时的页面跳转

This commit is contained in:
Sunny 2022-01-14 11:07:36 +08:00
parent ce29048f92
commit 8e9b4eea98
2 changed files with 14 additions and 6 deletions

Binary file not shown.

View File

@ -65,6 +65,7 @@ namespace Sunny.UI
timer.Tick += Timer_Tick; timer.Tick += Timer_Tick;
DisposeTabPageAfterRemove = true; DisposeTabPageAfterRemove = true;
AutoClosePage = true;
} }
private ConcurrentDictionary<TabPage, string> TipsTexts = new ConcurrentDictionary<TabPage, string>(); private ConcurrentDictionary<TabPage, string> TipsTexts = new ConcurrentDictionary<TabPage, string>();
@ -692,7 +693,7 @@ namespace Sunny.UI
public event OnAfterRemoveTabPage AfterRemoveTabPage; public event OnAfterRemoveTabPage AfterRemoveTabPage;
[DefaultValue(false)] [DefaultValue(true)]
[Description("多页面框架时包含UIPage在点击Tab页关闭时关闭UIPage"), Category("SunnyUI")] [Description("多页面框架时包含UIPage在点击Tab页关闭时关闭UIPage"), Category("SunnyUI")]
public bool AutoClosePage public bool AutoClosePage
{ {
@ -714,19 +715,26 @@ namespace Sunny.UI
} }
TabPage tabPage = TabPages[index]; TabPage tabPage = TabPages[index];
if (AutoClosePage)
{
var pages = tabPage.GetControls<UIPage>(); var pages = tabPage.GetControls<UIPage>();
for (int i = 0; i < pages.Count; i++) for (int i = 0; i < pages.Count; i++)
{
if (AutoClosePage)
{ {
pages[i].Final(); pages[i].Final();
pages[i].Dispose(); pages[i].Dispose();
pages[i] = null; pages[i] = null;
} }
else
{
pages[i].Parent = null;
}
}
if (TabCount > 1 && index > 0)
{
SelectedTab = TabPages[index - 1];
} }
SelectedTab = TabPages[index > 0 ? index - 1 : 0];
TabPages.Remove(tabPage); TabPages.Remove(tabPage);
AfterRemoveTabPage?.Invoke(this, index); AfterRemoveTabPage?.Invoke(this, index);