private void btnSelect_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureDatasetFilter()); ExplorerDialog exDlg = new ExplorerDialog("Target Feature Dataset", filters, true); if (exDlg.ShowDialog() == DialogResult.OK && exDlg.ExplorerObjects.Count == 1) { IExplorerObject parentObject = exDlg.ExplorerObjects[0]; if (parentObject.Object is IFeatureDataset && ((IDataset)parentObject.Object).Database is IFeatureUpdater) { _dataset = (IFeatureDataset)parentObject.Object; } else { MessageBox.Show("Can't determine target featureclass!"); return; } txtDatasetName.Text = _dataset.Database.ToString(); txtDatasetLocation.Text = parentObject.FullName; } }
private void btnImport_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenDataFilter()); ExplorerDialog dlg = new ExplorerDialog("Import Extent", filters, true); dlg.MulitSelection = true; if (dlg.ShowDialog() == DialogResult.OK) { IEnvelope bounds = null; foreach (IExplorerObject exObject in dlg.ExplorerObjects) { if (exObject == null || exObject.Object == null) { continue; } IEnvelope objEnvelope = null; if (exObject.Object is IDataset) { foreach (IDatasetElement element in ((IDataset)exObject.Object).Elements) { if (element == null) { continue; } objEnvelope = ClassEnvelope(element.Class, this.SpatialReference); } } else { objEnvelope = ClassEnvelope(exObject.Object as IClass, this.SpatialReference); } if (objEnvelope != null) { if (bounds == null) { bounds = new Envelope(objEnvelope); } else { bounds.Union(objEnvelope); } } } if (bounds != null) { numLeft.Value = (decimal)bounds.minx; numRight.Value = (decimal)bounds.maxx; numBottom.Value = (decimal)bounds.miny; numTop.Value = (decimal)bounds.maxx; } } }
async void newService_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenMapFilter()); ExplorerDialog exDialog = new ExplorerDialog("Select Map", filters, true); if (exDialog.ShowDialog() == DialogResult.OK) { List <IMap> maps = new List <IMap>(); foreach (IExplorerObject exObject in exDialog.ExplorerObjects) { var exObjectInstance = await exObject.GetInstanceAsync(); if (exObjectInstance is IMap) { maps.Add((IMap)exObjectInstance); } } FormAddServices services = new FormAddServices(maps); if (services.ShowDialog() == System.Windows.Forms.DialogResult.OK) { await AddMap2Connection(services.ServiceNames, services.Maps); } if (_refreshDelegate != null) { await _refreshDelegate(); } } }
async private void btnImport_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenDataFilter()); ExplorerDialog dlg = new ExplorerDialog("Import Extent", filters, true); dlg.MulitSelection = true; if (dlg.ShowDialog() == DialogResult.OK) { IEnvelope bounds = null; foreach (IExplorerObject exObject in dlg.ExplorerObjects) { var instance = await exObject?.GetInstanceAsync(); if (instance == null) { continue; } IEnvelope objEnvelope = null; if (instance is IDataset) { foreach (IDatasetElement element in await((IDataset)instance).Elements()) { if (element == null) { continue; } objEnvelope = ClassEnvelope(element.Class); } } else { objEnvelope = ClassEnvelope(instance as IClass); } if (objEnvelope != null) { if (bounds == null) { bounds = new Envelope(objEnvelope); } else { bounds.Union(objEnvelope); } } } if (bounds != null) { this.Extent = bounds; } } }
private void btnImport_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenDataFilter()); ExplorerDialog dlg = new ExplorerDialog("Import Extent", filters, true); dlg.MulitSelection = true; ISpatialReference sRef = SpatialReference.FromID("epsg:" + cmbEpsg.SelectedItem.ToString()); if (dlg.ShowDialog() == DialogResult.OK) { IEnvelope bounds = null; foreach (IExplorerObject exObject in dlg.ExplorerObjects) { if (exObject == null || exObject.Object == null) { continue; } IEnvelope objEnvelope = null; if (exObject.Object is IDataset) { foreach (IDatasetElement element in ((IDataset)exObject.Object).Elements) { if (element == null) { continue; } objEnvelope = ClassEnvelope(element.Class, sRef); } } else { objEnvelope = ClassEnvelope(exObject.Object as IClass, sRef); } if (objEnvelope != null) { if (bounds == null) { bounds = new Envelope(objEnvelope); } else { bounds.Union(objEnvelope); } } } if (bounds != null) { this.CurrentExtent = bounds; } } }
async private void btnImportDef_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFDBFeatureclassFilter()); ExplorerDialog dlg = new ExplorerDialog("Import Spatial Index", filters, true); dlg.MulitSelection = true; if (dlg.ShowDialog() == DialogResult.OK) { IEnvelope bounds = null; int levels = 0; foreach (IExplorerObject exObject in dlg.ExplorerObjects) { var instance = await exObject?.GetInstanceAsync(); if (instance == null) { continue; } if (instance is IFeatureClass && ((IFeatureClass)instance).Dataset != null && ((IFeatureClass)instance).Dataset.Database is IImplementsBinarayTreeDef) { IFeatureClass fc = (IFeatureClass)instance; IImplementsBinarayTreeDef fdb = (IImplementsBinarayTreeDef)fc.Dataset.Database; BinaryTreeDef def = await fdb.BinaryTreeDef(fc.Name); if (def != null) { if (bounds == null) { bounds = new Envelope(def.Bounds); } else { bounds.Union(def.Bounds); } levels = Math.Max(levels, def.MaxLevel); } } } if (bounds != null) { this.Extent = bounds; this.Levels = levels; } } }
public void OnEvent(object element, object dataset) { if (!(element is IFeatureLayer)) { MessageBox.Show("Item is not a featurelayer"); return; } if (((IFeatureLayer)element).FeatureClass == null) { MessageBox.Show("Item has not a valid featureclass!"); return; } List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenRendererFilter(((IFeatureLayer)element).FeatureClass.GeometryType)); ExplorerDialog dlg = new ExplorerDialog("Open Featurelayer...", filters, true); dlg.MulitSelection = false; if (dlg.ShowDialog() == DialogResult.OK) { IExplorerObject exObject = dlg.ExplorerObjects[0]; if (!(exObject.Object is ITOCElement)) { return; } IFeatureLayer source = ((ITOCElement)exObject.Object).Layers[0] as IFeatureLayer; if (source == null) { return; } IFeatureLayer dest = (IFeatureLayer)element; Dialogs.FormImportRenderers dlg2 = new Dialogs.FormImportRenderers(); if (dlg2.ShowDialog() == DialogResult.OK) { if (dlg2.FeatureRenderer) { dest.FeatureRenderer = source.FeatureRenderer; } if (dlg2.LabelRenderer) { dest.LabelRenderer = source.LabelRenderer; } if (dlg2.SelectionRenderer) { dest.SelectionRenderer = source.SelectionRenderer; } } } }
async public Task <IExplorerObject> CreateExplorerObject(IExplorerObject parentExObject) { SQLiteFDBDatasetExplorerObject parent = (SQLiteFDBDatasetExplorerObject)parentExObject; IFeatureDataset dataset = await parent.GetInstanceAsync() as IFeatureDataset; if (dataset == null) { return(null); } AccessFDB fdb = dataset.Database as AccessFDB; if (fdb == null) { return(null); } List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureclassFilter()); ExplorerDialog dlg = new ExplorerDialog("Select Featureclass", filters, true); IExplorerObject ret = null; if (dlg.ShowDialog() == DialogResult.OK && dlg.ExplorerObjects != null) { foreach (IExplorerObject exObj in dlg.ExplorerObjects) { var exObjectInstance = await exObj?.GetInstanceAsync(); if (exObjectInstance is IFeatureClass) { int fcid = await fdb.CreateLinkedFeatureClass(dataset.DatasetName, (IFeatureClass)exObjectInstance); if (ret == null) { IDatasetElement element = await dataset.Element(((IFeatureClass)exObjectInstance).Name); if (element != null) { ret = new SQLiteFDBFeatureClassExplorerObject( parent, parent.FileName, parent.Name, element); } } } } } return(ret); }
async private void contextItem_ImportFields_Click(object sender, EventArgs e) { var alterTable = await GetAlterTable(); if (alterTable == null) { MessageBox.Show("Change properties is not implemented for this feature..."); return; } var tableClass = await _exObject?.GetInstanceAsync() as ITableClass; if (tableClass == null) { return; } List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureclassFilter()); ExplorerDialog dlg = new ExplorerDialog("Open Featureclass", filters, true); dlg.MulitSelection = false; if (dlg.ShowDialog() == DialogResult.OK && dlg.ExplorerObjects != null && dlg.ExplorerObjects.Count == 1) { var dlgTableClass = await dlg.ExplorerObjects[0].GetInstanceAsync() as ITableClass; if (dlgTableClass != null) { ITableClass tcFrom = dlgTableClass; ITableClass tcTo = tableClass; FormSelectFields selDlg = new FormSelectFields(tcFrom, tcTo); if (selDlg.ShowDialog() == DialogResult.OK) { foreach (IField field in selDlg.SelectedFields) { if (!await alterTable.AlterTable(_exObject.Name, null, new Field(field))) { MessageBox.Show("ERROR :" + ((alterTable is IDatabase) ? ((IDatabase)alterTable).LastErrorMessage : "")); break; } } await this.OnShow(); } } } }
public IExplorerObject CreateExplorerObject(IExplorerObject parentExObject) { SqlFDBDatasetExplorerObject parent = (SqlFDBDatasetExplorerObject)parentExObject; IFeatureDataset dataset = parent.Object as IFeatureDataset; if (dataset == null) { return(null); } AccessFDB fdb = dataset.Database as AccessFDB; if (fdb == null) { return(null); } List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureclassFilter()); ExplorerDialog dlg = new ExplorerDialog("Select Featureclass", filters, true); IExplorerObject ret = null; if (dlg.ShowDialog() == DialogResult.OK && dlg.ExplorerObjects != null) { foreach (IExplorerObject exObj in dlg.ExplorerObjects) { if (exObj.Object is IFeatureClass) { int fcid = fdb.CreateLinkedFeatureClass(dataset.DatasetName, (IFeatureClass)exObj.Object); if (ret == null) { IDatasetElement element = dataset[((IFeatureClass)exObj.Object).Name]; if (element != null) { ret = new AccessFDBFeatureClassExplorerObject( parentExObject as AccessFDBDatasetExplorerObject, ((AccessFDBDatasetExplorerObject)parentExObject).FileName, parentExObject.Name, element); } } } } } return(ret); }
private void btnSelect_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureDatasetFilter()); ExplorerDialog exDlg = new ExplorerDialog("New Target Featureclass", SaveFeatureClassFilters.DatabaseFilters, false); if (exDlg.ShowDialog() == DialogResult.OK && exDlg.ExplorerObjects.Count == 1) { IExplorerObject parentObject = exDlg.ExplorerObjects[0]; if (parentObject.Object is IFeatureDataset && ((IDataset)parentObject.Object).Database is IFeatureUpdater) { _dataset = (IFeatureDataset)parentObject.Object; } else if (exDlg.SelectedExplorerDialogFilter.FilterObject is IFeatureDataset && ((IDataset)exDlg.SelectedExplorerDialogFilter.FilterObject).Database is IFileFeatureDatabase) { IFileFeatureDatabase fileDB = (IFileFeatureDatabase)((IFeatureDataset)exDlg.SelectedExplorerDialogFilter.FilterObject).Database; _dataset = fileDB[parentObject.FullName]; } else { MessageBox.Show("Can't determine target featureclass!"); return; } if (!(_dataset.Database is IFeatureDatabaseReplication)) { MessageBox.Show("Can't checkout to this database..."); return; } txtDatasetName.Text = _dataset.Database.ToString(); txtDatasetLocation.Text = parentObject.FullName; txtTargetClass.Text = exDlg.TargetName; } btnCheckout.Enabled = btnScript.Enabled = exDlg.TargetName != String.Empty; }
private void contextItem_ImportFields_Click(object sender, EventArgs e) { if (AlterTable == null) { MessageBox.Show("Change properties is not implemented for this feature..."); return; } if (_exObject == null || !(_exObject.Object is ITableClass)) { return; } List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureclassFilter()); ExplorerDialog dlg = new ExplorerDialog("Open Featureclass", filters, true); dlg.MulitSelection = false; if (dlg.ShowDialog() == DialogResult.OK && dlg.ExplorerObjects != null && dlg.ExplorerObjects.Count == 1 && dlg.ExplorerObjects[0].Object is ITableClass) { ITableClass tcFrom = dlg.ExplorerObjects[0].Object as ITableClass; ITableClass tcTo = _exObject.Object as ITableClass; FormSelectFields selDlg = new FormSelectFields(tcFrom, tcTo); if (selDlg.ShowDialog() == DialogResult.OK) { foreach (IField field in selDlg.SelectedFields) { if (!AlterTable.AlterTable(_exObject.Name, null, new Field(field))) { MessageBox.Show("ERROR :" + ((AlterTable is IDatabase) ? ((IDatabase)AlterTable).lastErrorMsg : "")); break; } } this.OnShow(); } } }
void SharePointButton_Click(object sender, EventArgs e) { ExplorerDialog dialog = new ExplorerDialog(); dialog.explorer.Url = SquadronContext.Url; bool result = dialog.ExecuteDialog(); if (result) { _selectedAll = false; _selectedObjects = dialog.SelectedObjects; this.Text = "SharePoint Objects: " + _selectedObjects.Count.ToString(); if (OnSelectionChanged != null) { OnSelectionChanged(this); } } }
async private void btnSelect_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureDatasetFilter()); ExplorerDialog exDlg = new ExplorerDialog("New Target Featureclass", SaveFeatureClassFilters.AllFilters, false); if (exDlg.ShowDialog() == DialogResult.OK && exDlg.ExplorerObjects.Count == 1) { IExplorerObject parentObject = exDlg.ExplorerObjects[0]; var instance = await parentObject.GetInstanceAsync(); if (instance is IFeatureDataset && ((IDataset)instance).Database is IFeatureUpdater) { _dataset = (IFeatureDataset)instance; } else if (exDlg.SelectedExplorerDialogFilter.FilterObject is IFeatureDataset && ((IDataset)exDlg.SelectedExplorerDialogFilter.FilterObject).Database is IFileFeatureDatabase) { IFileFeatureDatabase fileDB = (IFileFeatureDatabase)((IFeatureDataset)exDlg.SelectedExplorerDialogFilter.FilterObject).Database; _dataset = await fileDB.GetDataset(parentObject.FullName); } else { MessageBox.Show("Can't determine target featureclass!"); return; } txtDatasetName.Text = _dataset.Database.ToString(); txtDatasetLocation.Text = parentObject.FullName; txtTargetClass.Text = _listViewItem.TargetName = exDlg.TargetName; } btnNext.Enabled = exDlg.TargetName != String.Empty; }
protected override void OnEvent() { base.OnEvent(); List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureDatasetOrFolder()); ExplorerDialog exDlg = new ExplorerDialog("New Target Featureclass", filters, true); if (exDlg.ShowDialog() == DialogResult.OK && exDlg.ExplorerObjects.Count == 1) { if (_exapp.MoveToTreeNode(exDlg.ExplorerObjects[0].FullName)) { Paste paste = new Paste(); //var data = Clipboard.GetDataObject(); //var task = Task.Run(async () => // { // await Task.Delay(3000); // if (Clipboard.GetDataObject()==null) // { // Clipboard.SetDataObject(data); // } // paste.OnCreate(_exapp); // await paste.OnEvent(null); // }); paste.OnCreate(_exapp); paste.OnEvent(null); } } }
protected override void OnEvent() { base.OnEvent(); List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenFeatureDatasetOrFolder()); ExplorerDialog exDlg = new ExplorerDialog("New Target Featureclass", filters, true); if (exDlg.ShowDialog() == DialogResult.OK && exDlg.ExplorerObjects.Count == 1) { if (_exapp.MoveToTreeNode(exDlg.ExplorerObjects[0].FullName)) { Paste paste = new Paste(); paste.OnCreate(_exapp); paste.OnEvent(null); } } }
async private void btnImport_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenDataFilter()); ExplorerDialog dlg = new ExplorerDialog("Import Extent", filters, true); dlg.MulitSelection = true; ISpatialReference sRef = SpatialReference.FromID("epsg:" + cmbEpsgs.SelectedItem.ToString()); if (dlg.ShowDialog() == DialogResult.OK) { IEnvelope bounds = null; foreach (IExplorerObject exObject in dlg.ExplorerObjects) { var objectInstance = await exObject?.GetInstanceAsync(); if (objectInstance == null) { continue; } IEnvelope objEnvelope = null; if (objectInstance is IDataset) { foreach (IDatasetElement element in await((IDataset)objectInstance).Elements()) { if (element == null) { continue; } objEnvelope = ClassEnvelope(element.Class, sRef); } } else { objEnvelope = ClassEnvelope(objectInstance as IClass, sRef); } if (objEnvelope != null) { if (bounds == null) { bounds = new Envelope(objEnvelope); } else { bounds.Union(objEnvelope); } } } if (bounds != null) { this.CurrentEpsgExtent = bounds; } } if (_metadata != null && cmbEpsgs.SelectedIndex >= 0) { _metadata.SetEPSGEnvelope(_currentEpsg, this.CurrentEpsgExtent); } }
async public Task <bool> OnEvent(object element, object dataset) { if (!(element is IFeatureLayer)) { MessageBox.Show("Item is not a featurelayer"); return(true); } if (((IFeatureLayer)element).FeatureClass == null) { MessageBox.Show("Item has not a valid featureclass!"); return(true); } List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenRendererFilter(((IFeatureLayer)element).FeatureClass.GeometryType)); ExplorerDialog dlg = new ExplorerDialog("Open Featurelayer...", filters, true); dlg.MulitSelection = false; if (dlg.ShowDialog() == DialogResult.OK) { IExplorerObject exObject = dlg.ExplorerObjects[0]; var instatnce = await exObject?.GetInstanceAsync(); if (!(instatnce is ITOCElement)) { return(true); } IFeatureLayer source = ((ITOCElement)instatnce).Layers[0] as IFeatureLayer; if (source == null) { return(true); } IFeatureLayer dest = (IFeatureLayer)element; Dialogs.FormImportRenderers dlg2 = new Dialogs.FormImportRenderers(); if (dlg2.ShowDialog() == DialogResult.OK) { if (dlg2.FeatureRenderer) { dest.FeatureRenderer = source.FeatureRenderer; } if (dlg2.LabelRenderer) { dest.LabelRenderer = source.LabelRenderer; } if (dlg2.SelectionRenderer) { dest.SelectionRenderer = source.SelectionRenderer; } if (dlg2.RenderScales) { dest.MinimumScale = source.MinimumScale; dest.MaximumScale = source.MaximumScale; if (dlg2.FeatureRenderer) { dest.MaxRefScaleFactor = source.MaxRefScaleFactor; } } if (dlg2.LabelScales) { dest.MinimumLabelScale = source.MinimumLabelScale; dest.MaximumLabelScale = source.MaximumLabelScale; if (dlg2.LabelRenderer) { dest.MaxLabelRefScaleFactor = source.MaxLabelRefScaleFactor; } } if (dlg2.FilterQuery) { dest.FilterQuery = source.FilterQuery; } } } return(true); }
private void btnAdd_Click(object sender, EventArgs e) { List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); if (_open) { filters.Add(new OpenActivityDataFilter(_aData)); } else { filters = SaveFeatureClassFilters.AllFilters; } ExplorerDialog dlg = new ExplorerDialog(gbDataName.Text, filters, _open); if (dlg.ShowDialog() == DialogResult.OK && dlg.ExplorerObjects != null && dlg.ExplorerObjects.Count > 0) { object item = null; foreach (IExplorerObject exObject in dlg.ExplorerObjects) { if (exObject == null) { continue; } if (_open) // Source { if (exObject.Object is IDatasetElement) { item = new DatasetElementItem((IDatasetElement)exObject.Object); cmbData.Items.Add(item); } else if (exObject.Object is IClass) { item = new DatasetElementItem(new DatasetElement((IClass)exObject.Object)); cmbData.Items.Add(item); } } else // Target { if (exObject.Object is IDataset && !String.IsNullOrEmpty(dlg.TargetName)) { item = new DatasetItem((IDataset)exObject.Object, dlg.TargetName); cmbData.Items.Add(item); } else if (dlg.SelectedExplorerDialogFilter != null && dlg.SelectedExplorerDialogFilter.FilterObject is IFeatureDataset && !String.IsNullOrEmpty(dlg.TargetName)) { IFileFeatureDatabase fileDB = (IFileFeatureDatabase)((IFeatureDataset)dlg.SelectedExplorerDialogFilter.FilterObject).Database; IFeatureDataset ds = fileDB[exObject.FullName]; if (ds != null) { item = new DatasetItem(ds, dlg.TargetName); cmbData.Items.Add(item); } } } } // letztes eingefügtes auswählen if (item != null) { cmbData.SelectedItem = item; } } }
public void OnEvent(object MapEvent) { if (!(MapEvent is MapEvent)) { return; } IMap map = ((MapEvent)MapEvent).Map; bool firstDataset = (map[0] == null); List <ExplorerDialogFilter> filters = new List <ExplorerDialogFilter>(); filters.Add(new OpenDataFilter()); ExplorerDialog dlg = new ExplorerDialog("Add data...", filters, true); if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { List <IDataset> datasets = dlg.Datasets; FormDatasetProperties datasetProps = new FormDatasetProperties(datasets); try { if (((MapEvent)MapEvent).UserData == null) { if (datasetProps.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } } } catch // Kann ObjectDisposed Exception werfen... { return; } Envelope env = null; foreach (ILayer layer in datasetProps.Layers) { ISpatialReference sRef = null; IEnvelope classEnv = null; if (layer is IFeatureLayer && ((IFeatureLayer)layer).FeatureClass != null && ((IFeatureLayer)layer).FeatureClass.Envelope != null) { sRef = ((IFeatureLayer)layer).FeatureClass.SpatialReference; classEnv = ((IFeatureLayer)layer).FeatureClass.Envelope; } else if (layer is IRasterLayer && ((IRasterLayer)layer).RasterClass != null && ((IRasterLayer)layer).RasterClass.Polygon != null && ((IRasterLayer)layer).RasterClass.Polygon.Envelope != null) { sRef = ((IRasterLayer)layer).RasterClass.SpatialReference; classEnv = ((IRasterLayer)layer).RasterClass.Polygon.Envelope; } else if (layer is IWebServiceLayer && ((IWebServiceLayer)layer).WebServiceClass != null && ((IWebServiceLayer)layer).WebServiceClass.Envelope != null) { sRef = ((IWebServiceLayer)layer).WebServiceClass.SpatialReference; classEnv = ((IWebServiceLayer)layer).WebServiceClass.Envelope; } if (classEnv != null) { if (sRef != null && !sRef.Equals(map.Display.SpatialReference)) { bool found = false; foreach (string p in map.Display.SpatialReference.Parameters) { if (p.ToLower().Trim() == "+nadgrids=@null") { found = false; } } if (found) { classEnv = null; } else { IGeometry geom = GeometricTransformer.Transform2D(classEnv.ToPolygon(0), sRef, map.Display.SpatialReference); if (geom != null) { classEnv = geom.Envelope; } else { classEnv = null; } } } if (classEnv != null) { if (env == null) { env = new Envelope(classEnv); } else { env.Union(classEnv); } } } map.AddLayer(layer); } //map.AddDataset(dataset, 0); if (env != null && map.Display != null) { if (firstDataset) { map.Display.Limit = env; map.Display.ZoomTo(env); } else { IEnvelope limit = map.Display.Limit; limit.Union(env); map.Display.Limit = limit; } } ((MapEvent)MapEvent).drawPhase = DrawPhase.All; ((MapEvent)MapEvent).refreshMap = true; } }