Ejemplo n.º 1
0
        internal static Result OnStartup(UIControlledApplication applicationUI)
        {
            if (MainWindow.IsZero)
            {
                var result = Addin.CheckSetup(applicationUI.ControlledApplication);
                if (result != Result.Succeeded)
                {
                    return(result);
                }

#if REVIT_2019
                MainWindow = new WindowHandle(applicationUI.MainWindowHandle);
#else
                MainWindow = new WindowHandle(Process.GetCurrentProcess().MainWindowHandle);
#endif

                result = Rhinoceros.Startup();
                if (result != Result.Succeeded)
                {
                    MainWindow = WindowHandle.Zero;
                    return(result);
                }

                // Register some events
                applicationUI.Idling += OnIdle;
                applicationUI.ControlledApplication.DocumentChanged += OnDocumentChanged;

                Addin.CurrentStatus = Addin.Status.Ready;
            }

            return(Result.Succeeded);
        }
Ejemplo n.º 2
0
        internal static Result OnStartup(UIControlledApplication applicationUI)
        {
            if (MainWindow.IsZero)
            {
                var result = Addin.CheckSetup(applicationUI);
                if (result != Result.Succeeded)
                {
                    return(result);
                }

#if REVIT_2019
                MainWindow = new WindowHandle(applicationUI.MainWindowHandle);
#else
                MainWindow = new WindowHandle(Process.GetCurrentProcess().MainWindowHandle);
#endif

                // Save Revit window status
                bool wasEnabled   = MainWindow.Enabled;
                var  activeWindow = WindowHandle.ActiveWindow ?? MainWindow;

                try
                {
                    // Disable Revit window
                    MainWindow.Enabled = false;

                    result = Rhinoceros.Startup();
                }
                finally
                {
                    //Enable Revit window back
                    MainWindow.Enabled        = wasEnabled;
                    WindowHandle.ActiveWindow = activeWindow;
                }

                if (result != Result.Succeeded)
                {
                    MainWindow = WindowHandle.Zero;
                    return(result);
                }

                // Register some events
                applicationUI.Idling += OnIdle;
                applicationUI.ControlledApplication.DocumentChanged += OnDocumentChanged;

                Addin.CurrentStatus = Addin.Status.Ready;
            }

            return(Result.Succeeded);
        }
Ejemplo n.º 3
0
        internal static Result OnShutdown(UIControlledApplication applicationUI)
        {
            if (MainWindowHandle != IntPtr.Zero)
            {
                // Unregister some events
                applicationUI.ControlledApplication.DocumentChanged -= OnDocumentChanged;
                applicationUI.Idling -= OnIdle;

                Rhinoceros.Shutdown();

                MainWindowHandle = IntPtr.Zero;
            }

            return(Result.Succeeded);
        }
Ejemplo n.º 4
0
        internal static Result OnStartup(UIControlledApplication applicationUI)
        {
            if (MainWindowHandle == IntPtr.Zero)
            {
#if REVIT_2019
                MainWindowHandle = applicationUI.MainWindowHandle;
#else
                MainWindowHandle = Process.GetCurrentProcess().MainWindowHandle;
#endif

                var result = Rhinoceros.Startup();
                if (result != Result.Succeeded)
                {
                    MainWindowHandle = IntPtr.Zero;
                    return(result);
                }

                // Register some events
                applicationUI.Idling += OnIdle;
                applicationUI.ControlledApplication.DocumentChanged += OnDocumentChanged;
            }

            return(Result.Succeeded);
        }