mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-06 17:26:35 +08:00
整理一下项目文件
This commit is contained in:
45
AIStudio.Wpf.DiagramDesigner/Helpers/DesignerHelper.cs
Normal file
45
AIStudio.Wpf.DiagramDesigner/Helpers/DesignerHelper.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
|
||||
namespace AIStudio.Wpf.DiagramDesigner
|
||||
{
|
||||
public class DesignerHelper
|
||||
{
|
||||
private static bool? _isInDesignMode;
|
||||
|
||||
public static bool IsInDesignMode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_isInDesignMode.HasValue)
|
||||
{
|
||||
_isInDesignMode = (bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement)).Metadata.DefaultValue;
|
||||
}
|
||||
return _isInDesignMode.Value;
|
||||
}
|
||||
}
|
||||
|
||||
#region IsInMainThread
|
||||
|
||||
/// <summary>
|
||||
/// 是否是在主线程中处理
|
||||
/// </summary>
|
||||
public static bool IsInMainThread
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Thread.CurrentThread.IsBackground || Thread.CurrentThread.IsThreadPoolThread) return false;
|
||||
|
||||
if (Thread.CurrentThread.Name == "主线程") return true;
|
||||
|
||||
if (Application.Current == null)
|
||||
return true;
|
||||
|
||||
return Thread.CurrentThread == Application.Current.Dispatcher.Thread;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user