优化更新代码,添加界面功能并整合
This commit is contained in:
40
ShrlAlgo.RvKits/RvMEP/RevitCommandEndedMonitor.cs
Normal file
40
ShrlAlgo.RvKits/RvMEP/RevitCommandEndedMonitor.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Events;
|
||||
|
||||
namespace ShrlAlgo.RvKits.RvMEP;
|
||||
|
||||
public class RevitCommandEndedMonitor
|
||||
{
|
||||
private readonly UIApplication _revitUiApplication;
|
||||
|
||||
private bool _initializingCommandMonitor;
|
||||
|
||||
public event EventHandler CommandEnded;
|
||||
|
||||
public RevitCommandEndedMonitor(UIApplication revituiApplication)
|
||||
{
|
||||
_revitUiApplication = revituiApplication;
|
||||
|
||||
_initializingCommandMonitor = true;
|
||||
|
||||
_revitUiApplication.Idling += OnRevitUiApplicationIdling;
|
||||
}
|
||||
|
||||
private void OnRevitUiApplicationIdling(object sender, IdlingEventArgs idlingEventArgs)
|
||||
{
|
||||
if (_initializingCommandMonitor)
|
||||
{
|
||||
_initializingCommandMonitor = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_revitUiApplication.Idling -= OnRevitUiApplicationIdling;
|
||||
|
||||
OnCommandEnded();
|
||||
}
|
||||
|
||||
protected virtual void OnCommandEnded()
|
||||
{
|
||||
CommandEnded?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user