private void AddTreePortName(string NetName, int number, int NetNumber)
        {
            Document oDoc = default(Document);

            oDoc = m_inventorApplication.ActiveDocument;

            BrowserPanes oPanes = default(BrowserPanes);

            oPanes = oDoc.BrowserPanes;

            ClientNodeResources oRscs = oPanes.ClientNodeResources;
            //单一孔特征的图标显示
            ClientNodeResource    oRsc  = oRscs.ItemById(m_ClientId, 14);
            BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(NetName, number, oRsc);

            Inventor.BrowserNode node = oPanes["油路"].TopNode.BrowserNodes[NetNumber];
            node.AddChild(oDef1);
        }
        //-----------------------------------------------------------------------------------
        //从项目数据库加载油路信息
        private void AddNetInformationFrommdb()
        {
            Document oDoc = default(Document);

            oDoc = m_inventorApplication.ActiveDocument;

            BrowserPanes oPanes = default(BrowserPanes);

            oPanes = oDoc.BrowserPanes;
            int delete = 15;
            ClientBrowserNodeDefinition deleteoDef = oPanes.GetClientBrowserNodeDefinition(m_ClientId, delete);

            while (deleteoDef != null)
            {
                deleteoDef.Delete();
                delete++;
                deleteoDef = oPanes.GetClientBrowserNodeDefinition(m_ClientId, delete);
            }

            ClientNodeResources oRscs = oPanes.ClientNodeResources;
            ClientNodeResource  oRsc  = oRscs.ItemById(m_ClientId, 14);

            string[] getresult = new string[25];
            m_connectToaccess = new ConnectToAccess(deFaultpath + "\\CavityLibrary", "项目数据库");
            string sql    = @"select * from NETList";
            int    number = 15;

            #region
            m_connectToaccess.GetInformation(sql, "NET1", out getresult);
            int i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[1];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET2", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[2];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET3", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[3];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET4", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[4];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET5", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[5];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET6", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[6];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET7", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[7];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET8", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[8];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET9", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[9];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET10", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[10];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET11", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[11];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NET12", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[12];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }

            m_connectToaccess.GetInformation(sql, "NULLNET", out getresult);
            i = 0;
            while (getresult[i] != null)
            {
                if (getresult[i].ToString().Length > 0)
                {
                    BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(getresult[i], number, oRsc);
                    Inventor.BrowserNode  node  = oPanes["油路"].TopNode.BrowserNodes[13];
                    node.AddChild(oDef1);
                    number++;
                }
                i++;
            }
            #endregion//加载油孔网络信息
            foreach (Inventor.BrowserNode node in oPanes["油路"].TopNode.BrowserNodes)
            {
                if (node.BrowserNodes.Count == 0)
                {
                    node.Visible = false;
                }
            }
            oPanes["油路"].Update();
            oPanes["油路"].Activate();
        }
        private void  AddTreeBrowerNode(ClientNodeResources oRscs, string NetName, int number)
        {
            ClientNodeResource oRsc;

            switch (NetName)
            {
            case "NET1":
                oRsc = oRscs.ItemById(m_ClientId, 2);
                break;

            case "NET2":
                oRsc = oRscs.ItemById(m_ClientId, 3);
                break;

            case "NET3":
                oRsc = oRscs.ItemById(m_ClientId, 4);
                break;

            case "NET4":
                oRsc = oRscs.ItemById(m_ClientId, 5);
                break;

            case "NET5":
                oRsc = oRscs.ItemById(m_ClientId, 6);
                break;

            case "NET6":
                oRsc = oRscs.ItemById(m_ClientId, 7);
                break;

            case "NET7":
                oRsc = oRscs.ItemById(m_ClientId, 8);
                break;

            case "NET8":
                oRsc = oRscs.ItemById(m_ClientId, 9);
                break;

            case "NET9":
                oRsc = oRscs.ItemById(m_ClientId, 10);
                break;

            case "NET10":
                oRsc = oRscs.ItemById(m_ClientId, 11);
                break;

            case "NET11":
                oRsc = oRscs.ItemById(m_ClientId, 12);
                break;

            case "NET12":
                oRsc = oRscs.ItemById(m_ClientId, 13);
                break;

            default:
                oRsc = oRscs.ItemById(m_ClientId, 3);
                break;
            }

            Document oDoc = default(Document);

            oDoc = m_inventorApplication.ActiveDocument;

            BrowserPanes oPanes = default(BrowserPanes);

            oPanes = oDoc.BrowserPanes;
            BrowserNodeDefinition oDef1 = (BrowserNodeDefinition)oPanes.CreateBrowserNodeDefinition(NetName, number, oRsc);

            Inventor.BrowserNode topNode = oPanes["油路"].TopNode;
            topNode.AddChild(oDef1);
        }
Esempio n. 4
0
        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();
        }//创建浏览器节点