* UIForm: 增加一个在窗体显示后延时执行的事件

* UIPage: 增加一个在窗体显示后延时执行的事件
This commit is contained in:
Sunny 2023-10-09 23:45:04 +08:00
parent e37f8a27bd
commit 9be05923be
2 changed files with 45 additions and 3 deletions

View File

@ -48,6 +48,7 @@
* 2023-05-12: V3.3.6 DrawString函数
* 2023-07-24: V3.4.1 UIPage未执行Final事件的问题
* 2023-07-27: V3.4.1 TopMost为true
* 2023-10-09: V3.5.0
******************************************************************************/
using System;
@ -1399,7 +1400,7 @@ namespace Sunny.UI
SetZoomScale();
CalcSystemBoxPos();
if (isShow)
if (IsShown)
{
SetRadius();
}
@ -1419,7 +1420,9 @@ namespace Sunny.UI
public event EventHandler RectColorChanged;
private bool isShow;
private bool IsShown;
private System.Windows.Forms.Timer AfterShownTimer;
public event EventHandler AfterShown;
protected override void OnShown(EventArgs e)
{
@ -1428,9 +1431,27 @@ namespace Sunny.UI
CalcSystemBoxPos();
SetRadius();
isShow = true;
IsShown = true;
SetDPIScale();
SetZoomScaleRect();
if (AfterShown != null)
{
AfterShownTimer = new System.Windows.Forms.Timer();
AfterShownTimer.Tick += AfterShownTimer_Tick;
AfterShownTimer.Start();
}
}
private void AfterShownTimer_Tick(object sender, EventArgs e)
{
AfterShownTimer.Stop();
AfterShownTimer.Tick -= AfterShownTimer_Tick;
AfterShownTimer?.Dispose();
AfterShownTimer = null;
AfterShown?.Invoke(this, EventArgs.Empty);
AfterShown = null;
}
public event OnZoomScaleRectChanged ZoomScaleRectChanged;

View File

@ -38,6 +38,7 @@
* 2023-03-15: V3.3.3
* 2023-05-12: V3.3.6 DrawString函数
* 2023-07-27: V3.4.1 TopMost为true
* 2023-10-09: V3.5.0
******************************************************************************/
using System;
@ -490,12 +491,32 @@ namespace Sunny.UI
}
private bool IsShown;
private System.Windows.Forms.Timer AfterShownTimer;
public event EventHandler AfterShown;
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (AutoScaleMode == AutoScaleMode.Font) AutoScaleMode = AutoScaleMode.None;
IsShown = true;
if (AfterShown != null)
{
AfterShownTimer = new System.Windows.Forms.Timer();
AfterShownTimer.Tick += AfterShownTimer_Tick;
AfterShownTimer.Start();
}
}
private void AfterShownTimer_Tick(object sender, EventArgs e)
{
AfterShownTimer.Stop();
AfterShownTimer.Tick -= AfterShownTimer_Tick;
AfterShownTimer?.Dispose();
AfterShownTimer = null;
AfterShown?.Invoke(this, EventArgs.Empty);
AfterShown = null;
}
internal void ReLoad()