public frmAddProjectLayers(IMap map2, esriDatasetType dType) { InitializeComponent(); if (map2 == null) { OpenFileDialog ofdMxd = new OpenFileDialog(); ofdMxd.Filter = "Map Doc|*.mxd"; ofdMxd.Multiselect = false; DialogResult rslt = ofdMxd.ShowDialog(); if (rslt == DialogResult.OK) { mapDoc = new MapDocumentClass(); mapDoc.Open(ofdMxd.FileName, ""); map = mapDoc.get_Map(0); } else { MessageBox.Show("A map document must be selected to work. Shutting down"); this.Close(); } } else { map = map2; } if (dType == esriDatasetType.esriDTAny) { dType = esriDatasetType.esriDTFeatureClass; } switch (dType) { case esriDatasetType.esriDTTable: this.Text = "Add Table"; label1.Text = "Select Table"; break; case esriDatasetType.esriDTRasterDataset: this.Text = "Add Raster"; label1.Text = "Select Raster"; break; default: this.Text = "Add Feature"; label1.Text = "Select Feature"; break; } mapserviceutility msUtil = new mapserviceutility(); prjDatabase = msUtil.LcCacheDb; if (prjDatabase == "") { msUtil.changeLocalDatabase(); prjDatabase = msUtil.LcCacheDb; } this.cmbLayers.Items.Clear(); foreach (string s in getNames(dType)) { lyrDic.Add(s, prjDatabase + "\\" + s); cmbLayers.Items.Add(s); } this.Refresh(); }
private void btnDownload_Click(object sender, EventArgs e) { if (!checkInputs()) { MessageBox.Show("You must have a value for all inputs"); return; } mapserviceutility msUtil = new mapserviceutility(); geoDatabaseUtility geoUtil = new geoDatabaseUtility(); IImageServerLayer svLyr = getServerLayer(); ESRI.ArcGIS.Geometry.IEnvelope ext = new ESRI.ArcGIS.Geometry.EnvelopeClass(); if (cmbExtent.Text.ToLower() == "display") { ext = av.Extent; } else { IFeatureLayer ftrLyr = getFeatureLayer(); ext = ((ESRI.ArcGIS.Geodatabase.IGeoDataset)ftrLyr).Extent; } if (svLyr == null) { MessageBox.Show("You must select a Image server layer"); return; } this.Visible = false; ESRI.ArcGIS.Geodatabase.IWorkspace wks = geoUtil.OpenWorkSpace(txtGeoDb.Text); ESRI.ArcGIS.Geodatabase.IRaster rs = null; string msg = msUtil.fillDbRaster(svLyr, wks, ext, svLyr.ServiceInfo.SpatialReference, out rs); IMap mp = (IMap)av; if (rs != null) { IRasterLayer rsLyr = new RasterLayerClass(); rsLyr.CreateFromRaster(rs); rsLyr.Name = svLyr.ServiceInfo.Name; rsLyr.Visible = false; mp.AddLayer((ILayer)rsLyr); } this.Close(); //MessageBox.Show(msg); }
private void btnDownload_Click(object sender, EventArgs e) { if (!checkInputs()) { MessageBox.Show("You must have a value for all inputs"); return; } mapserviceutility msUtil = new mapserviceutility(); geoDatabaseUtility geoUtil = new geoDatabaseUtility(); IImageServerLayer svLyr = getServerLayer(); ESRI.ArcGIS.Geometry.IEnvelope ext = new ESRI.ArcGIS.Geometry.EnvelopeClass(); if(cmbExtent.Text.ToLower()=="display") { ext = av.Extent; } else { IFeatureLayer ftrLyr = getFeatureLayer(); ext = ((ESRI.ArcGIS.Geodatabase.IGeoDataset)ftrLyr).Extent; } if(svLyr==null) { MessageBox.Show("You must select a Image server layer"); return; } this.Visible = false; ESRI.ArcGIS.Geodatabase.IWorkspace wks = geoUtil.OpenWorkSpace(txtGeoDb.Text); ESRI.ArcGIS.Geodatabase.IRaster rs = null; string msg = msUtil.fillDbRaster(svLyr,wks,ext,svLyr.ServiceInfo.SpatialReference,out rs); IMap mp = (IMap)av; if (rs != null) { IRasterLayer rsLyr = new RasterLayerClass(); rsLyr.CreateFromRaster(rs); rsLyr.Name = svLyr.ServiceInfo.Name; rsLyr.Visible = false; mp.AddLayer((ILayer)rsLyr); } this.Close(); //MessageBox.Show(msg); }