diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index 9992a81a..5a19267f 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index 66e8e8fe..488728df 100644 Binary files a/Bin/net5.0-windows/SunnyUI.dll and b/Bin/net5.0-windows/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/ref/SunnyUI.dll b/Bin/net5.0-windows/ref/SunnyUI.dll index 772759ec..612029ad 100644 Binary files a/Bin/net5.0-windows/ref/SunnyUI.dll and b/Bin/net5.0-windows/ref/SunnyUI.dll differ diff --git a/Bin/netcoreapp3.1/SunnyUI.dll b/Bin/netcoreapp3.1/SunnyUI.dll index 7879bdfd..521f81b1 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI/Controls/UINavMenuHelper.cs b/SunnyUI/Controls/UINavMenuHelper.cs index c42274e8..1c3743f4 100644 --- a/SunnyUI/Controls/UINavMenuHelper.cs +++ b/SunnyUI/Controls/UINavMenuHelper.cs @@ -319,6 +319,40 @@ namespace Sunny.UI } } } + + public bool RemovePage(int pageIndex) + { + if (pageIndex < 0) return false; + foreach (var item in PageItems) + { + if (item.Value.PageIndex == pageIndex && item.Key != null) + { + TabPage tabPage = item.Key; + tabControl.RemoveTabPage(tabPage.TabIndex); + PageItems.TryRemove(item.Key, out _); + return true; + } + } + + return false; + } + + public bool RemovePage(Guid guid) + { + if (guid == Guid.Empty) return false; + foreach (var item in PageItems) + { + if (item.Value.PageGuid == guid && item.Key != null) + { + TabPage tabPage = item.Key; + tabControl.RemoveTabPage(tabPage.TabIndex); + PageItems.TryRemove(item.Key, out _); + return true; + } + } + + return false; + } } public class NavMenuItem diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index d31e2379..9e63fe8d 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -110,6 +110,10 @@ namespace Sunny.UI public void AddPage(UIPage page) => Helper.AddPage(page); + public bool RemovePage(int pageIndex) => Helper.RemovePage(pageIndex); + + public bool RemovePage(Guid guid) => Helper.RemovePage(guid); + public void AddPages(params UIPage[] pages) { foreach (var page in pages) AddPage(page); diff --git a/SunnyUI/Forms/UIFormHelper.cs b/SunnyUI/Forms/UIFormHelper.cs index 87adcb5b..307fafce 100644 --- a/SunnyUI/Forms/UIFormHelper.cs +++ b/SunnyUI/Forms/UIFormHelper.cs @@ -615,5 +615,9 @@ namespace Sunny.UI void SelectPage(int pageIndex); bool TopMost { get; set; } + + bool RemovePage(int pageIndex); + + bool RemovePage(Guid guid); } } \ No newline at end of file diff --git a/SunnyUI/Frames/UIMainFrame.cs b/SunnyUI/Frames/UIMainFrame.cs index a3348069..27b963db 100644 --- a/SunnyUI/Frames/UIMainFrame.cs +++ b/SunnyUI/Frames/UIMainFrame.cs @@ -114,7 +114,7 @@ namespace Sunny.UI public UIPage AddPage(UIPage page, Guid guid) { page.PageGuid = guid; - return AddPage(page); ; + return AddPage(page); } public UIPage AddPage(UIPage page) @@ -128,6 +128,17 @@ namespace Sunny.UI { MainTabControl.SelectPage(pageIndex); } + + public bool RemovePage(int pageIndex) + { + return MainTabControl.RemovePage(pageIndex); + } + + public bool RemovePage(Guid guid) + { + return MainTabControl.RemovePage(guid); + } + #endregion IFrame实现 } } \ No newline at end of file