//De-facto the command is here. Will either be started on start (duh) or activated when switched back to a Family Document
        public bool ShowForm()
        {
            GetRevitHandle();

            _presenter = null;
            if (_presenter == null || _presenter._isClosed)
            {
                try
                {
                    if (!Application.App.ActiveUIDocument.Document.IsFamilyDocument)
                    {
                        DialogUtils.Alert("Error", "Usable only in Family Documents");
                        return(false);
                    }

                    handler = new RequestHandler();                         //new handler
                    exEvent = ExternalEvent.Create(handler);                //new event

                    _document  = Application.App.ActiveUIDocument.Document; //set current document
                    _presenter = new FamilyParameterViewModel(_document);

                    _presenter.Show(_hWndRevit);    //pass parent (Revit) thread here
                    _presenter.PresenterClosed += Stop;
                }
                catch (Exception ex)
                {
                    TaskDialog.Show("Error", ex.Message);
                    _presenter.Dispose();
                    _presenter = null;
                    return(false);
                }
            }
            return(true);
        }
 //On DocumentClosed
 internal void DocumentClosed()
 {
     if (Application.App.ActiveUIDocument == null && Application.Started && _presenter != null)
     {
         _presenter.Close();
         _presenter = null;
     }
 }
Пример #3
0
 private void c_app_DocumentClosed(object sender, DocumentClosedEventArgs e)
 {
     if (!Started)
     {
         return;            // only do if the plugin is active
     }
     if (App.ActiveUIDocument == null && Started && _presenter != null)
     {
         _presenter.Close();
         _presenter = null;
     }
 }
Пример #4
0
        /// <summary>
        /// De-facto the command is here.
        /// </summary>
        /// <param name="uiapp"></param>
        public void ShowForm()
        {
            _presenter = null;

            // 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)
            {
                try
                {
                    if (!App.ActiveUIDocument.Document.IsFamilyDocument)
                    {
                        TaskDialog.Show("Error", "Usable only in Family Documents");
                        return;
                    }
                    //new handler
                    handler = new RequestHandler();
                    //new event
                    exEvent = ExternalEvent.Create(handler);
                    // set current document

                    _document  = App.ActiveUIDocument.Document;
                    _presenter = new FamilyParameterViewModel(_document);

                    //pass parent (Revit) thread here
                    _presenter.Show(_hWndRevit);
                    _presenter.PresenterClosed += Stop;
                }
                catch (Exception ex)
                {
                    TaskDialog.Show("Error", ex.Message);
                    _presenter.Dispose();
                    _presenter = null;
                }
            }
        }