zoukankan      html  css  js  c++  java
  • skyline TEP学习心得(1):工程树ProjectTree操作两例

    环境TEP6.1,C#

    1.查找或创建组,查找不到则创建,返回ItemID

    第二个参数是查找的组的路径,格式为:A\B\C

            /// <summary>
            /// 查找或创建组(查找不到则创建)
            /// </summary>
            /// <param name="tSGWorld"></param>
            /// <param name="tGroupPath">查找路径,格式:A\B\C</param>
            /// <returns></returns>
            public static int FindAndCreateGroup(ISGWorld61 tSGWorld, string tGroupPath)
            {
                if (tGroupPath.EndsWith("\\") == false)
                {
                    tGroupPath += "\\";
                }
    
                int tItemID = tSGWorld.ProjectTree.FindItem(tGroupPath);
                if (tItemID == 0)
                {
                    string tParentPath = tGroupPath.Substring(0, tGroupPath.LastIndexOf("\\"));
                    string tGroupName = tParentPath.Substring(tParentPath.LastIndexOf("\\") + 1);
                    int tItemIDParent = 0;
    
                    if (tParentPath.IndexOf("\\") < 0)
                    {
                        return tSGWorld.ProjectTree.CreateGroup(tParentPath, 0);
                    }
                    else
                    {
                        tParentPath = tGroupPath.Substring(0, tParentPath.LastIndexOf("\\"));
    
                        tItemIDParent = FindAndCreateGroup(tSGWorld, tParentPath);
                    }
    
                    tItemID = tSGWorld.ProjectTree.CreateGroup(tGroupName, tItemIDParent);
                }
    
                return tItemID;
            }


    2.在ProjectTree中找指定名称的图层的Layer

    返回ILayer61对象

    当从根节点找起,第二个参数为0,第三个参数为要找的图层名

            /// <summary>
            /// 在ProjectTree中找指定名称的图层的Layer
            /// </summary>
            /// <param name="tSGWorld"></param>
            /// <param name="tParentItemID"></param>
            /// <param name="tLayerName"></param>
            /// <returns></returns>
            public static ILayer61 FindLayerInProjectTree(ISGWorld61 tSGWorld, int tParentItemID, string tLayerName)
            {
                if (string.IsNullOrEmpty(tLayerName)) return null;
    
                int tItemID = tSGWorld.ProjectTree.GetNextItem(tParentItemID, ItemCode.CHILD);
                if (tItemID == 0) return null;
                while (tItemID != 0)
                {
                    if (tSGWorld.ProjectTree.IsGroup(tItemID) == true)
                    {
                        if (tSGWorld.ProjectTree.IsLayer(tItemID) == true)
                        {
                            if (tSGWorld.ProjectTree.GetItemName(tItemID) == tLayerName)
                            {
                                return tSGWorld.ProjectTree.GetLayer(tItemID);
                            }
                        }
    
                        ILayer61 tLayer = FindLayerInProjectTree(tSGWorld, tItemID, tLayerName);
                        if (tLayer != null)
                        {
                            return tLayer;
                        }
    
                    }
                    else
                    {
                        if (tSGWorld.ProjectTree.IsLayer(tItemID) == true)
                        {
                            if (tSGWorld.ProjectTree.GetItemName(tItemID) == tLayerName)
                            {
                                return tSGWorld.ProjectTree.GetLayer(tItemID);
                            }
                        }
                    }
                    tItemID = tSGWorld.ProjectTree.GetNextItem(tItemID, ItemCode.NEXT);
    
                }
    
                return null;
            }
  • 相关阅读:
    2008年Web2.0峰会:发展是绝对的硬道理
    盖茨"接班人":微软产品为何总是挨批
    如何使用命令方式检测mx记录是否生效
    IBM公布未来5年将改变人类生活的五大科技
    谷歌李开复:我的传奇人生源于十句箴言
    VCL已死,RAD已死(3)
    VCL已死,RAD已死(2)
    主要程序设计语言范型综论与概要
    谷歌正式放弃与雅虎的广告合作计划
    模仿google分页代码
  • 原文地址:https://www.cnblogs.com/cannel/p/2608653.html
Copyright © 2011-2022 走看看