private bool GetFabricSubLayers(IMap Map, esriCadastralFabricTable FabricSubClass, bool ExcludeNonTargetFabrics, ICadastralFabric TargetFabric, out IArray CFParcelFabSubLayers) { ICadastralFabricSubLayer pCFSubLyr = null; IArray CFParcelFabricSubLayers2 = new ArrayClass(); IFeatureLayer pParcelFabricSubLayer = null; UID pId = new UIDClass(); pId.Value = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"; IEnumLayer pEnumLayer = Map.get_Layers(pId, true); pEnumLayer.Reset(); ILayer pLayer = pEnumLayer.Next(); while (pLayer != null) { if (pLayer is ICadastralFabricSubLayer) { pCFSubLyr = (ICadastralFabricSubLayer)pLayer; if (pCFSubLyr.CadastralTableType == FabricSubClass) { pParcelFabricSubLayer = (IFeatureLayer)pCFSubLyr; ICadastralFabric ThisLayersFabric = pCFSubLyr.CadastralFabric; bool bIsTargetFabricLayer = ThisLayersFabric.Equals(TargetFabric); if (!ExcludeNonTargetFabrics || (ExcludeNonTargetFabrics && bIsTargetFabricLayer)) { CFParcelFabricSubLayers2.Add(pParcelFabricSubLayer); } } } pLayer = pEnumLayer.Next(); } CFParcelFabSubLayers = CFParcelFabricSubLayers2; if (CFParcelFabricSubLayers2.Count > 0) { return(true); } else { return(false); } }
public bool GetControlLayersFromFabric(IMap Map, ICadastralFabric Fabric, out IArray CFControlLayers) { ICadastralFabricLayer pCFLayer = null; ICadastralFabricSubLayer pCFSubLyr = null; ICompositeLayer pCompLyr = null; IArray CFControlLayers2 = new ArrayClass(); long layerCount = Map.LayerCount; IFeatureLayer pControllLayer = null; for (int idx = 0; idx <= (layerCount - 1); idx++) { ILayer pLayer = Map.get_Layer(idx); bool bIsComposite = false; if (pLayer is ICompositeLayer) { pCompLyr = (ICompositeLayer)pLayer; bIsComposite = true; } int iCompositeLyrCnt = 1; if (bIsComposite) iCompositeLyrCnt = pCompLyr.Count; for (int i = 0; i <= (iCompositeLyrCnt - 1); i++) { if (bIsComposite) pLayer = pCompLyr.get_Layer(i); if (pLayer is ICadastralFabricLayer) { pCFLayer = (ICadastralFabricLayer)pLayer; break; } if (pLayer is ICadastralFabricSubLayer) { pCFSubLyr = (ICadastralFabricSubLayer)pLayer; ICadastralFabric pCadFab2 = null; try { pCadFab2 = pCFSubLyr.CadastralFabric; //this fails when the layer is created from a selection } catch (Exception) { continue; } if (Fabric.Equals(pCadFab2) && pCFSubLyr.CadastralTableType == esriCadastralFabricTable.esriCFTControl) { pControllLayer = (IFeatureLayer)pCFSubLyr; CFControlLayers2.Add(pControllLayer); } } } //Check that the fabric layer belongs to the requested fabric if (pCFLayer != null) { if (pCFLayer.CadastralFabric.Equals(Fabric)) { pControllLayer = (IFeatureLayer)pCFLayer.get_CadastralSubLayer(esriCadastralFabricRenderer.esriCFRControlPoints); CFControlLayers2.Add(pControllLayer); Debug.WriteLine(pControllLayer.Name); } CFControlLayers = CFControlLayers2; return true; } } //at the minimum, just need to make sure we have a control sublayer for the requested fabric if (pControllLayer != null) { CFControlLayers = CFControlLayers2; return true; } else { CFControlLayers = null; return false; } }