* UIMainFrame:页面框架增加AutoClosePage属性,多页面框架时,包含UIPage,在点击Tab页关闭时关闭UIPage
This commit is contained in:
parent
0f1092ca14
commit
4acbbabb53
BIN
Bin/SunnyUI.dll
BIN
Bin/SunnyUI.dll
Binary file not shown.
@ -489,7 +489,7 @@ namespace Sunny.UI
|
||||
{
|
||||
if (ShowCloseButton)
|
||||
{
|
||||
if (BeforeRemoveTabPage == null || (BeforeRemoveTabPage != null && BeforeRemoveTabPage.Invoke(this, removeIndex)))
|
||||
if (BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, removeIndex))
|
||||
{
|
||||
RemoveTabPage(removeIndex);
|
||||
}
|
||||
@ -498,7 +498,7 @@ namespace Sunny.UI
|
||||
{
|
||||
if (DrawedIndex == removeIndex)
|
||||
{
|
||||
if (BeforeRemoveTabPage == null || (BeforeRemoveTabPage != null && BeforeRemoveTabPage.Invoke(this, removeIndex)))
|
||||
if (BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, removeIndex))
|
||||
{
|
||||
RemoveTabPage(removeIndex);
|
||||
}
|
||||
@ -515,6 +515,10 @@ namespace Sunny.UI
|
||||
|
||||
public event OnAfterRemoveTabPage AfterRemoveTabPage;
|
||||
|
||||
[DefaultValue(false)]
|
||||
[Description("多页面框架时,包含UIPage,在点击Tab页关闭时关闭UIPage"), Category("SunnyUI")]
|
||||
public bool AutoClosePage { get; set; }
|
||||
|
||||
internal void RemoveTabPage(int index)
|
||||
{
|
||||
if (index < 0 || index >= TabCount)
|
||||
@ -522,6 +526,19 @@ namespace Sunny.UI
|
||||
return;
|
||||
}
|
||||
|
||||
TabPage tabPage = TabPages[index];
|
||||
|
||||
if (AutoClosePage)
|
||||
{
|
||||
var pages = tabPage.GetControls<UIPage>();
|
||||
for (int i = 0; i < pages.Count; i++)
|
||||
{
|
||||
pages[i].Final();
|
||||
pages[i].Dispose();
|
||||
pages[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
TabPages.Remove(TabPages[index]);
|
||||
AfterRemoveTabPage?.Invoke(this, index);
|
||||
|
||||
|
@ -34,8 +34,34 @@ namespace Sunny.UI
|
||||
MainContainer.TabVisible = false;
|
||||
MainContainer.BringToFront();
|
||||
MainContainer.TabPages.Clear();
|
||||
|
||||
MainContainer.BeforeRemoveTabPage += MainContainer_BeforeRemoveTabPage;
|
||||
MainContainer.AfterRemoveTabPage += MainContainer_AfterRemoveTabPage;
|
||||
}
|
||||
|
||||
[DefaultValue(false)]
|
||||
[Description("多页面框架时,包含UIPage,在点击Tab页关闭时关闭UIPage"), Category("SunnyUI")]
|
||||
public bool AutoClosePage
|
||||
{
|
||||
get => MainContainer.AutoClosePage;
|
||||
set => MainContainer.AutoClosePage = value;
|
||||
}
|
||||
|
||||
private void MainContainer_AfterRemoveTabPage(object sender, int index)
|
||||
{
|
||||
AfterRemoveTabPage?.Invoke(sender, index);
|
||||
}
|
||||
|
||||
private bool MainContainer_BeforeRemoveTabPage(object sender, int index)
|
||||
{
|
||||
return BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, index);
|
||||
}
|
||||
|
||||
public event UITabControl.OnBeforeRemoveTabPage BeforeRemoveTabPage;
|
||||
|
||||
public event UITabControl.OnAfterRemoveTabPage AfterRemoveTabPage;
|
||||
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
MainContainer.BringToFront();
|
||||
|
Loading…
x
Reference in New Issue
Block a user