diff --git a/SunnyUI/Controls/UIComboBox.cs b/SunnyUI/Controls/UIComboBox.cs index 84cee751..64296317 100644 --- a/SunnyUI/Controls/UIComboBox.cs +++ b/SunnyUI/Controls/UIComboBox.cs @@ -29,6 +29,7 @@ * 2022-04-20: V3.1.5 过滤文字为空时,下拉框显示所有数据列表 * 2022-05-04: V3.1.8 过滤时修复ValueMember绑定值的显示 * 2022-05-24: V3.1.9 Selceted=-1,清除文本 + * 2022-08-25: V3.2.3 下拉框边框可设置颜色 ******************************************************************************/ using System; @@ -782,5 +783,12 @@ namespace Sunny.UI get => ListBox.HoverColor; set => FilterListBox.HoverColor = ListBox.HoverColor = value; } + + [DefaultValue(typeof(Color), "80, 160, 255")] + public Color ItemRectColor + { + get => ListBox.RectColor; + set => ListBox.RectColor = value; + } } } \ No newline at end of file diff --git a/SunnyUI/Controls/UIGlobal.cs b/SunnyUI/Controls/UIGlobal.cs index 2c525519..1c3e1456 100644 --- a/SunnyUI/Controls/UIGlobal.cs +++ b/SunnyUI/Controls/UIGlobal.cs @@ -62,4 +62,33 @@ namespace Sunny.UI public delegate void OnSelectionChanged(object sender, UITextBoxSelectionArgs e); public delegate void OnDateTimeChanged(object sender, UIDateTimeArgs e); + + public class UIPageParamsArgs : EventArgs + { + public UIPage Page { get; set; } + + public object Value { get; set; } + + public UIParamSourceType SourceType { get; set; } + + public UIPageParamsArgs() + { + + } + + public UIPageParamsArgs(UIPage page, object value, UIParamSourceType sourceType) + { + Page = page; + Value = value; + SourceType = sourceType; + } + } + + public enum UIParamSourceType + { + Frame, + Page + } + + public delegate bool OnReceiveParams(object sender, UIPageParamsArgs e); } \ No newline at end of file diff --git a/SunnyUI/Forms/UIForm.cs b/SunnyUI/Forms/UIForm.cs index fa64285e..ac34f691 100644 --- a/SunnyUI/Forms/UIForm.cs +++ b/SunnyUI/Forms/UIForm.cs @@ -38,6 +38,9 @@ * 2022-07-05: V3.2.1 多页面框架增加PageAdded,PageSelected,PageRemoved事件 * 2022-07-14: V3.2.1 增加UnRegisterHotKey,卸载全局热键 * 2022-07-25: V3.2.2 多页面框架增加程序关闭时调用UIPage的Final和FormClosed事件 + * 2022-08-25: V3.2.3 重构多页面框架传值删除SetParamToPage + * 2022-08-25: V3.2.3 重构多页面框架传值:框架发送给页面 SendParamToPage 函数 + * 2022-08-25: V3.2.3 重构多页面框架传值:接收页面传值 ReceiveParams 事件 ******************************************************************************/ using System; @@ -2115,15 +2118,15 @@ namespace Sunny.UI } } - public UIPage AddPage(UIPage page, int index) + public UIPage AddPage(UIPage page, int pageIndex) { - page.PageIndex = index; + page.PageIndex = pageIndex; return AddPage(page); } - public UIPage AddPage(UIPage page, Guid guid) + public UIPage AddPage(UIPage page, Guid pageGuid) { - page.PageGuid = guid; + page.PageGuid = pageGuid; return AddPage(page); } @@ -2174,43 +2177,59 @@ namespace Sunny.UI return MainTabControl.SelectPage(pageIndex); } - public virtual bool SelectPage(Guid guid) + public virtual bool SelectPage(Guid pageGuid) { SetDefaultTabControl(); if (MainTabControl == null) return false; - return MainTabControl.SelectPage(guid); + return MainTabControl.SelectPage(pageGuid); } public bool RemovePage(int pageIndex) => MainTabControl?.RemovePage(pageIndex) ?? false; - public bool RemovePage(Guid guid) => MainTabControl?.RemovePage(guid) ?? false; - - public virtual void FeedbackFormPage(int fromPageIndex, params object[] objects) { } + public bool RemovePage(Guid pageGuid) => MainTabControl?.RemovePage(pageGuid) ?? false; public UIPage GetPage(int pageIndex) => SetDefaultTabControl().MainTabControl?.GetPage(pageIndex); - public UIPage GetPage(Guid guid) => SetDefaultTabControl().MainTabControl?.GetPage(guid); + public UIPage GetPage(Guid pageGuid) => SetDefaultTabControl().MainTabControl?.GetPage(pageGuid); public bool ExistPage(int pageIndex) => GetPage(pageIndex) != null; - public bool ExistPage(Guid guid) => GetPage(guid) != null; + public bool ExistPage(Guid pageGuid) => GetPage(pageGuid) != null; - public bool SetParamToPage(int toPageIndex, int fromPageIndex, params object[] objects) + public bool SendParamToPage(int pageIndex, UIPage sourcePage, object value) { SetDefaultTabControl(); - UIPage page = GetPage(toPageIndex); + UIPage page = GetPage(pageIndex); if (page == null) return false; - return page.SetParam(fromPageIndex, objects); + return page.DoReceiveParams(new UIPageParamsArgs(sourcePage, value, UIParamSourceType.Page)); } - public bool SetParamToPage(Guid toPageGuid, Guid fromPageGuid, params object[] objects) + public bool SendParamToPage(Guid pageGuid, UIPage sourcePage, object value) { SetDefaultTabControl(); - UIPage page = GetPage(toPageGuid); + UIPage page = GetPage(pageGuid); if (page == null) return false; - return page.SetParam(fromPageGuid, objects); + return page.DoReceiveParams(new UIPageParamsArgs(sourcePage, value, UIParamSourceType.Page)); } + public bool SendParamToPage(int pageIndex, object value) + { + SetDefaultTabControl(); + UIPage page = GetPage(pageIndex); + if (page == null) return false; + return page.DoReceiveParams(new UIPageParamsArgs(null, value, UIParamSourceType.Frame)); + } + + public bool DoReceiveParams(UIPageParamsArgs e) + { + bool result = false; + if (ReceiveParams != null) + result = ReceiveParams.Invoke(this, e); + return result; + } + + public event OnReceiveParams ReceiveParams; + public T GetPage() where T : UIPage => SetDefaultTabControl().MainTabControl?.GetPage(); public List GetPages() where T : UIPage => SetDefaultTabControl().MainTabControl?.GetPages(); diff --git a/SunnyUI/Frames/IFrame.cs b/SunnyUI/Frames/IFrame.cs index a556806a..f1aa68be 100644 --- a/SunnyUI/Frames/IFrame.cs +++ b/SunnyUI/Frames/IFrame.cs @@ -28,35 +28,35 @@ namespace Sunny.UI { UITabControl MainTabControl { get; } - UIPage AddPage(UIPage page, int index); + UIPage AddPage(UIPage page, int pageIndex); - UIPage AddPage(UIPage page, Guid guid); + UIPage AddPage(UIPage page, Guid pageGuid); UIPage AddPage(UIPage page); bool SelectPage(int pageIndex); - bool SelectPage(Guid guid); + bool SelectPage(Guid pageGuid); UIPage GetPage(int pageIndex); - UIPage GetPage(Guid guid); + UIPage GetPage(Guid pageGuid); bool TopMost { get; set; } bool RemovePage(int pageIndex); - bool RemovePage(Guid guid); + bool RemovePage(Guid pageGuid); - void FeedbackFormPage(int fromPageIndex, params object[] objects); + bool ExistPage(int pageIndex); - bool ExistPage(int index); + bool ExistPage(Guid pageGuid); - bool ExistPage(Guid guid); + public bool SendParamToPage(int pageIndex, UIPage sourcePage, object value); - bool SetParamToPage(int toPageIndex, int fromPageIndex, params object[] objects); + public bool SendParamToPage(Guid pageGuid, UIPage sourcePage, object value); - bool SetParamToPage(Guid toPageGuid, Guid fromPageGuid, params object[] objects); + public bool DoReceiveParams(UIPageParamsArgs e); void Init(); diff --git a/SunnyUI/Frames/UIPage.cs b/SunnyUI/Frames/UIPage.cs index 3f2bb1b2..ce97e3c8 100644 --- a/SunnyUI/Frames/UIPage.cs +++ b/SunnyUI/Frames/UIPage.cs @@ -28,6 +28,10 @@ * 2022-04-26: V3.1.8 屏蔽一些属性 * 2022-05-11: V3.1.8 ShowTitle时,可调整Padding * 2022-06-11: V3.1.9 弹窗默认关闭半透明遮罩 + * 2022-08-25: V3.2.3 重构多页面框架传值删除SetParam,FeedbackToFrame + * 2022-08-25: V3.2.3 重构多页面框架传值:页面发送给框架 SendParamToFrame 函数 + * 2022-08-25: V3.2.3 重构多页面框架传值:页面发送给框架 SendParamToPage 函数 + * 2022-08-25: V3.2.3 重构多页面框架传值:接收框架、页面传值 ReceiveParams 事件 ******************************************************************************/ using System; @@ -828,21 +832,34 @@ namespace Sunny.UI get; set; } - public void FeedbackToFrame(params object[] objects) + public bool SendParamToFrame(object value) { - Frame?.FeedbackFormPage(PageIndex, objects); + if (Frame == null) return false; + return Frame.DoReceiveParams(new UIPageParamsArgs(this, value, UIParamSourceType.Page)); } - public virtual bool SetParam(int fromPageIndex, params object[] objects) + public bool SendParamToPage(int pageIndex, object value) { - return false; + if (Frame == null) return false; + return Frame.SendParamToPage(pageIndex, this, value); } - public virtual bool SetParam(Guid fromPageGuid, params object[] objects) + public bool SendParamToPage(Guid pageGuid, object value) { - return false; + if (Frame == null) return false; + return Frame.SendParamToPage(pageGuid, this, value); } + public bool DoReceiveParams(UIPageParamsArgs e) + { + bool result = false; + if (ReceiveParams != null) + result = ReceiveParams.Invoke(this, e); + return result; + } + + public event OnReceiveParams ReceiveParams; + #region 一些辅助窗口 ///