public static bool AddDataset(IBasicMap pBasicMap, IDatasetName pDatasetName, Collection <object> m_DatasetCol, bool blnAddData) { bool functionReturnValue = false; functionReturnValue = false; ////如果是特征数据集,则添加里边的所有要素类 IFeatureDataset pFeatDS = default(IFeatureDataset); IEnumDataset pEnumDataSet = default(IEnumDataset); IDataset pDataset = default(IDataset); IFeatureClass pFeatCls = default(IFeatureClass); IFeatureLayer pFeatLayer = default(IFeatureLayer); IName pName = default(IName); ILayer pLayer = default(ILayer); ITopologyLayer pTopoLayer = default(ITopologyLayer); //Dim pEnumLyr As IEnumLayer ITinWorkspace pTinWS = default(ITinWorkspace); IEnumFeatureClass pEnumFeatCls = null; IRasterCatalogDisplayProps pRasterCatalogPro = default(IRasterCatalogDisplayProps); //ClsErrorHandle pfrmError = new ClsErrorHandle(); //ClsLayerRender pLayerRender = null; if (pDatasetName is IFeatureDatasetName) { pName = pDatasetName as IName; pFeatDS = pName.Open() as IFeatureDataset; pEnumDataSet = pFeatDS.Subsets; pDataset = pEnumDataSet.Next(); m_DatasetCol.Add(pDataset); if (pDataset == null) { return(false); } ////根据数据集的类型,添加特征数据集中的所有要素类(拓扑,一般的,栅格目录,网络) while ((pDataset != null)) { if (pDataset.Type == esriDatasetType.esriDTFeatureClass) { //pLayerRender = new ClsLayerRender(); //// 陈昉 2008-12-3 修改 修改原因 添加SDE图层时从数据库读取符号化信息 //pFeatLayer = null; //if (pDataset.Workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) //{ // pFeatLayer = pLayerRender.GetRendererLayer((IFeatureClass)pDataset); //} if (pFeatLayer == null) { pFeatLayer = new FeatureLayer(); pFeatCls = pDataset as IFeatureClass; pFeatLayer.Name = pFeatCls.AliasName; pFeatLayer.FeatureClass = pFeatCls; } if (pDataset.Type == esriDatasetType.esriDTRasterCatalog) { // Dim pRaster } if (blnAddData == true) { //pMap.AddLayer pFeatLayer AddLyrToBasicMap(pBasicMap, pFeatLayer); SortLayer(pBasicMap, pFeatLayer); } // pSelectedCln.Add(pFeatLayer) } else if (pDataset.Type == esriDatasetType.esriDTTopology) { pTopoLayer = new TopologyLayer() as ITopologyLayer; pTopoLayer.Topology = pDataset as ITopology; pLayer = pTopoLayer as ILayer; pLayer.Name = pDataset.Name; if (blnAddData == true) { //pMap.AddLayer pLayer AddLyrToBasicMap(pBasicMap, pLayer); SortLayer(pBasicMap, pLayer); } //pSelectedCln.Add(pFeatLayer) } pDataset = pEnumDataSet.Next(); } functionReturnValue = true; ////添加拓扑图层 } else if (pDatasetName is ITopologyName) { ITopology pTopo = null; pName = pDatasetName as IName; pDataset = pName.Open() as IDataset; pTopoLayer = new TopologyLayer() as ITopologyLayer; pTopoLayer.Topology = pDataset as ITopology; pLayer = pTopoLayer as ILayer; pLayer.Name = pDataset.Name; m_DatasetCol.Add(pDataset); if (blnAddData == true) { //pMap.AddLayer pLayer AddLyrToBasicMap(pBasicMap, pLayer); SortLayer(pBasicMap, pLayer); } //pSelectedCln.Add(pLayer) if (MessageBox.Show("要把拓扑里边的所有要素类也添加到当前地图中吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { IFeatureClassContainer pFeatClsContainer = default(IFeatureClassContainer); pFeatClsContainer = pTopo as IFeatureClassContainer; pEnumFeatCls = pFeatClsContainer.Classes; pFeatCls = pEnumFeatCls.Next(); pFeatLayer = new FeatureLayer(); ////循环拓扑中的每个要素类,并添加到当前地图中 while ((pFeatCls != null)) { pFeatLayer.FeatureClass = pFeatCls; pFeatLayer.Name = pFeatCls.AliasName; if (blnAddData == true) { //pMap.AddLayer pFeatLayer AddLyrToBasicMap(pBasicMap, pFeatLayer); SortLayer(pBasicMap, pFeatLayer); } //pSelectedCln.Add(pFeatLayer) pFeatCls = pEnumFeatCls.Next(); } } functionReturnValue = true; ////添加网络数据 } else if (pDatasetName is IGeometricNetworkName) { INetworkCollection pNetworkCollection = default(INetworkCollection); IGeometricNetwork pGeometricNetwork = default(IGeometricNetwork); IDataset pGeoDataset = default(IDataset); pName = pDatasetName as IName; pGeoDataset = pName.Open() as IDataset; m_DatasetCol.Add(pGeoDataset); if (pGeoDataset.Type == esriDatasetType.esriDTGeometricNetwork) { ////这里对网络数据进行处理 IFeatureClassContainer pFeatureClassContainer = null; pGeometricNetwork = pGeoDataset as IGeometricNetwork; pFeatureClassContainer = pGeometricNetwork as IFeatureClassContainer; for (int i = 0; i < pFeatureClassContainer.ClassCount; i++) { pFeatCls = pFeatureClassContainer.get_Class(i); pFeatLayer = new FeatureLayer(); pFeatLayer.Name = pFeatCls.AliasName; pFeatLayer.FeatureClass = pFeatCls; if (blnAddData == true) { // pMap.AddLayer pFeatLayer AddLyrToBasicMap(pBasicMap, pFeatLayer); SortLayer(pBasicMap, pFeatLayer); } //pSelectedCln.Add(pFeatLayer) } } else { pFeatDS = pGeoDataset as IFeatureDataset; pNetworkCollection = pFeatDS as INetworkCollection; ////如果是用户选择一个网络技术打开的话,肯定只有一个网络在里边,其实 ////可以不需要循环,而用GeometricNetwork(0)代替循环 for (int j = 0; j < pNetworkCollection.GeometricNetworkCount; j++) { pGeometricNetwork = pNetworkCollection.get_GeometricNetwork(j); for (int i = 0; i <= 3; i++) { switch (i) { case 0: pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction); break; case 1: pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge); break; case 2: pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction); break; case 3: pEnumFeatCls = pGeometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge); break; } pFeatCls = pEnumFeatCls.Next(); while ((pFeatCls != null)) { pFeatLayer = new FeatureLayer(); pFeatLayer.Name = pFeatCls.AliasName; pFeatLayer.FeatureClass = pFeatCls; pFeatCls = pEnumFeatCls.Next(); if (blnAddData == true) { //pMap.AddLayer pFeatLayer AddLyrToBasicMap(pBasicMap, pFeatLayer); SortLayer(pBasicMap, pFeatLayer); } // pSelectedCln.Add(pFeatLayer) functionReturnValue = true; } } } } ////添加栅格目录,并设置为显示最新时相 } else if (pDatasetName is IRasterCatalogName) { pName = pDatasetName as IName; pDataset = pName.Open() as IDataset; m_DatasetCol.Add(pDataset); pFeatLayer = new GdbRasterCatalogLayer() as IFeatureLayer; pFeatLayer.FeatureClass = pDataset as IFeatureClass; pFeatLayer.Name = pDataset.Name; //'//如果是SDE的栅格目录 //If pFeatLayer.DataSourceType = "SDE Raster Catalog" Then // Dim pFeatLayerDef As IFeatureLayerDefinition // pFeatLayerDef = pFeatLayer // '//设置最初显示地图范围内最近时相的数据 // pFeatLayerDef.DefinitionExpression = "objectid in (select objectid from" & vbNewLine & _ // "(select a.objectid, b.receive_date,rank()" & vbNewLine & _ // "over(partition by a.name,a.resolution order by b.receive_date desc) as cid" & vbNewLine & _ // "from " & pFeatLayer.Name & " a, sj_t_tense b" & vbNewLine & _ // "where a.tense = b.tense" & vbNewLine & "and b.online_state = 1) t2" & vbNewLine & _ // "where " & pFeatLayer.Name & ".objectid=t2.objectid and t2.cid = 1)" //End If ////设置当栅格目录中的图幅在地图上超过16个的时候,以格网来显示,而不显示栅格本身 pRasterCatalogPro = pFeatLayer as IRasterCatalogDisplayProps; ////不用数量来控制了,而以比例尺来控制 pRasterCatalogPro.DisplayRasters = 16; pRasterCatalogPro.UseScale = true; ////设置一个比例,在此临界栅格数据将会在框架显示与实际栅格显示之间转换 pRasterCatalogPro.TransitionScale = 50000; if (blnAddData == true) { //pMap.AddLayer pFeatLayer AddLyrToBasicMap(pBasicMap, pFeatLayer); //SortLayer(pBasicMap, pFeatLayer) } //pSelectedCln.Add(pFeatLayer) functionReturnValue = true; } else if (pDatasetName is IRasterDatasetName) { IRasterLayer pRasterLayer = default(IRasterLayer); pName = pDatasetName as IName; pDataset = pName.Open() as IDataset; m_DatasetCol.Add(pDataset); pRasterLayer = new RasterLayer(); pRasterLayer.CreateFromDataset((IRasterDataset)pDataset); pRasterLayer.Name = pDataset.Name; AddLyrToBasicMap(pBasicMap, pRasterLayer); functionReturnValue = true; ////添加TIN图层 } else if (pDatasetName is ITinWorkspace) { pTinWS = pDatasetName as ITinWorkspace; ITinLayer pTinLyr = default(ITinLayer); pTinLyr = new TinLayer(); pTinLyr.Dataset = pTinWS.OpenTin(pDatasetName.Name); pTinLyr.Name = pDatasetName.Name; if (blnAddData == true) { //pMap.AddLayer pTinLyr AddLyrToBasicMap(pBasicMap, pTinLyr); SortLayer(pBasicMap, pTinLyr); } //pSelectedCln.Add(pTinLyr) functionReturnValue = true; } else if (pDatasetName is INetworkDatasetName) { //Dim pNetWorkDS As INetworkDataset try { INetworkLayer pNetLayer = default(INetworkLayer); pName = pDatasetName as IName; pNetLayer = new NetworkLayer() as INetworkLayer; pNetLayer.NetworkDataset = pName.Open() as INetworkDataset; pLayer = pNetLayer as ILayer; pLayer.Name = pName.NameString; if (blnAddData == true) { AddLyrToBasicMap(pBasicMap, pLayer); } } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } ////添加一般的要素类,未写完。。。。。。 } else { pName = pDatasetName as IName; pDataset = pName.Open() as IDataset; pFeatCls = pDataset as IFeatureClass; m_DatasetCol.Add(pDataset); if (pFeatCls.FeatureType == esriFeatureType.esriFTAnnotation) { pFeatLayer = new FDOGraphicsLayer() as IFeatureLayer; } else if (pFeatCls.FeatureType == esriFeatureType.esriFTDimension) { pFeatLayer = new DimensionLayer() as IFeatureLayer; } else { pFeatLayer = new FeatureLayer(); //pLayerRender = new ClsLayerRender(); //// 陈昉 2008-12-3 修改 修改原因 添加SDE图层时从数据库读取符号化信息 //if (pDataset.Workspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) //{ // pFeatLayer = pLayerRender.GetRendererLayer((IFeatureClass)pDataset); //} } //印骅 20081205 添加"Not" if ((pFeatLayer != null)) { //pFeatLayer.Name = pDataset.Name pFeatLayer.Name = pFeatCls.AliasName; pFeatLayer.FeatureClass = pDataset as IFeatureClass; } if (blnAddData == true) { //pMap.AddLayer pFeatLayer AddLyrToBasicMap(pBasicMap, pFeatLayer); SortLayer(pBasicMap, pFeatLayer); } //pSelectedCln.Add(pFeatLayer) functionReturnValue = true; } return(functionReturnValue); //'//添加Coverage图层 //ElseIf vItem.SmallIcon = "Coverage" Then //AddSelectedLayer = ADDCoverageLayer(pMap, pCurrentFilePath.Path, _ //vItem.Text, pSelectedCln, blnAddData) }
public void LoadData(IList ilist_0) { try { List <ILayer> list = new List <ILayer>(); for (int i = 0; i < ilist_0.Count; i++) { if (ilist_0[i] is IGxLayer) { list.Add((ilist_0[i] as IGxLayer).Layer); } else { IGxDataset gxDataset = ilist_0[i] as IGxDataset; if (gxDataset != null) { IDataset dataset = gxDataset.Dataset; if (dataset != null) { if (dataset.Type == esriDatasetType.esriDTFeatureClass) { IFeatureClass featureClass = (IFeatureClass)dataset; IFeatureLayer featureLayer; if ((gxDataset as IGxObject).Category.IndexOf("CAD") != -1) { if (featureClass.FeatureType == esriFeatureType.esriFTCoverageAnnotation) { featureLayer = new CadAnnotationLayer() as IFeatureLayer; } else { featureLayer = new CadFeatureLayer() as IFeatureLayer; } featureLayer.FeatureClass = featureClass; featureLayer.Name = featureClass.AliasName; } else if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation) { featureLayer = new FDOGraphicsLayer() as IFeatureLayer; featureLayer.FeatureClass = featureClass; featureLayer.Name = featureClass.AliasName; } else if (featureClass.FeatureType == esriFeatureType.esriFTDimension) { featureLayer = new DimensionLayer() as IFeatureLayer; featureLayer.FeatureClass = featureClass; featureLayer.Name = featureClass.AliasName; } else { featureLayer = new FeatureLayer(); featureLayer.FeatureClass = featureClass; featureLayer.Name = featureClass.AliasName; } list.Add(featureLayer); } else if (dataset.Type == esriDatasetType.esriDTCadDrawing) { if ((gxDataset as IGxObject).Category == "CAD绘图") { ICadLayer item = new CadLayer() as ICadLayer; item.CadDrawingDataset = gxDataset.Dataset as ICadDrawingDataset; item.Name = gxDataset.Dataset.Name; list.Add(item); } else { IEnumGxObject children = (gxDataset as IGxObjectContainer).Children; children.Reset(); for (IGxDataset gxDataset2 = children.Next() as IGxDataset; gxDataset2 != null; gxDataset2 = (children.Next() as IGxDataset)) { IFeatureClass featureClass = gxDataset2.Dataset as IFeatureClass; if (featureClass != null) { IFeatureLayer featureLayer; if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation) { featureLayer = new FDOGraphicsLayer() as IFeatureLayer; featureLayer.FeatureClass = featureClass; featureLayer.Name = featureClass.AliasName; } else { featureLayer = new CadFeatureLayer() as IFeatureLayer; featureLayer.FeatureClass = featureClass; featureLayer.Name = featureClass.AliasName; } list.Add(featureLayer); } } } } else if (dataset.Type == esriDatasetType.esriDTFeatureDataset) { IEnumDataset subsets = dataset.Subsets; subsets.Reset(); for (IDataset dataset2 = subsets.Next(); dataset2 != null; dataset2 = subsets.Next()) { if (dataset2.Type == esriDatasetType.esriDTFeatureClass) { IFeatureClass featureClass = dataset2 as IFeatureClass; if (featureClass.FeatureType == esriFeatureType.esriFTAnnotation) { IFeatureLayer item = new FDOGraphicsLayer() as IFeatureLayer; item.FeatureClass = featureClass; item.Name = featureClass.AliasName; list.Add(item); } else { list.Add(new FeatureLayer { FeatureClass = featureClass, Name = featureClass.AliasName }); } } else if (dataset2.Type == esriDatasetType.esriDTTopology) { ITopologyLayer topologyLayer = new TopologyLayer() as ITopologyLayer; topologyLayer.Topology = (dataset2 as ITopology); (topologyLayer as ILayer).Name = dataset2.Name; list.Add(topologyLayer as ILayer); } } } else if (dataset.Type == esriDatasetType.esriDTTopology) { if (System.Windows.Forms.MessageBox.Show("是否将参加拓扑-" + dataset.Name + "-的所有要素添加到地图中", "添加拓扑层", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Yes) { IEnumFeatureClass classes = (dataset as IFeatureClassContainer).Classes; classes.Reset(); for (IFeatureClass featureClass2 = classes.Next(); featureClass2 != null; featureClass2 = classes.Next()) { list.Add(new FeatureLayer { FeatureClass = featureClass2, Name = featureClass2.AliasName }); } } ITopologyLayer topologyLayer = new TopologyLayer() as ITopologyLayer; topologyLayer.Topology = (dataset as ITopology); (topologyLayer as ILayer).Name = dataset.Name; list.Add(topologyLayer as ILayer); } else if (dataset.Type == esriDatasetType.esriDTTin) { list.Add(new TinLayer { Dataset = (ITin)dataset, Name = dataset.Name }); } else if (dataset.Type == esriDatasetType.esriDTRasterDataset || dataset.Type == esriDatasetType.esriDTRasterBand) { bool flag = true; if (!((IRasterPyramid)dataset).Present) { if (ApplicationRef.PyramidPromptType == PyramidPromptType.AlwaysBuildNoPrompt) { ((IRasterPyramid)dataset).Create(); } else if (ApplicationRef.PyramidPromptType == PyramidPromptType.AlwaysPrompt) { System.Windows.Forms.DialogResult dialogResult = BuildPyramidSet.Show(); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { ((IRasterPyramid)dataset).Create(); } else if (dialogResult == System.Windows.Forms.DialogResult.Cancel) { flag = false; } } } if (flag) { IRasterLayer rasterLayer = new RasterLayer { Cached = true }; rasterLayer.CreateFromDataset((IRasterDataset)dataset); rasterLayer.Name = dataset.Name; list.Add(rasterLayer); } } else { if (dataset.Type == esriDatasetType.esriDTTable) { try { IRasterCatalogTable rasterCatalogTable = new RasterCatalogTable(); rasterCatalogTable.Table = (ITable)dataset; rasterCatalogTable.Update(); IRasterCatalogLayer rasterCatalogLayer = new RasterCatalogLayer() as IRasterCatalogLayer; rasterCatalogLayer.Create(rasterCatalogTable); rasterCatalogLayer.Name = dataset.BrowseName; list.Add(rasterCatalogLayer); goto IL_8B0; } catch (Exception ex) { try { IStandaloneTableCollection standaloneTableCollection = this.method_0() as IStandaloneTableCollection; IPropertySet connectionProperties = dataset.Workspace.ConnectionProperties; bool flag2 = false; for (int j = 0; j < standaloneTableCollection.StandaloneTableCount; j++) { ITable table = standaloneTableCollection.get_StandaloneTable(j).Table; if ( connectionProperties.IsEqual( (table as IDataset).Workspace.ConnectionProperties) && (table as IDataset).Name == dataset.Name) { flag2 = true; } else { standaloneTableCollection.AddStandaloneTable(new StandaloneTable { Table = dataset as ITable }); } } } catch (Exception exception_) { CErrorLog.writeErrorLog(this, exception_, ""); } goto IL_8B0; } } if (dataset.Type == esriDatasetType.esriDTGeometricNetwork) { IGeometricNetwork geometricNetwork = dataset as IGeometricNetwork; if (geometricNetwork != null) { IEnumFeatureClass enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleJunction); enumFeatureClass.Reset(); for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next()) { list.Add(new FeatureLayer { FeatureClass = featureClass3, Name = (featureClass3 as IDataset).Name }); } enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexJunction); enumFeatureClass.Reset(); for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next()) { list.Add(new FeatureLayer { FeatureClass = featureClass3, Name = (featureClass3 as IDataset).Name }); } enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTSimpleEdge); enumFeatureClass.Reset(); for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next()) { list.Add(new FeatureLayer { FeatureClass = featureClass3, Name = (featureClass3 as IDataset).Name }); } enumFeatureClass = geometricNetwork.get_ClassesByType(esriFeatureType.esriFTComplexEdge); enumFeatureClass.Reset(); for (IFeatureClass featureClass3 = enumFeatureClass.Next(); featureClass3 != null; featureClass3 = enumFeatureClass.Next()) { list.Add(new FeatureLayer { FeatureClass = featureClass3, Name = (featureClass3 as IDataset).Name }); } } } else if (dataset.Type == esriDatasetType.esriDTNetworkDataset) { INetworkDataset networkDataset = dataset as INetworkDataset; INetworkLayer item = new NetworkLayer() as INetworkLayer; item.NetworkDataset = networkDataset; list.Add(item as ILayer); if (System.Windows.Forms.MessageBox.Show("是否将参加网络要素集-" + dataset.Name + "-的所有要素添加到地图中", "添加拓扑层", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.Yes) { IEnumFeatureClass classes = (dataset as IFeatureClassContainer).Classes; classes.Reset(); for (IFeatureClass featureClass2 = classes.Next(); featureClass2 != null; featureClass2 = classes.Next()) { list.Add(new FeatureLayer { FeatureClass = featureClass2, Name = featureClass2.AliasName }); } } } } } } } IL_8B0 :; } int num = list.Count; ILayer layer = null; for (int i = num - 1; i >= 0; i--) { layer = list[i]; if (layer is IRasterCatalogLayer) { this.method_0().AddLayer(layer); (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); list.RemoveAt(i); num--; } } for (int i = num - 1; i >= 0; i--) { layer = list[i]; if (layer is IRasterLayer) { this.method_0().AddLayer(layer); (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); list.RemoveAt(i); num--; } } for (int i = num - 1; i >= 0; i--) { layer = list[i]; if (layer is ITinLayer) { this.method_0().AddLayer(layer); (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); list.RemoveAt(i); num--; } } for (int i = num - 1; i >= 0; i--) { layer = list[i]; if (layer is ICadLayer) { this.method_0().AddLayer(layer); (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); list.RemoveAt(i); num--; } } for (int i = num - 1; i >= 0; i--) { layer = list[i]; if (layer is IFeatureLayer) { IFeatureLayer featureLayer = layer as IFeatureLayer; IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass.ShapeType == esriGeometryType.esriGeometryPolygon || featureClass.ShapeType == esriGeometryType.esriGeometryEnvelope) { this.method_0().AddLayer(layer); (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); list.RemoveAt(i); num--; } } } for (int i = num - 1; i >= 0; i--) { layer = list[i]; if (layer is IFeatureLayer) { IFeatureLayer featureLayer = layer as IFeatureLayer; IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass.ShapeType == esriGeometryType.esriGeometryLine || featureClass.ShapeType == esriGeometryType.esriGeometryBezier3Curve || featureClass.ShapeType == esriGeometryType.esriGeometryCircularArc || featureClass.ShapeType == esriGeometryType.esriGeometryEllipticArc || featureClass.ShapeType == esriGeometryType.esriGeometryPath || featureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { try { this.method_0().AddLayer(layer); goto IL_B56; } catch { goto IL_B56; } goto IL_B4D; IL_B56: (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); list.RemoveAt(i); num--; } } IL_B4D :; } for (int i = num - 1; i >= 0; i--) { layer = list[i]; if (layer is IFeatureLayer) { IFeatureLayer featureLayer = layer as IFeatureLayer; IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass.ShapeType == esriGeometryType.esriGeometryMultipoint || featureClass.ShapeType == esriGeometryType.esriGeometryPoint) { this.method_0().AddLayer(layer); (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); list.RemoveAt(i); num--; } } } for (int i = num - 1; i >= 0; i--) { layer = list[i]; this.method_0().AddLayer(layer); (this.method_0() as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGeography, layer, null); list.RemoveAt(i); num--; } } catch (Exception ex) { ex.ToString(); } }
public static void AddDataset(IBasicMap ibasicMap_0, IDataset idataset_0, string string_0) { if (string_0 == null) { string_0 = ""; } switch (idataset_0.Type) { case esriDatasetType.esriDTFeatureDataset: { IEnumDataset subsets = idataset_0.Subsets; subsets.Reset(); for (IDataset dataset2 = subsets.Next(); dataset2 != null; dataset2 = subsets.Next()) { AddDataset(ibasicMap_0, dataset2, string_0); } break; } case esriDatasetType.esriDTFeatureClass: { IFeatureLayer layer; IFeatureClass class2 = (IFeatureClass)idataset_0; if (class2.FeatureType != esriFeatureType.esriFTAnnotation) { if (class2.FeatureType == esriFeatureType.esriFTDimension) { IFeatureLayer dimensionLayer = new DimensionLayer() as IFeatureLayer; dimensionLayer.FeatureClass = class2; dimensionLayer.Name = string_0 + class2.AliasName; layer = dimensionLayer as IFeatureLayer; ibasicMap_0.AddLayer(layer); } else { layer = new FeatureLayer { FeatureClass = class2, Name = string_0 + class2.AliasName }; ibasicMap_0.AddLayer(layer); } break; } layer = new FDOGraphicsLayer() as IFeatureLayer; try { layer.FeatureClass = class2; layer.Name = string_0 + class2.AliasName; ibasicMap_0.AddLayer(layer); } catch (Exception exception) { exception.ToString(); } break; } case esriDatasetType.esriDTGeometricNetwork: { IGeometricNetwork network = idataset_0 as IGeometricNetwork; if (network != null) { IFeatureLayer layer7; IEnumFeatureClass class3 = network.get_ClassesByType(esriFeatureType.esriFTSimpleJunction); class3.Reset(); IFeatureClass class4 = class3.Next(); while (class4 != null) { layer7 = new FeatureLayer { FeatureClass = class4, Name = string_0 + (class4 as IDataset).Name }; ibasicMap_0.AddLayer(layer7); class4 = class3.Next(); } class3 = network.get_ClassesByType(esriFeatureType.esriFTComplexJunction); class3.Reset(); for (class4 = class3.Next(); class4 != null; class4 = class3.Next()) { layer7 = new FeatureLayer { FeatureClass = class4, Name = string_0 + (class4 as IDataset).Name }; ibasicMap_0.AddLayer(layer7); } class3 = network.get_ClassesByType(esriFeatureType.esriFTSimpleEdge); class3.Reset(); for (class4 = class3.Next(); class4 != null; class4 = class3.Next()) { layer7 = new FeatureLayer { FeatureClass = class4, Name = string_0 + (class4 as IDataset).Name }; ibasicMap_0.AddLayer(layer7); } class3 = network.get_ClassesByType(esriFeatureType.esriFTComplexEdge); class3.Reset(); for (class4 = class3.Next(); class4 != null; class4 = class3.Next()) { layer7 = new FeatureLayer { FeatureClass = class4, Name = string_0 + (class4 as IDataset).Name }; ibasicMap_0.AddLayer(layer7); } } break; } case esriDatasetType.esriDTTopology: { ITopologyLayer layer = new TopologyLayer() as ITopologyLayer; layer.Topology = idataset_0 as ITopology; ITopologyLayer layer3 = layer as ITopologyLayer; (layer3 as ILayer).Name = string_0 + idataset_0.Name; ibasicMap_0.AddLayer(layer3 as ILayer); break; } case esriDatasetType.esriDTTable: try { IRasterCatalogTable pCatalog = new RasterCatalogTable { Table = (ITable)idataset_0 }; pCatalog.Update(); IRasterCatalogLayer pLayer = new RasterCatalogLayer() as IRasterCatalogLayer; pLayer.Create(pCatalog); pLayer.Name = string_0 + idataset_0.BrowseName; ibasicMap_0.AddLayer(pLayer); } catch { try { IStandaloneTableCollection tables = ibasicMap_0 as IStandaloneTableCollection; IPropertySet connectionProperties = idataset_0.Workspace.ConnectionProperties; bool flag = false; for (int i = 0; i < tables.StandaloneTableCount; i++) { ITable table = tables.get_StandaloneTable(i).Table; if (connectionProperties.IsEqual((table as IDataset).Workspace.ConnectionProperties) && ((table as IDataset).Name == idataset_0.Name)) { goto Label_03E1; } } goto Label_03E4; Label_03E1: flag = true; Label_03E4: if (!flag) { IStandaloneTable table3 = new StandaloneTable { Table = idataset_0 as ITable }; tables.AddStandaloneTable(table3); } } catch (Exception exception2) { CErrorLog.writeErrorLog(null, exception2, ""); } } break; case esriDatasetType.esriDTRasterDataset: case esriDatasetType.esriDTRasterBand: { IRasterLayer layer5 = new RasterLayer(); layer5.CreateFromDataset((IRasterDataset)idataset_0); layer5.Name = string_0 + idataset_0.Name; ibasicMap_0.AddLayer(layer5); break; } case esriDatasetType.esriDTTin: { ITinLayer layer4 = new TinLayer { Dataset = (ITin)idataset_0, Name = string_0 + idataset_0.Name }; ibasicMap_0.AddLayer(layer4); break; } case esriDatasetType.esriDTCadDrawing: { ICadLayer layer2 = new CadLayer() as ICadLayer; layer2.CadDrawingDataset = idataset_0 as ICadDrawingDataset; layer2.Name = idataset_0.Name; ibasicMap_0.AddLayer(layer2); break; } } }