/// <summary> /// When [HierarchicalBrowser] button is clicked /// </summary> /// <param name="Context"></param> /// <remarks></remarks> private void m_TreeViewBrowser_OnExecute(Inventor.NameValueMap Context) { Document oDoc = default(Document); oDoc = m_inventorApplication.ActiveDocument; BrowserPanes oPanes = default(BrowserPanes); oPanes = oDoc.BrowserPanes; //Create a standard Microsoft Windows IPictureDisp referencing an icon (.bmp) bitmap file. //Change the file referenced here as appropriate - here the code references test.bmp. //This is the icon that will be displayed at this node. Add the IPictureDisp to the client node resource. ClientNodeResources oRscs = oPanes.ClientNodeResources; stdole.IPictureDisp clientNodeIcon = AxHostConverter.ImageToPictureDisp(new Bitmap(@"Resources\test.bmp")); ClientNodeResource oRsc = oRscs.Add(m_ClientId, 1, clientNodeIcon); BrowserNodeDefinition oDef = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("Top Node", 3, oRsc); //adding a new pane tab to the panes collection, define the top node the pane will contain. Inventor.BrowserPane oPane = oPanes.AddTreeBrowserPane("My Pane", m_ClientId, oDef); //Add two child nodes to the tree, labeled Node 2 and Node 3. BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("Node2", 5, oRsc); BrowserNode oNode1 = oPane.TopNode.AddChild(oDef1); BrowserNodeDefinition oDef2 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("Node3", 6, oRsc); BrowserNode oNode2 = oPane.TopNode.AddChild(oDef2); //Add the native node (from root) of "Model" pane to the tree BrowserNode oNativeRootNode = default(BrowserNode); oNativeRootNode = oDoc.BrowserPanes["Model"].TopNode; oPane.TopNode.AddChild(oNativeRootNode.BrowserNodeDefinition); }
private void AddTreeBrowersPane() { IconPictureInitial(); Document oDoc = default(Document); oDoc = m_inventorApplication.ActiveDocument; BrowserPanes oPanes = default(BrowserPanes); oPanes = oDoc.BrowserPanes; System.IO.Stream oStream_Block = assembly.GetManifestResourceStream("ValveBlockDesign.resources.BlockStandard.ico"); System.Drawing.Icon oIcon_Block = new System.Drawing.Icon(oStream_Block); System.IO.Stream oStream_NET1 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET1.ico"); System.Drawing.Icon oIcon_NET1 = new System.Drawing.Icon(oStream_NET1); System.IO.Stream oStream_NET2 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET2.ico"); System.Drawing.Icon oIcon_NET2 = new System.Drawing.Icon(oStream_NET2); System.IO.Stream oStream_NET3 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET3.ico"); System.Drawing.Icon oIcon_NET3 = new System.Drawing.Icon(oStream_NET3); System.IO.Stream oStream_NET4 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET4.ico"); System.Drawing.Icon oIcon_NET4 = new System.Drawing.Icon(oStream_NET4); System.IO.Stream oStream_NET5 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET5.ico"); System.Drawing.Icon oIcon_NET5 = new System.Drawing.Icon(oStream_NET5); System.IO.Stream oStream_NET6 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET6.ico"); System.Drawing.Icon oIcon_NET6 = new System.Drawing.Icon(oStream_NET6); System.IO.Stream oStream_NET7 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET7.ico"); System.Drawing.Icon oIcon_NET7 = new System.Drawing.Icon(oStream_NET7); System.IO.Stream oStream_NET8 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET8.ico"); System.Drawing.Icon oIcon_NET8 = new System.Drawing.Icon(oStream_NET8); System.IO.Stream oStream_NET9 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET9.ico"); System.Drawing.Icon oIcon_NET9 = new System.Drawing.Icon(oStream_NET9); System.IO.Stream oStream_NET10 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET10.ico"); System.Drawing.Icon oIcon_NET10 = new System.Drawing.Icon(oStream_NET10); System.IO.Stream oStream_NET11 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET11.ico"); System.Drawing.Icon oIcon_NET11 = new System.Drawing.Icon(oStream_NET11); System.IO.Stream oStream_NET12 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET12.ico"); System.Drawing.Icon oIcon_NET12 = new System.Drawing.Icon(oStream_NET12); System.IO.Stream oStream_NET13 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET13.ico"); System.Drawing.Icon oIcon_NET13 = new System.Drawing.Icon(oStream_NET13); System.IO.Stream oStream_NET14 = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NET14.ico"); System.Drawing.Icon oIcon_NET14 = new System.Drawing.Icon(oStream_NET14); System.IO.Stream oStream_NULL = assembly.GetManifestResourceStream("ValveBlockDesign.resources.NULL.ico"); System.Drawing.Icon oIcon_NULL = new System.Drawing.Icon(oStream_NULL); System.IO.Stream oStream_Cavity = assembly.GetManifestResourceStream("ValveBlockDesign.resources.Cavity.ico"); System.Drawing.Icon oIcon_Cavity = new System.Drawing.Icon(oStream_Cavity); System.IO.Stream oStream_Footprint = assembly.GetManifestResourceStream("ValveBlockDesign.resources.Footprint.ico"); System.Drawing.Icon oIcon_Footprint = new System.Drawing.Icon(oStream_Footprint); //This is the icon that will be displayed at this node. Add the IPictureDisp to the client node resource. ClientNodeResources oRscs = oPanes.ClientNodeResources; stdole.IPictureDisp clientNodeIcon = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_Block.ToBitmap()); ClientNodeResource oRsc = oRscs.Add(m_ClientId, 1, clientNodeIcon); stdole.IPictureDisp clientNodeIcon1 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET1.ToBitmap()); ClientNodeResource oRsc1 = oRscs.Add(m_ClientId, 2, clientNodeIcon1); stdole.IPictureDisp clientNodeIcon2 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET2.ToBitmap()); ClientNodeResource oRsc2 = oRscs.Add(m_ClientId, 3, clientNodeIcon2); stdole.IPictureDisp clientNodeIcon3 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET3.ToBitmap()); ClientNodeResource oRsc3 = oRscs.Add(m_ClientId, 4, clientNodeIcon3); stdole.IPictureDisp clientNodeIcon4 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET4.ToBitmap()); ClientNodeResource oRsc4 = oRscs.Add(m_ClientId, 5, clientNodeIcon4); stdole.IPictureDisp clientNodeIcon5 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET5.ToBitmap()); ClientNodeResource oRsc5 = oRscs.Add(m_ClientId, 6, clientNodeIcon5); stdole.IPictureDisp clientNodeIcon6 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET6.ToBitmap()); ClientNodeResource oRsc6 = oRscs.Add(m_ClientId, 7, clientNodeIcon6); stdole.IPictureDisp clientNodeIcon7 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET7.ToBitmap()); ClientNodeResource oRsc7 = oRscs.Add(m_ClientId, 8, clientNodeIcon7); stdole.IPictureDisp clientNodeIcon8 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET8.ToBitmap()); ClientNodeResource oRsc8 = oRscs.Add(m_ClientId, 9, clientNodeIcon8); stdole.IPictureDisp clientNodeIcon9 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET9.ToBitmap()); ClientNodeResource oRsc9 = oRscs.Add(m_ClientId, 10, clientNodeIcon9); stdole.IPictureDisp clientNodeIcon10 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET10.ToBitmap()); ClientNodeResource oRsc10 = oRscs.Add(m_ClientId, 11, clientNodeIcon10); stdole.IPictureDisp clientNodeIcon11 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET11.ToBitmap()); ClientNodeResource oRsc11 = oRscs.Add(m_ClientId, 12, clientNodeIcon11); stdole.IPictureDisp clientNodeIcon12 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET12.ToBitmap()); ClientNodeResource oRsc12 = oRscs.Add(m_ClientId, 13, clientNodeIcon12); stdole.IPictureDisp clientNodeIcon13 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_Cavity.ToBitmap()); ClientNodeResource oRsc13 = oRscs.Add(m_ClientId, 14, clientNodeIcon13); stdole.IPictureDisp clientNodeIcon14 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_Footprint.ToBitmap()); ClientNodeResource oRsc14 = oRscs.Add(m_ClientId, 15, clientNodeIcon14); stdole.IPictureDisp clientNodeIcon15 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NULL.ToBitmap()); ClientNodeResource oRsc15 = oRscs.Add(m_ClientId, 16, clientNodeIcon15); stdole.IPictureDisp clientNodeIcon16 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET13.ToBitmap()); ClientNodeResource oRsc16 = oRscs.Add(m_ClientId, 17, clientNodeIcon16); stdole.IPictureDisp clientNodeIcon17 = ValveBlockDesign.StandardAddInServer.AxHostConverter.ImageToPictureDisp(oIcon_NET14.ToBitmap()); ClientNodeResource oRsc17 = oRscs.Add(m_ClientId, 18, clientNodeIcon17); BrowserNodeDefinition oDef = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("网络清单", 1, oRsc); Inventor.BrowserPane oPane = oPanes.AddTreeBrowserPane("油路", m_ClientId, oDef); Inventor.BrowserNode topNode = oPanes["油路"].TopNode; BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET1", 2, oRsc1); topNode.AddChild(oDef1); BrowserNodeDefinition oDef2 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET2", 3, oRsc2); topNode.AddChild(oDef2); BrowserNodeDefinition oDef3 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET3", 4, oRsc3); topNode.AddChild(oDef3); BrowserNodeDefinition oDef4 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET4", 5, oRsc4); topNode.AddChild(oDef4); BrowserNodeDefinition oDef5 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET5", 6, oRsc5); topNode.AddChild(oDef5); BrowserNodeDefinition oDef6 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET6", 7, oRsc6); topNode.AddChild(oDef6); BrowserNodeDefinition oDef7 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET7", 8, oRsc7); topNode.AddChild(oDef7); BrowserNodeDefinition oDef8 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET8", 9, oRsc8); topNode.AddChild(oDef8); BrowserNodeDefinition oDef9 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET9", 10, oRsc9); topNode.AddChild(oDef9); BrowserNodeDefinition oDef10 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET10", 11, oRsc10); topNode.AddChild(oDef10); BrowserNodeDefinition oDef11 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET11", 12, oRsc11); topNode.AddChild(oDef11); BrowserNodeDefinition oDef12 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET12", 13, oRsc12); topNode.AddChild(oDef12); BrowserNodeDefinition oDef13 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET13", 14, oRsc16); topNode.AddChild(oDef13); BrowserNodeDefinition oDef14 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NET14", 15, oRsc17); topNode.AddChild(oDef14); BrowserNodeDefinition oDef15 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition("NULLNET", 16, oRsc15); topNode.AddChild(oDef15); oPanes["油路"].Update(); oPanes["模型"].Activate(); }//创建浏览器节点