BuildingCoder.CmdWindowHandle.Execute C# (CSharp) Метод

Execute() публичный Метод

public Execute ( ExternalCommandData commandData, string &message, ElementSet elements ) : System.Result
commandData ExternalCommandData
message string
elements ElementSet
Результат System.Result
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            if( null == _hWndRevit )
              {
            //Process[] processes
            //  = Process.GetProcessesByName( "Revit" );

            //if( 0 < processes.Length )
            //{
            //  IntPtr h = processes[0].MainWindowHandle;
            //  _hWndRevit = new WindowHandle( h );
            //}

            Process process
              = Process.GetCurrentProcess();

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

              UIApplication app = commandData.Application;
              UIDocument uidoc = app.ActiveUIDocument;
              Document doc = uidoc.Document;

              Selection sel = uidoc.Selection;

              using( CmdWindowHandleForm f
            = new CmdWindowHandleForm() )
              {
            f.Show( _hWndRevit );
            bool go = true;
            while( go )
            {
              //SelElementSet ss = sel.Elements; // 2014
              //int n = ss.Size;
              ICollection<ElementId> ids = sel.GetElementIds(); // 2015
              int n = ids.Count;

              string s = string.Format(
            "{0} element{1} selected{2}",
            n, Util.PluralSuffix( n ),
            ((0 == n)
              ? ";\n" + _prompt
              : ":" ) );

              foreach( ElementId id in ids )
              {
            s += "\n";
            s += Util.ElementDescription(
              doc.GetElement( id ) );
              }
              f.LabelText = s;

            #if _2010
              sel.StatusbarTip = _prompt;
              go = sel.PickOne();
            #endif // _2010

              Reference r = uidoc.Selection.PickObject(
            ObjectType.Element, _prompt );

              go = null != r;

              Debug.Print( "go = " + go.ToString() );
            }
              }
              return Result.Failed;
        }
CmdWindowHandle