예제 #1
0
        private void getParentLayerNames(ILayer lyr)
        {
            foreach (ILayer grpLyr in groupLayerList)
            {
//				Zuerst Cast nach GroupLayer, erst dann nach ICompositeLayer
                IGroupLayer     grpLyr2 = (IGroupLayer)grpLyr;
                ICompositeLayer cmpLyr  = (ICompositeLayer)grpLyr2;
                for (int cmpLyrIndex = 0; cmpLyrIndex < cmpLyr.Count; cmpLyrIndex++)
                {
                    ILayer childLyr = cmpLyr.get_Layer(cmpLyrIndex);
                    if (childLyr.Equals(lyr))
                    {
                        this.parent = "/" + grpLyr.Name + this.parent;
                        getParentLayerNames(grpLyr);
                    }
                }
            }
        }
예제 #2
0
        public static void DealOrderOfNewLayer(ESRI.ArcGIS.Controls.IMapControlDefault pMapcontrol, ILayer pLayer)
        {
            int    intOrderID    = -1;
            int    intDataTypeID = -1;//为不同的数据类型分配不同的整数,用来排序
            string strOrderID    = GetOrderIDofLayer(pLayer);

            intDataTypeID = GetDataTypeIDofLayer(pLayer);
            if (!strOrderID.Equals(""))
            {
                intOrderID = int.Parse(strOrderID);
            }

            if (pLayer is IGroupLayer)
            {
                LayersComposeEx(pMapcontrol.Map, pLayer as IGroupLayer);
            }
            int IndexOfNewLayer = -1;

            for (int i = 0; i < pMapcontrol.Map.LayerCount; i++)
            {
                ILayer pTmpLayer = pMapcontrol.Map.get_Layer(i);
                if (pTmpLayer.Equals(pLayer))
                {
                    if ((pTmpLayer as ILayerGeneralProperties).LayerDescription == (pLayer as ILayerGeneralProperties).LayerDescription)
                    {
                        IndexOfNewLayer = i;
                        break;
                    }
                }
            }
            for (int i = 0; i < pMapcontrol.Map.LayerCount; i++)
            {
                ILayer pCurLayer     = pMapcontrol.Map.get_Layer(i);
                string strCurOrderID = GetOrderIDofLayer(pCurLayer);
                int    intCurOrderID = -1;
                if (!strCurOrderID.Equals(""))
                {
                    intCurOrderID = int.Parse(strCurOrderID);
                }
                if (intOrderID > 0 && intCurOrderID > 0)
                {
                    if (intOrderID < intCurOrderID)
                    {
                        if (IndexOfNewLayer > i)
                        {
                            pMapcontrol.Map.MoveLayer(pLayer, i);
                            IndexOfNewLayer = i;
                            break;
                        }
                    }
                    else if (intOrderID > intCurOrderID)
                    {
                        if (IndexOfNewLayer < i)
                        {
                            pMapcontrol.Map.MoveLayer(pLayer, i);
                            IndexOfNewLayer = i;
                        }
                    }
                }
                else
                {
                    int intCurDataTypeID = GetDataTypeIDofLayer(pCurLayer);
                    if (intDataTypeID < intCurDataTypeID)
                    {
                        if (IndexOfNewLayer > i)
                        {
                            pMapcontrol.Map.MoveLayer(pLayer, i);
                            IndexOfNewLayer = i;
                            break;
                        }
                    }
                    else if (intDataTypeID > intCurDataTypeID)
                    {
                        if (IndexOfNewLayer < i)
                        {
                            pMapcontrol.Map.MoveLayer(pLayer, i);
                            IndexOfNewLayer = i;
                        }
                    }
                }
            }
        }