forked from KennanChan/RevitAPIToolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
KennanChan
committed
Dec 21, 2017
1 parent
3800114
commit 6863748
Showing
5 changed files
with
157 additions
and
22 deletions.
There are no files selected for viewing
31 changes: 28 additions & 3 deletions
31
RevitAPIToolbox/Common/ParameterizedExternalEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using System; | ||
using Autodesk.Revit.Attributes; | ||
using Autodesk.Revit.DB; | ||
using Autodesk.Revit.UI; | ||
using Techyard.Revit.Common; | ||
|
||
namespace Test | ||
{ | ||
[Transaction(TransactionMode.Manual)] | ||
public class TestExternalEventHandler : IExternalCommand | ||
{ | ||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) | ||
{ | ||
var handler = new CustomEventHandler2(); | ||
var event2 = ExternalEvent.Create(handler); | ||
if (ExternalEventManager.Manager.Register(new CustomEventHandler())) | ||
{ | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("刘一"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("陈二"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("张三"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("李四"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("王五"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("赵六"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("孙七"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("周八"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("吴九"); | ||
event2.Raise(); | ||
ExternalEventManager.Manager.Raise<CustomEventHandler, string>("郑十"); | ||
event2.Raise(); | ||
} | ||
return Result.Succeeded; | ||
} | ||
|
||
private class CustomEventHandler : ParameterizedExternalEventHandler<string> | ||
{ | ||
private int Count { get; set; } | ||
|
||
public override void Execute(UIApplication app, string parameter) | ||
{ | ||
TaskDialog.Show("外部事件", $"{GetName()}事件第{++Count}次调用:{parameter}"); | ||
} | ||
|
||
public override string GetName() | ||
{ | ||
return "Test"; | ||
} | ||
} | ||
|
||
private class CustomEventHandler2 : IExternalEventHandler | ||
{ | ||
private int Count { get; set; } | ||
|
||
public void Execute(UIApplication app) | ||
{ | ||
TaskDialog.Show("外部事件", $"{GetName()}事件第{++Count}次调用"); | ||
} | ||
|
||
public string GetName() | ||
{ | ||
return "Test"; | ||
} | ||
} | ||
} | ||
} |