This class is implemented to make sample autotest. It checks whether the external file exists or not. The sample can control the UI's display by this judgement. It can dump the seleted event list to file or commandData.Data and also can retrieve the list from file and commandData.Data.
        /// <summary>
        /// Implement this method to implement the external application which should be called when
        /// Revit starts before a file or default template is actually loaded.
        /// </summary>
        /// <param name="application">An object that is passed to the external application
        /// which contains the controlled application.</param>
        /// <returns>Return the status of the external application.
        /// A result of Succeeded means that the external application successfully started.
        /// Cancelled can be used to signify that the user cancelled the external operation at
        /// some point.
        /// If false is returned then Revit should inform the user that the external application
        /// failed to load and the release the internal reference.</returns>
        public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)
        {
            // initialize member variables.
            m_ctrlApp            = application;
            m_logManager         = new LogManager();
            m_infWindows         = new EventsInfoWindows(m_logManager);
            m_settingDialog      = new EventsSettingForm();
            m_appEventsSelection = new List <string>();
            m_appEventMgr        = new EventManager(m_ctrlApp);

#if !(Debug || DEBUG)
            m_journalProcessor = new JournalProcessor();
#endif

            try
            {
#if !(Debug || DEBUG)
                // playing journal.
                if (m_journalProcessor.IsReplay)
                {
                    m_appEventsSelection = m_journalProcessor.EventsList;
                }

                // running the sample form UI.
                else
                {
#endif
                m_settingDialog.ShowDialog();
                if (DialogResult.OK == m_settingDialog.DialogResult)
                {
                    //get what user select.
                    m_appEventsSelection = m_settingDialog.AppSelectionList;
                }

#if !(Debug || DEBUG)
                // dump what user select to a file in order to autotesting.
                m_journalProcessor.DumpEventsListToFile(m_appEventsSelection);
            }
#endif

                // update the events according to the selection.
                m_appEventMgr.Update(m_appEventsSelection);

                // track the selected events by showing the information in the information windows.
                m_infWindows.Show();

                // add menu item in Revit menu bar to provide an approach to
                // retrieve events setting form. User can change his choices
                // by calling the setting form again.
                AddCustomPanel(application);
            }
            catch (Exception)
            {
                return(Autodesk.Revit.UI.Result.Failed);
            }

            return(Autodesk.Revit.UI.Result.Succeeded);
        }
Beispiel #2
0
        /// <summary>
        /// Implement this method to implement the external application which should be called when 
        /// Revit starts before a file or default template is actually loaded.
        /// </summary>
        /// <param name="application">An object that is passed to the external application 
        /// which contains the controlled application.</param> 
        /// <returns>Return the status of the external application. 
        /// A result of Succeeded means that the external application successfully started. 
        /// Cancelled can be used to signify that the user cancelled the external operation at 
        /// some point.
        /// If false is returned then Revit should inform the user that the external application 
        /// failed to load and the release the internal reference.</returns>
        public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application)
        {
            // initialize member variables.
            m_ctrlApp = application;
            m_logManager = new LogManager();
            m_infWindows = new EventsInfoWindows(m_logManager);
            m_settingDialog = new EventsSettingForm();
            m_appEventsSelection = new List<string>();
            m_appEventMgr = new EventManager(m_ctrlApp);

            #if !(Debug || DEBUG)
            m_journalProcessor = new JournalProcessor();
            #endif

            try
            {
            #if !(Debug || DEBUG)
                // playing journal.
                if (m_journalProcessor.IsReplay)
                {
                    m_appEventsSelection = m_journalProcessor.EventsList;
                }

                // running the sample form UI.
                else
                {
            #endif
                    m_settingDialog.ShowDialog();
                    if (DialogResult.OK == m_settingDialog.DialogResult)
                    {
                        //get what user select.
                        m_appEventsSelection = m_settingDialog.AppSelectionList;
                    }

            #if !(Debug || DEBUG)
                    // dump what user select to a file in order to autotesting.
                    m_journalProcessor.DumpEventsListToFile(m_appEventsSelection);
                }
            #endif

                // update the events according to the selection.
                m_appEventMgr.Update(m_appEventsSelection);

                // track the selected events by showing the information in the information windows.
                m_infWindows.Show();

                // add menu item in Revit menu bar to provide an approach to
                // retrieve events setting form. User can change his choices
                // by calling the setting form again.
                AddCustomPanel(application);
            }
            catch (Exception)
            {
                return Autodesk.Revit.UI.Result.Failed;
            }

            return Autodesk.Revit.UI.Result.Succeeded;
        }