示例#1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="exEvent"></param>
 /// <param name="handler"></param>
 public Interface(UIApplication uiapp, Autodesk.Revit.UI.ExternalEvent exEvent, RequestHandler handler)
 {
     this.uiapp = uiapp;
     this.uidoc = uiapp.ActiveUIDocument;
     this.doc = uidoc.Document;
     this.exEvent = exEvent;
     this.handler = handler;
     this.famParam = new SortedList<string, FamilyParameter>();
     InitializeComponent();
     this.SetStyle(
         ControlStyles.AllPaintingInWmPaint |
         ControlStyles.UserPaint |
         ControlStyles.DoubleBuffer, true);
     this.StartPosition = FormStartPosition.Manual;
     this.Location = new System.Drawing.Point(Screen.PrimaryScreen.WorkingArea.Width - 400, Convert.ToInt32(Screen.PrimaryScreen.WorkingArea.Height * 0.5 - this.Height * 0.5));
     CollectData();
 }
示例#2
0
        /// <summary>
        /// Form closed event handler
        /// </summary>
        /// <param name="e"></param>
        protected override void OnFormClosed(FormClosedEventArgs e)
        {
            // we own both the event and the handler
            // we should dispose it before we are closed
            exEvent.Dispose();
            exEvent = null;
            handler = null;

            // do not forget to call the base class
            base.OnFormClosed(e);
        }
示例#3
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 (m_MyForm == null || m_MyForm.IsDisposed)
            {
                //new handler
                RequestHandler handler = new RequestHandler();
                //new event
                ExternalEvent exEvent = ExternalEvent.Create(handler);

                m_MyForm = new Interface(uiapp, exEvent, handler);
                //pass parent (Revit) thread here
                m_MyForm.Show(_hWndRevit);
            }
        }