/// <summary> /// You typically register your panel class in your plug-in's OnLoad function. /// This informs Rhino of the existence of your panel class /// </summary> /// <param name="plugin">Plug-in this panel is associated with</param> /// <param name="panelType"> /// Class type to construct when a panel is shown. Currently only types /// that implement the IWin32Window interface are supported. The requirements /// for the class are that it has a parameterless constructor and have a /// GuidAttribute applied with a unique Guid /// </param> /// <param name="caption"></param> /// <param name="icon">Use a 32bit depth icon in order to get proper transparency</param> public static void RegisterPanel(Rhino.PlugIns.PlugIn plugin, Type panelType, string caption, System.Drawing.Icon icon) { if (!typeof(IWin32Window).IsAssignableFrom(panelType)) { throw new ArgumentException("panelType must implement IWin32Window interface", "panelType"); } System.Reflection.ConstructorInfo 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"); } object[] attr = panelType.GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false); if (attr.Length != 1) { throw new ArgumentException("panelType must have a GuidAttribute", "panelType"); } if (m_existing_panels == null) { m_existing_panels = new List <PanelData>(); } // make sure the type is not already registered for (int i = 0; i < m_existing_panels.Count; i++) { var pd = m_existing_panels[i]; if (pd != null && pd.PlugInId == plugin.Id && pd.PanelType == panelType) { return; } } PanelData panel_data = new PanelData(); panel_data.PlugInId = plugin.Id; panel_data.PanelType = panelType; m_existing_panels.Add(panel_data); m_create_panel_callback = OnCreatePanelCallback; m_visible_panel_callback = OnVisiblePanelCallback; UnsafeNativeMethods.RHC_RegisterTabbedDockBar(caption, panelType.GUID, plugin.Id, icon.Handle, m_create_panel_callback, m_visible_panel_callback); }
/// <summary> /// You typically register your panel class in your plug-in's OnLoad function. /// This informs Rhino of the existence of your panel class /// </summary> /// <param name="plugin">Plug-in this panel is associated with</param> /// <param name="panelType"> /// Class type to construct when a panel is shown. Currently only types /// that implement the IWin32Window interface are supported. The requirements /// for the class are that it has a parameterless constructor and have a /// GuidAttribute applied with a unique Guid /// </param> /// <param name="caption"></param> /// <param name="icon">Use a 32bit depth icon in order to get proper transparency</param> public static void RegisterPanel(Rhino.PlugIns.PlugIn plugin, Type panelType, string caption, System.Drawing.Icon icon) { if (!typeof(IWin32Window).IsAssignableFrom(panelType)) throw new ArgumentException("panelType must implement IWin32Window interface", "panelType"); System.Reflection.ConstructorInfo 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"); object[] attr = panelType.GetCustomAttributes(typeof(System.Runtime.InteropServices.GuidAttribute), false); if (attr.Length != 1) throw new ArgumentException("panelType must have a GuidAttribute", "panelType"); if (m_existing_panels == null) m_existing_panels = new List<PanelData>(); // make sure the type is not already registered for (int i = 0; i < m_existing_panels.Count; i++) { var pd = m_existing_panels[i]; if (pd != null && pd.PlugInId == plugin.Id && pd.PanelType == panelType) return; } PanelData panel_data = new PanelData(); panel_data.PlugInId = plugin.Id; panel_data.PanelType = panelType; m_existing_panels.Add(panel_data); m_create_panel_callback = OnCreatePanelCallback; m_visible_panel_callback = OnVisiblePanelCallback; UnsafeNativeMethods.RHC_RegisterTabbedDockBar(caption, panelType.GUID, plugin.Id, icon.Handle, m_create_panel_callback, m_visible_panel_callback); }