private IEnumLayer GetLayers() { //now get the map document to parse out the feature classes GxDialog pGxDialog = new GxDialogClass(); IEnumGxObject pEnumGxObject; bool pResult; pGxDialog.ObjectFilter = new GxFilterMapsClass(); pGxDialog.Title = "Select a map document"; try { pResult = pGxDialog.DoModalOpen(0, out pEnumGxObject); //check to see if the user canceled the dialog if (pResult == false) { return(null); } IGxObject pGxObject = pEnumGxObject.Next(); IMapReader pMapReader = new MapReaderClass(); pMapReader.Open(pGxObject.FullName.ToString()); IMap pMap = pMapReader.get_Map(0); ESRI.ArcGIS.esriSystem.UID pUID = new ESRI.ArcGIS.esriSystem.UIDClass(); pUID.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}"; //feature layer IEnumLayer pLayers = pMap.get_Layers(pUID, true); return(pLayers); } catch { //error getting layers return(null); } }
private IEnumLayer GetLayers() { //now get the map document to parse out the feature classes GxDialog pGxDialog = new GxDialogClass(); IEnumGxObject pEnumGxObject; bool pResult; pGxDialog.ObjectFilter = new GxFilterMapsClass(); pGxDialog.Title = "Select a map document"; try { pResult = pGxDialog.DoModalOpen(0, out pEnumGxObject); //check to see if the user canceled the dialog if (pResult == false) return null; IGxObject pGxObject = pEnumGxObject.Next(); IMapReader pMapReader = new MapReaderClass(); pMapReader.Open(pGxObject.FullName.ToString()); IMap pMap = pMapReader.get_Map(0); ESRI.ArcGIS.esriSystem.UID pUID = new ESRI.ArcGIS.esriSystem.UIDClass(); pUID.Value = "{40A9E885-5533-11D0-98BE-00805F7CED21}"; //feature layer IEnumLayer pLayers = pMap.get_Layers(pUID, true); return pLayers; } catch { //error getting layers return null; } }