internal static Envelope ToRBushEnvelope(this ArcGIS.Core.Geometry.Envelope esriEnvelope) { //Spatial index does not handle Z return(new Envelope( minX: esriEnvelope.XMin, minY: esriEnvelope.YMin, maxX: esriEnvelope.XMax, maxY: esriEnvelope.YMax)); }
/// Bookmark.GetDefinition(), Bookmark.SetDefinition(CIMBookmark) /// <example> /// <code title="Set Bookmark Definition" description="Update the definition of a bookmark using a new extent." region="Update Extent for a Bookmark" source="..\..\ArcGIS\SharedArcGIS\SDK\Examples\ArcGIS.Desktop.Mapping\MapExploration\Bookmark_Examples.cs" lang="CS"/> /// </example> #region Update Extent for a Bookmark public Task UpdateBookmarkExtentAsync(Bookmark bookmark, ArcGIS.Core.Geometry.Envelope envelope) { return(QueuedTask.Run(() => { //Get the bookmark's definition var bookmarkDef = bookmark.GetDefinition(); //Modify the bookmark's location bookmarkDef.Location = envelope; //Clear the camera as it is no longer valid. bookmarkDef.Camera = null; //Set the bookmark definition bookmark.SetDefinition(bookmarkDef); })); }
protected async override void OnClick() { var catalog = Project.GetCatalogPane(); var items = catalog.SelectedItems; var ProDataSubItems = items.OfType <ProDataSubItem>(); foreach (var item in ProDataSubItems) { try { await QueuedTask.Run(() => { switch (item.SubItemType) { case ProDataSubItem.EnumSubItemType.DirType: break; case ProDataSubItem.EnumSubItemType.GpxType: var conGpx = new PluginDatasourceConnectionPath("ProGpxPluginDatasource", new Uri(item.Path, UriKind.Absolute)); var groupLayer = LayerFactory.Instance.CreateGroupLayer(MapView.Active.Map, 0, Path.GetFileNameWithoutExtension(item.Path)); ArcGIS.Core.Geometry.Envelope zoomToEnv = null; using (var pluginGpx = new PluginDatastore(conGpx)) { System.Diagnostics.Debug.Write($"Table: {item.Path}\r\n"); // because this is a GPX file we have both line and point variations // we add them in a group layer foreach (var tn in pluginGpx.GetTableNames()) { using (var table = pluginGpx.OpenTable(tn)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, groupLayer); zoomToEnv = ((FeatureClass)table).GetExtent().Clone() as ArcGIS.Core.Geometry.Envelope; } } } if (zoomToEnv != null) { MapView.Active.ZoomToAsync(zoomToEnv); } break; case ProDataSubItem.EnumSubItemType.ImgDirType: case ProDataSubItem.EnumSubItemType.ImgType: var conJpg = new PluginDatasourceConnectionPath("ProJpgPluginDatasource", new Uri(item.Path, UriKind.Absolute)); using (var pluginJpg = new PluginDatastore(conJpg)) { System.Diagnostics.Debug.Write($"Table: {item.Path}\r\n"); //open each table....use the returned table name //or just pass in the name of a csv file in the workspace folder foreach (var tn in pluginJpg.GetTableNames()) { using (var table = pluginJpg.OpenTable(tn)) { //Add as a layer to the active map or scene LayerFactory.Instance.CreateFeatureLayer((FeatureClass)table, MapView.Active.Map); } } } break; } }); } catch (Exception ex) { MessageBox.Show($@"Unable to add to map: {ex.Message}"); } } }