using System; using System.ComponentModel; using System.Diagnostics; using System.Windows.Forms; namespace Keps.WinForms.Infrastructure { internal static class DesignTimeHelper { /// /// 현재 실행 컨텍스트가 디자이너(디자인 타임)인지 여부를 판단합니다. /// WinForms 디자이너나 XAML 디자이너 프로세스에서 실행 중이면 true를 반환합니다. /// /// 디자인 모드를 추가로 판별할 대상 컨트롤. null이면 프로세스 이름만으로 판별합니다. /// 디자인 타임이면 true, 런타임이면 false. public static bool IsDesignMode(Control control = null) { if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return true; } if (control != null && control.Site != null && control.Site.DesignMode) { return true; } string processName = Process.GetCurrentProcess().ProcessName; return string.Equals(processName, "devenv", StringComparison.OrdinalIgnoreCase) || string.Equals(processName, "XDesProc", StringComparison.OrdinalIgnoreCase); } } }