* UIForm: 增加页面间传值方法SetParamToPage

This commit is contained in:
Sunny 2022-02-09 18:22:05 +08:00
parent 0e301a55af
commit de67ee6c6f
8 changed files with 58 additions and 16 deletions

Binary file not shown.

Binary file not shown.

View File

@ -11,5 +11,18 @@
{ {
uiContextMenuStrip1.Show(uiAvatar4, 0, uiAvatar4.Height); uiContextMenuStrip1.Show(uiAvatar4, 0, uiAvatar4.Height);
} }
public override bool SetParam(int fromPageIndex, params object[] objects)
{
if (fromPageIndex == 1002 && objects.Length == 1)
{
uiLabel1.Text = objects[0].ToString();
return true;
}
else
{
return false;
}
}
} }
} }

View File

@ -355,7 +355,6 @@ namespace Sunny.UI.Demo
this.uiSymbolButton21.Name = "uiSymbolButton21"; this.uiSymbolButton21.Name = "uiSymbolButton21";
this.uiSymbolButton21.RadiusSides = Sunny.UI.UICornerRadiusSides.None; this.uiSymbolButton21.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.uiSymbolButton21.Size = new System.Drawing.Size(46, 35); this.uiSymbolButton21.Size = new System.Drawing.Size(46, 35);
this.uiSymbolButton21.Style = Sunny.UI.UIStyle.Custom;
this.uiSymbolButton21.Symbol = 61520; this.uiSymbolButton21.Symbol = 61520;
this.uiSymbolButton21.TabIndex = 98; this.uiSymbolButton21.TabIndex = 98;
this.uiSymbolButton21.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.uiSymbolButton21.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@ -369,7 +368,6 @@ namespace Sunny.UI.Demo
this.uiSymbolButton13.Name = "uiSymbolButton13"; this.uiSymbolButton13.Name = "uiSymbolButton13";
this.uiSymbolButton13.RadiusSides = Sunny.UI.UICornerRadiusSides.None; this.uiSymbolButton13.RadiusSides = Sunny.UI.UICornerRadiusSides.None;
this.uiSymbolButton13.Size = new System.Drawing.Size(46, 35); this.uiSymbolButton13.Size = new System.Drawing.Size(46, 35);
this.uiSymbolButton13.Style = Sunny.UI.UIStyle.Custom;
this.uiSymbolButton13.Symbol = 61518; this.uiSymbolButton13.Symbol = 61518;
this.uiSymbolButton13.TabIndex = 97; this.uiSymbolButton13.TabIndex = 97;
this.uiSymbolButton13.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.uiSymbolButton13.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
@ -1156,6 +1154,7 @@ namespace Sunny.UI.Demo
this.uiButton1.Text = "White"; this.uiButton1.Text = "White";
this.uiButton1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.uiButton1.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.uiButton1.TipsText = "1"; this.uiButton1.TipsText = "1";
this.uiButton1.Click += new System.EventHandler(this.uiButton1_Click);
// //
// uiToolTip1 // uiToolTip1
// //

View File

@ -63,5 +63,12 @@ namespace Sunny.UI.Demo
{ {
Frame.SelectPage(5000); Frame.SelectPage(5000);
} }
private void uiButton1_Click(object sender, EventArgs e)
{
//传值给页面1001
//设置FAvatar的Label文字
Frame.SetParamToPage(1001, PageIndex, "你好");
}
} }
} }

View File

