コード例 #1
0
ファイル: NDlabObject.cs プロジェクト: 741645596/Lab
    /// <summary>
    /// 设置元器件新的深度值,这常常是点选元器件后需要将其置顶
    /// </summary>
    public void SetTopDepth()
    {
        //如果当前没有两个及其以上对象,则不需要设置深度
        if (g_Depth.Count < 2)
        {
            return;
        }
        //如果是最高那个,则不需要设置深度
        int topMostDepth = FindTopMostDepth();

        if (topMostDepth >= m_iDepth)
        {
            return;
        }
        int index = FindIndex(ID);

        if (index == -1)//如果未找到当前组件,则报出异常
        {
            return;
        }
        int startIndex = MinDepth;

        for (int i = 0; i < g_Depth.Count; i++)//设置其他元器件深度
        {
            DepthData item = g_Depth[i];
            if (item.ID == ID)
            {
                startIndex++;
                continue;
            }
            NDlabObject obj = FindLabObject(item.ID);
            if (obj != null)
            {
                obj.SetDepth(startIndex - i);
            }
        }
        SetDepth(topMostDepth);//设置自身置顶深度
    }