Inheritance: IWin32Window
Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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);
        }