BuildingCoder.CmdElevationWatcher.Execute C# (CSharp) Method

Execute() public method

public Execute ( ExternalCommandData commandData, string &message, ElementSet elements ) : System.Result
commandData ExternalCommandData
message string
elements ElementSet
return System.Result
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
              Application app = uiapp.Application;

              if( null == _handler )
              {
            _handler
              = new EventHandler<DocumentChangedEventArgs>(
            OnDocumentChanged );

            // Subscribe to DocumentChanged event

            app.DocumentChanged += _handler;
              }
              else
              {
            app.DocumentChanged -= _handler;
            _handler = null;
              }
              return Result.Succeeded;
        }