first commit
This commit is contained in:
33
Keps.WinForms/Infrastructure/DesignTimeHelper.cs
Normal file
33
Keps.WinForms/Infrastructure/DesignTimeHelper.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Keps.WinForms.Infrastructure
|
||||
{
|
||||
internal static class DesignTimeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 현재 실행 컨텍스트가 디자이너(디자인 타임)인지 여부를 판단합니다.
|
||||
/// WinForms 디자이너나 XAML 디자이너 프로세스에서 실행 중이면 <c>true</c>를 반환합니다.
|
||||
/// </summary>
|
||||
/// <param name="control">디자인 모드를 추가로 판별할 대상 컨트롤. null이면 프로세스 이름만으로 판별합니다.</param>
|
||||
/// <returns>디자인 타임이면 <c>true</c>, 런타임이면 <c>false</c>.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user