Exemple #1
0
        /// <summary>
        /// De-facto the command is here.
        /// </summary>
        /// <param name="uiapp"></param>
        public void ShowForm(UIApplication uiapp)
        {
            // get the isntance of Revit Thread
            // to pass it to the Windows Form later
            if (null == _hWndRevit)
            {
                Process process
                    = Process.GetCurrentProcess();

                IntPtr h = process.MainWindowHandle;
                _hWndRevit = new WindowHandle(h);
            }

            if (_presenter == null || _presenter.IsClosed)
            {
                //new handler
                RequestHandler handler = new RequestHandler();
                //new event
                ExternalEvent exEvent = ExternalEvent.Create(handler);
                // set current document
                _document = uiapp.ActiveUIDocument.Document;

                // Set the initial number of warnings so we don't detect document change on the first event
                _currentCount = uiapp.ActiveUIDocument.Document.GetWarnings().Count;

                _presenter = new WarningChartPresenter(uiapp, exEvent, handler);

                try
                {
                    //pass parent (Revit) thread here
                    _presenter.Show(_hWndRevit);
                }
                catch (Exception ex)
                {
                    TaskDialog.Show("Error", ex.Message);
                    _presenter.Dispose();
                    _presenter = null;
                }
            }
        }
Exemple #2
0
        public Result OnStartup(UIControlledApplication a)
        {
            ControlledApplication c_app = a.ControlledApplication;

            MyApplication = a;

            // Make sure you have to update the plugin
            string version = a.ControlledApplication.VersionNumber;

            AddRibbonPanel(a);

            _presenter = null;    // no dialog needed yet; ThermalAsset command will bring it
            thisApp    = this;    // static access to this application instance
            c_app.DocumentChanged // Document Changed event - whenever it changes, check for your stuff (in this app check if warnings number has changed)
                += new EventHandler <Autodesk.Revit.DB.Events.DocumentChangedEventArgs>(
                       c_app_DocumentChanged);

            a.ViewActivated += new EventHandler <Autodesk.Revit.UI.Events.ViewActivatedEventArgs>(OnViewActivated);


            return(Result.Succeeded);
        }