public Result OnStartup(UIControlledApplication application) { documentLoaded = false; try { process = Process.GetCurrentProcess(); handle = process.MainWindowHandle; revitWindowHandle = new RevitWindowHandle(handle); uiCtrlApp = application; app = uiCtrlApp.ControlledApplication; app.DocumentOpened += ((object o, DocumentOpenedEventArgs e) => { UpdateDocument(e.Document); documentLoaded = true; ShowDialog(); }); app.DocumentClosed += ((object o, DocumentClosedEventArgs e) => { documentLoaded = false; }); uiCtrlApp.ViewActivated += ((object o, ViewActivatedEventArgs e) => { if (documentLoaded) { UpdateActiveView(e); ShowDialog(); } }); } catch (Exception) { return Result.Failed; } return Result.Succeeded; }
public Result OnStartup(UIControlledApplication application) { documentLoaded = false; try { process = Process.GetCurrentProcess(); handle = process.MainWindowHandle; revitWindowHandle = new RevitWindowHandle(handle); uiCtrlApp = application; app = uiCtrlApp.ControlledApplication; app.DocumentOpened += ((object o, DocumentOpenedEventArgs e) => { UpdateDocument(e.Document); documentLoaded = true; ShowDialog(); }); app.DocumentClosed += ((object o, DocumentClosedEventArgs e) => { documentLoaded = false; }); uiCtrlApp.ViewActivated += ((object o, ViewActivatedEventArgs e) => { if (documentLoaded) { UpdateActiveView(e); ShowDialog(); } }); } catch (Exception) { return(Result.Failed); } return(Result.Succeeded); }