private void InitLayerDic(EnumRasterBandCount renderType, IRasterLayer pRasterLayer) { switch (renderType) { case EnumRasterBandCount.One: if (pRasterLayer.BandCount <= 1) { this.InitCmbBoxAndLayerDic(pRasterLayer); } break; case EnumRasterBandCount.MoreThanOne: if (pRasterLayer.BandCount > 1) { this.InitCmbBoxAndLayerDic(pRasterLayer); } break; case EnumRasterBandCount.Any: this.InitCmbBoxAndLayerDic(pRasterLayer); break; } }
private void InitCurrentLayer(EnumLayerType layerType, EnumRasterBandCount rasterBandCount) { this.cmbEditCurrentLayer.Properties.BeginUpdate(); try { this.cmbEditCurrentLayer.Properties.Items.Clear(); List <ILayer> layers = EngineAPI.GetLayers(this.MapControl.ActiveView.FocusMap, "{6CA416B1-E160-11D2-9F4E-00C04F6BC78E}", null); this.cmbEditCurrentLayer.Properties.Items.Clear(); this.cmbEditCurrentLayer.EditValue = null; this.m_layers.Clear(); int i = 0; while (i < layers.Count) { ILayer layer = layers[i]; this.m_layers.Add(new MyDataLayer { Layer = layer, Visible = layer.Visible }); if (layer.Visible) { switch (layerType) { case EnumLayerType.Vector: { IFeatureLayer featureLayer = layer as IFeatureLayer; if (featureLayer != null) { CurrentLayer item = new CurrentLayer { Name = featureLayer.Name, Layer = featureLayer }; this.cmbEditCurrentLayer.Properties.Items.Add(item); } break; } case EnumLayerType.Raster: { IRasterLayer rasterLayer = layer as IRasterLayer; if (rasterLayer != null) { string format = (rasterLayer.Raster as IRaster2).RasterDataset.Format; if (!format.StartsWith("Cache", StringComparison.OrdinalIgnoreCase)) { this.InitLayerDic(rasterBandCount, rasterLayer); } } break; } case EnumLayerType.VectorAndRaster: if (layer is IFeatureLayer || layer is IRasterLayer) { if (layer is IRasterLayer) { IRasterLayer rasterLayer = layer as IRasterLayer; string format = (rasterLayer.Raster as IRaster2).RasterDataset.Format; if (format.StartsWith("Cache", StringComparison.OrdinalIgnoreCase)) { break; } } CurrentLayer item = new CurrentLayer { Name = layer.Name, Layer = layer }; this.cmbEditCurrentLayer.Properties.Items.Add(item); } break; } } IL_245: i++; continue; goto IL_245; } } finally { this.cmbEditCurrentLayer.Properties.EndUpdate(); } if (this.cmbEditCurrentLayer.Properties.Items.Count > 0) { this.cmbEditCurrentLayer.EditValue = this.cmbEditCurrentLayer.Properties.Items[0]; this.CurrentLayer = (this.cmbEditCurrentLayer.EditValue as CurrentLayer).Layer; } else { this.CurrentLayer = null; } }