protected override void OnFormClosed(FormClosedEventArgs e)
        {
            // we own both the event and the handler
            // we should dispose it before we are closed
            m_ExEvent.Dispose();
            m_ExEvent = null;
            m_Handler = null;

            // do not forget to call the base class
            base.OnFormClosed(e);
        }
        protected override void OnFormClosed(FormClosedEventArgs e)
        {
            // we own both the event and the handler
            // we should dispose it before we are closed
            m_ExEvent.Dispose();
            m_ExEvent = null;
            m_Handler = null;

            // do not forget to call the base class
            base.OnFormClosed(e);
        }
 public Result Execute(
   ExternalCommandData commandData,
   ref string message,
   ElementSet elements)
 {
     try
     {
         ExternalEventExample handler = new ExternalEventExample();
         ExternalEvent exEvent = ExternalEvent.Create(handler);
         ExternalEventExampleDialog m_MyForm = new ExternalEventExampleDialog(exEvent, handler);
         m_MyForm.Show();
     }
     // Catch any Exceptions and display them.
     catch (Autodesk.Revit.Exceptions.OperationCanceledException)
     {
         return Result.Cancelled;
     }
     catch (Exception x)
     {
         message = x.Message;
         return Result.Failed;
     }
     return Result.Succeeded;
 }
 public Result Execute(
     ExternalCommandData commandData,
     ref string message,
     ElementSet elements)
 {
     try
     {
         ExternalEventExample       handler  = new ExternalEventExample();
         ExternalEvent              exEvent  = ExternalEvent.Create(handler);
         ExternalEventExampleDialog m_MyForm = new ExternalEventExampleDialog(exEvent, handler);
         m_MyForm.Show();
     }
     // Catch any Exceptions and display them.
     catch (Autodesk.Revit.Exceptions.OperationCanceledException)
     {
         return(Result.Cancelled);
     }
     catch (Exception x)
     {
         message = x.Message;
         return(Result.Failed);
     }
     return(Result.Succeeded);
 }
 public ExternalEventExampleDialog(ExternalEvent exEvent, ExternalEventExample handler)
 {
     InitializeComponent();
     m_ExEvent = exEvent;
     m_Handler = handler;
 }
 public ExternalEventExampleDialog(ExternalEvent exEvent, ExternalEventExample handler)
 {
     InitializeComponent();
     m_ExEvent = exEvent;
     m_Handler = handler;
 }