0

I'm trying to register the DialogBoxShowing event of the UIControlledApplication. But I cannot use the OnStartup / OnShutdown implementation of the IExternalApplication interface. The best I could come up with is...

    public delegate void Handeler(object sender, DialogBoxShowingEventArgs e);

    public void RegesterDialogEvent(UIControlledApplication uicApp)
    {
        UIAppEventHandlers1 uaeh1 = new UIAppEventHandlers1();
        Handeler hdlr = new Handeler(UIAppEventHandlers1.UIAppEvent_DialogBoxShowing_Handler);

        uicApp.DialogBoxShowing += hdlr;

    }

But i'm getting the "Cannot implicitly convert type 'TaskDialogEvent_01.Form1.Handeler' to 'System.EventHandler Autodesk.Revit.UI.Events.DialogBoxShowingEventArgs> " error. My 'UIAppEventHandlers1' method has the same signature as the Handler. What am I doing wrong and can anyone provide an example? Thank you.

4

1 回答 1

0

您可能想要使用您创建的 uaeh1 实例:

UIAppEventHandlers1 uaeh1 = new UIAppEventHandlers1();
uicApp.DialogBoxShowing += uaeh1.UIAppEvent_DialogBoxShowing_Handler;

这仍然很奇怪,因为您刚刚新建了该对象。

你说你不能像下面这样在应用类中注册/注销?

public Result OnStartup(UIControlledApplication app)
{
    app.DialogBoxShowing += OnDialogBoxShowing;
    return Result.Succeeded;
}

public Result OnShutdown(UIControlledApplication app)
{
    app.DialogBoxShowing -= OnDialogBoxShowing;
    return Result.Succeeded;
}

void OnDialogBoxShowing(object sender, DialogBoxShowingEventArgs args)
{
}

根据我的经验,使用 DialogBoxShowing 事件处理对话框并不是最好的方法。我建议研究更新的故障处理 API。

于 2012-06-05T16:36:00.370 回答