DeviceManager/DeviceRepairAndOptimization/Utils/FormExtended.cs
2024-05-28 22:36:38 +08:00

52 lines
1.4 KiB
C#

using DevExpress.XtraEditors;
using DevExpress.XtraSplashScreen;
using System;
using System.Windows.Forms;
namespace DeviceRepairAndOptimization.Utils
{
public static class FormExtended
{
public static void ShowInPanel(this PanelControl control, Pages.FormBase page)
{
control.Controls.Clear();
page.Dock = DockStyle.Fill;
page.TopLevel = false;
control.SizeChanged += page.page_Resize;
control.Controls.Add(page);
page.Show();
}
public static void ShowInPanel<T>(this PanelControl control) where T : Pages.FormBase
{
var type = typeof(T);
var page = Activator.CreateInstance(type) as Pages.FormBase;
control.Controls.Clear();
page.Dock = DockStyle.Fill;
page.TopLevel = false;
control.SizeChanged += page.page_Resize;
control.Controls.Add(page);
page.Show();
}
/// <summary>
/// 关闭等待窗口
/// </summary>
/// <param name="ssm"></param>
public static void TryCloseWait(this SplashScreenManager ssm)
{
try
{
if (ssm.IsSplashFormVisible)
{
ssm.CloseWaitForm();
}
}
catch
{ }
}
}
}