Exemplo n.º 1
0
        /// <summary>
        /// Assign the add-in help file to the
        /// given ribbon push button contextual help.
        /// This method checks for Revit 2013 at runtime
        /// and uses .NET Reflection to access the
        /// ContextualHelp class and SetContextualHelp
        /// method which are not available in the
        /// Revit 2012 API.
        /// </summary>
        void AddContextualHelp(PushButtonData d, int i)
        {
            // This is the normal code uses
            // when directly referencing the
            // Revit 2013 API assemblies:
            //
            //ContextualHelp ch = new ContextualHelp(
            //  ContextualHelpType.ChmFile, helppath );
            //
            //d.SetContextualHelp( ch );

            // Invoke constructor:

            ConstructorInfo[] ctors
                = _contextual_help_type.GetConstructors();

            const int contextualHelpType_ChmFile = 3;

            object instance = ctors[0].Invoke(
                new object[] {
                contextualHelpType_ChmFile,
                HelpPath
            });       // + "#" + i.ToString()

            // Set the help topic URL

            PropertyInfo property = _contextual_help_type
                                    .GetProperty("HelpTopicUrl");

            property.SetValue(instance, i.ToString(), null);

            // Invoke SetContextualHelp method:

            Type pbdType = d.GetType();

            MethodInfo method = pbdType.GetMethod(
                "SetContextualHelp");

            method.Invoke(d, new object[] { instance });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Assign the add-in help file to the 
        /// given ribbon push button contextual help.
        /// This method checks for Revit 2013 at runtime
        /// and uses .NET Reflection to access the 
        /// ContextualHelp class and SetContextualHelp
        /// method which are not available in the 
        /// Revit 2012 API.
        /// </summary>
        void AddContextualHelp( PushButtonData d, int i )
        {
            // This is the normal code uses
              // when directly referencing the
              // Revit 2013 API assemblies:
              //
              //ContextualHelp ch = new ContextualHelp(
              //  ContextualHelpType.ChmFile, helppath );
              //
              //d.SetContextualHelp( ch );

              // Invoke constructor:

              ConstructorInfo[] ctors
            = _contextual_help_type.GetConstructors();

              const int contextualHelpType_ChmFile = 3;

              object instance = ctors[0].Invoke(
            new object[] {
            contextualHelpType_ChmFile,
            HelpPath } ); // + "#" + i.ToString()

              // Set the help topic URL

              PropertyInfo property = _contextual_help_type
            .GetProperty( "HelpTopicUrl" );

              property.SetValue( instance, i.ToString(), null );

              // Invoke SetContextualHelp method:

              Type pbdType = d.GetType();

              MethodInfo method = pbdType.GetMethod(
            "SetContextualHelp" );

              method.Invoke( d, new object[] { instance } );
        }