Esempio n. 1
0
 UnsafeNativeMethods.RhRdkCustomUiType RenderPanelTypeToRhRdkCustomUiType(RenderPanelType type)
 {
     switch (type)
     {
     case RenderPanelType.RenderWindow:
         return(UnsafeNativeMethods.RhRdkCustomUiType.RenderWindowCustomDlgInterface);
     }
     throw new Exception("Unknown RenderPanelTypeToRhRdkCustomUiType");
 }
Esempio n. 2
0
        /// <summary>
        /// Register custom render user interface with Rhino.  This should only be
        /// done in <see cref="RenderPlugIn.RegisterRenderPanels"/>.  Panels
        /// registered after <see cref="RenderPlugIn.RegisterRenderPanels"/> is called
        /// will be ignored.
        /// </summary>
        /// <param name="plugin">
        /// The plug-in providing the custom user interface
        /// </param>
        /// <param name="renderPanelType">
        /// See <see cref="RenderPanelType"/> for supported user interface types.
        /// </param>
        /// <param name="panelType">
        /// The type of object to be created and added to the render container.
        /// </param>
        /// <param name="caption">
        /// The caption for the custom user interface.
        /// </param>
        /// <param name="alwaysShow">
        /// If true the custom user interface will always be visible, if false then
        /// it may be hidden or shown as requested by the user.
        /// </param>
        /// <param name="initialShow">
        /// Initial visibility state of the custom user interface control.
        /// </param>
        public void RegisterPanel(PlugIn plugin, RenderPanelType renderPanelType, Type panelType, string caption, bool alwaysShow, bool initialShow)
        {
            if (!typeof(IWin32Window).IsAssignableFrom(panelType))
            {
                throw new ArgumentException("panelType must implement IWin32Window interface", "panelType");
            }
            var constructor = panelType.GetConstructor(System.Type.EmptyTypes);

            if (!panelType.IsPublic || constructor == null)
            {
                throw new ArgumentException("panelType must be a public class and have a parameterless constructor", "panelType");
            }
            var attr = panelType.GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false);

            if (attr.Length != 1)
            {
                throw new ArgumentException("panelType must have a GuidAttribute", "panelType");
            }

            if (g_existing_panels == null)
            {
                g_existing_panels = new List <RenderPanelData>();
            }
            // make sure the type is not already registered
            for (var i = 0; i < g_existing_panels.Count; i++)
            {
                var pd = g_existing_panels[i];
                if (pd != null && pd.PlugInId == plugin.Id && pd.PanelType == panelType)
                {
                    return;
                }
            }
            var panel_data = new RenderPanelData {
                PlugInId = plugin.Id, PanelType = panelType, RenderPanelType = renderPanelType
            };

            g_existing_panels.Add(panel_data);


            g_create_panel_callback  = OnCreatePanelCallback;
            g_visible_panel_callback = OnVisiblePanelCallback;
            g_destroy_panel_callback = OnDestroyPanelCallback;

            var render_panel_type = RenderPanelTypeToRhRdkCustomUiType(renderPanelType);

            UnsafeNativeMethods.CRhCmnRdkRenderPlugIn_RegisterCustomPlugInUi(
                render_panel_type,
                caption,
                panelType.GUID,
                plugin.Id,
                alwaysShow,
                initialShow,
                g_create_panel_callback,
                g_visible_panel_callback,
                g_destroy_panel_callback);
        }
Esempio n. 3
0
 UnsafeNativeMethods.RhRdkCustomUiType RenderPanelTypeToRhRdkCustomUiType(RenderPanelType type)
 {
   switch (type)
   {
     case RenderPanelType.RenderWindow:
       return UnsafeNativeMethods.RhRdkCustomUiType.RenderWindowCustomDlgInterface;
   }
   throw new Exception("Unknown RenderPanelTypeToRhRdkCustomUiType");
 }
Esempio n. 4
0
    /// <summary>
    /// Register custom render user interface with Rhino.  This should only be
    /// done in <see cref="RenderPlugIn.RegisterRenderPanels"/>.  Panels
    /// registered after <see cref="RenderPlugIn.RegisterRenderPanels"/> is called
    /// will be ignored.
    /// </summary>
    /// <param name="plugin">
    /// The plug-in providing the custom user interface
    /// </param>
    /// <param name="renderPanelType">
    /// See <see cref="RenderPanelType"/> for supported user interface types.
    /// </param>
    /// <param name="panelType">
    /// The type of object to be created and added to the render container.
    /// </param>
    /// <param name="caption">
    /// The caption for the custom user interface.
    /// </param>
    /// <param name="alwaysShow">
    /// If true the custom user interface will always be visible, if false then
    /// it may be hidden or shown as requested by the user.
    /// </param>
    /// <param name="initialShow">
    /// Initial visibility state of the custom user interface control.
    /// </param>
    public void RegisterPanel(PlugIn plugin, RenderPanelType renderPanelType, Type panelType, string caption, bool alwaysShow, bool initialShow)
    {
      if (!typeof(IWin32Window).IsAssignableFrom(panelType))
        throw new ArgumentException("panelType must implement IWin32Window interface", "panelType");
      var constructor = panelType.GetConstructor(System.Type.EmptyTypes);
      if (!panelType.IsPublic || constructor == null)
        throw new ArgumentException("panelType must be a public class and have a parameterless constructor", "panelType");
      var attr = panelType.GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false);
      if (attr.Length != 1)
        throw new ArgumentException("panelType must have a GuidAttribute", "panelType");

      if (g_existing_panels == null)
        g_existing_panels = new List<RenderPanelData>();
      // make sure the type is not already registered
      for (var i = 0; i < g_existing_panels.Count; i++)
      {
        var pd = g_existing_panels[i];
        if (pd != null && pd.PlugInId == plugin.Id && pd.PanelType == panelType)
          return;
      }
      var panel_data = new RenderPanelData { PlugInId = plugin.Id, PanelType = panelType, RenderPanelType = renderPanelType };
      g_existing_panels.Add(panel_data);


      g_create_panel_callback = OnCreatePanelCallback;
      g_visible_panel_callback = OnVisiblePanelCallback;
      g_destroy_panel_callback = OnDestroyPanelCallback;

      var render_panel_type = RenderPanelTypeToRhRdkCustomUiType(renderPanelType);

      UnsafeNativeMethods.CRhCmnRdkRenderPlugIn_RegisterCustomPlugInUi(
        render_panel_type,
        caption,
        panelType.GUID, 
        plugin.Id,
        alwaysShow,
        initialShow,
        g_create_panel_callback,
        g_visible_panel_callback,
        g_destroy_panel_callback);
    }