/*------------------------------------------------------------------------- * 功能描述:IdingSingleCommand * 作者:xulisong * 创建时间: 2019/5/31 15:46:51 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using Autodesk.Revit.UI; using Autodesk.Revit.UI.Events; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FWindSoft.Revit { public class SingleIdingCommand : IRevitRegister { #region 初始化 public SingleIdingCommand() { Enable = true; } public bool Enable { get; set; } #endregion #region 消费队列 /// /// 对接事件绑定 /// /// /// protected virtual void ApplicaionIdling(object sender, IdlingEventArgs e) { if (!Enable) { return; } var application = sender as UIApplication; OnExecute(application); e.SetRaiseWithoutDelay(); } #endregion protected virtual void OnExecute(UIApplication application) { Execute?.Invoke(this, application); } public event EventHandler Execute; #region 事件注册相关 public void Register(ExternalApplication application) { application.Idling += ApplicaionIdling; } public void Unregister(ExternalApplication application) { application.Idling -= ApplicaionIdling; } #endregion } }