diff --git a/Bin/net40/SunnyUI.Demo.exe b/Bin/net40/SunnyUI.Demo.exe index 66f235d5..438374cf 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 197b5879..7afa2939 100644 Binary files a/Bin/net40/SunnyUI.dll and b/Bin/net40/SunnyUI.dll differ diff --git a/Bin/net45/SunnyUI.dll b/Bin/net45/SunnyUI.dll index f085940d..0479229c 100644 Binary files a/Bin/net45/SunnyUI.dll and b/Bin/net45/SunnyUI.dll differ diff --git a/Bin/net5.0-windows/SunnyUI.dll b/Bin/net5.0-windows/SunnyUI.dll index af5a22cf..898e7c0d 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 a998bfa3..4678e417 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 a1b92b6f..756f9cc6 100644 Binary files a/Bin/netcoreapp3.1/SunnyUI.dll and b/Bin/netcoreapp3.1/SunnyUI.dll differ diff --git a/SunnyUI.Demo/Controls/FButton.cs b/SunnyUI.Demo/Controls/FButton.cs index 97d602be..a8b5fb7c 100644 --- a/SunnyUI.Demo/Controls/FButton.cs +++ b/SunnyUI.Demo/Controls/FButton.cs @@ -14,32 +14,39 @@ namespace Sunny.UI.Demo } /// - /// 放在 [窗体Load、重载OnLoad、重载Init] 的内容每次页面切换都会执行。 + /// 放在 [窗体Load、重载OnLoad、重载Init] 的内容每次页面切换,进入页面都会执行。 /// 这三个选一个用就行了。 /// /// /// private void FButton_Load(object sender, EventArgs e) { - uiSwitch1.Active = uiSwitch4.Active = true; - uiSwitch2.Active = uiSwitch3.Active = false; + Console.WriteLine("1. FButton_Load"); } - //放在 [窗体Load、重载OnLoad、重载Init] 的内容每次页面切换都会执行。 - //protected override void OnLoad(EventArgs e) - //{ - // base.OnLoad(e); - // uiSwitch1.Active = uiSwitch4.Active = true; - // uiSwitch2.Active = uiSwitch3.Active = false; - //} + //放在 [窗体Load、重载OnLoad、重载Init] 的内容每次页面切换,进入页面都会执行。 + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + Console.WriteLine("3. FButton_OnLoad"); + } - //放在 [窗体Load、重载OnLoad、重载Init] 的内容每次页面切换都会执行。 - //public override void Init() - //{ - // base.Init(); - // uiSwitch1.Active = uiSwitch4.Active = true; - // uiSwitch2.Active = uiSwitch3.Active = false; - //} + //放在 [窗体Load、重载OnLoad、重载Init] 的内容每次页面切换,进入页面都会执行。 + public override void Init() + { + base.Init(); + uiSwitch1.Active = uiSwitch4.Active = true; + uiSwitch2.Active = uiSwitch3.Active = false; + + Console.WriteLine("2. FButton_Init"); + } + + //放在 [Final] 的内容每次页面切换,退出页面都会执行 + public override void Final() + { + base.Final(); + Console.WriteLine("4. FButton_Final"); + } private void uiButton10_Click(object sender, EventArgs e) { diff --git a/SunnyUI/Controls/UITabControl.cs b/SunnyUI/Controls/UITabControl.cs index 04aa2375..8f0f8ab3 100644 --- a/SunnyUI/Controls/UITabControl.cs +++ b/SunnyUI/Controls/UITabControl.cs @@ -21,13 +21,13 @@ * 2020-08-12: V2.2.7 标题垂直居中 ******************************************************************************/ -using Sunny.UI.Win32; using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Drawing.Drawing2D; using System.Windows.Forms; +using Sunny.UI.Win32; namespace Sunny.UI { @@ -127,7 +127,10 @@ namespace Sunny.UI public void AddPage(Guid guid, UITabControlMenu page) => Helper.AddPage(guid, page); - public string Version { get; } + public string Version + { + get; + } private Color _fillColor = UIColor.LightBlue; private Color tabBackColor = Color.FromArgb(56, 56, 56); @@ -137,14 +140,20 @@ namespace Sunny.UI /// [DefaultValue(null)] [Description("获取或设置包含有关控件的数据的对象字符串"), Category("SunnyUI")] - public string TagString { get; set; } + public string TagString + { + get; set; + } /// /// 自定义主题风格 /// [DefaultValue(false)] [Description("获取或设置可以自定义主题风格"), Category("SunnyUI")] - public bool StyleCustomMode { get; set; } + public bool StyleCustomMode + { + get; set; + } private HorizontalAlignment textAlignment = HorizontalAlignment.Center; @@ -555,7 +564,10 @@ namespace Sunny.UI [DefaultValue(false)] [Description("多页面框架时,包含UIPage,在点击Tab页关闭时关闭UIPage"), Category("SunnyUI")] - public bool AutoClosePage { get; set; } + public bool AutoClosePage + { + get; set; + } internal void RemoveTabPage(int index) { @@ -608,27 +620,44 @@ namespace Sunny.UI protected override void OnSelectedIndexChanged(EventArgs e) { base.OnSelectedIndexChanged(e); - Init(SelectedIndex); + Init(); if (ShowActiveCloseButton && !ShowCloseButton) { timer.Start(); } } - public void Init(int index = 0) + private int LastIndex = 0; + + public void Init() { - if (index < 0 || index >= TabPages.Count) + if (SelectedIndex < 0 || SelectedIndex >= TabPages.Count) { return; } - if (SelectedIndex != index) - SelectedIndex = index; - - List pages = TabPages[SelectedIndex].GetControls(); - foreach (var page in pages) + if (SelectedIndex >= 0) { - page.ReLoad(); + List pages; + if (LastIndex != SelectedIndex) + { + if (LastIndex >= 0 && TabPages.Count > 0) + { + pages = TabPages[LastIndex].GetControls(); + foreach (var page in pages) + { + page.Final(); + } + } + + LastIndex = SelectedIndex; + } + + pages = TabPages[SelectedIndex].GetControls(); + foreach (var page in pages) + { + page.ReLoad(); + } } List leftTabControls = TabPages[SelectedIndex].GetControls(); @@ -901,11 +930,20 @@ namespace Sunny.UI MouseInUpButton = mouseInUpButton; } - public bool MouseOver { get; } + public bool MouseOver + { + get; + } - public bool MousePress { get; } + public bool MousePress + { + get; + } - public bool MouseInUpButton { get; } + public bool MouseInUpButton + { + get; + } } } } \ No newline at end of file diff --git a/SunnyUI/Pages/UIPage.cs b/SunnyUI/Pages/UIPage.cs index 2405696d..24eed16e 100644 --- a/SunnyUI/Pages/UIPage.cs +++ b/SunnyUI/Pages/UIPage.cs @@ -217,6 +217,7 @@ namespace Sunny.UI } public event EventHandler Initialize; + public event EventHandler Finalize; protected override void OnControlAdded(ControlEventArgs e) { @@ -260,7 +261,7 @@ namespace Sunny.UI public virtual void Init() { - Initialize?.Invoke(this, null); + Initialize?.Invoke(this, new EventArgs()); } protected override void OnLoad(EventArgs e) @@ -292,6 +293,7 @@ namespace Sunny.UI public virtual void Final() { + Finalize?.Invoke(this, new EventArgs()); } public void SetStyle(UIStyle style)