12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /*-------------------------------------------------------------------------
- * 功能描述: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 消费队列
- /// <summary>
- /// 对接事件绑定
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<UIApplication> Execute;
- #region 事件注册相关
- public void Register(ExternalApplication application)
- {
- application.Idling += ApplicaionIdling;
- }
- public void Unregister(ExternalApplication application)
- {
- application.Idling -= ApplicaionIdling;
- }
- #endregion
- }
- }
|