diff --git a/.editorconfig b/.editorconfig index aab681d0..e1a42d73 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,4 +4,7 @@ dotnet_diagnostic.IDE0090.severity = none # CA1416: 验证平台兼容性 -dotnet_diagnostic.CA1416.severity = none \ No newline at end of file +dotnet_diagnostic.CA1416.severity = none + +# CA822: 可标记为Static +dotnet_diagnostic.CA1822.severity = none \ No newline at end of file diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 2e6ac8a5..35a93dbd 100644 Binary files a/Bin/net40/SunnyUI.Demo.exe and b/Bin/net40/SunnyUI.Demo.exe differ diff --git a/Bin/net40/SunnyUI.dll b/Bin/net40/SunnyUI.dll index 34141f12..a9688739 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/SunnyUI/Controls/UINavMenuHelper.cs b/SunnyUI/Controls/UINavMenuHelper.cs index e2416523..58c1169c 100644 --- a/SunnyUI/Controls/UINavMenuHelper.cs +++ b/SunnyUI/Controls/UINavMenuHelper.cs @@ -334,6 +334,46 @@ namespace Sunny.UI } } + public UIPage GetPage(int pageIndex) + { + if (pageIndex < 0) return null; + foreach (var item in PageItems) + { + if (item.Value.PageIndex == pageIndex && item.Key != null) + { + var tabPage = item.Key; + var pages = tabPage.GetControls(); + for (int i = 0; i < pages.Count; i++) + { + if (pages[i].PageIndex == pageIndex) + return pages[i]; + } + } + } + + return null; + } + + public UIPage GetPage(Guid guid) + { + if (guid == Guid.Empty) return null; + foreach (var item in PageItems) + { + if (item.Value.PageGuid == guid && item.Key != null) + { + var tabPage = item.Key; + var pages = tabPage.GetControls(); + for (int i = 0; i < pages.Count; i++) + { + if (pages[i].PageGuid == guid) + return pages[i]; + } + } + } + + return null; + } + public bool RemovePage(int pageIndex) { if (pageIndex < 0) return false; diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index f98b70bc..8f3fc6c3 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -131,6 +131,10 @@ namespace Sunny.UI public bool RemovePage(Guid guid) => Helper.RemovePage(guid); + public UIPage GetPage(int pageIndex) => Helper.GetPage(pageIndex); + + public UIPage GetPage(Guid guid) => Helper.GetPage(guid); + public void AddPages(params UIPage[] pages) { foreach (var page in pages) AddPage(page); diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs index 86f747a5..02ecc9e5 100644 --- a/SunnyUI/Forms/UIForm.cs +++ b/SunnyUI/Forms/UIForm.cs @@ -1854,19 +1854,19 @@ namespace Sunny.UI public UITabControl MainTabControl { get; set; } - public UIPage AddPage(UIPage page, int index) + public virtual UIPage AddPage(UIPage page, int index) { page.PageIndex = index; return AddPage(page); } - public UIPage AddPage(UIPage page, Guid guid) + public virtual UIPage AddPage(UIPage page, Guid guid) { page.PageGuid = guid; return AddPage(page); } - public UIPage AddPage(UIPage page) + public virtual UIPage AddPage(UIPage page) { page.Frame = this; MainTabControl?.AddPage(page); @@ -1883,12 +1883,12 @@ namespace Sunny.UI MainTabControl?.SelectPage(guid); } - public bool RemovePage(int pageIndex) + public virtual bool RemovePage(int pageIndex) { return MainTabControl?.RemovePage(pageIndex) ?? false; } - public bool RemovePage(Guid guid) + public virtual bool RemovePage(Guid guid) { return MainTabControl?.RemovePage(guid) ?? false; } @@ -1897,6 +1897,16 @@ namespace Sunny.UI { } + public virtual UIPage GetPage(int pageIndex) + { + return MainTabControl?.GetPage(pageIndex); + } + + public virtual UIPage GetPage(Guid guid) + { + return MainTabControl?.GetPage(guid); + } + #endregion IFrame实现 } } \ No newline at end of file diff --git a/SunnyUI/Forms/UIFormHelper.cs b/SunnyUI/Forms/UIFormHelper.cs index 227089cc..3441946a 100644 --- a/SunnyUI/Forms/UIFormHelper.cs +++ b/SunnyUI/Forms/UIFormHelper.cs @@ -618,25 +618,4 @@ namespace Sunny.UI } } } - - public interface IFrame - { - UITabControl MainTabControl { get; } - - UIPage AddPage(UIPage page, int index); - - UIPage AddPage(UIPage page, Guid guid); - - UIPage AddPage(UIPage page); - - void SelectPage(int pageIndex); - - bool TopMost { get; set; } - - bool RemovePage(int pageIndex); - - bool RemovePage(Guid guid); - - void Feedback(object sender, int pageIndex, params object[] objects); - } } \ No newline at end of file diff --git a/SunnyUI/Frames/IFrame.cs b/SunnyUI/Frames/IFrame.cs new file mode 100644 index 00000000..b2e7af51 --- /dev/null +++ b/SunnyUI/Frames/IFrame.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Sunny.UI +{ + public interface IFrame + { + UITabControl MainTabControl { get; } + + UIPage AddPage(UIPage page, int index); + + UIPage AddPage(UIPage page, Guid guid); + + UIPage AddPage(UIPage page); + + void SelectPage(int pageIndex); + + void SelectPage(Guid guid); + + UIPage GetPage(int pageIndex); + + UIPage GetPage(Guid guid); + + bool TopMost { get; set; } + + bool RemovePage(int pageIndex); + + bool RemovePage(Guid guid); + + void Feedback(object sender, int pageIndex, params object[] objects); + } +} diff --git a/SunnyUI/Frames/UIPage.cs b/SunnyUI/Frames/UIPage.cs index 7e009d8e..643e0fe3 100644 --- a/SunnyUI/Frames/UIPage.cs +++ b/SunnyUI/Frames/UIPage.cs @@ -22,6 +22,7 @@ * 2021-07-18: V3.0.5 修复OnLoad在加载时重复加载两次的问题,增加Final函数,每次页面切换,退出页面都会执行 * 2021-08-17: V3.0.6 增加TitleFont属性 * 2021-08-24: V3.0.6 修复OnLoad在加载时重复加载两次的问题 + * 2021-12-01: V3.0.9 增加FeedBack和SetParam函数,用于多页面传值 ******************************************************************************/ using System; @@ -624,6 +625,16 @@ namespace Sunny.UI get; set; } + public void Feedback(object sender, params object[] objects) + { + Frame?.Feedback(this, PageIndex, objects); + } + + public virtual void SetParam(int fromPageIndex, params object[] objects) + { + + } + #region 一些辅助窗口 ///