@ -28,6 +28,7 @@
* 2021-08-17: V3.0.6 * 2021-08-17: V3.0.6
* 2021-08-17: V3.0.8 IFrame接口 * 2021-08-17: V3.0.8 IFrame接口
* 2022-01-03: V3.0.9 * 2022-01-03: V3.0.9
* 2022-02-09: V3.1.0 SetParamToPage
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -1921,19 +1922,19 @@ namespace Sunny.UI
public UITabControl MainTabControl { get; set; } public UITabControl MainTabControl { get; set; }
public virtual UIPage AddPage(UIPage page, int index) public UIPage AddPage(UIPage page, int index)
{ {
page.PageIndex = index; page.PageIndex = index;
return AddPage(page); return AddPage(page);
} }
public virtual UIPage AddPage(UIPage page, Guid guid) public UIPage AddPage(UIPage page, Guid guid)
{ {
page.PageGuid = guid; page.PageGuid = guid;
return AddPage(page); return AddPage(page);
} }
public virtual UIPage AddPage(UIPage page) public UIPage AddPage(UIPage page)
{ {
page.Frame = this; page.Frame = this;
MainTabControl?.AddPage(page); MainTabControl?.AddPage(page);
@ -1950,40 +1951,53 @@ namespace Sunny.UI
MainTabControl?.SelectPage(guid); MainTabControl?.SelectPage(guid);
} }
public virtual bool RemovePage(int pageIndex) public bool RemovePage(int pageIndex)
{ {
return MainTabControl?.RemovePage(pageIndex) ?? false; return MainTabControl?.RemovePage(pageIndex) ?? false;
} }
public virtual bool RemovePage(Guid guid) public bool RemovePage(Guid guid)
{ {
return MainTabControl?.RemovePage(guid) ?? false; return MainTabControl?.RemovePage(guid) ?? false;
} }
public virtual void Feedback(object sender, int pageIndex, params object[] objects) public virtual void FeedbackFormPage(int fromPageIndex, params object[] objects)
{ {
} }
public virtual UIPage GetPage(int pageIndex) public UIPage GetPage(int pageIndex)
{ {
return MainTabControl?.GetPage(pageIndex); return MainTabControl?.GetPage(pageIndex);
} }
public virtual UIPage GetPage(Guid guid) public UIPage GetPage(Guid guid)
{ {
return MainTabControl?.GetPage(guid); return MainTabControl?.GetPage(guid);
} }
public virtual bool ExistPage(int pageIndex) public bool ExistPage(int pageIndex)
{ {
return GetPage(pageIndex) != null; return GetPage(pageIndex) != null;
} }
public virtual bool ExistPage(Guid guid) public bool ExistPage(Guid guid)
{ {
return GetPage(guid) != null; return GetPage(guid) != null;
} }
public bool SetParamToPage(int toPageIndex, int fromPageIndex, params object[] objects)
{
UIPage page = GetPage(toPageIndex);
if (page == null) return false;
return page.SetParam(fromPageIndex, objects);
}
public bool SetParamToPage(Guid toPageGuid, Guid fromPageGuid, params object[] objects)
{
UIPage page = GetPage(toPageGuid);
if (page == null) return false;
return page.SetParam(fromPageGuid, objects);
}
#endregion IFrame实现 #endregion IFrame实现
} }

View File

@ -47,10 +47,14 @@ namespace Sunny.UI
bool RemovePage(Guid guid); bool RemovePage(Guid guid);
void Feedback(object sender, int pageIndex, params object[] objects); void FeedbackFormPage(int fromPageIndex, params object[] objects);
bool ExistPage(int index); bool ExistPage(int index);
bool ExistPage(Guid guid); bool ExistPage(Guid guid);
bool SetParamToPage(int toPageIndex, int fromPageIndex, params object[] objects);
bool SetParamToPage(Guid toPageGuid, Guid fromPageGuid, params object[] objects);
} }
} }

View File

@ -639,14 +639,19 @@ namespace Sunny.UI
get; set; get; set;
} }
public void Feedback(object sender, params object[] objects) public void FeedbackToFrame(params object[] objects)
{ {
Frame?.Feedback(this, PageIndex, objects); Frame?.FeedbackFormPage(PageIndex, objects);
} }
public virtual void SetParam(int fromPageIndex, params object[] objects) public virtual bool SetParam(int fromPageIndex, params object[] objects)
{ {
return false;
}
public virtual bool SetParam(Guid fromPageGuid, params object[] objects)
{
return false;
} }
#region #region