* UIComboBox: 下拉框边框可设置颜色

* UIForm: 重构多页面框架传值删除SetParamToPage
* UIForm: 重构多页面框架传值:框架发送给页面 SendParamToPage 函数
* UIForm: 重构多页面框架传值:接收页面传值 ReceiveParams 事件
* UIPage: 重构多页面框架传值删除SetParam,FeedbackToFrame
* UIPage: 重构多页面框架传值:页面发送给框架 SendParamToFrame 函数
* UIPage: 重构多页面框架传值:页面发送给框架 SendParamToPage 函数
* UIPage: 重构多页面框架传值:接收框架、页面传值 ReceiveParams 事件
This commit is contained in:
Sunny 2022-08-25 23:01:30 +08:00
parent 004f422df1
commit 93c7441803
5 changed files with 106 additions and 33 deletions

View File

@ -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;
}
}
}

View File

@ -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);
}

View File

@ -38,6 +38,9 @@
* 2022-07-05: V3.2.1 PageAddedPageSelectedPageRemoved事件
* 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<T>() where T : UIPage => SetDefaultTabControl().MainTabControl?.GetPage<T>();
public List<T> GetPages<T>() where T : UIPage => SetDefaultTabControl().MainTabControl?.GetPages<T>();

View File

@ -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();

View File

@ -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 SetParamFeedbackToFrame
* 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
/// <summary>