判斷WinForm窗體是否已經打開
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace IceInk
{
/// <summary>
/// //基于WinForm窗體的幫助類
/// </summary>
public class EkWinFormHelper
{
/// <summary>
/// 判斷窗體是否打開
/// </summary>
/// <typeparam name="T">窗體類型</typeparam>
/// <returns></returns>
public static bool CheckIsOpenForm<T>() where T : Form
{
Type wormType = typeof(T);
foreach (Form frm in Application.OpenForms)
{
if (frm.Name.Equals(wormType.Name))
{
return true;
}
}
return false;
}
}
}