* UITabControl: 修复不可关闭的主页被关闭了 #IC1XIU

This commit is contained in:
Sunny 2025-04-17 22:20:30 +08:00
parent c5e5a11188
commit 0b7f218b3c
2 changed files with 16 additions and 17 deletions

View File

@ -39,7 +39,7 @@
* 2023-11-16: V3.5.2 * 2023-11-16: V3.5.2
* 2024-04-13: V3.6.5 * 2024-04-13: V3.6.5
* 2024-05-17: V3.6.6 * 2024-05-17: V3.6.6
* 2025-04-17: V3.8.2 * 2025-04-17: V3.8.3
******************************************************************************/ ******************************************************************************/
using System; using System;

View File

@ -38,6 +38,7 @@
* 2024-12-12: V3.8.0 #IB7U69 * 2024-12-12: V3.8.0 #IB7U69
* 2025-02-07: V3.8.1 TabPage #IBKDR7 * 2025-02-07: V3.8.1 TabPage #IBKDR7
* 2025-02-13: V3.8.1 线 ShowTabDivider#IBLERL * 2025-02-13: V3.8.1 线 ShowTabDivider#IBLERL
* 2025-04-17: V3.8.3 #IC1XIU
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -819,7 +820,6 @@ namespace Sunny.UI
protected override void OnMouseDown(MouseEventArgs e) protected override void OnMouseDown(MouseEventArgs e)
{ {
base.OnMouseDown(e); base.OnMouseDown(e);
int removeIndex = -1; int removeIndex = -1;
for (int index = 0; index <= TabCount - 1; index++) for (int index = 0; index <= TabCount - 1; index++)
{ {
@ -838,29 +838,28 @@ namespace Sunny.UI
} }
TabPage tabPage = TabPages[removeIndex]; TabPage tabPage = TabPages[removeIndex];
if (tabPage.Text == MainPage) return;
UIPage uiPage = Helper.GetPage(tabPage); UIPage uiPage = Helper.GetPage(tabPage);
bool show1 = tabPage.Text != MainPage; if (uiPage == null) return;
bool show2 = uiPage == null || !uiPage.AlwaysOpen; if (uiPage.Text == MainPage) return;
bool showButton = show1 && show2; if (uiPage.AlwaysOpen) return;
if (showButton)
if (ShowCloseButton)
{ {
if (ShowCloseButton) if (BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, removeIndex))
{
RemoveTabPage(removeIndex);
}
}
else if (ShowActiveCloseButton && removeIndex == SelectedIndex)
{
if (DrawedIndex == removeIndex)
{ {
if (BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, removeIndex)) if (BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, removeIndex))
{ {
RemoveTabPage(removeIndex); RemoveTabPage(removeIndex);
} }
} }
else if (ShowActiveCloseButton && removeIndex == SelectedIndex)
{
if (DrawedIndex == removeIndex)
{
if (BeforeRemoveTabPage == null || BeforeRemoveTabPage.Invoke(this, removeIndex))
{
RemoveTabPage(removeIndex);
}
}
}
} }
} }