From 07e2cd67430c2cf3e25c988ac0519077ac55b03e Mon Sep 17 00:00:00 2001 From: uma2526 Date: Tue, 21 Jun 2022 12:18:52 -0700 Subject: [PATCH] ArcGIS Pro 3.0 SDK for .NET --- DAML/ADCore.daml.xml | 218 +- DAML/ADGeoDatabase.daml.xml | 1784 ++++++---- DAML/ADGeoProcessing.daml.xml | 391 ++- DAML/ADMapping.daml.xml | 1118 +++--- DAML/ADWorkflow.daml.xml | 115 +- DAML/ArcGISLayout.daml.xml | 525 ++- DAML/DataReviewer.daml.xml | 140 +- DAML/Editing.daml.xml | 649 +++- DAML/NetworkAnalysisFacility.daml.xml | 790 ----- DAML/NetworkAnalysisUtilityNetwork.daml.xml | 5 +- DAML/TaskAssistant.daml.xml | 27 +- Examples/Common/ArcGIS-References.lua | 42 - Examples/Common/System-References.lua | 24 - Examples/Content.csproj | 199 -- Examples/Content/BrowseDialogCodeSamples.cs | 13 +- Examples/Content/CatalogCodeSamples.cs | 425 +-- Examples/Content/Content.csproj | 80 + Examples/Content/ProSnippets.cs | 2279 ++++++------ Examples/CoreHost.csproj | 197 -- Examples/CoreHost/CoreHost.csproj | 80 + Examples/CoreHost/ProSnippets.cs | 5 +- Examples/Editing.csproj | 201 -- Examples/Editing/Attributes.cs | 96 - Examples/Editing/Concepts.cs | 23 +- Examples/Editing/Editing.csproj | 80 + Examples/Editing/Events.cs | 169 - Examples/Editing/ProSnippet.cs | 957 +++-- Examples/Editing/ProSnippetCS6.cs | 218 +- Examples/Framework.csproj | 198 -- Examples/Framework/Framework.csproj | 80 + Examples/Framework/ProSnippets.cs | 626 ++-- Examples/GeoProcessing.csproj | 198 -- Examples/Geodatabase/Feature/FeatureStore.cs | 4 +- .../FeatureClass/FeatureClassCreateRow.cs | 8 +- .../FeatureClass/FeatureClassSearch.cs | 4 +- .../FeatureClass/FeatureClassSelect.cs | 10 +- .../FeatureClass/FeatureClassValidate.cs | 10 +- .../FeatureDatasetOpenDataset.cs | 4 +- ...reServiceOpenRelationshipClassByLayerID.cs | 6 +- .../Geodatabase/GeodatabaseApplyEdits.cs | 2 +- .../Geodatabase/GeodatabaseGetDefinition.cs | 2 +- .../Geodatabase/GeodatabaseOpenFile.cs | 163 +- Examples/Geodatabase/GeodatabaseSDK.csproj | 80 + Examples/Geodatabase/ProSnippets.cs | 1291 +++++-- .../RelationshipClassCreateRelationship.cs | 2 +- .../RelationshipClassDeleteRelationship.cs | 2 +- Examples/Geodatabase/Row/RowOriginalValue.cs | 17 +- Examples/Geodatabase/Row/RowValueChanged.cs | 2 +- .../Geodatabase/Selection/SelectionAdd.cs | 4 +- .../Geodatabase/Selection/SelectionCombine.cs | 2 +- .../Geodatabase/Selection/SelectionRemove.cs | 2 +- .../Geodatabase/Selection/SelectionSearch.cs | 2 +- .../Geodatabase/Selection/SelectionSelect.cs | 2 +- Examples/Geodatabase/Table/TableCreateRow.cs | 4 +- Examples/Geodatabase/Table/TableSearch.cs | 4 +- Examples/Geodatabase/Table/TableSelect.cs | 8 +- Examples/Geodatabase/Table/TableValidate.cs | 2 +- .../Topology/ProSnippetTopology.cs | 77 +- Examples/GeodatabaseSDK.csproj | 245 -- Examples/Geometry.csproj | 199 -- Examples/Geometry/Geometry.csproj | 84 + Examples/Geometry/GeometryCodeExamples.cs | 69 - Examples/Geometry/ProSnippets.cs | 3097 ++++++++--------- .../Geometry/ProSnippetsGeometryEngine.cs | 1538 ++++---- Examples/Geoprocessing/GeoProcessing.csproj | 80 + .../Geoprocessing/Geoprocessing_Examples.cs | 53 +- Examples/Geoprocessing/ProSnippets.cs | 125 +- Examples/GraphicsLayers.csproj | 198 -- Examples/GraphicsLayers.lua | 23 - Examples/GraphicsLayers/GraphicsLayers.csproj | 80 + Examples/GraphicsLayers/ProSnippet.cs | 116 +- .../GraphicsLayers/Properties/AssemblyInfo.cs | 36 - Examples/Layouts.csproj | 212 -- Examples/Layouts/ElementClass.cs | 431 ++- Examples/Layouts/ExportCodeSamples.cs | 252 +- Examples/Layouts/GraphicElementClass.cs | 278 +- Examples/Layouts/LayoutClass.cs | 43 +- Examples/Layouts/LayoutEvents.cs | 705 +++- Examples/Layouts/LayoutFactory.cs | 282 +- Examples/Layouts/LayoutProjectItemClass.cs | 7 +- Examples/Layouts/LayoutViewClass.cs | 79 +- Examples/Layouts/Layouts.csproj | 80 + Examples/Layouts/MapFrameClass.cs | 38 +- Examples/Layouts/MapSeries.cs | 42 +- Examples/Layouts/MapSurroundClass.cs | 36 +- Examples/Layouts/MethodSnippets.cs | 59 +- Examples/Layouts/PictureElementClass.cs | 147 +- Examples/Layouts/ProSnippets.cs | 2803 +++++++++++++-- Examples/Layouts/ProSnippetsReports.cs | 597 ++-- Examples/Layouts/TextElementClass.cs | 32 +- Examples/MapAuthoring.csproj | 203 -- .../CartoFeatures/Carto_SDK_Examples.cs | 350 +- .../MapAuthoring/CartoFeatures/ProSnippet.cs | 1562 +++++---- Examples/MapAuthoring/MapAuthoring.csproj | 85 + Examples/MapAuthoring/ProSnippet.cs | 1402 ++++++-- Examples/MapAuthoring/ProSnippetAnnotation.cs | 150 +- Examples/MapAuthoring/ProSnippetLabeling.cs | 887 ++--- Examples/MapAuthoring/ProSnippetRealtime.cs | 216 +- .../MapAuthoring/ProSnippetVoxelLayers.cs | 570 ++- Examples/MapExploration.csproj | 244 -- Examples/MapExploration/Animation_Examples.cs | 269 -- Examples/MapExploration/BookmarkDockPane.xaml | 80 - .../MapExploration/BookmarkDockPane.xaml.cs | 58 - .../BookmarkDockPaneViewModel.cs | 114 - Examples/MapExploration/Bookmark_Examples.cs | 263 -- Examples/MapExploration/CameraDockPane.xaml | 97 - .../MapExploration/CameraDockPane.xaml.cs | 42 - .../MapExploration/CameraDockPaneViewModel.cs | 133 - Examples/MapExploration/Camera_Examples.cs | 73 - Examples/MapExploration/Config.daml | 71 - Examples/MapExploration/CustomIdentify.cs | 60 - .../MapExploration/EmbeddableControl.daml | 35 - Examples/MapExploration/EmbeddedControl.xaml | 29 - .../MapExploration/EmbeddedControl.xaml.cs | 47 - .../EmbeddedControlViewModel.cs | 50 - Examples/MapExploration/GetMapCoordinates.cs | 48 - Examples/MapExploration/MapExploration.csproj | 80 + Examples/MapExploration/MapTool_Examples.cs | 149 - Examples/MapExploration/MapView_Examples.cs | 716 ---- Examples/MapExploration/Module1.cs | 115 - Examples/MapExploration/Popup_Examples.cs | 155 - Examples/MapExploration/ProSnippet.cs | 2236 ++++++++---- Examples/MapExploration/Time_Examples.cs | 50 - Examples/ParcelFabric.csproj | 197 -- Examples/ParcelFabric/ParcelFabric.csproj | 80 + Examples/ParcelFabric/ProSnippets.cs | 167 +- Examples/Properties/AssemblyInfo.cs | 54 - Examples/Raster.csproj | 197 -- Examples/Raster/ProSnippet.cs | 471 +-- Examples/Raster/Raster.csproj | 80 + Examples/Resources/red_cursor.ani | Bin 51596 -> 0 bytes Examples/SDKExamples2019.sln | 122 - ...DKExamples2017.sln => SDKExamples2022.sln} | 249 +- Examples/SceneLayers.csproj | 202 -- Examples/SceneLayers/ProSnippets.cs | 14 +- ...ProSnippetsBuildingSceneLayerDiscipline.cs | 18 +- .../ProSnippetsBuildingSceneLayerFilter.cs | 70 +- .../ProSnippetsEditingFeatureSceneLayer.cs | 15 +- .../ProSnippetsFeatureSceneLayer.cs | 61 +- .../ProSnippetsPointCloudSceneLayer.cs | 165 +- Examples/SceneLayers/SceneLayers.csproj | 80 + Examples/Sharing.csproj | 198 -- Examples/Sharing/ProSnippets.cs | 234 +- Examples/Sharing/ProSnippetsCS6.cs | 680 ++-- Examples/Sharing/Sharing.csproj | 83 + Examples/Task.csproj | 206 -- Examples/Tasks/CloseTask.cs | 44 - Examples/Tasks/ExportTask.cs | 50 - Examples/Tasks/GetTaskItemInfo.cs | 58 - Examples/Tasks/GetTasks.cs | 49 - Examples/Tasks/OpenSpecificTask.cs | 69 - Examples/Tasks/OpenTask.cs | 46 - Examples/Tasks/OpenTaskItem.cs | 48 - Examples/Tasks/ProSnippets.cs | 226 +- Examples/Tasks/ProjectItem_GetTaskItemInfo.cs | 81 - Examples/Tasks/Task.csproj | 80 + Examples/Tasks/TaskEvents.cs | 68 - Examples/UtilityNetwork.csproj | 197 -- Examples/UtilityNetwork/ProSnippets.cs | 560 ++- Examples/UtilityNetwork/UtilityNetwork.csproj | 81 + Examples/WorkflowManager.csproj | 197 -- Examples/WorkflowManager/Prosnippets.cs | 392 ++- .../WorkflowManager/WorkflowManager.csproj | 80 + Examples/packages.config | 4 - Examples/premake5.exe | Bin 1362432 -> 0 bytes README.md | 263 +- 166 files changed, 22624 insertions(+), 19983 deletions(-) delete mode 100644 DAML/NetworkAnalysisFacility.daml.xml delete mode 100644 Examples/Common/ArcGIS-References.lua delete mode 100644 Examples/Common/System-References.lua delete mode 100644 Examples/Content.csproj create mode 100644 Examples/Content/Content.csproj delete mode 100644 Examples/CoreHost.csproj create mode 100644 Examples/CoreHost/CoreHost.csproj delete mode 100644 Examples/Editing.csproj delete mode 100644 Examples/Editing/Attributes.cs create mode 100644 Examples/Editing/Editing.csproj delete mode 100644 Examples/Editing/Events.cs delete mode 100644 Examples/Framework.csproj create mode 100644 Examples/Framework/Framework.csproj delete mode 100644 Examples/GeoProcessing.csproj create mode 100644 Examples/Geodatabase/GeodatabaseSDK.csproj delete mode 100644 Examples/GeodatabaseSDK.csproj delete mode 100644 Examples/Geometry.csproj create mode 100644 Examples/Geometry/Geometry.csproj delete mode 100644 Examples/Geometry/GeometryCodeExamples.cs create mode 100644 Examples/Geoprocessing/GeoProcessing.csproj delete mode 100644 Examples/GraphicsLayers.csproj delete mode 100644 Examples/GraphicsLayers.lua create mode 100644 Examples/GraphicsLayers/GraphicsLayers.csproj delete mode 100644 Examples/GraphicsLayers/Properties/AssemblyInfo.cs delete mode 100644 Examples/Layouts.csproj create mode 100644 Examples/Layouts/Layouts.csproj delete mode 100644 Examples/MapAuthoring.csproj create mode 100644 Examples/MapAuthoring/MapAuthoring.csproj delete mode 100644 Examples/MapExploration.csproj delete mode 100644 Examples/MapExploration/Animation_Examples.cs delete mode 100644 Examples/MapExploration/BookmarkDockPane.xaml delete mode 100644 Examples/MapExploration/BookmarkDockPane.xaml.cs delete mode 100644 Examples/MapExploration/BookmarkDockPaneViewModel.cs delete mode 100644 Examples/MapExploration/Bookmark_Examples.cs delete mode 100644 Examples/MapExploration/CameraDockPane.xaml delete mode 100644 Examples/MapExploration/CameraDockPane.xaml.cs delete mode 100644 Examples/MapExploration/CameraDockPaneViewModel.cs delete mode 100644 Examples/MapExploration/Camera_Examples.cs delete mode 100644 Examples/MapExploration/Config.daml delete mode 100644 Examples/MapExploration/CustomIdentify.cs delete mode 100644 Examples/MapExploration/EmbeddableControl.daml delete mode 100644 Examples/MapExploration/EmbeddedControl.xaml delete mode 100644 Examples/MapExploration/EmbeddedControl.xaml.cs delete mode 100644 Examples/MapExploration/EmbeddedControlViewModel.cs delete mode 100644 Examples/MapExploration/GetMapCoordinates.cs create mode 100644 Examples/MapExploration/MapExploration.csproj delete mode 100644 Examples/MapExploration/MapTool_Examples.cs delete mode 100644 Examples/MapExploration/MapView_Examples.cs delete mode 100644 Examples/MapExploration/Module1.cs delete mode 100644 Examples/MapExploration/Popup_Examples.cs delete mode 100644 Examples/MapExploration/Time_Examples.cs delete mode 100644 Examples/ParcelFabric.csproj create mode 100644 Examples/ParcelFabric/ParcelFabric.csproj delete mode 100644 Examples/Properties/AssemblyInfo.cs delete mode 100644 Examples/Raster.csproj create mode 100644 Examples/Raster/Raster.csproj delete mode 100644 Examples/Resources/red_cursor.ani delete mode 100644 Examples/SDKExamples2019.sln rename Examples/{SDKExamples2017.sln => SDKExamples2022.sln} (64%) delete mode 100644 Examples/SceneLayers.csproj create mode 100644 Examples/SceneLayers/SceneLayers.csproj delete mode 100644 Examples/Sharing.csproj create mode 100644 Examples/Sharing/Sharing.csproj delete mode 100644 Examples/Task.csproj delete mode 100644 Examples/Tasks/CloseTask.cs delete mode 100644 Examples/Tasks/ExportTask.cs delete mode 100644 Examples/Tasks/GetTaskItemInfo.cs delete mode 100644 Examples/Tasks/GetTasks.cs delete mode 100644 Examples/Tasks/OpenSpecificTask.cs delete mode 100644 Examples/Tasks/OpenTask.cs delete mode 100644 Examples/Tasks/OpenTaskItem.cs delete mode 100644 Examples/Tasks/ProjectItem_GetTaskItemInfo.cs create mode 100644 Examples/Tasks/Task.csproj delete mode 100644 Examples/Tasks/TaskEvents.cs delete mode 100644 Examples/UtilityNetwork.csproj create mode 100644 Examples/UtilityNetwork/UtilityNetwork.csproj delete mode 100644 Examples/WorkflowManager.csproj create mode 100644 Examples/WorkflowManager/WorkflowManager.csproj delete mode 100644 Examples/packages.config delete mode 100644 Examples/premake5.exe diff --git a/DAML/ADCore.daml.xml b/DAML/ADCore.daml.xml index 5a2695e..a153c1a 100644 --- a/DAML/ADCore.daml.xml +++ b/DAML/ADCore.daml.xml @@ -26,16 +26,14 @@ + + + + + + - - - - - - - - - + @@ -76,6 +74,7 @@ + @@ -157,25 +156,33 @@ + + + + + + + + - - - - + + + - + + @@ -232,7 +239,6 @@ - @@ -248,7 +254,7 @@ - + @@ -316,8 +322,9 @@ - + @@ -488,15 +505,16 @@ With the Catalog view you can sort items, preview spatial data, edit an item’s caption="Remove" extendedCaption="Remove the item from the project." smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericDeleteBlack16.png"> - Remove the selected items from the project. The references to the items are removed from the project. The selected items are not deleted. + Remove the selected items from the project or remove the selected items from the Favorites collection. This command does not delete items. + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DAML/NetworkAnalysisUtilityNetwork.daml.xml b/DAML/NetworkAnalysisUtilityNetwork.daml.xml index 201ccf8..12bb9ea 100644 --- a/DAML/NetworkAnalysisUtilityNetwork.daml.xml +++ b/DAML/NetworkAnalysisUtilityNetwork.daml.xml @@ -32,7 +32,7 @@ - + @@ -41,9 +41,8 @@ - + - diff --git a/DAML/TaskAssistant.daml.xml b/DAML/TaskAssistant.daml.xml index 2313781..20b9ae1 100644 --- a/DAML/TaskAssistant.daml.xml +++ b/DAML/TaskAssistant.daml.xml @@ -213,15 +213,7 @@ - - - - - - - - - + - \ No newline at end of file diff --git a/Examples/Content/BrowseDialogCodeSamples.cs b/Examples/Content/BrowseDialogCodeSamples.cs index 5c4ce8d..7154983 100644 --- a/Examples/Content/BrowseDialogCodeSamples.cs +++ b/Examples/Content/BrowseDialogCodeSamples.cs @@ -40,6 +40,7 @@ public async Task BrowseDialogCodeSample() // cref: OpenItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.Filter // cref: OpenItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.InitialLocation // cref: OpenItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.Title + // cref: OpenItemDialog;ArcGIS.Desktop.Catalog.OpenItemDialog #region OpenItemDialog /// Adds a single item to a map @@ -47,7 +48,7 @@ public async Task BrowseDialogCodeSample() { Title = "Add To Map", InitialLocation = @"C:\Data\NewYork\Counties\Erie\Streets", - Filter = ItemFilters.composite_addToMap + Filter = ItemFilters.Composite_AddToMap }; #endregion //OpenItemDialog @@ -62,7 +63,7 @@ public async Task BrowseDialogCodeSample() addToProjectDialog.Title = "Add To Project"; addToProjectDialog.InitialLocation = @"C:\Data\NewYork\Counties\Maps"; addToProjectDialog.MultiSelect = true; - addToProjectDialog.Filter = ItemFilters.composite_maps_import; + addToProjectDialog.Filter = ItemFilters.Composite_Maps_Import; bool? ok = addToMapDialog.ShowDialog(); @@ -78,13 +79,14 @@ public async Task BrowseDialogCodeSample() // cref: SaveItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.Filter // cref: SaveItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.InitialLocation // cref: SaveItemDialog;ArcGIS.Desktop.Catalog.ItemDialog.Title + // cref: SaveItemDialog;ArcGIS.Desktop.Catalog.SaveItemDialog #region SaveItemDialog SaveItemDialog saveLayerFileDialog = new SaveItemDialog() { Title = "Save Layer File", InitialLocation = @"C:\Data\ProLayers\Geographic\Streets", - Filter = ItemFilters.layers_allFileTypes + Filter = ItemFilters.Files_All }; #endregion //SaveItemDialog @@ -99,7 +101,7 @@ public async Task BrowseDialogCodeSample() Title = "Save Map File", InitialLocation = @"C:\Data\NewYork\Counties\Maps", DefaultExt = @"mapx", - Filter = ItemFilters.maps_all, + Filter = ItemFilters.Maps_All, OverwritePrompt = true }; bool? result = saveMapFileDialog.ShowDialog(); @@ -111,6 +113,9 @@ public async Task BrowseDialogCodeSample() #endregion //Show_SaveItemDialog + // cref: ArcGIS.Desktop.Catalog.OpenItemDialog.Items + // cref: ArcGIS.Desktop.Catalog.OpenItemDialog + // cref: BrowseDialogItems;ArcGIS.Desktop.Mapping.MapFactory.CreateMapFromItem #region BrowseDialogItems IEnumerable selectedDialogItems = selectItemDialog.Items; diff --git a/Examples/Content/CatalogCodeSamples.cs b/Examples/Content/CatalogCodeSamples.cs index 9d536f5..3fda921 100644 --- a/Examples/Content/CatalogCodeSamples.cs +++ b/Examples/Content/CatalogCodeSamples.cs @@ -1,204 +1,221 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Core; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Desktop.Framework.Threading.Tasks; -using ArcGIS.Desktop.Internal.Core; - -namespace ArcGIS.Desktop.Catalog.ApiTests.CodeSamples -{ - class CatalogCodeSamples - { - - /// - /// Sample code for ProjectItem - /// - public async Task ProjectItemExamples() - { - // not to be included in sample regions - var projectFolderConnection = (Project.Current.GetItems()).First(); - - #region GetMapProjectItems - - /// Get all the maps in a project - IEnumerable projectMaps = Project.Current.GetItems(); - - #endregion //GetMapProjectItems - - // cref: GetFolderConnectionProjectItems;ArcGIS.Desktop.Catalog.FolderConnectionProjectItem - #region GetFolderConnectionProjectItems - - /// Get all the folder connections in a project - IEnumerable projectFolders = Project.Current.GetItems(); - - #endregion //GetFolderConnectiontProjectItems - - // cref: GetServerConnectionProjectItems;ArcGIS.Desktop.Catalog.ServerConnectionProjectItem - #region GetServerConnectionProjectItems - - /// Get all the server connections in a project - IEnumerable projectServers = Project.Current.GetItems(); - - #endregion //GetServerConnectionProjectItems - - // cref: GetLocatorConnectionProjectItems;ArcGIS.Desktop.Catalog.LocatorsConnectionProjectItem - #region GetLocatorConnectionProjectItems - - /// Get all the locator connections in a project - IEnumerable projectLocators = Project.Current.GetItems(); - - #endregion //GetLocatorConnectionProjectItems - - - #region GetProjectItemContent - - /// Get all the items that can be accessed from a folder connection. The items immediately - /// contained by a folder, that is, the folder's children, are returned including folders - /// and individual items that can be used in ArcGIS Pro. This method does not return all - /// items contained by any sub-folder that can be accessed from the folder connection. - FolderConnectionProjectItem folderConnection = Project.Current.GetItems() - .FirstOrDefault((folder => folder.Name.Equals("Data"))); - await QueuedTask.Run(() => - { - IEnumerable folderContents = folderConnection.GetItems(); - }); - #endregion //GetProjectItems - - #region AddFolderConnectionProjectItem - - /// Add a folder connection to a project - Item folderToAdd = ItemFactory.Instance.Create(@"C:\Data\Oregon\Counties\Streets"); - bool wasAdded = await QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem)); - - #endregion //AddFolderConnectionProjectItem - - // cref: AddGDBProjectItem;ArcGIS.Desktop.Catalog.GDBProjectItem - #region AddGDBProjectItem - - /// Add a file geodatabase or a SQLite or enterprise database connection to a project - Item gdbToAdd = folderToAdd.GetItems().FirstOrDefault(folderItem => folderItem.Name.Equals("CountyData.gdb")); - var addedGeodatabase = await QueuedTask.Run(() => Project.Current.AddItem(gdbToAdd as IProjectItem)); - - #endregion //AddGDBProjectItem - - - - // cref: RemoveFolderConnectionFromProject;ArcGIS.Desktop.Catalog.FolderConnectionProjectItem - #region RemoveFolderConnectionFromProject - - /// Remove a folder connection from a project; the folder stored on the local disk - /// or the network is not deleted - FolderConnectionProjectItem folderToRemove = Project.Current.GetItems().FirstOrDefault(folder => folder.Name.Equals("PlantSpecies")); - if (folderToRemove != null) - Project.Current.RemoveItem(folderToRemove as IProjectItem); - - #endregion //RemoveFolderConnectionFromProject - - #region RemoveMapFromProject - - /// Remove a map from a project; the map is deleted - IProjectItem mapToRemove = Project.Current.GetItems().FirstOrDefault(map => map.Name.Equals("OldStreetRoutes")); - var removedMapProjectItem = await QueuedTask.Run( - () => Project.Current.RemoveItem(mapToRemove)); - - #endregion //RemoveMapFromProject - - - - #region ImportToProject - - /// Import a mxd - Item mxdToImport = ItemFactory.Instance.Create(@"C:\Projects\RegionalSurvey\LatestResults.mxd"); - var addedMxd = await QueuedTask.Run( - () => Project.Current.AddItem(mxdToImport as IProjectItem)); - - /// Add map package - Item mapPackageToAdd = ItemFactory.Instance.Create(@"c:\Data\Map.mpkx"); - var addedMapPackage = await QueuedTask.Run( - () => Project.Current.AddItem(mapPackageToAdd as IProjectItem)); - - /// Add an exported Pro map - Item proMapToAdd = ItemFactory.Instance.Create(@"C:\ExportedMaps\Election\Districts.mapx"); - var addedMapProjectItem = await QueuedTask.Run( - () => Project.Current.AddItem(proMapToAdd as IProjectItem)); - - #endregion //ImportToProject - - - } - - /// - /// Sample Code for Item. - /// - public async Task ItemExamples() - { - // not to be included in sample regions - var projectfolderConnection = (Project.Current.GetItems()).First(); - - - #region CreateAnItem - - Item mxdItem = ItemFactory.Instance.Create(@"C:\Projects\RegionalSurvey\LatestResults.mxd"); - - #endregion //CreateAnItem - - - #region CreateAPortalItem - - // Creates an Item from an existing portal item base on its ID - string portalItemID = "9801f878ff4a22738dff3f039c43e395"; - Item portalItem = ItemFactory.Instance.Create(portalItemID, ItemFactory.ItemType.PortalItem); - - #endregion - - - #region CreateAPortalFolder - - // Creates an Item from an existing portal folder base on its ID - string portalFolderID = "39c43e39f878f4a2279838dfff3f0015"; - Item portalFolder = ItemFactory.Instance.Create(portalFolderID, ItemFactory.ItemType.PortalFolderItem); - - #endregion - - - #region GetItemContent - - var folderConnectionContent = projectfolderConnection.GetItems(); - var folder = folderConnectionContent.FirstOrDefault(folderItem => folderItem.Name.Equals("Tourist Sites")); - var folderContents = folder.GetItems(); - - #endregion //GetItemContent - - - #region - - #endregion - } - - #region - - #endregion - - } -} +/* + + Copyright 2018 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ArcGIS.Desktop.Core; +using ArcGIS.Desktop.Mapping; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Internal.Core; + +namespace ArcGIS.Desktop.Catalog.ApiTests.CodeSamples +{ + class CatalogCodeSamples + { + + /// + /// Sample code for ProjectItem + /// + public async Task ProjectItemExamples() + { + // not to be included in sample regions + var projectFolderConnection = (Project.Current.GetItems()).First(); + + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Mapping.MapProjectItem + #region Get MapProjectItems + + /// Get all the maps in a project + IEnumerable projectMaps = Project.Current.GetItems(); + + #endregion //GetMapProjectItems + + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + #region Get FolderConnectionProjectItems + + /// Get all the folder connections in a project + IEnumerable projectFolders = Project.Current.GetItems(); + + #endregion //GetFolderConnectiontProjectItems + + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Catalog.ServerConnectionProjectItem + #region Get ServerConnectionProjectItems + + /// Get all the server connections in a project + IEnumerable projectServers = Project.Current.GetItems(); + + #endregion //Get ServerConnectionProjectItems + + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Catalog.LocatorsConnectionProjectItem + #region Get LocatorConnectionProjectItems + + /// Get all the locator connections in a project + IEnumerable projectLocators = Project.Current.GetItems(); + + #endregion //Get LocatorConnectionProjectItems + + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Item.GetItems + #region Get Project Items by ProjectItem type + + /// Get all the items that can be accessed from a folder connection. The items immediately + /// contained by a folder, that is, the folder's children, are returned including folders + /// and individual items that can be used in ArcGIS Pro. This method does not return all + /// items contained by any sub-folder that can be accessed from the folder connection. + FolderConnectionProjectItem folderConnection = Project.Current.GetItems() + .FirstOrDefault((folder => folder.Name.Equals("Data"))); + await QueuedTask.Run(() => + { + IEnumerable folderContents = folderConnection.GetItems(); + }); + #endregion //GetProjectItems + + // cref: ArcGIS.Desktop.Core.Project.AddItem + #region Add Folder to Project as IProjectItem + + /// Add a folder connection to a project + Item folderToAdd = ItemFactory.Instance.Create(@"C:\Data\Oregon\Counties\Streets"); + bool wasAdded = await QueuedTask.Run(() => Project.Current.AddItem(folderToAdd as IProjectItem)); + + #endregion //AddFolderConnectionProjectItem + + // cref: ArcGIS.Desktop.Catalog.GDBProjectItem + // cref: ArcGIS.Desktop.Core.Project.AddItem + #region Add GDBProjectItem to Project as IProjectItem + + /// Add a file geodatabase or a SQLite or enterprise database connection to a project + Item gdbToAdd = folderToAdd.GetItems().FirstOrDefault(folderItem => folderItem.Name.Equals("CountyData.gdb")); + var addedGeodatabase = await QueuedTask.Run(() => Project.Current.AddItem(gdbToAdd as IProjectItem)); + + #endregion //AddGDBProjectItem + + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Project.RemoveItem + #region Remove FolderConnection From Project + + /// Remove a folder connection from a project; the folder stored on the local disk + /// or the network is not deleted + FolderConnectionProjectItem folderToRemove = Project.Current.GetItems().FirstOrDefault(folder => folder.Name.Equals("PlantSpecies")); + if (folderToRemove != null) + Project.Current.RemoveItem(folderToRemove as IProjectItem); + + #endregion //RemoveFolderConnectionFromProject + + // cref: ArcGIS.Desktop.Mapping.MapProjectItem + // cref: ArcGIS.Desktop.Core.Project.RemoveItem + #region Remove Map From Project + + /// Remove a map from a project; the map is deleted + IProjectItem mapToRemove = Project.Current.GetItems().FirstOrDefault(map => map.Name.Equals("OldStreetRoutes")); + var removedMapProjectItem = await QueuedTask.Run( + () => Project.Current.RemoveItem(mapToRemove)); + + #endregion //RemoveMapFromProject + + // cref: ArcGIS.Desktop.Core.ItemFactory + // cref: ArcGIS.Desktop.Core.ItemFactory.Create + // cref: ArcGIS.Desktop.Core.ItemFactory.Create + // cref: ArcGIS.Desktop.Core.Project.AddItem + #region Importing Maps To Project + + /// Import a mxd + Item mxdToImport = ItemFactory.Instance.Create(@"C:\Projects\RegionalSurvey\LatestResults.mxd"); + var addedMxd = await QueuedTask.Run( + () => Project.Current.AddItem(mxdToImport as IProjectItem)); + + /// Add map package + Item mapPackageToAdd = ItemFactory.Instance.Create(@"c:\Data\Map.mpkx"); + var addedMapPackage = await QueuedTask.Run( + () => Project.Current.AddItem(mapPackageToAdd as IProjectItem)); + + /// Add an exported Pro map + Item proMapToAdd = ItemFactory.Instance.Create(@"C:\ExportedMaps\Election\Districts.mapx"); + var addedMapProjectItem = await QueuedTask.Run( + () => Project.Current.AddItem(proMapToAdd as IProjectItem)); + + #endregion //ImportToProject + + } + + /// + /// Sample Code for Item. + /// + public async Task ItemExamples() + { + // not to be included in sample regions + var projectfolderConnection = (Project.Current.GetItems()).First(); + + // cref: ArcGIS.Desktop.Core.ItemFactory.Create + // cref: ArcGIS.Desktop.Core.Item + #region Create An Item + + Item mxdItem = ItemFactory.Instance.Create(@"C:\Projects\RegionalSurvey\LatestResults.mxd"); + + #endregion //CreateAnItem + + // cref: ArcGIS.Desktop.Core.ItemFactory.Create + // cref: ArcGIS.Desktop.Core.ItemFactory.ItemType + // cref: ArcGIS.Desktop.Core.Portal.PortalItem + #region Create A PortalItem + + // Creates an Item from an existing portal item base on its ID + string portalItemID = "9801f878ff4a22738dff3f039c43e395"; + Item portalItem = ItemFactory.Instance.Create(portalItemID, ItemFactory.ItemType.PortalItem); + + #endregion + + // cref: ArcGIS.Desktop.Core.ItemFactory.Create + // cref: ArcGIS.Desktop.Core.ItemFactory.ItemType + // cref: ArcGIS.Desktop.Core.Portal.PortalItem + #region Create A PortalFolder + + // Creates an Item from an existing portal folder base on its ID + string portalFolderID = "39c43e39f878f4a2279838dfff3f0015"; + Item portalFolder = ItemFactory.Instance.Create(portalFolderID, ItemFactory.ItemType.PortalFolderItem); + + #endregion + + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Core.Portal.PortalItem + #region Get Folder Item Content from Project PortalItem + + var folderConnectionContent = projectfolderConnection.GetItems(); + var folder = folderConnectionContent.FirstOrDefault(folderItem => folderItem.Name.Equals("Tourist Sites")); + var folderContents = folder.GetItems(); + + #endregion //GetItemContent + + + #region + + #endregion + } + + #region + + #endregion + + } +} diff --git a/Examples/Content/Content.csproj b/Examples/Content/Content.csproj new file mode 100644 index 0000000..f2174bf --- /dev/null +++ b/Examples/Content/Content.csproj @@ -0,0 +1,80 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/Content/ProSnippets.cs b/Examples/Content/ProSnippets.cs index c53e669..c7b58bf 100644 --- a/Examples/Content/ProSnippets.cs +++ b/Examples/Content/ProSnippets.cs @@ -43,461 +43,547 @@ limitations under the License. namespace Content.Snippets { - #region ProSnippet Group: Project - #endregion - - internal class ProSinppets1 - { - public async void ContentSnippet() - { - #region New project - //Create an empty project. The project will be created in the default folder - //It will be named MyProject1, MyProject2, or similar... - await Project.CreateAsync(); - #endregion - - #region New project with specified name - //Settings used to create a new project - CreateProjectSettings projectSettings = new CreateProjectSettings() - { - //Sets the name of the project that will be created - Name = @"C:\Data\MyProject1\MyProject1.aprx" - }; - //Create the new project - await Project.CreateAsync(projectSettings); - #endregion - - } - - public async void ContentSnippets2() - { - #region Create new project using Pro's default settings - //Get Pro's default project settings. - var defaultProjectSettings = Project.GetDefaultProjectSettings(); - //Create a new project using the default project settings - await Project.CreateAsync(defaultProjectSettings); - #endregion - - #region New project using a custom template file - //Settings used to create a new project - CreateProjectSettings projectSettings = new CreateProjectSettings() - { - //Sets the project's name - Name = "New Project", - //Path where new project will be stored in - LocationPath = @"C:\Data\NewProject", - //Sets the project template that will be used to create the new project - TemplatePath = @"C:\Data\MyProject1\CustomTemplate.aptx" - }; - //Create the new project - await Project.CreateAsync(projectSettings); - #endregion - - #region Create project using template available with ArcGIS Pro - //Settings used to create a new project - CreateProjectSettings proTemplateSettings = new CreateProjectSettings() - { - //Sets the project's name - Name = "New Project", - //Path where new project will be stored in - LocationPath = @"C:\Data\NewProject", - //Select which Pro template you like to use - TemplateType = TemplateType.Catalog - //TemplateType = TemplateType.LocalScene - //TemplateType = TemplateType.GlobalScene - //TemplateType = TemplateType.Map - }; - //Create the new project - await Project.CreateAsync(proTemplateSettings); - #endregion - - #region Open project - //Opens an existing project or project package - await Project.OpenAsync(@"C:\Data\MyProject1\MyProject1.aprx"); - #endregion - - #region Current project - //Gets the current project - var project = Project.Current; - #endregion - - #region Get location of current project - //Gets the location of the current project; that is, the path to the current project file (*.aprx) - string projectPath = Project.Current.URI; - #endregion - - #region Get the project's default gdb path - var projGDBPath = Project.Current.DefaultGeodatabasePath; - #endregion - - #region Save project - //Saves the project - await Project.Current.SaveAsync(); - - #endregion - - #region Check if project needs to be saved - //The project's dirty state indicates changes made to the project have not yet been saved. - bool isProjectDirty = Project.Current.IsDirty; - #endregion - - #region SaveAs project - //Saves a copy of the current project file (*.aprx) to the specified location with the specified file name, - //then opens the new project file - await Project.Current.SaveAsAsync(@"C:\Data\MyProject1\MyNewProject1.aprx"); - #endregion - - #region Close project - //A project cannot be closed using the ArcGIS Pro API. - //A project is only closed when another project is opened, a new one is created, or the application is shutdown. - #endregion - - #region How to add a new map to a project - await QueuedTask.Run(() => - { - //Note: see also MapFactory in ArcGIS.Desktop.Mapping - var map = MapFactory.Instance.CreateMap("New Map", MapType.Map, MapViewingMode.Map, Basemap.Oceans); - ProApp.Panes.CreateMapPaneAsync(map); - }); - - #endregion - - #region ProSnippet Group: Project Items - #endregion - - #region Adds item to the current project - //Adding a folder connection - string folderPath = "@C:\\myDataFolder"; - var folder = await QueuedTask.Run(() => - { - //Create the folder connection project item - var item = ItemFactory.Instance.Create(folderPath) as IProjectItem; - //If it is succesfully added to the project, return it otherwise null - return Project.Current.AddItem(item) ? item as FolderConnectionProjectItem : null; - }); - - //Adding a Geodatabase: - string gdbPath = "@C:\\myDataFolder\\myData.gdb"; - var newlyAddedGDB = await QueuedTask.Run(() => - { - //Create the File GDB project item - var item = ItemFactory.Instance.Create(gdbPath) as IProjectItem; - //If it is succesfully added to the project, return it otherwise null - return Project.Current.AddItem(item) ? item as GDBProjectItem : null; - }); - - #endregion - - #region Get all the project items - IEnumerable allProjectItems = Project.Current.GetItems(); - foreach (var pi in allProjectItems) - { - //Do Something - } - #endregion - - #region Gets all the "MapProjectItems" - IEnumerable newMapItemsContainer = project.GetItems(); - - await QueuedTask.Run(() => - { - foreach (var mp in newMapItemsContainer) - { - //Do Something with the map. For Example: - Map myMap = mp.GetMap(); - } - }); - #endregion - - #region Gets a specific "MapProjectItem" - MapProjectItem mapProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("EuropeMap")); - #endregion - - #region Gets all the "StyleProjectItems" - IEnumerable newStyleItemsContainer = null; - newStyleItemsContainer = Project.Current.GetItems(); - foreach (var styleItem in newStyleItemsContainer) - { - //Do Something with the style. - } - #endregion - - #region Gets a specific "StyleProjectItem" - var container = Project.Current.GetItems(); - StyleProjectItem testStyle = container.FirstOrDefault(style => (style.Name == "ArcGIS 3D")); - StyleItem cone = null; - if (testStyle != null) - cone = testStyle.LookupItem(StyleItemType.PointSymbol, "Cone_Volume_3"); - #endregion - - #region Gets the "Favorites" StyleProjectItem - - var fav_style_item = await QueuedTask.Run(() => - { - var containerStyle = Project.Current.GetProjectItemContainer("Style"); - return containerStyle.GetItems().OfType().First(item => item.TypeID == "personal_style"); - }); - - #endregion - #region Gets all the "GDBProjectItems" - IEnumerable newGDBItemsContainer = null; - newGDBItemsContainer = Project.Current.GetItems(); - foreach (var GDBItem in newGDBItemsContainer) - { - //Do Something with the GDB. - } - #endregion - - #region Gets a specific "GDBProjectItem" - GDBProjectItem GDBProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("myGDB")); - #endregion - - #region Gets all the "ServerConnectionProjectItem" - IEnumerable newServerConnections = null; - newServerConnections = project.GetItems(); - foreach (var serverItem in newServerConnections) - { - //Do Something with the server connection. - } - #endregion - - #region Gets a specific "ServerConnectionProjectItem" - ServerConnectionProjectItem serverProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("myServer")); - #endregion - - #region Gets all folder connections in a project - //Gets all the folder connections in the current project - var projectFolders = Project.Current.GetItems(); - foreach (var FolderItem in projectFolders) - { - //Do Something with the Folder connection. - } - #endregion - - #region Gets a specific folder connection - //Gets a specific folder connection in the current project - FolderConnectionProjectItem myProjectFolder = Project.Current.GetItems().FirstOrDefault(folderPI => folderPI.Name.Equals("myDataFolder")); - #endregion - - #region Remove a specific folder connection - // Remove a folder connection from a project; the folder stored on the local disk or the network is not deleted - FolderConnectionProjectItem folderToRemove = Project.Current.GetItems().FirstOrDefault(myfolder => myfolder.Name.Equals("PlantSpecies")); - if (folderToRemove != null) - Project.Current.RemoveItem(folderToRemove as IProjectItem); - #endregion - - #region Gets a specific "LayoutProjectItem" - LayoutProjectItem layoutProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("myLayout")); - #endregion - - #region Gets all layouts in a project: - //Gets all the layouts in the current project - var projectLayouts = Project.Current.GetItems(); - foreach (var layoutItem in projectLayouts) - { - //Do Something with the layout - } - #endregion - - #region Gets a specific "GeoprocessingProjectItem" - GeoprocessingProjectItem GPProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("myToolbox")); - #endregion - - #region Gets all GeoprocessingProjectItems in a project: - //Gets all the GeoprocessingProjectItem in the current project - var GPItems = Project.Current.GetItems(); - foreach (var tbx in GPItems) - { - //Do Something with the toolbox - } - #endregion - - #region Search project for a specific item - List _mxd = new List(); - //Gets all the folder connections in the current project - var allFoldersItem = Project.Current.GetItems(); - if (allFoldersItem != null) - { - //iterate through all the FolderConnectionProjectItems found - foreach (var folderItem in allFoldersItem) - { - //Search for mxd files in that folder connection and add it to the List - //Note:ArcGIS Pro automatically creates and dynamically updates a searchable index as you build and work with projects. - //Items are indexed when they are added to a project. - //The first time a folder or database is indexed, indexing may take a while if it contains a large number of items. - //While the index is being created, searches will not return any results. - _mxd.AddRange(folderItem.GetItems()); - } - } - #endregion - - #region Get the Default Project Folder - - var defaultProjectPath = System.IO.Path.Combine( - System.Environment.GetFolderPath( - Environment.SpecialFolder.MyDocuments), - @"ArcGIS\Projects"); - - #endregion - - var contentItem = Project.Current.GetItems().First(); - - #region Refresh an Item's Children - //var contentItem = ... - //Check if the MCT is required for Refresh() - if (contentItem.IsMainThreadRequired) - { - //QueuedTask.Run must be used if item.IsMainThreadRequired - //returns true - QueuedTask.Run(() => contentItem.Refresh()); - } - else - { - //if item.IsMainThreadRequired returns false, any - //thread can be used to invoke Refresh(), though - //BackgroundTask is preferred. - contentItem.Refresh(); - - //Or, via BackgroundTask - ArcGIS.Core.Threading.Tasks.BackgroundTask.Run(() => - contentItem.Refresh(), ArcGIS.Core.Threading.Tasks.BackgroundProgressor.None); - } - #endregion - } - - public void ContentSnippet3() - { - // cref: Get Item Categories;ArcGIS.Desktop.Core.Item.ItemCategories - #region Get Item Categories - // Get the ItemCategories with which an item is associated - Item gdb = ItemFactory.Instance.Create(@"E:\CurrentProject\RegionalPolling\polldata.gdb"); - List gdbItemCategories = gdb.ItemCategories; - #endregion - - // cref: Using Item Categories;ArcGIS.Desktop.Core.ItemCategory.Items(System.Collections.Generic.IEnumerable{ArcGIS.Desktop.Core.Item}) - #region Using Item Categories - // Browse items using an ItemCategory as a filter - IEnumerable gdbContents = gdb.GetItems(); - IEnumerable filteredGDBContents1 = gdbContents.Where(item => item.ItemCategories.OfType().Any()); - IEnumerable filteredGDBContents2 = new ItemCategoryDataSet().Items(gdbContents); - #endregion - - } - - - //removed at 2.3 - public static string GetDefaultTemplateFolder() - { - string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); - string root = dir.Split(new string[] { @"\bin" }, StringSplitOptions.RemoveEmptyEntries)[0]; - return System.IO.Path.Combine(root, @"Resources\ProjectTemplates"); - } - - - - //removed at 2.3 - - public static Task> GetDefaultTemplatesAsync() - { - return Task.Run(() => - { - string templatesDir = GetDefaultTemplateFolder(); - return - Directory.GetFiles(templatesDir, "*", SearchOption.TopDirectoryOnly) - .Where(f => f.EndsWith(".ppkx") || f.EndsWith(".aptx")).ToList(); - }); - } - - - - public static async void CreateProjectWithTemplate() - { - - #region Create Project with Template - var projectFolder = System.IO.Path.Combine( - System.Environment.GetFolderPath( - Environment.SpecialFolder.MyDocuments), - @"ArcGIS\Projects"); - - CreateProjectSettings ps = new CreateProjectSettings() - { - Name = "MyProject", - LocationPath = projectFolder, - TemplatePath = @"C:\data\my_templates\custom_template.aptx" - }; - - var project = await Project.CreateAsync(ps); - #endregion - } - - public static void ItemFindAndSelection() - { - - #region Select project containers - for use with SelectItemAsync - - //Use Project.Current.ProjectItemContainers - var folderContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "FolderConnection"); - var gdbContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "GDB"); - var mapContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "Map"); - var layoutContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "Layout"); - var toolboxContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "GP"); - //etc. - - //or...use Project.Current.GetProjectItemContainer - - folderContainer = Project.Current.GetProjectItemContainer("FolderConnection"); - gdbContainer = Project.Current.GetProjectItemContainer("GDB"); - mapContainer = Project.Current.GetProjectItemContainer("Map"); - layoutContainer = Project.Current.GetProjectItemContainer("Layout"); - toolboxContainer = Project.Current.GetProjectItemContainer("GP"); - //etc. - - #endregion - - #region ProjectItem: Get an Item or Find an Item - - //GetItems searches project content - var map = Project.Current.GetItems().FirstOrDefault(m => m.Name == "Map1"); - var layout = Project.Current.GetItems().FirstOrDefault(m => m.Name == "Layout1"); - var folders = Project.Current.GetItems(); - var style = Project.Current.GetItems().FirstOrDefault(s => s.Name == "ArcGIS 3D"); - - //Find item uses a catalog path. The path can be to a file or dataset - var fcPath = @"C:\Pro\CommunitySampleData\Interacting with Maps\Interacting with Maps.gdb\Crimes"; - var pdfPath = @"C:\Temp\Layout1.pdf"; - var imgPath = @"C:\Temp\AddinDesktop16.png"; - - var fc = Project.Current.FindItem(fcPath); - var pdf = Project.Current.FindItem(pdfPath); - var img = Project.Current.FindItem(imgPath); + #region ProSnippet Group: Project + #endregion - #endregion + internal class ProSinppets1 + { + public async void ContentSnippet() + { + // cref: ArcGIS.Desktop.Core.Project.CreateAsync + #region Create an empty project + //Create an empty project. The project will be created in the default folder + //It will be named MyProject1, MyProject2, or similar... + await Project.CreateAsync(); + #endregion + + // cref: ArcGIS.Desktop.Core.Project.CreateAsync(ArcGIS.Desktop.Core.CreateProjectSettings) + // cref: ArcGIS.Desktop.Core.CreateProjectSettings + #region Create a new project with specified name + //Settings used to create a new project + CreateProjectSettings projectSettings = new CreateProjectSettings() + { + //Sets the name of the project that will be created + Name = @"C:\Data\MyProject1\MyProject1.aprx" + }; + //Create the new project + await Project.CreateAsync(projectSettings); + #endregion + + } + + public async void ContentSnippets2() + { + // cref: ArcGIS.Desktop.Core.Project.CreateAsync(ArcGIS.Desktop.Core.CreateProjectSettings) + // cref: ArcGIS.Desktop.Core.CreateProjectSettings + // cref: ArcGIS.Desktop.Core.Project.GetDefaultProjectSettings + #region Create new project using Pro's default settings + //Get Pro's default project settings. + var defaultProjectSettings = Project.GetDefaultProjectSettings(); + //Create a new project using the default project settings + await Project.CreateAsync(defaultProjectSettings); + #endregion + + // cref: ArcGIS.Desktop.Core.Project.CreateAsync(ArcGIS.Desktop.Core.CreateProjectSettings) + // cref: ArcGIS.Desktop.Core.CreateProjectSettings + #region New project using a custom template file + //Settings used to create a new project + CreateProjectSettings projectSettings = new CreateProjectSettings() + { + //Sets the project's name + Name = "New Project", + //Path where new project will be stored in + LocationPath = @"C:\Data\NewProject", + //Sets the project template that will be used to create the new project + TemplatePath = @"C:\Data\MyProject1\CustomTemplate.aptx" + }; + //Create the new project + await Project.CreateAsync(projectSettings); + #endregion + + // cref: ArcGIS.Desktop.Core.Project.CreateAsync(ArcGIS.Desktop.Core.CreateProjectSettings) + // cref: ArcGIS.Desktop.Core.CreateProjectSettings + // cref: ArcGIS.Desktop.Core.TemplateType + #region Create a project using template available with ArcGIS Pro + //Settings used to create a new project + CreateProjectSettings proTemplateSettings = new CreateProjectSettings() + { + //Sets the project's name + Name = "New Project", + //Path where new project will be stored in + LocationPath = @"C:\Data\NewProject", + //Select which Pro template you like to use + TemplateType = TemplateType.Catalog + //TemplateType = TemplateType.LocalScene + //TemplateType = TemplateType.GlobalScene + //TemplateType = TemplateType.Map + }; + //Create the new project + await Project.CreateAsync(proTemplateSettings); + #endregion + + // cref: ArcGIS.Desktop.Core.Project.OpenAsync(System.String) + #region Open an existing project + //Opens an existing project or project package + await Project.OpenAsync(@"C:\Data\MyProject1\MyProject1.aprx"); + #endregion + + // cref: ArcGIS.Desktop.Core.Project.Current + #region Get the Current project + //Gets the current project + var project = Project.Current; + #endregion + + // cref: ArcGIS.Desktop.Core.Project.Current + // cref: ArcGIS.Desktop.Core.Project.URI + #region Get location of current project + //Gets the location of the current project; that is, the path to the current project file (*.aprx) + string projectPath = Project.Current.URI; + #endregion + + // cref: ArcGIS.Desktop.Core.Project.Current + // cref: ArcGIS.Desktop.Core.Project.DefaultGeodatabasePath + #region Get the project's default gdb path + var projGDBPath = Project.Current.DefaultGeodatabasePath; + #endregion + + // cref: ArcGIS.Desktop.Core.Project.SaveAsync + #region Save project + //Saves the project + await Project.Current.SaveAsync(); + + #endregion + + // cref: ArcGIS.Desktop.Core.Project.Current + // cref: ArcGIS.Desktop.Core.Project.IsDirty + #region Check if project needs to be saved + //The project's dirty state indicates changes made to the project have not yet been saved. + bool isProjectDirty = Project.Current.IsDirty; + #endregion + + // cref: ArcGIS.Desktop.Core.Project.SaveAsAsync + #region SaveAs project + //Saves a copy of the current project file (*.aprx) to the specified location with the specified file name, + //then opens the new project file + await Project.Current.SaveAsAsync(@"C:\Data\MyProject1\MyNewProject1.aprx"); + #endregion + + // cref: ArcGIS.Desktop.Core.Project.OpenAsync(System.String) + #region Close a project + //A project cannot be closed using the ArcGIS Pro API. + //A project is only closed when another project is opened, a new one is created, or the application is shutdown. + #endregion + + // cref: ArcGIS.Desktop.Mapping.MapFactory.CreateMap(System.String,ArcGIS.Core.CIM.MapType,ArcGIS.Core.CIM.MapViewingMode,ArcGIS.Desktop.Mapping.Basemap) + #region How to add a new map to a project + await QueuedTask.Run(() => + { + //Note: see also MapFactory in ArcGIS.Desktop.Mapping + var map = MapFactory.Instance.CreateMap("New Map", MapType.Map, MapViewingMode.Map, Basemap.Oceans); + ProApp.Panes.CreateMapPaneAsync(map); + }); + + #endregion + + #region ProSnippet Group: Project Items + #endregion + + // cref: ArcGIS.Desktop.Core.ItemFactory + // cref: ArcGIS.Desktop.Core.IItemFactory.Create + // cref: ArcGIS.Desktop.Core.Project.AddItem(ArcGIS.Desktop.Core.IProjectItem) + #region Add a folder connection item to the current project + //Adding a folder connection + string folderPath = "@C:\\myDataFolder"; + var folder = await QueuedTask.Run(() => + { + //Create the folder connection project item + var item = ItemFactory.Instance.Create(folderPath) as IProjectItem; + //If it is succesfully added to the project, return it otherwise null + return Project.Current.AddItem(item) ? item as FolderConnectionProjectItem : null; + }); + + //Adding a Geodatabase: + string gdbPath = "@C:\\myDataFolder\\myData.gdb"; + var newlyAddedGDB = await QueuedTask.Run(() => + { + //Create the File GDB project item + var item = ItemFactory.Instance.Create(gdbPath) as IProjectItem; + //If it is succesfully added to the project, return it otherwise null + return Project.Current.AddItem(item) ? item as GDBProjectItem : null; + }); + + #endregion + + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get all project items + IEnumerable allProjectItems = Project.Current.GetItems(); + foreach (var pi in allProjectItems) + { + //Do Something + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.MapProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get all "MapProjectItems" for a project + IEnumerable newMapItemsContainer = project.GetItems(); + + await QueuedTask.Run(() => + { + foreach (var mp in newMapItemsContainer) + { + //Do Something with the map. For Example: + Map myMap = mp.GetMap(); + } + }); + #endregion + + // cref: ArcGIS.Desktop.Mapping.MapProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get a specific "MapProjectItem" + MapProjectItem mapProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("EuropeMap")); + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get all "StyleProjectItems" + IEnumerable newStyleItemsContainer = null; + newStyleItemsContainer = Project.Current.GetItems(); + foreach (var styleItem in newStyleItemsContainer) + { + //Do Something with the style. + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get a specific "StyleProjectItem" + var container = Project.Current.GetItems(); + StyleProjectItem testStyle = container.FirstOrDefault(style => (style.Name == "ArcGIS 3D")); + StyleItem cone = null; + if (testStyle != null) + cone = testStyle.LookupItem(StyleItemType.PointSymbol, "Cone_Volume_3"); + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get the "Favorite" StyleProjectItem + + var fav_style_item = await QueuedTask.Run(() => + { + var containerStyle = Project.Current.GetProjectItemContainer("Style"); + return containerStyle.GetItems().OfType().First(item => item.TypeID == "personal_style"); + }); + + #endregion + + // cref: ArcGIS.Desktop.Catalog.GDBProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get all "GDBProjectItems" + IEnumerable newGDBItemsContainer = null; + newGDBItemsContainer = Project.Current.GetItems(); + foreach (var GDBItem in newGDBItemsContainer) + { + //Do Something with the GDB. + } + #endregion + + // cref: ArcGIS.Desktop.Catalog.GDBProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get a specific "GDBProjectItem" + GDBProjectItem GDBProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("myGDB")); + #endregion + + // cref: ArcGIS.Desktop.Catalog.ServerConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get all "ServerConnectionProjectItems" + IEnumerable newServerConnections = null; + newServerConnections = project.GetItems(); + foreach (var serverItem in newServerConnections) + { + //Do Something with the server connection. + } + #endregion + + // cref: ArcGIS.Desktop.Catalog.ServerConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get a specific "ServerConnectionProjectItem" + ServerConnectionProjectItem serverProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("myServer")); + #endregion + + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get all folder connections in a project + //Gets all the folder connections in the current project + var projectFolders = Project.Current.GetItems(); + foreach (var FolderItem in projectFolders) + { + //Do Something with the Folder connection. + } + #endregion + + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get a specific folder connection + //Gets a specific folder connection in the current project + FolderConnectionProjectItem myProjectFolder = Project.Current.GetItems().FirstOrDefault(folderPI => folderPI.Name.Equals("myDataFolder")); + #endregion + + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Project.RemoveItem + #region Remove a specific folder connection + // Remove a folder connection from a project; the folder stored on the local disk or the network is not deleted + FolderConnectionProjectItem folderToRemove = Project.Current.GetItems().FirstOrDefault(myfolder => myfolder.Name.Equals("PlantSpecies")); + if (folderToRemove != null) + Project.Current.RemoveItem(folderToRemove as IProjectItem); + #endregion + + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Gets a specific "LayoutProjectItem" + LayoutProjectItem layoutProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("myLayout")); + #endregion + + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get all layouts in a project + //Gets all the layouts in the current project + var projectLayouts = Project.Current.GetItems(); + foreach (var layoutItem in projectLayouts) + { + //Do Something with the layout + } + #endregion + + // cref: ArcGIS.Desktop.GeoProcessing.GeoprocessingProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get a specific "GeoprocessingProjectItem" + GeoprocessingProjectItem GPProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("myToolbox")); + #endregion + + // cref: ArcGIS.Desktop.GeoProcessing.GeoprocessingProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Get all GeoprocessingProjectItems in a project + //Gets all the GeoprocessingProjectItem in the current project + var GPItems = Project.Current.GetItems(); + foreach (var tbx in GPItems) + { + //Do Something with the toolbox + } + #endregion + + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + #region Search project for a specific item + List _mxd = new List(); + //Gets all the folder connections in the current project + var allFoldersItem = Project.Current.GetItems(); + if (allFoldersItem != null) + { + //iterate through all the FolderConnectionProjectItems found + foreach (var folderItem in allFoldersItem) + { + //Search for mxd files in that folder connection and add it to the List + //Note:ArcGIS Pro automatically creates and dynamically updates a searchable index as you build and work with projects. + //Items are indexed when they are added to a project. + //The first time a folder or database is indexed, indexing may take a while if it contains a large number of items. + //While the index is being created, searches will not return any results. + _mxd.AddRange(folderItem.GetItems()); + } + } + #endregion + + // cref: ArcGIS.Desktop.Core.CreateProjectSettings.LocationPath + // cref: ArcGIS.Desktop.Core.Project.GetDefaultProjectSettings + #region Get the Default Project Folder + //Get Pro's default project settings. + var defaultSettings = Project.GetDefaultProjectSettings(); + var defaultProjectPath = defaultSettings.LocationPath; + if (defaultProjectPath == null) + { + // If not set, projects are saved in the user's My Documents\ArcGIS\Projects folder; + // this folder is created if it doesn't already exist. + defaultProjectPath = System.IO.Path.Combine( + System.Environment.GetFolderPath( + Environment.SpecialFolder.MyDocuments), + @"ArcGIS\Projects"); + } + #endregion + + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Core.Item.Refresh + #region Refresh the child item for a folder connection Item + var contentItem = Project.Current.GetItems().First(); + //var contentItem = ... + //Check if the MCT is required for Refresh() + if (contentItem.IsMainThreadRequired) + { + //QueuedTask.Run must be used if item.IsMainThreadRequired + //returns true + QueuedTask.Run(() => contentItem.Refresh()); + } + else + { + //if item.IsMainThreadRequired returns false, any + //thread can be used to invoke Refresh(), though + //BackgroundTask is preferred. + contentItem.Refresh(); + + //Or, via BackgroundTask + ArcGIS.Core.Threading.Tasks.BackgroundTask.Run(() => + contentItem.Refresh(), ArcGIS.Core.Threading.Tasks.BackgroundProgressor.None); + } + #endregion + } + + public void ContentSnippet3() + { + // cref: ArcGIS.Desktop.Core.Item.ItemCategories + #region Get Item Categories + // Get the ItemCategories with which an item is associated + Item gdb = ItemFactory.Instance.Create(@"E:\CurrentProject\RegionalPolling\polldata.gdb"); + List gdbItemCategories = gdb.ItemCategories; + #endregion + + // cref: ArcGIS.Desktop.Core.ItemCategory.Items(System.Collections.Generic.IEnumerable{ArcGIS.Desktop.Core.Item}) + #region Using Item Categories + // Browse items using an ItemCategory as a filter + IEnumerable gdbContents = gdb.GetItems(); + IEnumerable filteredGDBContents1 = gdbContents.Where(item => item.ItemCategories.OfType().Any()); + IEnumerable filteredGDBContents2 = new ItemCategoryDataSet().Items(gdbContents); + #endregion + + } + + + //removed at 2.3 + public static string GetDefaultTemplateFolder() + { + string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); + string root = dir.Split(new string[] { @"\bin" }, StringSplitOptions.RemoveEmptyEntries)[0]; + return System.IO.Path.Combine(root, @"Resources\ProjectTemplates"); + } + + + + //removed at 2.3 + + public static Task> GetDefaultTemplatesAsync() + { + return Task.Run(() => + { + string templatesDir = GetDefaultTemplateFolder(); + return + Directory.GetFiles(templatesDir, "*", SearchOption.TopDirectoryOnly) + .Where(f => f.EndsWith(".ppkx") || f.EndsWith(".aptx")).ToList(); + }); + } + + + + public static async void CreateProjectWithTemplate() + { + // cref: ArcGIS.Desktop.Core.Project.CreateAsync(ArcGIS.Desktop.Core.CreateProjectSettings) + // cref: ArcGIS.Desktop.Core.CreateProjectSettings + #region Create Project with Template + var projectFolder = System.IO.Path.Combine( + System.Environment.GetFolderPath( + Environment.SpecialFolder.MyDocuments), + @"ArcGIS\Projects"); + + CreateProjectSettings ps = new CreateProjectSettings() + { + Name = "MyProject", + LocationPath = projectFolder, + TemplatePath = @"C:\data\my_templates\custom_template.aptx" + }; + + var project = await Project.CreateAsync(ps); + #endregion + } + + public static void ItemFindAndSelection() + { + + // cref: ArcGIS.Desktop.Core.Project.ProjectItemContainers + // cref: ArcGIS.Desktop.Core.Project.GetProjectItemContainer(System.String) + #region Select project containers - for use with SelectItemAsync + + //Use Project.Current.ProjectItemContainers + var folderContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "FolderConnection"); + var gdbContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "GDB"); + var mapContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "Map"); + var layoutContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "Layout"); + var toolboxContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "GP"); + //etc. + + //or...use Project.Current.GetProjectItemContainer + + folderContainer = Project.Current.GetProjectItemContainer("FolderConnection"); + gdbContainer = Project.Current.GetProjectItemContainer("GDB"); + mapContainer = Project.Current.GetProjectItemContainer("Map"); + layoutContainer = Project.Current.GetProjectItemContainer("Layout"); + toolboxContainer = Project.Current.GetProjectItemContainer("GP"); + //etc. + + #endregion - #region Select an item in the Catalog pane + // cref: ArcGIS.Desktop.Catalog.FolderConnectionProjectItem + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Mapping.MapProjectItem + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Core.Project.FindItem(System.String) + #region ProjectItem: Get an Item or Find an Item - //Get the catalog pane - ArcGIS.Desktop.Core.IProjectWindow projectWindow = Project.GetCatalogPane(); - //or get the active catalog view... - //ArcGIS.Desktop.Core.IProjectWindow projectWindow = Project.GetActiveCatalogWindow(); + //GetItems searches project content + var map = Project.Current.GetItems().FirstOrDefault(m => m.Name == "Map1"); + var layout = Project.Current.GetItems().FirstOrDefault(m => m.Name == "Layout1"); + var folders = Project.Current.GetItems(); + var style = Project.Current.GetItems().FirstOrDefault(s => s.Name == "ArcGIS 3D"); - //eg Find a toolbox in the project - string gpName = "Interacting with Maps.tbx"; - var toolbox = Project.Current.GetItems().FirstOrDefault(tbx => tbx.Name == gpName); - //Select it under Toolboxes - projectWindow.SelectItemAsync(toolbox, true, true, null);//null selects it in the first container - optionally await - //Note: Project.Current.GetProjectItemContainer("GP") would get toolbox container... + //Find item uses a catalog path. The path can be to a file or dataset + var fcPath = @"C:\Pro\CommunitySampleData\Interacting with Maps\Interacting with Maps.gdb\Crimes"; + var pdfPath = @"C:\Temp\Layout1.pdf"; + var imgPath = @"C:\Temp\AddinDesktop16.png"; - //assume toolbox is also under Folders container. Select it under Folders instead of Toolboxes - var foldersContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "FolderConnection"); - //We must specify the container because Folders comes second (after Toolboxes) - projectWindow.SelectItemAsync(toolbox, true, true, foldersContainer);//optionally await + var fc = Project.Current.FindItem(fcPath); + var pdf = Project.Current.FindItem(pdfPath); + var img = Project.Current.FindItem(imgPath); - //Find a map and select it - var mapItem = Project.Current.GetItems().FirstOrDefault(m => m.Name == "Map"); - //Map only occurs under "Maps" so the container need not be specified - projectWindow.SelectItemAsync(mapItem, true, false, null); + #endregion + + + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Core.Project.GetCatalogPane + // cref: ArcGIS.Desktop.Core.IProjectWindow + // cref: ArcGIS.Desktop.Core.Project.ProjectItemContainers + // cref: ArcGIS.Desktop.Core.IProjectWindow.SelectItemAsync + #region Select an item in the Catalog pane + + //Get the catalog pane + ArcGIS.Desktop.Core.IProjectWindow projectWindow = Project.GetCatalogPane(); + //or get the active catalog view... + //ArcGIS.Desktop.Core.IProjectWindow projectWindow = Project.GetActiveCatalogWindow(); + + //eg Find a toolbox in the project + string gpName = "Interacting with Maps.tbx"; + var toolbox = Project.Current.GetItems().FirstOrDefault(tbx => tbx.Name == gpName); + //Select it under Toolboxes + projectWindow.SelectItemAsync(toolbox, true, true, null);//null selects it in the first container - optionally await + //Note: Project.Current.GetProjectItemContainer("GP") would get toolbox container... - #endregion + //assume toolbox is also under Folders container. Select it under Folders instead of Toolboxes + var foldersContainer = Project.Current.ProjectItemContainers.First(c => c.Path == "FolderConnection"); + //We must specify the container because Folders comes second (after Toolboxes) + projectWindow.SelectItemAsync(toolbox, true, true, foldersContainer);//optionally await + + //Find a map and select it + var mapItem = Project.Current.GetItems().FirstOrDefault(m => m.Name == "Map"); + //Map only occurs under "Maps" so the container need not be specified + projectWindow.SelectItemAsync(mapItem, true, false, null); + + #endregion } @@ -506,6 +592,9 @@ public static void ItemFindAndSelection() public async void Browse() { + // cref: ArcGIS.Desktop.Catalog.OpenItemDialog + // cref: ArcGIS.Desktop.Catalog.OpenItemDialog.ShowDialog + // cref: ArcGIS.Desktop.Core.BrowseProjectFilter #region Geodatabase Content from Browse Dialog var openDlg = new OpenItemDialog @@ -513,7 +602,7 @@ public async void Browse() Title = "Select a Feature Class", InitialLocation = @"C:\Data", MultiSelect = false, - BrowseFilter = BrowseProjectFilter.GetFilter(ArcGIS.Desktop.Catalog.ItemFilters.geodatabaseItems_all) + BrowseFilter = BrowseProjectFilter.GetFilter(ArcGIS.Desktop.Catalog.ItemFilters.GeodatabaseItems_All) }; //show the browse dialog @@ -540,7 +629,11 @@ await QueuedTask.Run(() => if (ds is ArcGIS.Core.Data.FeatureClass fc) { // create a layer - var layer = LayerFactory.Instance.CreateFeatureLayer(fc, MapView.Active.Map, 0); + var featureLayerParams = new FeatureLayerCreationParams(fc) + { + MapMemberIndex = 0 + }; + var layer = LayerFactory.Instance.CreateLayer(featureLayerParams, MapView.Active.Map); // continue } @@ -552,6 +645,11 @@ await QueuedTask.Run(() => public void CatalogWindow() { + // cref: ArcGIS.Desktop.Core.Events.ProjectWindowSelectedItemsChangedEventArgs + // cref: ArcGIS.Desktop.Core.Events.ProjectWindowSelectedItemsChangedEvent + // cref: ArcGIS.Desktop.Core.Events.ProjectWindowSelectedItemsChangedEvent.Subscribe + // cref: ArcGIS.Desktop.Core.IItemFactory.CanGetDataset + // cref: ArcGIS.Desktop.Core.ItemFactory.CanGetDataset #region Geodatabase Content from Catalog selection // subscribe to event @@ -604,14 +702,22 @@ await QueuedTask.Run(() => var name = fc.GetName() + "_copy"; // create - LayerFactory.Instance.CreateFeatureLayer(fc, MapView.Active.Map, 0, name); + var featureLayerParams = new FeatureLayerCreationParams(fc) + { + Name = name, + MapMemberIndex = 0 + }; + LayerFactory.Instance.CreateLayer(featureLayerParams, MapView.Active.Map); } else if (ds is Table table) { var name = table.GetName() + "_copy"; - + var tableParams = new StandaloneTableCreationParams(table) + { + Name = name + }; // create - StandaloneTableFactory.Instance.CreateStandaloneTable(table, MapView.Active.Map, name); + StandaloneTableFactory.Instance.CreateStandaloneTable(tableParams, MapView.Active.Map); } } } @@ -621,703 +727,792 @@ await QueuedTask.Run(() => #endregion } - #region ProSnippet Group: Favorites - - public void Favorites() - { - void AddFavorite() - { - #region Add a Favorite - Folder - - var itemFolder = ItemFactory.Instance.Create(@"d:\data"); - - // is the folder item already a favorite? - var fav = FavoritesManager.Current.GetFavorite(itemFolder); - if (fav == null) - { - if (FavoritesManager.Current.CanAddAsFavorite(itemFolder)) - { - fav = FavoritesManager.Current.AddFavorite(itemFolder); - } - } - - #endregion - } - - void InsertFavorite() - { - #region Insert a Favorite - Geodatabase path - - string gdbPath = "@C:\\myDataFolder\\myData.gdb"; - - var itemGDB = ItemFactory.Instance.Create(gdbPath); - - // is the item already a favorite? - var fav = FavoritesManager.Current.GetFavorite(itemGDB); - // no; add it with IsAddedToAllNewProjects set to true - if (fav != null) - { - if (FavoritesManager.Current.CanAddAsFavorite(itemGDB)) - FavoritesManager.Current.InsertFavorite(itemGDB, 1, true); - } - #endregion - } - - void AddFavoriteStyle() - { - #region Add a Favorite - Style project item - - StyleProjectItem styleItem = Project.Current.GetItems(). - FirstOrDefault(style => (style.Name == "ArcGIS 3D")); - - if (FavoritesManager.Current.CanAddAsFavorite(styleItem)) - { - // add to favorites with IsAddedToAllNewProjects set to false - FavoritesManager.Current.AddFavorite(styleItem); - } - - #endregion - } - - - void ToggleFavoriteFlag() - { - #region Toggle the flag IsAddedToAllNewProjects for a favorite - - var itemFolder = ItemFactory.Instance.Create(@"d:\data"); - - // is the folder item already a favorite? - var fav = FavoritesManager.Current.GetFavorite(itemFolder); - if (fav != null) - { - if (fav.IsAddedToAllNewProjects) - FavoritesManager.Current.ClearIsAddedToAllNewProjects(fav.Item); - else - FavoritesManager.Current.SetIsAddedToAllNewProjects(fav.Item); - } - #endregion - } - - void GetFavorites() - { - #region Get the set of favorites and iterate - var favorites = FavoritesManager.Current.GetFavorites(); - foreach (var favorite in favorites) - { - bool isAddedToAllProjects = favorite.IsAddedToAllNewProjects; - // retrieve the underlying item of the favorite - Item item = favorite.Item; - - // Item properties - var itemType = item.TypeID; - var path = item.Path; - - // if it's a folder item - if (item is FolderConnectionProjectItem) - { - } - // if it's a goedatabase item - else if (item is GDBProjectItem) - { - } - // else - } - - #endregion - } - - void RemoveAllFavorites() - { - #region Remove All Favorites - - var favorites = FavoritesManager.Current.GetFavorites(); - foreach (var favorite in favorites) - FavoritesManager.Current.RemoveFavorite(favorite.Item); - - #endregion - } - - void FavoriteEventt() - { - #region FavoritesChangedEvent - - ArcGIS.Desktop.Core.Events.FavoritesChangedEvent.Subscribe((args) => - { - // favorites have changed - int count = FavoritesManager.Current.GetFavorites().Count; - }); - - #endregion - } - } - #endregion - - #region ProSnippet Group: Metadata - #endregion - - public async Task MedataExamples() - { - string sourceXMLMetadataAsString = string.Empty; - - - // cref: Item: Get its IMetadata interface;ArcGIS.Desktop.Core.IMetadata - #region Item: Get its IMetadata interface - - Item gdbItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\regionFive.gdb"); - IMetadata gdbMetadataItem = gdbItem as IMetadata; + #region ProSnippet Group: Favorites + + public void Favorites() + { + void AddFavorite() + { + // cref: ArcGIS.Desktop.Core.FavoritesManager.GetFavorite + // cref: ArcGIS.Desktop.Core.FavoritesManager.CanAddAsFavorite + // cref: ArcGIS.Desktop.Core.FavoritesManager.AddFavorite(Item) + #region Add a Favorite - Folder + + var itemFolder = ItemFactory.Instance.Create(@"d:\data"); + + // is the folder item already a favorite? + var fav = FavoritesManager.Current.GetFavorite(itemFolder); + if (fav == null) + { + if (FavoritesManager.Current.CanAddAsFavorite(itemFolder)) + { + fav = FavoritesManager.Current.AddFavorite(itemFolder); + } + } + + #endregion + } + + void InsertFavorite() + { + // cref: ArcGIS.Desktop.Core.FavoritesManager.GetFavorite + // cref: ArcGIS.Desktop.Core.FavoritesManager.CanAddAsFavorite + // cref: ArcGIS.Desktop.Core.FavoritesManager.InsertFavorite(Item,Int32) + // cref: ArcGIS.Desktop.Core.FavoritesManager.InsertFavorite(Item, Int32,Boolean) + #region Insert a Favorite - Geodatabase path + + string gdbPath = "@C:\\myDataFolder\\myData.gdb"; + + var itemGDB = ItemFactory.Instance.Create(gdbPath); + + // is the item already a favorite? + var fav = FavoritesManager.Current.GetFavorite(itemGDB); + // no; add it with IsAddedToAllNewProjects set to true + if (fav != null) + { + if (FavoritesManager.Current.CanAddAsFavorite(itemGDB)) + FavoritesManager.Current.InsertFavorite(itemGDB, 1, true); + } + #endregion + } + + void AddFavoriteStyle() + { + // cref: ArcGIS.Desktop.Core.FavoritesManager.GetFavorite + // cref: ArcGIS.Desktop.Core.FavoritesManager.CanAddAsFavorite + // cref: ArcGIS.Desktop.Core.FavoritesManager.AddFavorite(Item) + #region Add a Favorite - Style project item + + StyleProjectItem styleItem = Project.Current.GetItems(). + FirstOrDefault(style => (style.Name == "ArcGIS 3D")); + + if (FavoritesManager.Current.CanAddAsFavorite(styleItem)) + { + // add to favorites with IsAddedToAllNewProjects set to false + FavoritesManager.Current.AddFavorite(styleItem); + } + + #endregion + } + + void ToggleFavoriteFlag() + { + // cref: ArcGIS.Desktop.Core.FavoritesManager.GetFavorite + // cref: ArcGIS.Desktop.Core.FavoritesManager.ClearIsAddedToAllNewProjects + // cref: ArcGIS.Desktop.Core.FavoritesManager.SetIsAddedToAllNewProjects + #region Toggle the flag IsAddedToAllNewProjects for a favorite + + var itemFolder = ItemFactory.Instance.Create(@"d:\data"); + + // is the folder item already a favorite? + var fav = FavoritesManager.Current.GetFavorite(itemFolder); + if (fav != null) + { + if (fav.IsAddedToAllNewProjects) + FavoritesManager.Current.ClearIsAddedToAllNewProjects(fav.Item); + else + FavoritesManager.Current.SetIsAddedToAllNewProjects(fav.Item); + } + #endregion + } + + void GetFavorites() + { + // cref: ArcGIS.Desktop.Core.FavoritesManager.GetFavorites + #region Get the set of favorites and iterate + var favorites = FavoritesManager.Current.GetFavorites(); + foreach (var favorite in favorites) + { + bool isAddedToAllProjects = favorite.IsAddedToAllNewProjects; + // retrieve the underlying item of the favorite + Item item = favorite.Item; + + // Item properties + var itemType = item.TypeID; + var path = item.Path; + + // if it's a folder item + if (item is FolderConnectionProjectItem) + { + } + // if it's a goedatabase item + else if (item is GDBProjectItem) + { + } + // else + } + + #endregion + } + + void RemoveAllFavorites() + { + // cref: ArcGIS.Desktop.Core.FavoritesManager.GetFavorites + // cref: ArcGIS.Desktop.Core.FavoritesManager.RemoveFavorite(ArcGIS.Desktop.Core.Item) + #region Remove All Favorites + + var favorites = FavoritesManager.Current.GetFavorites(); + foreach (var favorite in favorites) + FavoritesManager.Current.RemoveFavorite(favorite.Item); + + #endregion + } + + void FavoriteEvent() + { + // cref: ArcGIS.Desktop.Core.Events.FavoritesChangedEvent + // cref: ArcGIS.Desktop.Core.Events.FavoritesChangedEvent.Subscribe + // cref: ArcGIS.Desktop.Core.FavoritesManager.GetFavorites + #region FavoritesChangedEvent + + ArcGIS.Desktop.Core.Events.FavoritesChangedEvent.Subscribe((args) => + { + // favorites have changed + int count = FavoritesManager.Current.GetFavorites().Count; + }); + + #endregion + } + } + #endregion + + #region ProSnippet Group: Metadata + #endregion + + public async Task MedataExamples() + { + string sourceXMLMetadataAsString = string.Empty; + + + // cref: Item: Get its IMetadata interface;ArcGIS.Desktop.Core.IMetadata + #region Item: Get its IMetadata interface + + Item gdbItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\regionFive.gdb"); + IMetadata gdbMetadataItem = gdbItem as IMetadata; + + #endregion + + // cref: Item: Get an item's metadata: GetXML;ArcGIS.Desktop.Core.IMetadata.GetXml + // cref: Item: Get an item's metadata: GetXML;ArcGIS.Desktop.Core.Item.GetXml + #region Item: Get an item's metadata: GetXML + + string gdbXMLMetadataXmlAsString = string.Empty; + gdbXMLMetadataXmlAsString = await QueuedTask.Run(() => gdbMetadataItem.GetXml()); + //check metadata was returned + if (!string.IsNullOrEmpty(gdbXMLMetadataXmlAsString)) + { + //use the metadata + } + + #endregion + + IMetadata featureClassMetadataItem = null; + + // cref: Item: Set the metadata of an item: SetXML;ArcGIS.Desktop.Core.IMetadata.SetXml(System.String) + // cref: Item: Set the metadata of an item: SetXML;ArcGIS.Desktop.Core.Item.SetXml(System.String) + // cref: Item: Set the metadata of an item: SetXML;ArcGIS.Desktop.Core.Project.SetXml(System.String) + // cref: Item: Set the metadata of an item: SetXML;ARCGIS.DESKTOP.CORE.ITEM.CANEDIT + #region Item: Set the metadata of an item: SetXML + + await QueuedTask.Run(() => + { + var xml = System.IO.File.ReadAllText(@"E:\Data\Metadata\MetadataForFeatClass.xml"); + //Will throw InvalidOperationException if the metadata cannot be changed + //so check "CanEdit" first + if (featureClassMetadataItem.CanEdit()) + featureClassMetadataItem.SetXml(xml); + }); - #endregion - // cref: Item: Get an item's metadata: GetXML;ArcGIS.Desktop.Core.IMetadata.GetXml - // cref: Item: Get an item's metadata: GetXML;ArcGIS.Desktop.Core.Item.GetXml - // cref: Item: Get an item's metadata: GetXML;ArcGIS.Desktop.Core.Project.GetXml - #region Item: Get an item's metadata: GetXML + #endregion - string gdbXMLMetadataXmlAsString = string.Empty; - gdbXMLMetadataXmlAsString = await QueuedTask.Run(() => gdbMetadataItem.GetXml()); - //check metadata was returned - if (!string.IsNullOrEmpty(gdbXMLMetadataXmlAsString)) - { - //use the metadata - } + IMetadata metadataItemToCheck = null; - #endregion + // cref: Item: Check the metadata can be edited: CanEdit;ArcGIS.Desktop.Core.IMetadata.CanEdit + // cref: Item: Check the metadata can be edited: CanEdit;ArcGIS.Desktop.Core.Item.CanEdit + // cref: Item: Check the metadata can be edited: CanEdit;ArcGIS.Desktop.Core.Project.CanEdit + #region Item: Check the metadata can be edited: CanEdit - IMetadata featureClassMetadataItem = null; + bool canEdit1; + //Call CanEdit before calling SetXml + await QueuedTask.Run(() => canEdit1 = metadataItemToCheck.CanEdit()); - // cref: Item: Set the metadata of an item: SetXML;ArcGIS.Desktop.Core.IMetadata.SetXml(System.String) - // cref: Item: Set the metadata of an item: SetXML;ArcGIS.Desktop.Core.Item.SetXml(System.String) - // cref: Item: Set the metadata of an item: SetXML;ArcGIS.Desktop.Core.Project.SetXml(System.String) - #region Item: Set the metadata of an item: SetXML + #endregion - await QueuedTask.Run(() => - { - var xml = System.IO.File.ReadAllText(@"E:\Data\Metadata\MetadataForFeatClass.xml"); - //Will throw InvalidOperationException if the metadata cannot be changed - //so check "CanEdit" first - if (featureClassMetadataItem.CanEdit()) - featureClassMetadataItem.SetXml(xml); - }); + IMetadata metadataItemToSync = null; + // cref: Item: Updates metadata with the current properties of the item: Synchronize;ArcGIS.Desktop.Core.IMetadata.Synchronize + // cref: Item: Updates metadata with the current properties of the item: Synchronize;ArcGIS.Desktop.Core.Item.Synchronize + // cref: Item: Updates metadata with the current properties of the item: Synchronize;ArcGIS.Desktop.Core.Project.Synchronize + #region Item: Updates metadata with the current properties of the item: Synchronize - #endregion + string syncedMetadataXml = string.Empty; + await QueuedTask.Run(() => syncedMetadataXml = metadataItemToSync.Synchronize()); - IMetadata metadataItemToCheck = null; + #endregion - // cref: Item: Check the metadata can be edited: CanEdit;ArcGIS.Desktop.Core.IMetadata.CanEdit - // cref: Item: Check the metadata can be edited: CanEdit;ArcGIS.Desktop.Core.Item.CanEdit - // cref: Item: Check the metadata can be edited: CanEdit;ArcGIS.Desktop.Core.Project.CanEdit - #region Item: Check the metadata can be edited: CanEdit + IMetadata metadataCopyFrom = null; + IMetadata metadataItemImport = null; + // cref: ArcGIS.Desktop.Core.IMetadata.CopyMetadataFromItem(ArcGIS.Desktop.Core.Item) + // cref: ArcGIS.Desktop.Core.Item.CopyMetadataFromItem(ArcGIS.Desktop.Core.Item) + // cref: ArcGIS.Desktop.Core.Project.CopyMetadataFromItem(ArcGIS.Desktop.Core.Item) + // cref: ARCGIS.DESKTOP.CORE.ITEMFACTORY.CREATE + #region Item: Copy metadata from the source item's metadata: CopyMetadataFromItem - bool canEdit1; - //Call CanEdit before calling SetXml - await QueuedTask.Run(() => canEdit1 = metadataItemToCheck.CanEdit()); + Item featureClassItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\regionFive.gdb\SourceFeatureClass"); + await QueuedTask.Run(() => metadataItemImport.CopyMetadataFromItem(featureClassItem)); - #endregion + #endregion + + // cref: ArcGIS.Desktop.Core.IMetadata.DeleteMetadataContent(ArcGIS.Desktop.Core.MDDeleteContentOption) + // cref: ArcGIS.Desktop.Core.Item.DeleteMetadataContent(ArcGIS.Desktop.Core.MDDeleteContentOption) + // cref: ArcGIS.Desktop.Core.Project.DeleteMetadataContent(ArcGIS.Desktop.Core.MDDeleteContentOption) + // cref: ARCGIS.DESKTOP.CORE.ITEMFACTORY.CREATE + #region Item: Delete certain content from the metadata of the current item: DeleteMetadataContent + + Item featureClassWithMetadataItem = ItemFactory.Instance.Create(@"C:\projectBeta\GDBs\regionFive.gdb\SourceFeatureClass"); + //Delete thumbnail content from item's metadata + await QueuedTask.Run(() => featureClassWithMetadataItem.DeleteMetadataContent(MDDeleteContentOption.esriMDDeleteThumbnail)); + + #endregion + + //Item gdbItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\regionFive.gdb"); + + // cref: ArcGIS.Desktop.Core.IMetadata.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption) + // cref: ArcGIS.Desktop.Core.IMetadata.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,System.String) + // cref: ArcGIS.Desktop.Core.Item.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption) + // cref: ArcGIS.Desktop.Core.Item.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,System.String) + // cref: ArcGIS.Desktop.Core.Project.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption) + // cref: ArcGIS.Desktop.Core.Project.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,System.String) + #region Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata + + // the input path can be the path to an item with metadata, or a URI to an XML file + IMetadata metadataItemImport1 = null; + await QueuedTask.Run(() => metadataItemImport1.ImportMetadata(@"E:\YellowStone.gdb\MyDataset\MyFeatureClass", MDImportExportOption.esriCurrentMetadataStyle)); + + #endregion - IMetadata metadataItemToSync = null; + IMetadata metadataItemImport2 = null; - // cref: Item: Updates metadata with the current properties of the item: Synchronize;ArcGIS.Desktop.Core.IMetadata.Synchronize - // cref: Item: Updates metadata with the current properties of the item: Synchronize;ArcGIS.Desktop.Core.Item.Synchronize - // cref: Item: Updates metadata with the current properties of the item: Synchronize;ArcGIS.Desktop.Core.Project.Synchronize - #region Item: Updates metadata with the current properties of the item: Synchronize + // cref: ArcGIS.Desktop.Core.IMetadata.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,System.String) + #region Item: Updates metadata with the imported metadata: ImportMetadata - string syncedMetadataXml = string.Empty; - await QueuedTask.Run(() => syncedMetadataXml = metadataItemToSync.Synchronize()); + // the input path can be the path to an item with metadata, or a URI to an XML file - #endregion + await QueuedTask.Run(() => metadataItemImport2.ImportMetadata(@"E:\YellowStone.gdb\MyDataset\MyFeatureClass", MDImportExportOption.esriCustomizedStyleSheet, @"E:\StyleSheets\Import\MyImportStyleSheet.xslt")); - IMetadata metadataCopyFrom = null; - IMetadata metadataItemImport = null; - // cref: Item: Copy metadata from the source item's metadata: CopyMetadataFromItem;ArcGIS.Desktop.Core.IMetadata.CopyMetadataFromItem(ArcGIS.Desktop.Core.Item) - // cref: Item: Copy metadata from the source item's metadata: CopyMetadataFromItem;ArcGIS.Desktop.Core.Item.CopyMetadataFromItem(ArcGIS.Desktop.Core.Item) - // cref: Item: Copy metadata from the source item's metadata: CopyMetadataFromItem;ArcGIS.Desktop.Core.Project.CopyMetadataFromItem(ArcGIS.Desktop.Core.Item) - #region Item: Copy metadata from the source item's metadata: CopyMetadataFromItem + #endregion - Item featureClassItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\regionFive.gdb\SourceFeatureClass"); - await QueuedTask.Run(() => metadataItemImport.CopyMetadataFromItem(featureClassItem)); + IMetadata metadataItemExport1 = null; - #endregion + // cref: ArcGIS.Desktop.Core.IMetadata.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) + // cref: ArcGIS.Desktop.Core.IMetadata.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) + // cref: ArcGIS.Desktop.Core.Item.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) + // cref: ArcGIS.Desktop.Core.Item.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) + // cref: ArcGIS.Desktop.Core.Project.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) + // cref: ArcGIS.Desktop.Core.Project.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) + #region Item: export the metadata of the currently selected item: ExportMetadata - // cref: Item: Delete metadata from the source item's metadata: DeleteMetadataContent;ArcGIS.Desktop.Core.IMetadata.DeleteMetadataContent(ArcGIS.Desktop.Core.MDDeleteContentOption) - // cref: Item: Delete metadata from the source item's metadata: DeleteMetadataContent;ArcGIS.Desktop.Core.Item.DeleteMetadataContent(ArcGIS.Desktop.Core.MDDeleteContentOption) - // cref: Item: Delete metadata from the source item's metadata: DeleteMetadataContent;ArcGIS.Desktop.Core.Project.DeleteMetadataContent(ArcGIS.Desktop.Core.MDDeleteContentOption) - #region Item: Delete certain content from the metadata of the current item: DeleteMetadataContent + await QueuedTask.Run(() => metadataItemExport1.ExportMetadata(@"E:\Temp\OutputXML.xml", MDImportExportOption.esriCurrentMetadataStyle, MDExportRemovalOption.esriExportExactCopy)); - Item featureClassWithMetadataItem = ItemFactory.Instance.Create(@"C:\projectBeta\GDBs\regionFive.gdb\SourceFeatureClass"); - //Delete thumbnail content from item's metadata - await QueuedTask.Run(() => featureClassWithMetadataItem.DeleteMetadataContent(MDDeleteContentOption.esriMDDeleteThumbnail)); + #endregion - #endregion + IMetadata metadataItemExport2 = null; - //Item gdbItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\regionFive.gdb"); + // cref: ArcGIS.Desktop.Core.IMetadata.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) + // cref: ArcGIS.Desktop.Core.IMetadata.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) + // cref: ArcGIS.Desktop.Core.Item.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) + // cref: ArcGIS.Desktop.Core.Item.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) + // cref: ArcGIS.Desktop.Core.Project.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) + // cref: ArcGIS.Desktop.Core.Project.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) + #region Item: export the metadata of the currently selected item: ExportMetadata - // cref: Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata;ArcGIS.Desktop.Core.IMetadata.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption) - // cref: Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata;ArcGIS.Desktop.Core.IMetadata.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,System.String) - // cref: Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata;ArcGIS.Desktop.Core.Item.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption) - // cref: Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata;ArcGIS.Desktop.Core.Item.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,System.String) - // cref: Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata;ArcGIS.Desktop.Core.Project.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption) - // cref: Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata;ArcGIS.Desktop.Core.Project.ImportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,System.String) - #region Item: Updates metadata with the imported metadata - the input path can be the path to an item with metadata, or a URI to a XML file: ImportMetadata + await QueuedTask.Run(() => metadataItemExport2.ExportMetadata(@"E:\Temp\OutputXML.xml", MDImportExportOption.esriCustomizedStyleSheet, MDExportRemovalOption.esriExportExactCopy, @"E:\StyleSheets\Export\MyExportStyleSheet.xslt")); - // the input path can be the path to an item with metadata, or a URI to an XML file - IMetadata metadataItemImport1 = null; - await QueuedTask.Run(() => metadataItemImport1.ImportMetadata(@"E:\YellowStone.gdb\MyDataset\MyFeatureClass", MDImportExportOption.esriCurrentMetadataStyle)); + #endregion - #endregion + IMetadata metadataItemToSaveAsXML = null; - IMetadata metadataItemImport2 = null; + // cref: ArcGIS.Desktop.Core.IMetadata.SaveMetadataAsXML(System.String,ArcGIS.Desktop.Core.MDSaveAsXMLOption) + // cref: ArcGIS.Desktop.Core.Item.SaveMetadataAsXML(System.String,ArcGIS.Desktop.Core.MDSaveAsXMLOption) + // cref: ArcGIS.Desktop.Core.Project.SaveMetadataAsXML(System.String,ArcGIS.Desktop.Core.MDSaveAsXMLOption) + #region Item: Save the metadata of the current item as XML: SaveMetadataAsXML - #region Item: Updates metadata with the imported metadata: ImportMetadata + await QueuedTask.Run(() => metadataItemToSaveAsXML.SaveMetadataAsXML(@"E:\Temp\OutputXML.xml", MDSaveAsXMLOption.esriExactCopy)); - // the input path can be the path to an item with metadata, or a URI to an XML file + #endregion - await QueuedTask.Run(() => metadataItemImport2.ImportMetadata(@"E:\YellowStone.gdb\MyDataset\MyFeatureClass", MDImportExportOption.esriCustomizedStyleSheet, @"E:\StyleSheets\Import\MyImportStyleSheet.xslt")); + IMetadata metadataItemToSaveAsHTML = null; - #endregion + // cref: ArcGIS.Desktop.Core.IMetadata.SaveMetadataAsHTML(System.String,ArcGIS.Desktop.Core.MDSaveAsHTMLOption) + // cref: ArcGIS.Desktop.Core.Item.SaveMetadataAsHTML(System.String,ArcGIS.Desktop.Core.MDSaveAsHTMLOption) + // cref: ArcGIS.Desktop.Core.Project.SaveMetadataAsHTML(System.String,ArcGIS.Desktop.Core.MDSaveAsHTMLOption) + #region Item: Save the metadata of the current item as HTML: SaveMetadataAsHTML - IMetadata metadataItemExport1 = null; + await QueuedTask.Run(() => metadataItemToSaveAsHTML.SaveMetadataAsHTML(@"E:\Temp\OutputHTML.htm", MDSaveAsHTMLOption.esriCurrentMetadataStyle)); - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.IMetadata.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.IMetadata.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.Item.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.Item.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.Project.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.Project.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) - #region Item: export the metadata of the currently selected item: ExportMetadata + #endregion - await QueuedTask.Run(() => metadataItemExport1.ExportMetadata(@"E:\Temp\OutputXML.xml", MDImportExportOption.esriCurrentMetadataStyle, MDExportRemovalOption.esriExportExactCopy)); + IMetadata metadataItemToSaveAsUsingCustomXSLT = null; - #endregion + // cref: ArcGIS.Desktop.Core.IMetadata.SaveMetadataAsUsingCustomXSLT(System.String,System.String) + // cref: ArcGIS.Desktop.Core.Item.SaveMetadataAsUsingCustomXSLT(System.String,System.String) + // cref: ArcGIS.Desktop.Core.Project.SaveMetadataAsUsingCustomXSLT(System.String,System.String) + #region Item: Save the metadata of the current item using customized XSLT: SaveMetadataAsUsingCustomXSLT - IMetadata metadataItemExport2 = null; + await QueuedTask.Run(() => metadataItemToSaveAsUsingCustomXSLT.SaveMetadataAsUsingCustomXSLT(@"E:\Data\Metadata\CustomXSLT.xsl", @"E:\Temp\OutputXMLCustom.xml")); + #endregion - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.IMetadata.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.IMetadata.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.Item.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.Item.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.Project.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption) - // cref: Item: export the metadata of the currently selected item: ExportMetadata;ArcGIS.Desktop.Core.Project.ExportMetadata(System.String,ArcGIS.Desktop.Core.MDImportExportOption,ArcGIS.Desktop.Core.MDExportRemovalOption,System.String) - #region Item: export the metadata of the currently selected item: ExportMetadata + // cref: ArcGIS.Desktop.Core.IMetadata.UpgradeMetadata(ArcGIS.Desktop.Core.MDUpgradeOption) + // cref: ArcGIS.Desktop.Core.Item.UpgradeMetadata(ArcGIS.Desktop.Core.MDUpgradeOption) + // cref: ArcGIS.Desktop.Core.Project.UpgradeMetadata(ArcGIS.Desktop.Core.MDUpgradeOption) + #region Item: Upgrade the metadata of the current item: UpgradeMetadata - await QueuedTask.Run(() => metadataItemExport2.ExportMetadata(@"E:\Temp\OutputXML.xml", MDImportExportOption.esriCustomizedStyleSheet, MDExportRemovalOption.esriExportExactCopy, @"E:\StyleSheets\Export\MyExportStyleSheet.xslt")); + var fgdcItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\testData.gdb"); + await QueuedTask.Run(() => fgdcItem.UpgradeMetadata(MDUpgradeOption.esriUpgradeFgdcCsdgm)); + #endregion - #endregion + } - IMetadata metadataItemToSaveAsXML = null; + #region ProSnippet Group: Project Units + #endregion - // cref: Item: Save the metadata of the current item as XML: SaveMetadataAsXML;ArcGIS.Desktop.Core.IMetadata.SaveMetadataAsXML(System.String,ArcGIS.Desktop.Core.MDSaveAsXMLOption) - // cref: Item: Save the metadata of the current item as XML: SaveMetadataAsXML;ArcGIS.Desktop.Core.Item.SaveMetadataAsXML(System.String,ArcGIS.Desktop.Core.MDSaveAsXMLOption) - // cref: Item: Save the metadata of the current item as XML: SaveMetadataAsXML;ArcGIS.Desktop.Core.Project.SaveMetadataAsXML(System.String,ArcGIS.Desktop.Core.MDSaveAsXMLOption) - #region Item: Save the metadata of the current item as XML: SaveMetadataAsXML + public void ProjectUnits1() + { + // cref: ArcGIS.Desktop.Core.UnitFormats.UnitFormatType + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.GetPredefinedProjectUnitFormats + #region Get The Full List of All Available Unit Formats - await QueuedTask.Run(() => metadataItemToSaveAsXML.SaveMetadataAsXML(@"E:\Temp\OutputXML.xml", MDSaveAsXMLOption.esriExactCopy)); + //Must be on the QueuedTask.Run() - #endregion + var unit_formats = Enum.GetValues(typeof(UnitFormatType)) + .OfType().ToList(); + System.Diagnostics.Debug.WriteLine("All available units\r\n"); - IMetadata metadataItemToSaveAsHTML = null; + foreach (var unit_format in unit_formats) + { + var units = DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats(unit_format); + System.Diagnostics.Debug.WriteLine(unit_format.ToString()); - // cref: Item: Save the metadata of the current item as HTML: SaveMetadataAsHTML;ArcGIS.Desktop.Core.IMetadata.SaveMetadataAsHTML(System.String,ArcGIS.Desktop.Core.MDSaveAsHTMLOption) - // cref: Item: Save the metadata of the current item as HTML: SaveMetadataAsHTML;ArcGIS.Desktop.Core.Item.SaveMetadataAsHTML(System.String,ArcGIS.Desktop.Core.MDSaveAsHTMLOption) - // cref: Item: Save the metadata of the current item as HTML: SaveMetadataAsHTML;ArcGIS.Desktop.Core.Project.SaveMetadataAsHTML(System.String,ArcGIS.Desktop.Core.MDSaveAsHTMLOption) - #region Item: Save the metadata of the current item as HTML: SaveMetadataAsHTML + foreach (var display_unit_format in units) + { + var line = $"{display_unit_format.DisplayName}, {display_unit_format.UnitCode}"; + System.Diagnostics.Debug.WriteLine(line); + } + System.Diagnostics.Debug.WriteLine(""); + } + #endregion + } - await QueuedTask.Run(() => metadataItemToSaveAsHTML.SaveMetadataAsHTML(@"E:\Temp\OutputHTML.htm", MDSaveAsHTMLOption.esriCurrentMetadataStyle)); + public void ProjectUnits2() + { + // cref: ArcGIS.Desktop.Core.UnitFormats.UnitFormatType + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.GetProjectUnitFormats + #region Get The List of Unit Formats for the Current Project - #endregion + //Must be on the QueuedTask.Run() - IMetadata metadataItemToSaveAsUsingCustomXSLT = null; + var unit_formats = Enum.GetValues(typeof(UnitFormatType)) + .OfType().ToList(); + System.Diagnostics.Debug.WriteLine("Project units\r\n"); - // cref: Item: Save the metadata of the current item using customized XSLT: SaveMetadataAsUsingCustomXSLT;ArcGIS.Desktop.Core.IMetadata.SaveMetadataAsUsingCustomXSLT(System.String,System.String) - // cref: Item: Save the metadata of the current item using customized XSLT: SaveMetadataAsUsingCustomXSLT;ArcGIS.Desktop.Core.Item.SaveMetadataAsUsingCustomXSLT(System.String,System.String) - // cref: Item: Save the metadata of the current item using customized XSLT: SaveMetadataAsUsingCustomXSLT;ArcGIS.Desktop.Core.Project.SaveMetadataAsUsingCustomXSLT(System.String,System.String) - #region Item: Save the metadata of the current item using customized XSLT: SaveMetadataAsUsingCustomXSLT + foreach (var unit_format in unit_formats) + { + var units = DisplayUnitFormats.Instance.GetProjectUnitFormats(unit_format); + System.Diagnostics.Debug.WriteLine(unit_format.ToString()); - await QueuedTask.Run(() => metadataItemToSaveAsUsingCustomXSLT.SaveMetadataAsUsingCustomXSLT(@"E:\Data\Metadata\CustomXSLT.xsl", @"E:\Temp\OutputXMLCustom.xml")); - #endregion + foreach (var display_unit_format in units) + { + var line = $"{display_unit_format.DisplayName}, {display_unit_format.UnitCode}"; + System.Diagnostics.Debug.WriteLine(line); + } + System.Diagnostics.Debug.WriteLine(""); + } + #endregion + } - // cref: Item: Upgrade the metadata of the current item: UpgradeMetadata;ArcGIS.Desktop.Core.IMetadata.UpgradeMetadata(ArcGIS.Desktop.Core.MDUpgradeOption) - // cref: Item: Upgrade the metadata of the current item: UpgradeMetadata;ArcGIS.Desktop.Core.Item.UpgradeMetadata(ArcGIS.Desktop.Core.MDUpgradeOption) - // cref: Item: Upgrade the metadata of the current item: UpgradeMetadata;ArcGIS.Desktop.Core.Project.UpgradeMetadata(ArcGIS.Desktop.Core.MDUpgradeOption) - #region Item: Upgrade the metadata of the current item: UpgradeMetadata + public void ProjectUnits3() + { + // cref: ArcGIS.Desktop.Core.UnitFormats.UnitFormatType + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.GetProjectUnitFormats + #region Get A Specific List of Unit Formats for the Current Project - var fgdcItem = ItemFactory.Instance.Create(@"C:\projectAlpha\GDBs\testData.gdb"); - await QueuedTask.Run(() => fgdcItem.UpgradeMetadata(MDUpgradeOption.esriUpgradeFgdcCsdgm)); - #endregion + //Must be on the QueuedTask.Run() - } + //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, + //UnitFormatType.Direction, UnitFormatType.Location, UnitFormatType.Page + //UnitFormatType.Symbol2D, UnitFormatType.Symbol3D + var units = DisplayUnitFormats.Instance.GetProjectUnitFormats(UnitFormatType.Distance); - #region ProSnippet Group: Project Units - #endregion + #endregion + } - public void ProjectUnits1() - { - #region Get The Full List of All Available Unit Formats + public void ProjectUnits4() + { + // cref: ArcGIS.Desktop.Core.UnitFormats.UnitFormatType + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.GetDefaultProjectUnitFormat + #region Get The List of Default Formats for the Current Project - //Must be on the QueuedTask.Run() + //Must be on the QueuedTask.Run() - var unit_formats = Enum.GetValues(typeof(UnitFormatType)) - .OfType().ToList(); - System.Diagnostics.Debug.WriteLine("All available units\r\n"); + var unit_formats = Enum.GetValues(typeof(UnitFormatType)) + .OfType().ToList(); + System.Diagnostics.Debug.WriteLine("Default project units\r\n"); - foreach (var unit_format in unit_formats) - { - var units = DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats(unit_format); - System.Diagnostics.Debug.WriteLine(unit_format.ToString()); + foreach (var unit_format in unit_formats) + { + var default_unit = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_format); + var line = $"{unit_format.ToString()}: {default_unit.DisplayName}, {default_unit.UnitCode}"; + System.Diagnostics.Debug.WriteLine(line); + } + System.Diagnostics.Debug.WriteLine(""); - foreach (var display_unit_format in units) - { - var line = $"{display_unit_format.DisplayName}, {display_unit_format.UnitCode}"; - System.Diagnostics.Debug.WriteLine(line); - } - System.Diagnostics.Debug.WriteLine(""); - } - #endregion - } + #endregion + } - public void ProjectUnits2() - { - #region Get The List of Unit Formats for the Current Project + public void ProjectUnits5() + { + // cref: ArcGIS.Desktop.Core.UnitFormats.UnitFormatType + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.GetDefaultProjectUnitFormat + #region Get A Specific Default Unit Format for the Current Project - //Must be on the QueuedTask.Run() + //Must be on the QueuedTask.Run() - var unit_formats = Enum.GetValues(typeof(UnitFormatType)) - .OfType().ToList(); - System.Diagnostics.Debug.WriteLine("Project units\r\n"); + //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, + //UnitFormatType.Direction, UnitFormatType.Location, UnitFormatType.Page + //UnitFormatType.Symbol2D, UnitFormatType.Symbol3D + var default_unit = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat( + UnitFormatType.Distance); - foreach (var unit_format in unit_formats) - { - var units = DisplayUnitFormats.Instance.GetProjectUnitFormats(unit_format); - System.Diagnostics.Debug.WriteLine(unit_format.ToString()); + #endregion + } - foreach (var display_unit_format in units) - { - var line = $"{display_unit_format.DisplayName}, {display_unit_format.UnitCode}"; - System.Diagnostics.Debug.WriteLine(line); - } - System.Diagnostics.Debug.WriteLine(""); - } - #endregion - } + public void ProjectUnits6() + { + // cref: ArcGIS.Desktop.Core.UnitFormats.UnitFormatType + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.GetPredefinedProjectUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.SetProjectUnitFormats + #region Set a Specific List of Unit Formats for the Current Project - public void ProjectUnits3() - { + //Must be on the QueuedTask.Run() - #region Get A Specific List of Unit Formats for the Current Project + //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, + //UnitFormatType.Direction, UnitFormatType.Location - //Must be on the QueuedTask.Run() + //Get the full list of all available location units + var all_units = DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats( + UnitFormatType.Location); + //keep units with an even factory code + var list_units = all_units.Where(du => du.UnitCode % 2 == 0).ToList(); - //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, - //UnitFormatType.Direction, UnitFormatType.Location, UnitFormatType.Page - //UnitFormatType.Symbol2D, UnitFormatType.Symbol3D - var units = DisplayUnitFormats.Instance.GetProjectUnitFormats(UnitFormatType.Distance); + //set them as the new location unit collection. A new default is not being specified... + DisplayUnitFormats.Instance.SetProjectUnitFormats(list_units); - #endregion - } + //set them as the new location unit collection along with a new default + DisplayUnitFormats.Instance.SetProjectUnitFormats( + list_units, list_units.First()); - public void ProjectUnits4() - { - #region Get The List of Default Formats for the Current Project + //Note: UnitFormatType.Page, UnitFormatType.Symbol2D, UnitFormatType.Symbol3D + //cannot be set. + #endregion + } - //Must be on the QueuedTask.Run() + public void ProjectUnits7() + { + // cref: ArcGIS.Desktop.Core.UnitFormats.UnitFormatType + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.GetDefaultProjectUnitFormat + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.SetDefaultProjectUnitFormat - var unit_formats = Enum.GetValues(typeof(UnitFormatType)) - .OfType().ToList(); - System.Diagnostics.Debug.WriteLine("Default project units\r\n"); + #region Set the Defaults for the Project Unit Formats - foreach (var unit_format in unit_formats) - { - var default_unit = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_format); - var line = $"{unit_format.ToString()}: {default_unit.DisplayName}, {default_unit.UnitCode}"; - System.Diagnostics.Debug.WriteLine(line); - } - System.Diagnostics.Debug.WriteLine(""); + //Must be on the QueuedTask.Run() - #endregion - } + var unit_formats = Enum.GetValues(typeof(UnitFormatType)).OfType().ToList(); + foreach (var unit_type in unit_formats) + { + var current_default = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_type); + //Arbitrarily pick the last unit in each unit format list + var replacement = DisplayUnitFormats.Instance.GetProjectUnitFormats(unit_type).Last(); + DisplayUnitFormats.Instance.SetDefaultProjectUnitFormat(replacement); - public void ProjectUnits5() - { + var line = $"{current_default.DisplayName}, {current_default.UnitName}, {current_default.UnitCode}"; + var line2 = $"{replacement.DisplayName}, {replacement.UnitName}, {replacement.UnitCode}"; - #region Get A Specific Default Unit Format for the Current Project + System.Diagnostics.Debug.WriteLine($"Format: {unit_type.ToString()}"); + System.Diagnostics.Debug.WriteLine($" Current default: {line}"); + System.Diagnostics.Debug.WriteLine($" Replacement default: {line2}"); + } - //Must be on the QueuedTask.Run() + #endregion + } - //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, - //UnitFormatType.Direction, UnitFormatType.Location, UnitFormatType.Page - //UnitFormatType.Symbol2D, UnitFormatType.Symbol3D - var default_unit = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat( - UnitFormatType.Distance); + public void Project8() + { + // cref: ArcGIS.Desktop.Core.UnitFormats.UnitFormatType + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.GetProjectUnitFormats + // cref: ArcGIS.Desktop.Core.UnitFormats.IDisplayUnitFormats.SetProjectUnitFormats + #region Update Unit Formats for the Project + + //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, + //UnitFormatType.Direction, UnitFormatType.Location + var angle_units = DisplayUnitFormats.Instance.GetProjectUnitFormats(UnitFormatType.Angular); + + //Edit the display name of each unit - append the abbreviation + foreach (var unit in angle_units) + { + unit.DisplayName = $"{unit.DisplayName} ({unit.Abbreviation})"; + } + //apply the changes to the units and set the default to be the first entry + DisplayUnitFormats.Instance.SetProjectUnitFormats(angle_units, angle_units.First()); - #endregion - } + //The project must be saved to persist the changes... + #endregion - public void ProjectUnits6() - { + } - #region Set a Specific List of Unit Formats for the Current Project + #region ProSnippet Group: Application Options + #endregion - //Must be on the QueuedTask.Run() + public void GeneralOptions1() + { + // cref: ArcGIS.Desktop.Core.GeneralOptions + // cref: ArcGIS.Desktop.Core.GeneralOptions.StartupOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.StartupProjectPath + // cref: ArcGIS.Desktop.Core.GeneralOptions.HomeFolderOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomHomeFolder + // cref: ArcGIS.Desktop.Core.GeneralOptions.DefaultGeodatabaseOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomDefaultGeodatabase + // cref: ArcGIS.Desktop.Core.GeneralOptions.DefaultToolboxOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomDefaultToolbox + // cref: ArcGIS.Desktop.Core.GeneralOptions.ProjectCreateInFolder + #region Get GeneralOptions - //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, - //UnitFormatType.Direction, UnitFormatType.Location + var startMode = ApplicationOptions.GeneralOptions.StartupOption; + var aprx_path = ApplicationOptions.GeneralOptions.StartupProjectPath; - //Get the full list of all available location units - var all_units = DisplayUnitFormats.Instance.GetPredefinedProjectUnitFormats( - UnitFormatType.Location); - //keep units with an even factory code - var list_units = all_units.Where(du => du.UnitCode % 2 == 0).ToList(); + var hf_option = ApplicationOptions.GeneralOptions.HomeFolderOption; + var folder = ApplicationOptions.GeneralOptions.CustomHomeFolder; - //set them as the new location unit collection. A new default is not being specified... - DisplayUnitFormats.Instance.SetProjectUnitFormats(list_units); + var gdb_option = ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption; + var def_gdb = ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase; - //set them as the new location unit collection along with a new default - DisplayUnitFormats.Instance.SetProjectUnitFormats( - list_units, list_units.First()); + var tbx_option = ApplicationOptions.GeneralOptions.DefaultToolboxOption; + var def_tbx = ApplicationOptions.GeneralOptions.CustomDefaultToolbox; - //Note: UnitFormatType.Page, UnitFormatType.Symbol2D, UnitFormatType.Symbol3D - //cannot be set. - #endregion - } + var create_in_folder = ApplicationOptions.GeneralOptions.ProjectCreateInFolder; - public void ProjectUnits7() - { - #region Set the Defaults for the Project Unit Formats + #endregion - //Must be on the QueuedTask.Run() + // cref: ArcGIS.Desktop.Core.GeneralOptions + // cref: ArcGIS.Desktop.Core.GeneralOptions.StartupOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.StartupProjectPath + // cref: ArcGIS.Desktop.Core.GeneralOptions.HomeFolderOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomHomeFolder + // cref: ArcGIS.Desktop.Core.GeneralOptions.DefaultGeodatabaseOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomDefaultGeodatabase + // cref: ArcGIS.Desktop.Core.GeneralOptions.DefaultToolboxOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomDefaultToolbox + // cref: ArcGIS.Desktop.Core.GeneralOptions.ProjectCreateInFolder + #region Set GeneralOptions to Use Custom Settings + + //Set the application to use a custom project, home folder, gdb, and toolbox + //In each case, the custom _path_ must be set _first_ before + //setting the "option". This ensures the application remains + //in a consistent state. This is the same behavior as on the Pro UI. + if (string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.StartupProjectPath)) + ApplicationOptions.GeneralOptions.StartupProjectPath = @"D:\data\usa.aprx";//custom project path first + ApplicationOptions.GeneralOptions.StartupOption = StartProjectMode.WithDefaultProject;//option to use it second + + if (string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomHomeFolder)) + ApplicationOptions.GeneralOptions.CustomHomeFolder = @"D:\home_folder";//custom home folder first + ApplicationOptions.GeneralOptions.HomeFolderOption = OptionSetting.UseCustom;//option to use it second + + if (string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase)) + ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase = @"D:\data\usa.gdb";//custom gdb path first + ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption = OptionSetting.UseCustom;//option to use it second + + if (string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomDefaultToolbox)) + ApplicationOptions.GeneralOptions.CustomDefaultToolbox = @"D:\data\usa.tbx";//custom toolbox path first + ApplicationOptions.GeneralOptions.DefaultToolboxOption = OptionSetting.UseCustom;//option to use it second - var unit_formats = Enum.GetValues(typeof(UnitFormatType)).OfType().ToList(); - foreach (var unit_type in unit_formats) - { - var current_default = DisplayUnitFormats.Instance.GetDefaultProjectUnitFormat(unit_type); - //Arbitrarily pick the last unit in each unit format list - var replacement = DisplayUnitFormats.Instance.GetProjectUnitFormats(unit_type).Last(); - DisplayUnitFormats.Instance.SetDefaultProjectUnitFormat(replacement); + #endregion - var line = $"{current_default.DisplayName}, {current_default.UnitName}, {current_default.UnitCode}"; - var line2 = $"{replacement.DisplayName}, {replacement.UnitName}, {replacement.UnitCode}"; - System.Diagnostics.Debug.WriteLine($"Format: {unit_type.ToString()}"); - System.Diagnostics.Debug.WriteLine($" Current default: {line}"); - System.Diagnostics.Debug.WriteLine($" Replacement default: {line2}"); - } + // cref: ArcGIS.Desktop.Core.GeneralOptions + // cref: ArcGIS.Desktop.Core.GeneralOptions.StartupOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.StartupProjectPath + // cref: ArcGIS.Desktop.Core.GeneralOptions.HomeFolderOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomHomeFolder + // cref: ArcGIS.Desktop.Core.GeneralOptions.DefaultGeodatabaseOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomDefaultGeodatabase + // cref: ArcGIS.Desktop.Core.GeneralOptions.DefaultToolboxOption + // cref: ArcGIS.Desktop.Core.GeneralOptions.CustomDefaultToolbox + // cref: ArcGIS.Desktop.Core.GeneralOptions.ProjectCreateInFolder + // cref: ArcGIS.Desktop.Core.StartProjectMode + // cref: ArcGIS.Desktop.Core.OptionSetting + #region Set GeneralOptions to Use Defaults + + //Default options can be set regardless of the value of the "companion" + //path (to a project, folder, gdb, toolbox, etc.). The path value is ignored if + //the option setting does not use it. This is the same behavior as on the Pro UI. + ApplicationOptions.GeneralOptions.StartupOption = StartProjectMode.ShowStartPage; + ApplicationOptions.GeneralOptions.HomeFolderOption = OptionSetting.UseDefault; + ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption = OptionSetting.UseDefault; + ApplicationOptions.GeneralOptions.DefaultToolboxOption = OptionSetting.UseDefault;//set default option first + + //path values can (optionally) be set (back) to null if their + //"companion" option setting is the default option. + if (ApplicationOptions.GeneralOptions.StartupOption != StartProjectMode.WithDefaultProject) + ApplicationOptions.GeneralOptions.StartupProjectPath = null; + if (ApplicationOptions.GeneralOptions.HomeFolderOption == OptionSetting.UseDefault) + ApplicationOptions.GeneralOptions.CustomHomeFolder = null; + if (ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption == OptionSetting.UseDefault) + ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase = null; + if (ApplicationOptions.GeneralOptions.DefaultToolboxOption == OptionSetting.UseDefault) + ApplicationOptions.GeneralOptions.CustomDefaultToolbox = null; - #endregion - } + #endregion + } - public void Project8() - { - #region Update Unit Formats for the Project + public void DownloadOptions1() + { + // cref: ArcGIS.Desktop.Core.ApplicationOptions.DownloadOptions + // cref: ArcGIS.Desktop.Core.DownloadOptions + #region Get DownloadOptions - //UnitFormatType.Angular, UnitFormatType.Area, UnitFormatType.Distance, - //UnitFormatType.Direction, UnitFormatType.Location - var angle_units = DisplayUnitFormats.Instance.GetProjectUnitFormats(UnitFormatType.Angular); + var staging = ApplicationOptions.DownloadOptions.StagingLocation; - //Edit the display name of each unit - append the abbreviation - foreach (var unit in angle_units) - { - unit.DisplayName = $"{unit.DisplayName} ({unit.Abbreviation})"; - } - //apply the changes to the units and set the default to be the first entry - DisplayUnitFormats.Instance.SetProjectUnitFormats(angle_units, angle_units.First()); + var ppkx_loc = ApplicationOptions.DownloadOptions.UnpackPPKXLocation; + var ask_ppkx_loc = ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation; - //The project must be saved to persist the changes... - #endregion + var other_loc = ApplicationOptions.DownloadOptions.UnpackOtherLocation; + var ask_other_loc = ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation; + var use_proj_folder = ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation; - } + var offline_loc = ApplicationOptions.DownloadOptions.OfflineMapsLocation; + var ask_offline_loc = ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation; + var use_proj_folder_offline = ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation; - #region ProSnippet Group: Application Options - #endregion + #endregion - public void GeneralOptions1() - { - #region Get GeneralOptions + // cref: ArcGIS.Desktop.Core.DownloadOptions + // cref: ArcGIS.Desktop.Core.DownloadOptions.StagingLocation + #region Set Staging Location for Sharing and Publishing - var startMode = ApplicationOptions.GeneralOptions.StartupOption; - var aprx_path = ApplicationOptions.GeneralOptions.StartupProjectPath; + ApplicationOptions.DownloadOptions.StagingLocation = @"D:\data\staging"; - var hf_option = ApplicationOptions.GeneralOptions.HomeFolderOption; - var folder = ApplicationOptions.GeneralOptions.CustomHomeFolder; + #endregion - var gdb_option = ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption; - var def_gdb = ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase; + // cref: ArcGIS.Desktop.Core.DownloadOptions + // cref: ArcGIS.Desktop.Core.DownloadOptions.AskForUnpackPPKXLocation + #region Set DownloadOptions for PPKX + //Options are mutually exclusive. + + //Setting ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation = true + //superseeds any value in ApplicationOptions.DownloadOptions.UnpackPPKXLocation + //and will prompt the user on an unpack. The value of + //ApplicationOptions.DownloadOptions.UnpackPPKXLocation will be unaffected + //and is ignored. This is the same behavior as on the Pro UI. + ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation = true;//override location + + //The default location is typically \ArcGIS\Packages + //Setting ApplicationOptions.DownloadOptions.UnpackPPKXLocation to any + //location overrides ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation + //and sets it to false. This is the same behavior as on the Pro UI. + ApplicationOptions.DownloadOptions.UnpackPPKXLocation = @"D:\data\for_ppkx"; + + //Or, if ApplicationOptions.DownloadOptions.UnpackPPKXLocation already + //contains a valid path, set ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation + //explicitly to false to use the UnpackPPKXLocation + if (!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.UnpackPPKXLocation)) + ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation = false; - var tbx_option = ApplicationOptions.GeneralOptions.DefaultToolboxOption; - var def_tbx = ApplicationOptions.GeneralOptions.CustomDefaultToolbox; + #endregion - var create_in_folder = ApplicationOptions.GeneralOptions.ProjectCreateInFolder; + // cref: ArcGIS.Desktop.Core.DownloadOptions + // cref: ArcGIS.Desktop.Core.DownloadOptions.UnpackOtherLocation + #region Set DownloadOptions for UnpackOther + //UnpackOther settings control unpacking of anything _other than_ + //a ppkx or aptx. Options are mutually exclusive. + + //Set ApplicationOptions.DownloadOptions.UnpackOtherLocation explicitly to + //toggle ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation and + //ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false + //Note: default is typically \ArcGIS\Packages, _not_ null. + //This is the same behavior as on the Pro UI. + ApplicationOptions.DownloadOptions.UnpackOtherLocation = @"D:\data\for_other"; + + //or...to use a location already stored in UnpackOtherLocation as the + //default without changing it, + //set ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation and + //ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false + //explicitly. This is the same behavior as on the Pro UI. + if (!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.UnpackOtherLocation)) + { + ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation = false; + ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation = false; + } + + //Setting ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation to + //true overrides any UnpackOtherLocation value and sets + //ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false. + //This is the same behavior as on the Pro UI. + ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation = true; + + //Setting ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to + //true overrides any UnpackOtherLocation value and sets + //ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation to false. + //This is the same behavior as on the Pro UI. + ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation = false; - #endregion + #endregion - #region Set GeneralOptions to Use Custom Settings + // cref: ArcGIS.Desktop.Core.DownloadOptions + // cref: ArcGIS.Desktop.Core.DownloadOptions.OfflineMapsLocation + #region Set DownloadOptions for OfflineMaps + //OfflineMaps settings control where map content that is taken + //offline is copied to on the local machine. Options are mutually exclusive. + + //Set ApplicationOptions.DownloadOptions.OfflineMapsLocation explicitly to + //toggle ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation and + //ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false + //Note: default is typically \ArcGIS\OfflineMaps, _not_ null. + //This is the same behavior as on the Pro UI. + ApplicationOptions.DownloadOptions.OfflineMapsLocation = @"D:\data\for_offline"; + + //or...to use a location already stored in OfflineMapsLocation as the + //default without changing it, + //set ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation and + //ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false + //explicitly. + if (!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.OfflineMapsLocation)) + { + ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation = false; + ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation = false; + } + + //Setting ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation to + //true overrides any OfflineMapsLocation value and sets + //ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false. + //This is the same behavior as on the Pro UI. + ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation = true; + + //Setting ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to + //true overrides any OfflineMapsLocation value and sets + //ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation to false. + //This is the same behavior as on the Pro UI. + ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation = true; - //Set the application to use a custom project, home folder, gdb, and toolbox - //In each case, the custom _path_ must be set _first_ before - //setting the "option". This ensures the application remains - //in a consistent state. This is the same behavior as on the Pro UI. - if (string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.StartupProjectPath)) - ApplicationOptions.GeneralOptions.StartupProjectPath = @"D:\data\usa.aprx";//custom project path first - ApplicationOptions.GeneralOptions.StartupOption = StartProjectMode.WithDefaultProject;//option to use it second + #endregion - if (string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomHomeFolder)) - ApplicationOptions.GeneralOptions.CustomHomeFolder = @"D:\home_folder";//custom home folder first - ApplicationOptions.GeneralOptions.HomeFolderOption = OptionSetting.UseCustom;//option to use it second - - if (string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase)) - ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase = @"D:\data\usa.gdb";//custom gdb path first - ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption = OptionSetting.UseCustom;//option to use it second - - if (string.IsNullOrEmpty(ApplicationOptions.GeneralOptions.CustomDefaultToolbox)) - ApplicationOptions.GeneralOptions.CustomDefaultToolbox = @"D:\data\usa.tbx";//custom toolbox path first - ApplicationOptions.GeneralOptions.DefaultToolboxOption = OptionSetting.UseCustom;//option to use it second - - #endregion - - #region Set GeneralOptions to Use Defaults - - //Default options can be set regardless of the value of the "companion" - //path (to a project, folder, gdb, toolbox, etc.). The path value is ignored if - //the option setting does not use it. This is the same behavior as on the Pro UI. - ApplicationOptions.GeneralOptions.StartupOption = StartProjectMode.ShowStartPage; - ApplicationOptions.GeneralOptions.HomeFolderOption = OptionSetting.UseDefault; - ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption = OptionSetting.UseDefault; - ApplicationOptions.GeneralOptions.DefaultToolboxOption = OptionSetting.UseDefault;//set default option first - - //path values can (optionally) be set (back) to null if their - //"companion" option setting is the default option. - if (ApplicationOptions.GeneralOptions.StartupOption != StartProjectMode.WithDefaultProject) - ApplicationOptions.GeneralOptions.StartupProjectPath = null; - if (ApplicationOptions.GeneralOptions.HomeFolderOption == OptionSetting.UseDefault) - ApplicationOptions.GeneralOptions.CustomHomeFolder = null; - if (ApplicationOptions.GeneralOptions.DefaultGeodatabaseOption == OptionSetting.UseDefault) - ApplicationOptions.GeneralOptions.CustomDefaultGeodatabase = null; - if (ApplicationOptions.GeneralOptions.DefaultToolboxOption == OptionSetting.UseDefault) - ApplicationOptions.GeneralOptions.CustomDefaultToolbox = null; - - #endregion - } - - public void DownloadOptions1() - { - #region Get DownloadOptions - - var staging = ApplicationOptions.DownloadOptions.StagingLocation; - - var ppkx_loc = ApplicationOptions.DownloadOptions.UnpackPPKXLocation; - var ask_ppkx_loc = ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation; - - var other_loc = ApplicationOptions.DownloadOptions.UnpackOtherLocation; - var ask_other_loc = ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation; - var use_proj_folder = ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation; - - var offline_loc = ApplicationOptions.DownloadOptions.OfflineMapsLocation; - var ask_offline_loc = ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation; - var use_proj_folder_offline = ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation; - - #endregion - - #region Set Staging Location for Sharing and Publishing - - ApplicationOptions.DownloadOptions.StagingLocation = @"D:\data\staging"; - - #endregion - - #region Set DownloadOptions for PPKX - //Options are mutually exclusive. - - //Setting ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation = true - //superseeds any value in ApplicationOptions.DownloadOptions.UnpackPPKXLocation - //and will prompt the user on an unpack. The value of - //ApplicationOptions.DownloadOptions.UnpackPPKXLocation will be unaffected - //and is ignored. This is the same behavior as on the Pro UI. - ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation = true;//override location - - //The default location is typically \ArcGIS\Packages - //Setting ApplicationOptions.DownloadOptions.UnpackPPKXLocation to any - //location overrides ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation - //and sets it to false. This is the same behavior as on the Pro UI. - ApplicationOptions.DownloadOptions.UnpackPPKXLocation = @"D:\data\for_ppkx"; - - //Or, if ApplicationOptions.DownloadOptions.UnpackPPKXLocation already - //contains a valid path, set ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation - //explicitly to false to use the UnpackPPKXLocation - if (!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.UnpackPPKXLocation)) - ApplicationOptions.DownloadOptions.AskForUnpackPPKXLocation = false; - - #endregion - - #region Set DownloadOptions for UnpackOther - //UnpackOther settings control unpacking of anything _other than_ - //a ppkx or aptx. Options are mutually exclusive. - - //Set ApplicationOptions.DownloadOptions.UnpackOtherLocation explicitly to - //toggle ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation and - //ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false - //Note: default is typically \ArcGIS\Packages, _not_ null. - //This is the same behavior as on the Pro UI. - ApplicationOptions.DownloadOptions.UnpackOtherLocation = @"D:\data\for_other"; - - //or...to use a location already stored in UnpackOtherLocation as the - //default without changing it, - //set ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation and - //ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false - //explicitly. This is the same behavior as on the Pro UI. - if (!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.UnpackOtherLocation)) - { - ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation = false; - ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation = false; - } - - //Setting ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation to - //true overrides any UnpackOtherLocation value and sets - //ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to false. - //This is the same behavior as on the Pro UI. - ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation = true; - - //Setting ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation to - //true overrides any UnpackOtherLocation value and sets - //ApplicationOptions.DownloadOptions.AskForUnpackOtherLocation to false. - //This is the same behavior as on the Pro UI. - ApplicationOptions.DownloadOptions.UnpackOtherToProjectLocation = false; - - #endregion - - #region Set DownloadOptions for OfflineMaps - //OfflineMaps settings control where map content that is taken - //offline is copied to on the local machine. Options are mutually exclusive. - - //Set ApplicationOptions.DownloadOptions.OfflineMapsLocation explicitly to - //toggle ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation and - //ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false - //Note: default is typically \ArcGIS\OfflineMaps, _not_ null. - //This is the same behavior as on the Pro UI. - ApplicationOptions.DownloadOptions.OfflineMapsLocation = @"D:\data\for_offline"; - - //or...to use a location already stored in OfflineMapsLocation as the - //default without changing it, - //set ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation and - //ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false - //explicitly. - if (!string.IsNullOrEmpty(ApplicationOptions.DownloadOptions.OfflineMapsLocation)) - { - ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation = false; - ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation = false; - } - - //Setting ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation to - //true overrides any OfflineMapsLocation value and sets - //ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to false. - //This is the same behavior as on the Pro UI. - ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation = true; - - //Setting ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation to - //true overrides any OfflineMapsLocation value and sets - //ApplicationOptions.DownloadOptions.AskForOfflineMapsLocation to false. - //This is the same behavior as on the Pro UI. - ApplicationOptions.DownloadOptions.OfflineMapsToProjectLocation = true; - - #endregion - - } - } + } + } } diff --git a/Examples/CoreHost.csproj b/Examples/CoreHost.csproj deleted file mode 100644 index 742e8d5..0000000 --- a/Examples/CoreHost.csproj +++ /dev/null @@ -1,197 +0,0 @@ - - - - - Debug - AnyCPU - {EC7DA7C2-D84A-02CE-0164-F075ED8F375C} - Exe - Properties - CoreHost - CoreHost - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\CoreHost\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\CoreHost\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - \ No newline at end of file diff --git a/Examples/CoreHost/CoreHost.csproj b/Examples/CoreHost/CoreHost.csproj new file mode 100644 index 0000000..40c17ef --- /dev/null +++ b/Examples/CoreHost/CoreHost.csproj @@ -0,0 +1,80 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/CoreHost/ProSnippets.cs b/Examples/CoreHost/ProSnippets.cs index ae01246..076cfec 100644 --- a/Examples/CoreHost/ProSnippets.cs +++ b/Examples/CoreHost/ProSnippets.cs @@ -21,8 +21,8 @@ limitations under the License. namespace ConsoleApplication1 { - // cref: Initializing Core Host;ArcGIS.Core.Hosting.Host.Initialize - // cref: Initializing Core Host;ArcGIS.Core.Hosting.Host.Initialize(ArcGIS.Core.Hosting.Host.LicenseProductCode) + // cref: ArcGIS.Core.Hosting.Host.Initialize + // cref: ArcGIS.Core.Hosting.Host.Initialize(ArcGIS.Core.Hosting.Host.LicenseProductCode) #region Initializing Core Host using ArcGIS.Core.Data; //There must be a reference to ArcGIS.CoreHost.dll @@ -58,7 +58,6 @@ private static string TableString(TableDefinition table) { string name = table.GetName(); return string.Format("{0} ({1})", alias.Length > 0 ? alias : name, name); } - } #endregion } diff --git a/Examples/Editing.csproj b/Examples/Editing.csproj deleted file mode 100644 index fb332ab..0000000 --- a/Examples/Editing.csproj +++ /dev/null @@ -1,201 +0,0 @@ - - - - - Debug - AnyCPU - {695223B4-D531-A24F-DE49-2D264AA808B1} - Library - Properties - Editing - Editing - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\Editing\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\Editing\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Examples/Editing/Attributes.cs b/Examples/Editing/Attributes.cs deleted file mode 100644 index 58674a7..0000000 --- a/Examples/Editing/Attributes.cs +++ /dev/null @@ -1,96 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -using ArcGIS.Desktop.Editing; -using ArcGIS.Desktop.Editing.Attributes; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; -using ArcGIS.Desktop.Framework.Threading.Tasks; -using ArcGIS.Desktop.Internal.Framework.Controls; -using ArcGIS.Desktop.Mapping; - -namespace EditingSDKExamples -{ - internal class Attributes : Button - { - protected override void OnClick() - { - } - - protected void addvalidate() - { - //var featLayer = MappingModule.ActiveTOC.SelectedLayers[0] as FeatureLayer; - var featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer; - - // cref: AddValidate;ArcGIS.Desktop.Editing.Attributes.Attribute.AddValidate(System.Func{System.Collections.Generic.IEnumerable{ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError}}) - // cref: AddValidate;ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError.Create(System.String,ArcGIS.Desktop.Editing.Attributes.Severity) - // cref: AddValidate;ArcGIS.Desktop.Editing.Attributes.Inspector.#ctor(System.Boolean) - // cref: AddValidate;ArcGIS.Desktop.Editing.Attributes.Inspector - #region AddValidate - var insp = new Inspector(); - insp.LoadSchema(featLayer); - var attrib = insp.Where(a => a.FieldName == "Mineral").First(); - - attrib.AddValidate(() => - { - if (attrib.CurrentValue.ToString() == "Salt") - return Enumerable.Empty(); - else return new[] { ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError.Create("Error", ArcGIS.Desktop.Editing.Attributes.Severity.Low) }; - }); - #endregion - } - - protected void inspectorclass() - { - var featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer; - Int64 oid = 42; - - // cref: inspectorclass;ArcGIS.Desktop.Editing.Attributes.Inspector.#ctor(System.Boolean) - // cref: inspectorclass;ArcGIS.Desktop.Editing.EditOperation.Modify(ArcGIS.Desktop.Editing.Attributes.Inspector) - // cref: inspectorclass;ArcGIS.Desktop.Editing.Attributes.Inspector - #region inspectorclass - QueuedTask.Run(() => - { - var insp = new Inspector(); - insp.Load(featLayer, oid); - - //get the shape of the feature - var myGeometry = insp.Shape; - - //get an attribute value by name - var propValue = insp["Prop_value"]; - - //set an attribute value by name - insp["Parcel_no"] = 42; - - //perform the edit - var op = new EditOperation(); - op.Name = "Update parcel"; - op.Modify(insp); - op.Execute(); - }); - #endregion - } - } -} diff --git a/Examples/Editing/Concepts.cs b/Examples/Editing/Concepts.cs index f3b54a9..a65e68a 100644 --- a/Examples/Editing/Concepts.cs +++ b/Examples/Editing/Concepts.cs @@ -71,11 +71,11 @@ protected void UpdateAttrib() //get the geometry of the selected feature. var selectedFeatures = MapView.Active.Map.GetSelection(); var insp = new Inspector(); - insp.Load(selectedFeatures.Keys.First(), selectedFeatures.Values.First()); + insp.Load(selectedFeatures.ToDictionary().Keys.First(), selectedFeatures.ToDictionary().Values.First()); var selGeom = insp.Shape; //var extPolyline = some geometry operation. - var extPolyline = new MapPointBuilder(1.0, 1.0).ToGeometry(); + var extPolyline = new MapPointBuilderEx(1.0, 1.0).ToGeometry(); //set the new geometry back on the feature insp.Shape = extPolyline; @@ -119,9 +119,9 @@ protected void onRowEvent(RowChangedEventArgs args) protected Task onEditComplete(EditCompletedEventArgs args) { //show the count of features changed - Console.WriteLine("Creates: " + args.Creates.Values.Sum(list => list.Count).ToString()); - Console.WriteLine("Modifies: " + args.Modifies.Values.Sum(list => list.Count).ToString()); - Console.WriteLine("Deletes: " + args.Deletes.Values.Sum(list => list.Count).ToString()); + Console.WriteLine("Creates: " + args.Creates.ToDictionary().Values.Sum(list => list.Count).ToString()); + Console.WriteLine("Modifies: " + args.Modifies.ToDictionary().Values.Sum(list => list.Count).ToString()); + Console.WriteLine("Deletes: " + args.Deletes.ToDictionary().Values.Sum(list => list.Count).ToString()); return Task.FromResult(0); } @@ -138,13 +138,15 @@ protected async void SetSnapping() Snapping.SetSnapMode(SnapMode.Point, true); //set multiple snap modes exclusively. All others will be disabled. - Snapping.SetSnapModes(SnapMode.Edge, SnapMode.Point); + //at 2.x - Snapping.SetSnapModes(SnapMode.Edge, SnapMode.Point); + Snapping.SetSnapModes(new List() { SnapMode.Edge, SnapMode.Point }); await QueuedTask.Run(() => { //set snapping options via get/set options var snapOptions = Snapping.GetOptions(myMap); - snapOptions.SnapToSketchEnabled = true; + //at 2.x - snapOptions.SnapToSketchEnabled = true; + snapOptions.IsSnapToSketchEnabled = true; snapOptions.XYTolerance = 100; Snapping.SetOptions(myMap, snapOptions); }); @@ -198,9 +200,10 @@ protected void createTemplate() //get all templates on this layer var layerTemplates = layerDef.FeatureTemplates.ToList(); //copy template to new temporary one - var resTempDef = resTemplate.GetDefinition() as CIMFeatureTemplate; - //could also create a new one here - //var newTemplate = new CIMFeatureTemplate(); + //At 2.x - var resTempDef = resTemplate.GetDefinition() as CIMFeatureTemplate; + var resTempDef = resTemplate.GetDefinition() as CIMRowTemplate; + //could also create a new one here + //var newTemplate = new CIMRowTemplate(); //set template values resTempDef.Name = "Residential copy"; diff --git a/Examples/Editing/Editing.csproj b/Examples/Editing/Editing.csproj new file mode 100644 index 0000000..1898a3f --- /dev/null +++ b/Examples/Editing/Editing.csproj @@ -0,0 +1,80 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/Editing/Events.cs b/Examples/Editing/Events.cs deleted file mode 100644 index eae65e9..0000000 --- a/Examples/Editing/Events.cs +++ /dev/null @@ -1,169 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Core.Data; -using ArcGIS.Desktop.Core; -using ArcGIS.Desktop.Editing; -using ArcGIS.Desktop.Editing.Events; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; -using ArcGIS.Desktop.Framework.Dialogs; -using ArcGIS.Desktop.Framework.Threading.Tasks; -using ArcGIS.Desktop.Mapping; - -namespace EditingSDKExamples -{ - internal class Events : Button - { - protected override void OnClick() - { - } - - // cref: editevent;ArcGIS.Desktop.Editing.Events.EditCompletedEvent - // cref: editevent;ArcGIS.Desktop.Editing.Events.EditCompletedEventArgs - #region editevent - protected void subEditEvents() - { - //subscribe to editcompleted - var eceToken = EditCompletedEvent.Subscribe(onEce); - } - - protected Task onEce(EditCompletedEventArgs args) - { - //show number of edits - Console.WriteLine("Creates: " + args.Creates.Values.Sum(list => list.Count).ToString()); - Console.WriteLine("Modifies: " + args.Modifies.Values.Sum(list => list.Count).ToString()); - Console.WriteLine("Deletes: " + args.Deletes.Values.Sum(list => list.Count).ToString()); - return Task.FromResult(0); - } - #endregion - - // cref: rowevent;ArcGIS.Desktop.Editing.Events.RowChangedEvent.Subscribe(System.Action{ArcGIS.Desktop.Editing.Events.RowChangedEventArgs},ArcGIS.Core.Data.Table,System.Boolean) - // cref: rowevent;ArcGIS.Desktop.Editing.Events.RowCreatedEvent.Subscribe(System.Action{ArcGIS.Desktop.Editing.Events.RowChangedEventArgs},ArcGIS.Core.Data.Table,System.Boolean) - // cref: rowevent;ArcGIS.Desktop.Editing.Events.RowDeletedEvent.Subscribe(System.Action{ArcGIS.Desktop.Editing.Events.RowChangedEventArgs},ArcGIS.Core.Data.Table,System.Boolean) - // cref: rowevent;ArcGIS.Desktop.Editing.Events.RowChangedEvent - // cref: rowevent;ArcGIS.Desktop.Editing.Events.RowChangedEventArgs - // cref: rowevent;ArcGIS.Desktop.Editing.Events.RowCreatedEvent - // cref: rowevent;ArcGIS.Desktop.Editing.Events.RowDeletedEvent - #region rowevent - protected void subRowEvent() - { - QueuedTask.Run(() => - { - //Listen for row events on a layer - var featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer; - var layerTable = featLayer.GetTable(); - - //subscribe to row events - var rowCreateToken = RowCreatedEvent.Subscribe(OnRowCreated, layerTable); - var rowChangeToken = RowChangedEvent.Subscribe(OnRowChanged, layerTable); - var rowDeleteToken = RowDeletedEvent.Subscribe(OnRowDeleted, layerTable); - }); - } - - protected void OnRowCreated(RowChangedEventArgs args) - { - // RowEvent callbacks are always called on the QueuedTask so there is no need - // to wrap your code within a QueuedTask.Run lambda. - - // update a separate table when a row is created - // You MUST use the ArcGIS.Core.Data API to edit the table. Do NOT - // use a new edit operation in the RowEvent callbacks - try - { - // update Notes table with information about the new feature - var geoDatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath))); - var table = geoDatabase.OpenDataset("Notes"); - var tableDefinition = table.GetDefinition(); - using (var rowbuff = table.CreateRowBuffer()) - { - // add a description - rowbuff["Description"] = "OID: " + args.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString(); - table.CreateRow(rowbuff); - } - } - catch (Exception e) - { - MessageBox.Show($@"Error in OnRowCreated for OID: {args.Row.GetObjectID()} : {e.ToString()}"); - } - } - - - private Guid _currentRowChangedGuid = Guid.Empty; - - protected void OnRowChanged(RowChangedEventArgs args) - { - // RowEvent callbacks are always called on the QueuedTask so there is no need - // to wrap your code within a QueuedTask.Run lambda. - - var row = args.Row; - - // check for re-entry (only if row.Store is called) - if (_currentRowChangedGuid == args.Guid) - return; - - var fldIdx = row.FindField("POLICE_DISTRICT"); - if (fldIdx != -1) - { - //Validate any change to �police district� - // cancel the edit if validation on the field fails - if (row.HasValueChanged(fldIdx)) - { - if (FailsValidation(row["POLICE_DISTRICT"].ToString())) - { - //Cancel edits with invalid �police district� values - args.CancelEdit($"Police district {row["POLICE_DISTRICT"]} is invalid"); - } - } - - // update the description field - row["Description"] = "Row Changed"; - - // this update with cause another OnRowChanged event to occur - // keep track of the row guid to avoid recursion - _currentRowChangedGuid = args.Guid; - row.Store(); - _currentRowChangedGuid = Guid.Empty; - } - } - - protected void OnRowDeleted(RowChangedEventArgs args) - { - var row = args.Row; - - // cancel the delete if the feature is in Police District 5 - - var fldIdx = row.FindField("POLICE_DISTRICT"); - if (fldIdx != -1) - { - var value = row[fldIdx].ToString(); - if (value == "5") - args.CancelEdit(); - } - } - #endregion - - private bool FailsValidation(string s) => true; - - } -} diff --git a/Examples/Editing/ProSnippet.cs b/Examples/Editing/ProSnippet.cs index cedf108..f09c945 100644 --- a/Examples/Editing/ProSnippet.cs +++ b/Examples/Editing/ProSnippet.cs @@ -1,4 +1,4 @@ -/* +/* Copyright 2018 Esri @@ -38,13 +38,14 @@ limitations under the License. using ArcGIS.Desktop.Core; using System.Windows; using ArcGIS.Core.Events; +using ArcGIS.Core.Data.Topology; namespace EditingSDKExamples { class ProSnippet : MapTool { - Geometry _geometry; + Geometry geometry; public ProSnippet() { @@ -55,7 +56,6 @@ public ProSnippet() protected override Task OnSketchCompleteAsync(Geometry geometry) { - _geometry = geometry; return base.OnSketchCompleteAsync(geometry); } @@ -66,28 +66,30 @@ public void EditOperations() { var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList()[0] as FeatureLayer; - var polygon = new PolygonBuilder().ToGeometry(); - var clipPoly = new PolygonBuilder().ToGeometry(); - var cutLine = new PolylineBuilder().ToGeometry(); + var polygon = new PolygonBuilderEx().ToGeometry(); + var clipPoly = new PolygonBuilderEx().ToGeometry(); + var cutLine = new PolylineBuilderEx().ToGeometry(); var modifyLine = cutLine; var oid = 1; var layer = featureLayer; var standaloneTable = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().FirstOrDefault(); + // cref: ArcGIS.Desktop.Editing.EditOperation.#ctor() + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Desktop.Mapping.Layer, ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Desktop.Editing.EditOperation.IsSucceeded + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Desktop.Mapping.MapMember,System.Collections.Generic.Dictionary{System.String,System.Object}) + // cref: ArcGIS.Desktop.Editing.EditOperation.Execute + // cref: ArcGIS.Desktop.Editing.EditOperation.ExecuteAsync #region Edit Operation Create Features var createFeatures = new EditOperation(); createFeatures.Name = "Create Features"; //Create a feature with a polygon - createFeatures.Create(featureLayer, polygon); - - //with a callback - createFeatures.Create(featureLayer, polygon, (object_id) => + var token = createFeatures.Create(featureLayer, polygon); + if (createFeatures.IsSucceeded) { - //TODO - use the oid of the created feature - //in your callback - }); - + // token.ObjectID wll be populated with the objectID of the created feature after Execute has been successful + } //Do a create features and set attributes var attributes = new Dictionary(); attributes.Add("SHAPE", polygon); @@ -110,17 +112,19 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate.Current + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Desktop.Editing.EditingTemplate, ArcGIS.Core.Geometry.Geometry) #region Create a feature using the current template var myTemplate = ArcGIS.Desktop.Editing.Templates.EditingTemplate.Current; - var myGeometry = _geometry; //Create edit operation and execute var op = new ArcGIS.Desktop.Editing.EditOperation(); op.Name = "Create my feature"; - op.Create(myTemplate, myGeometry); + op.Create(myTemplate, geometry); op.Execute(); #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Desktop.Mapping.MapMember, System.Collections.Generic.Dictionary) #region Create feature from a modified inspector var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); @@ -141,6 +145,7 @@ public void EditOperations() var csvData = new List(); + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Desktop.Mapping.MapMember, System.Collections.Generic.Dictionary) #region Create features from a CSV file //Run on MCT ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -158,7 +163,8 @@ public void EditOperations() { //Create the point geometry - ArcGIS.Core.Geometry.MapPoint newMapPoint = ArcGIS.Core.Geometry.MapPointBuilder.CreateMapPoint(item.X, item.Y); + ArcGIS.Core.Geometry.MapPoint newMapPoint = + ArcGIS.Core.Geometry.MapPointBuilderEx.CreateMapPoint(item.X, item.Y); // include the attributes via a dictionary var atts = new Dictionary(); @@ -175,6 +181,7 @@ public void EditOperations() }); #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Desktop.Editing.EditingTemplate) #region Edit Operation Create row in a table using a table template var tableTemplate = standaloneTable.GetTemplates().FirstOrDefault(); var createRow = new EditOperation(); @@ -184,6 +191,7 @@ public void EditOperations() createRow.Execute(); #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Clip(ArcGIS.Desktop.Mapping.Layer, System.Int64, ArcGIS.Core.Geometry.Geometry, ArcGIS.Desktop.Editing.ClipMode) #region Edit Operation Clip Features var clipFeatures = new EditOperation(); @@ -198,6 +206,8 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Split(ArcGIS.Desktop.Mapping.Layer, System.Int64, ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Desktop.Editing.EditOperation.Split(ArcGIS.Desktop.Mapping.SelectionSet, ArcGIS.Core.Geometry.Geometry) #region Edit Operation Cut Features var select = MapView.Active.SelectFeatures(clipPoly); @@ -208,9 +218,11 @@ public void EditOperations() //Cut all the selected features in the active view //Select using a polygon (for example) - var kvps = MapView.Active.SelectFeatures(polygon).Select( - k => new KeyValuePair>(k.Key as MapMember, k.Value)); - cutFeatures.Split(kvps, cutLine); + //at 2.x - var kvps = MapView.Active.SelectFeatures(polygon).Select( + // k => new KeyValuePair>(k.Key as MapMember, k.Value)); + //cutFeatures.Split(kvps, cutLine); + var sset = MapView.Active.SelectFeatures(polygon); + cutFeatures.Split(sset, cutLine); //Execute to execute the operation //Must be called within QueuedTask.Run @@ -220,48 +232,64 @@ public void EditOperations() //await cutFeatures.ExecuteAsync(); #endregion + { + // cref: ArcGIS.Desktop.Editing.EditOperation.Delete(ArcGIS.Desktop.Mapping.MapMember, System.Int64) + // cref: ArcGIS.Desktop.Editing.EditOperation.Delete(ArcGIS.Desktop.Mapping.SelectionSet) + #region Edit Operation Delete Features + + var deleteFeatures = new EditOperation(); + deleteFeatures.Name = "Delete Features"; + var table = MapView.Active.Map.StandaloneTables[0]; + //Delete a row in a standalone table + deleteFeatures.Delete(table, oid); + + //Delete all the selected features in the active view + //Select using a polygon (for example) + //at 2.x - var selection = MapView.Active.SelectFeatures(polygon).Select( + // k => new KeyValuePair>(k.Key as MapMember, k.Value)); + //deleteFeatures.Delete(selection); + var selection = MapView.Active.SelectFeatures(polygon); + deleteFeatures.Delete(selection); + + //Execute to execute the operation + //Must be called within QueuedTask.Run + deleteFeatures.Execute(); + + //or use async flavor + //await deleteFeatures.ExecuteAsync(); - #region Edit Operation Delete Features - - var deleteFeatures = new EditOperation(); - deleteFeatures.Name = "Delete Features"; - var table = MapView.Active.Map.StandaloneTables[0]; - //Delete a row in a standalone table - deleteFeatures.Delete(table, oid); - - //Delete all the selected features in the active view - //Select using a polygon (for example) - var selection = MapView.Active.SelectFeatures(polygon).Select( - k => new KeyValuePair>(k.Key as MapMember, k.Value)); - - deleteFeatures.Delete(selection); - - //Execute to execute the operation - //Must be called within QueuedTask.Run - deleteFeatures.Execute(); - - //or use async flavor - //await deleteFeatures.ExecuteAsync(); - - #endregion + #endregion + } + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.CREATE + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.CREATECHAINEDOPERATION #region Edit Operation Duplicate Features + { + var duplicateFeatures = new EditOperation(); + duplicateFeatures.Name = "Duplicate Features"; - var duplicateFeatures = new EditOperation(); - duplicateFeatures.Name = "Duplicate Features"; + //Duplicate with an X and Y offset of 500 map units + //At 2.x duplicateFeatures.Duplicate(featureLayer, oid, 500.0, 500.0, 0.0); - //Duplicate with an X and Y offset of 500 map units - duplicateFeatures.Duplicate(featureLayer, oid, 500.0, 500.0, 0.0); + //Execute to execute the operation + //Must be called within QueuedTask.Run + var insp2 = new Inspector(); + insp2.Load(featureLayer, oid); + var geom = insp2["SHAPE"] as Geometry; - //Execute to execute the operation - //Must be called within QueuedTask.Run - duplicateFeatures.Execute(); + var rtoken = duplicateFeatures.Create(insp2.MapMember, insp2.ToDictionary(a => a.FieldName, a => a.CurrentValue)); + if (duplicateFeatures.Execute()) + { + var modifyOp = duplicateFeatures.CreateChainedOperation(); + modifyOp.Modify(featureLayer, (long)rtoken.ObjectID, GeometryEngine.Instance.Move(geom, 500.0, 500.0)); + modifyOp.Execute(); + } - //or use async flavor - //await duplicateFeatures.ExecuteAsync(); + } #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Explode(Layer,IEnumerable{Int64},Boolean) #region Edit Operation Explode Features var explodeFeatures = new EditOperation(); @@ -282,6 +310,9 @@ public void EditOperations() var destinationLayer = featureLayer; + // cref: ArcGIS.Desktop.Editing.EditOperation.Merge(LAYER,LAYER,IENUMERABLE{INT64},INSPECTOR) + // cref: ArcGIS.Desktop.Editing.EditOperation.Merge(EditingRowTemplate,Layer,IEnumerable{Int64}) + // cref: ArcGIS.Desktop.Editing.EditOperation.Merge(LAYER,IENUMERABLE{INT64},INSPECTOR) #region Edit Operation Merge Features var mergeFeatures = new EditOperation(); @@ -289,7 +320,9 @@ public void EditOperations() //Merge three features into a new feature using defaults //defined in the current template - mergeFeatures.Merge(this.CurrentTemplate as EditingFeatureTemplate, featureLayer, new List() { 10, 96, 12 }); + //At 2.x - + //mergeFeatures.Merge(this.CurrentTemplate as EditingFeatureTemplate, featureLayer, new List() { 10, 96, 12 }); + mergeFeatures.Merge(this.CurrentTemplate as EditingRowTemplate, featureLayer, new List() { 10, 96, 12 }); //Merge three features into a new feature in the destination layer mergeFeatures.Merge(destinationLayer, featureLayer, new List() { 10, 96, 12 }); @@ -314,6 +347,8 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify(ArcGIS.Desktop.Editing.Attributes.Inspector) + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify(ArcGIS.Desktop.Mapping.Layer, System.Int64, ArcGIS.Core.Geometry.Geometry, Nullable>) #region Edit Operation Modify single feature var modifyFeature = new EditOperation(); @@ -343,6 +378,7 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify(ArcGIS.Desktop.Editing.Attributes.Inspector) #region Edit Operation Modify multiple features //Search by attribute @@ -411,6 +447,7 @@ public void EditOperations() }); #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Move(ArcGIs.Desktop.Mapping.SelectionSet, System.Double, System.Double) #region Move features //Get all of the selected ObjectIDs from the layer. @@ -423,11 +460,13 @@ public void EditOperations() var moveFeature = new EditOperation(); moveFeature.Name = "Move features"; - moveFeature.Move(selectionDictionary, 10, 10); //specify your units along axis to move the geometry + //at 2.x - moveFeature.Move(selectionDictionary, 10, 10); //specify your units along axis to move the geometry + moveFeature.Move(SelectionSet.FromDictionary(selectionDictionary), 10, 10); //specify your units along axis to move the geometry moveFeature.Execute(); #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify(LAYER,INT64,GEOMETRY,DICTIONARY{STRING,OBJECT}) #region Move feature to a specific coordinate //Get all of the selected ObjectIDs from the layer. @@ -435,7 +474,7 @@ public void EditOperations() var mySelection = abLayer.GetSelection(); var selOid = mySelection.GetObjectIDs().FirstOrDefault(); - var moveToPoint = new MapPointBuilder(1.0, 2.0, 3.0, 4.0, MapView.Active.Map.SpatialReference); //can pass in coordinates. + var moveToPoint = new MapPointBuilderEx(1.0, 2.0, 3.0, 4.0, MapView.Active.Map.SpatialReference); //can pass in coordinates. var modifyFeatureCoord = new EditOperation(); modifyFeatureCoord.Name = "Move features"; @@ -444,6 +483,7 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Planarize(Layer,IEnumerable{Int64},Nullable{Double}) #region Edit Operation Planarize Features // note - EditOperation.Planarize requires a standard license. @@ -464,6 +504,8 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.ParallelOffset.Builder.#ctor + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Desktop.Editing.ParallelOffset.Builder) #region Edit Operation ParallelOffset //Create parrallel features from the selected features @@ -491,6 +533,7 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Reshape(ArcGIS.Desktop.Mapping.SelectionSet, ArcGIS.Core.Geometry.Geometry) #region Edit Operation Reshape Features var reshapeFeatures = new EditOperation(); @@ -499,10 +542,12 @@ public void EditOperations() reshapeFeatures.Reshape(featureLayer, oid, modifyLine); //Reshape a set of features that intersect some geometry.... - var selFeatures = MapView.Active.GetFeatures(modifyLine).Select( - k => new KeyValuePair>(k.Key as MapMember, k.Value)); - reshapeFeatures.Reshape(selFeatures, modifyLine); + //at 2.x - var selFeatures = MapView.Active.GetFeatures(modifyLine).Select( + // k => new KeyValuePair>(k.Key as MapMember, k.Value)); + //reshapeFeatures.Reshape(selFeatures, modifyLine); + + reshapeFeatures.Reshape(MapView.Active.GetFeatures(modifyLine), modifyLine); //Execute to execute the operation //Must be called within QueuedTask.Run @@ -513,8 +558,9 @@ public void EditOperations() #endregion - var origin = MapPointBuilder.CreateMapPoint(0, 0, null); + var origin = MapPointBuilderEx.CreateMapPoint(0, 0, null); + // cref: ArcGIS.Desktop.Editing.EditOperation.Rotate(ArcGIS.Desktop.Mapping.SelectionSet, ArcGIS.Core.Geometry.MapPoint, System.Double) #region Edit Operation Rotate Features var rotateFeatures = new EditOperation(); @@ -522,11 +568,13 @@ public void EditOperations() //Rotate works on a selected set of features //Get all features that intersect a polygon - var rotateSelection = MapView.Active.GetFeatures(polygon).Select( - k => new KeyValuePair>(k.Key as MapMember, k.Value)); + + //at 2.x - var rotateSelection = MapView.Active.GetFeatures(polygon).Select( + // k => new KeyValuePair>(k.Key as MapMember, k.Value)); + //rotateFeatures.Rotate(rotateSelection, origin, Math.PI / 2); //Rotate selected features 90 deg about "origin" - rotateFeatures.Rotate(rotateSelection, origin, Math.PI / 2); + rotateFeatures.Rotate(MapView.Active.GetFeatures(polygon), origin, Math.PI / 2); //Execute to execute the operation //Must be called within QueuedTask.Run @@ -537,17 +585,20 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.Scale(ArcGIS.Desktop.Mapping.SelectionSet, ArcGIS.Core.Geometry.MapPoint, System.Double, System.Double, System.Double) #region Edit Operation Scale Features var scaleFeatures = new EditOperation(); scaleFeatures.Name = "Scale Features"; //Rotate works on a selected set of features - var scaleSelection = MapView.Active.GetFeatures(polygon).Select( - k => new KeyValuePair>(k.Key as MapMember, k.Value)); + + //var scaleSelection = MapView.Active.GetFeatures(polygon).Select( + // k => new KeyValuePair>(k.Key as MapMember, k.Value)); + //scaleFeatures.Scale(scaleSelection, origin, 2.0, 2.0, 0.0); //Scale the selected features by 2.0 in the X and Y direction - scaleFeatures.Scale(scaleSelection, origin, 2.0, 2.0, 0.0); + scaleFeatures.Scale(MapView.Active.GetFeatures(polygon), origin, 2.0, 2.0, 0.0); //Execute to execute the operation //Must be called within QueuedTask.Run @@ -558,10 +609,16 @@ public void EditOperations() #endregion - var mp1 = MapPointBuilder.CreateMapPoint(0, 0, null); + var mp1 = MapPointBuilderEx.CreateMapPoint(0, 0, null); var mp2 = mp1; var mp3 = mp1; + // cref: ArcGIS.Desktop.Editing.SplitByPercentage.#ctor + // cref: ArcGIS.Desktop.Editing.SplitByEqualParts.#ctor + // cref: ArcGIS.Desktop.Editing.SplitByDistance.#ctor + // cref: ArcGIS.Desktop.Editing.SplitByVaryingDistance.#ctor + // cref: ArcGIS.Desktop.Editing.EditOperation.Split(ArcGIS.Desktop.Mapping.Layer, System.Int64, System.Collections.Generic.IEnumerable) + // cref: ArcGIS.Desktop.Editing.EditOperation.Split(ArcGIS.Desktop.Mapping.Layer, System.Int64, ArcGIS.Desktop.Editing.SplitMethod) #region Edit Operation Split Features var splitFeatures = new EditOperation(); @@ -600,22 +657,33 @@ public void EditOperations() var linkLayer = featureLayer; + // cref: ArcGIS.Desktop.Editing.TransformByLinkLayer.#ctor + // cref: ArcGIS.Desktop.Editing.TransformMethodType + // cref: ArcGIS.Desktop.Editing.EditOperation.Transform(ArcGIS.Desktop.Mapping.Layer,ArcGIS.Desktop.Editing.TransformMethod) + // cref: ArcGIS.Desktop.Editing.EditOperation.Transform(ArcGIS.Desktop.Mapping.SelectionSet,ArcGIS.Desktop.Editing.TransformMethod) #region Edit Operation Transform Features var transformFeatures = new EditOperation(); transformFeatures.Name = "Transform Features"; //Transform a selected set of features - var transformSelection = MapView.Active.GetFeatures(polygon).Select( - k => new KeyValuePair>(k.Key as MapMember, k.Value)); - - transformFeatures.Transform(transformSelection, linkLayer); - - //Transform just a layer - transformFeatures.Transform(featureLayer, linkLayer); - + //At 2.x - var transformSelection = MapView.Active.GetFeatures(polygon).Select( + // k => new KeyValuePair>(k.Key as MapMember, k.Value)); + //transformFeatures.Transform(transformSelection, linkLayer); + ////Transform just a layer + //transformFeatures.Transform(featureLayer, linkLayer); + ////Perform an affine transformation + //transformFeatures.TransformAffine(featureLayer, linkLayer); + + var affine_transform = new TransformByLinkLayer() + { + LinkLayer = linkLayer, + TransformType = TransformMethodType.Affine //TransformMethodType.Similarity + }; + //Transform a selected set of features + transformFeatures.Transform(MapView.Active.GetFeatures(polygon), affine_transform); //Perform an affine transformation - transformFeatures.TransformAffine(featureLayer, linkLayer); + transformFeatures.Transform(featureLayer, affine_transform); //Execute to execute the operation //Must be called within QueuedTask.Run @@ -626,10 +694,50 @@ public void EditOperations() #endregion - #region Edit Operation Perform a Clip, Cut, and Planarize + IEnumerable linkLines = new List(); + IEnumerable anchorPoints = new List(); + IEnumerable limitedAdjustmentAreas = new List(); + var anchorPointsLayer = featureLayer; + var limitedAdjustmentAreaLayer = featureLayer; - // note - EditOperation.Planarize requires a standard license. - // An exception will be thrown if Pro is running under a basic license. + // cref: ArcGIS.Desktop.Editing.RubbersheetByGeometries.#ctor + // cref: ArcGIS.Desktop.Editing.RubbersheetByLayers.#ctor + // cref: ArcGIS.Desktop.Editing.EditOperation.Rubbersheet(ArcGIS.Desktop.Mapping.Layer, ArcGIS.Desktop.Editing.RubbersheetMethod) + #region Edit Operation Rubbersheet Features + + //Perform rubbersheet by geometries + var rubbersheetMethod = new RubbersheetByGeometries() + { + RubbersheetType = RubbersheetMethodType.Linear, //The RubbersheetType can be Linear of NearestNeighbor + LinkLines = linkLines, //IEnumerable list of link lines (polylines) + AnchorPoints = anchorPoints, //IEnumerable list of anchor points (map points) + LimitedAdjustmentAreas = limitedAdjustmentAreas //IEnumerable list of limited adjustment areas (polygons) + }; + + var rubbersheetOp = new EditOperation(); + //Performs linear rubbersheet transformation on the features belonging to "layer" that fall within the limited adjustment areas + rubbersheetOp.Rubbersheet(layer, rubbersheetMethod); + //Execute the operation + rubbersheetOp.Execute(); + + //Alternatively, you can also perform rubbersheet by layer + var rubbersheetMethod2 = new RubbersheetByLayers() + { + RubbersheetType = RubbersheetMethodType.NearestNeighbor, //The RubbersheetType can be Linear of NearestNeighbor + LinkLayer = linkLayer, + AnchorPointLayer = anchorPointsLayer, + LimitedAdjustmentAreaLayer = limitedAdjustmentAreaLayer + }; + + //Performs nearest neighbor rubbersheet transformation on the features belonging to "layer" that fall within the limited adjustment areas + rubbersheetOp.Rubbersheet(layer, rubbersheetMethod2); + //Execute the operation + rubbersheetOp.Execute(); + + #endregion + + // cref: ArcGIS.Desktop.Editing.EditOperation.Planarize(Layer,Int64,Nullable{Double}) + #region Edit Operation Perform a Clip, Cut, and Planarize //Multiple operations can be performed by a single //edit operation. @@ -637,7 +745,7 @@ public void EditOperations() clipCutPlanarizeFeatures.Name = "Clip, Cut, and Planarize Features"; clipCutPlanarizeFeatures.Clip(featureLayer, oid, clipPoly); clipCutPlanarizeFeatures.Split(featureLayer, oid, cutLine); - clipCutPlanarizeFeatures.Planarize(featureLayer, new List() { oid }); + clipCutPlanarizeFeatures.Planarize(featureLayer, oid); //Note: An edit operation is a single transaction. //Execute the operations (in the order they were declared) @@ -648,6 +756,8 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.CreateChainedOperation + // cref: ArcGIS.Desktop.Editing.EditOperation.AddAttachment(ArcGIS.Desktop.Mapping.MapMember,System.Int64,System.String) #region Edit Operation Chain Edit Operations //Chaining operations is a special case. Use "Chained Operations" when you require multiple transactions @@ -660,7 +770,11 @@ public void EditOperations() long newFeatureID = -1; //The Create operation has to execute so we can get an object_id - editOperation1.Create(this.CurrentTemplate, polygon, (object_id) => newFeatureID = object_id); + var token2 = editOperation1.Create(this.CurrentTemplate, polygon); + if (editOperation1.IsSucceeded) + { + newFeatureID = (long)token2.ObjectID; + } //Must be within a QueuedTask editOperation1.Execute(); @@ -684,6 +798,8 @@ public void EditOperations() #endregion + // cref: ArcGIS.Desktop.Editing.RowToken + // cref: ArcGIS.Desktop.Editing.EditOperation.AddAttachment(ArcGIS.Desktop.Editing.RowToken,System.String) #region Edit Operation add attachment via RowToken //ArcGIS Pro 2.5 extends the EditOperation.AddAttachment method to take a RowToken as a paramter. @@ -692,13 +808,16 @@ public void EditOperations() var editOpAttach = new EditOperation(); editOperation1.Name = string.Format("Create point in '{0}'", CurrentTemplate.Layer.Name); - var attachRowToken = editOpAttach.CreateEx(this.CurrentTemplate, polygon); + var attachRowToken = editOpAttach.Create(this.CurrentTemplate, polygon); editOpAttach.AddAttachment(attachRowToken, @"c:\temp\image.jpg"); //Must be within a QueuedTask editOpAttach.Execute(); #endregion + // cref: ArcGIS.Desktop.Editing.EditOperation.SetOnUndone(System.Action) + // cref: ArcGIS.Desktop.Editing.EditOperation.SetOnComitted(System.Action{System.Boolean}) + // cref: ArcGIS.Desktop.Editing.EditOperation.SetOnRedone(System.Action) #region SetOnUndone, SetOnRedone, SetOnComitted // SetOnUndone, SetOnRedone and SetOnComittedManage can be used to manage @@ -708,7 +827,7 @@ public void EditOperations() //get selected feature and update attribute var selectedFeatures = MapView.Active.Map.GetSelection(); var testInspector = new Inspector(); - testInspector.Load(selectedFeatures.Keys.First(), selectedFeatures.Values.First()); + testInspector.Load(selectedFeatures.ToDictionary().Keys.First(), selectedFeatures.ToDictionary().Values.First()); testInspector["Name"] = "test"; //create and execute the edit operation @@ -736,7 +855,6 @@ public void EditOperations() }); updateTestField.Execute(); - } #endregion @@ -745,6 +863,8 @@ public void EditOperations() private void CanWeEdit() { + // cref: ArcGIs.Desktop.Core.Project.IsEditingEnabled + // cref: ArcGIs.Desktop.Core.Project.SetIsEditingEnabledAsync(System.Boolean) #region Enable Editing // if not editing @@ -762,6 +882,11 @@ private void CanWeEdit() #endregion + // cref: ArcGIs.Desktop.Core.Project.IsEditingEnabled + // cref: ArcGIs.Desktop.Core.Project.HasEdits + // cref: ArcGIs.Desktop.Core.Project.DiscardEditsAsync + // cref: ArcGIs.Desktop.Core.Project.SaveEditsAsync + // cref: ArcGIs.Desktop.Core.Project.SetIsEditingEnabledAsync(System.Boolean) #region Disable Editing // if editing @@ -795,31 +920,255 @@ private void CanWeEdit() } + #region ProSnippet Group: Map Topology + #endregion + + // cref: ArcGIS.Core.Data.Topology.TopologyDefinition + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.BuildMapTopologyGraph(ArcGIS.Desktop.Mapping.MapView, System.Action) + // cref: ArcGIS.Core.Data.Topology.TopologyGraph.GetNodes() + // cref: ArcGIS.Core.Data.Topology.TopologyGraph.GetEdges() + // cref: ArcGIS.Core.Data.Topology.TopologyNode + // cref: ArcGIS.Core.Data.Topology.TopologyEdge + #region Build Map Topology + private async Task BuildGraphWithActiveView() + { + await QueuedTask.Run(() => + { + //Build the map topology graph + MapView.Active.BuildMapTopologyGraph(async topologyGraph => + { + //Getting the nodes and edges present in the graph + var topologyGraphNodes = topologyGraph.GetNodes(); + var topologyGraphEdges = topologyGraph.GetEdges(); + + foreach (var node in topologyGraphNodes) + { + // do something with the node + } + foreach (var edge in topologyGraphEdges) + { + // do something with the edge + } + + MessageBox.Show($"Number of topo graph nodes are: {topologyGraphNodes.Count}.\n Number of topo graph edges are {topologyGraphEdges.Count}.", "Map Topology Info"); + }); + }); + } + #endregion + #region ProSnippet Group: Row Events #endregion + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEvent.Subscribe(System.Action{ArcGIS.Desktop.Editing.Events.RowChangedEventArgs},ArcGIS.Core.Data.Table,System.Boolean) + // cref: ArcGIS.Desktop.Editing.Events.RowCreatedEvent.Subscribe(System.Action{ArcGIS.Desktop.Editing.Events.RowChangedEventArgs},ArcGIS.Core.Data.Table,System.Boolean) + // cref: ArcGIS.Desktop.Editing.Events.RowDeletedEvent.Subscribe(System.Action{ArcGIS.Desktop.Editing.Events.RowChangedEventArgs},ArcGIS.Core.Data.Table,System.Boolean) + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEvent + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs + // cref: ArcGIS.Desktop.Editing.Events.RowCreatedEvent + // cref: ArcGIS.Desktop.Editing.Events.RowDeletedEvent + #region Subscribe to Row Events + protected void SubscribeRowEvent() + { + QueuedTask.Run(() => + { + //Listen for row events on a layer + var featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer; + var layerTable = featLayer.GetTable(); + + //subscribe to row events + var rowCreateToken = RowCreatedEvent.Subscribe(OnRowCreated, layerTable); + var rowChangeToken = RowChangedEvent.Subscribe(OnRowChanged, layerTable); + var rowDeleteToken = RowDeletedEvent.Subscribe(OnRowDeleted, layerTable); + }); + } + + protected void OnRowCreated(RowChangedEventArgs args) + { + } + + protected void OnRowChanged(RowChangedEventArgs args) + { + } + + protected void OnRowDeleted(RowChangedEventArgs args) + { + } + #endregion + private static Guid _lastEdit = Guid.Empty; - #region Stop a delete - public static void StopADelete() + + // cref: ArcGIS.Desktop.Editing.Events.RowCreatedEvent + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs.Operation + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Core.Data.Table, System.Collections.Generic.Dictionary) + #region Create a record in a separate table in the Map within Row Events + + // Use the EditOperation in the RowChangedEventArgs to append actions to be executed. + // Your actions will become part of the operation and combined into one item on the undo stack + + private void HookRowCreatedEvent() { - // subscribe to the RowDeletedEvent for the appropriate table + // subscribe to the RowCreatedEvent Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault().GetTable(); - RowDeletedEvent.Subscribe(OnRowDeletedEvent, table); + RowCreatedEvent.Subscribe(MyRowCreatedEvent, table); + } + + private void MyRowCreatedEvent(RowChangedEventArgs args) + { + // RowEvent callbacks are always called on the QueuedTask so there is no need + // to wrap your code within a QueuedTask.Run lambda. + + // get the edit operation + var parentEditOp = args.Operation; + + // set up some attributes + var attribs = new Dictionary { }; + attribs.Add("Layer", "Parcels"); + attribs.Add("Description", "OID: " + args.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString()); + + //create a record in an audit table + var sTable = MapView.Active.Map.FindStandaloneTables("EditHistory").First(); + var table = sTable.GetTable(); + parentEditOp.Create(table, attribs); + } + #endregion + + // cref: ArcGIS.Desktop.Editing.Events.RowCreatedEvent + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs.Operation + // cref: ArcGIS.Desktop.Editing.EditOperation.Create(ArcGIS.Core.Data.Table, System.Collections.Generic.Dictionary) + #region Create a record in a separate table within Row Events + + // Use the EditOperation in the RowChangedEventArgs to append actions to be executed. + // Your actions will become part of the operation and combined into one item on the undo stack + + private void HookCreatedEvent() + { + // subscribe to the RowCreatedEvent + Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault().GetTable(); + RowCreatedEvent.Subscribe(OnRowCreatedEvent, table); + } + + private void OnRowCreatedEvent(RowChangedEventArgs args) + { + // RowEvent callbacks are always called on the QueuedTask so there is no need + // to wrap your code within a QueuedTask.Run lambda. + + // update a separate table not in the map when a row is created + // You MUST use the ArcGIS.Core.Data API to edit the table. Do NOT + // use a new edit operation in the RowEvent callbacks + try + { + // get the edit operation + var parentEditOp = args.Operation; + + // set up some attributes + var attribs = new Dictionary { }; + attribs.Add("Description", "OID: " + args.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString()); + + // update Notes table with information about the new feature + using (var geoDatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(Project.Current.DefaultGeodatabasePath)))) + { + using (var table = geoDatabase.OpenDataset
("Notes")) + { + parentEditOp.Create(table, attribs); + } + } + } + catch (Exception e) + { + MessageBox.Show($@"Error in OnRowCreated for OID: {args.Row.GetObjectID()} : {e.ToString()}"); + } + } + #endregion + + + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEvent + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs.Row + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs.Guid + // cref: ArcGIS.Core.Data.Row.HasValueChanged(System.Int32) + // cref: ArcGIS.Core.Data.Row.Store + #region Modify a record within Row Events - using Row.Store + + private void HookRowChangedEvent() + { + // subscribe to the RowChangedEvent + Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault().GetTable(); + RowChangedEvent.Subscribe(OnRowChangedEvent, table); + } + + private Guid _currentRowChangedGuid = Guid.Empty; + protected void OnRowChangedEvent(RowChangedEventArgs args) + { + // RowEvent callbacks are always called on the QueuedTask so there is no need + // to wrap your code within a QueuedTask.Run lambda. + + var row = args.Row; + + // check for re-entry (only if row.Store is called) + if (_currentRowChangedGuid == args.Guid) + return; + + var fldIdx = row.FindField("POLICE_DISTRICT"); + if (fldIdx != -1) + { + //Validate any change to �police district� + // cancel the edit if validation on the field fails + if (row.HasValueChanged(fldIdx)) + { + // cancel edit with invalid district (5) + var value = row["POLICE_DISTRICT"].ToString(); + if (value == "5") + { + //Cancel edits with invalid �police district� values + args.CancelEdit($"Police district {row["POLICE_DISTRICT"]} is invalid"); + } + } + + // update the description field + row["Description"] = "Row Changed"; + + // this update with cause another OnRowChanged event to occur + // keep track of the row guid to avoid recursion + _currentRowChangedGuid = args.Guid; + row.Store(); + _currentRowChangedGuid = Guid.Empty; + } + } + #endregion + + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEvent + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs.Operation + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify(ArcGIS.Core.Data.Row, System.String, System.Object) + #region Modify a record within Row Events - using EditOperation.Modify + private void HookChangedEvent() + { + // subscribe to the RowChangedEvent + Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault().GetTable(); + RowChangedEvent.Subscribe(MyRowChangedEvent, table); } - private static void OnRowDeletedEvent(RowChangedEventArgs obj) + private void MyRowChangedEvent(RowChangedEventArgs args) { - if (_lastEdit != obj.Guid) + // RowEvent callbacks are always called on the QueuedTask so there is no need + // to wrap your code within a QueuedTask.Run lambda. + + //example of modifying a field on a row that has been created + var parentEditOp = args.Operation; + + // avoid recursion + if (_lastEdit != args.Guid) { - //cancel with dialog - // Note - feature edits on Hosted and Standard Feature Services cannot be cancelled. - obj.CancelEdit("Delete Event\nAre you sure", true); - _lastEdit = obj.Guid; + //update field on change + parentEditOp.Modify(args.Row, "ZONING", "New"); + + _lastEdit = args.Guid; } } #endregion + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEvent + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs.Row + // cref: ArcGIS.Core.Data.Row.GetOriginalvalue #region Determine if Geometry Changed while editing private static FeatureLayer featureLayer; private static void DetermineGeometryChange() @@ -831,11 +1180,14 @@ private static void DetermineGeometryChange() QueuedTask.Run(() => { //Listen to the RowChangedEvent that occurs when a Row is changed. - ArcGIS.Desktop.Editing.Events.RowChangedEvent.Subscribe(OnRowChangedEvent, featureLayer.GetTable()); + ArcGIS.Desktop.Editing.Events.RowChangedEvent.Subscribe(OnRowChangedEvent2, featureLayer.GetTable()); }); } - private static void OnRowChangedEvent(RowChangedEventArgs obj) + private static void OnRowChangedEvent2(RowChangedEventArgs args) { + // RowEvent callbacks are always called on the QueuedTask so there is no need + // to wrap your code within a QueuedTask.Run lambda. + //Get the layer's definition var lyrDefn = featureLayer.GetFeatureClass().GetDefinition(); //Get the shape field of the feature class @@ -843,67 +1195,79 @@ private static void OnRowChangedEvent(RowChangedEventArgs obj) //Index of the shape field var shapeIndex = lyrDefn.FindField(shapeField); //Original geometry of the modified row - var geomOrig = obj.Row.GetOriginalValue(shapeIndex) as Geometry; + var geomOrig = args.Row.GetOriginalValue(shapeIndex) as Geometry; //New geometry of the modified row - var geomNew = obj.Row[shapeIndex] as Geometry; + var geomNew = args.Row[shapeIndex] as Geometry; //Compare the two bool shapeChanged = geomOrig.IsEqual(geomNew); } #endregion - #region Create a record in a separate table within Row Events - - // Use the EditOperation in the RowChangedEventArgs to append actions to be executed. - // Your actions will become part of the operation and combined into one item on the undo stack - - private void HookEvents() + // cref: ArcGIS.Desktop.Editing.Events.RowDeletedEvent + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs.CancelEdit(System.String, System.Boolean) + // cref: ArcGIS.Desktop.Editing.Events.RowChangedEventArgs.CancelEdit() + #region Cancel a delete + public static void StopADelete() { - // subscribe to the RowCreatedEvent + // subscribe to the RowDeletedEvent for the appropriate table Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault().GetTable(); - RowCreatedEvent.Subscribe(MyRowCreatedEvent, table); + RowDeletedEvent.Subscribe(OnRowDeletedEvent, table); } - private void MyRowCreatedEvent(RowChangedEventArgs obj) + private static void OnRowDeletedEvent(RowChangedEventArgs args) { - // get the edit operation - var parentEditOp = obj.Operation; + // RowEvent callbacks are always called on the QueuedTask so there is no need + // to wrap your code within a QueuedTask.Run lambda. - // set up some attributes - var attribs = new Dictionary { }; - attribs.Add("Layer", "Parcels"); - attribs.Add("Description", "OID: " + obj.Row.GetObjectID().ToString() + " " + DateTime.Now.ToShortTimeString()); + var row = args.Row; - //create a record in an audit table - var sTable = MapView.Active.Map.FindStandaloneTables("EditHistory").First(); - var table = sTable.GetTable(); - parentEditOp.Create(table, attribs); + // cancel the delete if the feature is in Police District 5 + + var fldIdx = row.FindField("POLICE_DISTRICT"); + if (fldIdx != -1) + { + var value = row[fldIdx].ToString(); + if (value == "5") + { + //cancel with dialog + // Note - feature edits on Hosted and Standard Feature Services cannot be cancelled. + args.CancelEdit("Delete Event\nAre you sure", true); + + // or cancel without a dialog + // args.CancelEdit(); + } + } } #endregion - #region Modify a record within Row Events - private void HookChangedEvent() + + #region ProSnippet Group: EditCompletedEvent + #endregion + + // cref: ArcGIS.Desktop.Editing.Events.EditCompletedEvent + // cref: ArcGIS.Desktop.Editing.Events.EditCompletedEventArgs + // cref: ArcGIS.Desktop.Editing.Events.EditCompletedEventArgs.Creates + // cref: ArcGIS.Desktop.Editing.Events.EditCompletedEventArgs.Modifies + // cref: ArcGIS.Desktop.Editing.Events.EditCompletedEventArgs.Deletes + #region Subscribe to EditCompletedEvent + + protected void subEditEvents() { - // subscribe to the RowChangedEvent - Table table = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault().GetTable(); - RowChangedEvent.Subscribe(MyRowChangedEvent, table); + //subscribe to editcompleted + var eceToken = EditCompletedEvent.Subscribe(onEce); } - private void MyRowChangedEvent(RowChangedEventArgs obj) + protected Task onEce(EditCompletedEventArgs args) { - //example of modifying a field on a row that has been created - var parentEditOp = obj.Operation; - - // avoid recursion - if (_lastEdit != obj.Guid) - { - //update field on change - parentEditOp.Modify(obj.Row, "ZONING", "New"); - - _lastEdit = obj.Guid; - } + //show number of edits + Console.WriteLine("Creates: " + args.Creates.ToDictionary().Values.Sum(list => list.Count).ToString()); + Console.WriteLine("Modifies: " + args.Modifies.ToDictionary().Values.Sum(list => list.Count).ToString()); + Console.WriteLine("Deletes: " + args.Deletes.ToDictionary().Values.Sum(list => list.Count).ToString()); + return Task.FromResult(0); } #endregion + #region ProSnippet Group: Inspector #endregion @@ -911,6 +1275,8 @@ public async void LoadFirstFeature2Inspector() { int oid = 0; + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.#ctor + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.LoadAsync(ArcGIS.Desktop.Mapping.MapMember, System.Int64) #region Load a feature from a layer into the inspector // get the first feature layer in the map @@ -927,12 +1293,17 @@ public async void LoadFirstFeature2Inspector() public async void LoadSelection2Inspector() { + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.LoadAsync(MAPMEMBER,INT64) + // cref: ArcGIS.Desktop.Mapping.SelectionSet.ToDictionary + // cref: ArcGIS.Desktop.Mapping.SelectionSet.ToDictionary``1() + // cref: ArcGIS.Desktop.Mapping.SelectionSet.ToDictionary() + // cref: ArcGIS.Desktop.Mapping.Map.GetSelection #region Load map selection into Inspector // get the currently selected features in the map var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection(); // get the first layer and its corresponding selected feature OIDs - var firstSelectionSet = selectedFeatures.First(); + var firstSelectionSet = selectedFeatures.ToDictionary().First(); // create an instance of the inspector class var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(); @@ -943,15 +1314,21 @@ public async void LoadSelection2Inspector() public static void InspectorGetAttributeValue() { + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.Load(ArcGIS.Desktop.Mapping.MapMember, System.Int64) + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.Shape + // cref: ArcGIS.Desktop.Mapping.SelectionSet.ToDictionary + // cref: ArcGIS.Desktop.Mapping.SelectionSet.ToDictionary``1() + // cref: ArcGIS.Desktop.Mapping.SelectionSet.ToDictionary() + // cref: ArcGIS.Desktop.Mapping.Map.GetSelection + #region Get selected feature's attribute value QueuedTask.Run(() => { - #region Get selected feature's attribute value // get the currently selected features in the map var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection(); // get the first layer and its corresponding selected feature OIDs - var firstSelectionSet = selectedFeatures.First(); + var firstSelectionSet = selectedFeatures.ToDictionary().First(); // create an instance of the inspector class var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(); @@ -961,18 +1338,21 @@ public static void InspectorGetAttributeValue() //get the value of var pscode = inspector["STATE_NAME"]; - #endregion + var myGeometry = inspector.Shape; }); + #endregion } public async void InspectorChangeAttributes() { + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.Item(System.String) + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.ApplyAsync() #region Load map selection into Inspector and Change Attributes // get the currently selected features in the map var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection(); // get the first layer and its corresponding selected feature OIDs - var firstSelectionSet = selectedFeatures.First(); + var firstSelectionSet = selectedFeatures.ToDictionary().First(); // create an instance of the inspector class var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(); @@ -987,18 +1367,94 @@ public async void InspectorChangeAttributes() #endregion } + public void SchemaAttributes() + { + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.LoadSchema(ArcGIS.Desktop.Mapping.MapMember) + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.GetEnumerator() + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.FieldName + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.FieldAlias + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.FieldType + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.IsNullable + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.IsEditable + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.IsVisible + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.IsSystemField + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.IsGeometryField + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.GetField() + #region Get a layers schema using Inspector + QueuedTask.Run(() => + { + var firstFeatureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); + + // create an instance of the inspector class + var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(); + + // load the layer + inspector.LoadSchema(firstFeatureLayer); + + // iterate through the attributes, looking at properties + foreach (var attribute in inspector) + { + var fldName = attribute.FieldName; + var fldAlias = attribute.FieldAlias; + var fldType = attribute.FieldType; + int idxFld = attribute.FieldIndex; + var fld = attribute.GetField(); + var isNullable = attribute.IsNullable; + var isEditable = attribute.IsEditable; + var isVisible = attribute.IsVisible; + var isSystemField = attribute.IsSystemField; + var isGeometryField = attribute.IsGeometryField; + } + }); + #endregion + } + protected void addvalidate() + { + var featLayer = MapView.Active.GetSelectedLayers().First() as FeatureLayer; + + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError.Create(System.String,ArcGIS.Desktop.Editing.Attributes.Severity) + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute.AddValidate + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector._ctor + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector + #region Inspector.AddValidate + var insp = new Inspector(); + insp.LoadSchema(featLayer); + var attrib = insp.Where(a => a.FieldName == "Mineral").First(); + + attrib.AddValidate(() => + { + if (attrib.CurrentValue.ToString() == "Salt") + return Enumerable.Empty(); + else return new[] { ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError.Create("Error", ArcGIS.Desktop.Editing.Attributes.Severity.Low) }; + }); + #endregion + } + #region ProSnippet Group: Accessing Blob Fields #endregion public static void ReadWriteBlobInspector() { + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.MODIFY(INSPECTOR) + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.EXECUTE #region Read and Write blob fields with the attribute inspector QueuedTask.Run(() => { //get selected feature into inspector var selectedFeatures = MapView.Active.Map.GetSelection(); + var insp = new Inspector(); - insp.Load(selectedFeatures.Keys.First(), selectedFeatures.Values.First()); + insp.Load(selectedFeatures.ToDictionary().Keys.First(), selectedFeatures.ToDictionary().Values.First()); + + //read a blob field and save to a file + var msw = new MemoryStream(); + msw = insp["Blobfield"] as MemoryStream; + using (FileStream file = new FileStream(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write)) + { + msw.WriteTo(file); + } //read file into memory stream var msr = new MemoryStream(); @@ -1007,27 +1463,21 @@ public static void ReadWriteBlobInspector() file.CopyTo(msr); } - //put the memory stream in the blob field + //put the memory stream in the blob field and save to feature var op = new EditOperation(); op.Name = "Blob Inspector"; insp["Blobfield"] = msr; op.Modify(insp); op.Execute(); - - //read a blob field and save to a file - //assume inspector has been loaded with a feature - var msw = new MemoryStream(); - msw = insp["Blobfield"] as MemoryStream; - using (FileStream file = new FileStream(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write)) - { - msw.WriteTo(file); - } }); #endregion } public static void ReadWriteBlobRow() { + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.CALLBACK(ACTION{IEDITCONTEXT},DATASET) + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.CALLBACK(ACTION{IEDITCONTEXT},IENUMERABLE{DATASET}) + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.CALLBACK(ACTION{IEDITCONTEXT},DATASET[]) #region Read and Write blob fields with a row cursor in a callback QueuedTask.Run(() => { @@ -1041,25 +1491,27 @@ public static void ReadWriteBlobRow() { while (rc.MoveNext()) { - //read file into memory stream - var msr = new MemoryStream(); - using (FileStream file = new FileStream(@"d:\images\Hydrant.jpg", FileMode.Open, FileAccess.Read)) - { - file.CopyTo(msr); - } - using (var record = rc.Current) { - record["BlobField"] = msr; - record.Store(); - - //read the blob field to a file + //read the blob field and save to a file var msw = new MemoryStream(); msw = record["BlobField"] as MemoryStream; using (FileStream file = new FileStream(@"d:\temp\blob.jpg", FileMode.Create, FileAccess.Write)) { msw.WriteTo(file); } + + //read file into memory stream + var msr = new MemoryStream(); + using (FileStream file = new FileStream(@"d:\images\Hydrant.jpg", FileMode.Open, FileAccess.Read)) + { + file.CopyTo(msr); + } + + //put the memory stream in the blob field and save to feature + record["BlobField"] = msr; + record.Store(); + } } } @@ -1072,71 +1524,81 @@ public static void ReadWriteBlobRow() #region ProSnippet Group: Accessing Raster Fields #endregion - public static void WriteImageToRasterField() + public static void ReadFromRasterField() { - #region Write an image to a raster field - QueuedTask.Run(()=> - { - var sel = MapView.Active.Map.GetSelection(); - - //Insert an image into a raster field - //Image will be written with no compression - var op = new EditOperation(); - op.Name = "Raster Inspector"; - var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); - insp.Load(sel.Keys.First(), sel.Values.First()); - insp["Photo"] = @"e:\temp\Hydrant.jpg"; - op.Modify(insp); - op.Execute(); + // cref: ARCGIS.DESKTOP.EDITING.ATTRIBUTES.INSPECTOR.LOAD(MAPMEMBER,INT64) + #region Read from a raster field + QueuedTask.Run(() => + { + var sel = MapView.Active.Map.GetSelection(); + + //Read a raster from a raster field as an InteropBitmap + //the bitmap can then be used as an imagesource or written to disk + var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); + insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); + var ibmp = insp["Photo"] as System.Windows.Interop.InteropBitmap; }); #endregion } - public static void WriteCompImageToRasterField() + public static void WriteImageToRasterField() { - #region Write a compressed image to a raster field + // cref: ARCGIS.DESKTOP.EDITING.ATTRIBUTES.INSPECTOR.LOAD(MAPMEMBER,INT64) + #region Write an image to a raster field QueuedTask.Run(() => { - //Open the raster dataset on disk and create a compressed raster value dataset object - var dataStore = new ArcGIS.Core.Data.FileSystemDatastore(new ArcGIS.Core.Data.FileSystemConnectionPath(new System.Uri(@"e:\temp"), ArcGIS.Core.Data.FileSystemDatastoreType.Raster)); - var fileRasterDataset = dataStore.OpenDataset("Hydrant.jpg"); - var rv = new ArcGIS.Core.Data.Raster.RasterValue(); - rv.SetRasterDataset(fileRasterDataset); - var storageDef = new ArcGIS.Core.Data.Raster.RasterStorageDef(); - storageDef.SetCompressionType(ArcGIS.Core.Data.Raster.RasterCompressionType.JPEG); - storageDef.SetCompressionQuality(90); - rv.SetRasterStorageDef(storageDef); - var sel = MapView.Active.Map.GetSelection(); - //insert a raster value object into the raster field + //Insert an image into a raster field + //Image will be written with no compression + var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); + insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); + insp["Photo"] = @"e:\temp\Hydrant.jpg"; + var op = new EditOperation(); op.Name = "Raster Inspector"; - var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); - insp.Load(sel.Keys.First(), sel.Values.First()); - insp["Photo"] = rv; op.Modify(insp); op.Execute(); }); #endregion } - public static void ReadFromRasterField() + public static void WriteCompImageToRasterField() { - #region Read from a raster field + // cref: ArcGIS.Core.Data.Raster.RasterStorageDef._ctor + // cref: ArcGIS.Core.Data.Raster.RasterStorageDef._ctor() + // cref: ARCGIS.CORE.DATA.RASTER.RASTERSTORAGEDEF.SETCOMPRESSIONTYPE + // cref: ARCGIS.CORE.DATA.RASTER.RASTERSTORAGEDEF.SETCOMPRESSIONQUALITY + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.MODIFY(INSPECTOR) + // cref: ArcGIS.Core.Data.Raster.RasterValue.SetRasterStorageDef + // cref: ArcGIS.Core.Data.Raster.RasterValue.SetRasterDataset + #region Write a compressed image to a raster field QueuedTask.Run(() => { - var sel = MapView.Active.Map.GetSelection(); + //Open the raster dataset on disk and create a compressed raster value dataset object + var dataStore = new ArcGIS.Core.Data.FileSystemDatastore(new ArcGIS.Core.Data.FileSystemConnectionPath(new System.Uri(@"e:\temp"), ArcGIS.Core.Data.FileSystemDatastoreType.Raster)); + using (var fileRasterDataset = dataStore.OpenDataset("Hydrant.jpg")) + { + var storageDef = new ArcGIS.Core.Data.Raster.RasterStorageDef(); + storageDef.SetCompressionType(ArcGIS.Core.Data.Raster.RasterCompressionType.JPEG); + storageDef.SetCompressionQuality(90); - //Read a raster from a raster field as an InteropBitmap - //the bitmap can then be used as an imagesource or written to disk - var op = new EditOperation(); - op.Name = "Raster Inspector"; - var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); - insp.Load(sel.Keys.First(), sel.Values.First()); - var ibmp = insp["Photo"] as System.Windows.Interop.InteropBitmap; - op.Modify(insp); - op.Execute(); + var rv = new ArcGIS.Core.Data.Raster.RasterValue(); + rv.SetRasterDataset(fileRasterDataset); + rv.SetRasterStorageDef(storageDef); + + var sel = MapView.Active.Map.GetSelection(); + + //insert a raster value object into the raster field + var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector(); + insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First()); + insp["Photo"] = rv; + + var op = new EditOperation(); + op.Name = "Raster Inspector"; + op.Modify(insp); + op.Execute(); + } }); #endregion } @@ -1144,6 +1606,7 @@ public static void ReadFromRasterField() #region ProSnippet Group: Working with the Sketch #endregion + // cref: ARCGIS.DESKTOP.MAPPING.MAPTOOL.ACTIVATESELECTASYNC #region Toggle sketch selection mode //UseSelection = true; (UseSelection must be set to true in the tool constructor or tool activate) private bool _inSelMode = false; @@ -1199,6 +1662,8 @@ protected override void OnToolKeyUp(MapViewKeyEventArgs k) } #endregion + // cref: ArcGIS.Desktop.Mapping.Events.SketchModifiedEventArgs.CurrentSketch + // cref: ArcGIS.Desktop.Mapping.Events.SketchModifiedEventArgs.PreviousSketch #region Listen to the sketch modified event // SketchModified event is fired by @@ -1231,6 +1696,8 @@ private void OnSketchModified(ArcGIS.Desktop.Mapping.Events.SketchModifiedEventA #endregion + // cref: ArcGIS.Desktop.Mapping.Events.BeforeSketchCompletedEventArgs.Sketch + // cref: ArcGIS.Desktop.Mapping.Events.BeforeSketchCompletedEventArgs.SetSketchGeometry #region Listen to the before sketch completed event and modify the sketch // BeforeSketchCompleted event is fired by @@ -1251,6 +1718,7 @@ private Task OnBeforeSketchCompleted(BeforeSketchCompletedEventArgs args) } #endregion + // cref: ArcGIS.Desktop.Mapping.Events.SketchCompletedEventArgs.Sketch #region Listen to the sketch completed event // SketchCompleted event is fired by @@ -1287,13 +1755,18 @@ public ConstructionTool1() // set FireSketchEvents property to true FireSketchEvents = true; - } + } // ... } #endregion + // cref: ArcGIS.Desktop.Mapping.MapTool.GetSketchSegmentSymbolOptions() + // cref: ArcGIS.Desktop.Core.SegmentSymbolOptions + // cref: ArcGIS.Desktop.Mapping.MapTool.SetSketchSegmentSymbolOptions + // cref: ArcGIS.Desktop.Mapping.MapTool.SetSketchVertexSymbolOptions + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions #region Customizing the Sketch Symbol of a Custom Sketch Tool //Custom tools have the ability to change the symbology used when sketching a new feature. @@ -1341,7 +1814,7 @@ protected override Task OnToolActivateAsync(bool active) SetSketchVertexSymbolOptions(VertexSymbolType.RegularUnselected, vertexOptions); }); - return base.OnToolActivateAsync(active); + return base.OnToolActivateAsync(active); } #endregion @@ -1355,25 +1828,30 @@ private async void Snapping() FeatureLayer fLayer = null; IEnumerable layerList = null; + // cref: ArcGIS.Desktop.Mapping.Snapping.IsEnabled #region Configure Snapping - Turn Snapping on or off //enable snapping ArcGIS.Desktop.Mapping.Snapping.IsEnabled = true; - // disable snapping ArcGIS.Desktop.Mapping.Snapping.IsEnabled = false; #endregion - + // cref: ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(System.Collections.Generic.IEnumerable) + // cref: ArcGIS.Desktop.Mapping.Snapping.SetSnapMode(ArcGIS.Desktop.Mapping.SnapMode, System.Boolean) + // cref: ArcGIS.Desktop.Mapping.Snapping.SnapModes + // cref: ArcGIS.Desktop.Mapping.Snapping.GetSnapMode(ArcGIS.Desktop.Mapping.SnapMode) #region Configure Snapping - Application SnapModes // set only Point and Edge snapping modes, clear everything else - ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(SnapMode.Point, SnapMode.Edge); - + //At 2.x - ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(SnapMode.Point, SnapMode.Edge); + ArcGIS.Desktop.Mapping.Snapping.SetSnapModes( + new List() { SnapMode.Point, SnapMode.Edge }); // clear all snap modes - ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(); + //At 2.x - ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(); + ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(null); // set snap modes one at a time @@ -1381,24 +1859,24 @@ private async void Snapping() ArcGIS.Desktop.Mapping.Snapping.SetSnapMode(SnapMode.End, true); ArcGIS.Desktop.Mapping.Snapping.SetSnapMode(SnapMode.Intersection, true); - // get current snap modes var snapModes = ArcGIS.Desktop.Mapping.Snapping.SnapModes; - // get state of a specific snap mode bool isOn = ArcGIS.Desktop.Mapping.Snapping.GetSnapMode(SnapMode.Vertex); #endregion - + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.IsSnappable + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetSnappable(System.Boolean) + // cref: ARCGIS.CORE.CIM.CIMGEOFEATURELAYERBASE.SNAPPABLE #region Configure Snapping - Layer Snappability // is the layer snappable? bool isSnappable = fLayer.IsSnappable; // set snappability for a specific layer - needs to run on the MCT - await QueuedTask.Run(() => + await QueuedTask.Run(() => { // use an extension method fLayer.SetSnappable(true); @@ -1421,6 +1899,22 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.GetSnapMode(ArcGIS.Desktop.Mapping.SnapMode) + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.SetSnapMode(ArcGIS.Desktop.Mapping.SnapMode, System.Boolean) + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.Edge + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.End + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.#ctor(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.Vertex + // cref: ArcGIS.Desktop.Mapping.Snapping.GetLayerSnapModes(ArcGIS.Desktop.Mapping.Layer) + // cref: ArcGIS.Desktop.Mapping.Snapping.GetLayerSnapModes(IEnumerable{Layer}) + // cref: ARCGIS.DESKTOP.MAPPING.Snapping.SetLayerSnapModes(Layer,Boolean) + // cref: ARCGIS.DESKTOP.MAPPING.Snapping.SetLayerSnapModes(IEnumerable{Layer},Boolean) + // cref: ARCGIS.DESKTOP.MAPPING.Snapping.SetLayerSnapModes(Layer,LayerSnapModes) + // cref: ARCGIS.DESKTOP.MAPPING.Snapping.SetLayerSnapModes(Layer,SnapMode,Boolean) + // cref: ARCGIS.DESKTOP.MAPPING.Snapping.SetLayerSnapModes(IEnumerable{Layer},LayerSnapModes) + // cref: ARCGIS.DESKTOP.MAPPING.Snapping.SetLayerSnapModes(IDictionary{Layer,LayerSnapModes},Boolean) + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.Intersection #region Configure Snapping - LayerSnapModes layerList = MapView.Active.Map.GetLayersAsFlattenedList().OfType(); @@ -1491,6 +1985,10 @@ await QueuedTask.Run(() => #endregion + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.SetSnapModes + // cref: ArcGIS.Desktop.Mapping.LayerSnapModes.SetSnapMode(ArcGIS.Desktop.Mapping.SnapMode, System.Boolean) + // cref: ARCGIS.DESKTOP.MAPPING.Snapping.SetLayerSnapModes(IDictionary{Layer,LayerSnapModes},Boolean) + // cref: ARCGIS.DESKTOP.MAPPING.FEATURELAYER.SETSNAPPABLE #region Configure Snapping - Combined Example // interested in only snapping to the vertices of a specific layer of interest and not the vertices of other layers @@ -1500,7 +1998,8 @@ await QueuedTask.Run(() => ArcGIS.Desktop.Mapping.Snapping.IsEnabled = true; // turn all application snapModes off - ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(); + //At 2.x - ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(); + ArcGIS.Desktop.Mapping.Snapping.SetSnapModes(null); // set application snapMode vertex on ArcGIS.Desktop.Mapping.Snapping.SetSnapMode(SnapMode.Vertex, true); @@ -1521,14 +2020,26 @@ await QueuedTask.Run(() => ArcGIS.Desktop.Mapping.Snapping.SetLayerSnapModes(dict, true); // true = reset other layers #endregion - + // cref: ArcGIS.Desktop.Mapping.Snapping.GetOptions(ArcGIS.Desktop.Mapping.Map) + // cref: ArcGIS.Desktop.Mapping.SnappingOptions + // cref: ArcGIS.Desktop.Mapping.Snapping.SetOptions(ArcGIS.Desktop.Mapping.Map, ArcGIS.Desktop.Mapping.Snapping.SnappingOptions) + // cref: ArcGIS.Desktop.Mapping.SnappingOptions.IsSnapToSketchEnabled + // cref: ArcGIS.Desktop.Mapping.SnappingOptions.XYTolerance + // cref: ArcGIS.Desktop.Mapping.SnappingOptions.IsZToleranceEnabled + // cref: ArcGIS.Desktop.Mapping.SnappingOptions.ZTolerance + // cref: ArcGIS.Desktop.Mapping.SnappingOptions.SnapTipDisplayParts + // cref: ArcGIS.Desktop.Mapping.SnappingOptions.SnapTipColor + // cref: ArcGIS.Core.CIM.SnapTipDisplayPart + // cref: ArcGIS.Desktop.Mapping.SnappingOptions.SnapTipDisplayParts #region Snap Options //Set snapping options via get/set options var snapOptions = ArcGIS.Desktop.Mapping.Snapping.GetOptions(myMap); - snapOptions.SnapToSketchEnabled = true; + //At 2.x - snapOptions.SnapToSketchEnabled = true; + snapOptions.IsSnapToSketchEnabled = true; snapOptions.XYTolerance = 100; - snapOptions.ZToleranceEnabled = true; + //At 2.x - snapOptions.ZToleranceEnabled = true; + snapOptions.IsZToleranceEnabled = true; snapOptions.ZTolerance = 0.6; //turn on snap tip display parts @@ -1536,11 +2047,12 @@ await QueuedTask.Run(() => //turn off all snaptips //snapOptions.SnapTipDisplayParts = (int)SnapTipDisplayPart.SnapTipDisplayNone; - + //turn on layer display only //snapOptions.SnapTipDisplayParts = (int)SnapTipDisplayPart.SnapTipDisplayLayer; - snapOptions.GeometricFeedbackColor = ColorFactory.Instance.RedRGB; + //At 2.x - snapOptions.GeometricFeedbackColor = ColorFactory.Instance.RedRGB; + snapOptions.SnapTipColor = ColorFactory.Instance.RedRGB; ArcGIS.Desktop.Mapping.Snapping.SetOptions(myMap, snapOptions); @@ -1549,7 +2061,8 @@ await QueuedTask.Run(() => } - public class CSVData { - public Double X, Y, StopOrder, FacilityID; + public class CSVData + { + public Double X, Y, StopOrder, FacilityID; } } diff --git a/Examples/Editing/ProSnippetCS6.cs b/Examples/Editing/ProSnippetCS6.cs index 8aad7bc..c3be5c1 100644 --- a/Examples/Editing/ProSnippetCS6.cs +++ b/Examples/Editing/ProSnippetCS6.cs @@ -60,6 +60,12 @@ public void OpMgr() #region ProSnippet Group: Undo / Redo #endregion + // cref: ArcGIS.Desktop.Framework.OperationManager + // cref: ArcGIS.Desktop.Framework.OperationManager.CanUndo + // cref: ArcGIS.Desktop.Framework.OperationManager.UndoAsync() + // cref: ArcGIS.Desktop.Framework.OperationManager.CanRedo + // cref: ArcGIS.Desktop.Framework.OperationManager.RedoAsync() + // cref: ARCGIS.DESKTOP.MAPPING.MAP.OPERATIONMANAGER #region Undo/Redo the Most Recent Operation //undo @@ -76,8 +82,13 @@ public void OpMgr() #region ProSnippet Group: Edit Templates #endregion - public void FindTemplateByName() + public void Templates() { + // cref: ARCGIS.DESKTOP.MAPPING.MAP.FINDLAYERS + // cref: ARCGIS.DESKTOP.MAPPING.MAP.FINDSTANDALONETABLES + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.GetTemplate(ArcGIS.Desktop.Mapping.MapMember,System.String) + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate + // cref: ArcGIS.Desktop.Editing.Templates.EditingRowTemplate #region Find edit template by name on a layer ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { @@ -90,10 +101,12 @@ public void FindTemplateByName() var mhTemplate = map.FindLayers("Manhole").FirstOrDefault()?.GetTemplate("Active"); }); #endregion - } - public void FindTableTemplate() - { + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.GetTemplates(ArcGIS.Desktop.Mapping.MapMember) + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate + // cref: ArcGIS.Desktop.Editing.Templates.EditingRowTemplate + // cref: ARCGIS.DESKTOP.MAPPING.MAP.FINDSTANDALONETABLES(System.String) + // cref: ArcGIS.Desktop.Mapping.Map.GetStandaloneTablesAsFlattenedList #region Find table templates belonging to a standalone table ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { @@ -107,8 +120,26 @@ public void FindTableTemplate() var statisticsTableTemplates = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().First(l => l.Name.Equals("Trading Statistics")).GetTemplates(); }); #endregion + + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate.Current + #region Current template + EditingTemplate template = EditingTemplate.Current; + #endregion + } + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.GetTemplate(ArcGIS.Desktop.Mapping.MapMember,System.String) + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate + // cref: ArcGIS.Desktop.Editing.Templates.EditingRowTemplate + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate.DefaultToolID + // cref: ArcGIS.Core.CIM.CIMBasicFeatureLayer.AutoGenerateFeatureTemplates + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate.GetDefinition + // cref: ArcGIS.Core.CIM.CIMEditingTemplate + // cref: ArcGIS.Core.CIM.CIMBasicRowTemplate + // cref: ArcGIS.Core.CIM.CIMRowTemplate + // cref: ArcGIS.Core.CIM.CIMEditingTemplate.DefaultToolGUID + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate.GetDefinition( ArcGIS.Core.CIM.CIMEditingTemplate) #region Change Default Edit tool for a template public Task ChangeTemplateDefaultToolAsync(ArcGIS.Desktop.Mapping.FeatureLayer flayer, string toolContentGUID, string templateName) @@ -141,7 +172,10 @@ public Task ChangeTemplateDefaultToolAsync(ArcGIS.Desktop.Mapping.FeatureLayer f // // // then the toolContentGUID would be "e58239b3-9c69-49e5-ad4d-bb2ba29ff3ea" - templateDef.ToolProgID = toolContentGUID; + + //At 2.x - + //templateDef.ToolProgID = toolContentGUID; + templateDef.DefaultToolGUID = toolContentGUID; // set the definition back to template.SetDefinition(templateDef); @@ -157,6 +191,20 @@ public Task ChangeTemplateDefaultToolAsync(ArcGIS.Desktop.Mapping.FeatureLayer f protected void FilterTemplateTools() { + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.GetTemplates(ArcGIS.Desktop.Mapping.MapMember) + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate + // cref: ArcGIS.Core.CIM.CIMEditingTemplate + // cref: ArcGIS.Core.CIM.CIMBasicRowTemplate + // cref: ArcGIS.Core.CIM.CIMRowTemplate + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate.GetDefinition() + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate.ActivateDefaultToolAsync + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate.ToolIDs + // cref: ArcGIS.Core.CIM.CIMExtensions.GetExcludedToolIDs(ArcGIS.Core.CIM.CIMEditingTemplate) + // cref: ArcGIS.Core.CIM.CIMExtensions.SetExcludedToolIDs(ArcGIS.Core.CIM.CIMEditingTemplate,System.Collections.Generic.IEnumerable{System.String}) + // cref: ArcGIS.Core.CIM.CIMExtensions.AllowToolID(ArcGIS.Core.CIM.CIMEditingTemplate,System.String) + // cref: ArcGIS.Core.CIM.CIMBasicFeatureLayer.FeatureTemplates + // cref: ARCGIS.DESKTOP.MAPPING.LAYER.GETDEFINITION + // cref: ARCGIS.DESKTOP.MAPPING.LAYER.SETDEFINITION #region Hide or show editing tools on templates QueuedTask.Run(() => { @@ -174,10 +222,19 @@ protected void FilterTemplateTools() //get the visible tools on this template var allTools = et.ToolIDs.ToList(); //add the hidden tools on this template - allTools.AddRange(cimEditTemplate.GetExcludedToolDamlIds().ToList()); + allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList()); //hide all the tools then allow the line tool - cimEditTemplate.SetExcludedToolDamlIds(allTools.ToArray()); - cimEditTemplate.AllowToolDamlID("esri_editing_SketchLineTool"); + + //At 2.x - + //allTools.AddRange(cimEditTemplate.GetExcludedToolDamlIds().ToList()); + allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList()); + + //At 2.x - + //cimEditTemplate.SetExcludedToolDamlIds(allTools.ToArray()); + //cimEditTemplate.AllowToolDamlID("esri_editing_SketchLineTool"); + + cimEditTemplate.SetExcludedToolIDs(allTools.ToArray()); + cimEditTemplate.AllowToolID("esri_editing_SketchLineTool"); newCIMEditingTemplates.Add(cimEditTemplate); } //update the layer templates @@ -196,6 +253,10 @@ public void CreateTemplate() string value2 = ""; string value3 = ""; + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.LoadSchema(ArcGIS.Desktop.Mapping.MapMember) + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.CreateTemplate(ArcGIS.Desktop.Mapping.MapMember,System.String,System.String,ArcGIS.Desktop.Editing.Attributes.Inspector,System.String,System.String[],System.String[]) + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate + // cref: ArcGIS.Desktop.Editing.Templates.EditingRowTemplate #region Create New Template using layer.CreateTemplate var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); @@ -223,6 +284,16 @@ public void CreateTemplate() }); #endregion + // cref: ARCGIS.DESKTOP.EDITING.TEMPLATES.EDITINGTEMPLATE.GETDEFINITION + // cref: ArcGIS.ArcGIS.Core.CIM.CIMEditingTemplate + // cref: ArcGIS.ArcGIS.Core.CIM.CIMEditingTemplate.Description + // cref: ArcGIS.ArcGIS.Core.CIM.CIMEditingTemplate.Name + // cref: ArcGIS.Core.CIM.CIMBasicRowTemplate + // cref: ArcGIS.Core.CIM.CIMRowTemplate + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.CreateTemplate(ArcGIS.Desktop.Mapping.MapMember,ArcGIS.ArcGIS.Core.CIM.CIMEditingTemplate) + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.CreateTemplate(ArcGIS.Desktop.Mapping.MapMember,System.String,System.String,ArcGIS.Desktop.Editing.Attributes.Inspector,System.String,System.String[],System.String[]) + // cref: ArcGIS.Desktop.Editing.Templates.EditingTemplate + // cref: ArcGIS.Desktop.Editing.Templates.EditingRowTemplate #region Create New Table Template using table.CreateTemplate var table = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().FirstOrDefault(); if (table == null) @@ -242,6 +313,13 @@ public void CreateTemplate() }); #endregion + // cref: ARCGIS.DESKTOP.EDITING.TEMPLATES.EDITINGTEMPLATE.GETDEFINITION + // cref: ARCGIS.DESKTOP.EDITING.TEMPLATES.EDITINGTEMPLATE.SETDEFINITION(ArcGIS.ArcGIS.Core.CIM.CIMEditingTemplate) + // cref: ArcGIS.ArcGIS.Core.CIM.CIMEditingTemplate + // cref: ArcGIS.ArcGIS.Core.CIM.CIMEditingTemplate.Description + // cref: ArcGIS.ArcGIS.Core.CIM.CIMEditingTemplate.Name + // cref: ArcGIS.Core.CIM.CIMBasicRowTemplate + // cref: ArcGIS.Core.CIM.CIMRowTemplate #region Update a Table Template QueuedTask.Run(() => { @@ -255,6 +333,15 @@ public void CreateTemplate() }); #endregion + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition.GetSymbolCollection + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition.GetLabelClassCollection + // cref: ARCGIS.DESKTOP.MAPPING.FEATURELAYER.GETFEATURECLASS + // cref: ArcGIS.Desktop.Editing.AnnotationProperties + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.LoadSchema(ArcGIS.Desktop.Mapping.MapMember) + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.GetAnnotationProperties + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.SetAnnotationProperties + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.CreateTemplate(ArcGIS.Desktop.Mapping.MapMember,System.String,System.String,ArcGIS.Desktop.Editing.Attributes.Inspector,System.String,System.String[],System.String[]) #region Create Annotation Template // get an anno layer @@ -339,6 +426,9 @@ public void CreateTemplate() public void RemoveTemplate() { + // cref: ArcGIS.Desktop.Mapping.Map.GetStandaloneTablesAsFlattenedList + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.RemoveTemplate(ArcGIS.Desktop.Mapping.MapMember,ArcGIS.Desktop.Editing.Templates.EditingTemplate) + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.RemoveTemplate(ArcGIS.Desktop.Mapping.MapMember,System.String) #region Remove a table template var table = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().FirstOrDefault(); if (table == null) @@ -356,6 +446,11 @@ public void RemoveTemplate() public void TemplateChanged() { + // cref: ArcGIS.Desktop.Editing.Events.ActiveTemplateChangedEvent + // cref: ArcGIS.Desktop.Editing.Events.ActiveTemplateChangedEventArgs + // cref: ArcGIS.Desktop.Editing.Events.ActiveTemplateChangedEventArgs.IncomingTemplate + // cref: ARCGIS.DESKTOP.EDITING.TEMPLATES.EDITINGTEMPLATE.ACTIVATETOOLASYNC + // cref: ArcGIS.Desktop.Editing.Events.ActiveTemplateChangedEvent.Subscribe(System.Action{ArcGIS.Desktop.Editing.Events.ActiveTemplateChangedEventArgs},System.Boolean) #region Active Template Changed ArcGIS.Desktop.Editing.Events.ActiveTemplateChangedEvent.Subscribe(OnActiveTemplateChanged); @@ -376,6 +471,11 @@ async void OnActiveTemplateChanged(ArcGIS.Desktop.Editing.Events.ActiveTemplateC #region ProSnippet Group: Annotation #endregion + // cref: ARCGIS.DESKTOP.MAPPING.MAPTOOL.ONSKETCHCOMPLETEASYNC + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.GetAnnotationProperties + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.SetAnnotationProperties(ArcGIS.Desktop.Editing.AnnotationProperties) + // cref: ArcGIS.Desktop.Editing.AnnotationProperties + // cref: ArcGIS.Core.CIM.HorizontalAlignment #region Annotation Construction Tool //In your config.daml...set the categoryRefID @@ -427,6 +527,8 @@ protected async override Task OnSketchCompleteAsync(Geometry geometry) public static void StartEditAnnotationTool() { + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.GETPLUGINWRAPPER + // cref: ARCGIS.DESKTOP.FRAMEWORK.IPLUGINWRAPPER #region Programmatically start Edit Annotation var plugin = FrameworkApplication.GetPlugInWrapper("esri_editing_EditVerticesText"); @@ -441,6 +543,10 @@ internal async void UpdateAnnotation() BasicFeatureLayer annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().First() as BasicFeatureLayer; var oid = 1; + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.GetAnnotationProperties + // cref: ArcGIS.Desktop.Editing.AnnotationProperties.TextString + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.SetAnnotationProperties(ArcGIS.Desktop.Editing.AnnotationProperties) + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify(ArcGIS.Desktop.Editing.Attributes.Inspector) #region Update Annotation Text await QueuedTask.Run(() => @@ -448,7 +554,8 @@ await QueuedTask.Run(() => //annoLayer is ~your~ Annotation layer... // use the inspector methodology - var insp = new Inspector(true); + //at 2.x - var insp = new Inspector(true); + var insp = new Inspector(); insp.Load(annoLayer, oid); // get the annotation properties @@ -466,6 +573,10 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.GetAnnotationProperties + // cref: ArcGIS.Desktop.Editing.AnnotationProperties.Shape + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.SetAnnotationProperties(ArcGIS.Desktop.Editing.AnnotationProperties) + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify(ArcGIS.Desktop.Editing.Attributes.Inspector) #region Modify Annotation Shape await QueuedTask.Run(() => @@ -480,7 +591,8 @@ await QueuedTask.Run(() => //Instead, we must use the AnnotationProperties //annoLayer is ~your~ Annotation layer - var insp = new Inspector(true); + //at 2.x - var insp = new Inspector(true); + var insp = new Inspector(); insp.Load(annoLayer, oid); AnnotationProperties annoProperties = insp.GetAnnotationProperties(); @@ -500,6 +612,12 @@ await QueuedTask.Run(() => #endregion + // cref: ArcGIS.Core.CIM.HorizontalAlignment + // cref: ArcGIS.Desktop.Editing.AnnotationProperties.LoadFromTextGraphic(ArcGIS.Core.CIM.CIMTextGraphic) + // cref: ArcGIS.Desktop.Editing.AnnotationProperties.TextGraphic + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.GetAnnotationProperties + // cref: ArcGIS.Desktop.Editing.Attributes.Inspector.SetAnnotationProperties(ArcGIS.Desktop.Editing.AnnotationProperties) + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify(ArcGIS.Desktop.Editing.Attributes.Inspector) #region Modify Annotation Text Graphic await QueuedTask.Run(() => @@ -510,7 +628,8 @@ await QueuedTask.Run(() => return; // use the first selelcted feature - var insp = new Inspector(true); + //at 2.x - var insp = new Inspector(true); + var insp = new Inspector(); insp.Load(annoLayer, selection.GetObjectIDs().FirstOrDefault()); // getAnnoProperties should return null if not an annotation feature @@ -543,11 +662,41 @@ await QueuedTask.Run(() => #endregion } + #region ProSnippet Group : Ground to Grid + #endregion + + internal void G2G() + { + // cref: ArcGIS.Core.CIM.CIMGroundToGridCorrection + // cref: ArcGIS.Desktop.Editing.GroundToGridCorrection.IsCorrecting(ArcGIS.Core.CIM.CIMGroundToGridCorrection) + // cref: ArcGIS.Desktop.Editing.GroundToGridCorrection.UsingDirectionOffset(ArcGIS.Core.CIM.CIMGroundToGridCorrection) + // cref: ArcGIS.Desktop.Editing.GroundToGridCorrection.GetDirectionOffset(ArcGIS.Core.CIM.CIMGroundToGridCorrection) + // cref: ArcGIS.Desktop.Editing.GroundToGridCorrection.UsingDistanceFactor(ArcGIS.Core.CIM.CIMGroundToGridCorrection) + // cref: ArcGIS.Desktop.Editing.GroundToGridCorrection.UsingElevationMode(ArcGIS.Core.CIM.CIMGroundToGridCorrection) + // cref: ArcGIS.Desktop.Editing.GroundToGridCorrection.UsingConstantScaleFactor(ArcGIS.Core.CIM.CIMGroundToGridCorrection) + // cref: ArcGIS.Desktop.Editing.GroundToGridCorrection.GetConstantScaleFactor(ArcGIS.Core.CIM.CIMGroundToGridCorrection) + #region G2G Settings + CIMGroundToGridCorrection correction = null; + bool isCorecting = correction.IsCorrecting(); // equivalent to correction != null && correction.Enabled; + bool UsingOffset = correction.UsingDirectionOffset(); // equivalent to correction.IsCorrecting() && correction.UseDirection; + double dOffset = correction.GetDirectionOffset(); // equivalent to correction.UsingDirectionOffset() ? correction.Direction : DefaultDirectionOffset; + bool usingDistanceFactor = correction.UsingDistanceFactor(); // equivalent to correction.IsCorrecting() && correction.UseScale; + bool usingElevation = correction.UsingElevationMode(); // equivalent to correction.UsingDistanceFactor() && c.ScaleType == GroundToGridScaleType.ComputeUsingElevation; + bool usingSFactor = correction.UsingConstantScaleFactor(); //; equivalent to correction.UsingDistanceFactor() && correction.ScaleType == GroundToGridScaleType.ConstantFactor; + double dSFactor = correction.GetConstantScaleFactor(); // equivalent to correctionc.UsingDistanceFactor() ? correction.ConstantScaleFactor : DefaultConstantScaleFactor; + #endregion + } + #region ProSnippet Group: EditingOptions #endregion public void EditingOptions() { + // cref: ArcGIS.Desktop.Core.ApplicationOptions.EditingOptions + // cref: ArcGIS.Desktop.Core.EditingOptions + // cref: ArcGIS.Desktop.Core.UncommitedEditMode + // cref: ArcGIS.Desktop.Core.ToolbarPosition + // cref: ArcGIS.Desktop.Core.ToolbarSize #region Get/Set Editing Options //toggle, switch option values @@ -599,6 +748,12 @@ public void EditingOptions() public void SymbologyOptions() { + // cref: ArcGIS.Desktop.Core.ApplicationOptions.EditingOptions + // cref: ArcGIS.Desktop.Core.EditingOptions + // cref: ArcGIS.Desktop.Core.EditingOptions.GetVertexSymbolOptions(ArcGIS.Desktop.Core.VertexSymbolType) + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions.GetPointSymbol() + // cref: ArcGIS.Desktop.Core.VertexSymbolType #region Get Sketch Vertex Symbology Options var options = ApplicationOptions.EditingOptions; @@ -621,6 +776,13 @@ public void SymbologyOptions() #endregion + // cref: ArcGIS.Desktop.Core.ApplicationOptions.EditingOptions + // cref: ArcGIS.Desktop.Core.EditingOptions.GetSegmentSymbolOptions() + // cref: ArcGIS.Desktop.Core.SegmentSymbolOptions + // cref: ArcGIS.Desktop.Core.SegmentSymbolOptions.PrimaryColor + // cref: ArcGIS.Desktop.Core.SegmentSymbolOptions.Width + // cref: ArcGIS.Desktop.Core.SegmentSymbolOptions.HasSecondaryColor + // cref: ArcGIS.Desktop.Core.SegmentSymbolOptions.SecondaryColor #region Get Sketch Segment Symbology Options //var options = ApplicationOptions.EditingOptions; @@ -646,6 +808,15 @@ public void SymbologyOptions() }); #endregion + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions + // cref: ArcGIS.Desktop.Core.VertexSymbolType + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions.#ctor(ArcGIS.Desktop.Core.VertexSymbolType) + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions.OutlineColor + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions.MarkerType + // cref: ArcGIS.Desktop.Core.VertexMarkerType + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions.Size + // cref: ArcGIS.Desktop.Core.EditingOptions.CanSetVertexSymbolOptions(ArcGIS.Desktop.Core.VertexSymbolType, ArcGIS.Desktop.Core.VertexSymbolOptions) + // cref: ArcGIS.Desktop.Core.EditingOptions.SetVertexSymbolOptions(ArcGIS.Desktop.Core.VertexSymbolType, ArcGIS.Desktop.Core.VertexSymbolOptions) #region Set Sketch Vertex Symbol Options //var options = ApplicationOptions.EditingOptions; @@ -669,6 +840,10 @@ public void SymbologyOptions() #endregion + // cref: ArcGIS.Desktop.Core.EditingOptions.GetSegmentSymbolOptions() + // cref: ArcGIS.Desktop.Core.SegmentSymbolOptions + // cref: ArcGIS.Desktop.Core.EditingOptions.CanSetSegmentSymbolOptions(ArcGIS.Desktop.Core.SegmentSymbolOptions) + // cref: ArcGIS.desktop.Core.EditingOptions.SetSegmentSymbolOptions(ArcGIS.Desktop.Core.SegmentSymbolOptions) #region Set Sketch Segment Symbol Options //var options = ApplicationOptions.EditingOptions; @@ -689,6 +864,10 @@ public void SymbologyOptions() #endregion + // cref: ArcGIS.Desktop.Core.VertexSymbolType + // cref: ArcGIS.Desktop.Core.EditingOptions.GetDefaultVertexSymbolOptions(ArcGIS.Desktop.Core.VertexSymbolType) + // cref: ArcGIS.Desktop.Core.VertexSymbolOptions + // cref: ArcGIS.Desktop.Core.EditingOptions.SetVertexSymbolOptions(ArcGIS.Desktop.Core.VertexSymbolType, ArcGIS.Desktop.Core.VertexSymbolOptions) #region Set Sketch Vertex Symbol Back to Default //var options = ApplicationOptions.EditingOptions; @@ -704,6 +883,9 @@ public void SymbologyOptions() #endregion + // cref: ArcGIS.Desktop.Core.EditingOptions.GetDefaultSegmentSymbolOptions + // cref: ArcGIS.Desktop.Core.SegmentSymbolOptions + // cref: ArcGIS.Desktop.Core.EditingOptions.SetSegmentSymbolOptions #region Set Sketch Segment Symbol Back to Default //var options = ApplicationOptions.EditingOptions; @@ -722,9 +904,17 @@ public void SymbologyOptions() public void VersioningOptions() { - #region Get and Set Versioning Options + // cref: ArcGIS.Desktop.Core.ApplicationOptions.VersioningOptions + // cref: ArcGIS.Desktop.Core.VersioningOptions + // cref: ArcGIS.Desktop.Core.VersioningOptions.DefineConflicts + // cref: ArcGIS.Desktop.Core.VersioningOptions.ConflictResolution + // cref: ArcGIS.Desktop.Core.VersioningOptions.ShowConflictsDialog + // cref: ArcGIS.Desktop.Core.VersioningOptions.ShowReconcileDialog + // cref: ArcGIS.Core.Data.ConflictDetectionType + // cref: ArcGIS.Core.Data.ConflictResolutionType + #region Get and Set Versioning Options - var vOptions = ApplicationOptions.VersioningOptions; + var vOptions = ApplicationOptions.VersioningOptions; vOptions.DefineConflicts = (vOptions.DefineConflicts == ConflictDetectionType.ByRow) ? ConflictDetectionType.ByColumn : ConflictDetectionType.ByRow; @@ -737,4 +927,4 @@ public void VersioningOptions() #endregion } } -} \ No newline at end of file +} diff --git a/Examples/Framework.csproj b/Examples/Framework.csproj deleted file mode 100644 index 60e0722..0000000 --- a/Examples/Framework.csproj +++ /dev/null @@ -1,198 +0,0 @@ - - - - - Debug - AnyCPU - {1362EE31-7FCC-A2A8-C80A-544E34B480FD} - Library - Properties - Framework - Framework - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\Framework\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\Framework\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - - \ No newline at end of file diff --git a/Examples/Framework/Framework.csproj b/Examples/Framework/Framework.csproj new file mode 100644 index 0000000..98b623c --- /dev/null +++ b/Examples/Framework/Framework.csproj @@ -0,0 +1,80 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/Framework/ProSnippets.cs b/Examples/Framework/ProSnippets.cs index 86b0d9e..89821dc 100644 --- a/Examples/Framework/ProSnippets.cs +++ b/Examples/Framework/ProSnippets.cs @@ -35,144 +35,165 @@ limitations under the License. using ArcGIS.Desktop.Mapping.Events; using System.Linq; -namespace Framework.Snippets { +namespace Framework.Snippets +{ internal class Dockpane1ViewModel : ArcGIS.Desktop.Framework.Contracts.DockPane { - #region How to subscribe and unsubscribe to events when the dockpane is visible or hidden - private SubscriptionToken _eventToken = null; - // Called when the visibility of the DockPane changes. - protected override void OnShow(bool isVisible) - { - if (isVisible && _eventToken == null) //Subscribe to event when dockpane is visible - { - _eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent); - } - - if (!isVisible && _eventToken != null) //Unsubscribe as the dockpane closes. - { - MapSelectionChangedEvent.Unsubscribe(_eventToken); - _eventToken = null; - } - } - //Event handler when the MapSelection event is triggered. - private void OnMapSelectionChangedEvent(MapSelectionChangedEventArgs obj) - { - MessageBox.Show("Selection has changed"); - } - #endregion - } - + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANE.ONSHOW + #region How to subscribe and unsubscribe to events when the dockpane is visible or hidden + private SubscriptionToken _eventToken = null; + // Called when the visibility of the DockPane changes. + protected override void OnShow(bool isVisible) + { + if (isVisible && _eventToken == null) //Subscribe to event when dockpane is visible + { + _eventToken = MapSelectionChangedEvent.Subscribe(OnMapSelectionChangedEvent); + } + if (!isVisible && _eventToken != null) //Unsubscribe as the dockpane closes. + { + MapSelectionChangedEvent.Unsubscribe(_eventToken); + _eventToken = null; + } + } + //Event handler when the MapSelection event is triggered. + private void OnMapSelectionChangedEvent(MapSelectionChangedEventArgs obj) + { + MessageBox.Show("Selection has changed"); + } + #endregion + } - internal class ProSnippets2 + internal class ProSnippets2 { public void Snippets() { - #region Execute a command - IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("esri_editing_ShowAttributes"); - var command = wrapper as ICommand; // tool and command(Button) supports this - - if ((command != null) && command.CanExecute(null)) - command.Execute(null); - - #endregion - - #region Set the current tool - - // use SetCurrentToolAsync - FrameworkApplication.SetCurrentToolAsync("esri_mapping_selectByRectangleTool"); - - // or use ICommand.Execute - ICommand cmd = FrameworkApplication.GetPlugInWrapper("esri_mapping_selectByRectangleTool") as ICommand; - if ((cmd != null) && cmd.CanExecute(null)) - cmd.Execute(null); - #endregion - - #region Activate a tab - FrameworkApplication.ActivateTab("esri_mapping_insertTab"); - #endregion - - bool activate = true; - #region Activate/Deactivate a state - to modify a condition - - // Define the condition in the DAML file based on the state - if (activate) - FrameworkApplication.State.Activate("someState"); - else - FrameworkApplication.State.Deactivate("someState"); - #endregion - - #region Determine if the application is busy - - // The application is considered busy if a task is currently running on the main worker thread or any - // pane or dock pane reports that it is busy or intiializing. - - // Many Pro styles (such as Esri_SimpleButton) ensure that a button is disabled when FrameworkApplication.IsBusy is true - // You would use this property to bind to the IsEnabled property of a control (such as a listbox) on a dockpane or pane in order - // to disable it from user interaction while the application is busy. - bool isbusy = FrameworkApplication.IsBusy; - #endregion - - #region Get the Application main window - System.Windows.Window window = FrameworkApplication.Current.MainWindow; - - // center it - Rect rect = System.Windows.SystemParameters.WorkArea; - FrameworkApplication.Current.MainWindow.Left = rect.Left + (rect.Width - FrameworkApplication.Current.MainWindow.ActualWidth) / 2; - FrameworkApplication.Current.MainWindow.Top = rect.Top + (rect.Height - FrameworkApplication.Current.MainWindow.ActualHeight) / 2; - - #endregion - - #region Close ArcGIS Pro - FrameworkApplication.Close(); - #endregion - - #region Get ArcGIS Pro version - //"GetEntryAssembly" should be ArcGISPro.exe - string version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(); - #endregion - #region Close a specific pane - - string _viewPaneID = "my pane"; //DAML ID of your pane - //You could have multiple instances (InstanceIDs) of your pane. - //So you can iterate through the Panes to get "your" panes only - IList myPaneInstanceIDs = new List(); - foreach (Pane pane in FrameworkApplication.Panes) - { - if (pane.ContentID == _viewPaneID) - { - myPaneInstanceIDs.Add(pane.InstanceID); //InstanceID of your pane, could be multiple, so build the collection - } - } - foreach (var instanceID in myPaneInstanceIDs) //close each of "your" panes. - { - FrameworkApplication.Panes.ClosePane(instanceID); - } - #endregion - - #region Activate a pane - var mapPanes = ProApp.Panes.OfType(); - foreach (Pane pane in mapPanes) - { - if (pane.Caption == "MyMap") - { - pane.Activate(); - break; - } - } - #endregion + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.GETPLUGINWRAPPER + // cref: ARCGIS.DESKTOP.FRAMEWORK.IPLUGINWRAPPER + #region Execute a command + IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("esri_editing_ShowAttributes"); + var command = wrapper as ICommand; // tool and command(Button) supports this + + if ((command != null) && command.CanExecute(null)) + command.Execute(null); + + #endregion + + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.SETCURRENTTOOLASYNC + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.GETPLUGINWRAPPER + // cref: ARCGIS.DESKTOP.FRAMEWORK.IPLUGINWRAPPER + #region Set the current tool + + // use SetCurrentToolAsync + FrameworkApplication.SetCurrentToolAsync("esri_mapping_selectByRectangleTool"); + + // or use ICommand.Execute + ICommand cmd = FrameworkApplication.GetPlugInWrapper("esri_mapping_selectByRectangleTool") as ICommand; + if ((cmd != null) && cmd.CanExecute(null)) + cmd.Execute(null); + #endregion + + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.ACTIVATETAB + #region Activate a tab + FrameworkApplication.ActivateTab("esri_mapping_insertTab"); + #endregion + + bool activate = true; + // cref: ARCGIS.DESKTOP.FRAMEWORK.STATE.ACTIVATE + // cref: ARCGIS.DESKTOP.FRAMEWORK.STATE.DEACTIVATE + #region Activate/Deactivate a state - to modify a condition + + // Define the condition in the DAML file based on the state + if (activate) + FrameworkApplication.State.Activate("someState"); + else + FrameworkApplication.State.Deactivate("someState"); + #endregion + + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.IsBusy + #region Determine if the application is busy + + // The application is considered busy if a task is currently running on the main worker thread or any + // pane or dock pane reports that it is busy or intiializing. + + // Many Pro styles (such as Esri_SimpleButton) ensure that a button is disabled when FrameworkApplication.IsBusy is true + // You would use this property to bind to the IsEnabled property of a control (such as a listbox) on a dockpane or pane in order + // to disable it from user interaction while the application is busy. + bool isbusy = FrameworkApplication.IsBusy; + + #endregion + + // cref: ArcGIS.Desktop.Framework.FrameworkApplication + #region Get the Application main window + System.Windows.Window window = FrameworkApplication.Current.MainWindow; + // center it + Rect rect = System.Windows.SystemParameters.WorkArea; + FrameworkApplication.Current.MainWindow.Left = rect.Left + (rect.Width - FrameworkApplication.Current.MainWindow.ActualWidth) / 2; + FrameworkApplication.Current.MainWindow.Top = rect.Top + (rect.Height - FrameworkApplication.Current.MainWindow.ActualHeight) / 2; + + #endregion + + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.Close + #region Close ArcGIS Pro + FrameworkApplication.Close(); + #endregion + + + #region Get ArcGIS Pro version + //"GetEntryAssembly" should be ArcGISPro.exe + string version = System.Reflection.Assembly.GetEntryAssembly() + .GetName().Version.ToString(); + #endregion + + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.PANES + // cref: ARCGIS.DESKTOP.FRAMEWORK.PANECOLLECTION.CLOSEPANE + #region Close a specific pane + + string _viewPaneID = "my pane"; //DAML ID of your pane + //You could have multiple instances (InstanceIDs) of your pane. + //So you can iterate through the Panes to get "your" panes only + IList myPaneInstanceIDs = new List(); + foreach (Pane pane in FrameworkApplication.Panes) + { + if (pane.ContentID == _viewPaneID) + { + myPaneInstanceIDs.Add(pane.InstanceID); //InstanceID of your pane, could be multiple, so build the collection } + } + foreach (var instanceID in myPaneInstanceIDs) //close each of "your" panes. + { + FrameworkApplication.Panes.ClosePane(instanceID); + } + #endregion + + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.PANES + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.PANE.ACTIVATE + #region Activate a pane + var mapPanes = ProApp.Panes.OfType(); + foreach (Pane pane in mapPanes) + { + if (pane.Caption == "MyMap") + { + pane.Activate(); + break; + } + } + #endregion + + } public void Foo() { + // cref: ArcGIS.Desktop.Framework.FrameworkApplication.GetAddInInfos + // cref: ArcGIS.Desktop.Framework.AddInInfo #region Get Information on the Currently Installed Add-ins var addin_infos = FrameworkApplication.GetAddInInfos(); StringBuilder sb = new StringBuilder(); - foreach(var info in addin_infos) + foreach (var info in addin_infos) { if (info == null) break;//no addins probed @@ -199,8 +220,10 @@ public void Foo() #endregion } - public void Dockpane1() + public void Dockpane1() { + // cref: ARCGIS.DESKTOP.FRAMEWORK.DOCKPANEMANAGER + // cref: ARCGIS.DESKTOP.FRAMEWORK.DOCKPANEMANAGER.FIND #region Find a dockpane // in order to find a dockpane you need to know it's DAML id var pane = FrameworkApplication.DockPaneManager.Find("esri_core_ProjectDockPane"); @@ -210,6 +233,15 @@ public void Dockpane1() public void Dockpane2() { + // cref: ARCGIS.DESKTOP.FRAMEWORK.DOCKPANEMANAGER + // cref: ARCGIS.DESKTOP.FRAMEWORK.DOCKPANEMANAGER.FIND + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANESTATE + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANE.ACTIVATE + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANE.DOCKSTATE + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANE.ACTIVATE() + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANE.ACTIVATE(BOOLEAN) + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANE.PIN + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANE.HIDE #region Dockpane properties and methods // in order to find a dockpane you need to know it's DAML id var pane = FrameworkApplication.DockPaneManager.Find("esri_core_ProjectDockPane"); @@ -234,6 +266,15 @@ public void Dockpane2() public async void Dockpane3() { + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.DOCKPANEMANAGER + // cref: ARCGIS.DESKTOP.FRAMEWORK.DOCKPANEMANAGER.FIND + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.DOCKPANE.OperationManager + // cref: ARCGIS.DESKTOP.FRAMEWORK.OPERATIONMANAGER.CANREDO + // cref: ARCGIS.DESKTOP.FRAMEWORK.OPERATIONMANAGER.CANUNDO + // cref: ARCGIS.DESKTOP.FRAMEWORK.OPERATIONMANAGER.UNDOASYNC + // cref: ARCGIS.DESKTOP.FRAMEWORK.OPERATIONMANAGER.REDOASYNC + // cref: ARCGIS.DESKTOP.FRAMEWORK.OPERATIONMANAGER.CLEARREDOCATEGORY + // cref: ARCGIS.DESKTOP.FRAMEWORK.OPERATIONMANAGER.CLEARUNDOCATEGORY #region Dockpane undo / redo // in order to find a dockpane you need to know it's DAML id @@ -260,9 +301,10 @@ public async void Dockpane3() public void Dockpane4() { + // cref: ARCGIS.DESKTOP.FRAMEWORK.DOCKPANEMANAGER.FIND #region Find a dockpane and obtain its ViewModel // in order to find a dockpane you need to know it's DAML id. - + // Here is a DAML example with a dockpane defined. Once you have found the dockpane you can cast it // to the dockpane viewModel which is defined by the className attribute. // @@ -273,38 +315,52 @@ public void Dockpane4() // Dockpane1ViewModel vm = FrameworkApplication.DockPaneManager.Find("MySample_Dockpane") as Dockpane1ViewModel; - #endregion - - #region Open the Backstage tab - //Opens the Backstage to the "About ArcGIS Pro" tab. - FrameworkApplication.OpenBackstage("esri_core_aboutTab"); - #endregion - #region Access the current theme - //Gets the application's theme - var theme = FrameworkApplication.ApplicationTheme; - //ApplicationTheme enumeration - if (FrameworkApplication.ApplicationTheme == ApplicationTheme.Dark) { - //Dark theme - } - - if (FrameworkApplication.ApplicationTheme == ApplicationTheme.HighContrast){ - //High Contrast - } - if (FrameworkApplication.ApplicationTheme == ApplicationTheme.Default) { - //Light/Default theme - } - - #endregion + #endregion - } + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.OPENBACKSTAGE + #region Open the Backstage tab + //Opens the Backstage to the "About ArcGIS Pro" tab. + FrameworkApplication.OpenBackstage("esri_core_aboutTab"); + #endregion + + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.APPLICATIONTHEME + #region Access the current theme + //Gets the application's theme + var theme = FrameworkApplication.ApplicationTheme; + //ApplicationTheme enumeration + if (FrameworkApplication.ApplicationTheme == ApplicationTheme.Dark) + { + //Dark theme + } + + if (FrameworkApplication.ApplicationTheme == ApplicationTheme.HighContrast) + { + //High Contrast + } + if (FrameworkApplication.ApplicationTheme == ApplicationTheme.Default) + { + //Light/Default theme + } - public void SnippetsAdvanced() + #endregion + + } + + public void SnippetsAdvanced() { + // cref: ARCGIS.DESKTOP.FRAMEWORK.Notification + // cref: ARCGIS.DESKTOP.FRAMEWORK.Dialogs.MessageBox.Show(Window,String,String,MessageBoxButton,MessageBoxImage,MessageBoxResult,String,String,String) + // cref: ARCGIS.DESKTOP.FRAMEWORK.Dialogs.MessageBox.Show(Boolean,String,Window,String,String,MessageBoxButton,MessageBoxImage,MessageBoxResult,String,String,String) #region Display a Pro MessageBox ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Some Message", "Some title", MessageBoxButton.YesNo, MessageBoxImage.Information, MessageBoxResult.Yes); #endregion + // cref: ARCGIS.DESKTOP.FRAMEWORK.NOTIFICATION + // cref: ARCGIS.DESKTOP.FRAMEWORK.NOTIFICATION.TITLE + // cref: ARCGIS.DESKTOP.FRAMEWORK.NOTIFICATION.MESSAGE + // cref: ARCGIS.DESKTOP.FRAMEWORK.NOTIFICATION.IMAGEURL + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.ADDNOTIFICATION #region Add a toast notification Notification notification = new Notification(); @@ -316,6 +372,9 @@ public void SnippetsAdvanced() #endregion } + // cref: ARCGIS.DESKTOP.FRAMEWORK.FRAMEWORKAPPLICATION.GETPLUGINWRAPPER + // cref: ARCGIS.DESKTOP.FRAMEWORK.IPLUGINWRAPPER.SmallImage + // cref: ARCGIS.DESKTOP.FRAMEWORK.IPLUGINWRAPPER.LargeImage #region Change a buttons caption or image private void ChangeCaptionImage() @@ -340,23 +399,29 @@ private ImageSource BuildImage(string imageName) private Uri PackUriForResource(string resourceName) { string asm = System.IO.Path.GetFileNameWithoutExtension( - System.Reflection.Assembly.GetExecutingAssembly().CodeBase); + System.Reflection.Assembly.GetExecutingAssembly().Location); return new Uri(string.Format("pack://application:,,,/{0};component/Images/{1}", asm, resourceName), UriKind.Absolute); } - #endregion + #endregion - private void GetButtonTooltipHeading() - { - #region Get a button's tooltip heading - //Pass in the daml id of your button. Or pass in any Pro button ID. - IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("button_id_from daml"); - var buttonTooltipHeading = wrapper.TooltipHeading; - #endregion - } + private void GetButtonTooltipHeading() + { + // cref: ARCGIS.DESKTOP.FRAMEWORK.IPLUGINWRAPPER.TooltipHeading + #region Get a button's tooltip heading + //Pass in the daml id of your button. Or pass in any Pro button ID. + IPlugInWrapper wrapper = FrameworkApplication.GetPlugInWrapper("button_id_from daml"); + var buttonTooltipHeading = wrapper.TooltipHeading; + #endregion + } - #region Subscribe to Active Tool Changed Event - private void SubscribeEvent() + // cref: ARCGIS.DESKTOP.FRAMEWORK.EVENTS.ACTIVETOOLCHANGEDEVENT + // cref: ARCGIS.DESKTOP.FRAMEWORK.EVENTS.ACTIVETOOLCHANGEDEVENT.SUBSCRIBE + // cref: ARCGIS.DESKTOP.FRAMEWORK.EVENTS.ACTIVETOOLCHANGEDEVENT.UNSUBSCRIBE + // cref: ARCGIS.DESKTOP.FRAMEWORK.EVENTS.TOOLEVENTARGS.PreviousID + // cref: ARCGIS.DESKTOP.FRAMEWORK.EVENTS.TOOLEVENTARGS.CurrentID + #region Subscribe to Active Tool Changed Event + private void SubscribeEvent() { ArcGIS.Desktop.Framework.Events.ActiveToolChangedEvent.Subscribe(OnActiveToolChanged); } @@ -371,6 +436,9 @@ private void OnActiveToolChanged(ArcGIS.Desktop.Framework.Events.ToolEventArgs a } #endregion + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.PROGRESSOR + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.QUEUEDTASK.RUN(FUNC{TASK},PROGRESSOR,TASKCREATIONOPTIONS) + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.QUEUEDTASK.RUN(ACTION,PROGRESSOR,TASKCREATIONOPTIONS) #region Progressor - Simple and non-cancelable public async Task Progressor_NonCancelable() @@ -384,97 +452,118 @@ public async Task Progressor_NonCancelable() #endregion + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.PROGRESSOR.VALUE + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.PROGRESSOR.STATUS + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.PROGRESSOR.MESSAGE + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.PROGRESSOR.MAX + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.CANCELABLEPROGRESSOR + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.QUEUEDTASK.RUN(ACTION,CANCELABLEPROGRESSOR,TASKCREATIONOPTIONS) + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.QUEUEDTASK.RUN(FUNC{TASK},CANCELABLEPROGRESSOR,TASKCREATIONOPTIONS) #region Progressor - Cancelable public async Task Progressor_Cancelable() { - ArcGIS.Desktop.Framework.Threading.Tasks.CancelableProgressorSource cps = + ArcGIS.Desktop.Framework.Threading.Tasks.CancelableProgressorSource cps = new ArcGIS.Desktop.Framework.Threading.Tasks.CancelableProgressorSource("Doing my thing - cancelable", "Canceled"); int numSecondsDelay = 5; //If you run this in the DEBUGGER you will NOT see the dialog //simulate doing some work which can be canceled - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - cps.Progressor.Max = (uint)numSecondsDelay; - //check every second - while (!cps.Progressor.CancellationToken.IsCancellationRequested) { - cps.Progressor.Value += 1; - cps.Progressor.Status = "Status " + cps.Progressor.Value; - cps.Progressor.Message = "Message " + cps.Progressor.Value; - - if (System.Diagnostics.Debugger.IsAttached) { - System.Diagnostics.Debug.WriteLine(string.Format("RunCancelableProgress Loop{0}", cps.Progressor.Value)); - } - //are we done? - if (cps.Progressor.Value == cps.Progressor.Max) break; - //block the CIM for a second - Task.Delay(1000).Wait(); + cps.Progressor.Max = (uint)numSecondsDelay; + //check every second + while (!cps.Progressor.CancellationToken.IsCancellationRequested) + { + cps.Progressor.Value += 1; + cps.Progressor.Status = "Status " + cps.Progressor.Value; + cps.Progressor.Message = "Message " + cps.Progressor.Value; + if (System.Diagnostics.Debugger.IsAttached) + { + System.Diagnostics.Debug.WriteLine(string.Format("RunCancelableProgress Loop{0}", cps.Progressor.Value)); } - System.Diagnostics.Debug.WriteLine(string.Format("RunCancelableProgress: Canceled {0}", - cps.Progressor.CancellationToken.IsCancellationRequested)); + //are we done? + if (cps.Progressor.Value == cps.Progressor.Max) break; + //block the CIM for a second + Task.Delay(1000).Wait(); + + } + System.Diagnostics.Debug.WriteLine(string.Format("RunCancelableProgress: Canceled {0}", + cps.Progressor.CancellationToken.IsCancellationRequested)); }, cps.Progressor); } #endregion } - #region customize the disabedText property of a button or tool - //Set the tool's loadOnClick attribute to "false" in the config.daml. - //This will allow the tool to be created when Pro launches, so that the disabledText property can display customized text at startup. - //Remove the "condition" attribute from the tool. Use the OnUpdate method(below) to set the enable\disable state of the tool. - //Add the OnUpdate method to the tool. - //Note: since OnUpdate is called very frequently, you should avoid lengthy operations in this method - //as this would reduce the responsiveness of the application user interface. - internal class SnippetButton : ArcGIS.Desktop.Framework.Contracts.Button + + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.PLUGIN + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.PLUGIN.Enabled + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.PLUGIN.DisabledTooltip + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.PLUGIN.ONUPDATE + #region customize the disabedText property of a button or tool + //Set the tool's loadOnClick attribute to "false" in the config.daml. + //This will allow the tool to be created when Pro launches, so that the disabledText property can display customized text at startup. + //Remove the "condition" attribute from the tool. Use the OnUpdate method(below) to set the enable\disable state of the tool. + //Add the OnUpdate method to the tool. + //Note: since OnUpdate is called very frequently, you should avoid lengthy operations in this method + //as this would reduce the responsiveness of the application user interface. + internal class SnippetButton : ArcGIS.Desktop.Framework.Contracts.Button + { + protected override void OnUpdate() { - protected override void OnUpdate() - { - bool enableSate = true; //TODO: Code your enabled state - bool criteria = true; //TODO: Evaluate criteria for disabledText - - if (enableSate) - { - this.Enabled = true; //tool is enabled - } - else - { - this.Enabled = false; //tool is disabled - //customize your disabledText here - if (criteria) - this.DisabledTooltip = "Missing criteria 1"; - } - } + bool enableSate = true; //TODO: Code your enabled state + bool criteria = true; //TODO: Evaluate criteria for disabledText + + if (enableSate) + { + this.Enabled = true; //tool is enabled + } + else + { + this.Enabled = false; //tool is disabled + //customize your disabledText here + if (criteria) + this.DisabledTooltip = "Missing criteria 1"; + } } - #endregion + } + #endregion - internal class ProSnippets1 + internal class ProSnippets1 { - #region Get an Image Resource from the Current Assembly - - public static void ExampleUsage() { - //Image 'Dino32.png' is added as Build Action: Resource, 'Do not copy' - var img = ForImage("Dino32.png"); - //Use the image... - } - - public static BitmapImage ForImage(string imageName) { - return new BitmapImage(PackUriForResource(imageName)); - } - public static Uri PackUriForResource(string resourceName, string folderName = "Images") { - string asm = System.IO.Path.GetFileNameWithoutExtension( - System.Reflection.Assembly.GetExecutingAssembly().CodeBase); - string uriString = folderName.Length > 0 - ? string.Format("pack://application:,,,/{0};component/{1}/{2}", asm, folderName, resourceName) - : string.Format("pack://application:,,,/{0};component/{1}", asm, resourceName); - return new Uri(uriString, UriKind.Absolute); - } - - #endregion + #region Get an Image Resource from the Current Assembly + + public static void ExampleUsage() + { + //Image 'Dino32.png' is added as Build Action: Resource, 'Do not copy' + var img = ForImage("Dino32.png"); + //Use the image... + } + + public static BitmapImage ForImage(string imageName) + { + return new BitmapImage(PackUriForResource(imageName)); + } + public static Uri PackUriForResource(string resourceName, string folderName = "Images") + { + string asm = System.IO.Path.GetFileNameWithoutExtension( + System.Reflection.Assembly.GetExecutingAssembly().Location); + string uriString = folderName.Length > 0 + ? string.Format("pack://application:,,,/{0};component/{1}/{2}", asm, folderName, resourceName) + : string.Format("pack://application:,,,/{0};component/{1}", asm, resourceName); + return new Uri(uriString, UriKind.Absolute); + } + + #endregion } + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.MODULE.CANUNLOAD + // cref: ARCGIS.DESKTOP.FRAMEWORK.EVENTS.APPLICATIONCLOSINGEVENT + // cref: ARCGIS.DESKTOP.FRAMEWORK.EVENTS.APPLICATIONCLOSINGEVENT.SUBSCRIBE + // cref: ARCGIS.DESKTOP.FRAMEWORK.EVENTS.APPLICATIONCLOSINGEVENT.UNSUBSCRIBE #region Prevent ArcGIS Pro from Closing // There are two ways to prevent ArcGIS Pro from closing @@ -507,63 +596,74 @@ private Task OnApplicationClosing(System.ComponentModel.CancelEventArgs args) args.Cancel = true; return Task.FromResult(0); } - #region How to determine when a project is opened - protected override bool Initialize() //Called when the Module is initialized. - { - ProjectOpenedEvent.Subscribe(OnProjectOpened); //subscribe to Project opened event - return base.Initialize(); - } - private void OnProjectOpened(ProjectEventArgs obj) //Project Opened event handler - { - MessageBox.Show($"{Project.Current} has opened"); //show your message box - } + // cref: ARCGIS.DESKTOP.CORE.EVENTS.PROJECTOPENEDEVENT + // cref: ARCGIS.DESKTOP.CORE.EVENTS.PROJECTOPENEDEVENT.SUBSCRIBE + // cref: ARCGIS.DESKTOP.CORE.EVENTS.PROJECTOPENEDEVENT.UNSUBSCRIBE + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.MODULE.INITIALIZE + // cref: ARCGIS.DESKTOP.FRAMEWORK.CONTRACTS.MODULE.UNINITIALIZE + #region How to determine when a project is opened + protected override bool Initialize() //Called when the Module is initialized. + { + ProjectOpenedEvent.Subscribe(OnProjectOpened); //subscribe to Project opened event + return base.Initialize(); + } - protected override void Uninitialize() //unsubscribe to the project opened event - { - ProjectOpenedEvent.Unsubscribe(OnProjectOpened); //unsubscribe - return; - } - #endregion + private void OnProjectOpened(ProjectEventArgs obj) //Project Opened event handler + { + MessageBox.Show($"{Project.Current} has opened"); //show your message box } + + protected override void Uninitialize() //unsubscribe to the project opened event + { + ProjectOpenedEvent.Unsubscribe(OnProjectOpened); //unsubscribe + return; + } + #endregion } + } #endregion - internal class ProSnippetMapTool : MapTool - { + internal class ProSnippetMapTool : MapTool + { - #region How to position an embeddable control inside a MapView + // cref: ARCGIS.DESKTOP.MAPPING.MAPTOOL.OVERLAYCONTROLID + // cref: ARCGIS.DESKTOP.MAPPING.MAPTOOL.ONTOOLMOUSEDOWN + // cref: ARCGIS.DESKTOP.MAPPING.MAPTOOL.HANDLEMOUSEDOWNASYNC + // cref: ArcGIS.Desktop.Mapping.MapTool.OverlayControlPositionRatio + #region How to position an embeddable control inside a MapView - public ProSnippetMapTool() - { - //Set the MapTool base class' OverlayControlID to the DAML id of your embeddable control in the constructor - this.OverlayControlID = "ProAppModule1_EmbeddableControl1"; - } + public ProSnippetMapTool() + { + //Set the MapTool base class' OverlayControlID to the DAML id of your embeddable control in the constructor + this.OverlayControlID = "ProAppModule1_EmbeddableControl1"; + } - protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e) - { - if (e.ChangedButton == System.Windows.Input.MouseButton.Left) - e.Handled = true; - } + protected override void OnToolMouseDown(MapViewMouseButtonEventArgs e) + { + if (e.ChangedButton == System.Windows.Input.MouseButton.Left) + e.Handled = true; + } - protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e) - { - return QueuedTask.Run(() => - { - //assign the screen coordinate clicked point to the MapTool base class' OverlayControlLocation property. - this.OverlayControlPositionRatio = e.ClientPoint; + protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e) + { + return QueuedTask.Run(() => + { + //assign the screen coordinate clicked point to the MapTool base class' OverlayControlLocation property. + this.OverlayControlPositionRatio = e.ClientPoint; - }); - } + }); + } - #endregion + #endregion - } + } } internal class Module1 : Module { + // cref: ArcGIS.Desktop.Core.CoreModule.GetSuggestedCMDIDs #region Suggested command options in CommandSearch when a tab is activated. //In the module class.. public override string[] GetSuggestedCMDIDs(string activeTabID) diff --git a/Examples/GeoProcessing.csproj b/Examples/GeoProcessing.csproj deleted file mode 100644 index 78cb149..0000000 --- a/Examples/GeoProcessing.csproj +++ /dev/null @@ -1,198 +0,0 @@ - - - - - Debug - AnyCPU - {9DC590DF-0986-0C16-D2C0-55933E4051F2} - Library - Properties - GeoProcessing - GeoProcessing - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\GeoProcessing\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\GeoProcessing\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - - \ No newline at end of file diff --git a/Examples/Geodatabase/Feature/FeatureStore.cs b/Examples/Geodatabase/Feature/FeatureStore.cs index 74c5e8c..831d7f5 100644 --- a/Examples/Geodatabase/Feature/FeatureStore.cs +++ b/Examples/Geodatabase/Feature/FeatureStore.cs @@ -140,7 +140,7 @@ private static async Task EnterpriseGeodabaseWorkFlow() new Coordinate2D(1021405, 1875397) }; - feature.SetShape(new PolygonBuilder(newCoordinates).ToGeometry()); + feature.SetShape(new PolygonBuilderEx(newCoordinates).ToGeometry()); } feature.Store(); @@ -184,7 +184,7 @@ private static async Task FileGeodatabaseWorkFlow() // Note that to update the shape, you will need to create a new Shape object. - feature.SetShape(new MapPointBuilder(mapPoint.X + 1, mapPoint.Y + 1, mapPoint.SpatialReference).ToGeometry()); + feature.SetShape(new MapPointBuilderEx(mapPoint.X + 1, mapPoint.Y + 1, mapPoint.SpatialReference).ToGeometry()); feature.Store(); // Has to be called after the store too diff --git a/Examples/Geodatabase/FeatureClass/FeatureClassCreateRow.cs b/Examples/Geodatabase/FeatureClass/FeatureClassCreateRow.cs index f65eb08..f746bc4 100644 --- a/Examples/Geodatabase/FeatureClass/FeatureClassCreateRow.cs +++ b/Examples/Geodatabase/FeatureClass/FeatureClassCreateRow.cs @@ -134,7 +134,7 @@ private static async Task EnterpriseGeodabaseWorkFlow() new Coordinate2D(1021405, 1875397) }; - rowBuffer[facilitySiteDefinition.GetShapeField()] = new PolygonBuilder(newCoordinates).ToGeometry(); + rowBuffer[facilitySiteDefinition.GetShapeField()] = new PolygonBuilderEx(newCoordinates).ToGeometry(); feature = enterpriseFeatureClass.CreateRow(rowBuffer); @@ -146,7 +146,7 @@ private static async Task EnterpriseGeodabaseWorkFlow() // Do some other processing with the newly-created feature. } - catch (GeodatabaseException exObj) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseException exObj) { Console.WriteLine(exObj); } @@ -199,7 +199,7 @@ private static async Task FileGeodatabaseWorkFlow() rowBuffer["PHONE"] = "815-740-4782"; rowBuffer["EMAIL"] = "elections@willcounty.gov"; - rowBuffer[featureClassDefinition.GetShapeField()] = new MapPointBuilder(1028367, 1809789).ToGeometry(); + rowBuffer[featureClassDefinition.GetShapeField()] = new MapPointBuilderEx(1028367, 1809789).ToGeometry(); feature = featureClass.CreateRow(rowBuffer); @@ -219,7 +219,7 @@ private static async Task FileGeodatabaseWorkFlow() // If the table is non-versioned this is a no-op. If it is versioned, we need the Save to be done for the edits to be persisted. bool saveResult = await Project.Current.SaveEditsAsync(); } - catch (GeodatabaseException exObj) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseException exObj) { Console.WriteLine(exObj); throw; diff --git a/Examples/Geodatabase/FeatureClass/FeatureClassSearch.cs b/Examples/Geodatabase/FeatureClass/FeatureClassSearch.cs index 5936e27..545a10b 100644 --- a/Examples/Geodatabase/FeatureClass/FeatureClassSearch.cs +++ b/Examples/Geodatabase/FeatureClass/FeatureClassSearch.cs @@ -122,7 +122,7 @@ public void MainMethodCode() Feature feature = (Feature)recyclingCursor.Current; if (Convert.ToDouble(feature[areaFieldIndex]) > 500) - Console.WriteLine(feature.GetShape().ToXML()); + Console.WriteLine(feature.GetShape().ToXml()); } } } @@ -152,7 +152,7 @@ public void MainMethodCode() SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { WhereClause = "DISTRCTNAME = 'Indian Prairie School District 204'", - FilterGeometry = new PolygonBuilder(new List + FilterGeometry = new PolygonBuilderEx(new List { new Coordinate2D(1021880, 1867396), new Coordinate2D(1028223, 1870705), diff --git a/Examples/Geodatabase/FeatureClass/FeatureClassSelect.cs b/Examples/Geodatabase/FeatureClass/FeatureClassSelect.cs index dddd609..2a5d0df 100644 --- a/Examples/Geodatabase/FeatureClass/FeatureClassSelect.cs +++ b/Examples/Geodatabase/FeatureClass/FeatureClassSelect.cs @@ -87,7 +87,7 @@ public void MainMethodCode() Selection selection = featureClass.Select(queryFilter, SelectionType.ObjectID, SelectionOption.Normal); // Number of records that match the QueryFilter criteria. - int numberOfMatchingRecords = selection.GetCount(); + long numberOfMatchingRecords = selection.GetCount(); // The objectIDs which match the QueryFilter criteria. IReadOnlyList readOnlyList = selection.GetObjectIDs(); @@ -125,7 +125,7 @@ public void MainMethodCode() SpatialQueryFilter spatialFilter = new SpatialQueryFilter { WhereClause = "FCODE = 'Park'", - FilterGeometry = new PolygonBuilder(newCoordinates).ToGeometry(), + FilterGeometry = new PolygonBuilderEx(newCoordinates).ToGeometry(), SpatialRelationship = SpatialRelationship.Crosses }; @@ -137,7 +137,7 @@ public void MainMethodCode() Selection onlyOneSelection = enterpriseFeatureClass.Select(spatialFilter, SelectionType.ObjectID, SelectionOption.OnlyOne); // This will always be one. - int singleRecordCount = onlyOneSelection.GetCount(); + long singleRecordCount = onlyOneSelection.GetCount(); // This will always have one record. IReadOnlyList listWithOneValue = onlyOneSelection.GetObjectIDs(); @@ -146,7 +146,7 @@ public void MainMethodCode() Selection emptySelection = enterpriseFeatureClass.Select(spatialFilter, SelectionType.ObjectID, SelectionOption.Empty); // This will always be zero. - int zeroCount = emptySelection.GetCount(); + long zeroCount = emptySelection.GetCount(); // This will always have zero record. IReadOnlyList emptyList = emptySelection.GetObjectIDs(); @@ -155,7 +155,7 @@ public void MainMethodCode() Selection allRecordSelection = enterpriseFeatureClass.Select(null, SelectionType.ObjectID, SelectionOption.Normal); // This will give the count of records in a table. - int numberOfRecordsInATable = allRecordSelection.GetCount(); + long numberOfRecordsInATable = allRecordSelection.GetCount(); } } } diff --git a/Examples/Geodatabase/FeatureClass/FeatureClassValidate.cs b/Examples/Geodatabase/FeatureClass/FeatureClassValidate.cs index e051d6a..acf19bf 100644 --- a/Examples/Geodatabase/FeatureClass/FeatureClassValidate.cs +++ b/Examples/Geodatabase/FeatureClass/FeatureClassValidate.cs @@ -107,9 +107,9 @@ public void MainMethodCode() SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { - FilterGeometry = new EnvelopeBuilder( - new MapPointBuilder(1052803, 1812751).ToGeometry(), - new MapPointBuilder(1034600, 1821320).ToGeometry()).ToGeometry(), + FilterGeometry = new EnvelopeBuilderEx( + new MapPointBuilderEx(1052803, 1812751).ToGeometry(), + new MapPointBuilderEx(1034600, 1821320).ToGeometry()).ToGeometry(), SpatialRelationship = SpatialRelationship.Within }; @@ -173,7 +173,7 @@ public void MainMethodCode() rowBuffer["FCODE"] = "Park"; // Note that this is an invalid subtype value. rowBuffer[facilitySiteDefinition.GetSubtypeField()] = 890; - rowBuffer[facilitySiteDefinition.GetShapeField()] = new PolygonBuilder(new List + rowBuffer[facilitySiteDefinition.GetShapeField()] = new PolygonBuilderEx(new List { new Coordinate2D(1021570, 1880583), new Coordinate2D(1028730, 1880994), @@ -185,7 +185,7 @@ public void MainMethodCode() invalidFeatureObjectID = feature.GetObjectID(); } - catch (GeodatabaseException exObj) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseException exObj) { Console.WriteLine(exObj); } diff --git a/Examples/Geodatabase/FeatureDataset/FeatureDatasetOpenDataset.cs b/Examples/Geodatabase/FeatureDataset/FeatureDatasetOpenDataset.cs index ecd6c27..27c1cea 100644 --- a/Examples/Geodatabase/FeatureDataset/FeatureDatasetOpenDataset.cs +++ b/Examples/Geodatabase/FeatureDataset/FeatureDatasetOpenDataset.cs @@ -153,7 +153,7 @@ public void MainMethodCode() Dataset badRelationshipClass = enterpriseFeatureDataset.OpenDataset("SomeGibberish"); Dataset badAttributedRelationshipClass = enterpriseFeatureDataset.OpenDataset("SomeGibberish"); } - catch (GeodatabaseCatalogDatasetException exception) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseCatalogDatasetException exception) { // Thrown for RelationshipClass and AttributedRelationshipClass. } @@ -163,7 +163,7 @@ public void MainMethodCode() // Trying to open non-existent FeatureClasses. Dataset badFeatureClass = enterpriseFeatureDataset.OpenDataset("SomeGibberish"); } - catch (GeodatabaseDatasetException exception) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseDatasetException exception) { // Thrown for FeatureClasses. } diff --git a/Examples/Geodatabase/FeatureService/FeatureServiceOpenRelationshipClassByLayerID.cs b/Examples/Geodatabase/FeatureService/FeatureServiceOpenRelationshipClassByLayerID.cs index 3640d28..03fe564 100644 --- a/Examples/Geodatabase/FeatureService/FeatureServiceOpenRelationshipClassByLayerID.cs +++ b/Examples/Geodatabase/FeatureService/FeatureServiceOpenRelationshipClassByLayerID.cs @@ -84,11 +84,13 @@ public void MainMethodCode() using (Geodatabase featureService = new Geodatabase(arcGISOnline)) { //These are the relationship clases where the origin layer ID is 0 and destination layer ID is 1 - IReadOnlyList relationshipClasses = featureService.OpenRelationshipClass("0", "1"); + //At 2.x - IReadOnlyList relationshipClasses = featureService.OpenRelationshipClass("0", "1"); + IReadOnlyList relationshipClasses = featureService.OpenRelationshipClasses("0", "1"); //These are the relationship clases where the origin layer ID is 1 and destination layer ID is 0 //Note that these will be different from the relationship classes above. - IReadOnlyList reverseRrelationshipClasses = featureService.OpenRelationshipClass("1", "0"); + //At 2.x - IReadOnlyList reverseRrelationshipClasses = featureService.OpenRelationshipClass("1", "0"); + IReadOnlyList reverseRrelationshipClasses = featureService.OpenRelationshipClasses("1", "0"); } } } diff --git a/Examples/Geodatabase/Geodatabase/GeodatabaseApplyEdits.cs b/Examples/Geodatabase/Geodatabase/GeodatabaseApplyEdits.cs index caccf4b..289216b 100644 --- a/Examples/Geodatabase/Geodatabase/GeodatabaseApplyEdits.cs +++ b/Examples/Geodatabase/Geodatabase/GeodatabaseApplyEdits.cs @@ -135,7 +135,7 @@ private void EditingWorkFlow() row = enterpriseTable.CreateRow(rowBuffer); } - catch (GeodatabaseException exObj) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseException exObj) { Console.WriteLine(exObj); } diff --git a/Examples/Geodatabase/Geodatabase/GeodatabaseGetDefinition.cs b/Examples/Geodatabase/Geodatabase/GeodatabaseGetDefinition.cs index ce05a5b..ca32e55 100644 --- a/Examples/Geodatabase/Geodatabase/GeodatabaseGetDefinition.cs +++ b/Examples/Geodatabase/Geodatabase/GeodatabaseGetDefinition.cs @@ -132,7 +132,7 @@ public void MainMethodCode() // Trying to GetDefinition of a non existent dataset. geodatabase.GetDefinition("SomeRandomString"); } - catch (GeodatabaseCatalogDatasetException catalogDatasetException) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseCatalogDatasetException catalogDatasetException) { // All of the above scenarios will result in GeodatabaseCatalogDatasetException with a message "Item Not Found". // Remember that when you get this exception, most likely the following are the reasons. diff --git a/Examples/Geodatabase/Geodatabase/GeodatabaseOpenFile.cs b/Examples/Geodatabase/Geodatabase/GeodatabaseOpenFile.cs index e3aabe8..ca26d2a 100644 --- a/Examples/Geodatabase/Geodatabase/GeodatabaseOpenFile.cs +++ b/Examples/Geodatabase/Geodatabase/GeodatabaseOpenFile.cs @@ -1,75 +1,75 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.IO; -using System.Threading.Tasks; -using ArcGIS.Core.Data; -using ArcGIS.Desktop.Framework.Threading.Tasks; - -namespace SDKExamples +/* + + Copyright 2018 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System; +using System.IO; +using System.Threading.Tasks; +using ArcGIS.Core.Data; +using ArcGIS.Desktop.Framework.Threading.Tasks; + +namespace SDKExamples { - /// - /// Illustrates how to open a file geodatabase. - /// - /// - /// - /// - /// While it is true classes that are derived from the super class - /// consumes native resources (e.g., or ), - /// you can rest assured that the garbage collector will properly dispose of the unmanaged resources during - /// finalization. However, there are certain workflows that require a deterministic finalization of the - /// . Consider the case of a file geodatabase that needs to be deleted - /// on the fly at a particular moment. Because of the indeterministic nature of garbage collection, we can't - /// count on the garbage collector to dispose of the Geodatabase object, thereby removing the lock(s) at the - /// moment we want. To ensure a deterministic finalization of important native resources such as a - /// or , you should declare - /// and instantiate said objects in a using statement. Alternatively, you can achieve the same result by - /// putting the object inside a try block and then calling Dispose() in a finally block. - /// - /// - /// In general, you should always call Dispose() on the following types of objects: - /// - /// - /// - Those that are derived from (e.g., ). - /// - /// - /// - Those that are derived from (e.g., ). - /// - /// - /// - and . - /// - /// - /// - and . - /// - /// - /// - . - /// - /// - /// - and . - /// - /// + /// + /// Illustrates how to open a file geodatabase. + /// + /// + /// + /// + /// While it is true classes that are derived from the super class + /// consumes native resources (e.g., or ), + /// you can rest assured that the garbage collector will properly dispose of the unmanaged resources during + /// finalization. However, there are certain workflows that require a deterministic finalization of the + /// . Consider the case of a file geodatabase that needs to be deleted + /// on the fly at a particular moment. Because of the indeterministic nature of garbage collection, we can't + /// count on the garbage collector to dispose of the Geodatabase object, thereby removing the lock(s) at the + /// moment we want. To ensure a deterministic finalization of important native resources such as a + /// or , you should declare + /// and instantiate said objects in a using statement. Alternatively, you can achieve the same result by + /// putting the object inside a try block and then calling Dispose() in a finally block. + /// + /// + /// In general, you should always call Dispose() on the following types of objects: + /// + /// + /// - Those that are derived from (e.g., ). + /// + /// + /// - Those that are derived from (e.g., ). + /// + /// + /// - and . + /// + /// + /// - and . + /// + /// + /// - . + /// + /// + /// - and . + /// + /// public class GeodatabaseOpenFile { - /// - /// In order to illustrate that Geodatabase calls have to be made on the MCT - /// - /// + /// + /// In order to illustrate that Geodatabase calls have to be made on the MCT + /// + /// public async Task GeodatabaseOpenFileAsync() { await QueuedTask.Run(() => MainMethodCode()); @@ -78,23 +78,34 @@ public async Task GeodatabaseOpenFileAsync() public void MainMethodCode() { // Opens a file geodatabase. This will open the geodatabase if the folder exists and contains a valid geodatabase. - - using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb")))) + + using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-File-Geodatabase\YourName.gdb")))) { // Use the geodatabase. } - // Each of the following would fail with GeodatabaseNotFoundOrOpenedException. + // Opens a mobile geodatbase. This will open the geodatabase if the folder exists and contains a valid geodatabase. + MobileGeodatabaseConnectionPath mobileGeodatabaseConnectionPath = new MobileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-Mobile-Geodatabase\YourName.geodatabase")); + using (Geodatabase geodatabase = new Geodatabase(mobileGeodatabaseConnectionPath)) + { + // use the geodatabase + } + + // Each of the following would fail with GeodatabaseNotFoundOrOpenedException. try { - Geodatabase geodatabase1 = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"Gibberish.gdb"))); - Geodatabase geodatabase2 = new Geodatabase((FileGeodatabaseConnectionPath)null); + Geodatabase fileGeodatabase1 = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"BadPath.gdb"))); + Geodatabase fileGeodatabase2 = new Geodatabase((FileGeodatabaseConnectionPath)null); + + Geodatabase mobileGeodatabase1 = new Geodatabase( new MobileGeodatabaseConnectionPath(new Uri(@"BadPath.geodatabase"))); + Geodatabase mobileGeodatabase2 = new Geodatabase((MobileGeodatabaseConnectionPath)null); } - catch (GeodatabaseNotFoundOrOpenedException exception) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseNotFoundOrOpenedException exception) { // Handle Exception. } + } - } + } } \ No newline at end of file diff --git a/Examples/Geodatabase/GeodatabaseSDK.csproj b/Examples/Geodatabase/GeodatabaseSDK.csproj new file mode 100644 index 0000000..98b623c --- /dev/null +++ b/Examples/Geodatabase/GeodatabaseSDK.csproj @@ -0,0 +1,80 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/Geodatabase/ProSnippets.cs b/Examples/Geodatabase/ProSnippets.cs index a9cffcc..27066da 100644 --- a/Examples/Geodatabase/ProSnippets.cs +++ b/Examples/Geodatabase/ProSnippets.cs @@ -35,7 +35,7 @@ limitations under the License. using ArcGIS.Core.Data.DDL; using ArcGIS.Core.Data.Mapping; using FieldDescription = ArcGIS.Core.Data.DDL.FieldDescription; - +using ArcGIS.Core.Data.Exceptions; namespace GeodatabaseSDK.GeodatabaseSDK.Snippets { @@ -45,21 +45,26 @@ class Snippets #region ProSnippet Group: Geodatabases and Datastores #endregion + // cref: ARCGIS.CORE.DATA.FILEGEODATABASECONNECTIONPATH.#CTOR + // cref: ARCGIS.CORE.DATA.GEODATABASE.#CTOR(ARCGIS.CORE.DATA.FILEGEODATABASECONNECTIONPATH) #region Opening a File Geodatabase given the path - public async Task OpenFileGDB() { - try { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + try + { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { // Opens a file geodatabase. This will open the geodatabase if the folder exists and contains a valid geodatabase. using ( Geodatabase geodatabase = - new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb")))) { + new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb")))) + { // Use the geodatabase. } }); } - catch (GeodatabaseNotFoundOrOpenedException exception) { + catch (GeodatabaseNotFoundOrOpenedException exception) + { // Handle Exception. } @@ -67,13 +72,24 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { #endregion Opening a File Geodatabase given the path + // cref: ARCGIS.CORE.DATA.DATABASE.#CTOR(ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES) + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.#CTOR(ARCGIS.CORE.DATA.ENTERPRISEDATABASETYPE) + // cref: ARCGIS.CORE.DATA.GEODATABASE.#CTOR(ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES) + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.AuthenticationMode + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.Instance + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.Database + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.User + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.Password + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.Version + // cref: ARCGIS.CORE.DATA.AuthenticationMode #region Opening an Enterprise Geodatabase using connection properties - public async Task OpenEnterpriseGeodatabase() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { // Opening a Non-Versioned SQL Server instance. - DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { + DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) + { AuthenticationMode = AuthenticationMode.DBMS, // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance. @@ -88,7 +104,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { Version = "dbo.DEFAULT" }; - using (Geodatabase geodatabase = new Geodatabase(connectionProperties)) { + using (Geodatabase geodatabase = new Geodatabase(connectionProperties)) + { // Use the geodatabase } }); @@ -96,28 +113,36 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { #endregion Opening an Enterprise Geodatabase using connection properties + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONFILE.#CTOR + // cref: ARCGIS.CORE.DATA.GEODATABASE.#CTOR(ARCGIS.CORE.DATA.DATABASECONNECTIONFILE) #region Opening an Enterprise Geodatabase using sde file path - public async Task OpenEnterpriseGeodatabaseUsingSDEFilePath() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) + { // Use the geodatabase. } }); } - #endregion Opening an Enterprise Geodatabase using sde file path + // cref: ARCGIS.DESKTOP.CORE.ITEM.GETITEMS + // cref: ARCGIS.DESKTOP.CATALOG.GDBPROJECTITEM + // cref: ARCGIS.DESKTOP.CATALOG.GDBPROJECTITEM.GetDatastore + // cref: ARCGIS.CORE.DATA.UnknownDatastore #region Obtaining Geodatabase from Project Item - public async Task ObtainingGeodatabaseFromProjectItem() { IEnumerable gdbProjectItems = Project.Current.GetItems(); - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - foreach (GDBProjectItem gdbProjectItem in gdbProjectItems) { - using (Datastore datastore = gdbProjectItem.GetDatastore()) { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + foreach (GDBProjectItem gdbProjectItem in gdbProjectItems) + { + using (Datastore datastore = gdbProjectItem.GetDatastore()) + { //Unsupported datastores (non File GDB and non Enterprise GDB) will be of type UnknownDatastore if (datastore is UnknownDatastore) continue; @@ -128,9 +153,9 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Obtaining Geodatabase from Project Item + // cref: ArcGIS.Core.Data.DatabaseClient.GetDatabaseConnectionProperties public void GettingConnectionProperties() { #region Getting Database Connection Properties from a Connection File @@ -143,16 +168,21 @@ public void GettingConnectionProperties() #endregion } + // cref: ARCGIS.DESKTOP.MAPPING.MAP.LAYERS + // cref: ARCGIS.DESKTOP.MAPPING.BasicFeatureLayer.GetTable + // cref: ARCGIS.CORE.DATA.DATASET.GETDATASTORE #region Obtaining Geodatabase from FeatureLayer - public async Task ObtainingGeodatabaseFromFeatureLayer() { IEnumerable layers = MapView.Active.Map.Layers.Where(layer => layer is FeatureLayer); - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - foreach (FeatureLayer featureLayer in layers) { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + foreach (FeatureLayer featureLayer in layers) + { using (Table table = featureLayer.GetTable()) - using (Datastore datastore = table.GetDatastore()) { + using (Datastore datastore = table.GetDatastore()) + { if (datastore is UnknownDatastore) continue; @@ -161,11 +191,10 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Obtaining Geodatabase from FeatureLayer + // cref: ARCGIS.CORE.DATA.DATABASECLIENT.EXECUTESTATEMENT #region Executing SQL Statements - // Executes raw SQL on the underlying database management system. // Any SQL is permitted (DDL or DML), but no results can be returned public void ExecuteSQLOnGeodatabase(Geodatabase geodatabase, string statement) @@ -175,17 +204,22 @@ public void ExecuteSQLOnGeodatabase(Geodatabase geodatabase, string statement) DatabaseClient.ExecuteStatement(geodatabase, statement); }); } - #endregion #region ProSnippet Group: Definitions #endregion + // cref: ARCGIS.CORE.DATA.TABLEDEFINITION + // cref: ARCGIS.CORE.DATA.FEATURECLASSDEFINITION + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASSDEFINITION + // cref: ARCGIS.CORE.DATA.FEATUREDATASETDEFINITION + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETDEFINITION + // cref: ARCGIS.CORE.DATA.DatabaseConnectionFile._Ctor #region Obtaining Definition from Geodatabase - public async Task ObtainingDefinitionFromGeodatabase() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) { // Remember that for Enterprise databases you have to qualify your dataset names with the DatabaseName and UserName. @@ -202,47 +236,71 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Obtaining Definition from Geodatabase + // cref: ARCGIS.CORE.DATA.TABLEDEFINITION + // cref: ARCGIS.CORE.DATA.FEATURECLASSDEFINITION + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASSDEFINITION + // cref: ARCGIS.CORE.DATA.FEATUREDATASETDEFINITION + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETDEFINITIONS + // cref: ARCGIS.CORE.DATA.FEATURECLASSDEFINITION.HasGlobalID + // cref: ARCGIS.CORE.DATA.DEFINITION.GETNAME #region Obtaining List of Defintions from Geodatabase - public async Task ObtainingDefinitionsFromGeodatabase() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + using (Geodatabase geodatabase = new Geodatabase( + new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) { - IReadOnlyList enterpriseDefinitions = geodatabase.GetDefinitions(); - IEnumerable featureClassesHavingGlobalID = enterpriseDefinitions.Where(definition => definition.HasGlobalID()); + var enterpriseDefinitions = + geodatabase.GetDefinitions(); + IEnumerable featureClassesHavingGlobalID = + enterpriseDefinitions.Where(definition => definition.HasGlobalID()); - IReadOnlyList featureDatasetDefinitions = geodatabase.GetDefinitions(); - bool electionRelatedFeatureDatasets = featureDatasetDefinitions.Any(definition => definition.GetName().Contains("Election")); + var featureDatasetDefinitions = + geodatabase.GetDefinitions(); + bool electionRelatedFeatureDatasets = + featureDatasetDefinitions.Any( + definition => definition.GetName().Contains("Election")); - IReadOnlyList attributedRelationshipClassDefinitions = geodatabase.GetDefinitions(); + var attributedRelationshipClassDefinitions = + geodatabase.GetDefinitions(); - IReadOnlyList relationshipClassDefinitions = geodatabase.GetDefinitions(); + var relationshipClassDefinitions = + geodatabase.GetDefinitions(); } }); } - #endregion Obtaining List of Defintions from Geodatabase + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASSDEFINITION + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETRELATEDDEFINITIONS + // cref: ARCGIS.CORE.DATA.FEATURECLASSDEFINITION + // cref: ARCGIS.CORE.DATA.DefinitionRelationshipType #region Obtaining Related Definitions from Geodatabase public async Task ObtainingRelatedDefinitionsFromGeodatabase() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) { // Remember the qualification of DatabaseName. for the RelationshipClass. - RelationshipClassDefinition enterpriseDefinition = geodatabase.GetDefinition("LocalGovernment.GDB.AddressPointHasSiteAddresses"); - IReadOnlyList enterpriseDefinitions = geodatabase.GetRelatedDefinitions(enterpriseDefinition, DefinitionRelationshipType.DatasetsRelatedThrough); - FeatureClassDefinition enterpriseAddressPointDefinition = enterpriseDefinitions.First( + RelationshipClassDefinition enterpriseDefinition = + geodatabase.GetDefinition("LocalGovernment.GDB.AddressPointHasSiteAddresses"); + IReadOnlyList enterpriseDefinitions = + geodatabase.GetRelatedDefinitions(enterpriseDefinition, DefinitionRelationshipType.DatasetsRelatedThrough); + FeatureClassDefinition enterpriseAddressPointDefinition = + enterpriseDefinitions.First( defn => defn.GetName().Equals("LocalGovernment.GDB.AddressPoint")) as FeatureClassDefinition; - FeatureDatasetDefinition featureDatasetDefinition = geodatabase.GetDefinition("LocalGovernment.GDB.Address"); - IReadOnlyList datasetsInAddressDataset = geodatabase.GetRelatedDefinitions(featureDatasetDefinition, DefinitionRelationshipType.DatasetInFeatureDataset); - FeatureClassDefinition addressPointInAddressDataset = datasetsInAddressDataset.First( + FeatureDatasetDefinition featureDatasetDefinition = + geodatabase.GetDefinition("LocalGovernment.GDB.Address"); + IReadOnlyList datasetsInAddressDataset = + geodatabase.GetRelatedDefinitions(featureDatasetDefinition, DefinitionRelationshipType.DatasetInFeatureDataset); + FeatureClassDefinition addressPointInAddressDataset = + datasetsInAddressDataset.First( defn => defn.GetName().Equals("LocalGovernment.GDB.AddressPoint")) as FeatureClassDefinition; RelationshipClassDefinition addressPointHasSiteAddressInAddressDataset = datasetsInAddressDataset.First( @@ -250,11 +308,14 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Obtaining Related Definitions from Geodatabase + // cref: ARCGIS.CORE.DATA.TABLE.ISJOINEDTABLE + // cref: ARCGIS.CORE.DATA.JOIN.GETORIGINTABLE + // cref: ARCGIS.CORE.DATA.TABLE.GETJOIN + // cref: ARCGIS.CORE.DATA.TABLE.GetDefinition + // cref: ARCGIS.CORE.DATA.FeatureClass.GetDefinition #region Getting a Table Definition from a Layer - // GetDefinitionFromLayer - This code works even if the layer has a join to another table private TableDefinition GetDefinitionFromLayer(FeatureLayer featureLayer) { @@ -264,7 +325,6 @@ private TableDefinition GetDefinitionFromLayer(FeatureLayer featureLayer) // Determine if feature class is a join if (featureClass.IsJoinedTable()) { - // Get join from feature class Join join = featureClass.GetJoin(); @@ -284,39 +344,48 @@ private TableDefinition GetDefinitionFromLayer(FeatureLayer featureLayer) #region ProSnippet Group: Datasets #endregion - + // cref: ARCGIS.CORE.DATA.GEODATABASE.OPENDATASET #region Opening datasets from Geodatabase - public async Task OpeningDatasetsFromGeodatabase() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) { - using (Table table = geodatabase.OpenDataset
("LocalGovernment.GDB.EmployeeInfo")) { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) + { + using (Table table = + geodatabase.OpenDataset
("LocalGovernment.GDB.EmployeeInfo")) + { } // Open a featureClass (within a feature dataset or outside a feature dataset). - using (FeatureClass featureClass = geodatabase.OpenDataset("LocalGovernment.GDB.AddressPoint")) { + using (FeatureClass featureClass = + geodatabase.OpenDataset("LocalGovernment.GDB.AddressPoint")) + { } // You can open a FeatureClass as a Table which will give you a Table Reference. - using (Table featureClassAsTable = geodatabase.OpenDataset
("LocalGovernment.GDB.AddressPoint")) { + using (Table featureClassAsTable = geodatabase.OpenDataset
("LocalGovernment.GDB.AddressPoint")) + { // But it is really a FeatureClass object. FeatureClass featureClassOpenedAsTable = featureClassAsTable as FeatureClass; } // Open a FeatureDataset. - using (FeatureDataset featureDataset = geodatabase.OpenDataset("LocalGovernment.GDB.Address")) { + using (FeatureDataset featureDataset = geodatabase.OpenDataset("LocalGovernment.GDB.Address")) + { } // Open a RelationsipClass. Just as you can open a FeatureClass as a Table, you can also open an AttributedRelationshipClass as a RelationshipClass. - using (RelationshipClass relationshipClass = geodatabase.OpenDataset("LocalGovernment.GDB.AddressPointHasSiteAddresses")) { + using (RelationshipClass relationshipClass = geodatabase.OpenDataset("LocalGovernment.GDB.AddressPointHasSiteAddresses")) + { } } }); } - #endregion Opening datasets from Geodatabase + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETDEFINITION + // cref: ArcGIS.Core.CoreObjectsBase.Dispose #region Checking for the existence of a Table // Must be called within QueuedTask.Run9) public bool TableExists(Geodatabase geodatabase, string tableName) @@ -335,6 +404,8 @@ public bool TableExists(Geodatabase geodatabase, string tableName) } #endregion + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETDEFINITION + // cref: ArcGIS.Core.CoreObjectsBase.Dispose #region Checking for the existence of a Feature Class // Must be called within QueuedTask.Run() public bool FeatureClassExists(Geodatabase geodatabase, string featureClassName) @@ -353,7 +424,8 @@ public bool FeatureClassExists(Geodatabase geodatabase, string featureClassName) } #endregion - // cref: Opening RelationshipClass between two Tables;ArcGIS.Core.Data.Geodatabase.OpenRelationshipClass(System.String,System.String) + // cref: ArcGIS.Core.Data.Geodatabase.OpenRelationshipClasses(ArcGIS.Core.Data.Table,ArcGIS.Core.Data.Table) + // cref: ArcGIS.Core.Data.Geodatabase.OpenRelationshipClasses(System.String,System.String) #region Opening RelationshipClass between two Tables // Must be called within QueuedTask.Run(). @@ -361,10 +433,14 @@ public bool FeatureClassExists(Geodatabase geodatabase, string featureClassName) // When used with feature services, this routine takes layer IDs, or the names of the tables as they are exposed through the service (e.g., "L0States") public IReadOnlyList OpenRelationshipClassFeatureServices(Geodatabase geodatabase, string originClass, string destinationClass) { - return geodatabase.OpenRelationshipClass(originClass, destinationClass); + return geodatabase.OpenRelationshipClasses(originClass, destinationClass); } #endregion Opening RelationshipClass between two Tables + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETRELATEDDEFINITIONS + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETDEFINITIONS + // cref: ARCGIS.CORE.DATA.RelationshipClassDefinition + // cref: ARCGIS.CORE.DATA.DefinitionRelationshipType #region Obtaining related Feature Classes from a Relationship Class public async Task GetFeatureClassesInRelationshipClassAsync() { @@ -372,14 +448,19 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb")))) { - IReadOnlyList relationshipClassDefinitions = geodatabase.GetDefinitions(); - foreach (var relationshipClassDefintion in relationshipClassDefinitions) + IReadOnlyList relationshipClassDefinitions = + geodatabase.GetDefinitions(); + + foreach (var relationshipClassDefinition in relationshipClassDefinitions) { - IReadOnlyList definitions = geodatabase.GetRelatedDefinitions(relationshipClassDefintion, + IReadOnlyList definitions = + geodatabase.GetRelatedDefinitions(relationshipClassDefinition, DefinitionRelationshipType.DatasetsRelatedThrough); + foreach (var definition in definitions) { - MessageBox.Show($"Feature class in the RelationshipClass is:{definition.GetName()}"); + System.Diagnostics.Debug.WriteLine( + $"Feature class in the RelationshipClass is:{definition.GetName()}"); } } } @@ -387,11 +468,15 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => } #endregion + // cref: ArcGIS.Core.Data.FileSystemConnectionPath.#ctor(System.Uri, ArcGIS.Core.Data.FileSystemDatastoreType) + // cref: ArcGIS.Core.Data.FileSystemDatastoreType + // cref: ARCGIS.CORE.DATA.FILESYSTEMDATASTORE.OPENDATASET + // cref: ARCGIS.CORE.DATA.FILESYSTEMDATASTORE.#CTOR(ARCGIS.CORE.DATA.FILESYSTEMCONNECTIONPATH) #region Opening a FeatureClass from a ShapeFile Datastore - public async Task OpenShapefileFeatureClass() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { var fileConnection = new FileSystemConnectionPath(new Uri("path\\to\\folder\\containing\\shapefiles"), FileSystemDatastoreType.Shapefile); using (FileSystemDatastore shapefile = new FileSystemDatastore(fileConnection)) { @@ -402,21 +487,24 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Opening a FeatureClass from a ShapeFile Datastore + // cref: ArcGIS.Core.Data.FileSystemConnectionPath.#ctor(System.Uri, ArcGIS.Core.Data.FileSystemDatastoreType) + // cref: ArcGIS.Core.Data.FileSystemDatastoreType + // cref: ARCGIS.CORE.DATA.FILESYSTEMDATASTORE.OPENDATASET + // cref: ARCGIS.CORE.DATA.FILESYSTEMDATASTORE.#CTOR(ARCGIS.CORE.DATA.FILESYSTEMCONNECTIONPATH) #region Opening a CAD Datastore - public async Task OpenCADFeatureClass() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { var fileConnection = new FileSystemConnectionPath(new Uri("path\\to\\folder\\containing\\CAD"), FileSystemDatastoreType.Cad); using (FileSystemDatastore cadDatastore = new FileSystemDatastore(fileConnection)) { // note - extension is required var cadDataset = cadDatastore.OpenDataset("hatchplayboundaries.dwg"); // take note of the pattern for referencing a feature class. - var cadfeatureClass = cadDatastore.OpenDataset("hatchplayboundaries.dwg:Polyline"); + var cadfeatureClass = cadDatastore.OpenDataset("hatchplayboundaries.dwg:Polyline"); int numRows = 0; using (var cursor = cadfeatureClass.Search()) @@ -427,21 +515,27 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Opening a CAD Datastore #region ProSnippet Group: Queries #endregion - + // cref: ARCGIS.CORE.DATA.TABLE.SEARCH + // cref: ARCGIS.CORE.DATA.QUERYFILTER.#CTOR + // cref: ARCGIS.CORE.DATA.QUERYFILTER.WhereClause + // cref: ARCGIS.CORE.DATA.QUERYFILTER.SubFields + // cref: ARCGIS.CORE.DATA.QUERYFILTER.PostfixClause + // cref: ARCGIS.CORE.DATA.RowCursor + // cref: ARCGIS.CORE.DATA.RowCursor.MoveNext + // cref: ARCGIS.CORE.DATA.RowCursor.Current #region Searching a Table using QueryFilter - public async Task SearchingATable() { try { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table table = geodatabase.OpenDataset
("EmployeeInfo")) { @@ -477,46 +571,45 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { // logger.Error(exception.Message); } } - #endregion public async Task SearchingATableWithNonLatinCharacters() { - - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + // cref: ARCGIS.CORE.DATA.QUERYFILTER.#CTOR + // cref: ARCGIS.CORE.DATA.SQLSYNTAX.GETSUPPORTEDSTRINGS + // cref: ARCGIS.CORE.DATA.DATASTORE.GETSQLSYNTAX #region Searching a Table for non-Latin characters using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table table = geodatabase.OpenDataset
("TableWithChineseCharacters")) { // This will fail with many database systems that expect Latin characters by default - string incorrectWhereClause = "颜色 = '绿'"; // Correct solution is to prepend the 'National String Prefix' to the attribute value // For example, with SQL Server this value is 'N' // This value is obtained using the SQLSyntax class - string nationalStringPrefix = ""; SQLSyntax sqlSyntax = geodatabase.GetSQLSyntax(); nationalStringPrefix = sqlSyntax.GetSupportedStrings(SQLStringType.NationalStringPrefix).First(); // This Where clause will work - QueryFilter queryFilter = new QueryFilter() { WhereClause = "颜色 = " + nationalStringPrefix + "'绿'" }; } + #endregion }); - - } + // cref: ARCGIS.CORE.DATA.TABLE.SEARCH + // cref: ARCGIS.CORE.DATA.QUERYFILTER.#CTOR + // cref: ARCGIS.CORE.DATA.QUERYFILTER.ObjectIDs #region Searching a Table using a set of ObjectIDs - public RowCursor SearchingATable(Table table, IReadOnlyList objectIDs) { QueryFilter queryFilter = new QueryFilter() @@ -526,15 +619,18 @@ public RowCursor SearchingATable(Table table, IReadOnlyList objectIDs) return table.Search(queryFilter); } - #endregion - + // cref: ARCGIS.CORE.DATA.TABLE.SEARCH + // cref: ARCGIS.CORE.DATA.SPATIALQUERYFILTER.#CTOR + // cref: ARCGIS.CORE.DATA.SPATIALQUERYFILTER.FilterGeometry + // cref: ARCGIS.CORE.DATA.SPATIALQUERYFILTER.SpatialRelationship + // cref: ARCGIS.CORE.DATA.SpatialRelationship #region Searching a FeatureClass using SpatialQueryFilter - public async Task SearchingAFeatureClass() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (FeatureClass schoolBoundaryFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.SchoolBoundary")) { @@ -542,7 +638,7 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { WhereClause = "DISTRCTNAME = 'Indian Prairie School District 204'", - FilterGeometry = new PolygonBuilder(new List + FilterGeometry = new PolygonBuilderEx(new List { new Coordinate2D(1021880, 1867396), new Coordinate2D(1028223, 1870705), @@ -568,14 +664,17 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Searching a FeatureClass using SpatialQueryFilter + // cref: ARCGIS.CORE.DATA.Selection + // cref: ARCGIS.CORE.DATA.SelectionType + // cref: ARCGIS.CORE.DATA.SelectionOption + // cref: ARCGIS.CORE.DATA.TABLE.SELECT(ARCGIS.CORE.DATA.QUERYFILTER,ARCGIS.CORE.DATA.SELECTIONTYPE,ARCGIS.CORE.DATA.SELECTIONOPTION) #region Selecting Rows from a Table - public async Task SelectingRowsFromATable() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table enterpriseTable = geodatabase.OpenDataset
("LocalGovernment.GDB.piCIPCost")) { @@ -603,14 +702,19 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Selecting Rows from a Table + // cref: ARCGIS.CORE.DATA.TABLE.SELECT(ARCGIS.CORE.DATA.QUERYFILTER,ARCGIS.CORE.DATA.SELECTIONTYPE,ARCGIS.CORE.DATA.SELECTIONOPTION) + // cref: ARCGIS.CORE.DATA.SPATIALQUERYFILTER.FilterGeometry + // cref: ARCGIS.CORE.DATA.SPATIALQUERYFILTER.SpatialRelationship + // cref: ARCGIS.CORE.DATA.SpatialRelationship + // cref: ARCGIS.CORE.DATA.SelectionType + // cref: ARCGIS.CORE.DATA.SelectionOption #region Selecting Features from a FeatureClass - public async Task SelectingFeaturesFromAFeatureClass() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (FeatureClass enterpriseFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.FacilitySite")) { @@ -625,7 +729,7 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { SpatialQueryFilter spatialFilter = new SpatialQueryFilter { WhereClause = "FCODE = 'Park'", - FilterGeometry = new PolygonBuilder(newCoordinates).ToGeometry(), + FilterGeometry = new PolygonBuilderEx(newCoordinates).ToGeometry(), SpatialRelationship = SpatialRelationship.Crosses }; @@ -652,35 +756,53 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Selecting Features from a FeatureClass public void GetCount(FeatureLayer featureLayer) { - QueuedTask.Run(() => { + QueuedTask.Run(() => + { + // cref: ArcGIS.Core.Data.Table.GetCount + // cref: ARCGIS.DESKTOP.MAPPING.BASICFEATURELAYER.GETTABLE #region Gets the count of how many rows are currently in a Table //Note: call within QueuedTask.Run() var table = featureLayer.GetTable(); var count = table.GetCount(); #endregion }); + + + // cref: ArcGIS.Core.Data.Table.GetCount + // cref: ARCGIS.DESKTOP.MAPPING.FEATURELAYER.GETFEATURECLASS #region Gets the feature count of a layer var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); QueuedTask.Run(() => { FeatureClass featureClass = lyr.GetFeatureClass(); - int nCount = featureClass.GetCount(); + long nCount = featureClass.GetCount(); }); #endregion } + // cref: ArcGIS.Core.Data.TableSortDescription.#ctor + // cref: ArcGIS.Core.Data.SortDescription.#ctor + // cref: ArcGIS.Core.Data.FeatureClass.GetDefinition + // cref: ArcGIS.Core.Data.FeatureClass.Sort + // cref: ArcGIS.Core.Data.FeatureClassDefinition + // cref: ArcGIS.Core.Data.TableDefinition.GetFields + // cref: ArcGIS.Core.Data.SortDescription.CaseSensitivity + // cref: ArcGIS.Core.Data.SortDescription.SortOrder + // cref: ArcGIS.Core.Data.CaseSensitivity + // cref: ArcGIS.Core.Data.SortOrder #region Sorting a Table public RowCursor SortWorldCities(FeatureClass worldCitiesTable) { using (FeatureClassDefinition featureClassDefinition = worldCitiesTable.GetDefinition()) { - Field countryField = featureClassDefinition.GetFields().First(x => x.Name.Equals("COUNTRY_NAME")); - Field cityNameField = featureClassDefinition.GetFields().First(x => x.Name.Equals("CITY_NAME")); + Field countryField = featureClassDefinition.GetFields() + .First(x => x.Name.Equals("COUNTRY_NAME")); + Field cityNameField = featureClassDefinition.GetFields() + .First(x => x.Name.Equals("CITY_NAME")); // Create SortDescription for Country field SortDescription countrySortDescription = new SortDescription(countryField); @@ -693,35 +815,58 @@ public RowCursor SortWorldCities(FeatureClass worldCitiesTable) citySortDescription.SortOrder = SortOrder.Ascending; // Create our TableSortDescription - TableSortDescription tableSortDescription = new TableSortDescription(new List() { countrySortDescription, citySortDescription }); + TableSortDescription tableSortDescription = new TableSortDescription( + new List() { countrySortDescription, citySortDescription }); return worldCitiesTable.Sort(tableSortDescription); } } #endregion + // cref: ArcGIS.Core.Data.TableStatisticsDescription.#ctor + // cref: ArcGIS.Core.Data.TableStatisticsDescription.GroupBy + // cref: ArcGIS.Core.Data.TableStatisticsDescription.OrderBy + // cref: ArcGIS.Core.Data.StatisticsDescription.#ctor + // cref: ArcGIS.Core.Data.Table.CalculateStatistics + // cref: ArcGIS.Core.Data.StatisticsFunction + // cref: ArcGIS.Core.Data.TableStatisticsResult + // cref: ArcGIS.Core.Data.TableStatisticsResult.StatisticsResults #region Calculating Statistics on a Table // Calculate the Sum and Average of the Population_1990 and Population_2000 fields, grouped and ordered by Region public void CalculateStatistics(FeatureClass countryFeatureClass) { - using (FeatureClassDefinition featureClassDefinition = countryFeatureClass.GetDefinition()) + using (FeatureClassDefinition featureClassDefinition = + countryFeatureClass.GetDefinition()) { // Get fields - Field regionField = featureClassDefinition.GetFields().First(x => x.Name.Equals("Region")); - Field pop1990Field = featureClassDefinition.GetFields().First(x => x.Name.Equals("Population_1990")); - Field pop2000Field = featureClassDefinition.GetFields().First(x => x.Name.Equals("Population_2000")); + Field regionField = featureClassDefinition.GetFields() + .First(x => x.Name.Equals("Region")); + Field pop1990Field = featureClassDefinition.GetFields() + .First(x => x.Name.Equals("Population_1990")); + Field pop2000Field = featureClassDefinition.GetFields() + .First(x => x.Name.Equals("Population_2000")); // Create StatisticsDescriptions - StatisticsDescription pop1990StatisticsDescription = new StatisticsDescription(pop1990Field, new List() { StatisticsFunction.Sum, StatisticsFunction.Average }); - StatisticsDescription pop2000StatisticsDescription = new StatisticsDescription(pop2000Field, new List() { StatisticsFunction.Sum, StatisticsFunction.Average }); + StatisticsDescription pop1990StatisticsDescription = + new StatisticsDescription(pop1990Field, + new List() { StatisticsFunction.Sum, + StatisticsFunction.Average }); + StatisticsDescription pop2000StatisticsDescription = + new StatisticsDescription(pop2000Field, + new List() { StatisticsFunction.Sum, + StatisticsFunction.Average }); // Create TableStatisticsDescription - TableStatisticsDescription tableStatisticsDescription = new TableStatisticsDescription(new List() { pop1990StatisticsDescription, pop2000StatisticsDescription }); + TableStatisticsDescription tableStatisticsDescription = + new TableStatisticsDescription(new List() { + pop1990StatisticsDescription, pop2000StatisticsDescription }); tableStatisticsDescription.GroupBy = new List() { regionField }; - tableStatisticsDescription.OrderBy = new List() { new SortDescription(regionField) }; + tableStatisticsDescription.OrderBy = + new List() { new SortDescription(regionField) }; // Calculate Statistics - IReadOnlyList tableStatisticsResults = countryFeatureClass.CalculateStatistics(tableStatisticsDescription); + IReadOnlyList tableStatisticsResults = + countryFeatureClass.CalculateStatistics(tableStatisticsDescription); foreach (TableStatisticsResult tableStatisticsResult in tableStatisticsResults) { @@ -746,12 +891,15 @@ public void CalculateStatistics(FeatureClass countryFeatureClass) } #endregion - + // cref: ARCGIS.CORE.DATA.GEODATABASE.EVALUATE + // cref: ARCGIS.CORE.DATA.QUERYDEF + // cref: ARCGIS.CORE.DATA.QUERYDEF.Tables + // cref: ARCGIS.CORE.DATA.QUERYDEF.WhereClause #region Evaluating a QueryDef on a single table - public async Task SimpleQueryDef() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) { QueryDef adaCompilantParksQueryDef = new QueryDef @@ -785,14 +933,19 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Evaluating a QueryDef on a single table + // cref: ARCGIS.CORE.DATA.GEODATABASE.EVALUATE + // cref: ARCGIS.CORE.DATA.QUERYDEF + // cref: ARCGIS.CORE.DATA.QUERYDEF.Tables + // cref: ARCGIS.CORE.DATA.QUERYDEF.WhereClause + // cref: ARCGIS.CORE.DATA.QUERYDEF.SubFields + // cref: ARCGIS.CORE.DATA.Row.GetFields #region Evaluating a QueryDef on a Join using WHERE Clause - public async Task JoiningWithWhereQueryDef() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) { QueryDef municipalEmergencyFacilitiesQueryDef = new QueryDef @@ -821,14 +974,16 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Evaluating a QueryDef on a Join using WHERE Clause + // cref: ARCGIS.CORE.DATA.GEODATABASE.EVALUATE + // cref: ARCGIS.CORE.DATA.QUERYDEF.Tables + // cref: ARCGIS.CORE.DATA.QUERYDEF.SubFields #region Evaluating a QueryDef on a OUTER JOIN - public async Task EvaluatingQueryDefWithOuterJoin() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) { QueryDef queryDefWithLeftOuterJoin = new QueryDef @@ -854,11 +1009,12 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Evaluating a QueryDef on a OUTER JOIN + // cref: ARCGIS.CORE.DATA.GEODATABASE.EVALUATE + // cref: ARCGIS.CORE.DATA.QUERYDEF.Tables + // cref: ARCGIS.CORE.DATA.QUERYDEF.SubFields #region Evaluating a QueryDef on a INNER join - public async Task EvaluatingQueryDefWithInnerJoin() { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -884,17 +1040,18 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => } }); } - #endregion Evaluating a QueryDef on a INNER join - + // cref: ARCGIS.CORE.DATA.GEODATABASE.EVALUATE + // cref: ARCGIS.CORE.DATA.QUERYDEF.Tables + // cref: ARCGIS.CORE.DATA.QUERYDEF.SubFields #region Evaluating a QueryDef on a nested - INNER and OUTER join - public async Task EvaluatingQueryDefWithNestedJoin() { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) + using (Geodatabase geodatabase = new Geodatabase( + new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) { QueryDef queryDef = new QueryDef() { @@ -915,15 +1072,26 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => } }); } - #endregion Evaluating a QueryDef on nested (INNER & OUTER) join + // cref: ARCGIS.CORE.DATA.DATABASE.GETQUERYDESCRIPTION(System.String) + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.AuthenticationMode + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.Instance + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.Database + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.User + // cref: ARCGIS.CORE.DATA.DATABASECONNECTIONPROPERTIES.Password + // cref: ARCGIS.CORE.DATA.AuthenticationMode + // cref: ARCGIS.CORE.DATA.DATABASE._CTOR(DATABASECONNECTIONPROPERTIES) + // cref: ARCGIS.CORE.DATA.DATABASE.OpenTable + // cref: ARCGIS.CORE.DATA.EnterpriseDatabaseType + // cref: ARCGIS.CORE.DATA.QueryDescription #region Create Default QueryDescription for a Database table and obtain the ArcGIS.Core.Data.Table for the QueryDescription - public async Task DefaultQueryDescription() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - DatabaseConnectionProperties databaseConnectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + DatabaseConnectionProperties databaseConnectionProperties = + new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { AuthenticationMode = AuthenticationMode.DBMS, Instance = "instance", @@ -943,15 +1111,19 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Create Default QueryDescription for a Database table and obtain the ArcGIS.Core.Data.Table for the QueryDescription + // cref: ARCGIS.CORE.DATA.DATABASE.GETQUERYDESCRIPTION(System.String,System.String) + // cref: ARCGIS.CORE.DATA.EnterpriseDatabaseType + // cref: ARCGIS.CORE.DATA.QueryDescription + // cref: ARCGIS.CORE.DATA.DATABASE.OpenTable #region Create QueryDescription from a custom query for a Database table - public async Task CustomQueryDescription() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - DatabaseConnectionProperties databaseConnectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + DatabaseConnectionProperties databaseConnectionProperties = + new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { AuthenticationMode = AuthenticationMode.DBMS, Instance = "instance", @@ -971,15 +1143,17 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Create QueryDescription from a custom query for a Database table + // cref: ARCGIS.CORE.DATA.DATABASE.GETQUERYDESCRIPTION(System.String,System.String) + // cref: ARCGIS.CORE.DATA.QueryDescription.SetObjectIDFields #region Create QueryDescription from a join query where there is no non-nullable unique id column - public async Task JoinQueryDescription() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - DatabaseConnectionProperties databaseConnectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { + DatabaseConnectionProperties databaseConnectionProperties = + new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { AuthenticationMode = AuthenticationMode.DBMS, Instance = "instance", @@ -1001,14 +1175,15 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Create QueryDescription from a join query where there is no non-nullable unique id column + // cref: ARCGIS.CORE.DATA.DATABASE.GETQUERYDESCRIPTION(System.String,System.String) + // cref: ARCGIS.CORE.DATA.QUERYDESCRIPTION.SETSHAPETYPE #region Create QueryDescription from a query for a Database table which has more than one shape type - public async Task MultiGeometryQueryDescription() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { DatabaseConnectionProperties databaseConnectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { AuthenticationMode = AuthenticationMode.DBMS, @@ -1036,14 +1211,16 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Create QueryDescription from a query for a Database table which has more than one shape type + // cref: ARCGIS.CORE.DATA.SQLITECONNECTIONPATH.#CTOR + // cref: ARCGIS.CORE.DATA.DATABASE.GETQUERYDESCRIPTION(System.String,System.String) + // cref: ARCGIS.CORE.DATA.DATABASE.OPENTABLE #region Create QueryDescription from a query for an SQLite Database table - public async Task SqliteQueryDescription() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Database database = new Database(new SQLiteConnectionPath(new Uri("Path\\To\\Sqlite\\Database\\USA.sqlite")))) { QueryDescription washingtonCitiesQueryDescription = database.GetQueryDescription("select OBJECTID, Shape, CITY_FIPS, CITY_NAME, STATE_FIPS, STATE_CITY, TYPE, CAPITAL from main.cities where STATE_NAME='Washington'", "WashingtonCities"); @@ -1055,14 +1232,15 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Create QueryDescription from a query for a SQLite Database table + // cref: ARCGIS.CORE.DATA.SQLSYNTAX.GETFUNCTIONNAME + // cref: ARCGIS.CORE.DATA.DATASTORE.GETSQLSYNTAX #region Using SQLSyntax to form platform agnostic queries - public async Task UsingSqlSyntaxToFormPlatformAgnosticQueries() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("C:\\Data\\LocalGovernment.gdb")))) using (FeatureClass featureClass = geodatabase.OpenDataset("FacilitySite")) { @@ -1082,16 +1260,28 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Using SQLSyntax to form platform agnostic queries + // cref: ARCGIS.CORE.DATA.VIRTUALRELATIONSHIPCLASSDESCRIPTION + // cref: ARCGIS.CORE.DATA.JOIN.GETJOINEDTABLE + // cref: ARCGIS.CORE.DATA.Table.RelateTo + // cref: ARCGIS.CORE.DATA.JOIN.#CTOR(ARCGIS.CORE.DATA.JOINDESCRIPTION) + // cref: ARCGIS.CORE.DATA.JOIN.GetJoinedTable + // cref: ARCGIS.CORE.DATA.RelationshipCardinality + // cref: ARCGIS.CORE.DATA.RelationshipClass + // cref: ARCGIS.CORE.DATA.JoinDescription + // cref: ARCGIS.CORE.DATA.JoinDescription.JoinDirection + // cref: ARCGIS.CORE.DATA.JoinDescription.JoinType + // cref: ARCGIS.CORE.DATA.JoinDirection + // cref: ARCGIS.CORE.DATA.JoinType #region Joining a file geodatabase feature class to an Oracle database query layer feature class with a virtual relationship class - public async Task JoiningFileGeodatabaseFeatureClassToOracleQueryLayer() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("C:\\Data\\LocalGovernment.gdb")))) - using (Database database = new Database(new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle) + using (Database database = new Database( + new DatabaseConnectionProperties(EnterpriseDatabaseType.Oracle) { AuthenticationMode = AuthenticationMode.DBMS, Instance = "instance", @@ -1106,7 +1296,9 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { Field originPrimaryKey = leftFeatureClass.GetDefinition().GetFields().FirstOrDefault(field => field.Name.Equals("facilityId")); Field destinationForeignKey = rightTable.GetDefinition().GetFields().FirstOrDefault(field => field.Name.Equals("hospitalID")); - VirtualRelationshipClassDescription description = new VirtualRelationshipClassDescription(originPrimaryKey, destinationForeignKey, RelationshipCardinality.OneToOne); + VirtualRelationshipClassDescription description = + new VirtualRelationshipClassDescription( + originPrimaryKey, destinationForeignKey, RelationshipCardinality.OneToOne); using (RelationshipClass relationshipClass = leftFeatureClass.RelateTo(rightTable, description)) { @@ -1126,11 +1318,18 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Joining a file geodatabase feature class to an Oracle database query layer feature class with a virtual relationship class + // cref: ARCGIS.CORE.DATA.VIRTUALRELATIONSHIPCLASSDESCRIPTION + // cref: ARCGIS.CORE.DATA.JOIN.GETJOINEDTABLE + // cref: ARCGIS.CORE.DATA.JOIN.#CTOR(ARCGIS.CORE.DATA.JOINDESCRIPTION) + // cref: ARCGIS.CORE.DATA.JoinDescription + // cref: ARCGIS.CORE.DATA.JoinDescription.JoinDirection + // cref: ARCGIS.CORE.DATA.JoinDescription.JoinType + // cref: ARCGIS.CORE.DATA.JoinDescription.TargetFields + // cref: ARCGIS.CORE.DATA.JoinDirection + // cref: ARCGIS.CORE.DATA.JoinType #region Joining two tables from different geodatabases - public async Task JoinTablesFromDifferentGeodatabases() { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -1174,14 +1373,21 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => } }); } - #endregion Joining two tables from different geodatabases + // cref: ARCGIS.CORE.DATA.QUERYTABLEDESCRIPTION + // cref: ARCGIS.CORE.DATA.QUERYTABLEDESCRIPTION.Name + // cref: ARCGIS.CORE.DATA.QUERYTABLEDESCRIPTION.PrimaryKeys + // cref: ARCGIS.CORE.DATA.GEODATABASE.OPENQUERYTABLE + // cref: ARCGIS.CORE.DATA.QueryDef + // cref: ARCGIS.CORE.DATA.QueryDef.Tables + // cref: ARCGIS.CORE.DATA.QueryDef.SubFields + // cref: ARCGIS.CORE.DATA.SQLSyntax.QualifyColumnName #region Creating a QueryTable using a query which joins two versioned tables in a geodatabase - public async Task QueryTableJoinWithVersionedData() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { QueryDef queryDef = new QueryDef { Tables = "CommunityAddress JOIN MunicipalBoundary on CommunityAddress.Municipality = MunicipalBoundary.Name", @@ -1239,7 +1445,9 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { public void CheckColumnForNull(Row row, Field field) { + // cref: ARCGIS.CORE.DATA.ROW.ITEM(System.String) #region Checking a field value for null + var val = row[field.Name]; if (val is DBNull || val == null) { @@ -1249,9 +1457,14 @@ public void CheckColumnForNull(Row row, Field field) { // field value is not null } + #endregion Checking a field value for null } + // cref: ARCGIS.CORE.DATA.FIELD.GETDOMAIN + // cref: ARCGIS.CORE.DATA.TABLEDEFINITION.GETSUBTYPES + // cref: ARCGIS.CORE.DATA.Subtype + // cref: ARCGIS.CORE.DATA.CodedValueDomain #region Get domain string from a field public string GetDomainStringFromField(Row row, Field field) { @@ -1269,7 +1482,7 @@ public string GetDomainStringFromField(Row row, Field field) { // Get value of subtype field for this row var varSubtypeCode = row[subtypeFieldName]; - long subtypeCode = (long)varSubtypeCode ; + long subtypeCode = (long)varSubtypeCode; // Get subtype for this row subtype = tableDefinition.GetSubtypes().First(x => x.GetCode() == subtypeCode); @@ -1289,24 +1502,28 @@ public string GetDomainStringFromField(Row row, Field field) } } } - #endregion Get domain string from a field - + #region ProSnippet Group: Editing #endregion - + // cref: ARCGIS.CORE.DATA.TABLE.CREATEROWBUFFER + // cref: ARCGIS.CORE.DATA.TABLE.CREATEROW + // cref: ARCGIS.Desktop.Editing.EditOperation.Callback + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.IEDITCONTEXT.INVALIDATE + // cref: ARCGIS.CORE.DATA.RowBuffer #region Creating a Row - public async Task CreatingARow() { string message = String.Empty; bool creationResult = false; EditOperation editOperation = new EditOperation(); - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { - using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) + using (Geodatabase geodatabase = new Geodatabase( + new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table enterpriseTable = geodatabase.OpenDataset
("LocalGovernment.GDB.piCIPCost")) { @@ -1317,7 +1534,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { //var table = shapefile.OpenDataset
(strShapeFileName); for a Shape file //declare the callback here. We are not executing it ~yet~ - editOperation.Callback(context => { + editOperation.Callback(context => + { TableDefinition tableDefinition = enterpriseTable.GetDefinition(); int assetNameIndex = tableDefinition.FindField("ASSETNA"); @@ -1355,17 +1573,19 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { MessageBox.Show(message); } - #endregion Creating a Row + // cref: ARCGIS.CORE.DATA.TABLE.CREATEROWBUFFER + // cref: ARCGIS.CORE.DATA.FEATURECLASS.CREATEROW + // cref: ARCGIS.CORE.DATA.RowBuffer #region Creating a Feature - public async Task CreatingAFeature() { string message = String.Empty; bool creationResult = false; - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (FeatureClass enterpriseFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.FacilitySite")) { @@ -1377,7 +1597,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { //declare the callback here. We are not executing it ~yet~ EditOperation editOperation = new EditOperation(); - editOperation.Callback(context => { + editOperation.Callback(context => + { FeatureClassDefinition facilitySiteDefinition = enterpriseFeatureClass.GetDefinition(); int facilityIdIndex = facilitySiteDefinition.FindField("FACILITYID"); @@ -1399,7 +1620,7 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { new Coordinate2D(1021405, 1875397) }; - rowBuffer[facilitySiteDefinition.GetShapeField()] = new PolygonBuilder(newCoordinates).ToGeometry(); + rowBuffer[facilitySiteDefinition.GetShapeField()] = new PolygonBuilderEx(newCoordinates).ToGeometry(); using (Feature feature = enterpriseFeatureClass.CreateRow(rowBuffer)) { @@ -1425,17 +1646,19 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { if (!string.IsNullOrEmpty(message)) MessageBox.Show(message); } - #endregion Creating a Feature - - #region Modifying a Row + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.IEDITCONTEXT.INVALIDATE(ARCGIS.CORE.DATA.ROW) + // cref: ArcGIS.Core.Data.Row.Store + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.IEDITCONTEXT.INVALIDATE(Row) + #region Modifying a Row public async Task ModifyingARow() { string message = String.Empty; bool modificationResult = false; - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table enterpriseTable = geodatabase.OpenDataset
("LocalGovernment.GDB.piCIPCost")) { @@ -1446,7 +1669,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { //var table = shapefile.OpenDataset
(strShapeFileName); for a Shape file EditOperation editOperation = new EditOperation(); - editOperation.Callback(context => { + editOperation.Callback(context => + { QueryFilter openCutFilter = new QueryFilter { WhereClause = "ACTION = 'Open Cut'" }; using (RowCursor rowCursor = enterpriseTable.Search(openCutFilter, false)) @@ -1496,17 +1720,19 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { if (!string.IsNullOrEmpty(message)) MessageBox.Show(message); } - #endregion Modifying a Row + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.IEDITCONTEXT.INVALIDATE(ARCGIS.CORE.DATA.ROW) + // cref: ARCGIS.CORE.DATA.ROW.STORE + // cref: ARCGIS.CORE.DATA.FEATURE.SETSHAPE #region Modifying a Feature - public async Task ModifyingAFeature() { string message = String.Empty; bool modificationResult = false; - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (FeatureClass enterpriseFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.FacilitySite")) { @@ -1523,7 +1749,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { int areaIndex = facilitySiteDefinition.FindField(facilitySiteDefinition.GetAreaField()); EditOperation editOperation = new EditOperation(); - editOperation.Callback(context => { + editOperation.Callback(context => + { QueryFilter queryFilter = new QueryFilter { WhereClause = "FCODE = 'Hazardous Materials Facility' AND OWNTYPE = 'Private'" }; using (RowCursor rowCursor = enterpriseFeatureClass.Search(queryFilter, false)) @@ -1550,7 +1777,7 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { new Coordinate2D(1021405, 1875397) }; - feature.SetShape(new PolygonBuilder(newCoordinates).ToGeometry()); + feature.SetShape(new PolygonBuilderEx(newCoordinates).ToGeometry()); } feature.Store(); @@ -1577,29 +1804,29 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { if (!string.IsNullOrEmpty(message)) MessageBox.Show(message); } - #endregion Modifying a Feature public void WritingIntoGuidColumn(Row row, Field field, Guid guid) { + // cref: ARCGIS.CORE.DATA.ROW.FINDFIELD #region Writing a value into a Guid column row[field.Name] = "{" + guid.ToString() + "}"; #endregion Writing a value into a Guid column } - + // cref: ARCGIS.DESKTOP.EDITING.EDITOPERATION.IEDITCONTEXT.INVALIDATE(ARCGIS.CORE.DATA.ROW) + // cref: ARCGIS.CORE.DATA.ROW.DELETE #region Deleting a Row/Feature - public async Task DeletingARowOrFeature() { string message = String.Empty; bool deletionResult = false; - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table enterpriseTable = geodatabase.OpenDataset
("LocalGovernment.GDB.piCIPCost")) { - //var geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(uri)) for a File GDB // //var shapeFileConnPath = new FileSystemConnectionPath(uri, FileSystemDatastoreType.Shapefile); @@ -1607,7 +1834,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { //var table = shapefile.OpenDataset
(strShapeFileName); for a Shape file EditOperation editOperation = new EditOperation(); - editOperation.Callback(context => { + editOperation.Callback(context => + { QueryFilter openCutFilter = new QueryFilter { WhereClause = "ACTION = 'Open Cut'" }; using (RowCursor rowCursor = enterpriseTable.Search(openCutFilter, false)) @@ -1640,32 +1868,15 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { if (!string.IsNullOrEmpty(message)) MessageBox.Show(message); } - #endregion Deleting a Row/Feature - #region Obtaining a memory stream to modify or create Attachment data - - private MemoryStream CreateMemoryStreamFromContentsOf(String fileNameWithPath) - { - MemoryStream memoryStream = new MemoryStream(); - - using (FileStream file = new FileStream(fileNameWithPath, FileMode.Open, FileAccess.Read)) - { - byte[] bytes = new byte[file.Length]; - file.Read(bytes, 0, (int)file.Length); - memoryStream.Write(bytes, 0, (int)file.Length); - } - - return memoryStream; - } - - #endregion Obtaining a memory stream to modify or create Attachment data - + // cref: ARCGIS.CORE.DATA.ROW.ADDATTACHMENT + // cref: ARCGIS.CORE.DATA.Attachment #region Adding Attachments - public async Task AddingAttachments() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (FeatureClass parkFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.Park")) { @@ -1690,13 +1901,30 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { }); } + private MemoryStream CreateMemoryStreamFromContentsOf(String fileNameWithPath) + { + MemoryStream memoryStream = new MemoryStream(); + + using (FileStream file = new FileStream(fileNameWithPath, FileMode.Open, FileAccess.Read)) + { + byte[] bytes = new byte[file.Length]; + file.Read(bytes, 0, (int)file.Length); + memoryStream.Write(bytes, 0, (int)file.Length); + } + + return memoryStream; + } #endregion Adding Attachments + // cref: ARCGIS.CORE.DATA.ROW.UPDATEATTACHMENT + // cref: ARCGIS.CORE.DATA.ROW.GETATTACHMENTS + // cref: ARCGIS.CORE.DATA.Attachment + // cref: ARCGIS.CORE.DATA.Attachment.SetName #region Updating Attachments - public async Task UpdatingAttachments() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (FeatureClass landUseCaseFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.LandUseCase")) { @@ -1722,14 +1950,17 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Updating Attachments + // cref: ARCGIS.CORE.DATA.ROW.DELETEATTACHMENTS + // cref: ARCGIS.CORE.DATA.ROW.GETATTACHMENTS + // cref: ARCGIS.CORE.DATA.ATTACHMENT.GETATTACHMENTID + // cref: ARCGIS.CORE.DATA.Attachment.GetContentType #region Deleting Attachments - public async Task DeletingAttachments() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file\\sdefile.sde")))) using (Table inspectionTable = geodatabase.OpenDataset
("luCodeInspection")) { @@ -1757,11 +1988,11 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Deleting Attachments + // cref: ARCGIS.CORE.DATA.TABLE.CREATEROWBUFFER + // cref: ARCGIS.CORE.DATA.TABLE.CREATEROW #region Writing a Blob field - public async Task WriteBlobField(Table table, string blobFieldName, string imageFileName) { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -1781,11 +2012,11 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => } }); } - #endregion + // cref: ARCGIS.CORE.DATA.Feature + // cref: ARCGIS.CORE.DATA.Row #region Reading a Blob field - public async Task ReadBlobField(Table table, QueryFilter queryFilter, string blobFieldName) { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -1816,10 +2047,13 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => } #endregion + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASS.GETROWSRELATEDTODESTINATIONROWS + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASS.GETROWSRELATEDTOORIGINROWS #region Getting Rows related by RelationshipClass public async Task GettingRowsRelatedByRelationshipClass() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) using (RelationshipClass relationshipClass = geodatabase.OpenDataset("LocalGovernment.GDB.luCodeViolationHasInspections")) using (FeatureClass violationsFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.luCodeViolation")) @@ -1870,14 +2104,16 @@ private static void Dispose(IEnumerable rows) foreach (Row row in rows) row.Dispose(); } - #endregion Getting Rows related by RelationshipClass + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASS.CREATERELATIONSHIP + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASSDEFINITION.GETORIGINKEYFIELD + // cref: ARCGIS.CORE.DATA.RELATIONSHIP #region Creating a Relationship - public async Task CreatingARelationship() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) using (RelationshipClass relationshipClass = geodatabase.OpenDataset("LocalGovernment.GDB.OverviewToProject")) using (FeatureClass projectsFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.CIPProjects")) @@ -1887,7 +2123,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { string originKeyField = relationshipClass.GetDefinition().GetOriginKeyField(); EditOperation editOperation = new EditOperation(); - editOperation.Callback(context => { + editOperation.Callback(context => + { // The rows are being added to illustrate adding relationships. If one has existing rows, those can be used to add a relationship. using (RowBuffer projectsRowBuffer = projectsFeatureClass.CreateRowBuffer()) using (RowBuffer overviewRowBuffer = overviewFeatureClass.CreateRowBuffer()) @@ -1915,14 +2152,15 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Creating a Relationship + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASS.DELETERELATIONSHIP + // cref: ARCGIS.CORE.DATA.RELATIONSHIPCLASS.GETROWSRELATEDTOORIGINROWS #region Deleting a Relationship - public async Task DeletingARelationship() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) using (RelationshipClass relationshipClass = geodatabase.OpenDataset("LocalGovernment.GDB.luCodeViolationHasInspections")) using (FeatureClass violationsFeatureClass = geodatabase.OpenDataset("LocalGovernment.GDB.luCodeViolation")) @@ -1941,7 +2179,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { try { EditOperation editOperation = new EditOperation(); - editOperation.Callback(context => { + editOperation.Callback(context => + { foreach (Row relatedDestinationRow in relatedDestinationRows) { try @@ -1967,9 +2206,11 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Deleting a Relationship + // cref: ArcGIS.Core.Data.Table.CreateInsertCursor + // cref: ArcGIS.Core.Data.InsertCursor.Insert + // cref: ArcGIS.Core.Data.InsertCursor.Flush #region Using an Insert Cursor // Insert Cursors are intended for use in CoreHost applications, not Pro Add-ins public void UsingInsertCursor() @@ -2002,8 +2243,18 @@ public void UsingInsertCursor() } #endregion + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeatureClass.CreateRow(ArcGIS.Core.Data.RowBuffer) + // cref: ARCGIS.CORE.DATA.TABLE.CREATEROWBUFFER + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature.SetAnnotationClassID + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature.SetStatus + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature.SetGraphic + // cref: ArcGIS.Core.Data.AnnotationStatus + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeatureClass.GetDefinition + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition.GetLabelClassCollection + // cref: ArcGIS.Core.CIM.CIMLabelClass + // cref: ArcGIS.Core.CIM.CIMLabelClass.TextSymbol #region Creating a new Annotation Feature in an Annotation FeatureClass using a RowBuffer - public async Task CreatingAnAnnotationFeature(Geodatabase geodatabase) { await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -2017,7 +2268,8 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => annotationFeature.SetStatus(AnnotationStatus.Placed); // Get the annotation labels from the label collection - IReadOnlyList labelClasses = annotationFeatureClassDefinition.GetLabelClassCollection(); + IReadOnlyList labelClasses = + annotationFeatureClassDefinition.GetLabelClassCollection(); // Setup the symbol reference with the symbol id and the text symbol CIMSymbolReference cimSymbolReference = new CIMSymbolReference(); @@ -2027,7 +2279,7 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => // Setup the text graphic CIMTextGraphic cimTextGraphic = new CIMTextGraphic(); cimTextGraphic.Text = "Charlotte, North Carolina"; - cimTextGraphic.Shape = new MapPointBuilder(new Coordinate2D(-80.843, 35.234), SpatialReferences.WGS84).ToGeometry(); + cimTextGraphic.Shape = new MapPointBuilderEx(new Coordinate2D(-80.843, 35.234), SpatialReferences.WGS84).ToGeometry(); cimTextGraphic.Symbol = cimSymbolReference; // Set the symbol reference on the graphic and store @@ -2036,12 +2288,15 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => } }); } - #endregion Creating a new Annotation Feature in an Annotation FeatureClass using a RowBuffer #region ProSnippet Group: Versioning #endregion + // cref: ARCGIS.CORE.DATA.VERSIONMANAGER.GETVERSION + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETVERSIONMANAGER + // cref: ARCGIS.CORE.DATA.GEODATABASE.IsVersioningSupported + // cref: ARCGIS.CORE.DATA.VERSION.CONNECT #region Connecting to a Version public Geodatabase ConnectToVersion(Geodatabase geodatabase, string versionName) { @@ -2059,7 +2314,24 @@ public Geodatabase ConnectToVersion(Geodatabase geodatabase, string versionName) } #endregion - #region Reconciling and Posting a Version with its Parent + // cref: ARCGIS.CORE.DATA.GEODATABASE.IsVersioningSupported + // cref: ARCGIS.CORE.DATA.VERSIONMANAGER.GetCurrentVersion + // cref: ArcGIS.Core.Data.Version.Reconcile(ArcGIS.Core.Data.ReconcileOptions) + // cref: ArcGIS.Core.Data.Version.Post + // cref: ArcGIS.Core.Data.Version.GetParent + // cref: ArcGIS.Core.Data.ReconcileOptions + // cref: ArcGIS.Core.Data.ReconcileOptions.ConflictResolutionMethod + // cref: ArcGIS.Core.Data.ReconcileOptions.ConflictDetectionType + // cref: ArcGIS.Core.Data.ReconcileOptions.ConflictResolutionType + // cref: ArcGIS.Core.Data.ConflictResolutionMethod + // cref: ArcGIS.Core.Data.ConflictDetectionType + // cref: ArcGIS.Core.Data.ConflictResolutionType + // cref: ArcGIS.Core.Data.ReconcileResult + // cref: ArcGIS.Core.Data.ReconcileResult.HasConflicts + // cref: ArcGIS.Core.Data.PostOptions + // cref: ArcGIS.Core.Data.PostOptions.ServiceSynchronizationType + // cref: ArcGIS.Core.Data.ServiceSynchronizationType + #region Reconciling and Posting a Version with its Parent in separate edit sessions public void ReconcileAndPost(Geodatabase geodatabase) { // Get a reference to our version and our parent @@ -2070,35 +2342,126 @@ public void ReconcileAndPost(Geodatabase geodatabase) using (Version parentVersion = currentVersion.GetParent()) { - // Create a ReconcileDescription object - ReconcileDescription reconcileDescription = new ReconcileDescription(parentVersion); - reconcileDescription.ConflictResolutionMethod = ConflictResolutionMethod.Continue; // continue if conflicts are found - reconcileDescription.WithPost = true; + //// Create a ReconcileDescription object + //At 2.x - + //ReconcileDescription reconcileDescription = new ReconcileDescription(parentVersion); + //reconcileDescription.ConflictResolutionMethod = ConflictResolutionMethod.Continue; // continue if conflicts are found + //reconcileDescription.WithPost = true; - // Reconcile and post - ReconcileResult reconcileResult = currentVersion.Reconcile(reconcileDescription); + //// Reconcile and post + //ReconcileResult reconcileResult = currentVersion.Reconcile(reconcileDescription); // ReconcileResult.HasConflicts can be checked as-needed + + // Create a ReconcileOptions object + var reconcileOptions = new ReconcileOptions(parentVersion); + reconcileOptions.ConflictResolutionMethod = ConflictResolutionMethod.Continue; // continue if conflicts are found + reconcileOptions.ConflictDetectionType = ConflictDetectionType.ByRow; //Default + reconcileOptions.ConflictResolutionType = ConflictResolutionType.FavorTargetVersion;//or FavorEditVersion + + // Reconcile + ReconcileResult reconcileResult = currentVersion.Reconcile(reconcileOptions); + if (!reconcileResult.HasConflicts) + { + //No conflicts, perform the post + var postOptions = new PostOptions(parentVersion); + //var postOptions = new PostOptions(); for default version + postOptions.ServiceSynchronizationType = ServiceSynchronizationType.Synchronous;//Default + currentVersion.Post(postOptions); + } + } } } + #endregion + + // cref: ARCGIS.CORE.DATA.GEODATABASE.IsVersioningSupported + // cref: ARCGIS.CORE.DATA.VERSIONMANAGER.GetCurrentVersion + // cref: ArcGIS.Core.Data.Version.Reconcile(ArcGIS.Core.Data.ReconcileOptions,ArcGIS.Core.Data.PostOptions) + // cref: ArcGIS.Core.Data.Version.Post + // cref: ArcGIS.Core.Data.Version.GetParent + // cref: ArcGIS.Core.Data.ReconcileOptions + // cref: ArcGIS.Core.Data.ReconcileOptions.ConflictResolutionMethod + // cref: ArcGIS.Core.Data.ReconcileOptions.ConflictDetectionType + // cref: ArcGIS.Core.Data.ReconcileOptions.ConflictResolutionType + // cref: ArcGIS.Core.Data.ConflictResolutionMethod + // cref: ArcGIS.Core.Data.ConflictDetectionType + // cref: ArcGIS.Core.Data.ConflictResolutionType + // cref: ArcGIS.Core.Data.ReconcileResult + // cref: ArcGIS.Core.Data.ReconcileResult.HasConflicts + // cref: ArcGIS.Core.Data.PostOptions + // cref: ArcGIS.Core.Data.PostOptions.ServiceSynchronizationType + // cref: ArcGIS.Core.Data.ServiceSynchronizationType + #region Reconciling and Posting a Version with its Parent in the same edit session + public void ReconcileAndPost2(Geodatabase geodatabase) + { + // Get a reference to our version and our parent + if (geodatabase.IsVersioningSupported()) + { + using (VersionManager versionManager = geodatabase.GetVersionManager()) + using (Version currentVersion = versionManager.GetCurrentVersion()) + using (Version parentVersion = currentVersion.GetParent()) + { + + //// Create a ReconcileDescription object + //At 2.x - + //ReconcileDescription reconcileDescription = new ReconcileDescription(parentVersion); + //reconcileDescription.ConflictResolutionMethod = ConflictResolutionMethod.Continue; // continue if conflicts are found + //reconcileDescription.WithPost = true; + + //// Reconcile and post + //ReconcileResult reconcileResult = currentVersion.Reconcile(reconcileDescription); + + // ReconcileResult.HasConflicts can be checked as-needed + + // Create a ReconcileOptions object + var reconcileOptions = new ReconcileOptions(parentVersion); + reconcileOptions.ConflictResolutionMethod = ConflictResolutionMethod.Continue; // continue if conflicts are found + reconcileOptions.ConflictDetectionType = ConflictDetectionType.ByRow; //Default + reconcileOptions.ConflictResolutionType = ConflictResolutionType.FavorTargetVersion;//or FavorEditVersion + + var postOptions = new PostOptions(parentVersion); + //var postOptions = new PostOptions(); for default version + postOptions.ServiceSynchronizationType = ServiceSynchronizationType.Synchronous;//Default + // Reconcile + ReconcileResult reconcileResult = currentVersion.Reconcile(reconcileOptions, postOptions); + if (reconcileResult.HasConflicts) + { + //TODO resolve conflicts + + } + + } + } + } #endregion + // cref: ARCGIS.CORE.DATA.VERSIONMANAGER.GETVERSIONS + // cref: ARCGIS.CORE.DATA.GEODATABASE.GETVERSIONMANAGER + // cref: ARCGIS.CORE.DATA.VERSION.GetParent + // cref: ARCGIS.CORE.DATA.VERSION.Connect + // cref: ARCGIS.CORE.DATA.VERSION.GetAccessType + // cref: ARCGIS.CORE.DATA.VERSION.GetName + // cref: ARCGIS.CORE.DATA.VERSION.GetChildren + // cref: ARCGIS.CORE.DATA.VersionAccessType #region Working with Versions - public async Task WorkingWithVersions() { - await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + { using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri("path\\to\\sde\\file")))) - using (VersionManager versionManager = geodatabase.GetVersionManager()) { + using (VersionManager versionManager = geodatabase.GetVersionManager()) + { IReadOnlyList versionList = versionManager.GetVersions(); //The default version will have a null Parent Version defaultVersion = versionList.First(version => version.GetParent() == null); - IEnumerable publicVersions = versionList.Where(version => version.GetAccessType() == VersionAccessType.Public); - Version qaVersion = defaultVersion.GetChildren().First(version => version.GetName().Contains("QA")); + IEnumerable publicVersions = versionList.Where( + version => version.GetAccessType() == VersionAccessType.Public); + Version qaVersion = defaultVersion.GetChildren().First( + version => version.GetName().Contains("QA")); Geodatabase qaVersionGeodatabase = qaVersion.Connect(); @@ -2107,11 +2470,12 @@ await ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { } }); } - #endregion Working with Versions + // cref: ARCGIS.CORE.DATA.VERSION.GETPAREN + // // cref: ARCGIS.CORE.DATA.Geodatabase.GetVersionManager + // cref: ARCGIS.CORE.DATA.VERSIONMANAGER.GETCURRENTVERSION #region Working with the Default Version - // Check to see if the current version is default. // Works with both branch and traditional versioning. public bool IsDefaultVersion(Version version) @@ -2171,12 +2535,11 @@ public Version GetDefaultVersion(Geodatabase geodatabase) return defaultVersion; } } + #endregion Working with the Default Version - - #endregion - + // cref: ARCGIS.CORE.DATA.VERSIONMANAGER.CREATEVERSION + // cref: ARCGIS.CORE.DATA.VERSIONDESCRIPTION #region Creating a Version - public Version CreateVersion(Geodatabase geodatabase, string versionName, string description, VersionAccessType versionAccessType) { if (!geodatabase.IsVersioningSupported()) return null; @@ -2187,44 +2550,125 @@ public Version CreateVersion(Geodatabase geodatabase, string versionName, string return versionManager.CreateVersion(versionDescription); } } - #endregion Creating a Version + // cref: ArcGIS.Core.Data.VersionManager.CreateHistoricalVersion + // cref: ArcGIS.Core.Data.HistoricalVersionDescription + // cref: ArcGIS.Core.Data.HistoricalVersion + #region Creating a Historical version + public HistoricalVersion CreateHistoricalVersion(Geodatabase geodatabase, string versionName) + { + using (VersionManager versionManager = geodatabase.GetVersionManager()) + { + HistoricalVersionDescription historicalVersionDescription = new HistoricalVersionDescription(versionName, DateTime.Now); + HistoricalVersion historicalVersion = versionManager.CreateHistoricalVersion(historicalVersionDescription); + + return historicalVersion; + } + } + #endregion Creating a Historical version + + // cref: ArcGIS.Desktop.Mapping.Map.ChangeVersion(ArcGIS.Core.Data.VersionBase,ArcGIS.Core.Data.VersionBase) + // cref: ArcGIS.Core.Data.VersionManager.GetCurrentVersionBaseType + // cref: ArcGIS.Core.Data.VersionManager.GetCurrentHistoricalVersion + // cref: ArcGIS.Core.Data.VersionManager.GetHistoricalVersion + // cref: ArcGIS.Core.Data.VersionBaseType + // cref: ArcGIS.Core.Data.HistoricalVersion + #region Switching between versions + public void ChangeVersions(Geodatabase geodatabase, string toVersionName) + { + using (VersionManager versionManager = geodatabase.GetVersionManager()) + { + VersionBaseType versionBaseType = versionManager.GetCurrentVersionBaseType(); + + if (versionBaseType == VersionBaseType.Version) + { + Version fromVersion = versionManager.GetCurrentVersion(); + Version toVersion = versionManager.GetVersion(toVersionName); + + // Switch between versions + MapView.Active.Map.ChangeVersion(fromVersion,toVersion); + } + + if (versionBaseType == VersionBaseType.HistoricalVersion) + { + HistoricalVersion fromHistoricalVersion = versionManager.GetCurrentHistoricalVersion(); + HistoricalVersion toHistoricalVersion = versionManager.GetHistoricalVersion(toVersionName); + + // Switch between historical versions + MapView.Active.Map.ChangeVersion(fromHistoricalVersion, toHistoricalVersion); + } + + // Switch from HistoricalVersion to Version and vice-versa + // MapView.Active.Map.ChangeVersion(fromHistoricalVersion, toVersion); + // MapView.Active.Map.ChangeVersion(fromVersion, toHistoricalVersion); + + } + } + #endregion Switching between versions + public void PartialPostingSnippet(Version designVersion, FeatureClass supportStructureFeatureClass, List deletedSupportStructureObjectIDs) { + // cref: ArcGIS.Core.Data.ReconcileOptions + // cref: ArcGIS.Core.Data.PostOptions + // cref: ArcGIS.Core.Data.PostOptions.PartialPostSelections + // cref: ArcGIS.Core.Data.Version.Reconcile(ArcGIS.Core.Data.ReconcileOptions,ArcGIS.Core.Data.PostOptions) #region Partial Posting - // Partial posting allows developers to post a subset of changes made in a version. One sample use case is an electric utility that uses a version to design the facilities in a new - // housing subdivision. At some point in the process, one block of new houses have been completed, while the rest of the subdivision remains unbuilt. Partial posting allows the user - // to post the completed work, while leaving not yet constructed features in the version to be posted later. - // Partial posting requires a branch-versioned feature service using ArcGIS Enterprise 10.9 and higher + // Partial posting allows developers to post a subset of changes made in a version. + // One sample use case is an electric utility that uses a version to design the facilities in + // a new housing subdivision. At some point in the process, one block of new houses have been + // completed, while the rest of the subdivision remains unbuilt. Partial posting allows the user + // to post the completed work, while leaving not yet constructed features in the version to be + // posted later. Partial posting requires a branch-versioned feature service using ArcGIS + // Enterprise 10.9 and higher // Specify a set of features that were constructed QueryFilter constructedFilter = new QueryFilter() { WhereClause = "ConstructedStatus = 'True'" }; - // This selection represents the inserts and updates to the support structure feature class that we wish to post - using (Selection constructedSupportStructures = supportStructureFeatureClass.Select(constructedFilter, SelectionType.ObjectID, SelectionOption.Normal)) - { - // Specifying which feature deletions you wish to post is slightly trickier, since you cannot issue a query to fetch a set of deleted features - // Instead, a list of ObjectIDs must be used - using (Selection deletedSupportStructures = supportStructureFeatureClass.Select(null, SelectionType.ObjectID, SelectionOption.Empty)) + // This selection represents the inserts and updates to the support + // structure feature class that we wish to post + using (Selection constructedSupportStructures = + supportStructureFeatureClass.Select( + constructedFilter, SelectionType.ObjectID, SelectionOption.Normal)) + { + // Specifying which feature deletions you wish to post is slightly trickier, since you cannot issue + // a query to fetch a set of deleted features Instead, a list of ObjectIDs must be used + using (Selection deletedSupportStructures = supportStructureFeatureClass.Select( + null, SelectionType.ObjectID, SelectionOption.Empty)) { - deletedSupportStructures.Add(deletedSupportStructureObjectIDs); // deletedSupportStructureObjectIDs is defined as List + deletedSupportStructures.Add(deletedSupportStructureObjectIDs); //deletedSupportStructureObjectIDs is + //defined as List //Perform the reconcile with partial post - - ReconcileDescription reconcileDescription = new ReconcileDescription(); - reconcileDescription.ConflictDetectionType = ConflictDetectionType.ByColumn; - reconcileDescription.ConflictResolutionMethod = ConflictResolutionMethod.Continue; - reconcileDescription.ConflictResolutionType = ConflictResolutionType.FavorEditVersion; - reconcileDescription.PartialPostSelections = new List() { constructedSupportStructures, deletedSupportStructures }; - reconcileDescription.WithPost = true; - - ReconcileResult reconcileResult = designVersion.Reconcile(reconcileDescription); + //At 2.x - + //ReconcileDescription reconcileDescription = new ReconcileDescription(); + //reconcileDescription.ConflictDetectionType = ConflictDetectionType.ByColumn; + //reconcileDescription.ConflictResolutionMethod = ConflictResolutionMethod.Continue; + //reconcileDescription.ConflictResolutionType = ConflictResolutionType.FavorEditVersion; + //reconcileDescription.PartialPostSelections = new List() { constructedSupportStructures, deletedSupportStructures }; + //reconcileDescription.WithPost = true; + + //ReconcileResult reconcileResult = designVersion.Reconcile(reconcileDescription); + + var reconcileOptions = new ReconcileOptions();//reconcile against Default + reconcileOptions.ConflictDetectionType = ConflictDetectionType.ByColumn; + reconcileOptions.ConflictResolutionMethod = ConflictResolutionMethod.Continue; + reconcileOptions.ConflictResolutionType = ConflictResolutionType.FavorEditVersion; + + var postOptions = new PostOptions();//post against Default + postOptions.PartialPostSelections = new List() { + constructedSupportStructures, deletedSupportStructures }; + postOptions.ServiceSynchronizationType = ServiceSynchronizationType.Synchronous; + + var reconcileResult = designVersion.Reconcile(reconcileOptions, postOptions); + + //TODO process result(s) } } + #endregion } @@ -2233,8 +2677,17 @@ public void PartialPostingSnippet(Version designVersion, FeatureClass supportStr public void CreateTableSnippet(Geodatabase geodatabase, CodedValueDomain inspectionResultsDomain) { - // cref: Creating a Table;ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.TableDescription) - // cref: Creating a Table;ArcGIS.Core.Data.DDL.TableDescription.#ctor(System.String,System.Collections.Generic.IReadOnlyList{ArcGIS.Core.Data.DDL.FieldDescription}) + + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.TableDescription) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Build + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.ErrorMessages + // ArcGIS.Core.Data.DDL.TableDescription.#ctor(System.String,IEnumerable{ArcGIS.Core.Data.DDL.FieldDescription}) + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateGlobalIDField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateObjectIDField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateDomainField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateStringField + // cref: ArcGIS.Core.Data.DDL.FieldDescription._ctor + // cref: ArcGIS.Core.Data.DDL.FieldDescription.AliasName #region Creating a Table // Create a PoleInspection table with the following fields @@ -2265,7 +2718,7 @@ public void CreateTableSnippet(Geodatabase geodatabase, CodedValueDomain inspect inspectionNotesFieldDescription.AliasName = "Inspection Notes"; // Assemble a list of all of our field descriptions - List fieldDescriptions = new List() + List fieldDescriptions = new List() { globalIDFieldDescription, objectIDFieldDescription, inspectionDateFieldDescription, inspectionResultsFieldDescription, inspectionNotesFieldDescription }; // Create a TableDescription object to describe the table to create @@ -2292,16 +2745,16 @@ public void CreateTableSnippet(Geodatabase geodatabase, CodedValueDomain inspect public void CreateFeatureClassSnippet(Geodatabase geodatabase, FeatureClass existingFeatureClass, SpatialReference spatialReference) { - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.FeatureClassDescription.#ctor(System.String,System.Collections.Generic.IReadOnlyList{ArcGIS.Core.Data.DDL.FieldDescription},ArcGIS.Core.Data.DDL.ShapeDescription) - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.FieldDescription.#ctor(System.String,ArcGIS.Core.Data.FieldType) - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.FieldDescription.CreateGlobalIDField - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.FieldDescription.CreateIntegerField(System.String) - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.FieldDescription.CreateObjectIDField - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.FieldDescription.CreateStringField(System.String,System.Int32) - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.SchemaBuilder.Build - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.FeatureClassDescription) - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.ShapeDescription.#ctor(ArcGIS.Core.Data.FeatureClassDefinition) - // cref: Creating a feature class;ArcGIS.Core.Data.DDL.ShapeDescription.#ctor(ArcGIS.Core.Geometry.GeometryType,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Data.DDL.FeatureClassDescription.#ctor(System.String,System.Collections.Generic.IEnumerable{ArcGIS.Core.Data.DDL.FieldDescription},ArcGIS.Core.Data.DDL.ShapeDescription) + // cref: ArcGIS.Core.Data.DDL.FieldDescription.#ctor(System.String,ArcGIS.Core.Data.FieldType) + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateGlobalIDField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateIntegerField(System.String) + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateObjectIDField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateStringField(System.String,System.Int32) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Build + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.FeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.ShapeDescription.#ctor(ArcGIS.Core.Data.FeatureClassDefinition) + // cref: ArcGIS.Core.Data.DDL.ShapeDescription.#ctor(ArcGIS.Core.Geometry.GeometryType,ArcGIS.Core.Geometry.SpatialReference) #region Creating a feature class // Create a Cities feature class with the following fields @@ -2333,7 +2786,8 @@ public void CreateFeatureClassSnippet(Geodatabase geodatabase, FeatureClass exis ShapeDescription alternativeShapeDescription = new ShapeDescription(existingFeatureClass.GetDefinition()); // Create a FeatureClassDescription object to describe the feature class to create - FeatureClassDescription featureClassDescription = new FeatureClassDescription("Cities", fieldDescriptions, shapeDescription); + FeatureClassDescription featureClassDescription = + new FeatureClassDescription("Cities", fieldDescriptions, shapeDescription); // Create a SchemaBuilder object SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); @@ -2356,6 +2810,8 @@ public void CreateFeatureClassSnippet(Geodatabase geodatabase, FeatureClass exis public void DeleteTableSnippet(Geodatabase geodatabase, Table table) { + // cref:ArcGIS.Core.Data.DDL.SchemaBuilder.Delete + // cref:ArcGIS.Core.Data.DDL.SchemaBuilder.Build #region Deleting a Table // Create a TableDescription object @@ -2375,6 +2831,8 @@ public void DeleteTableSnippet(Geodatabase geodatabase, Table table) public void DeleteFeatureClassSnippet(Geodatabase geodatabase, FeatureClass featureClass) { + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Delete + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Build #region Deleting a Feature Class // Create a FeatureClassDescription object @@ -2388,13 +2846,34 @@ public void DeleteFeatureClassSnippet(Geodatabase geodatabase, FeatureClass feat // Execute the DDL bool success = schemaBuilder.Build(); + #endregion + } + + public void OpenMemoryGeodatabase() + { + // cref: ArcGIS.Core.Data.MemoryConnectionProperties + // cref: ArcGIS.Core.Data.Geodatabase.#ctor(ArcGIS.Core.Data.MemoryConnectionProperties) + #region Opens a memory geodatabase + + // Connects to the default memory geodatabase, if exists otherwise throws exception + MemoryConnectionProperties memoryConnectionProperties = new MemoryConnectionProperties(); + + // Alternatively, connects to memory geodatabase named as 'InterimMemoryGeodatabase' + // MemoryConnectionProperties memoryConnectionProperties = new MemoryConnectionProperties("InterimMemoryGeodatabase"); + + // Opens the memory geodatabase + using (Geodatabase geodatabase = new Geodatabase(memoryConnectionProperties)) + { + // Use memory geodatabase + } #endregion } public void CreateMemoryGeodatabaseSnippet() { - // cref: Creating a memory Geodatabase;ArcGIS.Core.Data.DDL.SchemaBuilder.CreateGeodatabase(ArcGIS.Core.Data.MemoryConnectionProperties) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.CreateGeodatabase(ArcGIS.Core.Data.MemoryConnectionProperties) + // cref: ArcGIS.Core.Data.MemoryConnectionProperties #region Creating a memory Geodatabase // Create the memory connection properties to connect to default memory geodatabase @@ -2414,7 +2893,8 @@ public void CreateMemoryGeodatabaseSnippet() public void DeleteMemoryGeodatabaseSnippet() { - // cref: Deleting a memory Geodatabase;ArcGIS.Core.Data.DDL.SchemaBuilder.DeleteGeodatabase(ArcGIS.Core.Data.MemoryConnectionProperties) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.DeleteGeodatabase(ArcGIS.Core.Data.MemoryConnectionProperties) + // cref: ArcGIS.Core.Data.MemoryConnectionProperties #region Deleting a memory Geodatabase // Create the memory connection properties to connect to default memory geodatabase @@ -2428,13 +2908,16 @@ public void DeleteMemoryGeodatabaseSnippet() public void CreateFileGeodatabaseSnippet() { - // cref: Creating a File Geodatabase;ArcGIS.Core.Data.DDL.SchemaBuilder.CreateGeodatabase(ArcGIS.Core.Data.FileGeodatabaseConnectionPath) + // cref: ArcGIS.Core.Data.FileGeodatabaseConnectionPath + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.CreateGeodatabase(ArcGIS.Core.Data.FileGeodatabaseConnectionPath) #region Creating a File Geodatabase // Create a FileGeodatabaseConnectionPath with the name of the file geodatabase you wish to create - FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new FileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-File-Geodatabase\YourName.gdb")); + FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = + new FileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-File-Geodatabase\YourName.gdb")); // Create and use the file geodatabase - using (Geodatabase geodatabase = SchemaBuilder.CreateGeodatabase(fileGeodatabaseConnectionPath)) + using (Geodatabase geodatabase = + SchemaBuilder.CreateGeodatabase(fileGeodatabaseConnectionPath)) { // Create additional schema here } @@ -2443,7 +2926,8 @@ public void CreateFileGeodatabaseSnippet() public void DeleteFileGeodatabaseSnippet() { - // cref: Deleting a File Geodatabase;ArcGIS.Core.Data.DDL.SchemaBuilder.DeleteGeodatabase(ArcGIS.Core.Data.FileGeodatabaseConnectionPath) + // cref: ArcGIS.Core.Data.FileGeodatabaseConnectionPath + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.DeleteGeodatabase(ArcGIS.Core.Data.FileGeodatabaseConnectionPath) #region Deleting a File Geodatabase // Create a FileGeodatabaseConnectionPath with the name of the file geodatabase you wish to delete FileGeodatabaseConnectionPath fileGeodatabaseConnectionPath = new FileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-File-Geodatabase\YourName.gdb")); @@ -2456,11 +2940,13 @@ public void DeleteFileGeodatabaseSnippet() public void CreateMobileGeodatabase() { - // cref: Creating a Mobile Geodatabase;ArcGIS.Core.Data.DDL.SchemaBuilder.CreateGeodatabase(ArcGIS.Core.Data.MobileGeodatabaseConnectionPath) + // cref: ArcGIS.Core.Data.MobileGeodatabaseConnectionPath + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.CreateGeodatabase(ArcGIS.Core.Data.MobileGeodatabaseConnectionPath) #region Creating a Mobile Geodatabase // Create a MobileGeodatabaseConnectionPath with the name of the mobile geodatabase you wish to create - MobileGeodatabaseConnectionPath mobileGeodatabaseConnectionPath = new MobileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-Mobile-Geodatabase\YourName.geodatabase")); + MobileGeodatabaseConnectionPath mobileGeodatabaseConnectionPath = + new MobileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-Mobile-Geodatabase\YourName.geodatabase")); // Create and use the mobile geodatabase using (Geodatabase geodatabase = SchemaBuilder.CreateGeodatabase(mobileGeodatabaseConnectionPath)) @@ -2473,11 +2959,13 @@ public void CreateMobileGeodatabase() public void DeleteMobileGeodatabase() { - // cref: Deleting a Mobile Geodatabase;ArcGIS.Core.Data.DDL.SchemaBuilder.DeleteGeodatabase(ArcGIS.Core.Data.MobileGeodatabaseConnectionPath) + // cref: ArcGIS.Core.Data.MobileGeodatabaseConnectionPath + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.DeleteGeodatabase(ArcGIS.Core.Data.MobileGeodatabaseConnectionPath) #region Deleting a Mobile Geodatabase // Create a MobileGeodatabaseConnectionPath with the name of the mobile geodatabase you wish to delete - MobileGeodatabaseConnectionPath mobileGeodatabaseConnectionPath = new MobileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-Mobile-Geodatabase\YourName.geodatabase")); + MobileGeodatabaseConnectionPath mobileGeodatabaseConnectionPath = + new MobileGeodatabaseConnectionPath(new Uri(@"C:\Path-To-Mobile-Geodatabase\YourName.geodatabase")); // Delete the mobile geodatabase SchemaBuilder.DeleteGeodatabase(mobileGeodatabaseConnectionPath); @@ -2487,19 +2975,21 @@ public void DeleteMobileGeodatabase() public void CreateRangeDomainSnippet(Geodatabase geodatabase) { - // cref: Creating a Range domain;ArcGIS.Core.Data.DDL.RangeDomainDescription.#ctor(System.String,ArcGIS.Core.Data.FieldType,System.Object,System.Object) - // cref: Creating a Range domain;ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.RangeDomainDescription) + // cref: ArcGIS.Core.Data.DDL.RangeDomainDescription.#ctor(System.String,ArcGIS.Core.Data.FieldType,System.Object,System.Object) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.RangeDomainDescription) + // cref: ArcGIS.Core.Data.DDL.DomainDescription.Description + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Build #region Creating a Range domain - + // Create a range description with minimum value = 0 and maximum value = 1000 - RangeDomainDescription rangeDomainDescriptionMinMax = new RangeDomainDescription("RangeDomain_0_1000", - FieldType.Integer, 0, 1000) - { Description = "Domain value ranges from 0 to 1000" }; + RangeDomainDescription rangeDomainDescriptionMinMax = new RangeDomainDescription("RangeDomain_0_1000", + FieldType.Integer, 0, 1000) + { Description = "Domain value ranges from 0 to 1000" }; SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Create a range domain - schemaBuilder.Create(rangeDomainDescriptionMinMax); + schemaBuilder.Create(rangeDomainDescriptionMinMax); schemaBuilder.Build(); #endregion @@ -2507,13 +2997,18 @@ public void CreateRangeDomainSnippet(Geodatabase geodatabase) public void CreateCodedDomainSnippet(Geodatabase geodatabase) { - // cref: Creating a CodedValue domain;ArcGIS.Core.Data.DDL.CodedValueDomainDescription.#ctor(System.String,ArcGIS.Core.Data.FieldType,System.Collections.Generic.SortedList{System.Object,System.String}) - // cref: Creating a CodedValue domain;ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.CodedValueDomainDescription) + // cref: ArcGIS.Core.Data.DDL.CodedValueDomainDescription.#ctor(System.String,ArcGIS.Core.Data.FieldType,System.Collections.Generic.SortedList{System.Object,System.String}) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.CodedValueDomainDescription) + // cref: ArcGIS.Core.Data.DDL.DomainDescription.SplitPolicy + // cref: ArcGIS.Core.Data.DDL.DomainDescription.MergePolicy + // cref: ArcGIS.Core.Data.SplitPolicy + // cref: ArcGIS.Core.Data.MergePolicy + // cref: ArcGIS.Core.Data.DDL.CodedValueDomainToken #region Creating a CodedValue domain // Create a CodedValueDomain description for water pipes CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription("WaterPipeTypes", FieldType.String, - new SortedList { { "Copper", "C_1" }, + new SortedList { { "Copper", "C_1" }, { "Steel", "S_2" } }) { SplitPolicy = SplitPolicy.Duplicate, @@ -2532,8 +3027,8 @@ public void CreateCodedDomainSnippet(Geodatabase geodatabase) public void CreateFeatureDatasetSnippet(Geodatabase geodatabase) { - // cref: Creating a FeatureDataset;ArcGIS.Core.Data.DDL.FeatureDatasetDescription.#ctor(System.String,ArcGIS.Core.Geometry.SpatialReference) - // cref: Creating a FeatureDataset;ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.FeatureDatasetDescription) + // cref: ArcGIS.Core.Data.DDL.FeatureDatasetDescription.#ctor(System.String,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.FeatureDatasetDescription) #region Creating a FeatureDataset // Creating a FeatureDataset named as 'Parcel_Information' @@ -2541,7 +3036,8 @@ public void CreateFeatureDatasetSnippet(Geodatabase geodatabase) SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Create a FeatureDataset named as 'Parcel Information' - FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription("Parcel_Information", SpatialReferences.WGS84); + FeatureDatasetDescription featureDatasetDescription = + new FeatureDatasetDescription("Parcel_Information", SpatialReferences.WGS84); schemaBuilder.Create(featureDatasetDescription); // Build status @@ -2558,14 +3054,16 @@ public void CreateFeatureDatasetSnippet(Geodatabase geodatabase) public void DeleteFeatureDatasetSnippet(Geodatabase geodatabase) { - // cref: Deleting a FeatureDataset;ArcGIS.Core.Data.DDL.SchemaBuilder.Delete(ArcGIS.Core.Data.DDL.Description) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Delete(ArcGIS.Core.Data.DDL.Description) + // cref: ArcGIS.Core.Data.FeatureDatasetDefinition #region Deleting a FeatureDataset // Deleting a FeatureDataset named as 'Parcel_Information' FeatureDatasetDefinition featureDatasetDefinition = geodatabase.GetDefinition("Parcel_Information"); - FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetDefinition); - + FeatureDatasetDescription featureDatasetDescription = + new FeatureDatasetDescription(featureDatasetDefinition); + SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Delete an existing feature dataset named as 'Parcel_Information' @@ -2577,6 +3075,7 @@ public void DeleteFeatureDatasetSnippet(Geodatabase geodatabase) public void RenameFeatureDatasetSnippet(Geodatabase geodatabase) { + // cref:ArcGIS.Core.Data.DDL.SchemaBuilder.Rename #region Renaming a FeatureDataset // Renaming a FeatureDataset from 'Parcel_Information' to 'Parcel_Information_With_Tax_Jurisdiction' @@ -2584,21 +3083,28 @@ public void RenameFeatureDatasetSnippet(Geodatabase geodatabase) string originalDatasetName = "Parcel_Information"; string datasetRenameAs = "Parcel_Information_With_Tax_Jurisdiction"; - FeatureDatasetDefinition originalDatasetDefinition = geodatabase.GetDefinition(originalDatasetName); - FeatureDatasetDescription originalFeatureDatasetDescription = new FeatureDatasetDescription(originalDatasetDefinition); + FeatureDatasetDefinition originalDatasetDefinition = + geodatabase.GetDefinition(originalDatasetName); + FeatureDatasetDescription originalFeatureDatasetDescription = + new FeatureDatasetDescription(originalDatasetDefinition); SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Rename the existing FeatureDataset, 'Parcel_Information' to 'Parcel_Information_With_Tax_Jurisdiction' schemaBuilder.Rename(originalFeatureDatasetDescription, datasetRenameAs); schemaBuilder.Build(); - #endregion } public void CreateFeatureDatasetWithFeatureClassSnippet(Geodatabase geodatabase) { - // cref: Creating a FeatureDataset with a FeatureClass in one operation;ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.FeatureDatasetDescription,ArcGIS.Core.Data.DDL.FeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.FeatureDatasetDescription,ArcGIS.Core.Data.DDL.FeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.FeatureDatasetToken + // cref: ArcGIS.Core.Data.DDL.FeatureClassDescription + // cref: ArcGIS.Core.Data.DDL.FieldDescription + // cref: ArcGIS.Core.Data.DDL.ShapeDescription + // cref: ArcGIS.Core.Data.DDL.FeatureClassToken + // cref: ArcGIS.Core.Data.FieldType #region Creating a FeatureDataset with a FeatureClass in one operation // Creating a FeatureDataset named as 'Parcel_Information' and a FeatureClass with name 'Parcels' in one operation @@ -2613,35 +3119,39 @@ public void CreateFeatureDatasetWithFeatureClassSnippet(Geodatabase geodatabase) FeatureDatasetToken featureDatasetToken = schemaBuilder.Create(featureDatasetDescription); // Create a FeatureClass description - FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassName, + FeatureClassDescription featureClassDescription = new FeatureClassDescription(featureClassName, new List() { new FieldDescription("Id", FieldType.Integer), new FieldDescription("Address", FieldType.String) - }, + }, new ShapeDescription(GeometryType.Point, SpatialReferences.WGS84)); - // Create a FeatureClass inside a FeatureDataset - FeatureClassToken featureClassToken = schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetToken), featureClassDescription); + // Create a FeatureClass inside a FeatureDataset + FeatureClassToken featureClassToken = schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetToken), featureClassDescription); - // Build status - bool buildStatus = schemaBuilder.Build(); + // Build status + bool buildStatus = schemaBuilder.Build(); - // Build errors - if (!buildStatus) - { - IReadOnlyList errors = schemaBuilder.ErrorMessages; - } + // Build errors + if (!buildStatus) + { + IReadOnlyList errors = schemaBuilder.ErrorMessages; + } - #endregion + #endregion } public void CreateFeatureClassInsideFeatureDatasetSnippet(Geodatabase geodatabase) { + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.FeatureDatasetDescription,ArcGIS.Core.Data.DDL.FeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.FeatureClassDescription + // cref: ArcGIS.Core.Data.DDL.FieldDescription + // cref: ArcGIS.Core.Data.DDL.ShapeDescription + // cref: ArcGIS.Core.Data.FieldType #region Creating a FeatureClass in existing FeatureDataset // Creating a FeatureClass named as 'Tax_Jurisdiction' in existing FeatureDataset with name 'Parcels_Information' - string featureDatasetName = "Parcels_Information"; string featureClassName = "Tax_Jurisdiction"; @@ -2669,13 +3179,12 @@ public void CreateFeatureClassInsideFeatureDatasetSnippet(Geodatabase geodatabas { IReadOnlyList errors = schemaBuilder.ErrorMessages; } - #endregion } - + public void AddFeatureClassToFeatureDatasetSnippet(Geodatabase geodatabase) { - // cref: Adding a FeatureClass to a FeatureDataset;ArcGIS.Core.Data.DDL.SchemaBuilder.AddFeatureClass(ArcGIS.Core.Data.DDL.FeatureDatasetDescription,ArcGIS.Core.Data.DDL.FeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.AddFeatureClass(ArcGIS.Core.Data.DDL.FeatureDatasetDescription,ArcGIS.Core.Data.DDL.FeatureClassDescription) #region Adding a FeatureClass to a FeatureDataset // Adding a FeatureClass with name 'Tax_Jurisdiction' into a FeatureDataset named as 'Parcels_Information' @@ -2705,9 +3214,10 @@ public void AddFeatureClassToFeatureDatasetSnippet(Geodatabase geodatabase) public void RenameTableSnippet(Geodatabase geodatabase) { - // cref: Renaming a Table;ArcGIS.Core.Data.DDL.SchemaBuilder.Rename(ArcGIS.Core.Data.DDL.Description,System.String) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Rename(ArcGIS.Core.Data.DDL.Description,System.String) + // cref: ArcGIS.Core.Data.DDL.TableDescription #region Renaming a Table - + //Renaming a table from 'Original_Table' to 'Renamed_Table' string tableToBeRenamed = "Original_Table"; @@ -2723,24 +3233,28 @@ public void RenameTableSnippet(Geodatabase geodatabase) #endregion } - + public void AddFieldsInFeatureClassSnippet(Geodatabase geodatabase) { - // cref: Adding fields to a FeatureClass;ArcGIS.Core.Data.DDL.SchemaBuilder.Modify(ArcGIS.Core.Data.DDL.FeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Modify(ArcGIS.Core.Data.DDL.FeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateGlobalIDField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateIntegerField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateStringField #region Adding fields to a FeatureClass - + // Adding following fields to the 'Parcels' FeatureClass // Global ID // Parcel_ID // Tax_Code // Parcel_Address - + // The FeatureClass to add fields string featureClassName = "Parcels"; FeatureClassDefinition originalFeatureClassDefinition = geodatabase.GetDefinition(featureClassName); - FeatureClassDescription originalFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDefinition); + FeatureClassDescription originalFeatureClassDescription = new + FeatureClassDescription(originalFeatureClassDefinition); // The four new fields to add on the 'Parcels' FeatureClass FieldDescription globalIdField = FieldDescription.CreateGlobalIDField(); @@ -2748,7 +3262,7 @@ public void AddFieldsInFeatureClassSnippet(Geodatabase geodatabase) FieldDescription taxCodeDescription = FieldDescription.CreateIntegerField("Tax_Code"); FieldDescription addressDescription = FieldDescription.CreateStringField("Parcel_Address", 150); - List fieldsToAdd = new List { globalIdField, parcelIdDescription, + List fieldsToAdd = new List { globalIdField, parcelIdDescription, taxCodeDescription, addressDescription }; // Add new fields on the new FieldDescription list @@ -2775,7 +3289,12 @@ public void AddFieldsInFeatureClassSnippet(Geodatabase geodatabase) public void AddFieldWithDomainSnippet(Geodatabase geodatabase) { - // cref: Adding a Field that uses a domain;ArcGIS.Core.Data.DDL.FieldDescription.CreateDomainField(System.String,ArcGIS.Core.Data.DDL.DomainDescription) + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateDomainField(System.String,ArcGIS.Core.Data.DDL.DomainDescription) + // cref: ArcGIS.Core.Data.DDL.CodedValueDomainToken + // cref: ArcGIS.Core.Data.DDL.CodedValueDomainDescription + // cref: ArcGIS.Core.Data.DDL.FieldDescription.DomainDescription + // cref: ArcGIS.Core.Data.DDL.FeatureClassDescription + // cref: ArcGIS.Core.Data.DDL.FeatureClassDescription.ShapeDescription #region Adding a Field that uses a domain // Adding a field,'PipeType', which uses the coded value domain to the 'Pipes' FeatureClass @@ -2786,7 +3305,8 @@ public void AddFieldWithDomainSnippet(Geodatabase geodatabase) SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); // Create a CodedValueDomain description for water pipes - CodedValueDomainDescription pipeDomainDescription = new CodedValueDomainDescription("WaterPipeTypes", FieldType.String, + CodedValueDomainDescription pipeDomainDescription = + new CodedValueDomainDescription("WaterPipeTypes", FieldType.String, new SortedList { { "Copper", "C_1" }, { "Steel", "S_2" } }) { @@ -2806,14 +3326,16 @@ public void AddFieldWithDomainSnippet(Geodatabase geodatabase) //Retrieve existing information for 'Pipes' FeatureClass FeatureClassDefinition originalFeatureClassDefinition = geodatabase.GetDefinition(featureClassName); - FeatureClassDescription originalFeatureClassDescription = new FeatureClassDescription(originalFeatureClassDefinition); + FeatureClassDescription originalFeatureClassDescription = + new FeatureClassDescription(originalFeatureClassDefinition); // Add domain field on existing fields List modifiedFieldDescriptions = new List(originalFeatureClassDescription.FieldDescriptions) { domainFieldDescription }; // Create a new description with updated fields for 'Pipes' FeatureClass - FeatureClassDescription featureClassDescription = new FeatureClassDescription(originalFeatureClassDescription.Name, modifiedFieldDescriptions, - originalFeatureClassDescription.ShapeDescription); + FeatureClassDescription featureClassDescription = + new FeatureClassDescription(originalFeatureClassDescription.Name, modifiedFieldDescriptions, + originalFeatureClassDescription.ShapeDescription); // Update the 'Pipes' FeatureClass with domain field schemaBuilder.Modify(featureClassDescription); @@ -2833,13 +3355,16 @@ public void AddFieldWithDomainSnippet(Geodatabase geodatabase) public void RemoveFieldTableSnippet(Geodatabase geodatabase) { - // cref: Removing fields from a Table;ArcGIS.Core.Data.DDL.SchemaBuilder.Modify(ArcGIS.Core.Data.DDL.TableDescription) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Modify(ArcGIS.Core.Data.DDL.TableDescription) + // cref: ArcGIS.Core.Data.Table.GetFields + // cref: ArcGIS.Core.Data.DDL.FieldDescription + // cref: ArcGIS.Core.Data.DDL.TableDescription #region Removing fields from a Table // Removing all fields from 'Parcels' table except following // Tax_Code // Parcel_Address - + // The table to remove fields string tableName = "Parcels"; @@ -2853,11 +3378,11 @@ public void RemoveFieldTableSnippet(Geodatabase geodatabase) FieldDescription taxFieldDescription = new FieldDescription(taxCodeField); FieldDescription parcelAddressFieldDescription = new FieldDescription(parcelAddressField); - + // Fields to retain in modified table - List fieldsToBeRetained =new List() + List fieldsToBeRetained = new List() { - taxFieldDescription, parcelAddressFieldDescription + taxFieldDescription, parcelAddressFieldDescription }; // New description of the 'Parcels' table with the 'Tax_Code' and 'Parcel_Address' fields @@ -2875,7 +3400,30 @@ public void RemoveFieldTableSnippet(Geodatabase geodatabase) public void CreateStandAloneAnnotationFeatureClass(Geodatabase geodatabase, SpatialReference spatialReference) { - // cref: Creating an annotation feature class;ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.#ctor(System.String,System.Collections.Generic.IReadOnlyList{ArcGIS.Core.Data.DDL.FieldDescription},ArcGIS.Core.Data.DDL.ShapeDescription,ArcGIS.Core.CIM.CIMGeneralPlacementProperties,System.Collections.Generic.List{ArcGIS.Core.CIM.CIMLabelClass}) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.#ctor(System.String,IEnumerable{ArcGIS.Core.Data.DDL.FieldDescription},ArcGIS.Core.Data.DDL.ShapeDescription,ARCGIS.CORE.CIM.CIMGENERALPLACEMENTPROPERTIES,IEnumerable{ArcGIS.Core.CIM.CIMLabelClass}) + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateGlobalIDField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateStringField + // cref: ArcGIS.Core.Data.DDL.ShapeDescription + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.AllowBorderOverlap + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.PlacementQuality + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.DrawUnplacedLabels + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.InvertedLabelTolerance + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.RotateLabelWithDisplay + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.UnplacedLabelColor + // cref: ArcGIS.Core.CIM.MaplexQualityType + // cref: ArcGIS.Core.CIM.CIMLabelClass + // cref: ArcGIS.Core.CIM.LabelExpressionEngine + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties.AllowOverlappingLabels + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties.LineOffset + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.AlignLabelToLineDirection + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.AvoidPolygonHoles + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsAutoCreate + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsSymbolIDRequired + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsUpdatedOnShapeChange #region Creating an annotation feature class // Creating a Cities annotation feature class @@ -3059,7 +3607,30 @@ public void CreateStandAloneAnnotationFeatureClass(Geodatabase geodatabase, Spat public void CreateFeatureLinkedAnnotationFeatureClass(Geodatabase geodatabase, SpatialReference spatialReference) { - // cref: Creating a feature-linked annotation feature class;ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.#ctor(System.String,System.Collections.Generic.IReadOnlyList{ArcGIS.Core.Data.DDL.FieldDescription},ArcGIS.Core.Data.DDL.ShapeDescription,ArcGIS.Core.CIM.CIMGeneralPlacementProperties,System.Collections.Generic.List{ArcGIS.Core.CIM.CIMLabelClass},ArcGIS.Core.Data.DDL.FeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.#ctor(System.String,IEnumerable{ArcGIS.Core.Data.DDL.FieldDescription},ArcGIS.Core.Data.DDL.ShapeDescription,ARCGIS.CORE.CIM.CIMGENERALPLACEMENTPROPERTIES,IEnumerable{ArcGIS.Core.CIM.CIMLabelClass}) + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateGlobalIDField + // cref: ArcGIS.Core.Data.DDL.FieldDescription.CreateStringField + // cref: ArcGIS.Core.Data.DDL.ShapeDescription + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.AllowBorderOverlap + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.PlacementQuality + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.DrawUnplacedLabels + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.InvertedLabelTolerance + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.RotateLabelWithDisplay + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.UnplacedLabelColor + // cref: ArcGIS.Core.CIM.MaplexQualityType + // cref: ArcGIS.Core.CIM.CIMLabelClass + // cref: ArcGIS.Core.CIM.LabelExpressionEngine + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties.AllowOverlappingLabels + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties.LineOffset + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.AlignLabelToLineDirection + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.AvoidPolygonHoles + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsAutoCreate + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsSymbolIDRequired + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsUpdatedOnShapeChange #region Creating a feature-linked annotation feature class // Creating a feature-linked annotation feature class between water pipe and valve in water distribution network @@ -3093,7 +3664,7 @@ public void CreateFeatureLinkedAnnotationFeatureClass(Geodatabase geodatabase, S R = 255, G = 0, B = 0, - Alpha = 0.5f + Alpha = 0.5f } }; @@ -3212,7 +3783,7 @@ public void CreateFeatureLinkedAnnotationFeatureClass(Geodatabase geodatabase, S // Create a linked feature class description FeatureClassDescription linkedFeatureClassDescription = new FeatureClassDescription(linkedFeatureClassName, pipeFieldDescriptions, new ShapeDescription(GeometryType.Polyline, spatialReference)); - + // Create a SchemaBuilder object SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase); @@ -3247,11 +3818,17 @@ public void CreateFeatureLinkedAnnotationFeatureClass(Geodatabase geodatabase, S public void CreateAnnotationFeatureClassUsingExistingAnnotationFeatureClassInDataset(Geodatabase geodatabase) { - // cref: Creating an annotation feature class inside feature dataset;ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.#ctor(ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition) + // cref: ArcGIS.Core.Data.DDL.SchemaBuilder.Create(ArcGIS.Core.Data.DDL.FeatureDatasetDescription,ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription) + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.#ctor(System.String, ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition) + // cref: ArcGIS.Core.Data.DDL.FeatureDatasetDescription + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsAutoCreate + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsSymbolIDRequired + // cref: ArcGIS.Core.Data.DDL.AnnotationFeatureClassDescription.IsUpdatedOnShapeChange #region Creating an annotation feature class inside feature dataset // Create a Cities annotation feature class inside Places feature dataset using existing annotation feature class - + // Feature dataset name string featureDatasetName = "Places"; @@ -3266,7 +3843,8 @@ public void CreateAnnotationFeatureClassUsingExistingAnnotationFeatureClassInDat { // Create Feature dataset description - FeatureDatasetDescription featureDatasetDescription = new FeatureDatasetDescription(featureDatasetName, existingAnnotationFeatureClass.GetDefinition().GetSpatialReference()); + FeatureDatasetDescription featureDatasetDescription = + new FeatureDatasetDescription(featureDatasetName, existingAnnotationFeatureClass.GetDefinition().GetSpatialReference()); // Add the creation of the Places dataset to DDL task FeatureDatasetToken featureDatasetToken = schemaBuilder.Create(featureDatasetDescription); @@ -3280,7 +3858,7 @@ public void CreateAnnotationFeatureClassUsingExistingAnnotationFeatureClassInDat }; // Add the creation of the Cities annotation feature class inside Places feature dataset - schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetToken) , annotationFeatureClassDescription); + schemaBuilder.Create(new FeatureDatasetDescription(featureDatasetToken), annotationFeatureClassDescription); // Execute the DDL bool success = schemaBuilder.Build(); @@ -3294,6 +3872,5 @@ public void CreateAnnotationFeatureClassUsingExistingAnnotationFeatureClassInDat } #endregion } - } } diff --git a/Examples/Geodatabase/RelationshipClass/RelationshipClassCreateRelationship.cs b/Examples/Geodatabase/RelationshipClass/RelationshipClassCreateRelationship.cs index aa48dba..8fedc46 100644 --- a/Examples/Geodatabase/RelationshipClass/RelationshipClassCreateRelationship.cs +++ b/Examples/Geodatabase/RelationshipClass/RelationshipClassCreateRelationship.cs @@ -134,7 +134,7 @@ public async Task MainMethodCode() { Relationship failingRelationship = relationshipClass.CreateRelationship(overviewRowWithoutPKValue, projectsRow); } - catch (GeodatabaseRelationshipClassException exception) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseRelationshipClassException exception) { // This will have a message "Unable to obtain origin primary key value.". So, the origin row needs to have the origin *primary* // key value referenced by the origin *foreign* key value in the RelationshipClass. diff --git a/Examples/Geodatabase/RelationshipClass/RelationshipClassDeleteRelationship.cs b/Examples/Geodatabase/RelationshipClass/RelationshipClassDeleteRelationship.cs index ec8040d..ceb3bcc 100644 --- a/Examples/Geodatabase/RelationshipClass/RelationshipClassDeleteRelationship.cs +++ b/Examples/Geodatabase/RelationshipClass/RelationshipClassDeleteRelationship.cs @@ -133,7 +133,7 @@ public async Task MainMethodCode() { relationshipClass.DeleteRelationship(jeffersoneAveViolation, relatedDestinationRow); } - catch (GeodatabaseRelationshipClassException exception) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseRelationshipClassException exception) { Console.WriteLine(exception); } diff --git a/Examples/Geodatabase/Row/RowOriginalValue.cs b/Examples/Geodatabase/Row/RowOriginalValue.cs index 26754e9..276165b 100644 --- a/Examples/Geodatabase/Row/RowOriginalValue.cs +++ b/Examples/Geodatabase/Row/RowOriginalValue.cs @@ -1,3 +1,5 @@ +/// cref: ArcGIS.Core.Data.AttributedRelationship.FindField(System.String) +#region RowOriginValue /* Copyright 2018 Esri @@ -88,7 +90,7 @@ private static async Task EnterpriseGeodabaseWorkFlow() DatabaseConnectionProperties connectionProperties = new DatabaseConnectionProperties(EnterpriseDatabaseType.SQLServer) { AuthenticationMode = AuthenticationMode.DBMS, - + // Where testMachine is the machine where the instance is running and testInstance is the name of the SqlServer instance. Instance = @"testMachine\testInstance", @@ -96,13 +98,13 @@ private static async Task EnterpriseGeodabaseWorkFlow() Database = "LocalGovernment", // Provided that a login called gdb has been created and corresponding schema has been created with the required permissions. - User = "gdb", + User = "gdb", Password = "password", - Version = "dbo.DEFAULT" + Version = "dbo.DEFAULT" }; using (Geodatabase geodatabase = new Geodatabase((connectionProperties))) - using (Table enterpriseTable = geodatabase.OpenDataset
("LocalGovernment.GDB.piCIPCost")) + using (Table enterpriseTable = geodatabase.OpenDataset
("LocalGovernment.GDB.piCIPCost")) { EditOperation editOperation = new EditOperation(); editOperation.Callback(context => @@ -156,7 +158,7 @@ private static async Task EnterpriseGeodabaseWorkFlow() private static async Task FileGeodatabaseWorkFlow() { using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb")))) - using (FeatureClass featureClass = fileGeodatabase.OpenDataset("PollingPlace")) + using (FeatureClass featureClass = fileGeodatabase.OpenDataset("PollingPlace")) { EditOperation editOperation = new EditOperation(); editOperation.Callback(context => @@ -182,7 +184,7 @@ private static async Task FileGeodatabaseWorkFlow() // Has to be called before any changes are made to the row context.Invalidate(feature); - MapPoint newShape = new MapPointBuilder(mapPoint.X + 10, mapPoint.Y, mapPoint.SpatialReference).ToGeometry(); + MapPoint newShape = new MapPointBuilderEx(mapPoint.X + 10, mapPoint.Y, mapPoint.SpatialReference).ToGeometry(); feature.SetShape(newShape); // Will be the same as feature.GetShape(). @@ -207,4 +209,5 @@ private static async Task FileGeodatabaseWorkFlow() } } } -} \ No newline at end of file +} +#endregion \ No newline at end of file diff --git a/Examples/Geodatabase/Row/RowValueChanged.cs b/Examples/Geodatabase/Row/RowValueChanged.cs index a6e72c5..93f6bac 100644 --- a/Examples/Geodatabase/Row/RowValueChanged.cs +++ b/Examples/Geodatabase/Row/RowValueChanged.cs @@ -184,7 +184,7 @@ private static async Task FileGeodatabaseWorkFlow() // Has to be called before any changes are made to the row context.Invalidate(feature); - MapPoint newShape = new MapPointBuilder(mapPoint.X + 10, mapPoint.Y, mapPoint.SpatialReference).ToGeometry(); + MapPoint newShape = new MapPointBuilderEx(mapPoint.X + 10, mapPoint.Y, mapPoint.SpatialReference).ToGeometry(); feature.SetShape(newShape); // Will be true. diff --git a/Examples/Geodatabase/Selection/SelectionAdd.cs b/Examples/Geodatabase/Selection/SelectionAdd.cs index adba93d..aa3f14f 100644 --- a/Examples/Geodatabase/Selection/SelectionAdd.cs +++ b/Examples/Geodatabase/Selection/SelectionAdd.cs @@ -122,7 +122,7 @@ public void MainMethodCode() // Using SpatialQueryFilter with Selection.Select. SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { - FilterGeometry = new PolygonBuilder(new List + FilterGeometry = new PolygonBuilderEx(new List { new Coordinate2D(1021880, 1867396), new Coordinate2D(1028223, 1870705), @@ -137,7 +137,7 @@ public void MainMethodCode() //Another SpatialQueryFilter SpatialQueryFilter anotherSpatialQueryFilter = new SpatialQueryFilter { - FilterGeometry = new PolygonBuilder(new List + FilterGeometry = new PolygonBuilderEx(new List { new Coordinate2D(1015106, 1829421), new Coordinate2D(1013413, 1834760), diff --git a/Examples/Geodatabase/Selection/SelectionCombine.cs b/Examples/Geodatabase/Selection/SelectionCombine.cs index ecae975..35c85df 100644 --- a/Examples/Geodatabase/Selection/SelectionCombine.cs +++ b/Examples/Geodatabase/Selection/SelectionCombine.cs @@ -84,7 +84,7 @@ public void MainMethodCode() { SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { - FilterGeometry = new PolygonBuilder(new List + FilterGeometry = new PolygonBuilderEx(new List { new Coordinate2D(1021880, 1867396), new Coordinate2D(1028223, 1870705), diff --git a/Examples/Geodatabase/Selection/SelectionRemove.cs b/Examples/Geodatabase/Selection/SelectionRemove.cs index 561511e..5a449c8 100644 --- a/Examples/Geodatabase/Selection/SelectionRemove.cs +++ b/Examples/Geodatabase/Selection/SelectionRemove.cs @@ -117,7 +117,7 @@ public void MainMethodCode() // Using SpatialQueryFilter with Selection.Select. SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { - FilterGeometry = new PolygonBuilder(new List + FilterGeometry = new PolygonBuilderEx(new List { new Coordinate2D(1021880, 1867396), new Coordinate2D(1028223, 1870705), diff --git a/Examples/Geodatabase/Selection/SelectionSearch.cs b/Examples/Geodatabase/Selection/SelectionSearch.cs index 30e4ae0..ab5d117 100644 --- a/Examples/Geodatabase/Selection/SelectionSearch.cs +++ b/Examples/Geodatabase/Selection/SelectionSearch.cs @@ -127,7 +127,7 @@ public void MainMethodCode() // Using SpatialQueryFilter with Selection.Search. SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { - FilterGeometry = new PolygonBuilder(new List + FilterGeometry = new PolygonBuilderEx(new List { new Coordinate2D(1021880, 1867396), new Coordinate2D(1028223, 1870705), diff --git a/Examples/Geodatabase/Selection/SelectionSelect.cs b/Examples/Geodatabase/Selection/SelectionSelect.cs index 0e1f693..860a00f 100644 --- a/Examples/Geodatabase/Selection/SelectionSelect.cs +++ b/Examples/Geodatabase/Selection/SelectionSelect.cs @@ -127,7 +127,7 @@ public void MainMethodCode() // Using SpatialQueryFilter with Selection.Select. SpatialQueryFilter spatialQueryFilter = new SpatialQueryFilter { - FilterGeometry = new PolygonBuilder(new List + FilterGeometry = new PolygonBuilderEx(new List { new Coordinate2D(1021880, 1867396), new Coordinate2D(1028223, 1870705), diff --git a/Examples/Geodatabase/Table/TableCreateRow.cs b/Examples/Geodatabase/Table/TableCreateRow.cs index b775dcb..ee249bd 100644 --- a/Examples/Geodatabase/Table/TableCreateRow.cs +++ b/Examples/Geodatabase/Table/TableCreateRow.cs @@ -132,7 +132,7 @@ private static async Task EnterpriseGeodabaseWorkFlow() // Do some other processing with the row. } - catch (GeodatabaseException exObj) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseException exObj) { Console.WriteLine(exObj); } @@ -192,7 +192,7 @@ private static async Task FileGeodatabaseWorkFlow() // Do some other processing with the row. } - catch (GeodatabaseException exObj) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseException exObj) { Console.WriteLine(exObj); } diff --git a/Examples/Geodatabase/Table/TableSearch.cs b/Examples/Geodatabase/Table/TableSearch.cs index f8ea1e1..0fb8ac6 100644 --- a/Examples/Geodatabase/Table/TableSearch.cs +++ b/Examples/Geodatabase/Table/TableSearch.cs @@ -225,7 +225,7 @@ private List GetRowListFor(Table table, QueryFilter queryFilter) } } } - catch (GeodatabaseFieldException fieldException) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseFieldException fieldException) { // One of the fields in the where clause might not exist. There are multiple ways this can be handled: // 1. You could rethrow the exception to bubble up to the caller after some debug or info logging @@ -256,7 +256,7 @@ private static Table OpenTable(Geodatabase geodatabase, string tableName) { table = geodatabase.OpenDataset
(tableName); } - catch (GeodatabaseCatalogDatasetException exception) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseCatalogDatasetException exception) { // logger.Error(exception.Message); return null; diff --git a/Examples/Geodatabase/Table/TableSelect.cs b/Examples/Geodatabase/Table/TableSelect.cs index 46fbca6..c2cbf44 100644 --- a/Examples/Geodatabase/Table/TableSelect.cs +++ b/Examples/Geodatabase/Table/TableSelect.cs @@ -85,7 +85,7 @@ public void MainMethodCode() using (Selection selection = table.Select(queryFilter, SelectionType.ObjectID, SelectionOption.Normal)) { //Number of records that match the QueryFilter criteria - int numberOfMatchingRecords = selection.GetCount(); + long numberOfMatchingRecords = selection.GetCount(); //The objectIDs which match the QueryFilter criteria IReadOnlyList readOnlyList = selection.GetObjectIDs(); @@ -121,7 +121,7 @@ public void MainMethodCode() using (Selection onlyOneSelection = enterpriseTable.Select(anotherQueryFilter, SelectionType.ObjectID, SelectionOption.OnlyOne)) { // This will always be one. - int singleRecordCount = onlyOneSelection.GetCount(); + long singleRecordCount = onlyOneSelection.GetCount(); // This will always have one record. IReadOnlyList listWithOneValue = onlyOneSelection.GetObjectIDs(); @@ -130,7 +130,7 @@ public void MainMethodCode() using (Selection emptySelection = enterpriseTable.Select(anotherQueryFilter, SelectionType.ObjectID, SelectionOption.Empty)) { //This will always be zero. - int zeroCount = emptySelection.GetCount(); + long zeroCount = emptySelection.GetCount(); //This will always have zero record. IReadOnlyList emptyList = emptySelection.GetObjectIDs(); @@ -140,7 +140,7 @@ public void MainMethodCode() using (Selection allRecordSelection = enterpriseTable.Select(null, SelectionType.ObjectID, SelectionOption.Normal)) { //This will give the count of records in a table - int numberOfRecordsInATable = allRecordSelection.GetCount(); + long numberOfRecordsInATable = allRecordSelection.GetCount(); } } } diff --git a/Examples/Geodatabase/Table/TableValidate.cs b/Examples/Geodatabase/Table/TableValidate.cs index 0eee8ad..9fda023 100644 --- a/Examples/Geodatabase/Table/TableValidate.cs +++ b/Examples/Geodatabase/Table/TableValidate.cs @@ -174,7 +174,7 @@ public void MainMethodCode() invalidRowObjectID = row.GetObjectID(); } - catch (GeodatabaseException exObj) + catch (ArcGIS.Core.Data.Exceptions.GeodatabaseException exObj) { Console.WriteLine(exObj); } diff --git a/Examples/Geodatabase/Topology/ProSnippetTopology.cs b/Examples/Geodatabase/Topology/ProSnippetTopology.cs index c98b9a5..a0c5f40 100644 --- a/Examples/Geodatabase/Topology/ProSnippetTopology.cs +++ b/Examples/Geodatabase/Topology/ProSnippetTopology.cs @@ -29,8 +29,12 @@ namespace GeodatabaseSDK.Topo { class ProSnippetTopology { - // cref: OpenTopologyAndProcessDefinition;ArcGIS.Core.Data.Topology.Topology.GetDefinition - // cref: OpenTopologyAndProcessDefinition;ArcGIS.Core.Data.Topology.TopologyDefinition.GetFeatureClassNames + // cref: ArcGIS.Core.Data.Topology.Topology + // cref: ArcGIS.Core.Data.Topology.Topology.GetDefinition + // cref: ArcGIS.Core.Data.Topology.TopologyDefinition + // cref: ArcGIS.Core.Data.Topology.TopologyDefinition.GetFeatureClassNames + // cref: ArcGIS.Core.Data.Topology.TopologyDefinition.GetClusterTolerance + // cref: ArcGIS.Core.Data.Topology.TopologyDefinition.GetZClusterTolerance #region OpenTopologyAndProcessDefinition public void OpenTopologyAndProcessDefinition() @@ -64,7 +68,8 @@ private void ProcessDefinition(Geodatabase geodatabase, Topology topology) OutputDefinition(geodatabase, definitionViaTopology); } - using (TopologyDefinition definitionViaGeodatabase = geodatabase.GetDefinition("Backcountry_Topology")) + using (TopologyDefinition definitionViaGeodatabase = + geodatabase.GetDefinition("Backcountry_Topology")) { OutputDefinition(geodatabase, definitionViaGeodatabase); } @@ -97,7 +102,14 @@ public void GetTopologyRules() using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\TestData\GrandTeton.gdb")))) using (Topology topology = geodatabase.OpenDataset("Backcountry_Topology")) { - // cref: GetTopologyRules;ArcGIS.Core.Data.Topology.TopologyDefinition.GetRules + // cref: ArcGIS.Core.Data.Topology.TopologyDefinition.GetRules + // cref: ArcGIS.Core.Data.Topology.TopologyRule + // cref: ArcGIS.Core.Data.Topology.TopologyRule.ID + // cref: ArcGIS.Core.Data.Topology.TopologyRule.OriginClass + // cref: ArcGIS.Core.Data.Topology.TopologyRule.OriginSubtype + // cref: ArcGIS.Core.Data.Topology.TopologyRule.DestinationClass + // cref: ArcGIS.Core.Data.Topology.TopologyRule.DestinationSubtype + // cref: ArcGIS.Core.Data.Topology.TopologyRule.RuleType #region GetTopologyRules using (TopologyDefinition topologyDefinition = topology.GetDefinition()) @@ -129,7 +141,11 @@ public void GetTopologyRules() } } - // cref: ValidateTopology;ArcGIS.Core.Data.Topology.Topology.Validate(ArcGIS.Core.Data.Topology.ValidationDescription) + // cref: ArcGIS.Core.Data.Topology.ValidationDescription.#ctor + // cref: ArcGIS.Core.Data.Topology.Topology.Validate(ArcGIS.Core.Data.Topology.ValidationDescription) + // cref: ArcGIS.Core.Data.Topology.Topology.GetExtent + // cref: ArcGIS.Core.Data.Topology.Topology.GetState + // cref: ArcGIS.Core.Data.Topology.ValidationResult #region ValidateTopology public void ValidateTopology() @@ -233,7 +249,17 @@ public void WorkWithTopologyErrors() using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\TestData\GrandTeton.gdb")))) using (Topology topology = geodatabase.OpenDataset("Backcountry_Topology")) { - // cref: GetTopologyErrors;ArcGIS.Core.Data.Topology.Topology.GetErrors(ArcGIS.Core.Data.Topology.ErrorDescription) + // cref: ArcGIS.Core.Data.Topology.Topology.GetErrors(ArcGIS.Core.Data.Topology.ErrorDescription) + // cref: ArcGIS.Core.Data.Topology.TopologyError + // cref: ArcGIS.Core.Data.Topology.ErrorDescription + // cref: ArcGIS.Core.Data.Topology.TopologyError.OriginClassName + // cref: ArcGIS.Core.Data.Topology.TopologyError.OriginObjectID + // cref: ArcGIS.Core.Data.Topology.TopologyError.DestinationClassName + // cref: ArcGIS.Core.Data.Topology.TopologyError.DestinationObjectID + // cref: ArcGIS.Core.Data.Topology.TopologyError.RuleType + // cref: ArcGIS.Core.Data.Topology.TopologyError.IsException + // cref: ArcGIS.Core.Data.Topology.TopologyError.Shape + // cref: ArcGIS.Core.Data.Topology.TopologyError.RuleID #region GetTopologyErrors // Get all the errors and exceptions currently associated with the topology. @@ -252,8 +278,17 @@ public void WorkWithTopologyErrors() #endregion GetTopologyErrors - // cref: MarkAndUnmarkAsErrors;ArcGIS.Core.Data.Topology.Topology.MarkAsException(ArcGIS.Core.Data.Topology.TopologyError) - // cref: MarkAndUnmarkAsErrors;ArcGIS.Core.Data.Topology.Topology.UnmarkAsException(ArcGIS.Core.Data.Topology.TopologyError) + // cref: ArcGIS.Core.Data.Topology.Topology.MarkAsException(ArcGIS.Core.Data.Topology.TopologyError) + // cref: ArcGIS.Core.Data.Topology.Topology.UnmarkAsException(ArcGIS.Core.Data.Topology.TopologyError) + // cref: ArcGIS.Core.Data.Topology.Topology.GetExtent + // cref: ArcGIS.Core.Data.Topology.Topology.GetErrors + // cref: ArcGIS.Core.Data.Topology.TopologyRule.RuleType + // cref: ArcGIS.Core.Data.Topology.TopologyDefinition.GetRules + // cref: ArcGIS.Core.Data.Topology.TopologyRuleType + // cref: ArcGIS.Core.Data.Topology.ErrorDescription.TopologyRule + // cref: ArcGIS.Core.Data.Topology.ErrorDescription.ErrorType + // cref: ArcGIS.Core.Data.Topology.ErrorType + // cref: ArcGIS.Core.Data.Topology.TopologyError #region MarkAndUnmarkAsErrors // Get all the errors due to features violating the "PointProperlyInsideArea" topology rule. @@ -306,7 +341,16 @@ public void WorkWithTopologyErrors() } } - // cref: ExploreTopologyGraph;ArcGIS.Core.Data.Topology.Topology.BuildGraph(ArcGIS.Core.Geometry.Geometry,System.Action{ArcGIS.Core.Data.Topology.TopologyGraph}) + // cref: ArcGIS.Core.Data.Topology.Topology.BuildGraph(ArcGIS.Core.Geometry.Geometry,System.Action{ArcGIS.Core.Data.Topology.TopologyGraph}) + // cref: ArcGIS.Core.Data.Topology.TopologyGraph.GetEdges + // cref: ArcGIS.Core.Data.Topology.TopologyEdge.GetFromNode + // cref: ArcGIS.Core.Data.Topology.TopologyEdge.GetToNode + // cref: ArcGIS.Core.Data.Topology.TopologyEdge.GetLeftParentFeatures + // cref: ArcGIS.Core.Data.Topology.TopologyEdge.GetRightParentFeatures + // cref: ArcGIS.Core.Data.Topology.TopologyNode + // cref: ArcGIS.Core.Data.Topology.FeatureInfo + // cref: ArcGIS.Core.Data.Topology.FeatureInfo.FeatureClassName + // cref: ArcGIS.Core.Data.Topology.FeatureInfo.ObjectID #region ExploreTopologyGraph public void ExploreTopologyGraph() @@ -387,7 +431,13 @@ private void EnsureShapeIsNotEmpty(FeatureInfo featureInfo) #endregion ExploreTopologyGraph - // cref: FindClosestElement;ArcGIS.Core.Data.Topology.TopologyGraph.FindClosestElement``1(ArcGIS.Core.Geometry.MapPoint,System.Double) + // cref: ArcGIS.Core.Data.Topology.TopologyGraph.FindClosestElement + // cref: ArcGIS.Core.Data.Topology.BuildGraph + // cref: ArcGIS.Core.Data.Topology.GetExtent + // cref: ArcGIS.Core.Data.Topology.TopologyElement + // cref: ArcGIS.Core.Data.Topology.TopologyElement.GetParentFeatures + // cref: ArcGIS.Core.Data.Topology.FeatureInfo.FeatureClassName + // cref: ArcGIS.Core.Data.Topology.FeatureInfo.ObjectID #region FindClosestElement public void FindClosestElement() @@ -408,9 +458,12 @@ public void FindClosestElement() double searchRadius = 1.0; - TopologyElement topologyElementViaCampsites12 = topologyGraph.FindClosestElement(queryPointViaCampsites12, searchRadius); + TopologyElement topologyElementViaCampsites12 = + topologyGraph.FindClosestElement( + queryPointViaCampsites12, searchRadius); - System.Diagnostics.Debug.Assert(topologyElementViaCampsites12 != null, "There should be a topology element corresponding to 'queryPointViaCampsites12' within the 'searchRadius' units."); + System.Diagnostics.Debug.Assert( + topologyElementViaCampsites12 != null, "There should be a topology element corresponding to 'queryPointViaCampsites12' within the 'searchRadius' units."); IReadOnlyList parentFeatures = topologyElementViaCampsites12.GetParentFeatures(); diff --git a/Examples/GeodatabaseSDK.csproj b/Examples/GeodatabaseSDK.csproj deleted file mode 100644 index c840f75..0000000 --- a/Examples/GeodatabaseSDK.csproj +++ /dev/null @@ -1,245 +0,0 @@ - - - - - Debug - AnyCPU - {37503055-231E-245B-0CB2-9481F81E00C0} - Library - Properties - GeodatabaseSDK - GeodatabaseSDK - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\GeodatabaseSDK\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\GeodatabaseSDK\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Examples/Geometry.csproj b/Examples/Geometry.csproj deleted file mode 100644 index 1fcbb58..0000000 --- a/Examples/Geometry.csproj +++ /dev/null @@ -1,199 +0,0 @@ - - - - - Debug - AnyCPU - {31B8896B-1D85-E476-469E-D21E32CA1905} - Library - Properties - Geometry - Geometry - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\Geometry\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\Geometry\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - - - \ No newline at end of file diff --git a/Examples/Geometry/Geometry.csproj b/Examples/Geometry/Geometry.csproj new file mode 100644 index 0000000..d83092a --- /dev/null +++ b/Examples/Geometry/Geometry.csproj @@ -0,0 +1,84 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + + \ No newline at end of file diff --git a/Examples/Geometry/GeometryCodeExamples.cs b/Examples/Geometry/GeometryCodeExamples.cs deleted file mode 100644 index 417402f..0000000 --- a/Examples/Geometry/GeometryCodeExamples.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using ArcGIS.Core.Geometry; - -namespace ForGeometryAPI { - class GeometryCodeExamples { - - public void CodeExamples() { - - #region Example1 - - // methods need to run on the MCT - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - List list = new List(); - MapPoint minPt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint maxPt = MapPointBuilder.CreateMapPoint(2.0, 2.0); - - // create an envelope - Envelope env = EnvelopeBuilder.CreateEnvelope(minPt, maxPt); - - // create a polygon from the envelope - using (PolygonBuilder polygonBuilder = new PolygonBuilder(env)) - { - Polygon poly = polygonBuilder.ToGeometry(); - } - }); - - #endregion Example1 - - // cref: Example2;ArcGIS.Core.Geometry.PolygonBuilder.CreatePolygon(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate3D},ArcGIS.Core.Geometry.SpatialReference) - #region Example2 - - // methods need to run on the MCT - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - List list3D = new List(); - list3D.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 1.0, 2.0)); - list3D.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0, 1.0, 2.0)); - list3D.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0, 1.0, 2.0)); - list3D.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0, 1.0, 2.0)); - - var polygon = PolygonBuilder.CreatePolygon(list3D); - }); - - - #endregion Example2 - } - - } -} diff --git a/Examples/Geometry/ProSnippets.cs b/Examples/Geometry/ProSnippets.cs index 6c917f5..2dbafda 100644 --- a/Examples/Geometry/ProSnippets.cs +++ b/Examples/Geometry/ProSnippets.cs @@ -20,7 +20,6 @@ limitations under the License. using System.Collections.Generic; using System.IO; using System.Linq; -using System.Windows.Media.Media3D; using ArcGIS.Core.Data; using ArcGIS.Core.Geometry; using ArcGIS.Desktop.Framework.Threading.Tasks; @@ -28,6 +27,7 @@ limitations under the License. namespace ProSnippetsGeometry { + class GeometryCodeExamples { #region ProSnippet Group: SpatialReference @@ -36,9 +36,9 @@ class GeometryCodeExamples public void SpatialReference() { { - // cref: Construct a SpatialReference - from a well-known ID;ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.Int32) - // cref: Construct a SpatialReference - from a well-known ID;ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.Int32) - // cref: Construct a SpatialReference - from a well-known ID;ArcGIS.Core.Geometry.SpatialReferenceBuilder.ToSpatialReference + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.Int32) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.Int32) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.ToSpatialReference #region Construct a SpatialReference - from a well-known ID // Use a builder convenience method or use a builder constructor. @@ -61,8 +61,9 @@ public void SpatialReference() } { - // cref: Construct a SpatialReference - from a string;ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.String) - // cref: Construct a SpatialReference - from a string;ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.String) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.String) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.String) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.ToSpatialReference #region Construct a SpatialReference - from a string // Use a builder convenience method or use a builder constructor. @@ -87,9 +88,9 @@ public void SpatialReference() } { - // cref: Use WGS84 SpatialReference;ArcGIS.Core.Geometry.SpatialReference.IsGeographic - // cref: Use WGS84 SpatialReference;ArcGIS.Core.Geometry.SpatialReference.IsProjected - // cref: Use WGS84 SpatialReference;ArcGIS.Core.Geometry.SpatialReferences.WGS84 + // cref: ArcGIS.Core.Geometry.SpatialReference.IsGeographic + // cref: ArcGIS.Core.Geometry.SpatialReference.IsProjected + // cref: ArcGIS.Core.Geometry.SpatialReferences.WGS84 #region Use WGS84 SpatialReference SpatialReference wgs84 = SpatialReferences.WGS84; @@ -100,10 +101,10 @@ public void SpatialReference() } { - // cref: Construct a SpatialReference with a vertical coordinate system - from well-known IDs;ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.Int32,System.Int32) - // cref: Construct a SpatialReference with a vertical coordinate system - from well-known IDs;ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.Int32,System.Int32) - // cref: Construct a SpatialReference with a vertical coordinate system - from well-known IDs;ArcGIS.Core.Geometry.SpatialReferenceBuilder.VcsWkid - // cref: Construct a SpatialReference with a vertical coordinate system - from well-known IDs;ArcGIS.Core.Geometry.SpatialReferenceBuilder.VcsWkt + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.Int32,System.Int32) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.Int32,System.Int32) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.VcsWkid + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.VcsWkt #region Construct a SpatialReference with a vertical coordinate system - from well-known IDs // Use a builder convenience method or use a builder constructor. @@ -120,12 +121,12 @@ public void SpatialReference() { using (SpatialReferenceBuilder sb = new SpatialReferenceBuilder(4326, 115700)) { - // spatialReferenceBuilder properties - // sb.wkid = 4326 - // sb.Wkt = "GEOGCS["MyGCS84",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT[\"Radian\",1.0]]" - // sb.name = GCS_WGS_1984 - // sb.vcsWkid = 115700 - // sb.VcsWkt = "VERTCS["WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]] + // SpatialReferenceBuilder properties + // sb.wkid == 4326 + // sb.Wkt == "GEOGCS["MyGCS84",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT[\"Radian\",1.0]]" + // sb.name == GCS_WGS_1984 + // sb.vcsWkid == 115700 + // sb.VcsWkt == "VERTCS["WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]] // do something with the builder @@ -137,10 +138,10 @@ public void SpatialReference() } { - // cref: Construct a SpatialReference with a vertical coordinate system - from a string;ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.Int32,System.String) - // cref: Construct a SpatialReference with a vertical coordinate system - from a string;ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.Int32,System.String) - // cref: Construct a SpatialReference with a vertical coordinate system - from a string;ArcGIS.Core.Geometry.SpatialReference.VcsWkid - // cref: Construct a SpatialReference with a vertical coordinate system - from a string;ArcGIS.Core.Geometry.SpatialReference.VcsWkt + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.Int32,System.String) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.Int32,System.String) + // cref: ArcGIS.Core.Geometry.SpatialReference.VcsWkid + // cref: ArcGIS.Core.Geometry.SpatialReference.VcsWkt #region Construct a SpatialReference with a vertical coordinate system - from a string // Use a builder convenience method or use a builder constructor. @@ -150,10 +151,11 @@ public void SpatialReference() // Builder convenience methods don't need to run on the MCT. SpatialReference sr4326_customVertical = SpatialReferenceBuilder.CreateSpatialReference(4326, custom_vWkt); - // sr4326_customVertical.wkid = 4326 - // sr4326_customVertical.vert_wkid = 0 - // sr4326_customVertical.vert_wkt = custom_vWkt - // sr4326_customVertical.hasVcs = true + // SpatialReferenceBuilder properties + // sr4326_customVertical.wkid == 4326 + // sr4326_customVertical.vert_wkid == 0 + // sr4326_customVertical.vert_wkt == custom_vWkt + // sr4326_customVertical.hasVcs == true // Builder constructors need to run on the MCT. ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -170,9 +172,11 @@ public void SpatialReference() } { - // cref: Construct a SpatialReference with a custom PCS - from a string;ArcGIS.Core.Geometry.SpatialReference.Gcs - // cref: Construct a SpatialReference with a custom PCS - from a string;ArcGIS.Core.Geometry.SpatialReference.GcsWkid - // cref: Construct a SpatialReference with a custom PCS - from a string;ArcGIS.Core.Geometry.SpatialReference.GcsWkt + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.#ctor(System.String) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.String) + // cref: ArcGIS.Core.Geometry.SpatialReference.Gcs + // cref: ArcGIS.Core.Geometry.SpatialReference.GcsWkid + // cref: ArcGIS.Core.Geometry.SpatialReference.GcsWkt #region Construct a SpatialReference with a custom PCS - from a string // Use a builder convenience method or use a builder constructor. @@ -182,15 +186,16 @@ public void SpatialReference() // Builder convenience methods don't need to run on the MCT. SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(customWkt); - // spatialReference.Wkt = customWkt - // spatialReference.Wkid = 0 - // spatialReference.VcsWkid = 0 - // spatialReference.GcsWkid = 4326 + // SpatialReferenceBuilder properties + // spatialReference.Wkt == customWkt + // spatialReference.Wkid == 0 + // spatialReference.VcsWkid == 0 + // spatialReference.GcsWkid == 4326 SpatialReference gcs = spatialReference.Gcs; - // gcs.Wkid = 4326 - // gcs.IsGeographic = true - // sr.GcsWkt = gcs.Wkt + // gcs.Wkid == 4326 + // gcs.IsGeographic == true + // spatialReference.GcsWkt == gcs.Wkt // Builder constructors need to run on the MCT. ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -207,39 +212,39 @@ public void SpatialReference() } { - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.FalseM - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.FalseX - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.FalseY - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.FalseZ - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.HasVcs - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.MScale - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.MTolerance - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.Name - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.Unit - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.Wkid - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.Wkt - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.XYResolution - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.XYScale - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.XYTolerance - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.ZScale - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.ZTolerance - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReference.ZUnit - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.FalseM - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.FalseX - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.FalseY - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.FalseZ - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.MScale - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.MTolerance - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.Name - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.Unit - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.Wkid - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.Wkt - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.XYResolution - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.XYScale - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.XYTolerance - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.ZScale - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.ZTolerance - // cref: SpatialReference Properties;ArcGIS.Core.Geometry.SpatialReferenceBuilder.ZUnit + // cref: ArcGIS.Core.Geometry.SpatialReference.Wkid + // cref: ArcGIS.Core.Geometry.SpatialReference.Wkt + // cref: ArcGIS.Core.Geometry.SpatialReference.Name + // cref: ArcGIS.Core.Geometry.SpatialReference.XYScale + // cref: ArcGIS.Core.Geometry.SpatialReference.XYTolerance + // cref: ArcGIS.Core.Geometry.SpatialReference.XYResolution + // cref: ArcGIS.Core.Geometry.SpatialReference.Unit + // cref: ArcGIS.Core.Geometry.SpatialReference.ZScale + // cref: ArcGIS.Core.Geometry.SpatialReference.ZTolerance + // cref: ArcGIS.Core.Geometry.SpatialReference.ZUnit + // cref: ArcGIS.Core.Geometry.SpatialReference.MScale + // cref: ArcGIS.Core.Geometry.SpatialReference.MTolerance + // cref: ArcGIS.Core.Geometry.SpatialReference.FalseX + // cref: ArcGIS.Core.Geometry.SpatialReference.FalseY + // cref: ArcGIS.Core.Geometry.SpatialReference.FalseZ + // cref: ArcGIS.Core.Geometry.SpatialReference.FalseM + // cref: ArcGIS.Core.Geometry.SpatialReference.HasVcs + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.Wkid + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.Wkt + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.Name + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.XYScale + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.XYTolerance + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.XYResolution + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.Unit + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.ZScale + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.ZTolerance + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.ZUnit + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.MScale + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.MTolerance + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.FalseX + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.FalseY + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.FalseZ + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.FalseM #region SpatialReference Properties // Builder constructors need to run on the MCT. @@ -303,16 +308,16 @@ public void SpatialReference() } { - // cref: Import and Export Spatial Reference;ArcGIS.Core.Geometry.SpatialReference.ToJson - // cref: Import and Export Spatial Reference;ArcGIS.Core.Geometry.SpatialReference.ToXML - // cref: Import and Export Spatial Reference;ArcGIS.Core.Geometry.SpatialReferenceBuilder.FromJson(System.String) - // cref: Import and Export Spatial Reference;ArcGIS.Core.Geometry.SpatialReferenceBuilder.FromXML(System.String) + // cref: ArcGIS.Core.Geometry.SpatialReference.ToJson + // cref: ArcGIS.Core.Geometry.SpatialReference.ToXml + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.FromJson(System.String) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.FromXml(System.String) #region Import and Export Spatial Reference SpatialReference srWithVertical = SpatialReferenceBuilder.CreateSpatialReference(4326, 6916); - string xml = srWithVertical.ToXML(); - SpatialReference importedSR = SpatialReferenceBuilder.FromXML(xml); + string xml = srWithVertical.ToXml(); + SpatialReference importedSR = SpatialReferenceBuilder.FromXml(xml); // importedSR.Wkid = 4326 // importedSR.VcsWkid = 6916 @@ -325,31 +330,37 @@ public void SpatialReference() } { - // cref: Determine grid convergence for a SpatialReference at a given point;ArcGIS.Core.Geometry.SpatialReference.ConvergenceAngle(ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Project + // cref: ArcGIS.Core.Geometry.SpatialReference.GetConvergenceAngle(ArcGIS.Core.Geometry.Coordinate2D) #region Determine grid convergence for a SpatialReference at a given point Coordinate2D coordinate = new Coordinate2D(10, 30); - double angle = SpatialReferences.WGS84.ConvergenceAngle(coordinate); + double angle = SpatialReferences.WGS84.GetConvergenceAngle(coordinate); // angle = 0 SpatialReference srUTM30N = SpatialReferenceBuilder.CreateSpatialReference(32630); coordinate.X = 500000; coordinate.Y = 550000; - angle = srUTM30N.ConvergenceAngle(coordinate); + angle = srUTM30N.GetConvergenceAngle(coordinate); // angle = 0 - MapPoint pointWGS84 = MapPointBuilder.CreateMapPoint(10, 50, SpatialReferences.WGS84); - MapPoint pointUTM30N = GeometryEngine.Instance.Project(pointWGS84, srUTM30N) as MapPoint; + MapPoint pointWGS84 = MapPointBuilderEx.CreateMapPoint(10, 50, SpatialReferences.WGS84); + MapPoint pointUTM30N = GeometryEngine.Instance.Project( + pointWGS84, srUTM30N) as MapPoint; coordinate = (Coordinate2D)pointUTM30N; // get convergence angle and convert to degrees - angle = srUTM30N.ConvergenceAngle(coordinate) * 180 / Math.PI; + angle = srUTM30N.GetConvergenceAngle(coordinate) * 180 / Math.PI; // angle = 10.03 #endregion } { + // cref: ArcGIS.Core.CIM.CIMMap.DatumTransforms + // cref: ArcGIS.Core.CIM.CIMDatumTransform + // cref: ArcGIS.Core.CIM.CIMMap.HVDatumTransforms + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation #region Datum var cimMapDefinition = MapView.Active.Map.GetDefinition(); @@ -362,14 +373,15 @@ public void SpatialReference() } { - // cref: SpatialReference Datum and datum properties;ArcGIS.Core.Geometry.Datum.Name - // cref: SpatialReference Datum and datum properties;ArcGIS.Core.Geometry.Datum.SpheroidFlattening - // cref: SpatialReference Datum and datum properties;ArcGIS.Core.Geometry.Datum.SpheroidName - // cref: SpatialReference Datum and datum properties;ArcGIS.Core.Geometry.Datum.SpheroidSemiMajorAxis - // cref: SpatialReference Datum and datum properties;ArcGIS.Core.Geometry.Datum.SpheroidSemiMinorAxis - // cref: SpatialReference Datum and datum properties;ArcGIS.Core.Geometry.Datum.SpheroidWkid - // cref: SpatialReference Datum and datum properties;ArcGIS.Core.Geometry.Datum.Wkid - // cref: SpatialReference Datum and datum properties;ArcGIS.Core.Geometry.SpatialReference.Datum + // cref: ArcGIS.Core.Geometry.SpatialReference.Datum + // cref: ArcGIS.Core.Geometry.SpatialReferences.WGS84 + // cref: ArcGIS.Core.Geometry.Datum.Name + // cref: ArcGIS.Core.Geometry.Datum.Wkid + // cref: ArcGIS.Core.Geometry.Datum.SpheroidName + // cref: ArcGIS.Core.Geometry.Datum.SpheroidWkid + // cref: ArcGIS.Core.Geometry.Datum.SpheroidFlattening + // cref: ArcGIS.Core.Geometry.Datum.SpheroidSemiMajorAxis + // cref: ArcGIS.Core.Geometry.Datum.SpheroidSemiMinorAxis #region SpatialReference Datum and datum properties // Get datum of a spatial reference @@ -404,9 +416,9 @@ public void SpatialReference() public void Coordinate3D() { - // cref: Vector Polar Coordinates;ArcGIS.Core.Geometry.Coordinate3D.QueryComponents - // cref: Vector Polar Coordinates;ArcGIS.Core.Geometry.Coordinate3D.QueryPolarComponents - // cref: Vector Polar Coordinates;ArcGIS.Core.Geometry.Coordinate3D.SetPolarComponents(System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate3D.QueryPolarComponents + // cref: ArcGIS.Core.Geometry.Coordinate3D.SetPolarComponents(System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate3D.QueryComponents #region Vector Polar Coordinates Coordinate3D polarVector = new Coordinate3D(0, 7, 0); Tuple polarComponents = polarVector.QueryPolarComponents(); @@ -422,8 +434,8 @@ public void Coordinate3D() #endregion - // cref: Getting vector inclination;ArcGIS.Core.Geometry.Coordinate3D.SetComponents(System.Double,System.Double,System.Double) - // cref: Getting vector inclination;ArcGIS.Core.Geometry.Coordinate3D.Inclination + // cref: ArcGIS.Core.Geometry.Coordinate3D.SetComponents(System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate3D.Inclination #region Getting vector inclination Coordinate3D v = new Coordinate3D(0, 0, 7); @@ -437,7 +449,9 @@ public void Coordinate3D() #endregion - // cref: Getting vector azimuth;ArcGIS.Core.Geometry.Coordinate3D.Azimuth + // cref: ArcGIS.Core.Geometry.Coordinate3D.Azimuth + // cref: ArcGIS.Core.Geometry.Coordinate3D.SetComponents + // cref: ArcGIS.Core.Geometry.AngularUnit.ConvertFromRadians #region Getting vector azimuth Coordinate3D vector = new Coordinate3D(0, 7, 0); double azimuth = vector.Azimuth; // azimuth = 0 @@ -455,13 +469,18 @@ public void Coordinate3D() public void Coordinate3D_Operations() { - // cref: Vector Operations;ArcGIS.Core.Geometry.Coordinate3D.#ctor(System.Double,System.Double,System.Double) - // cref: Vector Operations;ArcGIS.Core.Geometry.Coordinate3D.AddCoordinate3D(ArcGIS.Core.Geometry.Coordinate3D) - // cref: Vector Operations;ArcGIS.Core.Geometry.Coordinate3D.CrossProduct(ArcGIS.Core.Geometry.Coordinate3D) - // cref: Vector Operations;ArcGIS.Core.Geometry.Coordinate3D.DotProduct(ArcGIS.Core.Geometry.Coordinate3D) - // cref: Vector Operations;ArcGIS.Core.Geometry.Coordinate3D.Move(System.Double,System.Double,System.Double) - // cref: Vector Operations;ArcGIS.Core.Geometry.Coordinate3D.Rotate(System.Double,ArcGIS.Core.Geometry.Coordinate3D) - // cref: Vector Operations;ArcGIS.Core.Geometry.Coordinate3D.Scale(System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate3D.#ctor(System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate3D.DotProduct(ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.Coordinate3D.CrossProduct(ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.Coordinate3D.AddCoordinate3D(ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.Coordinate3D.Rotate(System.Double,ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.Coordinate3D.Scale(System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate3D.SetEmpty + // cref: ArcGIS.Core.Geometry.Coordinate3D.Move(System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate3D.op_Addition(ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.Coordinate3D.op_Subtraction(ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.Coordinate3D.op_Equality(ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.Coordinate3D.op_Inequality(ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D) #region Vector Operations // Easy 3D vectors @@ -535,6 +554,20 @@ public void Coordinate3D_Operations() public void Coordinate2D() { + // cref: ArcGIS.Core.Geometry.Coordinate2D.#ctor(System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate2D.Magnitude + // cref: ArcGIS.Core.Geometry.Coordinate2D.DotProduct(ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.Coordinate2D.op_Addition(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.Coordinate2D.op_Subtraction(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.Coordinate2D.Rotate(System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate2D.Rotate(System.Double,ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.Coordinate2D.op_Equality(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.Coordinate2D.op_Inequality(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.Coordinate2D.Scale(System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate2D.Move(System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.Coordinate2D.QueryComponents + // cref: ArcGIS.Core.Geometry.Coordinate2D.GetUnitVector + // cref: ArcGIS.Core.Geometry.Coordinate2D.SetComponents(System.Double,System.Double) #region 2D Vector Operations Coordinate2D v = new Coordinate2D(0, 1); // v.Magnitude = 1 @@ -586,70 +619,94 @@ public void Coordinate2D() public void Builders() { - // cref: Builder Properties;ArcGIS.Core.Geometry.EnvelopeBuilder.HasM - // cref: Builder Properties;ArcGIS.Core.Geometry.EnvelopeBuilder.HasZ - // cref: Builder Properties;ArcGIS.Core.Geometry.GeometryBuilder`1.HasID - // cref: Builder Properties;ArcGIS.Core.Geometry.GeometryBuilder`1.HasM - // cref: Builder Properties;ArcGIS.Core.Geometry.GeometryBuilder`1.HasZ + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline(IEnumerable points, ArcGIS.Core.Geometry.SpatialReference spatialReference = null) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline(IEnumerable points, AttributeFlags attributes, ArcGIS.Core.Geometry.SpatialReference spatialReference = null) + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.HasZ + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.HasM + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.HasID + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(IEnumerable points, ArcGIS.Core.Geometry.SpatialReference spatialReference = null) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(IEnumerable points, AttributeFlags attributes, ArcGIS.Core.Geometry.SpatialReference spatialReference = null) + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.HasZ + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.HasM + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.HasID + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.#ctor(IEnumerable points, AttributeFlags attributes, ArcGIS.Core.Geometry.SpatialReference spatialReference = null) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.#ctor(ArcGIS.Core.Geometry.Polyline polyline) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.#ctor(IEnumerable points, AttributeFlags attributes, ArcGIS.Core.Geometry.SpatialReference spatialReference = null) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.#ctor(ArcGIS.Core.Geometry.Polygon polygon) + // cref: ArcGIS.Core.Geometry.AttributeFlags #region Builder Properties // list of points List points = new List { - MapPointBuilder.CreateMapPoint(0, 0, 2, 3, 1), - MapPointBuilder.CreateMapPoint(1, 1, 5, 6), - MapPointBuilder.CreateMapPoint(2, 1, 6), - MapPointBuilder.CreateMapPoint(0, 0) + MapPointBuilderEx.CreateMapPoint(0, 0, 2, 3, 1), + MapPointBuilderEx.CreateMapPoint(1, 1, 5, 6), + MapPointBuilderEx.CreateMapPoint(2, 1, 6), + MapPointBuilderEx.CreateMapPoint(0, 0) }; // will have attributes because it is created with convenience method - Polyline polylineWithAttrs = PolylineBuilder.CreatePolyline(points); - + Polyline polylineWithAttrs = PolylineBuilderEx.CreatePolyline(points); bool hasZ = polylineWithAttrs.HasZ; // hasZ = true bool hasM = polylineWithAttrs.HasM; // hasM = true bool hasID = polylineWithAttrs.HasID; // hasID = true + // will not have attributes because it is specified as a parameter + Polyline polylineWithoutAttrs = + PolylineBuilderEx.CreatePolyline(points, AttributeFlags.None); + hasZ = polylineWithoutAttrs.HasZ; // hasZ = false + hasM = polylineWithoutAttrs.HasM; // hasM = false + hasID = polylineWithoutAttrs.HasID; // hasID = false + // will have attributes because it is created with convenience method - Polygon polygonWithAttrs = PolygonBuilder.CreatePolygon(points); + Polygon polygonWithAttrs = PolygonBuilderEx.CreatePolygon(points); hasZ = polygonWithAttrs.HasZ; // hasZ = true hasM = polygonWithAttrs.HasM; // hasM = true hasID = polygonWithAttrs.HasID; // hasID = true - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - // will not have attributes because it is passed something other than an attributed polyline - using (PolylineBuilder polylineB = new PolylineBuilder(points)) - { - hasZ = polylineB.HasZ; // hasZ = false - hasM = polylineB.HasM; // hasM = false - hasID = polylineB.HasID; // hasID = false - } - - // will have attributes because it is passed an attributed polyline - using (PolylineBuilder polylineB = new PolylineBuilder(polylineWithAttrs)) - { - hasZ = polylineB.HasZ; // hasZ = true - hasM = polylineB.HasM; // hasM = true - hasID = polylineB.HasID; // hasID = true - } - - // will not have attributes because it is passed something other than an attributed polygon - using (PolygonBuilder polygonB = new PolygonBuilder(points)) - { - hasZ = polygonB.HasZ; // hasZ = false - hasM = polygonB.HasM; // hasM = false - hasID = polygonB.HasID; // hasID = false - } - - // will have attributes because it is passed an attributed polygon - using (PolygonBuilder polygonB = new PolygonBuilder(polygonWithAttrs)) - { - hasZ = polygonB.HasZ; // hasZ = true - hasM = polygonB.HasM; // hasM = true - hasID = polygonB.HasID; // hasID = true - } - }); + // will not have attributes because it is specified as a parameter + Polygon polygonWithoutAttrs = + PolygonBuilderEx.CreatePolygon(points, AttributeFlags.None); + hasZ = polygonWithoutAttrs.HasZ; // hasZ = false + hasM = polygonWithoutAttrs.HasM; // hasM = false + hasID = polygonWithoutAttrs.HasID; // hasID = false + + // will not have attributes because it is specified as a parameter + PolylineBuilderEx polylineB = + new PolylineBuilderEx(points, AttributeFlags.None); + hasZ = polylineB.HasZ; // hasZ = false + hasM = polylineB.HasM; // hasM = false + hasID = polylineB.HasID; // hasID = false + + // will have attributes because it is passed an attributed polyline + polylineB = new PolylineBuilderEx(polylineWithAttrs); + hasZ = polylineB.HasZ; // hasZ = true + hasM = polylineB.HasM; // hasM = true + hasID = polylineB.HasID; // hasID = true + + // will not have attributes because it is passed a non-attributed polyline + polylineB = new PolylineBuilderEx(polylineWithoutAttrs); + hasZ = polylineB.HasZ; // hasZ = false + hasM = polylineB.HasM; // hasM = false + hasID = polylineB.HasID; // hasID = false + + // will not have attributes because it is specified as a parameter + PolygonBuilderEx polygonB = new PolygonBuilderEx(points, AttributeFlags.None); + hasZ = polygonB.HasZ; // hasZ = false + hasM = polygonB.HasM; // hasM = false + hasID = polygonB.HasID; // hasID = false + + // will have attributes because it is passed an attributed polygon + polygonB = new PolygonBuilderEx(polygonWithAttrs); + hasZ = polygonB.HasZ; // hasZ = true + hasM = polygonB.HasM; // hasM = true + hasID = polygonB.HasID; // hasID = true + + // will not have attributes because it is passed a non-attributed polygon + polygonB = new PolygonBuilderEx(polygonWithoutAttrs); + hasZ = polygonB.HasZ; // hasZ = true + hasM = polygonB.HasM; // hasM = true + hasID = polygonB.HasID; // hasID = true #endregion } @@ -660,40 +717,32 @@ public void Builders() public void MapPoint() { { - // cref: Construct a MapPoint;ArcGIS.Core.Geometry.Geometry.Clone - // cref: Construct a MapPoint;ArcGIS.Core.Geometry.MapPointBuilder.#ctor(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a MapPoint;ArcGIS.Core.Geometry.MapPointBuilder.CreateMapPoint(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a MapPoint;ArcGIS.Core.Geometry.MapPointBuilder.CreateMapPoint(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a MapPoint;ArcGIS.Core.Geometry.MapPointBuilder.ToGeometry - // cref: Construct a MapPoint;ArcGIS.Core.Geometry.MapPointBuilderEx.#ctor(System.Double,System.Double,System.Boolean,System.Double,System.Boolean,System.Double,System.Boolean,System.Int32,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a MapPoint;ArcGIS.Core.Geometry.MapPointBuilderEx.#ctor(System.Double,System.Double,System.Double) - // cref: Construct a MapPoint;ArcGIS.Core.Geometry.MapPointBuilder.ToGeometry(ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.CreateMapPoint(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.#ctor(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.Geometry.Clone + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.CreateMapPoint(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.#ctor(System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.#ctor(System.Double,System.Double,System.Boolean,System.Double,System.Boolean,System.Double,System.Boolean,System.Int32,ArcGIS.Core.Geometry.SpatialReference) #region Construct a MapPoint // Use a builder convenience method or use a builder constructor. - // Builder convenience methods don't need to run on the MCT. // create a 3d point with M - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 2.0, 3.0, 4.0); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 2.0, 3.0, 4.0); - MapPoint ptWithM = null; - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (MapPointBuilder mb = new MapPointBuilder(1.0, 2.0, 3.0, 4.0)) - { - // do something with the builder + // builderEx constructors don't need to run on the MCT. + MapPointBuilderEx mb = new MapPointBuilderEx(1.0, 2.0, 3.0, 4.0); + // do something with the builder + + MapPoint ptWithM = mb.ToGeometry(); - ptWithM = mb.ToGeometry(); - } - }); MapPoint clone = ptWithM.Clone() as MapPoint; - MapPoint anotherM = MapPointBuilder.CreateMapPoint(ptWithM); + MapPoint anotherM = MapPointBuilderEx.CreateMapPoint(ptWithM); - // builderEx constructors don't need to run on the MCT. MapPointBuilderEx builderEx = new MapPointBuilderEx(1.0, 2.0, 3.0); builderEx.HasM = true; builderEx.M = 4.0; @@ -713,68 +762,58 @@ public void MapPoint() } { - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint) - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.#ctor(ArcGIS.Core.Geometry.SpatialReference) - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.#ctor(System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.SetValues(System.Double,System.Double,System.Double) - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.ToGeometry - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint) - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.ToGeometry - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.EnvelopeBuilder.HasM - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.EnvelopeBuilder.HasZ - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.GeometryBuilder`1.HasID - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.GeometryBuilder`1.HasM - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.GeometryBuilder`1.HasZ - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.GeometryBuilder`1.IsEmpty - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPoint.IsEmpty - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPoint.M - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPoint.X - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPoint.Y - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPoint.Z - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.M - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.X - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.Y - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.Z - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.HasID - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.HasM - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.HasZ - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.ID - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.IsEmpty - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.M - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.X - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.Y - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilderEx.Z - // cref: MapPoint Builder Properties;ArcGIS.Core.Geometry.MapPointBuilder.ToGeometry(ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.#ctor(System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.HasZ + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.HasM + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.HasID + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.X + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.Y + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.Z + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.M + // cref: ArcGIS.Core.Geometry.MapPoint.X + // cref: ArcGIS.Core.Geometry.MapPoint.Y + // cref: ArcGIS.Core.Geometry.MapPoint.Z + // cref: ArcGIS.Core.Geometry.MapPoint.M + // cref: ArcGIS.Core.Geometry.MapPoint.ID + // cref: ArcGIS.Core.Geometry.Geometry.HasZ + // cref: ArcGIS.Core.Geometry.Geometry.HasM + // cref: ArcGIS.Core.Geometry.Geometry.HasID + // cref: ArcGIS.Core.Geometry.MapPoint.IsEmpty + // cref: ArcGIS.Core.Geometry.MapPoint.IsEqual + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.CreateMapPoint(ArcGIS.Core.Geometry.MapPoint, ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint, ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.ID + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.IsEmpty + // cref: ArcGIS.Core.Geometry.GeometryBuilderEx.HasZ + // cref: ArcGIS.Core.Geometry.GeometryBuilderEx.HasM + // cref: ArcGIS.Core.Geometry.GeometryBuilderEx.HasID + // cref: ArcGIS.Core.Geometry.GeometryBuilderEx.IsEmpty #region MapPoint Builder Properties - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or a builderEx constructor. + // neither need to run on the MCT. MapPoint point1 = null; MapPoint point2 = null; - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (MapPointBuilder mb = new MapPointBuilder(1.0, 2.0, 3.0)) - { - bool bhasZ = mb.HasZ; // hasZ = true - bool bhasM = mb.HasM; // hasM = false - bool bhasID = mb.HasID; // hasID = false + MapPointBuilderEx mb = new MapPointBuilderEx(1.0, 2.0, 3.0); + bool bhasZ = mb.HasZ; // hasZ = true + bool bhasM = mb.HasM; // hasM = false + bool bhasID = mb.HasID; // hasID = false - // do something with the builder + // do something with the builder - point1 = mb.ToGeometry(); + point1 = mb.ToGeometry(); - // change some of the builder properties - mb.X = 11; - mb.Y = 22; - mb.HasZ = false; - mb.HasM = true; - mb.M = 44; - // create another point - point2 = mb.ToGeometry(); - } - }); + // change some of the builder properties + mb.X = 11; + mb.Y = 22; + mb.HasZ = false; + mb.HasM = true; + mb.M = 44; + // create another point + point2 = mb.ToGeometry(); double x = point1.X; // x = 1.0 double y = point1.Y; // y = 2.0 @@ -788,8 +827,9 @@ public void MapPoint() bool isEqual = point1.IsEqual(point2); // isEqual = false - // Builder convenience methods don't need to run on the MCT. - MapPoint point3 = MapPointBuilder.CreateMapPoint(point1); + + // BuilderEx convenience methods + MapPoint point3 = MapPointBuilderEx.CreateMapPoint(point1); x = point3.X; // x = 1.0 y = point3.Y; // y = 2.0 z = point3.Z; // z = 3.0 @@ -800,7 +840,6 @@ public void MapPoint() hasID = point3.HasID; // hasID = false - // builderEx constructors don't need to run on the MCT. MapPointBuilderEx builderEx = new MapPointBuilderEx(point1); x = builderEx.X; // x = 1.0 y = builderEx.Y; // y = 2.0 @@ -815,8 +854,7 @@ public void MapPoint() MapPoint point4 = builderEx.ToGeometry() as MapPoint; - // builderEx convenience methods don't need to run on the MCT. - MapPoint point5 =MapPointBuilderEx.CreateMapPoint(point1); + MapPoint point5 = MapPointBuilderEx.CreateMapPoint(point1); x = point5.X; // x = 1.0 y = point5.Y; // y = 2.0 z = point5.Z; // z = 3.0 @@ -831,27 +869,27 @@ public void MapPoint() } { - // cref: MapPoint IsEqual;ArcGIS.Core.Geometry.MapPoint.IsEqual(ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.MapPoint.IsEqual(ArcGIS.Core.Geometry.MapPoint) #region MapPoint IsEqual - MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, 5); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 5); int ID = pt1.ID; // ID = 5 bool hasID = pt1.HasID; // hasID = true - MapPoint pt2 = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, 0); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, 0); ID = pt2.ID; // ID = 0 hasID = pt2.HasID; // hasID = true - MapPoint pt3 = MapPointBuilder.CreateMapPoint(1, 2, 3, 4); + MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4); ID = pt3.ID; // ID = 0 hasID = pt3.HasID; // hasID = false - MapPoint pt4 = MapPointBuilder.CreateMapPoint(1, 2, 3, 44); + MapPoint pt4 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 44); ID = pt4.ID; // ID = 0 hasID = pt4.HasID; // hasID = false bool hasM = pt4.HasM; // hasM = true - MapPoint pt5 = MapPointBuilder.CreateMapPoint(1, 2, 3); + MapPoint pt5 = MapPointBuilderEx.CreateMapPoint(1, 2, 3); ID = pt5.ID; // ID = 0 hasID = pt5.HasID; // hasID = false hasM = pt5.HasM; // hasM = false @@ -867,10 +905,14 @@ public void MapPoint() private static void ZoomToGeographicCoordinates(double x, double y, double buffer_size) { + // cref: ArcGIS.Desktop.Mapping.MapView.ZoomTo(ArcGIS.Core.Geometry.Geometry,Nullable(System.TimeSpan),System.Boolean) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Buffer + // cref: ArcGIS.Core.Geometry.GeometryEngine.Project #region Zoom to a specified point //Create a point - var pt = MapPointBuilder.CreateMapPoint(x, y, SpatialReferenceBuilder.CreateSpatialReference(4326)); + var pt = MapPointBuilderEx.CreateMapPoint(x, y, + SpatialReferenceBuilder.CreateSpatialReference(4326)); //Buffer it - for purpose of zoom var poly = GeometryEngine.Instance.Buffer(pt, buffer_size); @@ -897,42 +939,32 @@ private static void ZoomToGeographicCoordinates(double x, double y, double buffe public void Polyline() { { - // cref: Construct a Polyline - from an enumeration of MapPoints;ArcGIS.Core.Geometry.MapPointBuilder.CreateMapPoint(System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Polyline - from an enumeration of MapPoints;ArcGIS.Core.Geometry.PolylineBuilder.CreatePolyline(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.CreateMapPoint(System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},AttributeFlags attributes, ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.SpatialReferences.WGS84 + // cref: ArcGIS.Core.Geometry.AttributeFlags #region Construct a Polyline - from an enumeration of MapPoints - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or a builderEx constructor. + // neither need to run on the MCT - MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0); + MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0); List list = new List(); list.Add(startPt); list.Add(endPt); - // Builder convenience methods don't need to run on the MCT. - Polyline polyline = PolylineBuilder.CreatePolyline(list, SpatialReferences.WGS84); - - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (PolylineBuilder pb = new PolylineBuilder(list)) - { - pb.SpatialReference = SpatialReferences.WGS84; - Polyline polyline2 = pb.ToGeometry(); - } - }); - - - // buildEx constructors don't need to run on the MCT - PolylineBuilderEx pBuilder = new PolylineBuilderEx(list); - pBuilder.SpatialReference = SpatialReferences.WGS84; - Polyline polyline3 = pBuilder.ToGeometry() as Polyline; + Polyline polyline = PolylineBuilderEx.CreatePolyline(list, SpatialReferences.WGS84); + // use AttributeFlags.None since we only have 2D points in the list + PolylineBuilderEx pb = new PolylineBuilderEx(list, AttributeFlags.None); + pb.SpatialReference = SpatialReferences.WGS84; + Polyline polyline2 = pb.ToGeometry(); - // builderEx convenience methods don't need to run on the MCT // use AttributeFlags.NoAttributes because we only have 2d points in the list - Polyline polyline4 = PolylineBuilderEx.CreatePolyline(list, AttributeFlags.NoAttributes); + Polyline polyline4 = PolylineBuilderEx.CreatePolyline(list, AttributeFlags.None); #endregion } @@ -940,15 +972,14 @@ public void Polyline() { Polyline polyline = null; - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.Multipart.Copy2DCoordinatesToList - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.Multipart.Copy3DCoordinatesToList - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.Multipatch.Copy3DCoordinatesToList - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.ReadOnlyPointCollection.Copy2DCoordinatesToList(System.Int32,System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Coordinate2D}@) - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.ReadOnlyPointCollection.Copy3DCoordinatesToList(System.Int32,System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Coordinate3D}@) - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.ReadOnlyPointCollection.CopyPointsToList(System.Int32,System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.MapPoint}@) - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.ReadOnlyPointCollection.GetEnumerator - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.Multipart.PointCount - // cref: Get the points of a Polyline;ArcGIS.Core.Geometry.Multipart.Points + // cref: ArcGIS.Core.Geometry.Multipart.Points + // cref: ArcGIS.Core.Geometry.Multipart.PointCount + // cref: ArcGIS.Core.Geometry.ReadOnlyPointCollection.GetEnumerator + // cref: ArcGIS.Core.Geometry.Multipart.Copy2DCoordinatesToList + // cref: ArcGIS.Core.Geometry.Multipart.Copy3DCoordinatesToList + // cref: ArcGIS.Core.Geometry.ReadOnlyPointCollection.Copy2DCoordinatesToList(System.Int32,System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Coordinate2D}@) + // cref: ArcGIS.Core.Geometry.ReadOnlyPointCollection.Copy3DCoordinatesToList(System.Int32,System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Coordinate3D}@) + // cref: ArcGIS.Core.Geometry.ReadOnlyPointCollection.CopyPointsToList(System.Int32,System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.MapPoint}@) #region Get the points of a Polyline // get the points as a readonly Collection @@ -994,8 +1025,8 @@ public void Polyline() #endregion - // cref: Get the parts of a Polyline;ArcGIS.Core.Geometry.Multipart.PartCount - // cref: Get the parts of a Polyline;ArcGIS.Core.Geometry.Multipart.Parts + // cref: ArcGIS.Core.Geometry.Multipart.PartCount + // cref: ArcGIS.Core.Geometry.Multipart.Parts #region Get the parts of a Polyline int numParts = polyline.PartCount; @@ -1004,10 +1035,12 @@ public void Polyline() #endregion - // cref: Enumerate the parts of a Polyline;ArcGIS.Core.Geometry.ReadOnlyPartCollection.GetEnumerator - // cref: Enumerate the parts of a Polyline;ArcGIS.Core.Geometry.Multipart.Parts - // cref: Enumerate the parts of a Polyline;ArcGIS.Core.Geometry.Segment.Length - // cref: Enumerate the parts of a Polyline;ArcGIS.Core.Geometry.Segment.SegmentType + // cref: ArcGIS.Core.Geometry.Multipart.Parts + // cref: ArcGIS.Core.Geometry.ReadOnlyPartCollection.GetEnumerator + // cref: ArcGIS.Core.Geometry.ReadOnlySegmentCollection + // cref: ArcGIS.Core.Geometry.SegmentType + // cref: ArcGIS.Core.Geometry.Segment.Length + // cref: ArcGIS.Core.Geometry.Segment.SegmentType #region Enumerate the parts of a Polyline ReadOnlyPartCollection polylineParts = polyline.Parts; @@ -1056,25 +1089,18 @@ public void Polyline() } #endregion - // cref: Reverse the order of points in a Polyline;ArcGIS.Core.Geometry.MultipartBuilder`1.ReverseOrientation - // cref: Reverse the order of points in a Polyline;ArcGIS.Core.Geometry.PolylineBuilder.#ctor(ArcGIS.Core.Geometry.Polyline) - // cref: Reverse the order of points in a Polyline;ArcGIS.Core.Geometry.PolylineBuilder.ToGeometry + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.#ctor(ArcGIS.Core.Geometry.Polyline) + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.ReverseOrientation + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.ToGeometry #region Reverse the order of points in a Polyline - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (PolylineBuilder polylineBuilder = new PolylineBuilder(polyline)) - { - polylineBuilder.ReverseOrientation(); - Polyline reversedPolyline = polylineBuilder.ToGeometry(); - } - }); - + var polylineBuilder = new PolylineBuilderEx(polyline); + polylineBuilder.ReverseOrientation(); + Polyline reversedPolyline = polylineBuilder.ToGeometry(); #endregion - // cref: Get the segments of a Polyline;ArcGIS.Core.Geometry.Multipart.GetAllSegments(System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Segment}@) - // cref: Get the segments of a Polyline;ArcGIS.Core.Geometry.PolylineBuilder.CreatePolyline(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Segment},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.Multipart.GetAllSegments(System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Segment}@) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Segment},ArcGIS.Core.Geometry.SpatialReference) #region Get the segments of a Polyline ICollection collection = new List(); @@ -1088,61 +1114,52 @@ public void Polyline() } // use the segments to build another polyline - Polyline polylineFromSegments = PolylineBuilder.CreatePolyline(collection); + Polyline polylineFromSegments = PolylineBuilderEx.CreatePolyline(collection); #endregion } { - // cref: Build a multi-part Polyline;ArcGIS.Core.Geometry.MultipartBuilder`1.AddPart(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint}) - // cref: Build a multi-part Polyline;ArcGIS.Core.Geometry.MultipartBuilder`1.RemovePart(System.Int32) - // cref: Build a multi-part Polyline;ArcGIS.Core.Geometry.PolylineBuilder.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint}) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.AttributeFlags,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.AddPart(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint}) + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.RemovePart(System.Int32) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.AttributeFlags #region Build a multi-part Polyline List firstPoints = new List(); - firstPoints.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - firstPoints.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0)); - firstPoints.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0)); - firstPoints.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); + firstPoints.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + firstPoints.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0)); + firstPoints.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0)); + firstPoints.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); List nextPoints = new List(); - nextPoints.Add(MapPointBuilder.CreateMapPoint(11.0, 1.0)); - nextPoints.Add(MapPointBuilder.CreateMapPoint(11.0, 2.0)); - nextPoints.Add(MapPointBuilder.CreateMapPoint(12.0, 2.0)); - nextPoints.Add(MapPointBuilder.CreateMapPoint(12.0, 1.0)); - - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (PolylineBuilder pBuilder = new PolylineBuilder(firstPoints)) - { - pBuilder.AddPart(nextPoints); - - Polyline polyline = pBuilder.ToGeometry(); - // polyline has 2 parts - - pBuilder.RemovePart(0); - polyline = pBuilder.ToGeometry(); - // polyline has 1 part - } - }); + nextPoints.Add(MapPointBuilderEx.CreateMapPoint(11.0, 1.0)); + nextPoints.Add(MapPointBuilderEx.CreateMapPoint(11.0, 2.0)); + nextPoints.Add(MapPointBuilderEx.CreateMapPoint(12.0, 2.0)); + nextPoints.Add(MapPointBuilderEx.CreateMapPoint(12.0, 1.0)); + // use AttributeFlags.None since we have 2D points in the list + PolylineBuilderEx pBuilder = new PolylineBuilderEx(firstPoints, AttributeFlags.None); + pBuilder.AddPart(nextPoints); - // or use a builderEx constructor - doesn't need to run on MCT - PolylineBuilderEx pbuilderEx = new PolylineBuilderEx(firstPoints); - pbuilderEx.AddPart(nextPoints); - Polyline polyline2 = pbuilderEx.ToGeometry() as Polyline; - // polyline2 has 2 parts + Polyline polyline = pBuilder.ToGeometry(); + // polyline has 2 parts - pbuilderEx.RemovePart(0); - polyline2 = pbuilderEx.ToGeometry() as Polyline; - // polyline2 has 1 part + pBuilder.RemovePart(0); + polyline = pBuilder.ToGeometry(); + // polyline has 1 part #endregion } Geometry sketchGeometry = null; { + // cref: ArcGIS.Core.Geometry.Multipart.Points + // cref: ArcGIS.Core.Geometry.Multipart.Parts + // cref: ArcGIS.Core.Geometry.ReadOnlySegmentCollection + // cref: ArcGIS.Core.Geometry.LineSegment + // cref: ArcGIS.Core.Geometry.Segment.StartPoint #region StartPoint of a Polyline // Method 1: Get the start point of the polyline by converting the polyline // into a collection of points and getting the first point @@ -1172,21 +1189,23 @@ public void Polyline() public void ClothoidByAngle() { - // cref: Construct a Clothoid by Angle;ArcGIS.Core.Geometry.PolylineBuilder.CreatePolyline(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.esriClothoidCreateMethod,System.Double,ArcGIS.Core.Geometry.esriCurveDensifyMethod,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Clothoid by Angle;ArcGIS.Core.Geometry.PolylineBuilder.QueryClothoidParameters(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.esriClothoidCreateMethod,System.Double,ArcGIS.Core.Geometry.MapPoint@,System.Double@,System.Double@,System.Double@,System.Double@,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.ClothoidCreateMethod,System.Double,ArcGIS.Core.Geometry.CurveDensifyMethod,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.QueryClothoidParameters(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.ClothoidCreateMethod,System.Double,ArcGIS.Core.Geometry.MapPoint@,System.Double@,System.Double@,System.Double@,System.Double@,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.ClothoidCreateMethod + // cref: ArcGIS.Core.Geometry.CurveDensifyMethod #region Construct a Clothoid by Angle - MapPoint startPoint = MapPointBuilder.CreateMapPoint(0, 0); + MapPoint startPoint = MapPointBuilderEx.CreateMapPoint(0, 0); double tangentDirection = Math.PI / 6; - esriArcOrientation orientation = esriArcOrientation.esriArcCounterClockwise; + ArcOrientation orientation = ArcOrientation.ArcCounterClockwise; double startRadius = double.PositiveInfinity; double endRadius = 0.2; - esriClothoidCreateMethod createMethod = esriClothoidCreateMethod.ByAngle; + ClothoidCreateMethod createMethod = ClothoidCreateMethod.ByAngle; double angle = Math.PI / 2; - esriCurveDensifyMethod densifyMethod = esriCurveDensifyMethod.ByLength; + CurveDensifyMethod densifyMethod = CurveDensifyMethod.ByLength; double densifyParameter = 0.1; - Polyline polyline = PolylineBuilder.CreatePolyline(startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, angle, densifyMethod, densifyParameter, SpatialReferences.WGS84); + Polyline polyline = PolylineBuilderEx.CreatePolyline(startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, angle, densifyMethod, densifyParameter, SpatialReferences.WGS84); int numPoints = polyline.PointCount; MapPoint queryPoint = polyline.Points[numPoints - 2]; @@ -1194,106 +1213,106 @@ public void ClothoidByAngle() MapPoint pointOnPath; double radiusCalculated, tangentDirectionCalculated, lengthCalculated, angleCalculated; - PolylineBuilder.QueryClothoidParameters(queryPoint, startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, angle, out pointOnPath, out radiusCalculated, out tangentDirectionCalculated, out lengthCalculated, out angleCalculated, SpatialReferences.WGS84); + PolylineBuilderEx.QueryClothoidParameters(queryPoint, startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, angle, out pointOnPath, out radiusCalculated, out tangentDirectionCalculated, out lengthCalculated, out angleCalculated, SpatialReferences.WGS84); #endregion } public void ClothoidByLength() { - // cref: Construct a Clothoid by Length;ArcGIS.Core.Geometry.PolylineBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.esriClothoidCreateMethod,System.Double,ArcGIS.Core.Geometry.esriCurveDensifyMethod,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Clothoid by Length;ArcGIS.Core.Geometry.PolylineBuilder.QueryClothoidParameters(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.esriClothoidCreateMethod,System.Double,ArcGIS.Core.Geometry.MapPoint@,System.Double@,System.Double@,System.Double@,System.Double@,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.ClothoidCreateMethod,System.Double,ArcGIS.Core.Geometry.CurveDensifyMethod,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.QueryClothoidParameters(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.ClothoidCreateMethod,System.Double,ArcGIS.Core.Geometry.MapPoint@,System.Double@,System.Double@,System.Double@,System.Double@,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.ClothoidCreateMethod + // cref: ArcGIS.Core.Geometry.ArcOrientation #region Construct a Clothoid by Length - MapPoint startPoint = MapPointBuilder.CreateMapPoint(0, 0); - MapPoint queryPoint = MapPointBuilder.CreateMapPoint(3.8, 1); + MapPoint startPoint = MapPointBuilderEx.CreateMapPoint(0, 0); + MapPoint queryPoint = MapPointBuilderEx.CreateMapPoint(3.8, 1); double tangentDirection = 0; - esriArcOrientation orientation = esriArcOrientation.esriArcCounterClockwise; + ArcOrientation orientation = ArcOrientation.ArcCounterClockwise; double startRadius = double.PositiveInfinity; double endRadius = 1; - esriClothoidCreateMethod createMethod = esriClothoidCreateMethod.ByLength; + ClothoidCreateMethod createMethod = ClothoidCreateMethod.ByLength; double curveLength = 10; MapPoint pointOnPath; double radiusCalculated, tangentDirectionCalculated, lengthCalculated, angleCalculated; - PolylineBuilder.QueryClothoidParameters(queryPoint, startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, curveLength, out pointOnPath, out radiusCalculated, out tangentDirectionCalculated, out lengthCalculated, out angleCalculated, SpatialReferences.WGS84); - // pointOnPath = (3.7652656620171379, 1.0332006103128575) - // radiusCalculated = 2.4876382887687227 - // tangentDirectionCalculated = 0.80797056423543978 - // lengthCalculated = 4.0198770235802987 - // angleCalculated = 0.80797056423544011 + PolylineBuilderEx.QueryClothoidParameters(queryPoint, startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, curveLength, out pointOnPath, out radiusCalculated, out tangentDirectionCalculated, out lengthCalculated, out angleCalculated, SpatialReferences.WGS84); - queryPoint = MapPointBuilder.CreateMapPoint(1.85, 2.6); + pointOnPath = MapPointBuilderEx.CreateMapPoint(3.7652656620171379, 1.0332006103128575); + radiusCalculated = 2.4876382887687227; + tangentDirectionCalculated = 0.80797056423543978; + lengthCalculated = 4.0198770235802987; + angleCalculated = 0.80797056423544011; - PolylineBuilder.QueryClothoidParameters(queryPoint, startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, curveLength, out pointOnPath, out radiusCalculated, out tangentDirectionCalculated, out lengthCalculated, out angleCalculated, SpatialReferences.WGS84); + queryPoint = MapPointBuilderEx.CreateMapPoint(1.85, 2.6); - // pointOnPath = (1.8409964973501549, 2.6115979967308132) - // radiusCalculated = 1 - // tangentDirectionCalculated = -1.2831853071795867 - // lengthCalculated = 10 - // angleCalculated = 5 + PolylineBuilderEx.QueryClothoidParameters(queryPoint, startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, curveLength, out pointOnPath, out radiusCalculated, out tangentDirectionCalculated, out lengthCalculated, out angleCalculated, SpatialReferences.WGS84); + pointOnPath = MapPointBuilderEx.CreateMapPoint(1.8409964973501549, 2.6115979967308132); + radiusCalculated = 1; + tangentDirectionCalculated = -1.2831853071795867; + lengthCalculated = 10; + angleCalculated = 5; + tangentDirection = Math.PI / 4; - orientation = esriArcOrientation.esriArcClockwise; + orientation = ArcOrientation.ArcClockwise; startRadius = double.PositiveInfinity; endRadius = 0.8; - createMethod = esriClothoidCreateMethod.ByLength; + createMethod = ClothoidCreateMethod.ByLength; curveLength = 10; - Polyline polyline = PolylineBuilder.CreatePolyline(startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, curveLength, esriCurveDensifyMethod.ByLength, 0.5, SpatialReferences.WGS84); + Polyline polyline = PolylineBuilderEx.CreatePolyline(startPoint, tangentDirection, startRadius, endRadius, orientation, createMethod, curveLength, CurveDensifyMethod.ByLength, 0.5, SpatialReferences.WGS84); #endregion } public void SplitPolyline() { - // cref: Split Polyline at distance;ArcGIS.Core.Geometry.MultipartBuilder`1.SplitAtDistance(System.Double,System.Boolean,System.Boolean) - // cref: Split Polyline at distance;ArcGIS.Core.Geometry.MultipartBuilder`1.SplitPartAtDistance(System.Int32,System.Double,System.Boolean,System.Boolean) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.SplitAtDistance(System.Double,System.Boolean,System.Boolean) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.SplitPartAtDistance(System.Int32,System.Double,System.Boolean,System.Boolean) #region Split Polyline at distance // create list of points - MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0); + MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0); List list = new List(); list.Add(startPt); list.Add(endPt); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - // use the PolylineBuilder as we wish to manipulate the geometry - using (PolylineBuilder polylineBuilder = new PolylineBuilder(list)) - { - // split at a distance 0.75 - polylineBuilder.SplitAtDistance(0.75, false); - // get the polyline - Polyline p = polylineBuilder.ToGeometry(); - // polyline p should have 3 points (1,1), (1.75, 1), (2,1) + // BuilderEx constructors don't need to run on the MCT. - // add another path - MapPoint p1 = MapPointBuilder.CreateMapPoint(4.0, 1.0); - MapPoint p2 = MapPointBuilder.CreateMapPoint(6.0, 1.0); - MapPoint p3 = MapPointBuilder.CreateMapPoint(7.0, 1.0); - List pts = new List(); - pts.Add(p1); - pts.Add(p2); - pts.Add(p3); + // use the PolylineBuilder as we wish to manipulate the geometry + // use AttributeFlags.None as we have 2D points + PolylineBuilderEx polylineBuilder = new PolylineBuilderEx(list, AttributeFlags.None); + // split at a distance 0.75 + polylineBuilder.SplitAtDistance(0.75, false); + // get the polyline + Polyline p = polylineBuilder.ToGeometry(); + // polyline p should have 3 points (1,1), (1.75, 1), (2,1) - polylineBuilder.AddPart(pts); - p = polylineBuilder.ToGeometry(); + // add another path + MapPoint p1 = MapPointBuilderEx.CreateMapPoint(4.0, 1.0); + MapPoint p2 = MapPointBuilderEx.CreateMapPoint(6.0, 1.0); + MapPoint p3 = MapPointBuilderEx.CreateMapPoint(7.0, 1.0); + List pts = new List(); + pts.Add(p1); + pts.Add(p2); + pts.Add(p3); - // polyline p has 2 parts. Each part has 3 points + polylineBuilder.AddPart(pts); + p = polylineBuilder.ToGeometry(); - // split the 2nd path half way - dont create a new path - polylineBuilder.SplitPartAtDistance(1, 0.5, true, false); + // polyline p has 2 parts. Each part has 3 points - p = polylineBuilder.ToGeometry(); + // split the 2nd path half way - dont create a new path + polylineBuilder.SplitPartAtDistance(1, 0.5, true, false); - // polyline p still has 2 parts; but now has 7 points - } - }); + p = polylineBuilder.ToGeometry(); + + // polyline p still has 2 parts; but now has 7 points #endregion } @@ -1304,89 +1323,63 @@ public void SplitPolyline() public void ConstructPolygon() { { - // cref: Construct a Polygon - from an enumeration of MapPoints;ArcGIS.Core.Geometry.PolygonBuilder.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint}) - // cref: Construct a Polygon - from an enumeration of MapPoints;ArcGIS.Core.Geometry.PolygonBuilder.CreatePolygon(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.AttributeFlags,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.ToGeometry #region Construct a Polygon - from an enumeration of MapPoints - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. - MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(1.0, 2.0); - MapPoint pt3 = MapPointBuilder.CreateMapPoint(2.0, 2.0); - MapPoint pt4 = MapPointBuilder.CreateMapPoint(2.0, 1.0); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(1.0, 2.0); + MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(2.0, 2.0); + MapPoint pt4 = MapPointBuilderEx.CreateMapPoint(2.0, 1.0); List list = new List() { pt1, pt2, pt3, pt4 }; - // Builder convenience methods don't need to run on the MCT. - Polygon polygon = PolygonBuilder.CreatePolygon(list, SpatialReferences.WGS84); - - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (PolygonBuilder polygonBuilder = new PolygonBuilder(list)) - { - polygonBuilder.SpatialReference = SpatialReferences.WGS84; - polygon = polygonBuilder.ToGeometry(); - } - }); + Polygon polygon = PolygonBuilderEx.CreatePolygon(list, SpatialReferences.WGS84); + // polygon.HasZ will be false - it is determined by the HasZ flag of the points in the list + // or specifically use AttributeFlags.NoAttributes + polygon = PolygonBuilderEx.CreatePolygon(list, AttributeFlags.None); - // builderEx constructor's don't need to run on the MCT - PolygonBuilderEx polygonBuilderEx = new PolygonBuilderEx(list); - polygonBuilderEx.SpatialReference = SpatialReferences.WGS84; - polygon = polygonBuilderEx.ToGeometry() as Polygon; + // use AttributeFlags.None as we have 2D points + PolygonBuilderEx polygonBuilder = new PolygonBuilderEx(list, AttributeFlags.None); + polygonBuilder.SpatialReference = SpatialReferences.WGS84; + polygon = polygonBuilder.ToGeometry(); - // builderEx convenience methods don't need to run on the MCT - // use AttributeFlags.NoAttributes because we only have 2d points in the list - polygon = PolygonBuilderEx.CreatePolygon(list, AttributeFlags.NoAttributes); #endregion } { - // cref: Construct a Polygon - from an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.CreateEnvelope(ArcGIS.Core.Geometry.Envelope,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Polygon - from an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.CreateEnvelope(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Polygon - from an Envelope;ArcGIS.Core.Geometry.PolygonBuilder.CreatePolygon(ArcGIS.Core.Geometry.Envelope,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(ArcGIS.Core.Geometry.Envelope,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(ArcGIS.Core.Geometry.Envelope,ArcGIS.Core.Geometry.SpatialReference) #region Construct a Polygon - from an Envelope - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. - MapPoint minPt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint maxPt = MapPointBuilder.CreateMapPoint(2.0, 2.0); + MapPoint minPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint maxPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0); // Create an envelope - Envelope env = EnvelopeBuilder.CreateEnvelope(minPt, maxPt); - - // Builder convenience methods don't need to run on the MCT. - Polygon polygonFromEnv = PolygonBuilder.CreatePolygon(env); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(minPt, maxPt); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (PolygonBuilder polygonBuilder = new PolygonBuilder(env)) - { - polygonBuilder.SpatialReference = SpatialReferences.WGS84; - polygonFromEnv = polygonBuilder.ToGeometry(); - } - }); + Polygon polygonFromEnv = PolygonBuilderEx.CreatePolygon(env); - // builderEx constructors don't need to run on the MCt PolygonBuilderEx polygonBuilderEx = new PolygonBuilderEx(env); polygonBuilderEx.SpatialReference = SpatialReferences.WGS84; polygonFromEnv = polygonBuilderEx.ToGeometry() as Polygon; - // builderEx convenience methods don't need to run on MCT - polygonFromEnv = PolygonBuilderEx.CreatePolygon(env); - #endregion Create a Polygon from an Envelope } { Polygon polygon = null; - // cref: Get the points of a Polygon;ArcGIS.Core.Geometry.Multipart.Copy2DCoordinatesToList - // cref: Get the points of a Polygon;ArcGIS.Core.Geometry.Multipart.Copy3DCoordinatesToList - // cref: Get the points of a Polygon;ArcGIS.Core.Geometry.Multipatch.Copy3DCoordinatesToList - // cref: Get the points of a Polygon;ArcGIS.Core.Geometry.Multipart.Points + // cref: ArcGIS.Core.Geometry.Multipart.Points + // cref: ArcGIS.Core.Geometry.Multipart.Copy2DCoordinatesToList + // cref: ArcGIS.Core.Geometry.Multipart.Copy3DCoordinatesToList #region Get the points of a Polygon // get the points as a readonly Collection @@ -1402,14 +1395,15 @@ public void ConstructPolygon() IReadOnlyList coordinates3D = polygon.Copy3DCoordinatesToList(); #endregion - // cref: Get the parts of a Polygon;ArcGIS.Core.Geometry.Multipart.Parts + // cref: ArcGIS.Core.Geometry.Multipart.Parts #region Get the parts of a Polygon // get the parts as a readonly collection ReadOnlyPartCollection parts = polygon.Parts; #endregion - // cref: Enumerate the parts of a Polygon;ArcGIS.Core.Geometry.Multipart.Parts + // cref: ArcGIS.Core.Geometry.Multipart.Parts + // cref: ArcGIS.Core.Geometry.ReadOnlySegmentCollection #region Enumerate the parts of a Polygon int numSegments = 0; @@ -1426,8 +1420,8 @@ public void ConstructPolygon() #endregion - // cref: Get the segments of a Polygon;ArcGIS.Core.Geometry.Multipart.GetAllSegments(System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Segment}@) - // cref: Get the segments of a Polygon;ArcGIS.Core.Geometry.PolygonBuilder.CreatePolygon(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Segment},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.Multipart.GetAllSegments(System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Segment}@) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Segment},ArcGIS.Core.Geometry.SpatialReference) #region Get the segments of a Polygon List segmentList = new List(30); @@ -1437,17 +1431,17 @@ public void ConstructPolygon() // segmentList.Capacity = 30 // use the segments to build another polygon - Polygon polygonFromSegments = PolygonBuilder.CreatePolygon(collection); + Polygon polygonFromSegments = PolygonBuilderEx.CreatePolygon(collection); #endregion } - // cref: Build a donut polygon;ArcGIS.Core.Geometry.Coordinate2D.#ctor(System.Double,System.Double) - // cref: Build a donut polygon;ArcGIS.Core.Geometry.GeometryEngine.Area(ArcGIS.Core.Geometry.Geometry) - // cref: Build a donut polygon;ArcGIS.Core.Geometry.IGeometryEngine.Area(ArcGIS.Core.Geometry.Geometry) - // cref: Build a donut polygon;ArcGIS.Core.Geometry.MultipartBuilder`1.AddPart(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate2D}) - // cref: Build a donut polygon;ArcGIS.Core.Geometry.PolygonBuilder.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate2D},ArcGIS.Core.Geometry.SpatialReference) - // cref: Build a donut polygon;ArcGIS.Core.Geometry.PolygonBuilder.ToGeometry - // cref: Build a donut polygon;ArcGIS.Core.Geometry.Polygon.Area + // cref: ArcGIS.Core.Geometry.Coordinate2D.#ctor(System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate2D},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.Polygon.Area + // cref: ArcGIS.Core.Geometry.MultipartBuilderEx.AddPart(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate2D}) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Area(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Area(ArcGIS.Core.Geometry.Geometry) #region Build a donut polygon List outerCoordinates = new List(); @@ -1463,26 +1457,6 @@ public void ConstructPolygon() innerCoordinates.Add(new Coordinate2D(17.0, 17.0)); innerCoordinates.Add(new Coordinate2D(13.0, 17.0)); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - // use the PolygonBuilder as we wish to manipulate the parts - using (PolygonBuilder pb = new PolygonBuilder(outerCoordinates)) - { - Polygon donut = pb.ToGeometry(); - double area = donut.Area; // area = 100 - - pb.AddPart(innerCoordinates); - donut = pb.ToGeometry(); - - area = donut.Area; // area = 84.0 - - area = GeometryEngine.Instance.Area(donut); // area = 84.0 - } - }); - - - // builderEx constructors don't need to run on the MCt PolygonBuilderEx pbEx = new PolygonBuilderEx(outerCoordinates); Polygon donutEx = pbEx.ToGeometry() as Polygon; double areaEx = donutEx.Area; // area = 100 @@ -1498,6 +1472,7 @@ public void ConstructPolygon() #endregion } + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(IEnumerable{Polygon},SpatialReference) #region Create an N-sided regular polygon // @@ -1536,15 +1511,15 @@ public Polygon CreateRegularPolygon(int numSides, Coordinate2D center, double ra coords[numSides] = start; - return PolygonBuilder.CreatePolygon(coords); + return PolygonBuilderEx.CreatePolygon(coords); } #endregion - // cref: Get the exterior rings of a polygon - polygon.GetExteriorRing;ArcGIS.Core.Geometry.Polygon.GetExteriorRing(System.Int32,System.Boolean) - // cref: Get the exterior rings of a polygon - polygon.GetExteriorRing;ArcGIS.Core.Geometry.Polygon.GetExteriorRings(System.Boolean) - // cref: Get the exterior rings of a polygon - polygon.GetExteriorRing;ArcGIS.Core.Geometry.Polygon.IsExteriorRing(System.Int32) - // cref: Get the exterior rings of a polygon - polygon.GetExteriorRing;ArcGIS.Core.Geometry.Polygon.ExteriorRingCount + // cref: ArcGIS.Core.Geometry.Polygon.ExteriorRingCount + // cref: ArcGIS.Core.Geometry.Polygon.GetExteriorRings(System.Boolean) + // cref: ArcGIS.Core.Geometry.Polygon.IsExteriorRing(System.Int32) + // cref: ArcGIS.Core.Geometry.Polygon.GetExteriorRing(System.Int32,System.Boolean) #region Get the exterior rings of a polygon - polygon.GetExteriorRing public void GetExteriorRings(Polygon inputPolygon) { @@ -1562,6 +1537,7 @@ public void GetExteriorRings(Polygon inputPolygon) for (int idx = 0; idx < partCount; idx++) { bool isExteriorRing = inputPolygon.IsExteriorRing(idx); + var ring = inputPolygon.GetExteriorRing(idx); } } #endregion @@ -1571,91 +1547,68 @@ public void GetExteriorRings(Polygon inputPolygon) public void ConstructEnvelope() { - // cref: Construct an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint) - // cref: Construct an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.ToGeometry - // cref: Construct an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint) - // cref: Construct an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.ToGeometry #region Construct an Envelope - // Use a builder convenience method or use a builder constructor. - - MapPoint minPt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint maxPt = MapPointBuilder.CreateMapPoint(2.0, 2.0); + // Use a builderEx convenience method or use a builderEx constructor. - // Builder convenience methods don't need to run on the MCT. - Envelope envelope = EnvelopeBuilder.CreateEnvelope(minPt, maxPt); + MapPoint minPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint maxPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EnvelopeBuilder builder = new EnvelopeBuilder(minPt, maxPt)) - { - // do something with the builder - - envelope = builder.ToGeometry(); - } - }); + Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(minPt, maxPt); - // builderEx constructors don't need to run on the MCT. EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(minPt, maxPt); envelope = builderEx.ToGeometry() as Envelope; - // builderEx convenience methods don't need to run on the MCT - envelope = EnvelopeBuilderEx.CreateEnvelope(minPt, maxPt); - #endregion - // cref: Construct an Envelope - from a JSON string;ArcGIS.Core.Geometry.EnvelopeBuilder.FromJson(System.String) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.FromJson(System.String) #region Construct an Envelope - from a JSON string string jsonString = "{ \"xmin\" : 1, \"ymin\" : 2,\"xmax\":3,\"ymax\":4,\"spatialReference\":{\"wkid\":4326}}"; - Envelope envFromJson = EnvelopeBuilder.FromJson(jsonString); + Envelope envFromJson = EnvelopeBuilderEx.FromJson(jsonString); #endregion } + public void EnvelopeUnion() - { - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.IsEqual(ArcGIS.Core.Geometry.Envelope) - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.Union(ArcGIS.Core.Geometry.Envelope) - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.CreateEnvelope(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.Union(ArcGIS.Core.Geometry.Envelope) - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.Union(ArcGIS.Core.Geometry.Envelope) - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.Area - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.Center - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.CenterCoordinate - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.Depth - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.Height - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.IDMax - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.IDMin - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.IsEmpty - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.Length - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.MMax - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.MMin - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.PointCount - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.Width - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.XMax - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.XMin - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.YMax - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.YMin - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.ZMax - // cref: Union two Envelopes;ArcGIS.Core.Geometry.Envelope.ZMin - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.Center - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.CenterCoordinate - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.Depth - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.Height - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.Width - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.Center - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.CenterCoordinate - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.Depth - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.Height - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.IsEmpty - // cref: Union two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.Width + { + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.Envelope.Union(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.Envelope.Area + // cref: ArcGIS.Core.Geometry.Envelope.Depth + // cref: ArcGIS.Core.Geometry.Envelope.Height + // cref: ArcGIS.Core.Geometry.Envelope.Width + // cref: ArcGIS.Core.Geometry.Envelope.Length + // cref: ArcGIS.Core.Geometry.Envelope.Center + // cref: ArcGIS.Core.Geometry.Envelope.CenterCoordinate + // cref: ArcGIS.Core.Geometry.Envelope.IsEmpty + // cref: ArcGIS.Core.Geometry.Envelope.PointCount + // cref: ArcGIS.Core.Geometry.Envelope.XMin + // cref: ArcGIS.Core.Geometry.Envelope.XMax + // cref: ArcGIS.Core.Geometry.Envelope.YMin + // cref: ArcGIS.Core.Geometry.Envelope.YMax + // cref: ArcGIS.Core.Geometry.Envelope.ZMin + // cref: ArcGIS.Core.Geometry.Envelope.ZMax + // cref: ArcGIS.Core.Geometry.Envelope.MMin + // cref: ArcGIS.Core.Geometry.Envelope.MMax + // cref: ArcGIS.Core.Geometry.Envelope.IDMin + // cref: ArcGIS.Core.Geometry.Envelope.IDMax + // cref: ArcGIS.Core.Geometry.Envelope.IsEqual(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.Union(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.Depth + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.Height + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.Width + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.Center + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CenterCoordinate + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.IsEmpty + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.ToGeometry #region Union two Envelopes - // use the convenience builders - don't need to run on the MCT. - Envelope env1 = EnvelopeBuilder.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84); - Envelope env2 = EnvelopeBuilder.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84); + // use the convenience builders + Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84); + Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84); Envelope env3 = env1.Union(env2); @@ -1678,21 +1631,6 @@ public void EnvelopeUnion() bool isEqual = env1.IsEqual(env2); // false - // or use the builder constructor - need to run on the MCT. - using (var builder = new EnvelopeBuilder(0, 0, 1, 1, SpatialReferences.WGS84)) - { - env3 = builder.Union(env2); // builder is updated to the result - depth = builder.Depth; - height = builder.Height; - width = builder.Width; - - centerPt = builder.Center; - coord = builder.CenterCoordinate; - - isEmpty = builder.IsEmpty; - } - - // or use the builderEx constructors = don't need to run on the MCT. EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(0, 0, 1, 1, SpatialReferences.WGS84); builderEx.Union(env2); // builder is updated to the result @@ -1713,29 +1651,21 @@ public void EnvelopeUnion() public void EnvelopeIntersection() { - // cref: Intersect two Envelopes;ArcGIS.Core.Geometry.Envelope.Intersection(ArcGIS.Core.Geometry.Envelope) - // cref: Intersect two Envelopes;ArcGIS.Core.Geometry.Envelope.Intersects(ArcGIS.Core.Geometry.Envelope) - // cref: Intersect two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.Intersection(ArcGIS.Core.Geometry.Envelope) - // cref: Intersect two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilder.Intersects(ArcGIS.Core.Geometry.Envelope) - // cref: Intersect two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.Intersection(ArcGIS.Core.Geometry.Envelope) - // cref: Intersect two Envelopes;ArcGIS.Core.Geometry.EnvelopeBuilderEx.Intersects(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.Envelope.Intersection(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.Envelope.Intersects(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.Intersection(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.Intersects(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.ToGeometry #region Intersect two Envelopes - // use the convenience builders - don't need to run on the MCT. - Envelope env1 = EnvelopeBuilder.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84); - Envelope env2 = EnvelopeBuilder.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84); + // use the convenience builders + Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(0, 0, 1, 1, SpatialReferences.WGS84); + Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(0.5, 0.5, 1.5, 1.5, SpatialReferences.WGS84); bool intersects = env1.Intersects(env2); // true Envelope env3 = env1.Intersection(env2); - // or use the builder constructor - need to run on the MCT. - using (var builder = new EnvelopeBuilder(0, 0, 1, 1, SpatialReferences.WGS84)) - { - intersects = builder.Intersects(env2); // true - env3 = builder.Intersection(env2); - } - // or use the builderEx constructors = don't need to run on the MCT. EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(0, 0, 1, 1, SpatialReferences.WGS84); intersects = builderEx.Intersects(env2); @@ -1748,30 +1678,19 @@ public void EnvelopeIntersection() public void EnvelopeExpand() { // cref: Expand an Envelope;ArcGIS.Core.Geometry.Envelope.Expand(System.Double,System.Double,System.Boolean) - // cref: Expand an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.#ctor(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Expand an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.Expand(System.Double,System.Double,System.Boolean) // cref: Expand an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.#ctor(System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: Expand an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.Expand(System.Double,System.Double,System.Boolean) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.ToGeometry #region Expand an Envelope - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. - // Builder convenience methods don't need to run on the MCT. - Envelope envelope = EnvelopeBuilder.CreateEnvelope(100.0, 100.0, 500.0, 500.0); + // convenience methods don't need to run on the MCT. + Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(100.0, 100.0, 500.0, 500.0); // shrink the envelope by 50% Envelope result = envelope.Expand(0.5, 0.5, true); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EnvelopeBuilder eBuilder = new EnvelopeBuilder(100.0, 100.0, 500.0, 500.0)) - { - // shrink by 50% - eBuilder.Expand(0.5, 0.5, true); - - result = eBuilder.ToGeometry(); - } - }); // builderEx constructors don't need to run on the MCT. EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(100.0, 100.0, 500.0, 500.0); @@ -1783,30 +1702,23 @@ public void EnvelopeExpand() public void EnvelopeUpdate() { - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.#ctor(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.SetMCoords(System.Double,System.Double) - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.SetXYCoords(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D) - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.SetZCoords(System.Double,System.Double) - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.SetMCoords(System.Double,System.Double) - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.SetXYCoords(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D) - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.SetZCoords(System.Double,System.Double) - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.MMax - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.MMin - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.XMax - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.XMin - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.YMax - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.YMin - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.ZMax - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilder.ZMin - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.HasM - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.MMax - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.MMin - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.XMax - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.XMin - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.YMax - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.YMin - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.ZMax - // cref: Update Coordinates of an Envelope;ArcGIS.Core.Geometry.EnvelopeBuilderEx.ZMin + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.#ctor(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.XMin + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.XMax + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.YMin + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.YMax + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.ZMin + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.ZMax + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.MMin + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.MMax + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.IDMax + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.IDMin + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.SetZCoords(System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.SetXYCoords(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.HasM + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.SetMCoords(System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.SetIDCoords(System.Int32,System.Int32) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.ToGeometry #region Update Coordinates of an Envelope Coordinate2D minCoord = new Coordinate2D(1, 3); @@ -1815,62 +1727,8 @@ public void EnvelopeUpdate() Coordinate2D c1 = new Coordinate2D(0, 5); Coordinate2D c2 = new Coordinate2D(1, 3); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EnvelopeBuilder builder = new EnvelopeBuilder(minCoord, maxCoord)) - { - // builder.XMin, YMin, Zmin, MMin = 1, 3, 0, double.Nan - // builder.XMax, YMax, ZMax, MMax = 2, 4, 0, double.Nan - - // set XMin. if XMin > XMax; both XMin and XMax change - builder.XMin = 6; - // builder.XMin, YMin, ZMin, MMin = 6, 3, 0, double.Nan - // builder.XMax, YMax, ZMax, MMax = 6, 4, 0, double.Nan - - // set XMax - builder.XMax = 8; - // builder.XMin, YMin, ZMin, MMin = 6, 3, 0, double.Nan - // builder.XMax, YMax, ZMax, MMax = 8, 4, 0, double.Nan - - // set XMax. if XMax < XMin, both XMin and XMax change - builder.XMax = 3; - // builder.XMin, YMin, ZMin, MMin = 3, 3, 0, double.Nan - // builder.XMax, YMax, ZMax, MMax = 3, 4, 0, double.Nan - - // set YMin - builder.YMin = 2; - // builder.XMin, YMin, ZMin, MMin = 3, 2, 0, double.Nan - // builder.XMax, YMax, ZMax, MMax = 3, 4, 0, double.Nan - - // set ZMin. if ZMin > ZMax, both ZMin and ZMax change - builder.ZMin = 3; - // builder.XMin, YMin, ZMin, MMin = 3, 2, 3, double.Nan - // builder.XMax, YMax, ZMax, MMax = 3, 4, 3, double.Nan - - // set ZMax. if ZMax < ZMin. both ZMin and ZMax change - builder.ZMax = -1; - // builder.XMin, YMin, ZMin, MMin = 3, 2, -1, double.Nan - // builder.XMax, YMax, ZMax, MMax = 3, 4, -1, double.Nan - - builder.SetZCoords(8, -5); - // builder.XMin, YMin, ZMin, MMin = 3, 2, -5, double.Nan - // builder.XMax, YMax, ZMax, MMax = 3, 4, 8, double.Nan - - - builder.SetXYCoords(c1, c2); - // builder.XMin, YMin, ZMin, MMin = 0, 3, -5, double.Nan - // builder.XMax, YMax, ZMax, MMax = 1, 5, 8, double.Nan - - - builder.HasM = true; - builder.SetMCoords(2, 5); - - var geom = builder.ToGeometry(); - } - }); - - // or use the EnvelopeBuilderEx. This constructor doesn't need to run on the MCT. + + // use the EnvelopeBuilderEx. This constructor doesn't need to run on the MCT. EnvelopeBuilderEx builderEx = new EnvelopeBuilderEx(minCoord, maxCoord); // builderEx.XMin, YMin, Zmin, MMin = 1, 3, 0, double.Nan @@ -1928,64 +1786,58 @@ public void EnvelopeUpdate() public void ConstructMultiPoint() { - // cref: Construct a Multipoint - from an enumeration of MapPoints;ArcGIS.Core.Geometry.MultipointBuilder.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint}) - // cref: Construct a Multipoint - from an enumeration of MapPoints;ArcGIS.Core.Geometry.MultipointBuilder.CreateMultipoint(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Multipoint - from an enumeration of MapPoints;ArcGIS.Core.Geometry.MultipointBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Multipoint - from an enumeration of MapPoints;ArcGIS.Core.Geometry.MultipointBuilderEx.ToGeometry - // cref: Construct a Multipoint - from an enumeration of MapPoints;ArcGIS.Core.Geometry.MultipointBuilderEx.PointCount + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.AttributeFlags,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.PointCount + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.CreateMultipoint(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.CreateMultipoint(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.AttributeFlags, ArcGIS.Core.Geometry.SpatialReference) #region Construct a Multipoint - from an enumeration of MapPoints - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. List list = new List(); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0)); - list.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0)); - list.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); - - // Builder convenience methods don't need to run on the MCT. - Multipoint multiPoint = MultipointBuilder.CreateMultipoint(list); - int ptCount = multiPoint.PointCount; - - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (MultipointBuilder mpb = new MultipointBuilder(list)) - { - // do something with the builder + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); - Multipoint mPt = mpb.ToGeometry(); + // use the builderEx constructors - don't need to run on the MCT. + // use AttributeFlags.NoAttributes - we have 2d points in the list + MultipointBuilderEx builderEx = new MultipointBuilderEx(list, AttributeFlags.None); + Multipoint multiPoint = builderEx.ToGeometry() as Multipoint; + int ptCount = builderEx.PointCount; - ptCount = mpb.PointCount; - } - }); + // builderEx convenience methods dont need to run on the MCT + multiPoint = MultipointBuilderEx.CreateMultipoint(list); + // multiPoint.HasZ, HasM, HasID will be false - the attributes are determined + // based on the attribute state of the points in the list - // or use the builderEx constructors - don't need to run on the MCT. - MultipointBuilderEx builderEx = new MultipointBuilderEx(list); - multiPoint = builderEx.ToGeometry() as Multipoint; - ptCount = builderEx.PointCount; + // or specifically set the state + multiPoint = MultipointBuilderEx.CreateMultipoint(list, AttributeFlags.None); + // multiPoint.HasM = false + multiPoint = MultipointBuilderEx.CreateMultipoint(list, AttributeFlags.HasM); + // multiPoint.HasM = true - // builderEx convenience methods dont need to run on the MCT - // use AttributeFlags.NoAttributes - we have 2d points in the list - multiPoint = MultipointBuilderEx.CreateMultipoint(list, AttributeFlags.NoAttributes); + ptCount = multiPoint.PointCount; #endregion } public void MultipointBuilderEx_() { - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate2D},ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.RemovePoints(System.Int32,System.Int32) - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.SetEmpty - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.SetPoint(System.Int32,ArcGIS.Core.Geometry.MapPoint) - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.Coords - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.HasID - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.HasM - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.HasZ - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.IDs - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.Ms - // cref: Construct a Multipoint - using MultipointBuilderEx;ArcGIS.Core.Geometry.MultipointBuilderEx.Zs + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate2D},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.HasZ + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.Zs + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.HasM + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.Ms + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.HasID + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.IDs + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.GetPoint + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.SetEmpty + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.Coordinate2Ds + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.SetPoint(System.Int32,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.RemovePoints(System.Int32,System.Int32) #region Construct a Multipoint - using MultipointBuilderEx Coordinate2D[] coordinate2Ds = new Coordinate2D[] { new Coordinate2D(1, 2), new Coordinate2D(-1, -2) }; @@ -1993,7 +1845,7 @@ public void MultipointBuilderEx_() MultipointBuilderEx builder = new MultipointBuilderEx(coordinate2Ds, sr); - // builder.Coords.Count = 2 + // builder.PointCount = 2 builder.HasZ = true; // builder.Zs.Count = 2 @@ -2020,7 +1872,7 @@ public void MultipointBuilderEx_() // reset coordinates List inCoords = new List() { new Coordinate2D(1, 2), new Coordinate2D(3, 4), new Coordinate2D(5, 6) }; - builder.Coords = inCoords; + builder.Coordinate2Ds = inCoords; // builder.Coords.Count = 3 // builder.HasZ = true // builder.HasM = true @@ -2066,7 +1918,7 @@ public void MultipointBuilderEx_() // create a new point - MapPoint point = MapPointBuilder.CreateMapPoint(-300, 400, 4); + MapPoint point = MapPointBuilderEx.CreateMapPoint(-300, 400, 4); builder.SetPoint(2, point); // coordinates are now (x, y, z, m, id) @@ -2082,41 +1934,19 @@ public void MultipointBuilderEx_() public void ModifyMultipoint() { Multipoint multipoint = null; - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilder.#ctor(ArcGIS.Core.Geometry.Multipoint) - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilder.Add(ArcGIS.Core.Geometry.MapPoint) - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilder.GetMapPoint(System.Int32) - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilder.RemovePoint(System.Int32) - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilder.ToGeometry - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilderEx.#ctor(ArcGIS.Core.Geometry.Multipoint) - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilderEx.AddPoint(ArcGIS.Core.Geometry.MapPoint) - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilderEx.GetPoint(System.Int32) - // cref: Modify the points of a Multipoint;ArcGIS.Core.Geometry.MultipointBuilderEx.RemovePoint(System.Int32) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.#ctor(ArcGIS.Core.Geometry.Multipoint) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.RemovePoint(System.Int32) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.GetPoint(System.Int32) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.AddPoint(ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.Multipoint.Copy2DCoordinatesToList + // cref: ArcGIS.Core.Geometry.Multipoint.Copy3DCoordinatesToList #region Modify the points of a Multipoint - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - // assume a multiPoint has been built from 4 points - // the modified multiPoint will have the first point removed and the last point moved - - using (MultipointBuilder mpb = new MultipointBuilder(multipoint)) - { - // remove the first point - mpb.RemovePoint(0); - - // modify the coordinates of the last point - MapPoint pt = mpb.GetMapPoint(mpb.PointCount - 1); - mpb.RemovePoint(mpb.PointCount - 1); - - MapPoint newPt = MapPointBuilder.CreateMapPoint(pt.X + 1.0, pt.Y + 2.0); - mpb.Add(newPt); - - Multipoint modifiedMultiPoint = mpb.ToGeometry(); - } - }); - + // assume a multiPoint has been built from 4 points + // the modified multiPoint will have the first point removed and the last point moved - // or use the builderEx constructors = don't need to run on the MCT. + // use the builderEx constructors = don't need to run on the MCT. MultipointBuilderEx builderEx = new MultipointBuilderEx(multipoint); // remove the first point builderEx.RemovePoint(0); @@ -2124,12 +1954,14 @@ public void ModifyMultipoint() var ptEx = builderEx.GetPoint(builderEx.PointCount - 1); builderEx.RemovePoint(builderEx.PointCount - 1); - var newPtEx = MapPointBuilder.CreateMapPoint(ptEx.X + 1.0, ptEx.Y + 2.0); + var newPtEx = MapPointBuilderEx.CreateMapPoint(ptEx.X + 1.0, ptEx.Y + 2.0); builderEx.AddPoint(newPtEx); Multipoint modifiedMultiPointEx = builderEx.ToGeometry() as Multipoint; #endregion + // cref: ArcGIS.Core.Geometry.MultiPoint.Copy2DCoordinatesToList + // cref: ArcGIS.Core.Geometry.MultiPoint.Copy3DCoordinatesToList #region Retrieve Points, 2D Coordinates, 3D Coordinates from a multipoint ReadOnlyPointCollection points = multipoint.Points; @@ -2144,71 +1976,39 @@ public void ModifyMultipoint() public void ConstructLineSegment() { - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.#ctor(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.#ctor(ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.#ctor(ArcGIS.Core.Geometry.LineSegment) - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint) - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.CreateLineSegment(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.CreateLineSegment(ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.CreateLineSegment(ArcGIS.Core.Geometry.LineSegment,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.CreateLineSegment(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a LineSegment using two MapPoints;ArcGIS.Core.Geometry.LineBuilder.ToSegment + // cref: ArcGIS.Core.Geometry.LineBuilderEx.CreateLineSegment(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.CreateLineSegment(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.CreateLineSegment(ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.CreateLineSegment(ArcGIS.Core.Geometry.LineSegment,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.#ctor(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.#ctor(ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.#ctor(ArcGIS.Core.Geometry.LineSegment,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.ToSegment #region Construct a LineSegment using two MapPoints - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. - MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 1.0); + MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0); - // Builder convenience methods don't need to run on the MCT. - LineSegment lineFromMapPoint = LineBuilder.CreateLineSegment(startPt, endPt); + // BuilderEx convenience methods don't need to run on the MCT. + LineSegment lineFromMapPoint = LineBuilderEx.CreateLineSegment(startPt, endPt); // coordinate2D Coordinate2D start2d = (Coordinate2D)startPt; Coordinate2D end2d = (Coordinate2D)endPt; - LineSegment lineFromCoordinate2D = LineBuilder.CreateLineSegment(start2d, end2d); + LineSegment lineFromCoordinate2D = LineBuilderEx.CreateLineSegment(start2d, end2d); // coordinate3D Coordinate3D start3d = (Coordinate3D)startPt; Coordinate3D end3d = (Coordinate3D)endPt; - LineSegment lineFromCoordinate3D = LineBuilder.CreateLineSegment(start3d, end3d); + LineSegment lineFromCoordinate3D = LineBuilderEx.CreateLineSegment(start3d, end3d); // lineSegment - LineSegment anotherLineFromLineSegment = LineBuilder.CreateLineSegment(lineFromCoordinate3D); - - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (LineBuilder lb = new LineBuilder(startPt, endPt)) - { - // do something with the builder - - lineFromMapPoint = lb.ToSegment(); - } - - using (LineBuilder lb = new LineBuilder(start2d, end2d)) - { - // do something with the builder - - lineFromCoordinate2D = lb.ToSegment(); - } - - using (LineBuilder lb = new LineBuilder(start3d, end3d)) - { - // do something with the builder - - lineFromCoordinate3D = lb.ToSegment(); - } - - using (LineBuilder lb = new LineBuilder(lineFromCoordinate3D)) - { - // do something with the builder - - anotherLineFromLineSegment = lb.ToSegment(); - } - }); + LineSegment anotherLineFromLineSegment = LineBuilderEx.CreateLineSegment(lineFromCoordinate3D); // builderEx constructors don't need to run on the MCT @@ -2227,61 +2027,31 @@ public void ConstructLineSegment() lbEx = new LineBuilderEx(lineFromCoordinate3D); anotherLineFromLineSegment = lbEx.ToSegment() as LineSegment; - - // builderEx convenience methods don't need to run on the MCT - lineFromMapPoint = LineBuilderEx.CreateLineSegment(startPt, endPt); - lineFromCoordinate2D = LineBuilderEx.CreateLineSegment(start2d, end2d); - lineFromCoordinate3D = LineBuilderEx.CreateLineSegment(start3d, end3d); - anotherLineFromLineSegment = LineBuilderEx.CreateLineSegment(lineFromCoordinate3D); - #endregion LineSegment lineSegment = null; - // cref: Alter LineSegment Coordinates;ArcGIS.Core.Geometry.LineBuilder.QueryCoords(ArcGIS.Core.Geometry.MapPoint@,ArcGIS.Core.Geometry.MapPoint@) - // cref: Alter LineSegment Coordinates;ArcGIS.Core.Geometry.LineBuilder.SetCoords(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint) - // cref: Alter LineSegment Coordinates;ArcGIS.Core.Geometry.LineBuilder.EndPoint - // cref: Alter LineSegment Coordinates;ArcGIS.Core.Geometry.LineBuilder.StartPoint + // cref: ArcGIS.Core.Geometry.LineBuilderEx.QueryCoords(ArcGIS.Core.Geometry.MapPoint@,ArcGIS.Core.Geometry.MapPoint@) + // cref: ArcGIS.Core.Geometry.SegmentBuilderEx.StartPoint + // cref: ArcGIS.Core.Geometry.SegmentBuilderEx.EndPoint + // cref: ArcGIS.Core.Geometry.LineBuilderEx.SetCoords(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.LineBuilderEx.ToSegment #region Alter LineSegment Coordinates - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - // use the builder constructor - using (LineBuilder lb = new LineBuilder(lineSegment)) - { - // find the existing coordinates - lb.QueryCoords(out startPt, out endPt); - - // or use - //startPt = lb.StartPoint; - //endPt = lb.EndPoint; - - // update the coordinates - lb.SetCoords(GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint, GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint); - - // or use - //lb.StartPoint = GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint; - //lb.EndPoint = GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint; - - LineSegment anotherLineSegment = lb.ToSegment(); - } - }); - // builderEx constructors don't need to run on the MCT LineBuilderEx lbuilderEx = new LineBuilderEx(lineSegment); // find the existing coordinates lbuilderEx.QueryCoords(out startPt, out endPt); // or use - //startPt = lb.StartPoint; - //endPt = lb.EndPoint; + //startPt = lbuilderEx.StartPoint; + //endPt = lbuilderEx.EndPoint; // update the coordinates lbuilderEx.SetCoords(GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint, GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint); // or use - //lb.StartPoint = GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint; - //lb.EndPoint = GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint; + //lbuilderEx.StartPoint = GeometryEngine.Instance.Move(startPt, 10, 10) as MapPoint; + //lbuilderEx.EndPoint = GeometryEngine.Instance.Move(endPt, -10, -10) as MapPoint; LineSegment segment2 = lbuilderEx.ToSegment() as LineSegment; @@ -2293,96 +2063,78 @@ public void ConstructLineSegment() public void ConstructCubicBezier() { - // cref: Construct a Cubic Bezier - from Coordinates;ArcGIS.Core.Geometry.CubicBezierBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.MapPoint) - // cref: Construct a Cubic Bezier - from Coordinates;ArcGIS.Core.Geometry.CubicBezierBuilder.CreateCubicBezierSegment(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.CreateCubicBezierSegment(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ToSegment + // cref: ArcGIS.Core.Geometry.CubicBezierSegment #region Construct a Cubic Bezier - from Coordinates - // Use a builder convenience method or a builder constructor. + // Use a builderEx convenience method or a builderEx constructor. - MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0); - MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 2.0, 3.0); + MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 3.0); + MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0, 3.0); Coordinate2D ctrl1Pt = new Coordinate2D(1.0, 2.0); Coordinate2D ctrl2Pt = new Coordinate2D(2.0, 1.0); - // Builder convenience methods don't need to run on the MCT - CubicBezierSegment bezier = CubicBezierBuilder.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt, SpatialReferences.WGS84); + // BuilderEx convenience methods don't need to run on the MCT + CubicBezierSegment bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt, SpatialReferences.WGS84); - // Builder constructors need to run on the MCT - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (CubicBezierBuilder cbb = new CubicBezierBuilder(startPt, ctrl1Pt, ctrl2Pt, endPt)) - { - // do something with the builder - - bezier = cbb.ToSegment(); - } - }); + // without a SR + bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt); // builderEx constructors dont need to run on the MCT - CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(startPt, ctrl1Pt.ToMapPoint(), ctrl2Pt.ToMapPoint(), endPt); + CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(startPt, ctrl1Pt, ctrl2Pt, endPt); + bezier = cbbEx.ToSegment() as CubicBezierSegment; + + // another alternative + cbbEx = new CubicBezierBuilderEx(startPt, ctrl1Pt.ToMapPoint(), ctrl2Pt.ToMapPoint(), endPt); bezier = cbbEx.ToSegment() as CubicBezierSegment; - // builderEx convenience methods dont need to run on the MCt - bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt); #endregion } public void ConstructCubicBezier2() { - // cref: Construct a Cubic Bezier - from MapPoints;ArcGIS.Core.Geometry.CubicBezierBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint) - // cref: Construct a Cubic Bezier - from MapPoints;ArcGIS.Core.Geometry.CubicBezierBuilder.CreateCubicBezierSegment(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.CreateCubicBezierSegment(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ToSegment #region Construct a Cubic Bezier - from MapPoints - // Use a builder convenience method or a builder constructor. + // Use a builderEx convenience method or a builderEx constructor. - MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); - MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84); - - MapPoint ctrl1Pt = MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84); - MapPoint ctrl2Pt = MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84); - - // Builder convenience methods don't need to run on the MCT - CubicBezierSegment bezier = CubicBezierBuilder.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt); - - // Builder constructors need to run on the MCT - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (CubicBezierBuilder cbb = new CubicBezierBuilder(startPt, ctrl1Pt, ctrl2Pt, endPt)) - { - // do something with the builder + MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); + MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84); - bezier = cbb.ToSegment(); - } - }); + MapPoint ctrl1Pt = MapPointBuilderEx.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84); + MapPoint ctrl2Pt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84); + // BuilderEx convenience methods don't need to run on the MCT + CubicBezierSegment bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt); // builderEx constructors dont need to run on the MCT CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(startPt, ctrl1Pt, ctrl2Pt, endPt); bezier = cbbEx.ToSegment() as CubicBezierSegment; - // builderEx convenience methods dont need to run on the MCt - bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(startPt, ctrl1Pt, ctrl2Pt, endPt); - #endregion } public void ConstructCubicBezier3() { - // cref: Construct a Cubic Bezier - from an enumeration of MapPoints;ArcGIS.Core.Geometry.CubicBezierBuilder.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint}) - // cref: Construct a Cubic Bezier - from an enumeration of MapPoints;ArcGIS.Core.Geometry.CubicBezierBuilder.CreateCubicBezierSegment(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Cubic Bezier - from an enumeration of MapPoints;ArcGIS.Core.Geometry.CubicBezierBuilder.ToSegment + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.CreateCubicBezierSegment(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ToSegment #region Construct a Cubic Bezier - from an enumeration of MapPoints - // Use a builder convenience method or use a builder constructor. + // Use a buildeExr convenience method or use a builderEx constructor. - MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); - MapPoint endPt = MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84); + MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); + MapPoint endPt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84); - MapPoint ctrl1Pt = MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84); - MapPoint ctrl2Pt = MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84); + MapPoint ctrl1Pt = MapPointBuilderEx.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84); + MapPoint ctrl2Pt = MapPointBuilderEx.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84); List listMapPoints = new List(); listMapPoints.Add(startPt); @@ -2390,27 +2142,13 @@ public void ConstructCubicBezier3() listMapPoints.Add(ctrl2Pt); listMapPoints.Add(endPt); - // Builder convenience methods don't need to run on the MCT - CubicBezierSegment bezier = CubicBezierBuilder.CreateCubicBezierSegment(listMapPoints); - - // Builder constructors need to run on the MCT - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (CubicBezierBuilder cbb = new CubicBezierBuilder(listMapPoints)) - { - // do something with the builder - - bezier = cbb.ToSegment(); - } - }); + // BuilderEx convenience methods don't need to run on the MCT + CubicBezierSegment bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(listMapPoints); // builderEx constructors dont need to run on the MCT CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(listMapPoints); bezier = cbbEx.ToSegment() as CubicBezierSegment; - // builderEx convenience methods dont need to run on the MCt - bezier = CubicBezierBuilderEx.CreateCubicBezierSegment(listMapPoints); - #endregion } @@ -2418,31 +2156,17 @@ public void ConstructCubicBezierBuilderUtils() { CubicBezierSegment bezierSegment = null; - // cref: Cubic Bezier Builder Properties;ArcGIS.Core.Geometry.CubicBezierBuilder.#ctor(ArcGIS.Core.Geometry.CubicBezierSegment) - // cref: Cubic Bezier Builder Properties;ArcGIS.Core.Geometry.CubicBezierBuilder.QueryCoords(ArcGIS.Core.Geometry.MapPoint@,ArcGIS.Core.Geometry.Coordinate2D@,ArcGIS.Core.Geometry.Coordinate2D@,ArcGIS.Core.Geometry.MapPoint@) - // cref: Cubic Bezier Builder Properties;ArcGIS.Core.Geometry.CubicBezierBuilder.ControlPoint1 - // cref: Cubic Bezier Builder Properties;ArcGIS.Core.Geometry.CubicBezierBuilder.ControlPoint2 - // cref: Cubic Bezier Builder Properties;ArcGIS.Core.Geometry.CubicBezierBuilder.EndPoint - // cref: Cubic Bezier Builder Properties;ArcGIS.Core.Geometry.CubicBezierBuilder.StartPoint + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.#ctor(ArcGIS.Core.Geometry.CubicBezierSegment,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.SegmentBuilderEx.StartPoint + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ControlPoint1 + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ControlPoint2 + // cref: ArcGIS.Core.Geometry.SegmentBuilderEx.EndPoint + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.QueryCoords(ArcGIS.Core.Geometry.MapPoint@,ArcGIS.Core.Geometry.Coordinate2D@,ArcGIS.Core.Geometry.Coordinate2D@,ArcGIS.Core.Geometry.MapPoint@) #region Cubic Bezier Builder Properties - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - // retrieve the bezier curve's control points - using (CubicBezierBuilder cbb = new CubicBezierBuilder(bezierSegment)) - { - MapPoint startPt = cbb.StartPoint; - Coordinate2D ctrlPt1 = cbb.ControlPoint1; - Coordinate2D ctrlPt2 = cbb.ControlPoint2; - MapPoint endPt = cbb.EndPoint; - - // or use the QueryCoords method - cbb.QueryCoords(out startPt, out ctrlPt1, out ctrlPt2, out endPt); - } - }); + // retrieve the bezier curve's control points - CubicBezierBuilder cbbEx = new CubicBezierBuilder(bezierSegment); + CubicBezierBuilderEx cbbEx = new CubicBezierBuilderEx(bezierSegment); MapPoint startPtEx = cbbEx.StartPoint; Coordinate2D ctrlPt1Ex = cbbEx.ControlPoint1; Coordinate2D ctrlPt2Ex = cbbEx.ControlPoint2; @@ -2457,16 +2181,16 @@ public void ConstructCubicBezierUtils() { CubicBezierSegment bezierSegment = null; - // cref: Cubic Bezier Properties;ArcGIS.Core.Geometry.CubicBezierSegment.ControlPoint1 - // cref: Cubic Bezier Properties;ArcGIS.Core.Geometry.CubicBezierSegment.ControlPoint2 - // cref: Cubic Bezier Properties;ArcGIS.Core.Geometry.CubicBezierSegment.IsCurve - // cref: Cubic Bezier Properties;ArcGIS.Core.Geometry.CubicBezierSegment.Length - // cref: Cubic Bezier Properties;ArcGIS.Core.Geometry.Segment.EndPoint - // cref: Cubic Bezier Properties;ArcGIS.Core.Geometry.Segment.StartPoint + // cref: ArcGIS.Core.Geometry.Segment.StartPoint + // cref: ArcGIS.Core.Geometry.CubicBezierSegment.ControlPoint1 + // cref: ArcGIS.Core.Geometry.CubicBezierSegment.ControlPoint2 + // cref: ArcGIS.Core.Geometry.Segment.EndPoint + // cref: ArcGIS.Core.Geometry.CubicBezierSegment.IsCurve + // cref: ArcGIS.Core.Geometry.CubicBezierSegment.Length #region Cubic Bezier Properties // retrieve the bezier curve's control points - CubicBezierSegment cb = CubicBezierBuilder.CreateCubicBezierSegment(bezierSegment); + CubicBezierSegment cb = CubicBezierBuilderEx.CreateCubicBezierSegment(bezierSegment); MapPoint startPt = cb.StartPoint; Coordinate2D ctrlPt1 = cb.ControlPoint1; Coordinate2D ctrlPt2 = cb.ControlPoint2; @@ -2477,9 +2201,10 @@ public void ConstructCubicBezierUtils() #endregion + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline(Segment,SpatialReference) #region Construct a Polyline - from a Cubic Bezier - Polyline polyline = PolylineBuilder.CreatePolyline(bezierSegment); + Polyline polyline = PolylineBuilderEx.CreatePolyline(bezierSegment); #endregion } @@ -2489,78 +2214,70 @@ public void ConstructCubicBezierUtils() public void ConstructArcUsingInteriorPt() { - // cref: Construct a Circular Arc - using an interior point;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D) - // cref: Construct a Circular Arc - using an interior point;ArcGIS.Core.Geometry.EllipticArcBuilder.CreateEllipticArcSegment(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circular Arc - using an interior point;ArcGIS.Core.Geometry.EllipticArcBuilder.ToSegment + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateCircularArc(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.ToSegment #region Construct a Circular Arc - using an interior point // Construct a circular arc from (2, 1) to (1, 2) with interior pt (1 + sqrt(2)/2, 1 + sqrt(2)/2). - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. - MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1); - MapPoint toPt = MapPointBuilder.CreateMapPoint(1, 2); + MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1); + MapPoint toPt = MapPointBuilderEx.CreateMapPoint(1, 2); Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2); - // Builder convenience methods don't need to run on the MCT. - EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt, toPt, interiorPt); + // BuilderEx convenience methods don't need to run on the MCT. + EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, interiorPt); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EllipticArcBuilder cab = new EllipticArcBuilder(fromPt, toPt, interiorPt)) - { - // do something with the builder + // BuilderEx constructors dont need to run on the MCT. + EllipticArcBuilderEx eab = new EllipticArcBuilderEx(fromPt, toPt, interiorPt); + // do something with the builder - EllipticArcSegment anotherCircularArc = cab.ToSegment(); - } - }); + EllipticArcSegment anotherCircularArc = eab.ToSegment(); #endregion } public void ConstructArcUsingChordAndBearing() { - // cref: Construct a Circular Arc - using a chord length and bearing;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.MinorOrMajor,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circular Arc - using a chord length and bearing;ArcGIS.Core.Geometry.EllipticArcBuilder.CreateEllipticArcSegment(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.MinorOrMajor,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateCircularArc(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.MinorOrMajor,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.MinorOrMajor,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.ToSegment #region Construct a Circular Arc - using a chord length and bearing // Construct a circular arc counterclockwise from (2, 1) to (1, 2) such that the embedded // circle has center point at (1, 1) and radius = 1. - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. - MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1, SpatialReferences.WGS84); + MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1, SpatialReferences.WGS84); double chordLength = Math.Sqrt(2); double chordBearing = 3 * Math.PI / 4; double radius = 1; - esriArcOrientation orientation = esriArcOrientation.esriArcCounterClockwise; + ArcOrientation orientation = ArcOrientation.ArcCounterClockwise; MinorOrMajor minorOrMajor = MinorOrMajor.Minor; - // Builder convenience methods don't need to run on the MCT. - EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor); + // BuildeExr convenience methods don't need to run on the MCT. + EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EllipticArcBuilder cab = new EllipticArcBuilder(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor)) - { - // do something with the builder + // BuilderEx constructors need to run on the MCT. + EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor); + // do something with the builder - EllipticArcSegment anotherCircularArc = cab.ToSegment(); - } - }); + EllipticArcSegment anotherCircularArc = cab.ToSegment(); #endregion } public void ConstructArcUsingCenterPtAngleAndRadius() { - // cref: Construct a Circular Arc - using a center point, angle and radius;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(System.Double,System.Double,ArcGIS.Core.Geometry.Coordinate2D,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circular Arc - using a center point, angle and radius;ArcGIS.Core.Geometry.EllipticArcBuilder.CreateEllipticArcSegment(System.Double,System.Double,ArcGIS.Core.Geometry.Coordinate2D,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateCircularArc(System.Double,System.Double,ArcGIS.Core.Geometry.Coordinate2D,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(System.Double,System.Double,ArcGIS.Core.Geometry.Coordinate2D,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.ToSegment #region Construct a Circular Arc - using a center point, angle and radius // Construct a circular arc with center point at (0, 0), from angle = 0, // central angle = pi/2, radius = 1. - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. SpatialReference sr4326 = SpatialReferences.WGS84; Coordinate2D centerPt = new Coordinate2D(0, 0); @@ -2568,142 +2285,118 @@ public void ConstructArcUsingCenterPtAngleAndRadius() double centralAngle = Math.PI / 2; double radius = 1; - // Builder convenience methods don't need to run on the MCT. - EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromAngle, centralAngle, centerPt, radius, sr4326); - - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EllipticArcBuilder cab = new EllipticArcBuilder(fromAngle, centralAngle, centerPt, radius, sr4326)) - { - // do something with the builder + // BuilderEx convenience methods don't need to run on the MCT. + EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromAngle, centralAngle, centerPt, radius, sr4326); - EllipticArcSegment otherCircularArc = cab.ToSegment(); - } - }); + // BuilderEx constructors dont need to run on the MCT. + EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromAngle, centralAngle, centerPt, radius, sr4326); + EllipticArcSegment otherCircularArc = cab.ToSegment(); #endregion } public void ConstructArcCenterPtRotationAngle() { - // cref: Construct a Circular Arc - using a center point and rotation angle;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(ArcGIS.Core.Geometry.Coordinate2D,System.Double,System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circular Arc - using a center point and rotation angle;ArcGIS.Core.Geometry.EllipticArcBuilder.CreateEllipticArcSegment(ArcGIS.Core.Geometry.Coordinate2D,System.Double,System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circular Arc - using a center point and rotation angle;ArcGIS.Core.Geometry.EllipticArcBuilder.GetAxes(System.Double@,System.Double@) - #region Construct a Circular Arc - using a center point and rotation angle + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateEllipticArcSegment(ArcGIS.Core.Geometry.Coordinate2D,System.Double,System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(ArcGIS.Core.Geometry.Coordinate2D,System.Double,System.Double,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.GetAxes(System.Double@,System.Double@) + #region Construct an Elliptic Arc - using a center point and rotation angle // Construct an elliptic arc centered at (1,1), startAngle = 0, centralAngle = PI/2, // rotationAngle = 0, semiMajorAxis = 1, minorMajorRatio = 0.5. - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. Coordinate2D centerPt = new Coordinate2D(1, 1); - // Builder convenience methods don't need to run on the MCT. - EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(centerPt, 0, Math.PI / 2, 0, 1, 0.5); + // BuilderEx convenience methods don't need to run on the MCT. + EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateEllipticArcSegment(centerPt, 0, Math.PI / 2, 0, 1, 0.5); double semiMajor; double semiMinor; circularArc.GetAxes(out semiMajor, out semiMinor); // semiMajor = 1, semiMinor = 0.5 - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EllipticArcBuilder cab = new EllipticArcBuilder(centerPt, 0, Math.PI / 2, 0, 1, 0.5)) - { - // do something with the builder - - EllipticArcSegment otherCircularArc = cab.ToSegment(); - } - }); + // BuilderEx constructors dont need to run on the MCT. + EllipticArcBuilderEx cab = new EllipticArcBuilderEx(centerPt, 0, Math.PI / 2, 0, 1, 0.5); + cab.GetAxes(out semiMajor, out semiMinor); + EllipticArcSegment otherCircularArc = cab.ToSegment(); #endregion } public void ConstructArcCenterPtOrientation() { - // cref: Construct a Circular Arc - using a center point and orientation;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circular Arc - using a center point and orientation;ArcGIS.Core.Geometry.EllipticArcBuilder.CreateEllipticArcSegment(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateCircularArc(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.SpatialReference) #region Construct a Circular Arc - using a center point and orientation // Construct a circular arc from (2, 1) to (1, 2) // with center point at (1, 1) and orientation counterclockwise. - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. - MapPoint toPt = MapPointBuilder.CreateMapPoint(1, 2); - MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1); + MapPoint toPt = MapPointBuilderEx.CreateMapPoint(1, 2); + MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1); Coordinate2D centerPtCoord = new Coordinate2D(1, 1); - // Builder convenience methods don't need to run on the MCT. - EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt, toPt, centerPtCoord, esriArcOrientation.esriArcCounterClockwise); + // BuilderEx convenience methods don't need to run on the MCT. + EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, centerPtCoord, ArcOrientation.ArcCounterClockwise); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EllipticArcBuilder cab = new EllipticArcBuilder(fromPt, toPt, centerPtCoord, esriArcOrientation.esriArcCounterClockwise)) - { - // do something with the builder - - EllipticArcSegment otherCircularArc = cab.ToSegment(); - } - }); + // BuilderEx constructors need to run on the MCT. + EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromPt, toPt, centerPtCoord, ArcOrientation.ArcCounterClockwise); + EllipticArcSegment otherCircularArc = cab.ToSegment(); #endregion } public void ConstructArcSegmentsRadius() { - // cref: Construct a Circular Arc - using two segments and radius;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.Segment,System.Double,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circular Arc - using two segments and radius;ArcGIS.Core.Geometry.EllipticArcBuilder.CreateEllipticArcSegment(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.Segment,System.Double,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circular Arc - using two segments and radius;ArcGIS.Core.Geometry.EllipticArcBuilder.QueryFilletRadiusRange(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.QueryFilletRadiusRange(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.Coordinate2D) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateCircularArc(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.Segment,System.Double,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.Segment,System.Double,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) #region Construct a Circular Arc - using two segments and radius // Construct a segment from (100, 100) to (50, 50) and another segment from (100, 100) to (150, 50). - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. - LineSegment segment1 = LineBuilder.CreateLineSegment(new Coordinate2D(100, 100), new Coordinate2D(50, 50)); - LineSegment segment2 = LineBuilder.CreateLineSegment(new Coordinate2D(100, 100), new Coordinate2D(150, 50)); + LineSegment segment1 = LineBuilderEx.CreateLineSegment(new Coordinate2D(100, 100), new Coordinate2D(50, 50)); + LineSegment segment2 = LineBuilderEx.CreateLineSegment(new Coordinate2D(100, 100), new Coordinate2D(150, 50)); // Construct the hint point to determine where the arc will be constructed. Coordinate2D hintPoint = new Coordinate2D(100, 75); // Call QueryFilletRadius to get the minimum and maximum radii that can be used with these segments. - var minMaxRadii = EllipticArcBuilder.QueryFilletRadiusRange(segment1, segment2, hintPoint); + var minMaxRadii = EllipticArcBuilderEx.QueryFilletRadiusRange(segment1, segment2, hintPoint); // Use the maximum radius to create the arc. double maxRadius = minMaxRadii.Item2; - // Builder convenience methods don't need to run on the MCT. - EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(segment1, segment2, maxRadius, hintPoint); - - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EllipticArcBuilder cab = new EllipticArcBuilder(segment1, segment2, maxRadius, hintPoint)) - { - // do something with the builder + // BuilderEx convenience methods don't need to run on the MCT. + //At 2.x - EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateEllipticArcSegment(segment1, segment2, maxRadius, hintPoint); + EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc( + segment1, segment2, maxRadius, hintPoint); - EllipticArcSegment otherCircularArc = cab.ToSegment(); - } - }); + // BuilderEx constructors need to run on the MCT. + EllipticArcBuilderEx cab = new EllipticArcBuilderEx(segment1, segment2, maxRadius, hintPoint); + EllipticArcSegment otherCircularArc = cab.ToSegment(); #endregion } public void ConstructCircle() { - // cref: Construct a Circle;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(ArcGIS.Core.Geometry.Coordinate2D,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circle;ArcGIS.Core.Geometry.EllipticArcBuilder.CreateEllipticArcSegment(ArcGIS.Core.Geometry.Coordinate2D,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Circle;ArcGIS.Core.Geometry.EllipticArcBuilder.QueryCoords(ArcGIS.Core.Geometry.Coordinate2D@,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateCircle(ArcGIS.Core.Geometry.Coordinate2D,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.QueryCoords(ArcGIS.Core.Geometry.Coordinate2D@,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(ArcGIS.Core.Geometry.Coordinate2D,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.ArcOrientation #region Construct a Circle // Construct a circle with center at (-1,-1), radius = 2, and oriented clockwise. - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. Coordinate2D centerPtCoord = new Coordinate2D(-1, -1); // Builder convenience methods don't need to run on the MCT. - EllipticArcSegment circle = EllipticArcBuilder.CreateEllipticArcSegment(centerPtCoord, 2, esriArcOrientation.esriArcClockwise); + EllipticArcSegment circle = EllipticArcBuilderEx.CreateCircle(centerPtCoord, 2, ArcOrientation.ArcClockwise); // circle.IsCircular = true // circle.IsCounterClockwise = false // circle.IsMinor = false @@ -2719,45 +2412,31 @@ public void ConstructCircle() // rotationAngle = 0 // endAngle = PI/2 - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EllipticArcBuilder builder = new EllipticArcBuilder(centerPtCoord, 2, esriArcOrientation.esriArcClockwise)) - { - // do something with the builder - - EllipticArcSegment otherCircle = builder.ToSegment(); - } - }); + // BuilderEx constructors need to run on the MCT. + EllipticArcBuilderEx builder = new EllipticArcBuilderEx(centerPtCoord, 2, ArcOrientation.ArcClockwise); + EllipticArcSegment otherCircle = builder.ToSegment(); #endregion } public void ConstructEllipse() { - // cref: Construct an Ellipse;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(ArcGIS.Core.Geometry.Coordinate2D,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct an Ellipse;ArcGIS.Core.Geometry.EllipticArcBuilder.CreateEllipticArcSegment(ArcGIS.Core.Geometry.Coordinate2D,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.esriArcOrientation,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateEllipse(ArcGIS.Core.Geometry.Coordinate2D,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(ArcGIS.Core.Geometry.Coordinate2D,System.Double,System.Double,System.Double,ArcGIS.Core.Geometry.ArcOrientation,ArcGIS.Core.Geometry.SpatialReference) #region Construct an Ellipse // Construct an ellipse centered at (1, 2) with rotationAngle = -pi/6, // semiMajorAxis = 5, minorMajorRatio = 0.2, oriented clockwise. - // Use a builder convenience method or use a builder constructor. + // Use a builderEx convenience method or use a builderEx constructor. Coordinate2D centerPt = new Coordinate2D(1, 2); - // Builder convenience methods don't need to run on the MCT. - EllipticArcSegment ellipse = EllipticArcBuilder.CreateEllipticArcSegment(centerPt, -1 * Math.PI / 6, 5, 0.2, esriArcOrientation.esriArcClockwise); + // BuilderEx convenience methods don't need to run on the MCT. + EllipticArcSegment ellipse = EllipticArcBuilderEx.CreateEllipse(centerPt, -1 * Math.PI / 6, 5, 0.2, ArcOrientation.ArcClockwise); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (EllipticArcBuilder builder = new EllipticArcBuilder(centerPt, -1 * Math.PI / 6, 5, 0.2, esriArcOrientation.esriArcClockwise)) - { - // do something with the builder - - EllipticArcSegment anotherEllipse = builder.ToSegment(); - } - }); + // BuilderEx constructors need to run on the MCT. + EllipticArcBuilderEx builder = new EllipticArcBuilderEx(centerPt, -1 * Math.PI / 6, 5, 0.2, ArcOrientation.ArcClockwise); + EllipticArcSegment anotherEllipse = builder.ToSegment(); #endregion } @@ -2766,37 +2445,31 @@ public void ConstructArcBuilderUtils() { EllipticArcSegment arcSegment = null; - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.#ctor(ArcGIS.Core.Geometry.EllipticArcSegment) - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.CenterPoint - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.CentralAngle - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.EndAngle - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.EndPoint - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.IsCircular - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.IsMinor - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.Orientation - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.RotationAngle - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.StartAngle - // cref: Elliptic Arc Builder Properties;ArcGIS.Core.Geometry.EllipticArcBuilder.StartPoint + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.#ctor(ArcGIS.Core.Geometry.EllipticArcSegment,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.StartPoint + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.EndPoint + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CenterPoint + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.IsCircular + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.IsMinor + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.StartAngle + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.EndAngle + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CentralAngle + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.RotationAngle + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.Orientation #region Elliptic Arc Builder Properties - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - // retrieve the curve's control points - using (EllipticArcBuilder builder = new EllipticArcBuilder(arcSegment)) - { - MapPoint startPt = builder.StartPoint; - MapPoint endPt = builder.EndPoint; - Coordinate2D centerPt = builder.CenterPoint; - bool isCircular = builder.IsCircular; - bool isMinor = builder.IsMinor; - double startAngle = builder.StartAngle; - double endAngle = builder.EndAngle; - double centralAngle = builder.CentralAngle; - double rotationAngle = builder.RotationAngle; - esriArcOrientation orientation = builder.Orientation; - } - }); + // retrieve the curve's properties + EllipticArcBuilderEx builder = new EllipticArcBuilderEx(arcSegment); + MapPoint startPt = builder.StartPoint; + MapPoint endPt = builder.EndPoint; + Coordinate2D centerPt = builder.CenterPoint; + bool isCircular = builder.IsCircular; + bool isMinor = builder.IsMinor; + double startAngle = builder.StartAngle; + double endAngle = builder.EndAngle; + double centralAngle = builder.CentralAngle; + double rotationAngle = builder.RotationAngle; + ArcOrientation orientation = builder.Orientation; #endregion } @@ -2805,25 +2478,25 @@ public void ConstructArcUtils() { EllipticArcSegment arcSegment = null; - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.GetAxes(System.Double@,System.Double@) - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.QueryCoords(ArcGIS.Core.Geometry.Coordinate2D@,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@) - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.CenterPoint - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.CentralAngle - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.EndAngle - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.IsCircular - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.IsCounterClockwise - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.IsCurve - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.IsMinor - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.Length - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.MinorMajorRatio - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.RotationAngle - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.SemiMajorAxis - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.SemiMinorAxis - // cref: Elliptic Arc Properties;ArcGIS.Core.Geometry.EllipticArcSegment.StartAngle + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.StartAngle + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.EndAngle + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.CenterPoint + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.IsCircular + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.IsMinor + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.IsCounterClockwise + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.IsCurve + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.Length + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.MinorMajorRatio + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.GetAxes(System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.SemiMajorAxis + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.SemiMinorAxis + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.QueryCoords(ArcGIS.Core.Geometry.Coordinate2D@,System.Double@,System.Double@,System.Double@,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.CentralAngle + // cref: ArcGIS.Core.Geometry.EllipticArcSegment.RotationAngle #region Elliptic Arc Properties // retrieve the curve's control points - EllipticArcSegment arc = EllipticArcBuilder.CreateEllipticArcSegment(arcSegment); + EllipticArcSegment arc = EllipticArcBuilderEx.CreateEllipticArcSegment(arcSegment); MapPoint startPt = arc.StartPoint; MapPoint endPt = arc.EndPoint; Coordinate2D centerPt = arc.CenterPoint; @@ -2860,124 +2533,116 @@ public void ConstructArcUtils() public void GeometryBag() { { - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBag.IsEqual(ArcGIS.Core.Geometry.GeometryBag) - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBagBuilder.#ctor(ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBagBuilder.AddGeometry(ArcGIS.Core.Geometry.Geometry) - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBagBuilder.InsertGeometry(System.Int32,ArcGIS.Core.Geometry.Geometry) - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBagBuilder.RemoveGeometry(System.Int32) - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBagBuilder.ToGeometry - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBag.Geometries - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBag.IsEmpty - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBag.PartCount - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBag.PointCount - // cref: Construct GeometryBag;ArcGIS.Core.Geometry.GeometryBagBuilder.CountGeometries + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.#ctor(ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.GeometryBag.IsEmpty + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.AddGeometry(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.GeometryCount + // cref: ArcGIS.Core.Geometry.GeometryBag.PartCount + // cref: ArcGIS.Core.Geometry.GeometryBag.PointCount + // cref: ArcGIS.Core.Geometry.GeometryBag.Geometries + // cref: ArcGIS.Core.Geometry.GeometryBag.IsEqual(ArcGIS.Core.Geometry.GeometryBag) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.RemoveGeometry(System.Int32) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.InsertGeometry(System.Int32,ArcGIS.Core.Geometry.Geometry) #region Construct GeometryBag - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => + MapPoint point = MapPointBuilderEx.CreateMapPoint(1, 2, SpatialReferences.WebMercator); + + List coords2D = new List() { - using (GeometryBagBuilder builder = new GeometryBagBuilder(SpatialReferences.WGS84)) - { - GeometryBag emptyBag = builder.ToGeometry(); - // emptyBag.IsEmpty = true + new Coordinate2D(0, 0), + new Coordinate2D(0, 1), + new Coordinate2D(1, 1), + new Coordinate2D(1, 0) + }; - MapPoint point = MapPointBuilder.CreateMapPoint(1, 2, SpatialReferences.WebMercator); - builder.AddGeometry(point); - // builder.CountGeometries = 1 + Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(coords2D, SpatialReferences.WGS84); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords2D, SpatialReferences.WebMercator); - GeometryBag geometryBag = builder.ToGeometry(); - // geometryBag.PartCount = 1 - // geometryBag.PointCount = 1 - // geometryBag.IsEmpty = false + GeometryBagBuilderEx builder = new GeometryBagBuilderEx(SpatialReferences.WGS84); - IReadOnlyList geometries = geometryBag.Geometries; - // geometries.Count = 1 - // geometries[0] is MapPoint with a sr of WGS84 + GeometryBag emptyBag = builder.ToGeometry(); + // emptyBag.IsEmpty = true - bool isEqual = geometryBag.IsEqual(emptyBag); // isEqual = false + builder.AddGeometry(point); + // builder.GeometryCount = 1 - List coords2D = new List() - { - new Coordinate2D(0, 0), - new Coordinate2D(0, 1), - new Coordinate2D(1, 1), - new Coordinate2D(1, 0) - }; - - Multipoint multipoint = MultipointBuilder.CreateMultipoint(coords2D, SpatialReferences.WGS84); - builder.InsertGeometry(0, multipoint); - geometryBag = builder.ToGeometry(); - // geometryBag.PartCount = 2 - - geometries = geometryBag.Geometries; - // geometries.Count = 2 - // geometries[0] is Multipoint - // geometries[1] is MapPoint - - Polyline polyline = PolylineBuilder.CreatePolyline(coords2D, SpatialReferences.WebMercator); - builder.AddGeometry(polyline); - builder.RemoveGeometry(1); - geometryBag = builder.ToGeometry(); - // geometryBag.PartCount = 2 - - geometries = geometryBag.Geometries; - // geometries.Count = 2 - // geometries[0] is Multipoint - // geometries[1] is Polyline - } - }); + GeometryBag geometryBag = builder.ToGeometry(); + // geometryBag.PartCount = 1 + // geometryBag.PointCount = 1 + // geometryBag.IsEmpty = false + + IReadOnlyList geometries = geometryBag.Geometries; + // geometries.Count = 1 + // geometries[0] is MapPoint with a sr of WGS84 + + bool isEqual = geometryBag.IsEqual(emptyBag); // isEqual = false + + builder.InsertGeometry(0, multipoint); + geometryBag = builder.ToGeometry(); + // geometryBag.PartCount = 2 + + geometries = geometryBag.Geometries; + // geometries.Count = 2 + // geometries[0] is Multipoint + // geometries[1] is MapPoint + + builder.AddGeometry(polyline); + builder.RemoveGeometry(1); + geometryBag = builder.ToGeometry(); + // geometryBag.PartCount = 2 + + geometries = geometryBag.Geometries; + // geometries.Count = 2 + // geometries[0] is Multipoint + // geometries[1] is Polyline #endregion } { - // cref: Construct GeometryBag - from an enumeration of geometries;ArcGIS.Core.Geometry.GeometryBagBuilder.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct GeometryBag - from an enumeration of geometries;ArcGIS.Core.Geometry.GeometryBagBuilder.CreateGeometryBag(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.CreateGeometryBag(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.#ctor(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.ToGeometry #region Construct GeometryBag - from an enumeration of geometries // Use a builder convenience method or use a builder constructor. - MapPoint point = MapPointBuilder.CreateMapPoint(10, 20); + MapPoint point = MapPointBuilderEx.CreateMapPoint(10, 20); List coords = new List() { new Coordinate2D(50, 60), new Coordinate2D(-120, -70), new Coordinate2D(40, 60) }; - Multipoint multipoint = MultipointBuilder.CreateMultipoint(coords, SpatialReferences.WebMercator); - Polyline polyline = PolylineBuilder.CreatePolyline(coords); + Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(coords, SpatialReferences.WebMercator); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords); string json = "{\"rings\":[[[0,0],[0,1],[1,1],[1,0],[0,0]],[[3,0],[3,1],[4,1],[4,0],[3,0]]]}"; - Polygon polygon = PolygonBuilder.FromJson(json); + Polygon polygon = PolygonBuilderEx.FromJson(json); var geometries = new List() { point, multipoint, polyline, polygon }; // Builder convenience methods don't need to run on the MCT. - GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(geometries, SpatialReferences.WGS84); - - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (var builder = new GeometryBagBuilder(geometries, SpatialReferences.WGS84)) - { - // builder.CountGeometries = 4 - - // do something with the builder + //At 2.x - GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(geometries, SpatialReferences.WGS84); + var bag = GeometryBagBuilderEx.CreateGeometryBag(geometries, SpatialReferences.WGS84); - bag = builder.ToGeometry(); - // bag.PartCount = 4 - // bag.PointCount = 17 - } - }); + //At 2.x - using (var builder = new GeometryBagBuilder(geometries, SpatialReferences.WGS84)) + var builder = new GeometryBagBuilderEx(geometries, SpatialReferences.WGS84); + // do something with the builder + bag = builder.ToGeometry(); #endregion } { - // cref: Construct GeometryBag - from JSON, Xml;ArcGIS.Core.Geometry.GeometryBagBuilder.FromJson(System.String) - // cref: Construct GeometryBag - from JSON, Xml;ArcGIS.Core.Geometry.GeometryBagBuilder.FromXML(System.String) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.FromJson(System.String) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.FromXML(System.String) + // cref: ArcGIS.Core.Geometry.Geometry.ToXml #region Construct GeometryBag - from JSON, Xml const string jsonString = "{\"geometries\":[{\"x\":1,\"y\":2},{\"rings\":[[[0,0],[0,4],[3,4],[3,0],[0,0]]]}],\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326}}"; - GeometryBag geometryBag = GeometryBagBuilder.FromJson(jsonString); + //At 2.x - GeometryBag geometryBag = GeometryBagBuilder.FromJson(jsonString); + var geometryBag = GeometryBagBuilderEx.FromJson(jsonString); - string xml = geometryBag.ToXML(); - GeometryBag xmlString = GeometryBagBuilder.FromXML(xml); + string xml = geometryBag.ToXml(); + //At 2.x - GeometryBag xmlString = GeometryBagBuilder.FromXML(xml); + var xmlString = GeometryBagBuilderEx.FromXml(xml); #endregion } @@ -2985,41 +2650,34 @@ public void GeometryBag() public void GeometryBagInsert() { - // cref: Construct GeometryBag - adding or inserting an enumeration of geometries;ArcGIS.Core.Geometry.GeometryBagBuilder.AddGeometries(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) - // cref: Construct GeometryBag - adding or inserting an enumeration of geometries;ArcGIS.Core.Geometry.GeometryBagBuilder.InsertGeometries(System.Int32,System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) - // cref: Construct GeometryBag - adding or inserting an enumeration of geometries;ArcGIS.Core.Geometry.GeometryBagBuilder.CountGeometries + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.AddGeometries(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.InsertGeometries(System.Int32,System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.GeometryCount + // cref: ArcGIS.Core.Geometry.GeometryBagBuilderEx.ToGeometry #region Construct GeometryBag - adding or inserting an enumeration of geometries - MapPoint point = MapPointBuilder.CreateMapPoint(10, 20); + MapPoint point = MapPointBuilderEx.CreateMapPoint(10, 20); List coords = new List() { new Coordinate2D(50, 60), new Coordinate2D(-120, -70), new Coordinate2D(40, 60) }; - Multipoint multipoint = MultipointBuilder.CreateMultipoint(coords, SpatialReferences.WebMercator); - Polyline polyline = PolylineBuilder.CreatePolyline(coords); + Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(coords, SpatialReferences.WebMercator); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords); string json = "{\"rings\":[[[0,0],[0,1],[1,1],[1,0],[0,0]],[[3,0],[3,1],[4,1],[4,0],[3,0]]]}"; - Polygon polygon = PolygonBuilder.FromJson(json); + Polygon polygon = PolygonBuilderEx.FromJson(json); var geometries = new List() { point, multipoint, polyline, polygon }; - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - using (var builder = new GeometryBagBuilder(SpatialReferences.WGS84)) - { - // builder.CountGeometries = 0 + //At 2.x - using (var builder = new GeometryBagBuilder(SpatialReferences.WGS84)) + var builder = new GeometryBagBuilderEx(SpatialReferences.WGS84); + builder.AddGeometries(geometries); - builder.AddGeometries(geometries); - // builder.CountGeometries = 4 + GeometryBag geomBag = builder.ToGeometry(); + // geomBag.PartCount == 4 (point, multipoint, polyline, polygon) - GeometryBag geomBag = builder.ToGeometry(); - // bag.PartCount = 4 (point, multipoint, polyline, polygon) - - geometries = new List() { point, polyline }; - builder.InsertGeometries(1, geometries); - // builder.CountGeometries = 6 - geomBag = builder.ToGeometry(); - // bag.PartCount = 6 (point, point, polyline, multipoint, polyline, polygon) - } - }); + geometries = new List() { point, polyline }; + builder.InsertGeometries(1, geometries); + // builder.GeometryCount == 6 + geomBag = builder.ToGeometry(); + // geomBag.PartCount == 6 (point, point, polyline, multipoint, polyline, polygon) #endregion } @@ -3029,28 +2687,28 @@ public void GeometryBagInsert() public void Multipatch() { - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrude(ArcGIS.Core.Geometry.Multipart,System.Double) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrudeAlongLine(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrudeAlongVector3D(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Coordinate3D) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrudeFromToZ(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrudeToZ(ArcGIS.Core.Geometry.Multipart,System.Double) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrude(ArcGIS.Core.Geometry.Multipart,System.Double) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrudeAlongLine(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrudeAlongVector3D(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Coordinate3D) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrudeFromToZ(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) - // cref: Construct Multipatch via Extrusion of Polygon or Polyline;ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrudeToZ(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrude(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrude(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrudeFromToZ(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrudeFromToZ(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrudeAlongVector3D(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrudeAlongVector3D(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrudeToZ(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrudeToZ(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructMultipatchExtrudeAlongLine(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructMultipatchExtrudeAlongLine(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Coordinate3D,ArcGIS.Core.Geometry.Coordinate3D) #region Construct Multipatch via Extrusion of Polygon or Polyline // build a polygon string json = "{\"hasZ\":true,\"rings\":[[[0,0,0],[0,1,0],[1,1,0],[1,0,0],[0,0,0]]],\"spatialReference\":{\"wkid\":4326}}"; - Polygon polygon = PolygonBuilder.FromJson(json); + Polygon polygon = PolygonBuilderEx.FromJson(json); // extrude the polygon by an offset to create a multipatch Multipatch multipatch = GeometryEngine.Instance.ConstructMultipatchExtrude(polygon, 2); // a different polygon json = "{\"hasZ\":true,\"rings\":[[[0,0,1],[0,1,2],[1,1,3],[1,0,4],[0,0,1]]],\"spatialReference\":{\"wkid\":4326}}"; - polygon = PolygonBuilder.FromJson(json); + polygon = PolygonBuilderEx.FromJson(json); // extrude between z values to create a multipatch multipatch = GeometryEngine.Instance.ConstructMultipatchExtrudeFromToZ(polygon, -10, 20); @@ -3061,7 +2719,7 @@ public void Multipatch() // build a polyline json = "{\"hasZ\":true,\"paths\":[[[400,800,1000],[800,1400,1500],[1200,800,2000],[1800,1800,2500],[2200,800,3000]]],\"spatialReference\":{\"wkid\":3857}}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); // extrude to a specific z value to create a multipatch multipatch = GeometryEngine.Instance.ConstructMultipatchExtrudeToZ(polyline, 500); @@ -3077,21 +2735,34 @@ public void Multipatch() Multipatch multiPatch = null; int patchIndex = 0; - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.GetPatchPointCount(System.Int32) - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.GetPatchPriority(System.Int32) - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.GetPatchStartPointIndex(System.Int32) - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.GetPatchTextureCoordinate(System.Int32,System.Int32) - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.GetPatchTextureCoordinates(System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Coordinate2D}@) - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.GetPatchTextureVertexCount(System.Int32) - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.GetPatchType(System.Int32) - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.HasMaterials - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.HasTextures - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.IsEmpty - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.MaterialCount - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.PartCount - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.PointCount - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.Points - // cref: Multipatch Properties;ArcGIS.Core.Geometry.Multipatch.TextureVertexCount + // cref: ArcGIS.Core.Geometry.Multipatch.IsEmpty + // cref: ArcGIS.Core.Geometry.Multipatch.PartCount + // cref: ArcGIS.Core.Geometry.Multipatch.PointCount + // cref: ArcGIS.Core.Geometry.Multipatch.Points + // cref: ArcGIS.Core.Geometry.Multipatch.HasMaterials + // cref: ArcGIS.Core.Geometry.Multipatch.MaterialCount + // cref: ArcGIS.Core.Geometry.Multipatch.HasTextures + // cref: ArcGIS.Core.Geometry.Multipatch.TextureVertexCount + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialColor + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialEdgeColor + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialEdgeWidth + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialShininess + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTransparencyPercent + // cref: ArcGIS.Core.Geometry.Multipatch.IsMaterialCullBackFace + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureColumnCount + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureRowCount + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureBytesPerPixel + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureCompressionType + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTexture + // cref: ArcGIS.Core.Geometry.TextureCompressionType + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchPriority(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchType(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchPointCount(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchStartPointIndex(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchTextureVertexCount(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchTextureCoordinate(System.Int32,System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchTextureCoordinates(System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Coordinate2D}@) + // cref: ArcGIS.Core.Geometry.Multipatch.Copy3DCoordinatesToList #region Multipatch Properties // standard geometry properties @@ -3127,7 +2798,7 @@ public void Multipatch() // properties for an individual patch (if multipatch.PartCount > 0) int patchPriority = multiPatch.GetPatchPriority(patchIndex); - esriPatchType patchType = multiPatch.GetPatchType(patchIndex); + PatchType patchType = multiPatch.GetPatchType(patchIndex); // patch points int patchPointCount = multiPatch.GetPatchPointCount(patchIndex); @@ -3149,7 +2820,7 @@ public void Multipatch() var edgeWidth = multipatch.GetMaterialEdgeWidth(materialIndex); var shiness = multipatch.GetMaterialShininess(materialIndex); var percent = multipatch.GetMaterialTransparencyPercent(materialIndex); - var cullBackFace = multipatch.IsMaterialCullBackface(materialIndex); + var cullBackFace = multipatch.IsMaterialCullBackFace(materialIndex); // texture properties bool isTextured = multipatch.IsMaterialTextured(materialIndex); @@ -3158,7 +2829,7 @@ public void Multipatch() int columnCount = multipatch.GetMaterialTextureColumnCount(materialIndex); int rowCount = multipatch.GetMaterialTextureRowCount(materialIndex); int bpp = multipatch.GetMaterialTextureBytesPerPixel(materialIndex); - esriTextureCompressionType compressionType = multipatch.GetMaterialTextureCompressionType(materialIndex); + TextureCompressionType compressionType = multipatch.GetMaterialTextureCompressionType(materialIndex); var texture = multipatch.GetMaterialTexture(materialIndex); } } @@ -3186,50 +2857,43 @@ public void Multipatch() #endregion - // cref: Construct Multipatch;ArcGIS.Core.Geometry.Multipatch.ToBinaryXML - // cref: Construct Multipatch;ArcGIS.Core.Geometry.Multipatch.ToEsriShape - // cref: Construct Multipatch;ArcGIS.Core.Geometry.MultipatchBuilder.FromBinaryXML(System.String) - // cref: Construct Multipatch;ArcGIS.Core.Geometry.MultipatchBuilder.FromEsriShape(System.Byte[],ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct Multipatch;ArcGIS.Core.Geometry.MultipatchBuilder.FromXML(System.String) - // cref: Construct Multipatch;ArcGIS.Core.Geometry.Multipatch.ToEsriShape(System.Byte[]@) + // cref: ArcGIS.Core.Geometry.Multipatch.ToBinaryXml + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.FromBinaryXml(System.String) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.FromXml(System.String) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.FromEsriShape(System.Byte[],ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.Multipatch.ToEsriShape #region Construct Multipatch // export to binary xml - string binaryXml = multiPatch.ToBinaryXML(); + string binaryXml = multiPatch.ToBinaryXml(); // import from binaryXML - methods need to run on the MCT - Multipatch binaryMultipatch = MultipatchBuilder.FromBinaryXML(binaryXml); + Multipatch binaryMultipatch = MultipatchBuilderEx.FromBinaryXml(binaryXml); // xml export / import - string xml = multiPatch.ToXML(); - Multipatch xmlMultipatch = MultipatchBuilder.FromXML(xml); + string xml = multiPatch.ToXml(); + Multipatch xmlMultipatch = MultipatchBuilderEx.FromXml(xml); // esriShape export/import byte[] buffer = multiPatch.ToEsriShape(); - Multipatch esriPatch = MultipatchBuilder.FromEsriShape(buffer); + Multipatch esriPatch = MultipatchBuilderEx.FromEsriShape(buffer); // or use GeometryEngine - Multipatch patchImport = GeometryEngine.Instance.ImportFromEsriShape(EsriShapeImportFlags.esriShapeImportDefaults, buffer, multiPatch.SpatialReference) as Multipatch; + Multipatch patchImport = GeometryEngine.Instance.ImportFromEsriShape(EsriShapeImportFlags.EsriShapeImportDefaults, buffer, multiPatch.SpatialReference) as Multipatch; #endregion - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.BasicMaterial.#ctor - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.BasicMaterial.#ctor(ArcGIS.Core.Geometry.BasicMaterial) - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.MakePatch(ArcGIS.Core.Geometry.esriPatchType) - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.QueryPatchIndicesWithMaterial(ArcGIS.Core.Geometry.Material) - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.ToGeometry - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.BasicMaterial.Color - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.BasicMaterial.CullBackFace - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.BasicMaterial.EdgeColor - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.BasicMaterial.EdgeWidth - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.BasicMaterial.Shininess - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.BasicMaterial.TransparencyPercent - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.Multipatch) - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.MultipatchBuilderEx) - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.MultipatchConstructType,ArcGIS.Core.Geometry.MapPoint,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.MultipatchConstructType,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct Multipatch via MultipatchBuilderEx;ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.SpatialReference) + + // cref: ArcGIS.Core.Geometry.BasicMaterial.#ctor + // cref: ArcGIS.Core.Geometry.BasicMaterial.Color + // cref: ArcGIS.Core.Geometry.BasicMaterial.TransparencyPercent + // cref: ArcGIS.Core.Geometry.BasicMaterial.#ctor(ArcGIS.Core.Geometry.BasicMaterial) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.MakePatch(ArcGIS.Core.Geometry.PatchType) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.QueryPatchIndicesWithMaterial(ArcGIS.Core.Geometry.Material) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.Patch + // cref: ArcGIS.Core.Geometry.PatchType #region Construct Multipatch via MultipatchBuilderEx var coords_face1 = new List() @@ -3310,27 +2974,27 @@ public void Multipatch() var mpb = new ArcGIS.Core.Geometry.MultipatchBuilderEx(); // make each patch using the appropriate coordinates and add to the patch list - var patch = mpb.MakePatch(esriPatchType.Triangles); + var patch = mpb.MakePatch(PatchType.Triangles); patch.Coords = coords_face1; patches.Add(patch); - patch = mpb.MakePatch(esriPatchType.Triangles); + patch = mpb.MakePatch(PatchType.Triangles); patch.Coords = coords_face2; patches.Add(patch); - patch = mpb.MakePatch(esriPatchType.Triangles); + patch = mpb.MakePatch(PatchType.Triangles); patch.Coords = coords_face3; patches.Add(patch); - patch = mpb.MakePatch(esriPatchType.Triangles); + patch = mpb.MakePatch(PatchType.Triangles); patch.Coords = coords_face4; patches.Add(patch); - patch = mpb.MakePatch(esriPatchType.Triangles); + patch = mpb.MakePatch(PatchType.Triangles); patch.Coords = coords_face5; patches.Add(patch); - patch = mpb.MakePatch(esriPatchType.Triangles); + patch = mpb.MakePatch(PatchType.Triangles); patch.Coords = coords_face6; patches.Add(patch); @@ -3355,7 +3019,7 @@ public void Multipatch() #endregion } - public void MultipatchBuilderEx() + public void MultipatchBuilderEx_() { Multipatch multipatch = null; TextureResource brickTextureResource = null; @@ -3363,18 +3027,20 @@ public void MultipatchBuilderEx() MapPoint newPoint = null; var coords = new List(); - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.Multipatch) - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.GetPatchPointCount(System.Int32) - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.GetPoint(System.Int32,System.Int32) - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.QueryPatchIndicesWithTexture(ArcGIS.Core.Geometry.TextureResource) - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.SetPoint(System.Int32,System.Int32,ArcGIS.Core.Geometry.MapPoint) - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.SynchronizeAttributeAwareness - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.HasID - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.HasM - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.HasNormals - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.HasZ - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.IsEmpty - // cref: Construct Multipatch from another Multipatch;ArcGIS.Core.Geometry.MultipatchBuilderEx.Patches + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.Multipatch) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.HasM + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.HasZ + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.HasID + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.IsEmpty + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.HasNormals + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.Patches + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.ToGeometry + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.GetPatchPointCount(System.Int32) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.GetPoint(System.Int32,System.Int32) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.SetPoint(System.Int32,System.Int32,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.QueryPatchIndicesWithTexture(ArcGIS.Core.Geometry.TextureResource) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.SynchronizeAttributeAwareness + // cref: ArcGIS.Core.Geometry.Patch.Material #region Construct Multipatch from another Multipatch // create the multipatchBuilderEx object @@ -3423,6 +3089,7 @@ public void MultipatchBuilderEx() #endregion + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.From3DModelFile(System.String,ArcGIS.Core.Geometry.SpatialReference) #region Construct Multipatch from a 3D model file try @@ -3440,6 +3107,15 @@ public void MultipatchBuilderEx() } #endregion + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.#ctor(ArcGIS.Core.Geometry.MultipatchConstructType,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MultipatchBuilderEx.CreateMultipatch(ArcGIS.Core.Geometry.MultipatchConstructType,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.MultipatchConstructType + // cref: ArcGIS.Core.Geometry.BasicMaterial + // cref: ArcGIS.Core.Geometry.BasicMaterial.Color + // cref: ArcGIS.Core.Geometry.BasicMaterial.Shininess + // cref: ArcGIS.Core.Geometry.BasicMaterial.TransparencyPercent + // cref: ArcGIS.Core.Geometry.BasicMaterial.EdgeWidth + // cref: ArcGIS.Core.Geometry.Patch.Material #region Construct 3D special Multipatch shapes var sr = MapView.Active.Map.SpatialReference; @@ -3488,14 +3164,14 @@ public void MultipatchBuilderEx() public void Material() { { - // cref: Create BasicMaterial;ArcGIS.Core.Geometry.BasicMaterial.#ctor - // cref: Create BasicMaterial;ArcGIS.Core.Geometry.BasicMaterial.Color - // cref: Create BasicMaterial;ArcGIS.Core.Geometry.BasicMaterial.CullBackFace - // cref: Create BasicMaterial;ArcGIS.Core.Geometry.BasicMaterial.EdgeColor - // cref: Create BasicMaterial;ArcGIS.Core.Geometry.BasicMaterial.EdgeWidth - // cref: Create BasicMaterial;ArcGIS.Core.Geometry.BasicMaterial.Shininess - // cref: Create BasicMaterial;ArcGIS.Core.Geometry.BasicMaterial.TransparencyPercent - // cref: Create BasicMaterial;ArcGIS.Core.Geometry.BasicMaterial.#ctor(ArcGIS.Core.Geometry.BasicMaterial) + // cref: ArcGIS.Core.Geometry.BasicMaterial.#ctor + // cref: ArcGIS.Core.Geometry.BasicMaterial.#ctor(ArcGIS.Core.Geometry.BasicMaterial) + // cref: ArcGIS.Core.Geometry.BasicMaterial.Color + // cref: ArcGIS.Core.Geometry.BasicMaterial.EdgeColor + // cref: ArcGIS.Core.Geometry.BasicMaterial.EdgeWidth + // cref: ArcGIS.Core.Geometry.BasicMaterial.TransparencyPercent + // cref: ArcGIS.Core.Geometry.BasicMaterial.Shininess + // cref: ArcGIS.Core.Geometry.BasicMaterial.IsCullBackFace #region Create BasicMaterial // Create BasicMaterial with default values @@ -3505,7 +3181,7 @@ public void Material() int edgeWidth = material.EdgeWidth; // edgeWidth = 0 int transparency = material.TransparencyPercent; // transparency = 0 int shininess = material.Shininess; // shininess = 0 - bool cullBackFace = material.CullBackFace; // cullBackFace = false + bool cullBackFace = material.IsCullBackFace; // cullBackFace = false // Modify the properties material.Color = System.Windows.Media.Colors.Red; @@ -3513,20 +3189,22 @@ public void Material() material.EdgeWidth = 10; material.TransparencyPercent = 50; material.Shininess = 25; - material.CullBackFace = true; + material.IsCullBackFace = true; #endregion } { - // cref: Create BasicMaterial with JPEG texture;ArcGIS.Core.Geometry.JPEGTexture.#ctor(System.Byte[]) - // cref: Create BasicMaterial with JPEG texture;ArcGIS.Core.Geometry.TextureResource.#ctor(ArcGIS.Core.Geometry.Texture) - // cref: Create BasicMaterial with JPEG texture;ArcGIS.Core.Geometry.BasicMaterial.TextureResource - // cref: Create BasicMaterial with JPEG texture;ArcGIS.Core.Geometry.JPEGTexture.BytesPerPixel - // cref: Create BasicMaterial with JPEG texture;ArcGIS.Core.Geometry.JPEGTexture.ColumnCount - // cref: Create BasicMaterial with JPEG texture;ArcGIS.Core.Geometry.JPEGTexture.RowCount + // cref: ArcGIS.Core.Geometry.JPEGTexture.#ctor(System.Byte[]) + // cref: ArcGIS.Core.Geometry.JPEGTexture.BytesPerPixel + // cref: ArcGIS.Core.Geometry.JPEGTexture.ColumnCount + // cref: ArcGIS.Core.Geometry.JPEGTexture.RowCount + // cref: ArcGIS.Core.Geometry.TextureResource.#ctor(ArcGIS.Core.Geometry.Texture) + // cref: ArcGIS.Core.Geometry.BasicMaterial.TextureResource #region Create BasicMaterial with JPEG texture // read the jpeg into a buffer + //At 3.0 you need https://www.nuget.org/packages/Microsoft.Windows.Compatibility + //System.Drawing System.Drawing.Image image = System.Drawing.Image.FromFile(@"C:\temp\myImageFile.jpg"); MemoryStream memoryStream = new MemoryStream(); @@ -3549,11 +3227,12 @@ public void Material() } { - // cref: Create BasicMaterial with Uncompressed texture;ArcGIS.Core.Geometry.TextureResource.#ctor(ArcGIS.Core.Geometry.Texture) - // cref: Create BasicMaterial with Uncompressed texture;ArcGIS.Core.Geometry.UncompressedTexture.#ctor(System.Byte[],System.Int32,System.Int32,System.Byte) - // cref: Create BasicMaterial with Uncompressed texture;ArcGIS.Core.Geometry.UncompressedTexture.BytesPerPixel - // cref: Create BasicMaterial with Uncompressed texture;ArcGIS.Core.Geometry.UncompressedTexture.ColumnCount - // cref: Create BasicMaterial with Uncompressed texture;ArcGIS.Core.Geometry.UncompressedTexture.RowCount + // cref: ArcGIS.Core.Geometry.UncompressedTexture.#ctor(System.Byte[],System.Int32,System.Int32,System.Byte) + // cref: ArcGIS.Core.Geometry.UncompressedTexture.BytesPerPixel + // cref: ArcGIS.Core.Geometry.UncompressedTexture.ColumnCount + // cref: ArcGIS.Core.Geometry.UncompressedTexture.RowCount + // cref: ArcGIS.Core.Geometry.TextureResource.#ctor(ArcGIS.Core.Geometry.Texture) + // cref: ArcGIS.Core.Geometry.BasicMaterial.TextureResource #region Create BasicMaterial with Uncompressed texture UncompressedTexture uncompressedTexture1 = new UncompressedTexture(new byte[10 * 12 * 3], 10, 12, 3); @@ -3572,10 +3251,11 @@ public void Material() } } - // cref: Get the texture image of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetMaterialTexture(System.Int32) - // cref: Get the texture image of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureCompressionType(System.Int32) - // cref: Get the texture image of a multipatch;ArcGIS.Core.Geometry.Multipatch.IsMaterialTextured(System.Int32) - // cref: Get the texture image of a multipatch;ArcGIS.Core.Geometry.esriTextureCompressionType + // cref: ArcGIS.Core.Geometry.Multipatch.IsMaterialTextured(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureCompressionType(System.Int32) + // cref: ArcGIS.Core.Geometry.TextureCompressionType + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTexture(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchMaterialIndex #region Get the texture image of a multipatch // @@ -3590,8 +3270,10 @@ public void GetMultipatchTextureImage(Multipatch multipatch, int patchIndex) if (!multipatch.IsMaterialTextured(materialIndex)) return; - esriTextureCompressionType compressionType = multipatch.GetMaterialTextureCompressionType(materialIndex); - string ext = compressionType == esriTextureCompressionType.CompressionJPEG ? ".jpg" : ".dat"; + TextureCompressionType compressionType = + multipatch.GetMaterialTextureCompressionType(materialIndex); + + string ext = compressionType == TextureCompressionType.CompressionJPEG ? ".jpg" : ".dat"; byte[] textureBuffer = multipatch.GetMaterialTexture(materialIndex); Stream imageStream = new MemoryStream(textureBuffer); @@ -3601,8 +3283,8 @@ public void GetMultipatchTextureImage(Multipatch multipatch, int patchIndex) #endregion - // cref: Get the normal coordinate of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetPatchNormal(System.Int32,System.Int32) - // cref: Get the normal coordinate of a multipatch;ArcGIS.Core.Geometry.Multipatch.HasNormals + // cref: ArcGIS.Core.Geometry.Multipatch.HasNormals + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchNormal(System.Int32,System.Int32) #region Get the normal coordinate of a multipatch // @@ -3629,7 +3311,7 @@ public void DoSomethingWithNormalCoordinate(Multipatch multipatch, int patchInde #endregion - // cref: Get the normals of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetPatchNormals(System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Coordinate3D}@) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchNormals(System.Int32,System.Collections.Generic.ICollection{ArcGIS.Core.Geometry.Coordinate3D}@) #region Get the normals of a multipatch // @@ -3659,13 +3341,13 @@ public void DoSomethingWithNormalCoordinates(Multipatch multipatch) #endregion - // cref: Get the material properties of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetMaterialColor(System.Int32) - // cref: Get the material properties of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureBytesPerPixel(System.Int32) - // cref: Get the material properties of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureColumnCount(System.Int32) - // cref: Get the material properties of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureRowCount(System.Int32) - // cref: Get the material properties of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetMaterialTransparencyPercent(System.Int32) - // cref: Get the material properties of a multipatch;ArcGIS.Core.Geometry.Multipatch.GetPatchMaterialIndex(System.Int32) - // cref: Get the material properties of a multipatch;ArcGIS.Core.Geometry.Multipatch.IsMaterialCullBackface(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetPatchMaterialIndex(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTransparencyPercent(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.IsMaterialCullBackFace(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureBytesPerPixel(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureColumnCount(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.GetMaterialTextureRowCount(System.Int32) + // cref: ArcGIS.Core.Geometry.Multipatch.IsMaterialTextured #region Get the material properties of a multipatch /// @@ -3683,7 +3365,7 @@ public void GetMaterialProperties(Multipatch multipatch, int patchIndex) System.Windows.Media.Color color = multipatch.GetMaterialColor(materialIndex); int tranparencyPercent = multipatch.GetMaterialTransparencyPercent(materialIndex); - bool isBackCulled = multipatch.IsMaterialCullBackface(materialIndex); + bool isBackCulled = multipatch.IsMaterialCullBackFace(materialIndex); if (multipatch.IsMaterialTextured(materialIndex)) { @@ -3699,6 +3381,13 @@ public void GetMaterialProperties(Multipatch multipatch, int patchIndex) #region ProSnippet Group: Multiparts #endregion + // cref: ArcGIS.Core.Geometry.Geometry.IsEmpty + // cref: ArcGIS.Core.Geometry.Geometry.GeometryType + // cref: ArcGIS.Core.Geometry.Geometry.Clone + // cref: ArcGIS.Core.Geometry.GeometryType + // cref: ArcGIS.Core.Geometry.MultiPoint.Points + // cref: ArcGIS.Core.Geometry.MultiPart.Parts + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(IEnumerable{Segment},SpatialReference) #region Get the individual parts of a multipart feature /// @@ -3745,9 +3434,9 @@ public IEnumerable MultipartToSinglePart(Geometry inputGeometry) foreach (var polygonPart in polygon.Parts) { - // use the PolygonBuilder turning the segments into a standalone + // use the PolygonBuilderEx turning the segments into a standalone // polygon instance - singleParts.Add(PolygonBuilder.CreatePolygon(polygonPart)); + singleParts.Add(PolygonBuilderEx.CreatePolygon(polygonPart)); } break; case GeometryType.Polyline: @@ -3755,9 +3444,9 @@ public IEnumerable MultipartToSinglePart(Geometry inputGeometry) foreach (var polylinePart in polyline.Parts) { - // use the PolylineBuilder turning the segments into a standalone + // use the PolylineBuilderEx turning the segments into a standalone // polyline instance - singleParts.Add(PolylineBuilder.CreatePolyline(polylinePart)); + singleParts.Add(PolylineBuilderEx.CreatePolyline(polylinePart)); } break; case GeometryType.Unknown: @@ -3771,6 +3460,8 @@ public IEnumerable MultipartToSinglePart(Geometry inputGeometry) #endregion + // cref: ArcGIS.Core.Geometry.Polygon + // cref: ArcGIS.Core.Geometry.GeometryEngine.Within #region Get the outermost rings of a polygon /// @@ -3788,11 +3479,13 @@ public Polygon GetOutermostRings(Polygon inputPolygon) List internalRings = new List(); // explode the parts of the polygon into a list of individual geometries - // see the "Get the individual parts of a multipart feature" snippet for MultipartToSinglePart method defintion + // see the "Get the individual parts of a multipart feature" + // snippet for MultipartToSinglePart var parts = MultipartToSinglePart(inputPolygon); // get an enumeration of clockwise geometries (area > 0) ordered by the area - var clockwiseParts = parts.Where(geom => ((Polygon)geom).Area > 0).OrderByDescending(geom => ((Polygon)geom).Area); + var clockwiseParts = parts.Where(geom => ((Polygon)geom).Area > 0) + .OrderByDescending(geom => ((Polygon)geom).Area); // for each of the exterior rings foreach (var part in clockwiseParts) @@ -3816,17 +3509,15 @@ public Polygon GetOutermostRings(Polygon inputPolygon) internalRings.Add(part as Polygon); } - using (PolygonBuilder outerRings = new PolygonBuilder()) + PolygonBuilderEx outerRings = new PolygonBuilderEx(); + // now assemble a new polygon geometry based on the internal polygon collection + foreach (var ring in internalRings) { - // now assemble a new polygon geometry based on the internal polygon collection - foreach (var ring in internalRings) - { - outerRings.AddParts(ring.Parts); - } - - // return the final geometry of the outer rings - return outerRings.ToGeometry(); + outerRings.AddParts(ring.Parts); } + + // return the final geometry of the outer rings + return outerRings.ToGeometry(); } #endregion @@ -3836,6 +3527,9 @@ public Polygon GetOutermostRings(Polygon inputPolygon) public void RetrieveGeometryFromGeodatabase() { + // cref: ArcGIS.Core.Geometry.Polygon + // cref: ArcGIS.Core.Geometry.Geometry + // cref: ArcGIS.Core.Data.Feature.GetShape #region Retrieve Geometry from Geodatabase // methods need to run on the MCT @@ -3844,26 +3538,24 @@ public void RetrieveGeometryFromGeodatabase() try { // open a gdb - using (ArcGIS.Core.Data.Geodatabase gdb = new ArcGIS.Core.Data.Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"c:\Temp\MyDatabase.gdb")))) + using (ArcGIS.Core.Data.Geodatabase gdb = + new ArcGIS.Core.Data.Geodatabase( + new FileGeodatabaseConnectionPath(new Uri(@"c:\Temp\MyDatabase.gdb")))) { //Open a featureClass - using (ArcGIS.Core.Data.FeatureClass featureClass = gdb.OpenDataset("Polygon")) + using (ArcGIS.Core.Data.FeatureClass featureClass = + gdb.OpenDataset("Polygon")) { - // find a field - ArcGIS.Core.Data.FeatureClassDefinition featureClassDefinition = featureClass.GetDefinition(); - int fldIndex = featureClassDefinition.FindField("SomeField"); - if (fldIndex == -1) - { - return; - } - - ArcGIS.Core.Data.QueryFilter filter = new ArcGIS.Core.Data.QueryFilter - { - WhereClause = "OBJECTID = 6" - }; + + ArcGIS.Core.Data.QueryFilter filter = + new ArcGIS.Core.Data.QueryFilter() + { + WhereClause = "OBJECTID = 6" + }; // get the row - using (ArcGIS.Core.Data.RowCursor rowCursor = featureClass.Search(filter, false)) + using (ArcGIS.Core.Data.RowCursor rowCursor = + featureClass.Search(filter, false)) { while (rowCursor.MoveNext()) { @@ -3875,9 +3567,6 @@ public void RetrieveGeometryFromGeodatabase() ArcGIS.Core.Data.Feature feature = row as ArcGIS.Core.Data.Feature; Polygon polygon = feature.GetShape() as Polygon; - // get the attribute from the row (assume it's a double field) - double value = (double)row.GetOriginalValue(fldIndex); - // do something here } } @@ -3900,22 +3589,27 @@ public void RetrieveGeometryFromGeodatabase() public void ImportExport() { { - // cref: Import and Export Geometries to well-known Text;ArcGIS.Core.Geometry.GeometryEngine.ExportToWKT(ArcGIS.Core.Geometry.WKTExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to well-known Text;ArcGIS.Core.Geometry.GeometryEngine.ImportFromWKT(ArcGIS.Core.Geometry.WKTImportFlags,System.String,ArcGIS.Core.Geometry.SpatialReference) - // cref: Import and Export Geometries to well-known Text;ArcGIS.Core.Geometry.IGeometryEngine.ExportToWKT(ArcGIS.Core.Geometry.WKTExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to well-known Text;ArcGIS.Core.Geometry.IGeometryEngine.ImportFromWKT(ArcGIS.Core.Geometry.WKTImportFlags,System.String,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ExportToWKT(ArcGIS.Core.Geometry.WktExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ExportToWKT(ArcGIS.Core.Geometry.WktExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ImportFromWKT(ArcGIS.Core.Geometry.WktImportFlags,System.String,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ImportFromWKT(ArcGIS.Core.Geometry.WktImportFlags,System.String,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.SpatialReferences.WebMercator + // cref: ArcGIS.Core.Geometry.WktExportFlags + // cref: ArcGIS.Core.Geometry.WktImportFlags #region Import and Export Geometries to well-known Text // create a point with z, m - MapPoint point = MapPointBuilder.CreateMapPoint(100, 200, 300, 400, SpatialReferences.WebMercator); + MapPoint point = MapPointBuilderEx.CreateMapPoint( + 100, 200, 300, 400, SpatialReferences.WebMercator); // set the flags - WKTExportFlags wktExportFlags = WKTExportFlags.wktExportDefaults; - WKTImportFlags wktImportFlags = WKTImportFlags.wktImportDefaults; + WktExportFlags wktExportFlags = WktExportFlags.WktExportDefaults; + WktImportFlags wktImportFlags = WktImportFlags.WktImportDefaults; // export and import string wktString = GeometryEngine.Instance.ExportToWKT(wktExportFlags, point); - MapPoint importPoint = GeometryEngine.Instance.ImportFromWKT(wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint; + MapPoint importPoint = GeometryEngine.Instance.ImportFromWKT( + wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint; double x = importPoint.X; // x = 100 double y = importPoint.Y; // y = 200 @@ -3925,9 +3619,10 @@ public void ImportExport() double m = importPoint.M; // m = 400 // export without z - WKTExportFlags exportFlagsNoZ = WKTExportFlags.wktExportStripZs; + WktExportFlags exportFlagsNoZ = WktExportFlags.WktExportStripZs; wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoZ, point); - importPoint = GeometryEngine.Instance.ImportFromWKT(wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint; + importPoint = GeometryEngine.Instance.ImportFromWKT( + wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint; x = importPoint.X; // x = 100 y = importPoint.Y; // y = 200 @@ -3937,9 +3632,10 @@ public void ImportExport() m = importPoint.M; // m = 400 // export without m - WKTExportFlags exportFlagsNoM = WKTExportFlags.wktExportStripMs; + WktExportFlags exportFlagsNoM = WktExportFlags.WktExportStripMs; wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoM, point); - importPoint = GeometryEngine.Instance.ImportFromWKT(wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint; + importPoint = GeometryEngine.Instance.ImportFromWKT( + wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint; x = importPoint.X; // x = 100 y = importPoint.Y; // y = 200 @@ -3949,8 +3645,10 @@ public void ImportExport() m = importPoint.M; // m = Nan // export without z, m - wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoZ | exportFlagsNoM, point); - importPoint = GeometryEngine.Instance.ImportFromWKT(wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint; + wktString = GeometryEngine.Instance.ExportToWKT( + exportFlagsNoZ | exportFlagsNoM, point); + importPoint = GeometryEngine.Instance.ImportFromWKT( + wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint; x = importPoint.X; // x = 100 y = importPoint.Y; // y = 200 @@ -3963,14 +3661,17 @@ public void ImportExport() } { - // cref: Import and Export Geometries to well-known Binary;ArcGIS.Core.Geometry.GeometryEngine.ExportToWKB(ArcGIS.Core.Geometry.WKBExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to well-known Binary;ArcGIS.Core.Geometry.GeometryEngine.ExportToWKB(ArcGIS.Core.Geometry.WKBExportFlags,ArcGIS.Core.Geometry.Geometry,System.Byte[]@) - // cref: Import and Export Geometries to well-known Binary;ArcGIS.Core.Geometry.GeometryEngine.GetWKBSize(ArcGIS.Core.Geometry.WKBExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to well-known Binary;ArcGIS.Core.Geometry.GeometryEngine.ImportFromWKB(ArcGIS.Core.Geometry.WKBImportFlags,System.Byte[],ArcGIS.Core.Geometry.SpatialReference) - // cref: Import and Export Geometries to well-known Binary;ArcGIS.Core.Geometry.IGeometryEngine.ExportToWKB(ArcGIS.Core.Geometry.WKBExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to well-known Binary;ArcGIS.Core.Geometry.IGeometryEngine.ExportToWKB(ArcGIS.Core.Geometry.WKBExportFlags,ArcGIS.Core.Geometry.Geometry,System.Byte[]@) - // cref: Import and Export Geometries to well-known Binary;ArcGIS.Core.Geometry.IGeometryEngine.GetWKBSize(ArcGIS.Core.Geometry.WKBExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to well-known Binary;ArcGIS.Core.Geometry.IGeometryEngine.ImportFromWKB(ArcGIS.Core.Geometry.WKBImportFlags,System.Byte[],ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ExportToWKB(ArcGIS.Core.Geometry.WkbExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ExportToWKB(ArcGIS.Core.Geometry.WkbExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ImportFromWKB(ArcGIS.Core.Geometry.WkbImportFlags,System.Byte[],ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ImportFromWKB(ArcGIS.Core.Geometry.WkbImportFlags,System.Byte[],ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetWKBSize(ArcGIS.Core.Geometry.WkbExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetWKBSize(ArcGIS.Core.Geometry.WkbExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ExportToWKB(ArcGIS.Core.Geometry.WkbExportFlags,ArcGIS.Core.Geometry.Geometry,System.Byte[]@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ExportToWKB(ArcGIS.Core.Geometry.WkbExportFlags,ArcGIS.Core.Geometry.Geometry,System.Byte[]@) + // cref: ArcGIS.Core.Geometry.SpatialReferences.WGS84 + // cref: ArcGIS.Core.Geometry.WktExportFlags + // cref: ArcGIS.Core.Geometry.WktImportFlags #region Import and Export Geometries to well-known Binary // create a polyline @@ -3982,14 +3683,16 @@ public void ImportExport() new Coordinate2D(1, 0) }; - Polyline polyline = PolylineBuilder.CreatePolyline(coords, SpatialReferences.WGS84); + Polyline polyline = PolylineBuilderEx.CreatePolyline( + coords, SpatialReferences.WGS84); - WKBExportFlags wkbExportFlags = WKBExportFlags.wkbExportDefaults; - WKBImportFlags wkbImportFlags = WKBImportFlags.wkbImportDefaults; + WkbExportFlags wkbExportFlags = WkbExportFlags.WkbExportDefaults; + WkbImportFlags wkbImportFlags = WkbImportFlags.WkbImportDefaults; // export and import byte[] buffer = GeometryEngine.Instance.ExportToWKB(wkbExportFlags, polyline); - Geometry geometry = GeometryEngine.Instance.ImportFromWKB(wkbImportFlags, buffer, SpatialReferences.WGS84); + Geometry geometry = GeometryEngine.Instance.ImportFromWKB( + wkbImportFlags, buffer, SpatialReferences.WGS84); Polyline importPolyline = geometry as Polyline; @@ -3997,9 +3700,11 @@ public void ImportExport() int bufferSize = GeometryEngine.Instance.GetWKBSize(wkbExportFlags, polyline); buffer = new byte[bufferSize]; // export - bufferSize = GeometryEngine.Instance.ExportToWKB(wkbExportFlags, polyline, ref buffer); + bufferSize = GeometryEngine.Instance.ExportToWKB( + wkbExportFlags, polyline, ref buffer); // import - importPolyline = GeometryEngine.Instance.ImportFromWKB(wkbImportFlags, buffer, SpatialReferences.WGS84) as Polyline; + importPolyline = GeometryEngine.Instance.ImportFromWKB( + wkbImportFlags, buffer, SpatialReferences.WGS84) as Polyline; #endregion } @@ -4007,96 +3712,114 @@ public void ImportExport() public void ImportExportEsriShape() { - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.Envelope.ToEsriShape - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.EnvelopeBuilder.FromEsriShape(System.Byte[],ArcGIS.Core.Geometry.SpatialReference) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.GeometryEngine.ExportToEsriShape(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.GeometryEngine.ExportToEsriShape(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry,System.Byte[]@) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.GeometryEngine.GetEsriShapeSize(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.GeometryEngine.ImportFromEsriShape(ArcGIS.Core.Geometry.EsriShapeImportFlags,System.Byte[],ArcGIS.Core.Geometry.SpatialReference) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.IGeometryEngine.ExportToEsriShape(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.IGeometryEngine.ExportToEsriShape(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry,System.Byte[]@) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.IGeometryEngine.GetEsriShapeSize(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.IGeometryEngine.ImportFromEsriShape(ArcGIS.Core.Geometry.EsriShapeImportFlags,System.Byte[],ArcGIS.Core.Geometry.SpatialReference) - // cref: Import and Export Geometries to EsriShape;ArcGIS.Core.Geometry.Envelope.ToEsriShape(System.Byte[]@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ExportToEsriShape(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ExportToEsriShape(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ImportFromEsriShape(ArcGIS.Core.Geometry.EsriShapeImportFlags,System.Byte[],ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ImportFromEsriShape(ArcGIS.Core.Geometry.EsriShapeImportFlags,System.Byte[],ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetEsriShapeSize(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetEsriShapeSize(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ExportToEsriShape(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry,System.Byte[]@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ExportToEsriShape(ArcGIS.Core.Geometry.EsriShapeExportFlags,ArcGIS.Core.Geometry.Geometry,System.Byte[]@) + // cref: ArcGIS.Core.Geometry.Envelope.ToEsriShape + // cref: ArcGIS.Core.Geometry.Envelope.ToEsriShape(System.Byte[]@) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.FromEsriShape(System.Byte[],ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.SpatialReferences.WGS84 + // cref: ArcGIS.Core.Geometry.EsriShapeExportFlags #region Import and Export Geometries to EsriShape // create an envelope List coordsZM = new List { - MapPointBuilder.CreateMapPoint(1001, 1002, 1003, 1004), - MapPointBuilder.CreateMapPoint(2001, 2002, Double.NaN, 2004), - MapPointBuilder.CreateMapPoint(3001, -3002, 3003, 3004), - MapPointBuilder.CreateMapPoint(1001, -4002, 4003, 4004) + MapPointBuilderEx.CreateMapPoint(1001, 1002, 1003, 1004), + MapPointBuilderEx.CreateMapPoint(2001, 2002, Double.NaN, 2004), + MapPointBuilderEx.CreateMapPoint(3001, -3002, 3003, 3004), + MapPointBuilderEx.CreateMapPoint(1001, -4002, 4003, 4004) }; - Envelope envelope = EnvelopeBuilder.CreateEnvelope(coordsZM[0], coordsZM[2], SpatialReferences.WGS84); + Envelope envelope = EnvelopeBuilderEx.CreateEnvelope( + coordsZM[0], coordsZM[2], SpatialReferences.WGS84); // export and import - EsriShapeExportFlags exportFlags = EsriShapeExportFlags.esriShapeExportDefaults; - EsriShapeImportFlags importFlags = EsriShapeImportFlags.esriShapeImportDefaults; + EsriShapeExportFlags exportFlags = EsriShapeExportFlags.EsriShapeExportDefaults; + EsriShapeImportFlags importFlags = EsriShapeImportFlags.EsriShapeImportDefaults; byte[] buffer = GeometryEngine.Instance.ExportToEsriShape(exportFlags, envelope); - Polygon importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(importFlags, buffer, envelope.SpatialReference) as Polygon; + Polygon importedPolygon = GeometryEngine.Instance.ImportFromEsriShape( + importFlags, buffer, envelope.SpatialReference) as Polygon; Envelope importedEnvelope = importedPolygon.Extent; // export without z,m - buffer = GeometryEngine.Instance.ExportToEsriShape(EsriShapeExportFlags.esriShapeExportStripZs | EsriShapeExportFlags.esriShapeExportStripMs, envelope); - importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(importFlags, buffer, SpatialReferences.WGS84) as Polygon; + buffer = GeometryEngine.Instance.ExportToEsriShape( + EsriShapeExportFlags.EsriShapeExportStripZs | + EsriShapeExportFlags.EsriShapeExportStripMs, envelope); + importedPolygon = GeometryEngine.Instance.ImportFromEsriShape( + importFlags, buffer, SpatialReferences.WGS84) as Polygon; importedEnvelope = importedPolygon.Extent; bool hasZ = importedEnvelope.HasZ; // hasZ = false bool hasM = importedEnvelope.HasM; // hasM = false // export with shapeSize - int bufferSize = GeometryEngine.Instance.GetEsriShapeSize(exportFlags, envelope); + int bufferSize = GeometryEngine.Instance.GetEsriShapeSize( + exportFlags, envelope); buffer = new byte[bufferSize]; - bufferSize = GeometryEngine.Instance.ExportToEsriShape(exportFlags, envelope, ref buffer); - importedPolygon = GeometryEngine.Instance.ImportFromEsriShape(importFlags, buffer, envelope.SpatialReference) as Polygon; + bufferSize = GeometryEngine.Instance.ExportToEsriShape( + exportFlags, envelope, ref buffer); + importedPolygon = GeometryEngine.Instance.ImportFromEsriShape( + importFlags, buffer, envelope.SpatialReference) as Polygon; importedEnvelope = importedPolygon.Extent; - // or use the envelope and envelopeBuilder classes + // or use the envelope and envelopeBuilderEx classes buffer = envelope.ToEsriShape(); // buffer represents a polygon as there is not an envelope Esri shape buffer - // EnvelopeBuilder.FromEsriShape takes a polygon Esri shape buffer and returns the extent of the polygon. - importedEnvelope = EnvelopeBuilder.FromEsriShape(buffer); + // EnvelopeBuilderEx.FromEsriShape takes a polygon Esri shape buffer and returns the extent of the polygon. + importedEnvelope = EnvelopeBuilderEx.FromEsriShape(buffer); #endregion } public void ImportExportJson() { - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.Geometry.ToJson(System.Boolean) - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.GeometryEngine.ExportToJSON(ArcGIS.Core.Geometry.JSONExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.GeometryEngine.ImportFromJSON(ArcGIS.Core.Geometry.JSONImportFlags,System.String) - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.IGeometryEngine.ExportToJSON(ArcGIS.Core.Geometry.JSONExportFlags,ArcGIS.Core.Geometry.Geometry) - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.IGeometryEngine.ImportFromJSON(ArcGIS.Core.Geometry.JSONImportFlags,System.String) - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.MapPointBuilder.FromJson(System.String) - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.MultipointBuilder.FromJson(System.String) - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.PolygonBuilder.FromJson(System.String) - // cref: Import and Export Geometries to JSON;ArcGIS.Core.Geometry.PolylineBuilder.FromJson(System.String) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ImportFromJson(ArcGIS.Core.Geometry.JsonImportFlags,System.String) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ImportFromJson(ArcGIS.Core.Geometry.JsonImportFlags,System.String) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.FromJson(System.String) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ExportToJson(ArcGIS.Core.Geometry.JsonExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ExportToJson(ArcGIS.Core.Geometry.JsonExportFlags,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.Geometry.ToJson(System.Boolean) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.FromJson(System.String) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.FromJson(System.String) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.FromJson(System.String) + // cref: ArcGIS.Core.Geometry.JsonImportFlags + // cref: ArcGIS.Core.Geometry.JsonExportFlags #region Import and Export Geometries to JSON // MapPoint - string inputString = "{\"x\":1,\"y\":2,\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326}}"; - Geometry geometry = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, inputString); + string inputString = + "{\"x\":1,\"y\":2,\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326}}"; + Geometry geometry = GeometryEngine.Instance.ImportFromJson( + JsonImportFlags.JsonImportDefaults, inputString); MapPoint importPoint = geometry as MapPoint; // importPoint = 1, 2 // importPoint.SpatialReference.WKid = 4326 - // use the MapPointBuilder convenience method - MapPoint importPoint2 = MapPointBuilder.FromJson(inputString); + // use the MapPointBuilderEx convenience method + MapPoint importPoint2 = MapPointBuilderEx.FromJson(inputString); // importPoint2 = 1, 2 // impointPoint2.SpatialReference.Wkid = 4326 - string outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportDefaults, importPoint); - // outputString = "{\"x\":1,\"y\":2,\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326}}" + string outputString = GeometryEngine.Instance.ExportToJson( + JsonExportFlags.JsonExportDefaults, importPoint); + // outputString = + // "{\"x\":1,\"y\":2,\"spatialReference\":{\"wkid\":4326,\"latestWkid\":4326}}" string outputString2 = importPoint.ToJson(); - inputString = "{\"spatialReference\":{\"wkid\":4326},\"z\":3,\"m\":4,\"x\":1,\"y\":2}"; - importPoint = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, inputString) as MapPoint; + inputString = + "{\"spatialReference\":{\"wkid\":4326},\"z\":3,\"m\":4,\"x\":1,\"y\":2}"; + importPoint = GeometryEngine.Instance.ImportFromJson( + JsonImportFlags.JsonImportDefaults, inputString) as MapPoint; // importPoint.HasM = true // importPoint.HasZ = true // importPoint.X = 1 @@ -4104,13 +3827,14 @@ public void ImportExportJson() // importPoint.M = 4 // importPoint.Z = 3 - importPoint2 = MapPointBuilder.FromJson(inputString); + importPoint2 = MapPointBuilderEx.FromJson(inputString); // export to json - skip spatial reference - outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportSkipCRS, importPoint); + outputString = GeometryEngine.Instance.ExportToJson( + JsonExportFlags.JsonExportSkipCRS, importPoint); // outputString = "{\"x\":1,\"y\":2,\"z\":3,\"m\":4}" - // export from mappoint, skipping the sr - same as GeometryEngine.Instance.ExportToJSON w JSONExportFlags.jsonExportSkipCRS + // export from mappoint, skipping the sr - same as GeometryEngine.Instance.ExportToJson w JsonExportFlags.JsonExportSkipCRS outputString2 = importPoint.ToJson(true); // @@ -4124,10 +3848,14 @@ public void ImportExportJson() new Coordinate2D(401, 500) }; - Multipoint multipoint = MultipointBuilder.CreateMultipoint(coords, SpatialReferences.WebMercator); + Multipoint multipoint = MultipointBuilderEx.CreateMultipoint( + coords, SpatialReferences.WebMercator); - inputString = "{\"points\":[[100,200],[201,300],[301,400],[401,500]],\"spatialReference\":{\"wkid\":3857}}"; - Multipoint importMultipoint = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, inputString) as Multipoint; + inputString = + "{\"points\":[[100,200],[201,300],[301,400],[401,500]],\"spatialReference\":{\"wkid\":3857}}"; + Multipoint importMultipoint = + GeometryEngine.Instance.ImportFromJson( + JsonImportFlags.JsonImportDefaults, inputString) as Multipoint; // importMultipoint.IsEqual(multipoint) = true ReadOnlyPointCollection points = importMultipoint.Points; @@ -4137,12 +3865,13 @@ public void ImportExportJson() // points[2] = 301, 400 // points[3] = 401, 500 - // use the Multipointbuilder convenience method - Multipoint importMultipoint2 = MultipointBuilder.FromJson(inputString); + // use the MultipointbuilderEx convenience method + Multipoint importMultipoint2 = MultipointBuilderEx.FromJson(inputString); // importMultipoint2.IsEqual(multipoint) = true // export to json - outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportDefaults, multipoint); + outputString = GeometryEngine.Instance.ExportToJson( + JsonExportFlags.JsonExportDefaults, multipoint); // outputString = inputString // or use the multipoint itself @@ -4151,12 +3880,15 @@ public void ImportExportJson() // // Polyline // - Polyline polyline = PolylineBuilder.CreatePolyline(coords, SpatialReferences.WebMercator); + Polyline polyline = PolylineBuilderEx.CreatePolyline( + coords, SpatialReferences.WebMercator); // export without the spatial reference - outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportSkipCRS, polyline); + outputString = GeometryEngine.Instance.ExportToJson( + JsonExportFlags.JsonExportSkipCRS, polyline); // import - geometry = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, outputString); + geometry = GeometryEngine.Instance.ImportFromJson( + JsonImportFlags.JsonImportDefaults, outputString); Polyline importPolyline = geometry as Polyline; // importPolyline.SpatialReference = null @@ -4168,8 +3900,8 @@ public void ImportExportJson() // points[2] = 301, 400 // points[3] = 401, 500 - // use the polylineBuilder convenience method - Polyline importPolyline2 = PolylineBuilder.FromJson(outputString); + // use the polylineBuilderEx convenience method + Polyline importPolyline2 = PolylineBuilderEx.FromJson(outputString); // importPolyline2 = importPolyline outputString2 = importPolyline2.ToJson(); @@ -4178,29 +3910,34 @@ public void ImportExportJson() // // Polygon // - Polygon polygon = PolygonBuilder.CreatePolygon(coords, SpatialReferences.WebMercator); + Polygon polygon = PolygonBuilderEx.CreatePolygon( + coords, SpatialReferences.WebMercator); // export without the spatial reference - outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportSkipCRS, polygon); + outputString = GeometryEngine.Instance.ExportToJson( + JsonExportFlags.JsonExportSkipCRS, polygon); // import - geometry = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, outputString); + geometry = GeometryEngine.Instance.ImportFromJson( + JsonImportFlags.JsonImportDefaults, outputString); Polygon importPolygon = geometry as Polygon; // importPolygon.SpatialReference = null points = importPolygon.Points; // points.Count = 5 - // polygonBuilder convenience method - Polygon importPolyon2 = PolygonBuilder.FromJson(outputString); + // polygonBuilderEx convenience method + Polygon importPolyon2 = PolygonBuilderEx.FromJson(outputString); // importPolygon2 = importPolygon // export from the polygon outputString2 = importPolyon2.ToJson(true); // Empty polygon - polygon = PolygonBuilder.CreatePolygon(SpatialReferences.WebMercator); - outputString = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportDefaults, polygon); - importPolygon = GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, outputString) as Polygon; + polygon = PolygonBuilderEx.CreatePolygon(SpatialReferences.WebMercator); + outputString = GeometryEngine.Instance.ExportToJson( + JsonExportFlags.JsonExportDefaults, polygon); + importPolygon = GeometryEngine.Instance.ImportFromJson( + JsonImportFlags.JsonImportDefaults, outputString) as Polygon; // importPolygon.IsEmpty = true // importPolygon.SpatialReference.Wkid = 3857 @@ -4210,34 +3947,34 @@ public void ImportExportJson() public void ImportExportXML() { - // cref: Import and Export Geometries to XML;ArcGIS.Core.Geometry.EnvelopeBuilder.FromXML(System.String) - // cref: Import and Export Geometries to XML;ArcGIS.Core.Geometry.Geometry.ToXML - // cref: Import and Export Geometries to XML;ArcGIS.Core.Geometry.MapPointBuilder.FromXML(System.String) - // cref: Import and Export Geometries to XML;ArcGIS.Core.Geometry.MultipointBuilder.FromXML(System.String) + // cref: ArcGIS.Core.Geometry.Geometry.ToXml + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.FromXml(System.String) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.FromXml(System.String) + // cref: ArcGIS.Core.Geometry.MultipointBuilderEx.FromXml(System.String) #region Import and Export Geometries to XML - MapPoint minPoint = MapPointBuilder.CreateMapPoint(1, 1, 1, 1, 3); - MapPoint maxPoint = MapPointBuilder.CreateMapPoint(5, 5, 5); + MapPoint minPoint = MapPointBuilderEx.CreateMapPoint(1, 1, 1, 1, 3); + MapPoint maxPoint = MapPointBuilderEx.CreateMapPoint(5, 5, 5); // // MapPoint // - string xml = minPoint.ToXML(); - MapPoint minPointImport = MapPointBuilder.FromXML(xml); + string xml = minPoint.ToXml(); + MapPoint minPointImport = MapPointBuilderEx.FromXml(xml); // minPointImport = minPoint // // Envelope // - Envelope envelopeWithID = EnvelopeBuilder.CreateEnvelope(minPoint, maxPoint); + Envelope envelopeWithID = EnvelopeBuilderEx.CreateEnvelope(minPoint, maxPoint); // Envelopes don't have IDs // envelopeWithID.HasID = false // envelopeWithID.HasM = true // envelopeWithID.HasZ = true - xml = envelopeWithID.ToXML(); - Envelope envelopeImport = EnvelopeBuilder.FromXML(xml); + xml = envelopeWithID.ToXml(); + Envelope envelopeImport = EnvelopeBuilderEx.FromXml(xml); // // Multipoint @@ -4246,10 +3983,10 @@ public void ImportExportXML() list.Add(minPoint); list.Add(maxPoint); - Multipoint multiPoint = MultipointBuilder.CreateMultipoint(list); + Multipoint multiPoint = MultipointBuilderEx.CreateMultipoint(list); - xml = multiPoint.ToXML(); - Multipoint multipointImport = MultipointBuilder.FromXML(xml); + xml = multiPoint.ToXml(); + Multipoint multipointImport = MultipointBuilderEx.FromXml(xml); // multipointImport.PointCount == 2 // multipointImport.HasID = true // multipointImport.HasM = true @@ -4264,26 +4001,29 @@ public void ImportExportXML() public void Create_GeographicTransformation() { - // cref: Create Geographic Transformation;ArcGIS.Core.Geometry.GeographicTransformation.Create(System.Int32,System.Boolean) - // cref: Create Geographic Transformation;ArcGIS.Core.Geometry.GeographicTransformation.Create(System.String,System.Boolean) - // cref: Create Geographic Transformation;ArcGIS.Core.Geometry.GeographicTransformation.GetInverse - // cref: Create Geographic Transformation;ArcGIS.Core.Geometry.GeographicTransformation.IsForward - // cref: Create Geographic Transformation;ArcGIS.Core.Geometry.GeographicTransformation.Name - // cref: Create Geographic Transformation;ArcGIS.Core.Geometry.GeographicTransformation.Wkid - // cref: Create Geographic Transformation;ArcGIS.Core.Geometry.GeographicTransformation.Wkt + // cref: ArcGIS.Core.Geometry.GeographicTransformation.Create(System.Int32,System.Boolean) + // cref: ArcGIS.Core.Geometry.GeographicTransformation.Create(System.String,System.Boolean) + // cref: ArcGIS.Core.Geometry.GeographicTransformation.Name + // cref: ArcGIS.Core.Geometry.GeographicTransformation.Wkt + // cref: ArcGIS.Core.Geometry.GeographicTransformation.Wkid + // cref: ArcGIS.Core.Geometry.GeographicTransformation.GetInverse + // cref: ArcGIS.Core.Geometry.GeographicTransformation.IsForward #region Create Geographic Transformation // create from wkid - GeographicTransformation gt1478 = ArcGIS.Core.Geometry.GeographicTransformation.Create(1478); + GeographicTransformation gt1478 = + ArcGIS.Core.Geometry.GeographicTransformation.Create(1478); string name = gt1478.Name; string wkt = gt1478.Wkt; int wkid = gt1478.Wkid; // create from wkt - GeographicTransformation another_gt1478 = ArcGIS.Core.Geometry.GeographicTransformation.Create(wkt); + GeographicTransformation another_gt1478 = + ArcGIS.Core.Geometry.GeographicTransformation.Create(wkt); // inverse - GeographicTransformation inverse_gt148 = another_gt1478.GetInverse() as GeographicTransformation; + GeographicTransformation inverse_gt148 = + another_gt1478.GetInverse() as GeographicTransformation; bool isForward = inverse_gt148.IsForward; #endregion @@ -4291,27 +4031,30 @@ public void Create_GeographicTransformation() public void Create_CompositeGeographicTransformation() { - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.GeographicTransformation}) - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(System.Int32,System.Boolean) - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(System.String,System.Boolean) - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.CompositeGeographicTransformation.GetInverse - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.CompositeGeographicTransformation.ToJson - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.DatumTransformation.CreateFromJson(System.String) - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.CompositeGeographicTransformation.Count - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.CompositeGeographicTransformation.Item(System.Int32) - // cref: Create Composite Geographic Transformation;ArcGIS.Core.Geometry.CompositeGeographicTransformation.Transformations + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.GeographicTransformation}) + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(System.Int32,System.Boolean) + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(System.String,System.Boolean) + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation.Count + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation.Transformations + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation.Item(System.Int32) + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation.GetInverse + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation.ToJson + // cref: ArcGIS.Core.Geometry.DatumTransformation.CreateFromJson(System.String) #region Create Composite Geographic Transformation // Create singleton from wkid - CompositeGeographicTransformation cgt = ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(108272); + CompositeGeographicTransformation cgt = + ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(108272); int count = cgt.Count; // count = 1 - IList gts = cgt.Transformations as IList; + IList gts = cgt.Transformations + as IList; gts.Add(ArcGIS.Core.Geometry.GeographicTransformation.Create(1437, false)); count = cgt.Count; // count = 2 // create from an enumeration - CompositeGeographicTransformation another_cgt = ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(gts); + CompositeGeographicTransformation another_cgt = + ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(gts); GeographicTransformation gt0 = another_cgt[0]; GeographicTransformation gt1 = another_cgt[1]; @@ -4322,21 +4065,23 @@ public void Create_CompositeGeographicTransformation() var wkt = gt0.Wkt; // create from string - CompositeGeographicTransformation third_cgt = ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(wkt, gt0.IsForward); + CompositeGeographicTransformation third_cgt = + ArcGIS.Core.Geometry.CompositeGeographicTransformation.Create(wkt, gt0.IsForward); count = third_cgt.Count; // count = 1 // create from josn string json = cgt.ToJson(); - CompositeGeographicTransformation joson_cgt = DatumTransformation.CreateFromJson(json) as CompositeGeographicTransformation; + CompositeGeographicTransformation joson_cgt = + DatumTransformation.CreateFromJson(json) as CompositeGeographicTransformation; #endregion } public void Create_ProjectionTransformation() { - // cref: Create Projection Transformation;ArcGIS.Core.Geometry.GeometryEngine.ProjectEx(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.ProjectionTransformation) - // cref: Create Projection Transformation;ArcGIS.Core.Geometry.IGeometryEngine.ProjectEx(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.ProjectionTransformation) - // cref: Create Projection Transformation;ArcGIS.Core.Geometry.ProjectionTransformation.Create(ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.ProjectionTransformation.Create(ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ProjectEx(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.ProjectionTransformation) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ProjectEx(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.ProjectionTransformation) #region Create Projection Transformation // methods need to be on the MCT @@ -4347,18 +4092,24 @@ public void Create_ProjectionTransformation() SpatialReference sr3857 = SpatialReferences.WebMercator; // Create transformation from 4267 -> 3857 - ProjectionTransformation projTransFromSRs = ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr4267, sr3857); + ProjectionTransformation projTransFromSRs = + ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr4267, sr3857); // create an envelope - Envelope env = EnvelopeBuilder.CreateEnvelope(new Coordinate2D(2, 2), new Coordinate2D(3, 3), sr4267); + Envelope env = EnvelopeBuilderEx.CreateEnvelope( + new Coordinate2D(2, 2), new Coordinate2D(3, 3), sr4267); // Project with one geo transform 4267 -> 3857 - Envelope projectedEnvEx = GeometryEngine.Instance.ProjectEx(env, projTransFromSRs) as Envelope; + Envelope projectedEnvEx = GeometryEngine.Instance.ProjectEx( + env, projTransFromSRs) as Envelope; // Create inverse transformation, 3857 -> 4267 - ProjectionTransformation projTransFromSRsInverse = ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr3857, sr4267); + ProjectionTransformation projTransFromSRsInverse = + ArcGIS.Core.Geometry.ProjectionTransformation.Create(sr3857, sr4267); // Project the projected envelope back using the inverse transformation - Envelope projectedEnvBack = GeometryEngine.Instance.ProjectEx(projectedEnvEx, projTransFromSRsInverse) as Envelope; + Envelope projectedEnvBack = + GeometryEngine.Instance.ProjectEx( + projectedEnvEx, projTransFromSRsInverse) as Envelope; bool isEqual = env.IsEqual(projectedEnvBack); }); @@ -4368,13 +4119,13 @@ public void Create_ProjectionTransformation() public void Create_HVDatumTransformation() { - // cref: Create HV Datum Transformation;ArcGIS.Core.Geometry.HVDatumTransformation.Create(System.Int32,System.Boolean) - // cref: Create HV Datum Transformation;ArcGIS.Core.Geometry.HVDatumTransformation.Create(System.String,System.Boolean) - // cref: Create HV Datum Transformation;ArcGIS.Core.Geometry.HVDatumTransformation.GetInverse - // cref: Create HV Datum Transformation;ArcGIS.Core.Geometry.HVDatumTransformation.IsForward - // cref: Create HV Datum Transformation;ArcGIS.Core.Geometry.HVDatumTransformation.Name - // cref: Create HV Datum Transformation;ArcGIS.Core.Geometry.HVDatumTransformation.Wkid - // cref: Create HV Datum Transformation;ArcGIS.Core.Geometry.HVDatumTransformation.Wkt + // cref: ArcGIS.Core.Geometry.HVDatumTransformation.Create(System.Int32,System.Boolean) + // cref: ArcGIS.Core.Geometry.HVDatumTransformation.Create(System.String,System.Boolean) + // cref: ArcGIS.Core.Geometry.HVDatumTransformation.IsForward + // cref: ArcGIS.Core.Geometry.HVDatumTransformation.Wkid + // cref: ArcGIS.Core.Geometry.HVDatumTransformation.Name + // cref: ArcGIS.Core.Geometry.HVDatumTransformation.Wkt + // cref: ArcGIS.Core.Geometry.HVDatumTransformation.GetInverse #region Create HV Datum Transformation // Create from wkid @@ -4388,7 +4139,8 @@ public void Create_HVDatumTransformation() HVDatumTransformation hv110018FromWkt = HVDatumTransformation.Create(wkt); // Get the inverse - HVDatumTransformation hv110018Inverse = hv110018.GetInverse() as HVDatumTransformation; + HVDatumTransformation hv110018Inverse = + hv110018.GetInverse() as HVDatumTransformation; // hv110018Inverse.IsForward = false #endregion @@ -4396,17 +4148,17 @@ public void Create_HVDatumTransformation() public void Create_CompositeHVDatumTransformation() { - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Create(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.HVDatumTransformation}) - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Create(System.Int32,System.Boolean) - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Create(System.String,System.Boolean) - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.CreateFromXML(System.String) - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.GetInverse - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.ToJson - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.ToXML - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.DatumTransformation.CreateFromJson(System.String) - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Count - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Item(System.Int32) - // cref: Create Composite HV Datum Transformation;ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Transformations + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Create(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.HVDatumTransformation}) + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Create(System.Int32,System.Boolean) + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Create(System.String,System.Boolean) + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Count + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Transformations + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.GetInverse + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.ToXml + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.CreateFromXml(System.String) + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.ToJson + // cref: ArcGIS.Core.Geometry.DatumTransformation.CreateFromJson(System.String) + // cref: ArcGIS.Core.Geometry.CompositeHVDatumTransformation.Item(System.Int32) #region Create Composite HV Datum Transformation HVDatumTransformation hv1 = HVDatumTransformation.Create(108034); @@ -4414,30 +4166,42 @@ public void Create_CompositeHVDatumTransformation() List hvs = new List() { hv1, hv2 }; // create from enumeration - CompositeHVDatumTransformation compositehv = CompositeHVDatumTransformation.Create(hvs); + CompositeHVDatumTransformation compositehv = + CompositeHVDatumTransformation.Create(hvs); int count = compositehv.Count; // count = 2 - List transforms = compositehv.Transformations as List; + List transforms = + compositehv.Transformations as List; HVDatumTransformation tranform = transforms[0]; // transform.Wkid = 108034 // get inverse - CompositeHVDatumTransformation inverse_compositehv = compositehv.GetInverse() as CompositeHVDatumTransformation; + CompositeHVDatumTransformation inverse_compositehv = + compositehv.GetInverse() as CompositeHVDatumTransformation; // create from xml - string xml = compositehv.ToXML(); - CompositeHVDatumTransformation xml_compositehv = CompositeHVDatumTransformation.CreateFromXML(xml); + string xml = compositehv.ToXml(); + //At 2.x - CompositeHVDatumTransformation xml_compositehv = + // CompositeHVDatumTransformation.CreateFromXML(xml); + + var xml_compositehv = CompositeHVDatumTransformation.CreateFromXml(xml); // create from json string json = compositehv.ToJson(); - CompositeHVDatumTransformation json_compositehv = DatumTransformation.CreateFromJson(json) as CompositeHVDatumTransformation; + CompositeHVDatumTransformation json_compositehv = + DatumTransformation.CreateFromJson(json) as CompositeHVDatumTransformation; #endregion } public void Determine_Transformations() { - // cref: Determine Transformations;ArcGIS.Core.Geometry.ProjectionTransformation.FindTransformations(ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.Envelope,System.Int32,System.Boolean) + // cref: ArcGIS.Core.Geometry.ProjectionTransformation.FindTransformations(ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.Envelope,System.Int32,System.Boolean) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference + // cref: ArcGIS.Core.Geometry.ProjectionTransformation.FindTransformations + // cref: ArcGIS.Core.Geometry.ProjectionTransformation.Transformation + // cref: ArcGIS.Core.Geometry.CompositeGeographicTransformation + // cref: ArcGIS.Core.Geometry.GeographicTransformation #region Determine Transformations // methods need to run on the MCT @@ -4446,13 +4210,16 @@ public void Determine_Transformations() // // find the first transformation used between spatial references 4267 and 4326 // - SpatialReference sr4267 = SpatialReferenceBuilder.CreateSpatialReference(4267); + SpatialReference sr4267 = + SpatialReferenceBuilder.CreateSpatialReference(4267); SpatialReference sr4326 = SpatialReferences.WGS84; - List transformations = ProjectionTransformation.FindTransformations(sr4267, sr4326); + List transformations = + ProjectionTransformation.FindTransformations(sr4267, sr4326); // transformations.Count = 1 ProjectionTransformation projTrans = transformations[0]; - CompositeGeographicTransformation compositeGT = projTrans.Transformation as CompositeGeographicTransformation; + CompositeGeographicTransformation compositeGT = + projTrans.Transformation as CompositeGeographicTransformation; GeographicTransformation gt = compositeGT[0]; // gt.Wkid = 15851 // gt.Name = "NAD_1927_To_WGS_1984_79_CONUS" @@ -4462,7 +4229,8 @@ public void Determine_Transformations() // // find the first five transformation used between spatial references 4267 and 4326 // - transformations = ProjectionTransformation.FindTransformations(sr4267, sr4326, numResults: 5); + transformations = ProjectionTransformation.FindTransformations( + sr4267, sr4326, numResults: 5); // transformations.Count = 5 projTrans = transformations[0]; compositeGT = projTrans.Transformation as CompositeGeographicTransformation; @@ -4509,12 +4277,14 @@ public void Determine_Transformations() // - // find the first transformation used between spatial references 4267 and 4326 within Alaska + // find the first transformation used between spatial + // references 4267 and 4326 within Alaska // // Alaska - Envelope envelope = EnvelopeBuilder.CreateEnvelope(-161, 61, -145, 69); - transformations = ProjectionTransformation.FindTransformations(sr4267, sr4326, envelope); + Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(-161, 61, -145, 69); + transformations = ProjectionTransformation.FindTransformations( + sr4267, sr4326, envelope); // transformations.Count = 1 projTrans = transformations[0]; compositeGT = projTrans.Transformation as CompositeGeographicTransformation; @@ -4531,11 +4301,13 @@ public void Determine_Transformations() // // find the first geographic transformation used between two spatial references with VCS (use vertical = false) // + SpatialReference inSR = + SpatialReferenceBuilder.CreateSpatialReference(4269, 115702); + SpatialReference outSR = + SpatialReferenceBuilder.CreateSpatialReference(4326, 3855); - SpatialReference inSR = SpatialReferenceBuilder.CreateSpatialReference(4269, 115702); - SpatialReference outSR = SpatialReferenceBuilder.CreateSpatialReference(4326, 3855); - - // Even though each spatial reference has a VCS, vertical = false should return geographic transformations. + // Even though each spatial reference has a VCS, + // vertical = false should return geographic transformations. transformations = ProjectionTransformation.FindTransformations(inSR, outSR); // transformations.Count = 1 projTrans = transformations[0]; @@ -4545,16 +4317,18 @@ public void Determine_Transformations() // compositeGT[0].Name = ""WGS_1984_(ITRF00)_To_NAD_1983" // compositeGT[0].IsForward = false - // // find the first vertical transformation used between two spatial references with VCS (use vertical = true) // - transformations = ProjectionTransformation.FindTransformations(inSR, outSR, vertical: true); + transformations = + ProjectionTransformation.FindTransformations( + inSR, outSR, vertical: true); // transformations.Count = 1 projTrans = transformations[0]; - CompositeHVDatumTransformation compositeHV = projTrans.Transformation as CompositeHVDatumTransformation; + CompositeHVDatumTransformation compositeHV = + projTrans.Transformation as CompositeHVDatumTransformation; // compositeHV.Count = 2 // compositeHV[0].Wkid = 1188 // compositeHV[0].Name = "NAD_1983_To_WGS_1984_1" @@ -4572,63 +4346,90 @@ public void Determine_Transformations() public void GeoCoordinateStringConversion() { - // cref: MapPoint - GeoCoordinateString Conversion;ArcGIS.Core.Geometry.MapPoint.ToGeoCoordinateString(ArcGIS.Core.Geometry.ToGeoCoordinateParameter) - // cref: MapPoint - GeoCoordinateString Conversion;ArcGIS.Core.Geometry.MapPointBuilder.FromGeoCoordinateString(System.String,ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.GeoCoordinateType,ArcGIS.Core.Geometry.FromGeoCoordinateMode) - // cref: MapPoint - GeoCoordinateString Conversion;ArcGIS.Core.Geometry.ToGeoCoordinateParameter.#ctor(ArcGIS.Core.Geometry.GeoCoordinateType) - // cref: MapPoint - GeoCoordinateString Conversion;ArcGIS.Core.Geometry.ToGeoCoordinateParameter.#ctor(ArcGIS.Core.Geometry.GeoCoordinateType,ArcGIS.Core.Geometry.ToGeoCoordinateMode) - // cref: MapPoint - GeoCoordinateString Conversion;ArcGIS.Core.Geometry.ToGeoCoordinateParameter.#ctor(ArcGIS.Core.Geometry.GeoCoordinateType,ArcGIS.Core.Geometry.ToGeoCoordinateMode,System.Int32,System.Boolean,System.Boolean) + // cref: ArcGIS.Core.Geometry.ToGeoCoordinateParameter.#ctor(ArcGIS.Core.Geometry.GeoCoordinateType) + // cref: ArcGIS.Core.Geometry.ToGeoCoordinateParameter.#ctor(ArcGIS.Core.Geometry.GeoCoordinateType,ArcGIS.Core.Geometry.ToGeoCoordinateMode) + // cref: ArcGIS.Core.Geometry.ToGeoCoordinateParameter.#ctor(ArcGIS.Core.Geometry.GeoCoordinateType,ArcGIS.Core.Geometry.ToGeoCoordinateMode,System.Int32,System.Boolean,System.Boolean) + // cref: ArcGIS.Core.Geometry.MapPoint.ToGeoCoordinateString(ArcGIS.Core.Geometry.ToGeoCoordinateParameter) + // cref: ArcGIS.Core.Geometry.MapPointBuilderEx.FromGeoCoordinateString(System.String,ArcGIS.Core.Geometry.SpatialReference,ArcGIS.Core.Geometry.GeoCoordinateType,ArcGIS.Core.Geometry.FromGeoCoordinateMode) + // cref: ArcGIS.Core.Geometry.GeoCoordinateType #region MapPoint - GeoCoordinateString Conversion SpatialReference sr = SpatialReferences.WGS84; SpatialReference sr2 = SpatialReferences.WebMercator; // create some points - MapPoint point0 = MapPointBuilder.CreateMapPoint(0, 0, sr); - MapPoint point1 = MapPointBuilder.CreateMapPoint(10, 20, sr); + MapPoint point0 = MapPointBuilderEx.CreateMapPoint(0, 0, sr); + MapPoint point1 = MapPointBuilderEx.CreateMapPoint(10, 20, sr); MapPoint point2 = GeometryEngine.Instance.Project(point1, sr2) as MapPoint; - MapPoint pointEmpty = MapPointBuilder.CreateMapPoint(sr); - MapPoint pointwithNoSR = MapPointBuilder.CreateMapPoint(1, 1); - MapPoint pointZM = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, sr); + MapPoint pointEmpty = MapPointBuilderEx.CreateMapPoint(sr); + MapPoint pointwithNoSR = MapPointBuilderEx.CreateMapPoint(1, 1); + MapPoint pointZM = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, sr); // convert to MGRS - ToGeoCoordinateParameter mgrsParam = new ToGeoCoordinateParameter(GeoCoordinateType.MGRS); - string geoCoordString = point0.ToGeoCoordinateString(mgrsParam); // 31NAA6602100000 - - // use the builder to create a new point from the string. Coordinates are the same - MapPoint outPoint = MapPointBuilder.FromGeoCoordinateString(geoCoordString, sr, GeoCoordinateType.MGRS); // outPoint.x = 0; outPoint.Y = 0 - - geoCoordString = point1.ToGeoCoordinateString(mgrsParam); // 32QPH0460911794 - outPoint = MapPointBuilder.FromGeoCoordinateString(geoCoordString, sr, GeoCoordinateType.MGRS); // outPoint.X = 10; outPoint.Y = 20 + ToGeoCoordinateParameter mgrsParam = + new ToGeoCoordinateParameter(GeoCoordinateType.MGRS); + // 31NAA6602100000 + string geoCoordString = point0.ToGeoCoordinateString(mgrsParam); + + // use the builder to create a new point from the string. + // Coordinates are the same + // outPoint.x = 0; outPoint.Y = 0 + MapPoint outPoint = + MapPointBuilderEx.FromGeoCoordinateString( + geoCoordString, sr, GeoCoordinateType.MGRS); + + // 32QPH0460911794 + // outPoint.X = 10; outPoint.Y = 20 + geoCoordString = point1.ToGeoCoordinateString(mgrsParam); + outPoint = MapPointBuilderEx.FromGeoCoordinateString( + geoCoordString, sr, GeoCoordinateType.MGRS); // z, m are not transformed + // outPoint.X = 1; outPoint.Y = 2; outPoint.Z = Nan; outPoint.M = Nan; geoCoordString = pointZM.ToGeoCoordinateString(mgrsParam); - outPoint = MapPointBuilder.FromGeoCoordinateString(geoCoordString, sr, GeoCoordinateType.MGRS); // outPoint.X = 1; outPoint.Y = 2; outPoint.Z = Nan; outPoint.M = Nan; + outPoint = MapPointBuilderEx.FromGeoCoordinateString( + geoCoordString, sr, GeoCoordinateType.MGRS); // set the number of digits to 2 and convert + // 32QPH0512 + // outPoint.X = 10; outPoint.Y = 20 mgrsParam.NumDigits = 2; - geoCoordString = point1.ToGeoCoordinateString(mgrsParam); // 32QPH0512 - outPoint = MapPointBuilder.FromGeoCoordinateString(geoCoordString, sr, GeoCoordinateType.MGRS); // outPoint.X = 10; outPoint.Y = 20 + geoCoordString = point1.ToGeoCoordinateString(mgrsParam); + outPoint = MapPointBuilderEx.FromGeoCoordinateString( + geoCoordString, sr, GeoCoordinateType.MGRS); // convert to UTM - ToGeoCoordinateParameter utmParam = new ToGeoCoordinateParameter(GeoCoordinateType.UTM); - geoCoordString = point0.ToGeoCoordinateString(utmParam); // 31N 166021 0000000 - geoCoordString = point1.ToGeoCoordinateString(utmParam); // 32Q 604609 2211793 + ToGeoCoordinateParameter utmParam = + new ToGeoCoordinateParameter(GeoCoordinateType.UTM); + // 31N 166021 0000000 + geoCoordString = point0.ToGeoCoordinateString(utmParam); + // 32Q 604609 2211793 + geoCoordString = point1.ToGeoCoordinateString(utmParam); // convert to DMS - ToGeoCoordinateParameter dmsParam = new ToGeoCoordinateParameter(GeoCoordinateType.DMS); - geoCoordString = point0.ToGeoCoordinateString(dmsParam); // 00 00 00.00N 000 00 00.00E - geoCoordString = point1.ToGeoCoordinateString(dmsParam); // 20 00 00.00N 010 00 00.00E + ToGeoCoordinateParameter dmsParam = + new ToGeoCoordinateParameter(GeoCoordinateType.DMS); + // 00 00 00.00N 000 00 00.00E + geoCoordString = point0.ToGeoCoordinateString(dmsParam); + // 20 00 00.00N 010 00 00.00E + geoCoordString = point1.ToGeoCoordinateString(dmsParam); // convert to DDM - ToGeoCoordinateParameter ddmParam = new ToGeoCoordinateParameter(GeoCoordinateType.DDM); - geoCoordString = point0.ToGeoCoordinateString(ddmParam); // 00 00.0000N 000 00.0000E - geoCoordString = point1.ToGeoCoordinateString(ddmParam); // 20 00.0000N 010 00.0000E + ToGeoCoordinateParameter ddmParam = + new ToGeoCoordinateParameter(GeoCoordinateType.DDM); + // 00 00.0000N 000 00.0000E + geoCoordString = point0.ToGeoCoordinateString(ddmParam); + // 20 00.0000N 010 00.0000E + geoCoordString = point1.ToGeoCoordinateString(ddmParam); // convert to DD - ToGeoCoordinateParameter ddParam = new ToGeoCoordinateParameter(GeoCoordinateType.DD); - geoCoordString = point0.ToGeoCoordinateString(ddParam); // 00.000000N 000.000000E - geoCoordString = point1.ToGeoCoordinateString(ddParam); // 20.000000N 010.000000E + ToGeoCoordinateParameter ddParam = + new ToGeoCoordinateParameter(GeoCoordinateType.DD); + // 00.000000N 000.000000E + geoCoordString = point0.ToGeoCoordinateString(ddParam); + // 20.000000N 010.000000E + geoCoordString = point1.ToGeoCoordinateString(ddParam); #endregion } @@ -4638,9 +4439,9 @@ public void OtherUtilities() #region ProSnippet Group: AngularUnit #endregion - // cref: AngularUnit - Convert between degrees and radians;ArcGIS.Core.Geometry.AngularUnit.ConvertFromRadians(System.Double) - // cref: AngularUnit - Convert between degrees and radians;ArcGIS.Core.Geometry.AngularUnit.ConvertToRadians(System.Double) - // cref: AngularUnit - Convert between degrees and radians;ArcGIS.Core.Geometry.AngularUnit.Degrees + // cref: ArcGIS.Core.Geometry.AngularUnit.Degrees + // cref: ArcGIS.Core.Geometry.AngularUnit.ConvertToRadians(System.Double) + // cref: ArcGIS.Core.Geometry.AngularUnit.ConvertFromRadians(System.Double) #region AngularUnit - Convert between degrees and radians // convert 45 degrees to radians @@ -4651,13 +4452,15 @@ public void OtherUtilities() #endregion - // cref: AngularUnit - Create an AngularUnit with a factory code;ArcGIS.Core.Geometry.AngularUnit.ConvertFromRadians(System.Double) - // cref: AngularUnit - Create an AngularUnit with a factory code;ArcGIS.Core.Geometry.AngularUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.AngularUnit) - // cref: AngularUnit - Create an AngularUnit with a factory code;ArcGIS.Core.Geometry.AngularUnit.CreateAngularUnit(System.Int32) - // cref: AngularUnit - Create an AngularUnit with a factory code;ArcGIS.Core.Geometry.AngularUnit.RadiansPerUnit - // cref: AngularUnit - Create an AngularUnit with a factory code;ArcGIS.Core.Geometry.Unit.ConversionFactor - // cref: AngularUnit - Create an AngularUnit with a factory code;ArcGIS.Core.Geometry.Unit.FactoryCode - // cref: AngularUnit - Create an AngularUnit with a factory code;ArcGIS.Core.Geometry.Unit.Name + // cref: ArcGIS.Core.Geometry.AngularUnit.CreateAngularUnit(System.Int32) + // cref: ArcGIS.Core.Geometry.AngularUnit.Degrees + // cref: ArcGIS.Core.Geometry.AngularUnit.ConvertFromRadians + // cref: ArcGIS.Core.Geometry.Unit.Name + // cref: ArcGIS.Core.Geometry.Unit.ConversionFactor + // cref: ArcGIS.Core.Geometry.AngularUnit.RadiansPerUnit + // cref: ArcGIS.Core.Geometry.Unit.FactoryCode + // cref: ArcGIS.Core.Geometry.AngularUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.AngularUnit) + // cref: ArcGIS.Core.Geometry.AngularUnit.ConvertFromRadians(System.Double) #region AngularUnit - Create an AngularUnit with a factory code try @@ -4677,19 +4480,24 @@ public void OtherUtilities() } catch (ArgumentException) { - // ArgumentException will be thrown by CreateAngularUnit in the following scenarios - // - if the factory code used is a non-angular factory code (i.e. it corresponds to square meters which is an area unit code) - // - if the factory code used is invalid (i.e. it is negative or doesn't correspond to any factory code) + // ArgumentException will be thrown by CreateAngularUnit in + // the following scenarios: + // - if the factory code used is a non-angular factory code + // (i.e. it corresponds to square meters which is an area unit code) + // - if the factory code used is invalid + // (i.e. it is negative or doesn't correspond to any factory code) } #endregion - // cref: AngularUnit - Create a Custom AngularUnit;ArcGIS.Core.Geometry.AngularUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.AngularUnit) - // cref: AngularUnit - Create a Custom AngularUnit;ArcGIS.Core.Geometry.AngularUnit.CreateAngularUnit(System.String) - // cref: AngularUnit - Create a Custom AngularUnit;ArcGIS.Core.Geometry.AngularUnit.CreateAngularUnit(System.String,System.Double) - // cref: AngularUnit - Create a Custom AngularUnit;ArcGIS.Core.Geometry.AngularUnit.Degrees - // cref: AngularUnit - Create a Custom AngularUnit;ArcGIS.Core.Geometry.AngularUnit.RadiansPerUnit - // cref: AngularUnit - Create a Custom AngularUnit;ArcGIS.Core.Geometry.Unit.FactoryCode + // cref: ArcGIS.Core.Geometry.AngularUnit.CreateAngularUnit(System.String,System.Double) + // cref: ArcGIS.Core.Geometry.AngularUnit.Degrees + // cref: ArcGIS.Core.Geometry.AngularUnit.ConvertFromRadians + // cref: ArcGIS.Core.Geometry.Unit.FactoryCode + // cref: ArcGIS.Core.Geometry.AngularUnit.RadiansPerUnit + // cref: ArcGIS.Core.Geometry.AngularUnit.Degrees + // cref: ArcGIS.Core.Geometry.AngularUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.AngularUnit) + // cref: ArcGIS.Core.Geometry.AngularUnit.CreateAngularUnit(System.String) #region AngularUnit - Create a Custom AngularUnit // custom unit - 3 radians per unit @@ -4721,9 +4529,9 @@ public void OtherUtilities() #region ProSnippet Group: LinearUnit #endregion - // cref: LinearUnit - Convert between feet and meters;ArcGIS.Core.Geometry.LinearUnit.ConvertFromMeters(System.Double) - // cref: LinearUnit - Convert between feet and meters;ArcGIS.Core.Geometry.LinearUnit.ConvertToMeters(System.Double) - // cref: LinearUnit - Convert between feet and meters;ArcGIS.Core.Geometry.LinearUnit.Feet + // cref: ArcGIS.Core.Geometry.LinearUnit.Feet + // cref: ArcGIS.Core.Geometry.LinearUnit.ConvertToMeters(System.Double) + // cref: ArcGIS.Core.Geometry.LinearUnit.ConvertFromMeters(System.Double) #region LinearUnit - Convert between feet and meters // convert 10 feet to meters double metres = LinearUnit.Feet.ConvertToMeters(10); @@ -4732,10 +4540,10 @@ public void OtherUtilities() double feet = LinearUnit.Feet.ConvertFromMeters(20.0); #endregion - // cref: LinearUnit - Convert between centimeters and millimeters;ArcGIS.Core.Geometry.LinearUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.LinearUnit) - // cref: LinearUnit - Convert between centimeters and millimeters;ArcGIS.Core.Geometry.LinearUnit.ConvertToMeters(System.Double) - // cref: LinearUnit - Convert between centimeters and millimeters;ArcGIS.Core.Geometry.LinearUnit.Centimeters - // cref: LinearUnit - Convert between centimeters and millimeters;ArcGIS.Core.Geometry.LinearUnit.Millimeters + // cref: ArcGIS.Core.Geometry.LinearUnit.Centimeters + // cref: ArcGIS.Core.Geometry.LinearUnit.Millimeters + // cref: ArcGIS.Core.Geometry.LinearUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.LinearUnit.ConvertToMeters(System.Double) #region LinearUnit - Convert between centimeters and millimeters // convert 11 centimeters to millimeters @@ -4749,12 +4557,13 @@ public void OtherUtilities() #endregion - // cref: LinearUnit - Create a LinearUnit with a factory code;ArcGIS.Core.Geometry.LinearUnit.ConvertFromMeters(System.Double) - // cref: LinearUnit - Create a LinearUnit with a factory code;ArcGIS.Core.Geometry.LinearUnit.CreateLinearUnit(System.Int32) - // cref: LinearUnit - Create a LinearUnit with a factory code;ArcGIS.Core.Geometry.LinearUnit.MetersPerUnit - // cref: LinearUnit - Create a LinearUnit with a factory code;ArcGIS.Core.Geometry.Unit.ConversionFactor - // cref: LinearUnit - Create a LinearUnit with a factory code;ArcGIS.Core.Geometry.Unit.FactoryCode - // cref: LinearUnit - Create a LinearUnit with a factory code;ArcGIS.Core.Geometry.Unit.Name + // cref: ArcGIS.Core.Geometry.LinearUnit.CreateLinearUnit(System.Int32) + // cref: ArcGIS.Core.Geometry.Unit.Name + // cref: ArcGIS.Core.Geometry.Unit.ConversionFactor + // cref: ArcGIS.Core.Geometry.LinearUnit.MetersPerUnit + // cref: ArcGIS.Core.Geometry.LinearUnit.Centimeters + // cref: ArcGIS.Core.Geometry.Unit.FactoryCode + // cref: ArcGIS.Core.Geometry.LinearUnit.ConvertFromMeters(System.Double) #region LinearUnit - Create a LinearUnit with a factory code try @@ -4774,18 +4583,24 @@ public void OtherUtilities() } catch (ArgumentException) { - // ArgumentException will be thrown by CreateLinearUnit in the following scenarios - // - if the factory code used is a non-linear factory code (i.e. it corresponds to square meters which is an area unit code) - // - if the factory code used is invalid (i.e. it is negative or doesn't correspond to any factory code) + // ArgumentException will be thrown by CreateLinearUnit + // in the following scenarios: + // - if the factory code used is a non-linear factory code + // (i.e. it corresponds to square meters which is an area unit code) + // - if the factory code used is invalid + // (i.e. it is negative or doesn't correspond to any factory code) } #endregion - // cref: LinearUnit - Create a Custom LinearUnit;ArcGIS.Core.Geometry.LinearUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.LinearUnit) - // cref: LinearUnit - Create a Custom LinearUnit;ArcGIS.Core.Geometry.LinearUnit.CreateLinearUnit(System.String) - // cref: LinearUnit - Create a Custom LinearUnit;ArcGIS.Core.Geometry.LinearUnit.CreateLinearUnit(System.String,System.Double) - // cref: LinearUnit - Create a Custom LinearUnit;ArcGIS.Core.Geometry.Unit.ToString - // cref: LinearUnit - Create a Custom LinearUnit;ArcGIS.Core.Geometry.Unit.FactoryCode + // cref: ArcGIS.Core.Geometry.LinearUnit.CreateLinearUnit(System.String,System.Double) + // cref: ArcGIS.Core.Geometry.LinearUnit.MetersPerUnit + // cref: ArcGIS.Core.Geometry.Unit.ToString + // cref: ArcGIS.Core.Geometry.Unit.Wkt + // cref: ArcGIS.Core.Geometry.Unit.ConversionFactor + // cref: ArcGIS.Core.Geometry.Unit.FactoryCode + // cref: ArcGIS.Core.Geometry.LinearUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.LinearUnit.CreateLinearUnit(System.String) #region LinearUnit - Create a Custom LinearUnit // create a custom linear unit - there are 0.33 meters per myLinearUnit @@ -4813,9 +4628,9 @@ public void OtherUtilities() #region ProSnippet Group: AreaUnit #endregion - // cref: AreaUnit - Convert between square feet and square meters;ArcGIS.Core.Geometry.AreaUnit.ConvertFromSquareMeters(System.Double) - // cref: AreaUnit - Convert between square feet and square meters;ArcGIS.Core.Geometry.AreaUnit.ConvertToSquareMeters(System.Double) - // cref: AreaUnit - Convert between square feet and square meters;ArcGIS.Core.Geometry.AreaUnit.SquareFeet + // cref: ArcGIS.Core.Geometry.AreaUnit.ConvertFromSquareMeters(System.Double) + // cref: ArcGIS.Core.Geometry.AreaUnit.ConvertToSquareMeters(System.Double) + // cref: ArcGIS.Core.Geometry.AreaUnit.SquareFeet #region AreaUnit - Convert between square feet and square meters // convert 700 square meters to square feet @@ -4825,8 +4640,9 @@ public void OtherUtilities() double sqMeters = AreaUnit.SquareFeet.ConvertToSquareMeters(1000); #endregion - // cref: AreaUnit - Convert between hectares and acres;ArcGIS.Core.Geometry.AreaUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.AreaUnit) - // cref: AreaUnit - Convert between hectares and acres;ArcGIS.Core.Geometry.AreaUnit.Hectares + // cref: ArcGIS.Core.Geometry.AreaUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.AreaUnit) + // cref: ArcGIS.Core.Geometry.AreaUnit.Hectares + // cref: ArcGIS.Core.Geometry.AreaUnit.Acres #region AreaUnit - Convert between hectares and acres // convert 2 hectares to acres @@ -4834,14 +4650,20 @@ public void OtherUtilities() #endregion - // cref: AreaUnit - Convert between hectares and square miles;ArcGIS.Core.Geometry.AreaUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.AreaUnit) - // cref: AreaUnit - Convert between hectares and square miles;ArcGIS.Core.Geometry.AreaUnit.Hectares + // cref: ArcGIS.Core.Geometry.AreaUnit.ConvertTo(System.Double,ArcGIS.Core.Geometry.AreaUnit) + // cref: ArcGIS.Core.Geometry.AreaUnit.SquareMiles + // cref: ArcGIS.Core.Geometry.AreaUnit.Hectares #region AreaUnit - Convert between hectares and square miles // convert 300 hectares to square miles double sqMiles = AreaUnit.Hectares.ConvertTo(300, AreaUnit.SquareMiles); #endregion - // cref: AreaUnit - How many Square meters in various units;ArcGIS.Core.Geometry.AreaUnit.SquareMetersPerUnit + // cref: ArcGIS.Core.Geometry.AreaUnit.SquareMetersPerUnit + // cref: ArcGIS.Core.Geometry.AreaUnit.Ares + // cref: ArcGIS.Core.Geometry.AreaUnit.Hectares + // cref: ArcGIS.Core.Geometry.AreaUnit.SquareKilometers + // cref: ArcGIS.Core.Geometry.AreaUnit.SquareMiles + // cref: ArcGIS.Core.Geometry.AreaUnit.SquareYards #region AreaUnit - How many Square meters in various units double sqMetersPerUnit = AreaUnit.Acres.SquareMetersPerUnit; @@ -4853,14 +4675,13 @@ public void OtherUtilities() #endregion - // cref: AreaUnit - Create an AreaUnit;ArcGIS.Core.Geometry.AreaUnit.CreateAreaUnit(System.Int32) - // cref: AreaUnit - Create an AreaUnit;ArcGIS.Core.Geometry.AreaUnit.CreateAreaUnit(System.String) - // cref: AreaUnit - Create an AreaUnit;ArcGIS.Core.Geometry.AreaUnit.CreateAreaUnit(System.String,System.Double) + // cref: ArcGIS.Core.Geometry.AreaUnit.CreateAreaUnit(System.Int32) + // cref: ArcGIS.Core.Geometry.AreaUnit.CreateAreaUnit(System.String,System.Double) + // cref: ArcGIS.Core.Geometry.AreaUnit.CreateAreaUnit(System.String) #region AreaUnit - Create an AreaUnit try { - var myFactoryCodeInit = AreaUnit.CreateAreaUnit(109439); // 109439 is the factory code for square miles var myWktUnit = AreaUnit.CreateAreaUnit("HECTARE_AREAUNIT[\"H\",10000.0]"); diff --git a/Examples/Geometry/ProSnippetsGeometryEngine.cs b/Examples/Geometry/ProSnippetsGeometryEngine.cs index fd6c79c..d004f6f 100644 --- a/Examples/Geometry/ProSnippetsGeometryEngine.cs +++ b/Examples/Geometry/ProSnippetsGeometryEngine.cs @@ -38,8 +38,8 @@ public void AccelerateGeomtries() Polygon polygon = null; IEnumerable testPolygons = null; - // cref: Accelerate Geometries;ArcGIS.Core.Geometry.GeometryEngine.AccelerateForRelationalOperations(ArcGIS.Core.Geometry.Geometry) - // cref: Accelerate Geometries;ArcGIS.Core.Geometry.IGeometryEngine.AccelerateForRelationalOperations(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.AccelerateForRelationalOperations(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.AccelerateForRelationalOperations(ArcGIS.Core.Geometry.Geometry) #region Accelerate Geometries // Use acceleration to speed up relational operations. Accelerate your source geometry only if you are going to test many other geometries against it. @@ -78,11 +78,11 @@ public void AccelerateGeomtries() public void Area() { - // cref: Determine area of a polygon;ArcGIS.Core.Geometry.GeometryEngine.Area(ArcGIS.Core.Geometry.Geometry) - // cref: Determine area of a polygon;ArcGIS.Core.Geometry.IGeometryEngine.Area(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Area(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Area(ArcGIS.Core.Geometry.Geometry) #region Determine area of a polygon - var g1 = PolygonBuilder.FromJson("{\"rings\": [ [ [0, 0], [10, 0], [10, 10], [0, 10] ] ] }"); + var g1 = PolygonBuilderEx.FromJson("{\"rings\": [ [ [0, 0], [10, 0], [10, 10], [0, 10] ] ] }"); double d = GeometryEngine.Instance.Area(g1); // d = -100.0 //negative due to wrong ring orientation d = GeometryEngine.Instance.Area(GeometryEngine.Instance.SimplifyAsFeature(g1)); @@ -93,11 +93,11 @@ public void Area() public void Boundary() { - // cref: Determine the boundary of a multi-part Polygon;ArcGIS.Core.Geometry.GeometryEngine.Boundary(ArcGIS.Core.Geometry.Geometry) - // cref: Determine the boundary of a multi-part Polygon;ArcGIS.Core.Geometry.IGeometryEngine.Boundary(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Boundary(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Boundary(ArcGIS.Core.Geometry.Geometry) #region Determine the boundary of a multi-part Polygon - // create a donut polygon. Must use the PolygonBuilder object + // create a donut polygon. Must use the PolygonBuilderEx object List outerPts = new List(); outerPts.Add(new Coordinate2D(10.0, 10.0)); @@ -113,18 +113,12 @@ public void Boundary() Polygon donut = null; - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - // add the outer points - using (PolygonBuilder pb = new PolygonBuilder(outerPts)) - { - // add the inner points (note they are defined anticlockwise) - pb.AddPart(innerPts); - // get the polygon - donut = pb.ToGeometry(); - } - }); + // add the outer points + PolygonBuilderEx pb = new PolygonBuilderEx(outerPts); + // add the inner points (note they are defined anticlockwise) + pb.AddPart(innerPts); + // get the polygon + donut = pb.ToGeometry(); // get the boundary Geometry g = GeometryEngine.Instance.Boundary(donut); @@ -135,30 +129,30 @@ public void Boundary() public void Buffer() { - // cref: Buffer a MapPoint;ArcGIS.Core.Geometry.GeometryEngine.Buffer(ArcGIS.Core.Geometry.Geometry,System.Double) - // cref: Buffer a MapPoint;ArcGIS.Core.Geometry.IGeometryEngine.Buffer(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Buffer(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Buffer(ArcGIS.Core.Geometry.Geometry,System.Double) #region Buffer a MapPoint // buffer a point - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); Geometry ptBuffer = GeometryEngine.Instance.Buffer(pt, 5.0); Polygon buffer = ptBuffer as Polygon; #endregion - // cref: Buffer a Circular Arc;ArcGIS.Core.Geometry.GeometryEngine.Buffer(ArcGIS.Core.Geometry.Geometry,System.Double) - // cref: Buffer a Circular Arc;ArcGIS.Core.Geometry.IGeometryEngine.Buffer(ArcGIS.Core.Geometry.Geometry,System.Double) - // cref: Buffer a Circular Arc;ArcGIS.Core.Geometry.PolylineBuilder.CreatePolyline(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Buffer(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Buffer(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SpatialReference) #region Buffer a Circular Arc // create the circular arc - MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1); - MapPoint toPt = MapPointBuilder.CreateMapPoint(1, 2); + MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1); + MapPoint toPt = MapPointBuilderEx.CreateMapPoint(1, 2); Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2); - EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt, toPt, interiorPt); + EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, interiorPt); // buffer the arc - Polyline polyline = PolylineBuilder.CreatePolyline(circularArc); + Polyline polyline = PolylineBuilderEx.CreatePolyline(circularArc); Geometry lineBuffer = GeometryEngine.Instance.Buffer(polyline, 10); #endregion @@ -170,18 +164,18 @@ public void Buffer() // creates a buffer around each MapPoint List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0)); - pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0)); - pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); Geometry ptsBuffer = GeometryEngine.Instance.Buffer(pts, 0.25); Polygon bufferResult = ptsBuffer as Polygon; // bufferResult will have 4 parts #endregion - // cref: Buffer many different Geometry Types;ArcGIS.Core.Geometry.GeometryEngine.Buffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double) - // cref: Buffer many different Geometry Types;ArcGIS.Core.Geometry.IGeometryEngine.Buffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Buffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Buffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double) #region Buffer many different Geometry Types List coords = new List() @@ -194,10 +188,10 @@ public void Buffer() List manyGeometries = new List { - MapPointBuilder.CreateMapPoint(coords[9]), - PolylineBuilder.CreatePolyline(new List(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84), - PolylineBuilder.CreatePolyline(new List(){coords[3], coords[4], coords[5]}), - PolygonBuilder.CreatePolygon(new List(){coords[6], coords[7], coords[8]}) + MapPointBuilderEx.CreateMapPoint(coords[9]), + PolylineBuilderEx.CreatePolyline(new List(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84), + PolylineBuilderEx.CreatePolyline(new List(){coords[3], coords[4], coords[5]}), + PolygonBuilderEx.CreatePolygon(new List(){coords[6], coords[7], coords[8]}) }; Geometry manyGeomBuffer = GeometryEngine.Instance.Buffer(manyGeometries, 0.25); @@ -208,8 +202,8 @@ public void Buffer() public void CalculateNonSimpleZs_Ms() { { - // cref: Interpolate Z values on a polyline;ArcGIS.Core.Geometry.GeometryEngine.CalculateNonSimpleZs(ArcGIS.Core.Geometry.Multipart,System.Double) - // cref: Interpolate Z values on a polyline;ArcGIS.Core.Geometry.IGeometryEngine.CalculateNonSimpleZs(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.CalculateNonSimpleZs(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.CalculateNonSimpleZs(ArcGIS.Core.Geometry.Multipart,System.Double) #region Interpolate Z values on a polyline List coords2 = new List() @@ -224,7 +218,7 @@ public void CalculateNonSimpleZs_Ms() SpatialReference sr = SpatialReferences.WebMercator; - Polyline polyline = PolylineBuilder.CreatePolyline(coords2, sr); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords2, sr); // polyline.HasZ = true // polyline.Points[1].HasZ = true @@ -242,20 +236,20 @@ public void CalculateNonSimpleZs_Ms() } { - // cref: Interpolate M values on a polygon;ArcGIS.Core.Geometry.GeometryEngine.CalculateNonSimpleMs(ArcGIS.Core.Geometry.Multipart,System.Double) - // cref: Interpolate M values on a polygon;ArcGIS.Core.Geometry.IGeometryEngine.CalculateNonSimpleMs(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.CalculateNonSimpleMs(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.CalculateNonSimpleMs(ArcGIS.Core.Geometry.Multipart,System.Double) #region Interpolate M values on a polygon List coords = new List() { - MapPointBuilder.CreateMapPoint(0, 0, 0, 0), - MapPointBuilder.CreateMapPoint(0, 1000), - MapPointBuilder.CreateMapPoint(1000, 1000, 10, 50) + MapPointBuilderEx.CreateMapPoint(0, 0, 0, 0), + MapPointBuilderEx.CreateMapPoint(0, 1000), + MapPointBuilderEx.CreateMapPoint(1000, 1000, 10, 50) }; SpatialReference sr = SpatialReferences.WebMercator; - Polygon polygon = PolygonBuilder.CreatePolygon(coords, sr); + Polygon polygon = PolygonBuilderEx.CreatePolygon(coords, sr); // polygon.HasM = true // polygon.Points[1].HasM = true @@ -272,12 +266,12 @@ public void CalculateNonSimpleZs_Ms() public void CenterAt() { - // cref: Center an envelope around X,Y;ArcGIS.Core.Geometry.Envelope.CenterAt(System.Double,System.Double) - // cref: Center an envelope around X,Y;ArcGIS.Core.Geometry.GeometryEngine.CenterAt(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double) - // cref: Center an envelope around X,Y;ArcGIS.Core.Geometry.IGeometryEngine.CenterAt(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.Envelope.CenterAt(System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.CenterAt(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.CenterAt(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double) #region Center an envelope around X,Y - Envelope env = EnvelopeBuilder.CreateEnvelope(1.0, 1.0, 5.0, 5.0); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(1.0, 1.0, 5.0, 5.0); Envelope centered = GeometryEngine.Instance.CenterAt(env, 2.0, 2.0); // centered.Center.X = 2.0 @@ -299,8 +293,8 @@ public void CenterAt() public void Centroid() { - // cref: Find the centroid of geometries;ArcGIS.Core.Geometry.GeometryEngine.Centroid(ArcGIS.Core.Geometry.Geometry) - // cref: Find the centroid of geometries;ArcGIS.Core.Geometry.IGeometryEngine.Centroid(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Centroid(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Centroid(ArcGIS.Core.Geometry.Geometry) #region Find the centroid of geometries // simple polygon @@ -310,7 +304,7 @@ public void Centroid() list2D.Add(new Coordinate2D(2, 2)); list2D.Add(new Coordinate2D(2, 0)); - Polygon polygon = PolygonBuilder.CreatePolygon(list2D, SpatialReferences.WGS84); + Polygon polygon = PolygonBuilderEx.CreatePolygon(list2D, SpatialReferences.WGS84); // verify it is simple bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon); @@ -320,8 +314,8 @@ public void Centroid() // centroid.Y = 1 // map Point - MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 2, 3, 4, SpatialReferences.WGS84); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(5, 2, double.NaN, 7); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4, SpatialReferences.WGS84); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(5, 2, double.NaN, 7); // pt1.HasZ = true // pt1.HasM = true @@ -332,7 +326,7 @@ public void Centroid() // multipoint List list = new List() { pt1, pt2 }; - Multipoint multipoint = MultipointBuilder.CreateMultipoint(list); + Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(list); // multipoint.HasZ = true // multipoint.HasM = true @@ -346,23 +340,23 @@ public void Centroid() public void Clip() { - // cref: Clip a Polyline;ArcGIS.Core.Geometry.GeometryEngine.Clip(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Envelope) - // cref: Clip a Polyline;ArcGIS.Core.Geometry.IGeometryEngine.Clip(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Clip(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Clip(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Envelope) #region Clip a Polyline // clip a polyline by an envelope - Envelope env = EnvelopeBuilder.CreateEnvelope(2.0, 2.0, 4.0, 4.0); - LineSegment line = LineBuilder.CreateLineSegment(new Coordinate2D(0, 3), new Coordinate2D(5.0, 3.0)); - Polyline polyline = PolylineBuilder.CreatePolyline(line); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(2.0, 2.0, 4.0, 4.0); + LineSegment line = LineBuilderEx.CreateLineSegment(new Coordinate2D(0, 3), new Coordinate2D(5.0, 3.0)); + Polyline polyline = PolylineBuilderEx.CreatePolyline(line); Geometry clipGeom = GeometryEngine.Instance.Clip(polyline, env); #endregion - // cref: Clip a Polyline by a Polygon;ArcGIS.Core.Geometry.GeometryEngine.Clip(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Envelope) - // cref: Clip a Polyline by a Polygon;ArcGIS.Core.Geometry.IGeometryEngine.Clip(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Envelope) - // cref: Clip a Polyline by a Polygon;ArcGIS.Core.Geometry.PolygonBuilder.CreatePolygon(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate2D},ArcGIS.Core.Geometry.SpatialReference) - // cref: Clip a Polyline by a Polygon;ArcGIS.Core.Geometry.Multipart.Extent + // cref: ArcGIS.Core.Geometry.GeometryEngine.Clip(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Clip(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Coordinate2D},ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.Multipart.Extent #region Clip a Polyline by a Polygon // clip a polyline by a polygon @@ -373,10 +367,10 @@ public void Clip() list.Add(new Coordinate2D(4.0, 4.0)); list.Add(new Coordinate2D(4.0, 1.0)); - Polygon polygon = PolygonBuilder.CreatePolygon(list, SpatialReferences.WGS84); + Polygon polygon = PolygonBuilderEx.CreatePolygon(list, SpatialReferences.WGS84); - LineSegment crossingLine = LineBuilder.CreateLineSegment(MapPointBuilder.CreateMapPoint(0, 3), MapPointBuilder.CreateMapPoint(5.0, 3.0)); - Polyline p = PolylineBuilder.CreatePolyline(crossingLine); + LineSegment crossingLine = LineBuilderEx.CreateLineSegment(MapPointBuilderEx.CreateMapPoint(0, 3), MapPointBuilderEx.CreateMapPoint(5.0, 3.0)); + Polyline p = PolylineBuilderEx.CreatePolyline(crossingLine); Geometry geometry = GeometryEngine.Instance.Clip(p, polygon.Extent); #endregion } @@ -390,18 +384,22 @@ public void Clip() public void ConstructGeodeticLineFromDistance() { + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructGeodeticLineFromDistance(ArcGIS.Core.Geometry.GeodeticCurveType,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.CurveDensifyMethod,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructGeodeticLineFromDistance(ArcGIS.Core.Geometry.GeodeticCurveType,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.CurveDensifyMethod,System.Double) #region Construct a geodetic line with specified distance and azimuth var sr = SpatialReferenceBuilder.CreateSpatialReference(4326); var mapPoint = MapPointBuilderEx.CreateMapPoint(15, 60, sr); // calculate - var polylineGeodetic = GeometryEngine.Instance.ConstructGeodeticLineFromDistance(GeodeticCurveType.Loxodrome, mapPoint, 5000000, 45, null, esriCurveDensifyMethod.ByLength, 300000); + var polylineGeodetic = GeometryEngine.Instance.ConstructGeodeticLineFromDistance(GeodeticCurveType.Loxodrome, mapPoint, 5000000, 45, null, CurveDensifyMethod.ByLength, 300000); #endregion } public void ConstructGeodeticLineFromPoints() { + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructGeodeticLineFromPoints(ArcGIS.Core.Geometry.GeodeticCurveType,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.CurveDensifyMethod,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructGeodeticLineFromPoints(ArcGIS.Core.Geometry.GeodeticCurveType,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.CurveDensifyMethod,System.Double) #region Construct a geodetic line connecting points var sr = SpatialReferenceBuilder.CreateSpatialReference(4326); @@ -409,21 +407,21 @@ public void ConstructGeodeticLineFromPoints() var pt2 = MapPointBuilderEx.CreateMapPoint(60, 0, sr); // densify by length - var gl = GeometryEngine.Instance.ConstructGeodeticLineFromPoints(GeodeticCurveType.Geodesic, pt1, pt2, null, esriCurveDensifyMethod.ByLength, -3.356); + var gl = GeometryEngine.Instance.ConstructGeodeticLineFromPoints(GeodeticCurveType.Geodesic, pt1, pt2, null, CurveDensifyMethod.ByLength, -3.356); // densify by deviation - gl = GeometryEngine.Instance.ConstructGeodeticLineFromPoints(GeodeticCurveType.Geodesic, pt1, pt2, null, esriCurveDensifyMethod.ByDeviation, -0.0026); + gl = GeometryEngine.Instance.ConstructGeodeticLineFromPoints(GeodeticCurveType.Geodesic, pt1, pt2, null, CurveDensifyMethod.ByDeviation, -0.0026); #endregion } public void ConstructPointFromAngleDistance() { - // cref: Construct a Point at a distance and angle from an existing Point;ArcGIS.Core.Geometry.GeometryEngine.ConstructPointFromAngleDistance(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) - // cref: Construct a Point at a distance and angle from an existing Point;ArcGIS.Core.Geometry.IGeometryEngine.ConstructPointFromAngleDistance(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructPointFromAngleDistance(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructPointFromAngleDistance(ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,ArcGIS.Core.Geometry.SpatialReference) #region Construct a Point at a distance and angle from an existing Point - MapPoint inPoint = MapPointBuilder.CreateMapPoint(3, 4); + MapPoint inPoint = MapPointBuilderEx.CreateMapPoint(3, 4); double angle = 0; double distance = 10; @@ -432,7 +430,7 @@ public void ConstructPointFromAngleDistance() // outPoint.Y = 4 SpatialReference sr = SpatialReferences.WGS84; - inPoint = MapPointBuilder.CreateMapPoint(0, 0, sr); + inPoint = MapPointBuilderEx.CreateMapPoint(0, 0, sr); angle = Math.PI; distance = 1; @@ -445,8 +443,8 @@ public void ConstructPointFromAngleDistance() public void ConstructPolygonsFromPolylines() { - // cref: Construct a Polygon from a set of Polylines;ArcGIS.Core.Geometry.GeometryEngine.ConstructPolygonsFromPolylines(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Polyline}) - // cref: Construct a Polygon from a set of Polylines;ArcGIS.Core.Geometry.IGeometryEngine.ConstructPolygonsFromPolylines(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Polyline}) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConstructPolygonsFromPolylines(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Polyline}) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConstructPolygonsFromPolylines(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Polyline}) #region Construct a Polygon from a set of Polylines List firstLinePts = new List(); @@ -467,10 +465,10 @@ public void ConstructPolygonsFromPolylines() // build the polylines List polylines = new List(); - polylines.Add(PolylineBuilder.CreatePolyline(firstLinePts)); - polylines.Add(PolylineBuilder.CreatePolyline(secondLinePts)); - polylines.Add(PolylineBuilder.CreatePolyline(thirdLinePts)); - polylines.Add(PolylineBuilder.CreatePolyline(fourthLinePts)); + polylines.Add(PolylineBuilderEx.CreatePolyline(firstLinePts)); + polylines.Add(PolylineBuilderEx.CreatePolyline(secondLinePts)); + polylines.Add(PolylineBuilderEx.CreatePolyline(thirdLinePts)); + polylines.Add(PolylineBuilderEx.CreatePolyline(fourthLinePts)); // construct polygons from the polylines var polygons = GeometryEngine.Instance.ConstructPolygonsFromPolylines(polylines); @@ -483,63 +481,63 @@ public void ConstructPolygonsFromPolylines() public void Contains() { - // cref: Polygon contains MapPoints, Polylines, Polygons;ArcGIS.Core.Geometry.GeometryEngine.Contains(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Polygon contains MapPoints, Polylines, Polygons;ArcGIS.Core.Geometry.IGeometryEngine.Contains(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Polygon contains MapPoints, Polylines, Polygons;ArcGIS.Core.Geometry.ReadOnlyPointCollection.Item(System.Int32) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Contains(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Contains(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.ReadOnlyPointCollection.Item(System.Int32) #region Polygon contains MapPoints, Polylines, Polygons // build a polygon List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0)); - pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0)); - pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); - Polygon poly = PolygonBuilder.CreatePolygon(pts); + Polygon poly = PolygonBuilderEx.CreatePolygon(pts); // test if an inner point is contained - MapPoint innerPt = MapPointBuilder.CreateMapPoint(1.5, 1.5); + MapPoint innerPt = MapPointBuilderEx.CreateMapPoint(1.5, 1.5); bool contains = GeometryEngine.Instance.Contains(poly, innerPt); // contains = true // test a point on a boundary contains = GeometryEngine.Instance.Contains(poly, poly.Points[0]); // contains = false // test an interior line - MapPoint innerPt2 = MapPointBuilder.CreateMapPoint(1.25, 1.75); + MapPoint innerPt2 = MapPointBuilderEx.CreateMapPoint(1.25, 1.75); List innerLinePts = new List(); innerLinePts.Add(innerPt); innerLinePts.Add(innerPt2); // test an inner polyline - Polyline polyline = PolylineBuilder.CreatePolyline(innerLinePts); + Polyline polyline = PolylineBuilderEx.CreatePolyline(innerLinePts); contains = GeometryEngine.Instance.Contains(poly, polyline); // contains = true // test a line that crosses the boundary - MapPoint outerPt = MapPointBuilder.CreateMapPoint(3, 1.5); + MapPoint outerPt = MapPointBuilderEx.CreateMapPoint(3, 1.5); List crossingLinePts = new List(); crossingLinePts.Add(innerPt); crossingLinePts.Add(outerPt); - polyline = PolylineBuilder.CreatePolyline(crossingLinePts); + polyline = PolylineBuilderEx.CreatePolyline(crossingLinePts); contains = GeometryEngine.Instance.Contains(poly, polyline); // contains = false // test a polygon in polygon - Envelope env = EnvelopeBuilder.CreateEnvelope(innerPt, innerPt2); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(innerPt, innerPt2); contains = GeometryEngine.Instance.Contains(poly, env); // contains = true #endregion } public void ConvexHull() { - // cref: Determine convex hull;ArcGIS.Core.Geometry.GeometryEngine.ConvexHull(ArcGIS.Core.Geometry.Geometry) - // cref: Determine convex hull;ArcGIS.Core.Geometry.IGeometryEngine.ConvexHull(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ConvexHull(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ConvexHull(ArcGIS.Core.Geometry.Geometry) #region Determine convex hull // // convex hull around a point - returns a point // - MapPoint pt = MapPointBuilder.CreateMapPoint(2.0, 2.0); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0); Geometry hull = GeometryEngine.Instance.ConvexHull(pt); MapPoint hullPt = hull as MapPoint; // nullPt.X = 2 @@ -547,17 +545,17 @@ public void ConvexHull() List list = new List(); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0)); - list.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0)); - list.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); // // convex hull around a multipoint - returns a polygon // // build a multiPoint - Multipoint multiPoint = MultipointBuilder.CreateMultipoint(list); + Multipoint multiPoint = MultipointBuilderEx.CreateMultipoint(list); hull = GeometryEngine.Instance.ConvexHull(multiPoint); Polygon hullPoly = hull as Polygon; @@ -569,19 +567,19 @@ public void ConvexHull() // List polylineList = new List(); - polylineList.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - polylineList.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0)); + polylineList.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + polylineList.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0)); // 2 point straight line - Polyline polyline = PolylineBuilder.CreatePolyline(polylineList); + Polyline polyline = PolylineBuilderEx.CreatePolyline(polylineList); hull = GeometryEngine.Instance.ConvexHull(polyline); Polyline hullPolyline = hull as Polyline; // hullPolyline.Length = Math.Sqrt(2) // hullPolyline.PointCount = 2 // 3 point angular line - polylineList.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); - polyline = PolylineBuilder.CreatePolyline(polylineList); + polylineList.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); + polyline = PolylineBuilderEx.CreatePolyline(polylineList); hull = GeometryEngine.Instance.ConvexHull(polyline); hullPoly = hull as Polygon; // hullPoly.Length = 2 + Math.Sqrt(2) @@ -593,7 +591,7 @@ public void ConvexHull() // // simple polygon - Polygon poly = PolygonBuilder.CreatePolygon(list); + Polygon poly = PolygonBuilderEx.CreatePolygon(list); hull = GeometryEngine.Instance.ConvexHull(poly); hullPoly = hull as Polygon; @@ -603,15 +601,15 @@ public void ConvexHull() // polygon with concave angles List funkyList = new List(); - funkyList.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - funkyList.Add(MapPointBuilder.CreateMapPoint(1.5, 1.5)); - funkyList.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0)); - funkyList.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0)); - funkyList.Add(MapPointBuilder.CreateMapPoint(1.5, 1.5)); - funkyList.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); - funkyList.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - - Polygon funkyPoly = PolygonBuilder.CreatePolygon(funkyList); + funkyList.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + funkyList.Add(MapPointBuilderEx.CreateMapPoint(1.5, 1.5)); + funkyList.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0)); + funkyList.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0)); + funkyList.Add(MapPointBuilderEx.CreateMapPoint(1.5, 1.5)); + funkyList.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); + funkyList.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + + Polygon funkyPoly = PolygonBuilderEx.CreatePolygon(funkyList); hull = GeometryEngine.Instance.ConvexHull(funkyPoly); hullPoly = hull as Polygon; // hullPoly.Length = 4.0 @@ -627,16 +625,16 @@ public void ConvexHull() public void Crosses() { - // cref: Determine if two geometries cross;ArcGIS.Core.Geometry.GeometryEngine.Crosses(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Determine if two geometries cross;ArcGIS.Core.Geometry.IGeometryEngine.Crosses(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Crosses(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Crosses(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Determine if two geometries cross // // pt on pt // - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.0); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2.0, 2.0); bool crosses = GeometryEngine.Instance.Crosses(pt, pt2); // crosses = false crosses = GeometryEngine.Instance.Crosses(pt, pt); // crosses = false @@ -646,11 +644,11 @@ public void Crosses() // List list = new List(); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - list.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0)); - list.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0)); - Polyline line1 = PolylineBuilder.CreatePolyline(list); + Polyline line1 = PolylineBuilderEx.CreatePolyline(list); crosses = GeometryEngine.Instance.Crosses(line1, pt2); // crosses = false crosses = GeometryEngine.Instance.Crosses(pt2, line1); // crosses = false // end pt of line @@ -660,12 +658,12 @@ public void Crosses() // pt and polygon // List polyPts = new List(); - polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 2.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 6.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 6.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 2.0)); - Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts); + Polygon poly1 = PolygonBuilderEx.CreatePolygon(polyPts); crosses = GeometryEngine.Instance.Crosses(poly1, pt); // crosses = false crosses = GeometryEngine.Instance.Crosses(pt, poly1); // crosses = false @@ -673,11 +671,11 @@ public void Crosses() // line and line // List list2 = new List(); - list2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0)); - list2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0)); - list2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(5.0, 3.0)); - Polyline line2 = PolylineBuilder.CreatePolyline(list2); + Polyline line2 = PolylineBuilderEx.CreatePolyline(list2); crosses = GeometryEngine.Instance.Crosses(line1, line2); // crosses = true // @@ -688,8 +686,8 @@ public void Crosses() // // polygon and polygon // - Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4)); - Polygon poly2 = PolygonBuilder.CreatePolygon(env); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4)); + Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); crosses = GeometryEngine.Instance.Crosses(poly1, poly2); // crosses = false #endregion @@ -697,25 +695,25 @@ public void Crosses() public void Cut() { - // cref: Cut a geometry with a polyline;ArcGIS.Core.Geometry.GeometryEngine.Cut(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Polyline) - // cref: Cut a geometry with a polyline;ArcGIS.Core.Geometry.IGeometryEngine.Cut(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Polyline) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Cut(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Polyline) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Cut(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Polyline) #region Cut a geometry with a polyline SpatialReference sr = SpatialReferences.WGS84; List list = new List(); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, sr)); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 4.0, sr)); - list.Add(MapPointBuilder.CreateMapPoint(4.0, 4.0, sr)); - list.Add(MapPointBuilder.CreateMapPoint(4.0, 1.0, sr)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, sr)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 4.0, sr)); + list.Add(MapPointBuilderEx.CreateMapPoint(4.0, 4.0, sr)); + list.Add(MapPointBuilderEx.CreateMapPoint(4.0, 1.0, sr)); List cutGeometries; - LineSegment line = LineBuilder.CreateLineSegment(MapPointBuilder.CreateMapPoint(0, 0, sr), MapPointBuilder.CreateMapPoint(3, 6, sr)); - Polyline cutter = PolylineBuilder.CreatePolyline(line); + LineSegment line = LineBuilderEx.CreateLineSegment(MapPointBuilderEx.CreateMapPoint(0, 0, sr), MapPointBuilderEx.CreateMapPoint(3, 6, sr)); + Polyline cutter = PolylineBuilderEx.CreatePolyline(line); // polyline - Polyline polyline = PolylineBuilder.CreatePolyline(list); + Polyline polyline = PolylineBuilderEx.CreatePolyline(list); bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline); cutGeometries = GeometryEngine.Instance.Cut(polyline, cutter) as List; @@ -741,7 +739,7 @@ public void Cut() // segments1[1].EndCoordinate = 4, 1 // polygon - Polygon polygon = PolygonBuilder.CreatePolygon(list); + Polygon polygon = PolygonBuilderEx.CreatePolygon(list); isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon); cutGeometries = GeometryEngine.Instance.Cut(polygon, cutter) as List; #endregion @@ -749,52 +747,50 @@ public void Cut() public void DensifyByLength() { - // cref: Densify By Length;ArcGIS.Core.Geometry.GeometryEngine.DensifyByLength(ArcGIS.Core.Geometry.Geometry,System.Double) - // cref: Densify By Length;ArcGIS.Core.Geometry.IGeometryEngine.DensifyByLength(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.DensifyByLength(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.DensifyByLength(ArcGIS.Core.Geometry.Geometry,System.Double) #region Densify by Length // densify a line segment - MapPoint startPt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint endPt = MapPointBuilder.CreateMapPoint(1, 21); - LineSegment line = LineBuilder.CreateLineSegment(startPt, endPt); - Polyline polyline = PolylineBuilder.CreatePolyline(line); + MapPoint startPt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint endPt = MapPointBuilderEx.CreateMapPoint(1, 21); + LineSegment line = LineBuilderEx.CreateLineSegment(startPt, endPt); + Polyline polyline = PolylineBuilderEx.CreatePolyline(line); Geometry geom = GeometryEngine.Instance.DensifyByLength(polyline, 2); Polyline result = geom as Polyline; // densify a circular arc - MapPoint fromPt = MapPointBuilder.CreateMapPoint(2, 1); - MapPoint toPt = MapPointBuilder.CreateMapPoint(1, 2); + MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1); + MapPoint toPt = MapPointBuilderEx.CreateMapPoint(1, 2); Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2); - using (EllipticArcBuilder cab = new EllipticArcBuilder(fromPt, toPt, interiorPt)) - { - EllipticArcSegment circularArc = cab.ToSegment(); - polyline = PolylineBuilder.CreatePolyline(circularArc); - geom = GeometryEngine.Instance.DensifyByLength(polyline, 2); - result = geom as Polyline; - } + EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromPt, toPt, interiorPt); + EllipticArcSegment circularArc = cab.ToSegment(); + polyline = PolylineBuilderEx.CreatePolyline(circularArc); + geom = GeometryEngine.Instance.DensifyByLength(polyline, 2); + result = geom as Polyline; #endregion } public void Difference() { - // cref: Difference between two Polygons;ArcGIS.Core.Geometry.GeometryEngine.Difference(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Difference between two Polygons;ArcGIS.Core.Geometry.IGeometryEngine.Difference(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Difference(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Difference(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Difference between two Polygons List polyPts = new List(); - polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 2.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 6.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 6.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 2.0)); - Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts); + Polygon poly1 = PolygonBuilderEx.CreatePolygon(polyPts); - Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4)); - Polygon poly2 = PolygonBuilder.CreatePolygon(env); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4)); + Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); Geometry result = GeometryEngine.Instance.Difference(poly1, poly2); Polygon polyResult = result as Polygon; @@ -808,40 +804,38 @@ public void Difference() public void Disjoint_Disjoint3D() { - // cref: Determine if two Geometries are disjoint;ArcGIS.Core.Geometry.GeometryEngine.Disjoint(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Determine if two Geometries are disjoint;ArcGIS.Core.Geometry.GeometryEngine.Disjoint3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Determine if two Geometries are disjoint;ArcGIS.Core.Geometry.IGeometryEngine.Disjoint(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Determine if two Geometries are disjoint;ArcGIS.Core.Geometry.IGeometryEngine.Disjoint3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Disjoint(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Disjoint(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Disjoint3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Disjoint3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Determine if two Geometries are disjoint // // pt on pt // - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.5); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2.0, 2.5); bool disjoint = GeometryEngine.Instance.Disjoint(pt, pt2); // result is true - using (MultipointBuilder mpb = new MultipointBuilder()) - { - mpb.Add(pt); - mpb.Add(pt2); - Multipoint multiPoint = mpb.ToGeometry(); + MultipointBuilderEx mpb = new MultipointBuilderEx(); + mpb.AddPoint(pt); + mpb.AddPoint(pt2); + Multipoint multiPoint = mpb.ToGeometry(); - disjoint = GeometryEngine.Instance.Disjoint(multiPoint, pt); // result is false - } + disjoint = GeometryEngine.Instance.Disjoint(multiPoint, pt); // result is false // // pt and line // List list = new List(); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - list.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0)); - list.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0)); - Polyline line1 = PolylineBuilder.CreatePolyline(list); + Polyline line1 = PolylineBuilderEx.CreatePolyline(list); disjoint = GeometryEngine.Instance.Disjoint(line1, pt2); // result is true disjoint = GeometryEngine.Instance.Disjoint(pt2, line1); // result is true @@ -853,12 +847,12 @@ public void Disjoint_Disjoint3D() // pt and polygon // List polyPts = new List(); - polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 2.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 6.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 6.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 2.0)); - Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts); + Polygon poly1 = PolygonBuilderEx.CreatePolygon(polyPts); disjoint = GeometryEngine.Instance.Disjoint(poly1, pt); // result is true disjoint = GeometryEngine.Instance.Disjoint(pt, poly1); // result is true @@ -867,11 +861,11 @@ public void Disjoint_Disjoint3D() // List list2 = new List(); - list2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0)); - list2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0)); - list2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(5.0, 3.0)); - Polyline line2 = PolylineBuilder.CreatePolyline(list2); + Polyline line2 = PolylineBuilderEx.CreatePolyline(list2); disjoint = GeometryEngine.Instance.Disjoint(line1, line2); // result is false // @@ -883,8 +877,8 @@ public void Disjoint_Disjoint3D() // // polygon and polygon // - Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4)); - Polygon poly2 = PolygonBuilder.CreatePolygon(env); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4)); + Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); disjoint = GeometryEngine.Instance.Disjoint(poly1, poly2); // result is false @@ -893,32 +887,30 @@ public void Disjoint_Disjoint3D() SpatialReference sr = SpatialReferences.WGS84; - MapPoint pt3D_1 = MapPointBuilder.CreateMapPoint(1, 1, 1, sr); - MapPoint pt3D_2 = MapPointBuilder.CreateMapPoint(2, 2, 2, sr); - MapPoint pt3D_3 = MapPointBuilder.CreateMapPoint(1, 1, 2, sr); + MapPoint pt3D_1 = MapPointBuilderEx.CreateMapPoint(1, 1, 1, sr); + MapPoint pt3D_2 = MapPointBuilderEx.CreateMapPoint(2, 2, 2, sr); + MapPoint pt3D_3 = MapPointBuilderEx.CreateMapPoint(1, 1, 2, sr); - using (MultipointBuilder mpb = new MultipointBuilder()) - { - mpb.Add(pt3D_1); - mpb.Add(pt3D_2); - mpb.HasZ = true; + MultipointBuilderEx mpbEx = new MultipointBuilderEx(); + mpbEx.AddPoint(pt3D_1); + mpbEx.AddPoint(pt3D_2); + mpbEx.HasZ = true; - Multipoint multiPoint = mpb.ToGeometry(); - disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_2); // disjoint = false - disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_3); // disjoint = true - } + multiPoint = mpbEx.ToGeometry(); + disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_2); // disjoint = false + disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_3); // disjoint = true #endregion } public void Distance() { - // cref: Determine distance between two Geometries;ArcGIS.Core.Geometry.GeometryEngine.Distance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Determine distance between two Geometries;ArcGIS.Core.Geometry.IGeometryEngine.Distance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Distance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Distance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Determine distance between two Geometries - MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.0); - MapPoint pt3 = MapPointBuilder.CreateMapPoint(4.0, 2.0); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2.0, 2.0); + MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(4.0, 2.0); // // pt and pt @@ -931,30 +923,30 @@ public void Distance() List multiPts = new List(); multiPts.Add(pt2); multiPts.Add(pt3); - Multipoint multiPoint = MultipointBuilder.CreateMultipoint(multiPts); + Multipoint multiPoint = MultipointBuilderEx.CreateMultipoint(multiPts); d = GeometryEngine.Instance.Distance(pt1, multiPoint); // d = Math.Sqrt(2) // // pt and envelope // - Envelope env = EnvelopeBuilder.CreateEnvelope(pt1, pt2); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(pt1, pt2); d = GeometryEngine.Instance.Distance(pt1, env); // d = 0 // // pt and polyline // List polylinePts = new List(); - polylinePts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); + polylinePts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); polylinePts.Add(pt2); - Polyline polyline = PolylineBuilder.CreatePolyline(polylinePts); + Polyline polyline = PolylineBuilderEx.CreatePolyline(polylinePts); d = GeometryEngine.Instance.Distance(pt1, polyline); // d = 1.0 // // pt and polygon // - Envelope env2 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(3.0, 3.0), MapPointBuilder.CreateMapPoint(5.0, 5.0)); - Polygon poly = PolygonBuilder.CreatePolygon(env2); + Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(3.0, 3.0), MapPointBuilderEx.CreateMapPoint(5.0, 5.0)); + Polygon poly = PolygonBuilderEx.CreatePolygon(env2); d = GeometryEngine.Instance.Distance(pt1, poly); // d = Math.Sqrt(8) // @@ -966,9 +958,9 @@ public void Distance() // polyline and polyline // List polylineList = new List(); - polylineList.Add(MapPointBuilder.CreateMapPoint(4, 3)); - polylineList.Add(MapPointBuilder.CreateMapPoint(4, 4)); - Polyline polyline2 = PolylineBuilder.CreatePolyline(polylineList); + polylineList.Add(MapPointBuilderEx.CreateMapPoint(4, 3)); + polylineList.Add(MapPointBuilderEx.CreateMapPoint(4, 4)); + Polyline polyline2 = PolylineBuilderEx.CreatePolyline(polylineList); d = GeometryEngine.Instance.Distance(polyline, polyline2); // d = Math.Sqrt(5) @@ -976,7 +968,7 @@ public void Distance() // // polygon and polygon // - Polygon poly2 = PolygonBuilder.CreatePolygon(env); + Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); d = GeometryEngine.Instance.Distance(poly, poly2); // d = Math.Sqrt(2) #endregion @@ -984,14 +976,14 @@ public void Distance() public void Distance3D() { - // cref: Determine 3D distance between two Geometries;ArcGIS.Core.Geometry.GeometryEngine.Distance3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Determine 3D distance between two Geometries;ArcGIS.Core.Geometry.IGeometryEngine.Distance3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Distance3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Distance3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Determine 3D distance between two Geometries // between points - MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 1, 1); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(2, 2, 2); - MapPoint pt3 = MapPointBuilder.CreateMapPoint(10, 2, 1); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1, 1, 1); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2, 2, 2); + MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(10, 2, 1); // pt1 to pt2 double d = GeometryEngine.Instance.Distance3D(pt1, pt2); // d = Math.Sqrt(3) @@ -1005,18 +997,18 @@ public void Distance3D() // intersecting lines List list = new List(); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 1.0)); - list.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0, 1.0)); - list.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0, 1.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0, 1.0)); - Polyline line1 = PolylineBuilder.CreatePolyline(list); + Polyline line1 = PolylineBuilderEx.CreatePolyline(list); List list2 = new List(); - list2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 1.0)); - list2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 1.0)); - list2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0, 1.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0, 1.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0, 1.0)); + list2.Add(MapPointBuilderEx.CreateMapPoint(5.0, 3.0, 1.0)); - Polyline line2 = PolylineBuilder.CreatePolyline(list2); + Polyline line2 = PolylineBuilderEx.CreatePolyline(list2); bool intersects = GeometryEngine.Instance.Intersects(line1, line2); // intersects = true d = GeometryEngine.Instance.Distance3D(line1, line2); // d = 0 (distance is 0 when geomtries intersect) @@ -1026,13 +1018,13 @@ public void Distance3D() public void Expand() { - // cref: Expand envelopes;ArcGIS.Core.Geometry.GeometryEngine.Expand(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double,System.Boolean) - // cref: Expand envelopes;ArcGIS.Core.Geometry.GeometryEngine.Expand(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double,System.Double,System.Boolean) - // cref: Expand envelopes;ArcGIS.Core.Geometry.IGeometryEngine.Expand(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double,System.Boolean) - // cref: Expand envelopes;ArcGIS.Core.Geometry.IGeometryEngine.Expand(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double,System.Double,System.Boolean) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Expand(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double,System.Boolean) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Expand(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double,System.Double,System.Boolean) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Expand(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double,System.Boolean) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Expand(ArcGIS.Core.Geometry.Envelope,System.Double,System.Double,System.Double,System.Boolean) #region Expand envelopes - Envelope env = EnvelopeBuilder.CreateEnvelope(100.0, 100.0, 500.0, 500.0); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(100.0, 100.0, 500.0, 500.0); // env.HasZ = false Envelope result = GeometryEngine.Instance.Expand(env, 0.5, 0.5, true); @@ -1060,10 +1052,10 @@ public void Expand() } // expand a 3d envelope - MapPoint pt1 = MapPointBuilder.CreateMapPoint(100, 100, 100); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(200, 200, 200); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(100, 100, 100); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(200, 200, 200); - env = EnvelopeBuilder.CreateEnvelope(pt1, pt2); + env = EnvelopeBuilderEx.CreateEnvelope(pt1, pt2); // env.HasZ = true result = GeometryEngine.Instance.Expand(env, 0.5, 0.5, 0.5, true); @@ -1081,23 +1073,23 @@ public void Expand() public void Extend() { - // cref: Extend a polyline;ArcGIS.Core.Geometry.GeometryEngine.Extend(ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.ExtendFlags) - // cref: Extend a polyline;ArcGIS.Core.Geometry.IGeometryEngine.Extend(ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.ExtendFlags) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Extend(ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.ExtendFlags) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Extend(ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.ExtendFlags) #region Extend a polyline // build a polyline - var polyline = PolylineBuilder.CreatePolyline(new[] + var polyline = PolylineBuilderEx.CreatePolyline(new[] { - MapPointBuilder.CreateMapPoint(1, 1, 10, 20), - MapPointBuilder.CreateMapPoint(0, 0, 10, 20), - MapPointBuilder.CreateMapPoint(1, -1, 10, 20) + MapPointBuilderEx.CreateMapPoint(1, 1, 10, 20), + MapPointBuilderEx.CreateMapPoint(0, 0, 10, 20), + MapPointBuilderEx.CreateMapPoint(1, -1, 10, 20) }); // build the extender line - var extender = PolylineBuilder.CreatePolyline(new[] + var extender = PolylineBuilderEx.CreatePolyline(new[] { - MapPointBuilder.CreateMapPoint(2, 2), - MapPointBuilder.CreateMapPoint(2, -2), + MapPointBuilderEx.CreateMapPoint(2, 2), + MapPointBuilderEx.CreateMapPoint(2, -2), }); // extend @@ -1128,16 +1120,16 @@ public void Extend() // extend with no intersection - polyline = PolylineBuilder.CreatePolyline(new[] + polyline = PolylineBuilderEx.CreatePolyline(new[] { - MapPointBuilder.CreateMapPoint(1, 1), - MapPointBuilder.CreateMapPoint(3, 1) + MapPointBuilderEx.CreateMapPoint(1, 1), + MapPointBuilderEx.CreateMapPoint(3, 1) }); - extender = PolylineBuilder.CreatePolyline(new[] + extender = PolylineBuilderEx.CreatePolyline(new[] { - MapPointBuilder.CreateMapPoint(1, 4), - MapPointBuilder.CreateMapPoint(3, 4) + MapPointBuilderEx.CreateMapPoint(1, 4), + MapPointBuilderEx.CreateMapPoint(3, 4) }); result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.Default); @@ -1150,10 +1142,10 @@ public void Generalize() { Polyline polylineWithZ = null; - // cref: Generalize;ArcGIS.Core.Geometry.GeometryEngine.Generalize(ArcGIS.Core.Geometry.Geometry,System.Double,System.Boolean,System.Boolean) - // cref: Generalize;ArcGIS.Core.Geometry.GeometryEngine.Generalize3D(ArcGIS.Core.Geometry.Geometry,System.Double) - // cref: Generalize;ArcGIS.Core.Geometry.IGeometryEngine.Generalize(ArcGIS.Core.Geometry.Geometry,System.Double,System.Boolean,System.Boolean) - // cref: Generalize;ArcGIS.Core.Geometry.IGeometryEngine.Generalize3D(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Generalize(ArcGIS.Core.Geometry.Geometry,System.Double,System.Boolean,System.Boolean) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Generalize3D(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Generalize(ArcGIS.Core.Geometry.Geometry,System.Double,System.Boolean,System.Boolean) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Generalize3D(ArcGIS.Core.Geometry.Geometry,System.Double) #region Generalize Polyline generalizedPolyline = GeometryEngine.Instance.Generalize(polylineWithZ, 200) as Polyline; @@ -1170,15 +1162,15 @@ public void Generalize() public void GeodesicArea() { - // cref: Calculate the Geodesic Area of a polygon;ArcGIS.Core.Geometry.GeometryEngine.GeodesicArea(ArcGIS.Core.Geometry.Geometry) - // cref: Calculate the Geodesic Area of a polygon;ArcGIS.Core.Geometry.IGeometryEngine.GeodesicArea(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicArea(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.AreaUnit) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicArea(ArcGIS.Core.Geometry.Geometry) #region Calculate the Geodesic Area of a polygon - var polygon = PolygonBuilder.CreatePolygon(new[] + var polygon = PolygonBuilderEx.CreatePolygon(new[] { - MapPointBuilder.CreateMapPoint(-10018754.1713946, 10018754.1713946), - MapPointBuilder.CreateMapPoint(10018754.1713946, 10018754.1713946), - MapPointBuilder.CreateMapPoint(10018754.1713946, -10018754.1713946), - MapPointBuilder.CreateMapPoint(-10018754.1713946, -10018754.1713946) + MapPointBuilderEx.CreateMapPoint(-10018754.1713946, 10018754.1713946), + MapPointBuilderEx.CreateMapPoint(10018754.1713946, 10018754.1713946), + MapPointBuilderEx.CreateMapPoint(10018754.1713946, -10018754.1713946), + MapPointBuilderEx.CreateMapPoint(-10018754.1713946, -10018754.1713946) }, SpatialReferences.WebMercator); var area = GeometryEngine.Instance.GeodesicArea(polygon); @@ -1192,14 +1184,18 @@ public void GeodesicArea() public void GeodesicBuffer() { - // cref: Create a buffer polygon at the specified geodesic distance;ArcGIS.Core.Geometry.GeometryEngine.GeodesicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double) - // cref: Create a buffer polygon at the specified geodesic distance;ArcGIS.Core.Geometry.GeometryEngine.GeodesicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double) - // cref: Create a buffer polygon at the specified geodesic distance;ArcGIS.Core.Geometry.IGeometryEngine.GeodesicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double) - // cref: Create a buffer polygon at the specified geodesic distance;ArcGIS.Core.Geometry.IGeometryEngine.GeodesicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double,ArcGIS.Core.Geometry.LinearUnit) #region Create a buffer polygon at the specified geodesic distance // buffer a point - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); Polygon outPolygon = GeometryEngine.Instance.GeodesicBuffer(pt, 5) as Polygon; double delta = SpatialReferences.WGS84.XYTolerance * 2 * Math.Sqrt(2); @@ -1219,10 +1215,10 @@ public void GeodesicBuffer() // buffer many points List list = new List(); - list.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84)); - list.Add(MapPointBuilder.CreateMapPoint(10.0, 20.0)); - list.Add(MapPointBuilder.CreateMapPoint(40.0, 40.0)); - list.Add(MapPointBuilder.CreateMapPoint(60.0, 60.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84)); + list.Add(MapPointBuilderEx.CreateMapPoint(10.0, 20.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(40.0, 40.0)); + list.Add(MapPointBuilderEx.CreateMapPoint(60.0, 60.0)); outPolygon = GeometryEngine.Instance.GeodesicBuffer(list, 10000) as Polygon; // outPolygon.PartCount = 4 @@ -1238,10 +1234,10 @@ public void GeodesicBuffer() List manyGeometries = new List { - MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84), - PolylineBuilder.CreatePolyline(new List(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84), - PolylineBuilder.CreatePolyline(new List(){coords[3], coords[4], coords[5]}), - PolygonBuilder.CreatePolygon(new List(){coords[9], coords[10], coords[11]}) + MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84), + PolylineBuilderEx.CreatePolyline(new List(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84), + PolylineBuilderEx.CreatePolyline(new List(){coords[3], coords[4], coords[5]}), + PolygonBuilderEx.CreatePolygon(new List(){coords[9], coords[10], coords[11]}) }; outPolygon = GeometryEngine.Instance.GeodesicBuffer(manyGeometries, 20000) as Polygon; @@ -1255,11 +1251,13 @@ public void GeodesicBuffer() public void GeodesicDistance() { - // cref: Determine geodesic distance between two Geometries;ArcGIS.Core.Geometry.GeometryEngine.GeodesicDistance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Determine geodesic distance between two Geometries;ArcGIS.Core.Geometry.IGeometryEngine.GeodesicDistance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicDistance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicDistance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicDistance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicDistance(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LinearUnit) #region Determine geodesic distance between two Geometries - var point1 = MapPointBuilder.CreateMapPoint(-170, 45, SpatialReferences.WGS84); - var point2 = MapPointBuilder.CreateMapPoint(170, 45, SpatialReferences.WGS84); + var point1 = MapPointBuilderEx.CreateMapPoint(-170, 45, SpatialReferences.WGS84); + var point2 = MapPointBuilderEx.CreateMapPoint(170, 45, SpatialReferences.WGS84); var distances_meters = GeometryEngine.Instance.GeodesicDistance(point1, point2); // distance is approximately 1572912.2066940258 in meters @@ -1272,16 +1270,16 @@ public void GeodesicDistance() public void GeodesicEllipse() { - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeometryEngine.GeodesicEllipse(ArcGIS.Core.Geometry.GeodesicEllipseParameter,ArcGIS.Core.Geometry.SpatialReference) - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.IGeometryEngine.GeodesicEllipse(ArcGIS.Core.Geometry.GeodesicEllipseParameter,ArcGIS.Core.Geometry.SpatialReference) - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeodesicEllipseParameter.AxisDirection - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeodesicEllipseParameter.Center - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeodesicEllipseParameter.LinearUnit - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeodesicEllipseParameter.OutGeometryType - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeodesicEllipseParameter.SemiAxis1Length - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeodesicEllipseParameter.SemiAxis2Length - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeodesicEllipseParameter.VertexCount - // cref: GeodesicEllipse;ArcGIS.Core.Geometry.GeodesicEllipseParameter + // cref: ArcGIS.Core.Geometry.GeodesicEllipseParameter + // cref: ArcGIS.Core.Geometry.GeodesicEllipseParameter.AxisDirection + // cref: ArcGIS.Core.Geometry.GeodesicEllipseParameter.Center + // cref: ArcGIS.Core.Geometry.GeodesicEllipseParameter.LinearUnit + // cref: ArcGIS.Core.Geometry.GeodesicEllipseParameter.SemiAxis1Length + // cref: ArcGIS.Core.Geometry.GeodesicEllipseParameter.SemiAxis2Length + // cref: ArcGIS.Core.Geometry.GeodesicEllipseParameter.VertexCount + // cref: ArcGIS.Core.Geometry.GeodesicEllipseParameter.OutGeometryType + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicEllipse(ArcGIS.Core.Geometry.GeodesicEllipseParameter,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicEllipse(ArcGIS.Core.Geometry.GeodesicEllipseParameter,ArcGIS.Core.Geometry.SpatialReference) #region GeodesicEllipse GeodesicEllipseParameter param = new GeodesicEllipseParameter(); @@ -1303,12 +1301,16 @@ public void GeodesicEllipse() } public void GeodesicLength() { + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicLength(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicLength(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicLength(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicLength(ArcGIS.Core.Geometry.Geometry) #region Determine geodesic length of a line - var polyline = PolylineBuilder.CreatePolyline(new[] + var polyline = PolylineBuilderEx.CreatePolyline(new[] { - MapPointBuilder.CreateMapPoint(-10018754.1713946, 10018754.1713946), - MapPointBuilder.CreateMapPoint(10018754.1713946, 10018754.1713946) + MapPointBuilderEx.CreateMapPoint(-10018754.1713946, 10018754.1713946), + MapPointBuilderEx.CreateMapPoint(10018754.1713946, 10018754.1713946) }, SpatialReferences.WebMercator); var length = GeometryEngine.Instance.GeodesicLength(polyline); @@ -1326,19 +1328,19 @@ public void GeodesicLength() public void GeodesicSector() { - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeometryEngine.GeodesicSector(ArcGIS.Core.Geometry.GeodesicSectorParameter,ArcGIS.Core.Geometry.SpatialReference) - // cref: GeodesicSector;ArcGIS.Core.Geometry.IGeometryEngine.GeodesicSector(ArcGIS.Core.Geometry.GeodesicSectorParameter,ArcGIS.Core.Geometry.SpatialReference) - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.ArcVertexCount - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.AxisDirection - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.Center - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.LinearUnit - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.OutGeometryType - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.RadiusVertexCount - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.SectorAngle - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.SemiAxis1Length - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.SemiAxis2Length - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter.StartDirection - // cref: GeodesicSector;ArcGIS.Core.Geometry.GeodesicSectorParameter + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.ArcVertexCount + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.AxisDirection + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.Center + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.LinearUnit + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.OutGeometryType + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.RadiusVertexCount + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.SectorAngle + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.SemiAxis1Length + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.SemiAxis2Length + // cref: ArcGIS.Core.Geometry.GeodesicSectorParameter.StartDirection + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicSector(ArcGIS.Core.Geometry.GeodesicSectorParameter,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicSector(ArcGIS.Core.Geometry.GeodesicSectorParameter,ArcGIS.Core.Geometry.SpatialReference) #region GeodesicSector GeodesicSectorParameter param = new GeodesicSectorParameter(); @@ -1364,8 +1366,8 @@ public void GeodesicSector() public void GeodeticDensifyByDeviation() { - // cref: GeodeticDensifyByDeviation - polyline;ArcGIS.Core.Geometry.GeometryEngine.GeodeticDensifyByDeviation(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.GeodeticCurveType) - // cref: GeodeticDensifyByDeviation - polyline;ArcGIS.Core.Geometry.IGeometryEngine.GeodeticDensifyByDeviation(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.GeodeticCurveType) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodeticDensifyByDeviation(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.GeodeticCurveType) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodeticDensifyByDeviation(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.GeodeticCurveType) #region GeodeticDensifyByDeviation - polyline List coords = new List() @@ -1380,7 +1382,7 @@ public void GeodeticDensifyByDeviation() SpatialReference sr = SpatialReferences.WGS84; // create a polyline - Polyline polyline = PolylineBuilder.CreatePolyline(coords, sr); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords, sr); // densify in km Polyline geodesicPolyline = GeometryEngine.Instance.GeodeticDensifyByDeviation(polyline, 200, LinearUnit.Kilometers, GeodeticCurveType.Geodesic) as Polyline; @@ -1395,10 +1397,10 @@ public void GeodeticDensifyByDeviation() public void GeodeticDensifyByLength() { - // cref: GeodeticDensifyByLength - polygon;ArcGIS.Core.Geometry.GeometryEngine.GeodesicLength(ArcGIS.Core.Geometry.Geometry) - // cref: GeodeticDensifyByLength - polygon;ArcGIS.Core.Geometry.GeometryEngine.GeodeticDensifyByLength(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.GeodeticCurveType) - // cref: GeodeticDensifyByLength - polygon;ArcGIS.Core.Geometry.IGeometryEngine.GeodesicLength(ArcGIS.Core.Geometry.Geometry) - // cref: GeodeticDensifyByLength - polygon;ArcGIS.Core.Geometry.IGeometryEngine.GeodeticDensifyByLength(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.GeodeticCurveType) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodesicLength(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodesicLength(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodeticDensifyByLength(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.GeodeticCurveType) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodeticDensifyByLength(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LinearUnit,ArcGIS.Core.Geometry.GeodeticCurveType) #region GeodeticDensifyByLength - polygon List coords = new List() @@ -1413,14 +1415,14 @@ public void GeodeticDensifyByLength() SpatialReference sr = SpatialReferences.WGS84; // create a polygon - Polygon polygon = PolygonBuilder.CreatePolygon(coords, sr); + Polygon polygon = PolygonBuilderEx.CreatePolygon(coords, sr); // get the geodesic lengths of the polygon segments ReadOnlySegmentCollection segments = polygon.Parts[0]; List geoLengths = new List(segments.Count); foreach (Segment s in segments) { - Polyline line = PolylineBuilder.CreatePolyline(s, sr); + Polyline line = PolylineBuilderEx.CreatePolyline(s, sr); double geoLen = GeometryEngine.Instance.GeodesicLength(line); geoLengths.Add(geoLen); } @@ -1441,14 +1443,16 @@ public void GeodeticDensifyByLength() public void GeodeticDistanceAndAzimuth() { - // cref: Calculate geodetic distance, azimuth between two points;ArcGIS.Core.Geometry.GeometryEngine.GeodeticDistanceAndAzimuth(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.GeodeticCurveType,System.Double@,System.Double@) - // cref: Calculate geodetic distance, azimuth between two points;ArcGIS.Core.Geometry.IGeometryEngine.GeodeticDistanceAndAzimuth(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.GeodeticCurveType,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodeticDistanceAndAzimuth(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.GeodeticCurveType,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodeticDistanceAndAzimuth(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.GeodeticCurveType,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodeticDistanceAndAzimuth(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.GeodeticCurveType,ArcGIS.Core.Geometry.LinearUnit,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodeticDistanceAndAzimuth(ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.GeodeticCurveType,ArcGIS.Core.Geometry.LinearUnit,System.Double@,System.Double@) #region Calculate geodetic distance, azimuth between two points SpatialReference sr = SpatialReferences.WGS84; - MapPoint p1 = MapPointBuilder.CreateMapPoint(111, 55, sr); - MapPoint p2 = MapPointBuilder.CreateMapPoint(95.5845, 64.2285, sr); + MapPoint p1 = MapPointBuilderEx.CreateMapPoint(111, 55, sr); + MapPoint p2 = MapPointBuilderEx.CreateMapPoint(95.5845, 64.2285, sr); double distance, az12, az21; @@ -1469,8 +1473,8 @@ public void GeodeticDistanceAndAzimuth() - MapPoint p3 = MapPointBuilder.CreateMapPoint(0, 0, sr); - MapPoint p4 = MapPointBuilder.CreateMapPoint(1, 0, sr); + MapPoint p3 = MapPointBuilderEx.CreateMapPoint(0, 0, sr); + MapPoint p4 = MapPointBuilderEx.CreateMapPoint(1, 0, sr); distance = GeometryEngine.Instance.GeodeticDistanceAndAzimuth(p3, p4, GeodeticCurveType.Geodesic, out az12, out az21); // distance - 111319.49079327342 @@ -1487,12 +1491,12 @@ public void GeodeticDistanceAndAzimuth() public void GeodeticMove() { - // cref: Perform Geodetic Move on a set of MapPoints;ArcGIS.Core.Geometry.GeometryEngine.GeodeticMove(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference,System.Double,ArcGIS.Core.Geometry.LinearUnit,System.Double,ArcGIS.Core.Geometry.GeodeticCurveType) - // cref: Perform Geodetic Move on a set of MapPoints;ArcGIS.Core.Geometry.IGeometryEngine.GeodeticMove(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference,System.Double,ArcGIS.Core.Geometry.LinearUnit,System.Double,ArcGIS.Core.Geometry.GeodeticCurveType) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GeodeticMove(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference,System.Double,ArcGIS.Core.Geometry.LinearUnit,System.Double,ArcGIS.Core.Geometry.GeodeticCurveType) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GeodeticMove(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.SpatialReference,System.Double,ArcGIS.Core.Geometry.LinearUnit,System.Double,ArcGIS.Core.Geometry.GeodeticCurveType) #region Perform Geodetic Move on a set of MapPoints SpatialReference sr = SpatialReferences.WebMercator; - var points = new[] { MapPointBuilder.CreateMapPoint(0, 0, sr) }; + var points = new[] { MapPointBuilderEx.CreateMapPoint(0, 0, sr) }; double distance = 10; double azimuth = Math.PI / 2; var resultPoints = GeometryEngine.Instance.GeodeticMove(points, sr, distance, LinearUnit.Meters, azimuth, GeodeticCurveType.Geodesic); @@ -1515,11 +1519,11 @@ public void GeodeticMove() public void GetPredefinedCoordinateSystemList() { - // cref: Retrieve coordinate systems;ArcGIS.Core.Geometry.GeometryEngine.GetPredefinedCoordinateSystemList(ArcGIS.Core.Geometry.CoordinateSystemFilter) - // cref: Retrieve coordinate systems;ArcGIS.Core.Geometry.IGeometryEngine.GetPredefinedCoordinateSystemList(ArcGIS.Core.Geometry.CoordinateSystemFilter) - // cref: Retrieve coordinate systems;ArcGIS.Core.Geometry.CoordinateSystemListEntry.Category - // cref: Retrieve coordinate systems;ArcGIS.Core.Geometry.CoordinateSystemListEntry.Name - // cref: Retrieve coordinate systems;ArcGIS.Core.Geometry.CoordinateSystemListEntry.Wkid + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetPredefinedCoordinateSystemList(ArcGIS.Core.Geometry.CoordinateSystemFilter) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetPredefinedCoordinateSystemList(ArcGIS.Core.Geometry.CoordinateSystemFilter) + // cref: ArcGIS.Core.Geometry.CoordinateSystemListEntry.Category + // cref: ArcGIS.Core.Geometry.CoordinateSystemListEntry.Name + // cref: ArcGIS.Core.Geometry.CoordinateSystemListEntry.Wkid #region Retrieve coordinate systems // get all the geographic coordinate systems @@ -1544,12 +1548,12 @@ public void GetPredefinedCoordinateSystemList() public void GetPredefinedGeographicTransformationList() { - // cref: Retrieve system geographic transformations;ArcGIS.Core.Geometry.GeometryEngine.GetPredefinedGeographicTransformationList - // cref: Retrieve system geographic transformations;ArcGIS.Core.Geometry.IGeometryEngine.GetPredefinedGeographicTransformationList - // cref: Retrieve system geographic transformations;ArcGIS.Core.Geometry.GeographicTransformationListEntry.FromSRWkid - // cref: Retrieve system geographic transformations;ArcGIS.Core.Geometry.GeographicTransformationListEntry.Name - // cref: Retrieve system geographic transformations;ArcGIS.Core.Geometry.GeographicTransformationListEntry.ToSRWkid - // cref: Retrieve system geographic transformations;ArcGIS.Core.Geometry.GeographicTransformationListEntry.Wkid + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetPredefinedGeographicTransformationList + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetPredefinedGeographicTransformationList + // cref: ArcGIS.Core.Geometry.GeographicTransformationListEntry.FromSRWkid + // cref: ArcGIS.Core.Geometry.GeographicTransformationListEntry.Name + // cref: ArcGIS.Core.Geometry.GeographicTransformationListEntry.ToSRWkid + // cref: ArcGIS.Core.Geometry.GeographicTransformationListEntry.Wkid #region Retrieve system geographic transformations // a geographic transformation is the definition of how to project from one spatial reference to another @@ -1567,10 +1571,10 @@ public void GetPredefinedGeographicTransformationList() public void GetSubCurve_GetSubCurve3D() { - // cref: Get Sub-curve of a polyline or polygon;ArcGIS.Core.Geometry.GeometryEngine.GetSubCurve(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) - // cref: Get Sub-curve of a polyline or polygon;ArcGIS.Core.Geometry.GeometryEngine.GetSubCurve3D(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) - // cref: Get Sub-curve of a polyline or polygon;ArcGIS.Core.Geometry.IGeometryEngine.GetSubCurve(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) - // cref: Get Sub-curve of a polyline or polygon;ArcGIS.Core.Geometry.IGeometryEngine.GetSubCurve3D(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetSubCurve(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetSubCurve3D(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetSubCurve(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetSubCurve3D(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) #region Get Sub-curve of a polyline or polygon SpatialReference sr = SpatialReferences.WGS84; @@ -1582,7 +1586,7 @@ public void GetSubCurve_GetSubCurve3D() new Coordinate2D(-114, 68) }; - Polyline polyline = PolylineBuilder.CreatePolyline(coords, sr); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords, sr); Polyline subCurve = GeometryEngine.Instance.GetSubCurve(polyline, 0, 5, AsRatioOrLength.AsLength); // subCurve.PartCount = 1 @@ -1609,7 +1613,7 @@ public void GetSubCurve_GetSubCurve3D() new Coordinate3D(1, 0, 3) }; - Polygon polygon = PolygonBuilder.CreatePolygon(coords3D, sr); + Polygon polygon = PolygonBuilderEx.CreatePolygon(coords3D, sr); subCurve = GeometryEngine.Instance.GetSubCurve3D(polygon, 0, 1, AsRatioOrLength.AsLength); // subCurve.HasZ = true @@ -1624,8 +1628,8 @@ public void GetSubCurve_GetSubCurve3D() public void GraphicBuffer() { - // cref: GraphicBuffer;ArcGIS.Core.Geometry.GeometryEngine.GraphicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LineJoinType,ArcGIS.Core.Geometry.LineCapType,System.Double,System.Double,System.Int32) - // cref: GraphicBuffer;ArcGIS.Core.Geometry.IGeometryEngine.GraphicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LineJoinType,ArcGIS.Core.Geometry.LineCapType,System.Double,System.Double,System.Int32) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GraphicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LineJoinType,ArcGIS.Core.Geometry.LineCapType,System.Double,System.Double,System.Int32) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GraphicBuffer(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.LineJoinType,ArcGIS.Core.Geometry.LineCapType,System.Double,System.Double,System.Int32) #region GraphicBuffer // mitered join and butt caps @@ -1637,24 +1641,24 @@ public void GraphicBuffer() new Coordinate2D(1800,6200) }; - Polyline polyline = PolylineBuilder.CreatePolyline(coords, sr); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords, sr); Polygon polygon = GeometryEngine.Instance.GraphicBuffer(polyline, 50, LineJoinType.Miter, LineCapType.Butt, 10, 0, -1) as Polygon; // bevelled join and round caps - Envelope envelope = EnvelopeBuilder.CreateEnvelope(0, 0, 10000, 10000, SpatialReferences.WebMercator); + Envelope envelope = EnvelopeBuilderEx.CreateEnvelope(0, 0, 10000, 10000, SpatialReferences.WebMercator); Polygon outPolygon = GeometryEngine.Instance.GraphicBuffer(envelope, 1000, LineJoinType.Bevel, LineCapType.Round, 4, 0, 96) as Polygon; #endregion - // cref: GraphicBuffer Many;ArcGIS.Core.Geometry.GeometryEngine.GraphicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double,ArcGIS.Core.Geometry.LineJoinType,ArcGIS.Core.Geometry.LineCapType,System.Double,System.Double,System.Int32) - // cref: GraphicBuffer Many;ArcGIS.Core.Geometry.IGeometryEngine.GraphicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double,ArcGIS.Core.Geometry.LineJoinType,ArcGIS.Core.Geometry.LineCapType,System.Double,System.Double,System.Int32) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GraphicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double,ArcGIS.Core.Geometry.LineJoinType,ArcGIS.Core.Geometry.LineCapType,System.Double,System.Double,System.Int32) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GraphicBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry},System.Double,ArcGIS.Core.Geometry.LineJoinType,ArcGIS.Core.Geometry.LineCapType,System.Double,System.Double,System.Int32) #region GraphicBuffer Many // round join and round caps - MapPoint point1 = MapPointBuilder.CreateMapPoint(0, 0); - MapPoint point2 = MapPointBuilder.CreateMapPoint(1, 1, SpatialReferences.WGS84); - MapPoint point3 = MapPointBuilder.CreateMapPoint(1000000, 1200000, SpatialReferences.WebMercator); + MapPoint point1 = MapPointBuilderEx.CreateMapPoint(0, 0); + MapPoint point2 = MapPointBuilderEx.CreateMapPoint(1, 1, SpatialReferences.WGS84); + MapPoint point3 = MapPointBuilderEx.CreateMapPoint(1000000, 1200000, SpatialReferences.WebMercator); List points = new List() { point1, point2, point3 }; IReadOnlyList geometries = GeometryEngine.Instance.GraphicBuffer(points, 5, LineJoinType.Round, LineCapType.Round, 0, 0, 3000); @@ -1663,51 +1667,49 @@ public void GraphicBuffer() public void Intersection() { - // cref: Intersection between two Polylines;ArcGIS.Core.Geometry.GeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Intersection between two Polylines;ArcGIS.Core.Geometry.GeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.GeometryDimension) - // cref: Intersection between two Polylines;ArcGIS.Core.Geometry.GeometryEngine.Intersects(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Intersection between two Polylines;ArcGIS.Core.Geometry.IGeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Intersection between two Polylines;ArcGIS.Core.Geometry.IGeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.GeometryDimension) - // cref: Intersection between two Polylines;ArcGIS.Core.Geometry.IGeometryEngine.Intersects(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.GeometryDimensionType) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Intersects(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.GeometryDimensionType) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Intersects(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Intersection between two Polylines // determine intersection between two polylines List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0)); - Polyline line1 = PolylineBuilder.CreatePolyline(pts); + Polyline line1 = PolylineBuilderEx.CreatePolyline(pts); List pts2 = new List(); - pts2.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0)); - pts2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0)); - pts2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0)); + pts2.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0)); + pts2.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0)); + pts2.Add(MapPointBuilderEx.CreateMapPoint(5.0, 3.0)); - Polyline line2 = PolylineBuilder.CreatePolyline(pts2); + Polyline line2 = PolylineBuilderEx.CreatePolyline(pts2); bool intersects = GeometryEngine.Instance.Intersects(line1, line2); // intersects = true - Geometry g = GeometryEngine.Instance.Intersection(line1, line2, GeometryDimension.esriGeometry0Dimension); + Geometry g = GeometryEngine.Instance.Intersection(line1, line2, GeometryDimensionType.EsriGeometry0Dimension); Multipoint resultMultipoint = g as Multipoint; // result is a multiPoint that intersects at (2,2) and (4,2) #endregion - // cref: Intersection between two Polygons;ArcGIS.Core.Geometry.EnvelopeBuilder.CreateEnvelope(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) - // cref: Intersection between two Polygons;ArcGIS.Core.Geometry.GeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Intersection between two Polygons;ArcGIS.Core.Geometry.GeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.GeometryDimension) - // cref: Intersection between two Polygons;ArcGIS.Core.Geometry.IGeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Intersection between two Polygons;ArcGIS.Core.Geometry.IGeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.GeometryDimension) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Intersection(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Intersection between two Polygons // determine intersection between two polygons - Envelope env1 = EnvelopeBuilder.CreateEnvelope(new Coordinate2D(3.0, 2.0), new Coordinate2D(6.0, 6.0)); - Polygon poly1 = PolygonBuilder.CreatePolygon(env1); + Envelope env1 = EnvelopeBuilderEx.CreateEnvelope(new Coordinate2D(3.0, 2.0), new Coordinate2D(6.0, 6.0)); + Polygon poly1 = PolygonBuilderEx.CreatePolygon(env1); - Envelope env2 = EnvelopeBuilder.CreateEnvelope(new Coordinate2D(1.0, 1.0), new Coordinate2D(4.0, 4.0)); - Polygon poly2 = PolygonBuilder.CreatePolygon(env2); + Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(new Coordinate2D(1.0, 1.0), new Coordinate2D(4.0, 4.0)); + Polygon poly2 = PolygonBuilderEx.CreatePolygon(env2); Polygon polyResult = GeometryEngine.Instance.Intersection(poly1, poly2) as Polygon; #endregion @@ -1715,8 +1717,8 @@ public void Intersection() public void LabelPoint() { - // cref: Determine label point for a Polygon;ArcGIS.Core.Geometry.GeometryEngine.LabelPoint(ArcGIS.Core.Geometry.Geometry) - // cref: Determine label point for a Polygon;ArcGIS.Core.Geometry.IGeometryEngine.LabelPoint(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.LabelPoint(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.LabelPoint(ArcGIS.Core.Geometry.Geometry) #region Determine label point for a Polygon // create a polygon @@ -1726,7 +1728,7 @@ public void LabelPoint() list2D.Add(new Coordinate2D(2.0, 2.0)); list2D.Add(new Coordinate2D(2.0, 1.0)); - Polygon polygon = PolygonBuilder.CreatePolygon(list2D); + Polygon polygon = PolygonBuilderEx.CreatePolygon(list2D); bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon); MapPoint pt = GeometryEngine.Instance.LabelPoint(polygon); #endregion @@ -1734,22 +1736,22 @@ public void LabelPoint() public void Length_Length3D() { - // cref: Determine Length, Length3D of line;ArcGIS.Core.Geometry.GeometryEngine.Length(ArcGIS.Core.Geometry.Geometry) - // cref: Determine Length, Length3D of line;ArcGIS.Core.Geometry.GeometryEngine.Length3D(ArcGIS.Core.Geometry.Geometry) - // cref: Determine Length, Length3D of line;ArcGIS.Core.Geometry.IGeometryEngine.Length(ArcGIS.Core.Geometry.Geometry) - // cref: Determine Length, Length3D of line;ArcGIS.Core.Geometry.IGeometryEngine.Length3D(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Length(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Length3D(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Length(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Length3D(ArcGIS.Core.Geometry.Geometry) #region Determine Length, Length3D of line - MapPoint c1 = MapPointBuilder.CreateMapPoint(1, 2, 3); - MapPoint c2 = MapPointBuilder.CreateMapPoint(4, 2, 4); + MapPoint c1 = MapPointBuilderEx.CreateMapPoint(1, 2, 3); + MapPoint c2 = MapPointBuilderEx.CreateMapPoint(4, 2, 4); // line segment - LineSegment line = LineBuilder.CreateLineSegment(c1, c2); + LineSegment line = LineBuilderEx.CreateLineSegment(c1, c2); double len = line.Length; // = 3 double len3D = line.Length3D; // = Math.Sqrt(10) // polyline - Polyline p = PolylineBuilder.CreatePolyline(line); + Polyline p = PolylineBuilderEx.CreatePolyline(line); double p_len = p.Length; // = len = 3 double p_len3D = p.Length3D; // = len3D = Math.Sqrt(10) @@ -1762,12 +1764,12 @@ public void GetMinMaxM() { // GetMinMaxM, GetMMonotonic, GetPointsAtM, GetSubCurveBetweenMs, GetNormalsAtM, SetMsAsDistance, SetAndInterpolateMsBetween - // cref: Get the minimum and maximum M values - GetMinMaxM;ArcGIS.Core.Geometry.GeometryEngine.GetMinMaxM(ArcGIS.Core.Geometry.Multipart,System.Double@,System.Double@) - // cref: Get the minimum and maximum M values - GetMinMaxM;ArcGIS.Core.Geometry.IGeometryEngine.GetMinMaxM(ArcGIS.Core.Geometry.Multipart,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetMinMaxM(ArcGIS.Core.Geometry.Multipart,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetMinMaxM(ArcGIS.Core.Geometry.Multipart,System.Double@,System.Double@) #region Get the minimum and maximum M values - GetMinMaxM string json = "{\"hasM\":true,\"rings\":[[[-3000,-2000,10],[-2000,-2000,15],[-1000,-2000,20],[0,-2000,0],[1000,-2000,-20],[2000,-2000,-30],[3000,-2000,10],[4000,-2000,5]]],\"spatialReference\":{\"wkid\":3857}}"; - Polygon polygon = PolygonBuilder.FromJson(json); + Polygon polygon = PolygonBuilderEx.FromJson(json); double minM, maxM; GeometryEngine.Instance.GetMinMaxM(polygon, out minM, out maxM); @@ -1775,14 +1777,14 @@ public void GetMinMaxM() // maxM = 20 json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,10],[-2000,-2000,null],[-1000,-2000,null]]]}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); GeometryEngine.Instance.GetMinMaxM(polyline, out minM, out maxM); // minM = 10 // maxM = 10 json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,null],[-2000,-2000,null],[-1000,-2000,null]]]}"; - polyline = PolylineBuilder.FromJson(json); + polyline = PolylineBuilderEx.FromJson(json); GeometryEngine.Instance.GetMinMaxM(polyline, out minM, out maxM); // minM = double.Nan @@ -1792,24 +1794,24 @@ public void GetMinMaxM() public void GetMMonotonic() { - // cref: Determine whether Ms are monotonic and whether ascending or descending - GetMMonotonic;ArcGIS.Core.Geometry.GeometryEngine.GetMMonotonic(ArcGIS.Core.Geometry.Multipart) - // cref: Determine whether Ms are monotonic and whether ascending or descending - GetMMonotonic;ArcGIS.Core.Geometry.IGeometryEngine.GetMMonotonic(ArcGIS.Core.Geometry.Multipart) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetMMonotonic(ArcGIS.Core.Geometry.Multipart) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetMMonotonic(ArcGIS.Core.Geometry.Multipart) #region Determine whether Ms are monotonic and whether ascending or descending - GetMMonotonic string json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,10],[-2000,-2000,15],[-1000,-2000,20]]]}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); - Monotonic monotonic = GeometryEngine.Instance.GetMMonotonic(polyline); + MonotonicType monotonic = GeometryEngine.Instance.GetMMonotonic(polyline); // monotonic = Monotonic.Ascending json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,10],[-2000,-2000,5],[-1000,-2000,0]]]}"; - polyline = PolylineBuilder.FromJson(json); + polyline = PolylineBuilderEx.FromJson(json); monotonic = GeometryEngine.Instance.GetMMonotonic(polyline); // monotonic = Monotonic.Descending json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,10],[-2000,-2000,15],[-1000,-2000,0]]]}"; - polyline = PolylineBuilder.FromJson(json); + polyline = PolylineBuilderEx.FromJson(json); monotonic = GeometryEngine.Instance.GetMMonotonic(polyline); // monotonic = Monotonic.NotMonotonic @@ -1819,12 +1821,12 @@ public void GetMMonotonic() public void GetPointsAtM() { - // cref: Get a multipoint corresponding to the locations where the specified M values occur along the geometry - GetPointsAtM;ArcGIS.Core.Geometry.GeometryEngine.GetPointsAtM(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) - // cref: Get a multipoint corresponding to the locations where the specified M values occur along the geometry - GetPointsAtM;ArcGIS.Core.Geometry.IGeometryEngine.GetPointsAtM(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetPointsAtM(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetPointsAtM(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) #region Get a multipoint corresponding to the locations where the specified M values occur along the geometry - GetPointsAtM string json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,10],[-2000,-2000,15],[-1000,-2000,20],[0,-2000,0],[1000,-2000,20],[2000,-2000,30],[3000,-2000,10],[4000,-2000,5]]],\"spatialReference\":{\"wkid\":3857}}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); Multipoint multipoint = GeometryEngine.Instance.GetPointsAtM(polyline, 10, 500); // multiPoint.PointCount = 4 @@ -1837,12 +1839,12 @@ public void GetPointsAtM() public void GetSubCurveBetweenMs() { - // cref: Get a polyline corresponding to the subcurves between specified M values - GetSubCurveBetweenMs;ArcGIS.Core.Geometry.GeometryEngine.GetSubCurveBetweenMs(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) - // cref: Get a polyline corresponding to the subcurves between specified M values - GetSubCurveBetweenMs;ArcGIS.Core.Geometry.IGeometryEngine.GetSubCurveBetweenMs(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetSubCurveBetweenMs(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetSubCurveBetweenMs(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) #region Get a polyline corresponding to the subcurves between specified M values - GetSubCurveBetweenMs string json = "{\"hasM\":true,\"paths\":[[[-2000,0,1],[-1000,1000,2],[-1000,0,3],[1000,1000,4],[2000,1000,5],[2000,2000,6],[3000,2000,7],[4000,0,8]]],\"spatialReference\":{\"wkid\":3857}}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); Polyline subCurve = GeometryEngine.Instance.GetSubCurveBetweenMs(polyline, 2, 6); // subCurve.PointCount = 5 @@ -1860,24 +1862,24 @@ public void GetSubCurveBetweenMs() public void GetNormalsAtM() { - // cref: Get line segments corresponding to the normal at the locations where the specified M values occur along the geometry - GetNormalsAtM;ArcGIS.Core.Geometry.GeometryEngine.GetNormalsAtM(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) - // cref: Get line segments corresponding to the normal at the locations where the specified M values occur along the geometry - GetNormalsAtM;ArcGIS.Core.Geometry.IGeometryEngine.GetNormalsAtM(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetNormalsAtM(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetNormalsAtM(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) #region Get line segments corresponding to the normal at the locations where the specified M values occur along the geometry - GetNormalsAtM IList inPoints = new List() { - MapPointBuilder.CreateMapPoint(-3000, -2000, 0, 100), - MapPointBuilder.CreateMapPoint(-3000, 0, 0, 200), - MapPointBuilder.CreateMapPoint(-1000, 0, 0, 300), - MapPointBuilder.CreateMapPoint(-1000, 2000, 0, 100), - MapPointBuilder.CreateMapPoint(3000, 2000, 0, 200), - MapPointBuilder.CreateMapPoint(3000, 0, 0, 300), - MapPointBuilder.CreateMapPoint(1000, 0, 0, 100), - MapPointBuilder.CreateMapPoint(1000, -2000, 0, 200), - MapPointBuilder.CreateMapPoint(-3000, -2000, 0, 300) + MapPointBuilderEx.CreateMapPoint(-3000, -2000, 0, 100), + MapPointBuilderEx.CreateMapPoint(-3000, 0, 0, 200), + MapPointBuilderEx.CreateMapPoint(-1000, 0, 0, 300), + MapPointBuilderEx.CreateMapPoint(-1000, 2000, 0, 100), + MapPointBuilderEx.CreateMapPoint(3000, 2000, 0, 200), + MapPointBuilderEx.CreateMapPoint(3000, 0, 0, 300), + MapPointBuilderEx.CreateMapPoint(1000, 0, 0, 100), + MapPointBuilderEx.CreateMapPoint(1000, -2000, 0, 200), + MapPointBuilderEx.CreateMapPoint(-3000, -2000, 0, 300) }; - Polygon polygon = PolygonBuilder.CreatePolygon(inPoints); + Polygon polygon = PolygonBuilderEx.CreatePolygon(inPoints); // polygon.HasM = true Polyline polyline = GeometryEngine.Instance.GetNormalsAtM(polygon, 150, 100); @@ -1915,12 +1917,12 @@ public void GetNormalsAtM() public void GetMsAtDistance() { - // cref: Get the M values at the specified distance along the multipart;ArcGIS.Core.Geometry.GeometryEngine.GetMsAtDistance(ArcGIS.Core.Geometry.Multipart,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@) - // cref: Get the M values at the specified distance along the multipart;ArcGIS.Core.Geometry.IGeometryEngine.GetMsAtDistance(ArcGIS.Core.Geometry.Multipart,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.GetMsAtDistance(ArcGIS.Core.Geometry.Multipart,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.GetMsAtDistance(ArcGIS.Core.Geometry.Multipart,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@) #region Get the M values at the specified distance along the multipart string json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,-3],[-2000,-2000,-2]],[[-2000,-2000,1],[-2000,1000,2]]],\"spatialReference\":{\"wkid\":3857}}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); // polyline has 2 parts @@ -1942,12 +1944,12 @@ public void GetMsAtDistance() public void SetMsAsDistance() { - // cref: Set M values to the cumulative length from the start of the multipart - SetMsAsDistance;ArcGIS.Core.Geometry.GeometryEngine.SetMsAsDistance(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.AsRatioOrLength) - // cref: Set M values to the cumulative length from the start of the multipart - SetMsAsDistance;ArcGIS.Core.Geometry.IGeometryEngine.SetMsAsDistance(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SetMsAsDistance(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SetMsAsDistance(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.AsRatioOrLength) #region Set M values to the cumulative length from the start of the multipart - SetMsAsDistance string json = "{\"hasM\":true,\"rings\":[[[0,0],[0,3000],[4000,3000],[4000,0],[0,0]]],\"spatialReference\":{\"wkid\":3857}}"; - Polygon polygon = PolygonBuilder.FromJson(json); + Polygon polygon = PolygonBuilderEx.FromJson(json); Polygon outPolygon = GeometryEngine.Instance.SetMsAsDistance(polygon, AsRatioOrLength.AsLength) as Polygon; ReadOnlyPointCollection outPoints = outPolygon.Points; @@ -1957,12 +1959,12 @@ public void SetMsAsDistance() public void InsertMAtDistance() { - // cref: Insert M value at the given distance - InsertMAtDistance;ArcGIS.Core.Geometry.GeometryEngine.InsertMAtDistance(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Boolean,System.Boolean@,System.Int32@,System.Int32@) - // cref: Insert M value at the given distance - InsertMAtDistance;ArcGIS.Core.Geometry.IGeometryEngine.InsertMAtDistance(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Boolean,System.Boolean@,System.Int32@,System.Int32@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.InsertMAtDistance(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Boolean,System.Boolean@,System.Int32@,System.Int32@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.InsertMAtDistance(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Boolean,System.Boolean@,System.Int32@,System.Int32@) #region Insert M value at the given distance - InsertMAtDistance string json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,-3],[-2000,-2000,-2],[-1000,-2000,null]]]}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); bool splitHappened; int partIndex, segmentIndex; @@ -1976,7 +1978,7 @@ public void InsertMAtDistance() // outputPolyline.Points[2].M = -1 json = "{\"hasM\":true,\"paths\":[[[-3000,-2000,-3],[-2000,-2000,-2],[-1000,-2000,-1]],[[0,0,0],[0,1000,0],[0,2000,2]]],\"spatialReference\":{\"wkid\":3857}}"; - polyline = PolylineBuilder.FromJson(json); + polyline = PolylineBuilderEx.FromJson(json); // A point already exists at the given distance, but createNewPart = true m = 1; @@ -2006,12 +2008,12 @@ public void InsertMAtDistance() public void CalibrateByMs() { - // cref: Calibrate M values using M values from input points - CalibrateByMs;ArcGIS.Core.Geometry.GeometryEngine.CalibrateByMs(ArcGIS.Core.Geometry.Multipart,System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.UpdateMMethod,System.Double) - // cref: Calibrate M values using M values from input points - CalibrateByMs;ArcGIS.Core.Geometry.IGeometryEngine.CalibrateByMs(ArcGIS.Core.Geometry.Multipart,System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.UpdateMMethod,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.CalibrateByMs(ArcGIS.Core.Geometry.Multipart,System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.UpdateMMethod,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.CalibrateByMs(ArcGIS.Core.Geometry.Multipart,System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.MapPoint},ArcGIS.Core.Geometry.UpdateMMethod,System.Double) #region Calibrate M values using M values from input points - CalibrateByMs string json = "{\"hasM\":true,\"paths\":[[[0,0,-1],[1,0,0],[1,1,1],[1,2,2],[3,1,3],[5,3,4],[9,5,5],[7,6,6]]],\"spatialReference\":{\"wkid\":4326}}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); // Interpolate using points (0, 0, 17), (1, 0, 42), (7, 6, 18) List updatePoints = new List(3); @@ -2074,12 +2076,12 @@ public void CalibrateByMs() public void InterpolateMsBetween() { - // cref: Generates M values by linear interpolation over a range of points - InterpolateMsBetween;ArcGIS.Core.Geometry.GeometryEngine.InterpolateMsBetween(ArcGIS.Core.Geometry.Multipart,System.Int32,System.Int32,System.Int32,System.Int32) - // cref: Generates M values by linear interpolation over a range of points - InterpolateMsBetween;ArcGIS.Core.Geometry.IGeometryEngine.InterpolateMsBetween(ArcGIS.Core.Geometry.Multipart,System.Int32,System.Int32,System.Int32,System.Int32) + // cref: ArcGIS.Core.Geometry.GeometryEngine.InterpolateMsBetween(ArcGIS.Core.Geometry.Multipart,System.Int32,System.Int32,System.Int32,System.Int32) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.InterpolateMsBetween(ArcGIS.Core.Geometry.Multipart,System.Int32,System.Int32,System.Int32,System.Int32) #region Generates M values by linear interpolation over a range of points - InterpolateMsBetween string json = "{\"hasM\":true,\"paths\":[[[0,0,-1],[1,0,0],[1,1,1],[1,2,2],[3,1,3],[5,3,4],[9,5,5],[7,6,6]]],\"spatialReference\":{\"wkid\":4326}}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); // Interpolate between points 2 and 6 Polyline outPolyline = GeometryEngine.Instance.InterpolateMsBetween(polyline, 0, 2, 0, 6) as Polyline; @@ -2091,12 +2093,12 @@ public void InterpolateMsBetween() public void SetAndInterpolateMsBetween() { - // cref: Set Ms at the beginning and end of the geometry and interpolate M values between the two values - SetAndInterpolateMsBetween;ArcGIS.Core.Geometry.GeometryEngine.SetAndInterpolateMsBetween(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) - // cref: Set Ms at the beginning and end of the geometry and interpolate M values between the two values - SetAndInterpolateMsBetween;ArcGIS.Core.Geometry.IGeometryEngine.SetAndInterpolateMsBetween(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SetAndInterpolateMsBetween(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SetAndInterpolateMsBetween(ArcGIS.Core.Geometry.Multipart,System.Double,System.Double) #region Set Ms at the beginning and end of the geometry and interpolate M values between the two values - SetAndInterpolateMsBetween string json = "{\"hasM\":true,\"paths\":[[[-3000,-2000],[-2000,-2000],[-1000,-2000],[0,-2000],[1000,-2000],[2000,-2000],[3000,-2000],[4000,-2000]]],\"spatialReference\":{\"wkid\":3857}}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); Polyline outPolyline = GeometryEngine.Instance.SetAndInterpolateMsBetween(polyline, 100, 800) as Polyline; ReadOnlyPointCollection outPoints = outPolyline.Points; @@ -2106,33 +2108,34 @@ public void SetAndInterpolateMsBetween() public void Move() { - // cref: Move a MapPoint;ArcGIS.Core.Geometry.IGeometryEngine.Move (ArcGIS.Core.Geometry.Geometry,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Move (ArcGIS.Core.Geometry.Geometry,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Move (ArcGIS.Core.Geometry.Geometry,System.Double,System.Double) #region Move a MapPoint - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 3.0); MapPoint ptResult = GeometryEngine.Instance.Move(pt, -3.5, 2.5) as MapPoint; // ptResult is (-2.5, 5.5) #endregion - // cref: Move a z-aware MapPoint;ArcGIS.Core.Geometry.GeometryEngine.Move(ArcGIS.Core.Geometry.Geometry,System.Double,System.Double,System.Double) - // cref: Move a z-aware MapPoint;ArcGIS.Core.Geometry.IGeometryEngine.Move(ArcGIS.Core.Geometry.Geometry,System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Move(ArcGIS.Core.Geometry.Geometry,System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Move(ArcGIS.Core.Geometry.Geometry,System.Double,System.Double,System.Double) #region Move a z-aware MapPoint - MapPoint zPt = MapPointBuilder.CreateMapPoint(1.0, 3.0, 2.0); + MapPoint zPt = MapPointBuilderEx.CreateMapPoint(1.0, 3.0, 2.0); MapPoint zPtResult = GeometryEngine.Instance.Move(zPt, 4, 0.25, 0.5) as MapPoint; // zPtResult is (5.0, 3.25, 2.5); #endregion - // cref: Move a Polyline;ArcGIS.Core.Geometry.GeometryEngine.Move(ArcGIS.Core.Geometry.Geometry,System.Double,System.Double) - // cref: Move a Polyline;ArcGIS.Core.Geometry.IGeometryEngine.Move(ArcGIS.Core.Geometry.Geometry,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Move(ArcGIS.Core.Geometry.Geometry,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Move(ArcGIS.Core.Geometry.Geometry,System.Double,System.Double) #region Move a Polyline List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3, 2, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(4.0, 2.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3, 2, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(4.0, 2.0, 3.0)); - Polyline polyline = PolylineBuilder.CreatePolyline(pts); + Polyline polyline = PolylineBuilderEx.CreatePolyline(pts); Geometry geometry = GeometryEngine.Instance.Move(polyline, 3, 2); Polyline polylineResult = geometry as Polyline; @@ -2145,115 +2148,115 @@ public void Move() public void MovePointAlongLine() { - // cref: MovePointAlongLine;ArcGIS.Core.Geometry.GeometryEngine.MovePointAlongLine(ArcGIS.Core.Geometry.Multipart,System.Double,System.Boolean,System.Double,ArcGIS.Core.Geometry.SegmentExtension) - // cref: MovePointAlongLine;ArcGIS.Core.Geometry.IGeometryEngine.MovePointAlongLine(ArcGIS.Core.Geometry.Multipart,System.Double,System.Boolean,System.Double,ArcGIS.Core.Geometry.SegmentExtension) + // cref: ArcGIS.Core.Geometry.GeometryEngine.MovePointAlongLine(ArcGIS.Core.Geometry.Multipart,System.Double,System.Boolean,System.Double,ArcGIS.Core.Geometry.SegmentExtensionType) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.MovePointAlongLine(ArcGIS.Core.Geometry.Multipart,System.Double,System.Boolean,System.Double,ArcGIS.Core.Geometry.SegmentExtensionType) #region MovePointAlongLine - LineSegment line = LineBuilder.CreateLineSegment(MapPointBuilder.CreateMapPoint(0, 3), MapPointBuilder.CreateMapPoint(5.0, 3.0)); - Polyline polyline = PolylineBuilder.CreatePolyline(line); + LineSegment line = LineBuilderEx.CreateLineSegment(MapPointBuilderEx.CreateMapPoint(0, 3), MapPointBuilderEx.CreateMapPoint(5.0, 3.0)); + Polyline polyline = PolylineBuilderEx.CreatePolyline(line); bool simple = GeometryEngine.Instance.IsSimpleAsFeature(polyline); // ratio = false - MapPoint pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 0.0, SegmentExtension.NoExtension); + MapPoint pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 0.0, SegmentExtensionType.NoExtension); // pt = 1.0, 3.0 - pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, -1.0, SegmentExtension.NoExtension); + pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, -1.0, SegmentExtensionType.NoExtension); // pt = 1.0, 4.0 - pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 2.0, SegmentExtension.NoExtension); + pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 2.0, SegmentExtensionType.NoExtension); // pt = 1.0, 1.0 // ratio = true - pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtension.NoExtension); + pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtensionType.NoExtension); // pt = 2.5, 3.0 // move past the line - pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtension.NoExtension); + pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtensionType.NoExtension); // pt = 5.0, 3.0 // move past the line with extension at "to" point - pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtension.ExtendEmbeddedAtTo); + pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtensionType.ExtendEmbeddedAtTo); // pt = 7.0, 3.0 // negative distance with extension at "from" point - pt = GeometryEngine.Instance.MovePointAlongLine(polyline, -2, false, 0, SegmentExtension.ExtendEmbeddedAtFrom); + pt = GeometryEngine.Instance.MovePointAlongLine(polyline, -2, false, 0, SegmentExtensionType.ExtendEmbeddedAtFrom); // pt = -2.0, 3.0 // ratio = true - pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtension.NoExtension); + pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtensionType.NoExtension); // pt = 2.5, 3.0 // line with Z List coords3D = new List { new Coordinate3D(0, 0, 0), new Coordinate3D(1113195, 1118890, 5000) }; - Polyline polylineZ = PolylineBuilder.CreatePolyline(coords3D, SpatialReferences.WebMercator); + Polyline polylineZ = PolylineBuilderEx.CreatePolyline(coords3D, SpatialReferences.WebMercator); // polylineZ.HasZ = true // ratio = true, no offset - pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 0.5, true, 0, SegmentExtension.NoExtension); + pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 0.5, true, 0, SegmentExtensionType.NoExtension); // pt.X = 556597.5 // pt.Y = 559445 // pt.Z = 2500 // ratio = true, past the line with "to" extension, no offset - pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 1.5, true, 0, SegmentExtension.ExtendEmbeddedAtTo); + pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 1.5, true, 0, SegmentExtensionType.ExtendEmbeddedAtTo); // pt.X = 1669792.5 // pt.Y = 1678335 // pt.Z = 7500 // ratio = true, negative distance past the line with no extension, no offset - pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, -1.5, true, 0, SegmentExtension.NoExtension); + pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, -1.5, true, 0, SegmentExtensionType.NoExtension); // pt.X = 0 // pt.Y = 0 // pt.Z = -7500 // polyline with Z but 2d distance = 0 - MapPoint pt3 = MapPointBuilder.CreateMapPoint(5, 5, 0); - MapPoint pt4 = MapPointBuilder.CreateMapPoint(5, 5, 10); + MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(5, 5, 0); + MapPoint pt4 = MapPointBuilderEx.CreateMapPoint(5, 5, 10); List pts = new List() { pt3, pt4 }; - polyline = PolylineBuilder.CreatePolyline(pts); + polyline = PolylineBuilderEx.CreatePolyline(pts); // polyline.HasZ = true // polyline.Length3D = 10 // polyline.Length = 0 - MapPoint result = GeometryEngine.Instance.MovePointAlongLine(polyline, 2, false, 0, SegmentExtension.NoExtension); + MapPoint result = GeometryEngine.Instance.MovePointAlongLine(polyline, 2, false, 0, SegmentExtensionType.NoExtension); // result = 5, 5, 2 // polyline with length2d = 0 and length3d = 0 - MapPoint pt5 = MapPointBuilder.CreateMapPoint(5, 5, 10); - MapPoint pt6 = MapPointBuilder.CreateMapPoint(5, 5, 10); + MapPoint pt5 = MapPointBuilderEx.CreateMapPoint(5, 5, 10); + MapPoint pt6 = MapPointBuilderEx.CreateMapPoint(5, 5, 10); pts.Clear(); pts.Add(pt5); pts.Add(pt6); - polyline = PolylineBuilder.CreatePolyline(pts); + polyline = PolylineBuilderEx.CreatePolyline(pts); // polyline.HasZ = true // polyline.Length3D = 0 // polyline.Length = 0 - result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtension.NoExtension); + result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtensionType.NoExtension); // result = 5, 5, 10 - result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtension.ExtendEmbeddedAtFrom); + result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtensionType.ExtendEmbeddedAtFrom); // result = 5, 5, 10 // polyline with Z and M List inputPoints = new List() { - MapPointBuilder.CreateMapPoint(1, 2, 3, 4), - MapPointBuilder.CreateMapPoint(1, 2, 33, 44), + MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4), + MapPointBuilderEx.CreateMapPoint(1, 2, 33, 44), }; - Polyline polylineZM = PolylineBuilder.CreatePolyline(inputPoints, SpatialReferences.WGS84); + Polyline polylineZM = PolylineBuilderEx.CreatePolyline(inputPoints, SpatialReferences.WGS84); // polylineZM.HasZ = true // polylineZM.HasM = true // ratio = true, no offset - MapPoint pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.5, true, 0, SegmentExtension.NoExtension); + MapPoint pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.5, true, 0, SegmentExtensionType.NoExtension); // pointAlong = 1, 2, 18, 24 // ratio = true with offset - pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.2, true, 2.23606797749979, SegmentExtension.NoExtension); + pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.2, true, 2.23606797749979, SegmentExtensionType.NoExtension); // pointAlong = 1, 2, 9, 12 #endregion } @@ -2262,8 +2265,8 @@ public void MultipartToSinglePart() { Polygon multipartPolygon = null; - // cref: Separate components of a geometry into single component geometries;ArcGIS.Core.Geometry.GeometryEngine.MultipartToSinglePart(ArcGIS.Core.Geometry.Geometry) - // cref: Separate components of a geometry into single component geometries;ArcGIS.Core.Geometry.IGeometryEngine.MultipartToSinglePart(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.MultipartToSinglePart(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.MultipartToSinglePart(ArcGIS.Core.Geometry.Geometry) #region Separate components of a geometry into single component geometries List coords2D = new List() @@ -2274,7 +2277,7 @@ public void MultipartToSinglePart() new Coordinate2D(-10, 3) }; - Multipoint multipoint = MultipointBuilder.CreateMultipoint(coords2D, SpatialReferences.WGS84); + Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(coords2D, SpatialReferences.WGS84); IReadOnlyList result = GeometryEngine.Instance.MultipartToSinglePart(multipoint); // result.Count = 4, @@ -2285,12 +2288,13 @@ public void MultipartToSinglePart() // create a bag of geometries - Polygon polygon = PolygonBuilder.CreatePolygon(coords2D, SpatialReferences.WGS84); - GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(new List() { multipoint, polygon }); - // bag.PartCount = 2 + Polygon polygon = PolygonBuilderEx.CreatePolygon(coords2D, SpatialReferences.WGS84); + //At 2.x - GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(new List() { multipoint, polygon }); + var bag = GeometryBagBuilderEx.CreateGeometryBag(new List() { multipoint, polygon }); + // bag.PartCount = =2 result = GeometryEngine.Instance.MultipartToSinglePart(bag); - // result.Count = 2 + // result.Count == 2 // result[0] is MultiPoint // result[1] is Polygon @@ -2299,14 +2303,14 @@ public void MultipartToSinglePart() public void NearestPoint_NearestVertex() { - // cref: Nearest Point versus Nearest Vertex;ArcGIS.Core.Geometry.GeometryEngine.NearestPoint(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) - // cref: Nearest Point versus Nearest Vertex;ArcGIS.Core.Geometry.GeometryEngine.NearestVertex(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) - // cref: Nearest Point versus Nearest Vertex;ArcGIS.Core.Geometry.IGeometryEngine.NearestPoint(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) - // cref: Nearest Point versus Nearest Vertex;ArcGIS.Core.Geometry.IGeometryEngine.NearestVertex(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.GeometryEngine.NearestPoint(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.GeometryEngine.NearestVertex(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.NearestPoint(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.NearestVertex(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) #region Nearest Point versus Nearest Vertex SpatialReference sr = SpatialReferences.WGS84; - MapPoint pt = MapPointBuilder.CreateMapPoint(5, 5, sr); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(5, 5, sr); List coords = new List() { @@ -2317,7 +2321,7 @@ public void NearestPoint_NearestVertex() new Coordinate2D(10, 1) }; - Polygon polygon = PolygonBuilder.CreatePolygon(coords); + Polygon polygon = PolygonBuilderEx.CreatePolygon(coords); // find the nearest point in the polygon geomtry to the pt ProximityResult result = GeometryEngine.Instance.NearestPoint(polygon, pt); @@ -2341,13 +2345,13 @@ public void NearestPoint_NearestVertex() public void NearestPoint3D() { - // cref: Determine Nearest Point in 3D;ArcGIS.Core.Geometry.GeometryEngine.NearestPoint3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) - // cref: Determine Nearest Point in 3D;ArcGIS.Core.Geometry.IGeometryEngine.NearestPoint3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.GeometryEngine.NearestPoint3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.NearestPoint3D(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint) #region Determine Nearest Point in 3D - MapPoint pt1 = MapPointBuilder.CreateMapPoint(1, 1, 1); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(2, 2, 2); - MapPoint pt3 = MapPointBuilder.CreateMapPoint(10, 2, 1); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1, 1, 1); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2, 2, 2); + MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(10, 2, 1); // // test pt1 to pt2 @@ -2363,7 +2367,7 @@ public void NearestPoint3D() // // multipoint built from pt1, pt2. should be closer to pt2 // - Multipoint multipoint = MultipointBuilder.CreateMultipoint(new List() { pt1, pt2 }); + Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(new List() { pt1, pt2 }); result = GeometryEngine.Instance.NearestPoint3D(multipoint, pt3); // result.Point = 2, 2, 2 // result.Distance = Math.Sqrt(65) @@ -2376,15 +2380,15 @@ public void NearestPoint3D() public void Offset() { - // cref: Calculate a geometry offset from the source;ArcGIS.Core.Geometry.GeometryEngine.Offset(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.OffsetType,System.Double) - // cref: Calculate a geometry offset from the source;ArcGIS.Core.Geometry.IGeometryEngine.Offset(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.OffsetType,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Offset(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.OffsetType,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Offset(ArcGIS.Core.Geometry.Geometry,System.Double,ArcGIS.Core.Geometry.OffsetType,System.Double) #region Calculate a geometry offset from the source List linePts = new List(); - linePts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84)); - linePts.Add(MapPointBuilder.CreateMapPoint(10.0, 1.0, SpatialReferences.WGS84)); + linePts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84)); + linePts.Add(MapPointBuilderEx.CreateMapPoint(10.0, 1.0, SpatialReferences.WGS84)); - Polyline polyline = PolylineBuilder.CreatePolyline(linePts); + Polyline polyline = PolylineBuilderEx.CreatePolyline(linePts); Geometry g = GeometryEngine.Instance.Offset(polyline, 10, OffsetType.Square, 0); Polyline gResult = g as Polyline; @@ -2406,9 +2410,9 @@ public void Offset() Coordinate2D toPt = new Coordinate2D(1, 2); Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2); - EllipticArcSegment circularArc = EllipticArcBuilder.CreateEllipticArcSegment(fromPt.ToMapPoint(), toPt.ToMapPoint(), interiorPt); + EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt.ToMapPoint(), toPt.ToMapPoint(), interiorPt); - polyline = PolylineBuilder.CreatePolyline(circularArc); + polyline = PolylineBuilderEx.CreatePolyline(circularArc); g = GeometryEngine.Instance.Offset(polyline, -0.25, OffsetType.Miter, 0.5); gResult = g as Polyline; @@ -2420,12 +2424,12 @@ public void Offset() // offset for a polygon // List list = new List(); - list.Add(MapPointBuilder.CreateMapPoint(10.0, 10.0, SpatialReferences.WGS84)); - list.Add(MapPointBuilder.CreateMapPoint(10.0, 20.0, SpatialReferences.WGS84)); - list.Add(MapPointBuilder.CreateMapPoint(20.0, 20.0, SpatialReferences.WGS84)); - list.Add(MapPointBuilder.CreateMapPoint(20.0, 10.0, SpatialReferences.WGS84)); + list.Add(MapPointBuilderEx.CreateMapPoint(10.0, 10.0, SpatialReferences.WGS84)); + list.Add(MapPointBuilderEx.CreateMapPoint(10.0, 20.0, SpatialReferences.WGS84)); + list.Add(MapPointBuilderEx.CreateMapPoint(20.0, 20.0, SpatialReferences.WGS84)); + list.Add(MapPointBuilderEx.CreateMapPoint(20.0, 10.0, SpatialReferences.WGS84)); - Polygon polygon = PolygonBuilder.CreatePolygon(list); + Polygon polygon = PolygonBuilderEx.CreatePolygon(list); g = GeometryEngine.Instance.Offset(polygon, 2, OffsetType.Square, 0); Polygon gPolygon = g as Polygon; @@ -2441,14 +2445,14 @@ public void Offset() public void Overlaps() { - // cref: Determine if geometries overlap;ArcGIS.Core.Geometry.GeometryEngine.Overlaps(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Determine if geometries overlap;ArcGIS.Core.Geometry.IGeometryEngine.Overlaps(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Overlaps(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Overlaps(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Determine if geometries overlap - MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.5, 1.5); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(1.25, 1.75); - MapPoint pt3 = MapPointBuilder.CreateMapPoint(3, 1.5); - MapPoint pt4 = MapPointBuilder.CreateMapPoint(1.5, 2); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1.5, 1.5); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(1.25, 1.75); + MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(3, 1.5); + MapPoint pt4 = MapPointBuilderEx.CreateMapPoint(1.5, 2); // // point and point overlap @@ -2471,14 +2475,14 @@ public void Overlaps() // // pt and line overlap // - Polyline polyline = PolylineBuilder.CreatePolyline(pts); + Polyline polyline = PolylineBuilderEx.CreatePolyline(pts); bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline); // isSimple = true overlaps = GeometryEngine.Instance.Overlaps(polyline, pt1); // overlaps = false // // line and line // - Polyline polyline2 = PolylineBuilder.CreatePolyline(pts2); + Polyline polyline2 = PolylineBuilderEx.CreatePolyline(pts2); isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline2); // isSimple = true overlaps = GeometryEngine.Instance.Overlaps(polyline, polyline2); // overlaps = true @@ -2487,31 +2491,31 @@ public void Overlaps() public void Project() { - // cref: Project from WGS84 to WebMercator;ArcGIS.Core.Geometry.GeometryEngine.Project(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.SpatialReference) - // cref: Project from WGS84 to WebMercator;ArcGIS.Core.Geometry.IGeometryEngine.Project(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.SpatialReference) - // cref: Project from WGS84 to WebMercator;ArcGIS.Core.Geometry.SpatialReferences.WebMercator + // cref: ArcGIS.Core.Geometry.GeometryEngine.Project(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Project(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.SpatialReferences.WebMercator #region Project from WGS84 to WebMercator - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0, SpatialReferences.WGS84); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 3.0, SpatialReferences.WGS84); Geometry result = GeometryEngine.Instance.Project(pt, SpatialReferences.WebMercator); MapPoint projectedPt = result as MapPoint; #endregion - // cref: Project from WGS84;ArcGIS.Core.Geometry.GeometryEngine.IsSimpleAsFeature(ArcGIS.Core.Geometry.Geometry,System.Boolean) - // cref: Project from WGS84;ArcGIS.Core.Geometry.GeometryEngine.Project(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.SpatialReference) - // cref: Project from WGS84;ArcGIS.Core.Geometry.IGeometryEngine.IsSimpleAsFeature(ArcGIS.Core.Geometry.Geometry,System.Boolean) - // cref: Project from WGS84;ArcGIS.Core.Geometry.IGeometryEngine.Project(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.SpatialReference) - // cref: Project from WGS84;ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.Int32) + // cref: ArcGIS.Core.Geometry.GeometryEngine.IsSimpleAsFeature(ArcGIS.Core.Geometry.Geometry,System.Boolean) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.IsSimpleAsFeature(ArcGIS.Core.Geometry.Geometry,System.Boolean) + // cref: ArcGIS.Core.Geometry.SpatialReferenceBuilder.CreateSpatialReference(System.Int32) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Project(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.SpatialReference) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Project(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.SpatialReference) #region Project from WGS84 // create the polygon List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84)); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84)); - pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84)); - pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0, SpatialReferences.WGS84)); + pts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0, SpatialReferences.WGS84)); + pts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0, SpatialReferences.WGS84)); - Polygon polygon = PolygonBuilder.CreatePolygon(pts); + Polygon polygon = PolygonBuilderEx.CreatePolygon(pts); // ensure it is simple bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polygon); @@ -2525,58 +2529,58 @@ public void Project() public void QueryNormal() { - // cref: QueryNormal;ArcGIS.Core.Geometry.GeometryEngine.QueryNormal(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) - // cref: QueryNormal;ArcGIS.Core.Geometry.GeometryEngine.QueryNormal(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) - // cref: QueryNormal;ArcGIS.Core.Geometry.IGeometryEngine.QueryNormal(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) - // cref: QueryNormal;ArcGIS.Core.Geometry.IGeometryEngine.QueryNormal(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.QueryNormal(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.QueryNormal(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.QueryNormal(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.QueryNormal(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) #region QueryNormal string json = "{\"curvePaths\":[[[-13046586.8335,4036570.6796000004]," + "{\"c\":[[-13046645.107099999,4037152.5873000026]," + "[-13046132.776277589,4036932.1325614937]]}]],\"spatialReference\":{\"wkid\":3857}}"; - Polyline polyline = PolylineBuilder.FromJson(json); + Polyline polyline = PolylineBuilderEx.FromJson(json); EllipticArcSegment arc = polyline.Parts[0][0] as EllipticArcSegment; // No extension, distanceAlongCurve = 0.5 // use the polyline - Polyline poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtension.NoExtension, 0.5, AsRatioOrLength.AsRatio, 1000); + Polyline poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtensionType.NoExtension, 0.5, AsRatioOrLength.AsRatio, 1000); // or a segment - LineSegment seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtension.NoExtension, 0.5, AsRatioOrLength.AsRatio, 1000); + LineSegment seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtensionType.NoExtension, 0.5, AsRatioOrLength.AsRatio, 1000); // TangentAtFrom, distanceAlongCurve = -1.2 - poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtension.ExtendTangentAtFrom, -1.2, AsRatioOrLength.AsRatio, 1000); - seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtension.ExtendTangentAtFrom, -1.2, AsRatioOrLength.AsRatio, 1000); + poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtensionType.ExtendTangentAtFrom, -1.2, AsRatioOrLength.AsRatio, 1000); + seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtensionType.ExtendTangentAtFrom, -1.2, AsRatioOrLength.AsRatio, 1000); // TangentAtTo (ignored because distanceAlongCurve < 0), distanceAlongCurve = -1.2 - poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtension.ExtendTangentAtTo, -1.2, AsRatioOrLength.AsRatio, 1000); - seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtension.ExtendTangentAtTo, -1.2, AsRatioOrLength.AsRatio, 1000); + poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtensionType.ExtendTangentAtTo, -1.2, AsRatioOrLength.AsRatio, 1000); + seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtensionType.ExtendTangentAtTo, -1.2, AsRatioOrLength.AsRatio, 1000); // TangentAtTo, distanceAlongCurve = 1.2 - poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtension.ExtendTangentAtTo, 1.2, AsRatioOrLength.AsRatio, 1000); - seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtension.ExtendTangentAtTo, 1.2, AsRatioOrLength.AsRatio, 1000); + poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtensionType.ExtendTangentAtTo, 1.2, AsRatioOrLength.AsRatio, 1000); + seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtensionType.ExtendTangentAtTo, 1.2, AsRatioOrLength.AsRatio, 1000); // TangentAtFrom (ignored because distanceAlongCurve > 0), distanceAlongCurve = 1.2 - poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtension.ExtendTangentAtFrom, 1.2, AsRatioOrLength.AsRatio, 1000); - seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtension.ExtendTangentAtFrom, 1.2, AsRatioOrLength.AsRatio, 1000); + poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtensionType.ExtendTangentAtFrom, 1.2, AsRatioOrLength.AsRatio, 1000); + seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtensionType.ExtendTangentAtFrom, 1.2, AsRatioOrLength.AsRatio, 1000); // EmbeddedAtTo, distanceAlongCurve = 1.2 - poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtension.ExtendEmbeddedAtTo, 1.2, AsRatioOrLength.AsRatio, 1000); - seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtension.ExtendEmbeddedAtTo, 1.2, AsRatioOrLength.AsRatio, 1000); + poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtensionType.ExtendEmbeddedAtTo, 1.2, AsRatioOrLength.AsRatio, 1000); + seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtensionType.ExtendEmbeddedAtTo, 1.2, AsRatioOrLength.AsRatio, 1000); // EmbeddedAtFrom, distanceAlongCurve = -0.2 - poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtension.ExtendEmbeddedAtFrom, -0.2, AsRatioOrLength.AsRatio, 1000); - seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtension.ExtendEmbeddedAtFrom, -0.2, AsRatioOrLength.AsRatio, 1000); + poly_normal = GeometryEngine.Instance.QueryNormal(polyline, SegmentExtensionType.ExtendEmbeddedAtFrom, -0.2, AsRatioOrLength.AsRatio, 1000); + seg_normal = GeometryEngine.Instance.QueryNormal(arc, SegmentExtensionType.ExtendEmbeddedAtFrom, -0.2, AsRatioOrLength.AsRatio, 1000); #endregion } public void QueryPoint() { - // cref: QueryPoint;ArcGIS.Core.Geometry.GeometryEngine.QueryPoint(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) - // cref: QueryPoint;ArcGIS.Core.Geometry.GeometryEngine.QueryPoint(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) - // cref: QueryPoint;ArcGIS.Core.Geometry.IGeometryEngine.QueryPoint(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) - // cref: QueryPoint;ArcGIS.Core.Geometry.IGeometryEngine.QueryPoint(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.GeometryEngine.QueryPoint(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.GeometryEngine.QueryPoint(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.QueryPoint(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.QueryPoint(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength) #region QueryPoint SpatialReference sr = SpatialReferences.WGS84; @@ -2584,47 +2588,47 @@ public void QueryPoint() // Horizontal line segment Coordinate2D start = new Coordinate2D(1, 1); Coordinate2D end = new Coordinate2D(11, 1); - LineSegment line = LineBuilder.CreateLineSegment(start, end, sr); + LineSegment line = LineBuilderEx.CreateLineSegment(start, end, sr); - Polyline polyline = PolylineBuilder.CreatePolyline(line); + Polyline polyline = PolylineBuilderEx.CreatePolyline(line); // Don't extend the segment - MapPoint outPoint = GeometryEngine.Instance.QueryPoint(polyline, SegmentExtension.NoExtension, 1.0, AsRatioOrLength.AsLength); + MapPoint outPoint = GeometryEngine.Instance.QueryPoint(polyline, SegmentExtensionType.NoExtension, 1.0, AsRatioOrLength.AsLength); // outPoint = (2, 1) // or the segment - MapPoint outPoint_seg = GeometryEngine.Instance.QueryPoint(line, SegmentExtension.NoExtension, 1.0, AsRatioOrLength.AsLength); + MapPoint outPoint_seg = GeometryEngine.Instance.QueryPoint(line, SegmentExtensionType.NoExtension, 1.0, AsRatioOrLength.AsLength); // outPoint_seg = (2, 1) // Extend infinitely in both directions - outPoint = GeometryEngine.Instance.QueryPoint(polyline, SegmentExtension.ExtendTangents, 1.5, AsRatioOrLength.AsRatio); + outPoint = GeometryEngine.Instance.QueryPoint(polyline, SegmentExtensionType.ExtendTangents, 1.5, AsRatioOrLength.AsRatio); // outPoint = (16, 1) - outPoint_seg = GeometryEngine.Instance.QueryPoint(line, SegmentExtension.ExtendTangents, 1.5, AsRatioOrLength.AsRatio); + outPoint_seg = GeometryEngine.Instance.QueryPoint(line, SegmentExtensionType.ExtendTangents, 1.5, AsRatioOrLength.AsRatio); // outPoint_seg = (16, 1) #endregion } public void QueryPointAndDistance() { - // cref: QueryPointAndDistance;ArcGIS.Core.Geometry.GeometryEngine.QueryPointAndDistance(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtension,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@,ArcGIS.Core.Geometry.LeftOrRightSide@) - // cref: QueryPointAndDistance;ArcGIS.Core.Geometry.GeometryEngine.QueryPointAndDistance(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtension,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@,ArcGIS.Core.Geometry.LeftOrRightSide@) - // cref: QueryPointAndDistance;ArcGIS.Core.Geometry.IGeometryEngine.QueryPointAndDistance(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtension,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@,ArcGIS.Core.Geometry.LeftOrRightSide@) - // cref: QueryPointAndDistance;ArcGIS.Core.Geometry.IGeometryEngine.QueryPointAndDistance(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtension,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@,ArcGIS.Core.Geometry.LeftOrRightSide@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.QueryPointAndDistance(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtensionType,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@,ArcGIS.Core.Geometry.LeftOrRightSide@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.QueryPointAndDistance(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtensionType,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@,ArcGIS.Core.Geometry.LeftOrRightSide@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.QueryPointAndDistance(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtensionType,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@,ArcGIS.Core.Geometry.LeftOrRightSide@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.QueryPointAndDistance(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtensionType,ArcGIS.Core.Geometry.MapPoint,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double@,System.Double@,ArcGIS.Core.Geometry.LeftOrRightSide@) #region QueryPointAndDistance // Horizontal line segment List linePts = new List(); - linePts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84)); - linePts.Add(MapPointBuilder.CreateMapPoint(11.0, 1.0, SpatialReferences.WGS84)); - Polyline polyline = PolylineBuilder.CreatePolyline(linePts); + linePts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84)); + linePts.Add(MapPointBuilderEx.CreateMapPoint(11.0, 1.0, SpatialReferences.WGS84)); + Polyline polyline = PolylineBuilderEx.CreatePolyline(linePts); bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline); // Don't extent the segment - SegmentExtension extension = SegmentExtension.NoExtension; + SegmentExtensionType extension = SegmentExtensionType.NoExtension; // A point on the line segment - MapPoint inPoint = MapPointBuilder.CreateMapPoint(2, 1, SpatialReferences.WGS84); + MapPoint inPoint = MapPointBuilderEx.CreateMapPoint(2, 1, SpatialReferences.WGS84); double distanceAlongCurve, distanceFromCurve; LeftOrRightSide whichSide; @@ -2638,10 +2642,10 @@ public void QueryPointAndDistance() // Extend infinitely in both directions - extension = SegmentExtension.ExtendTangents; + extension = SegmentExtensionType.ExtendTangents; // A point on the left side - inPoint = MapPointBuilder.CreateMapPoint(16, 6, SpatialReferences.WGS84); + inPoint = MapPointBuilderEx.CreateMapPoint(16, 6, SpatialReferences.WGS84); asRatioOrLength = AsRatioOrLength.AsRatio; outPoint = GeometryEngine.Instance.QueryPointAndDistance(polyline, extension, inPoint, asRatioOrLength, out distanceAlongCurve, out distanceFromCurve, out whichSide); @@ -2655,32 +2659,32 @@ public void QueryPointAndDistance() public void QueryTangent() { - // cref: QueryTangent;ArcGIS.Core.Geometry.GeometryEngine.QueryTangent(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) - // cref: QueryTangent;ArcGIS.Core.Geometry.GeometryEngine.QueryTangent(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) - // cref: QueryTangent;ArcGIS.Core.Geometry.IGeometryEngine.QueryTangent(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) - // cref: QueryTangent;ArcGIS.Core.Geometry.IGeometryEngine.QueryTangent(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtension,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.QueryTangent(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.QueryTangent(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.QueryTangent(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.QueryTangent(ArcGIS.Core.Geometry.Segment,ArcGIS.Core.Geometry.SegmentExtensionType,System.Double,ArcGIS.Core.Geometry.AsRatioOrLength,System.Double) #region QueryTangent - LineSegment line = LineBuilder.CreateLineSegment(new Coordinate2D(0, 0), new Coordinate2D(1, 0)); + LineSegment line = LineBuilderEx.CreateLineSegment(new Coordinate2D(0, 0), new Coordinate2D(1, 0)); // No extension, distanceAlongCurve = 0.5 - LineSegment tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtension.NoExtension, 0.5, AsRatioOrLength.AsRatio, 1); + LineSegment tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtensionType.NoExtension, 0.5, AsRatioOrLength.AsRatio, 1); // tangent.StartCoordinate = (0.5, 0.0) // tangent.EndCoordinate = (1.5, 0.0) - tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtension.NoExtension, 1.5, AsRatioOrLength.AsLength, 1); + tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtensionType.NoExtension, 1.5, AsRatioOrLength.AsLength, 1); // tangent.StartCoordinate = (1.0, 0.0) // tangent.EndCoordinate = (2.0, 0.0) - tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtension.ExtendTangentAtTo, 1.5, AsRatioOrLength.AsLength, 1); + tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtensionType.ExtendTangentAtTo, 1.5, AsRatioOrLength.AsLength, 1); // tangent.StartCoordinate = (1.5, 0.0) // tangent.EndCoordinate = (2.5, 0.0) - tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtension.ExtendTangentAtFrom, -1.5, AsRatioOrLength.AsLength, 1); + tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtensionType.ExtendTangentAtFrom, -1.5, AsRatioOrLength.AsLength, 1); // tangent.StartCoordinate = (-1.5, 0.0) // tangent.EndCoordinate = (-0.5, 0.0) - tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtension.ExtendTangentAtFrom, -0.5, AsRatioOrLength.AsRatio, 1); + tangent = GeometryEngine.Instance.QueryTangent(line, SegmentExtensionType.ExtendTangentAtFrom, -0.5, AsRatioOrLength.AsRatio, 1); // tangent.StartCoordinate = (-0.5, 0.0) // tangent.EndCoordinate = (0.5, 0.0) #endregion @@ -2688,15 +2692,15 @@ public void QueryTangent() public void ReflectAboutLine() { - // cref: Reflect a polygon about a line;ArcGIS.Core.Geometry.GeometryEngine.ReflectAboutLine(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LineSegment) - // cref: Reflect a polygon about a line;ArcGIS.Core.Geometry.IGeometryEngine.ReflectAboutLine(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LineSegment) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ReflectAboutLine(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LineSegment) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ReflectAboutLine(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LineSegment) #region Reflect a polygon about a line SpatialReference sr = SpatialReferences.WGS84; Coordinate2D start = new Coordinate2D(0, 0); Coordinate2D end = new Coordinate2D(4, 4); - LineSegment line = LineBuilder.CreateLineSegment(start, end, sr); + LineSegment line = LineBuilderEx.CreateLineSegment(start, end, sr); Coordinate2D[] coords = new Coordinate2D[] { @@ -2706,7 +2710,7 @@ public void ReflectAboutLine() new Coordinate2D(-1, 2) }; - Polygon polygon = PolygonBuilder.CreatePolygon(coords, sr); + Polygon polygon = PolygonBuilderEx.CreatePolygon(coords, sr); // reflect a polygon about the line Polygon reflectedPolygon = GeometryEngine.Instance.ReflectAboutLine(polygon, line) as Polygon; @@ -2718,20 +2722,20 @@ public void ReflectAboutLine() public void Related() { - // cref: Determine relationship between two geometries;ArcGIS.Core.Geometry.GeometryEngine.Relate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,System.String) - // cref: Determine relationship between two geometries;ArcGIS.Core.Geometry.IGeometryEngine.Relate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,System.String) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Relate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,System.String) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Relate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry,System.String) #region Determine relationship between two geometries // set up some geometries // points - MapPoint point0 = MapPointBuilder.CreateMapPoint(0, 0, SpatialReferences.WGS84); - MapPoint point1 = MapPointBuilder.CreateMapPoint(1, 1, SpatialReferences.WGS84); - MapPoint point2 = MapPointBuilder.CreateMapPoint(-5, 5, SpatialReferences.WGS84); + MapPoint point0 = MapPointBuilderEx.CreateMapPoint(0, 0, SpatialReferences.WGS84); + MapPoint point1 = MapPointBuilderEx.CreateMapPoint(1, 1, SpatialReferences.WGS84); + MapPoint point2 = MapPointBuilderEx.CreateMapPoint(-5, 5, SpatialReferences.WGS84); // multipoint List points = new List() { point0, point1, point2 }; - Multipoint multipoint = MultipointBuilder.CreateMultipoint(points, SpatialReferences.WGS84); + Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(points, SpatialReferences.WGS84); // polygon List polygonCoords = new List() @@ -2741,33 +2745,33 @@ public void Related() new Coordinate2D(10, 0), new Coordinate2D(-10, 0) }; - Polygon polygon = PolygonBuilder.CreatePolygon(polygonCoords, SpatialReferences.WGS84); + Polygon polygon = PolygonBuilderEx.CreatePolygon(polygonCoords, SpatialReferences.WGS84); // polylines - Polyline polyline1 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(-9.1, 0.1), new Coordinate2D(0, 9)), SpatialReferences.WGS84); - Polyline polyline2 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(-5, 5), new Coordinate2D(0, 5)), SpatialReferences.WGS84); - Polyline polyline3 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(2.09, -2.04), new Coordinate2D(5, 10)), SpatialReferences.WGS84); - Polyline polyline4 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(10, -5), new Coordinate2D(10, 5)), SpatialReferences.WGS84); + Polyline polyline1 = PolylineBuilderEx.CreatePolyline(LineBuilderEx.CreateLineSegment(new Coordinate2D(-9.1, 0.1), new Coordinate2D(0, 9)), SpatialReferences.WGS84); + Polyline polyline2 = PolylineBuilderEx.CreatePolyline(LineBuilderEx.CreateLineSegment(new Coordinate2D(-5, 5), new Coordinate2D(0, 5)), SpatialReferences.WGS84); + Polyline polyline3 = PolylineBuilderEx.CreatePolyline(LineBuilderEx.CreateLineSegment(new Coordinate2D(2.09, -2.04), new Coordinate2D(5, 10)), SpatialReferences.WGS84); + Polyline polyline4 = PolylineBuilderEx.CreatePolyline(LineBuilderEx.CreateLineSegment(new Coordinate2D(10, -5), new Coordinate2D(10, 5)), SpatialReferences.WGS84); List segments = new List() { - LineBuilder.CreateLineSegment(new Coordinate2D(5.05, -2.87), new Coordinate2D(6.35, 1.57)), - LineBuilder.CreateLineSegment(new Coordinate2D(6.35, 1.57), new Coordinate2D(4.13, 2.59)), - LineBuilder.CreateLineSegment(new Coordinate2D(4.13, 2.59), new Coordinate2D(5, 5)) + LineBuilderEx.CreateLineSegment(new Coordinate2D(5.05, -2.87), new Coordinate2D(6.35, 1.57)), + LineBuilderEx.CreateLineSegment(new Coordinate2D(6.35, 1.57), new Coordinate2D(4.13, 2.59)), + LineBuilderEx.CreateLineSegment(new Coordinate2D(4.13, 2.59), new Coordinate2D(5, 5)) }; - Polyline polyline5 = PolylineBuilder.CreatePolyline(segments, SpatialReferences.WGS84); + Polyline polyline5 = PolylineBuilderEx.CreatePolyline(segments, SpatialReferences.WGS84); - segments.Add(LineBuilder.CreateLineSegment(new Coordinate2D(5, 5), new Coordinate2D(10, 10))); + segments.Add(LineBuilderEx.CreateLineSegment(new Coordinate2D(5, 5), new Coordinate2D(10, 10))); - Polyline polyline6 = PolylineBuilder.CreatePolyline(segments, SpatialReferences.WGS84); - Polyline polyline7 = PolylineBuilder.CreatePolyline(polyline5); - Polyline polyline8 = PolylineBuilder.CreatePolyline(LineBuilder.CreateLineSegment(new Coordinate2D(5, 5), new Coordinate2D(10, 10)), SpatialReferences.WGS84); + Polyline polyline6 = PolylineBuilderEx.CreatePolyline(segments, SpatialReferences.WGS84); + Polyline polyline7 = PolylineBuilderEx.CreatePolyline(polyline5); + Polyline polyline8 = PolylineBuilderEx.CreatePolyline(LineBuilderEx.CreateLineSegment(new Coordinate2D(5, 5), new Coordinate2D(10, 10)), SpatialReferences.WGS84); segments.Clear(); - segments.Add(LineBuilder.CreateLineSegment(new Coordinate2D(0.6, 3.5), new Coordinate2D(0.7, 7))); - segments.Add(LineBuilder.CreateLineSegment(new Coordinate2D(0.7, 7), new Coordinate2D(3, 9))); + segments.Add(LineBuilderEx.CreateLineSegment(new Coordinate2D(0.6, 3.5), new Coordinate2D(0.7, 7))); + segments.Add(LineBuilderEx.CreateLineSegment(new Coordinate2D(0.7, 7), new Coordinate2D(3, 9))); - Polyline polyline9 = PolylineBuilder.CreatePolyline(segments, SpatialReferences.WGS84); + Polyline polyline9 = PolylineBuilderEx.CreatePolyline(segments, SpatialReferences.WGS84); // now do the Related tests @@ -2810,8 +2814,8 @@ public void Related() public void ReplaceNaNZs() { - // cref: Replace NaN Zs in a polygon;ArcGIS.Core.Geometry.GeometryEngine.ReplaceNaNZs(ArcGIS.Core.Geometry.Geometry,System.Double) - // cref: Replace NaN Zs in a polygon;ArcGIS.Core.Geometry.IGeometryEngine.ReplaceNaNZs(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ReplaceNaNZs(ArcGIS.Core.Geometry.Geometry,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ReplaceNaNZs(ArcGIS.Core.Geometry.Geometry,System.Double) #region Replace NaN Zs in a polygon List coordsZ = new List() @@ -2821,7 +2825,7 @@ public void ReplaceNaNZs() new Coordinate3D(7, 8, double.NaN) }; - Polygon polygon = PolygonBuilder.CreatePolygon(coordsZ); + Polygon polygon = PolygonBuilderEx.CreatePolygon(coordsZ); // polygon.HasZ = true Polygon polygonZReplaced = GeometryEngine.Instance.ReplaceNaNZs(polygon, -1) as Polygon; @@ -2834,8 +2838,8 @@ public void ReplaceNaNZs() public void Reshape() { - // cref: Reshape a polygon;ArcGIS.Core.Geometry.GeometryEngine.Reshape(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Polyline) - // cref: Reshape a polygon;ArcGIS.Core.Geometry.IGeometryEngine.Reshape(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Polyline) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Reshape(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Polyline) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Reshape(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.Polyline) #region Reshape a polygon List polygon1Coords = new List() @@ -2855,8 +2859,8 @@ public void Reshape() }; SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(102010); - Polygon polygon1 = PolygonBuilder.CreatePolygon(polygon1Coords, sr); - Polyline reshaper = PolylineBuilder.CreatePolyline(reshaperCoords, sr); + Polygon polygon1 = PolygonBuilderEx.CreatePolygon(polygon1Coords, sr); + Polyline reshaper = PolylineBuilderEx.CreatePolyline(reshaperCoords, sr); Polygon outPolygon = GeometryEngine.Instance.Reshape(polygon1, reshaper) as Polygon; // outPolygon.PartCount = 1 @@ -2865,7 +2869,7 @@ public void Reshape() // segments.Count = 4 // outPolygon.PointCount = 5 - string json = GeometryEngine.Instance.ExportToJSON(JSONExportFlags.jsonExportSkipCRS, outPolygon); + string json = GeometryEngine.Instance.ExportToJson(JsonExportFlags.JsonExportSkipCRS, outPolygon); // json = "{\"rings\":[[[0,-11800],[0,-11000],[1000,-11000],[1000,-11800],[0,-11800]]]}"; @@ -2875,7 +2879,7 @@ public void Reshape() reshaperCoords.Add(new Coordinate2D(1000, 1000)); reshaperCoords.Add(new Coordinate2D(2000, 1000)); - reshaper = PolylineBuilder.CreatePolyline(reshaperCoords, sr); + reshaper = PolylineBuilderEx.CreatePolyline(reshaperCoords, sr); outPolygon = GeometryEngine.Instance.Reshape(polygon1, reshaper) as Polygon; // outPolygon = null @@ -2885,8 +2889,8 @@ public void Reshape() public void ReverseOrientation() { - // cref: Reverse the order of points in a Polygon;ArcGIS.Core.Geometry.GeometryEngine.ReverseOrientation(ArcGIS.Core.Geometry.Multipart) - // cref: Reverse the order of points in a Polygon;ArcGIS.Core.Geometry.IGeometryEngine.ReverseOrientation(ArcGIS.Core.Geometry.Multipart) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ReverseOrientation(ArcGIS.Core.Geometry.Multipart) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ReverseOrientation(ArcGIS.Core.Geometry.Multipart) #region Reverse the order of points in a Polygon List list2D = new List(); @@ -2895,7 +2899,7 @@ public void ReverseOrientation() list2D.Add(new Coordinate2D(2.0, 2.0)); list2D.Add(new Coordinate2D(2.0, 1.0)); - Polygon polygon = PolygonBuilder.CreatePolygon(list2D); + Polygon polygon = PolygonBuilderEx.CreatePolygon(list2D); Geometry g = GeometryEngine.Instance.ReverseOrientation(polygon); Polygon gPolygon = g as Polygon; @@ -2911,31 +2915,31 @@ public void ReverseOrientation() public void Rotate() { - // cref: Rotate a MapPoint;ArcGIS.Core.Geometry.GeometryEngine.Rotate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double) - // cref: Rotate a MapPoint;ArcGIS.Core.Geometry.IGeometryEngine.Rotate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Rotate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Rotate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double) #region Rotate a MapPoint - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0); - MapPoint rotatePt = MapPointBuilder.CreateMapPoint(3.0, 3.0); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 3.0); + MapPoint rotatePt = MapPointBuilderEx.CreateMapPoint(3.0, 3.0); Geometry result = GeometryEngine.Instance.Rotate(pt, rotatePt, Math.PI / 2); // result point is (3, 1) #endregion - // cref: Rotate a Polyline;ArcGIS.Core.Geometry.GeometryEngine.Rotate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double) - // cref: Rotate a Polyline;ArcGIS.Core.Geometry.IGeometryEngine.Rotate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Rotate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Rotate(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double) #region Rotate a Polyline // rotate a polyline - MapPoint fixedPt = MapPointBuilder.CreateMapPoint(3.0, 3.0); + MapPoint fixedPt = MapPointBuilderEx.CreateMapPoint(3.0, 3.0); List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 5.0)); - pts.Add(MapPointBuilder.CreateMapPoint(5, 5)); - pts.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0)); - Polyline polyline = PolylineBuilder.CreatePolyline(pts); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 5.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(5, 5)); + pts.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0)); + Polyline polyline = PolylineBuilderEx.CreatePolyline(pts); Polyline rotated = GeometryEngine.Instance.Rotate(polyline, fixedPt, Math.PI / 4) as Polyline; // rotate 45 deg #endregion @@ -2943,22 +2947,22 @@ public void Rotate() public void Scale() { - // cref: Scale a geometry;ArcGIS.Core.Geometry.GeometryEngine.Scale(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double) - // cref: Scale a geometry;ArcGIS.Core.Geometry.GeometryEngine.Scale(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double) - // cref: Scale a geometry;ArcGIS.Core.Geometry.IGeometryEngine.Scale(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double) - // cref: Scale a geometry;ArcGIS.Core.Geometry.IGeometryEngine.Scale(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Scale(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Scale(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Scale(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Scale(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.MapPoint,System.Double,System.Double) #region Scale a geometry List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3, 3, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3, 3, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0, 3.0)); - MapPoint midPt = MapPointBuilder.CreateMapPoint(1.5, 1.5); + MapPoint midPt = MapPointBuilderEx.CreateMapPoint(1.5, 1.5); // polyline - Polyline polyline = PolylineBuilder.CreatePolyline(pts); + Polyline polyline = PolylineBuilderEx.CreatePolyline(pts); // polyline.Length = 6 // polyline.Length3D = 0 Geometry g = GeometryEngine.Instance.Scale(polyline, midPt, 0.5, 0.5); @@ -2970,7 +2974,7 @@ public void Scale() // resultPolyline.Points[3] = 2.25, 1.25, 3 // 3D point - scale in 3d - MapPoint midPtZ = MapPointBuilder.CreateMapPoint(1.5, 1.5, 1); + MapPoint midPtZ = MapPointBuilderEx.CreateMapPoint(1.5, 1.5, 1); g = GeometryEngine.Instance.Scale(polyline, midPtZ, 0.5, 0.5, 0.25); resultPolyline = g as Polyline; // resultPolyline.Points[0] = 1.25, 1.25, 1.5 @@ -2983,8 +2987,8 @@ public void Scale() public void SetConstantZ() { - // cref: Set all Zs in a polyline;ArcGIS.Core.Geometry.GeometryEngine.SetConstantZ(ArcGIS.Core.Geometry.Multipart,System.Double) - // cref: Set all Zs in a polyline;ArcGIS.Core.Geometry.IGeometryEngine.SetConstantZ(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SetConstantZ(ArcGIS.Core.Geometry.Multipart,System.Double) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SetConstantZ(ArcGIS.Core.Geometry.Multipart,System.Double) #region Set all Zs in a polyline List coordsZ = new List() @@ -2994,7 +2998,7 @@ public void SetConstantZ() new Coordinate3D(7, 8, double.NaN) }; - Polyline polyline = PolylineBuilder.CreatePolyline(coordsZ); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coordsZ); // polyline.HasZ = true Polyline polylineSetZ = GeometryEngine.Instance.SetConstantZ(polyline, -1) as Polyline; @@ -3024,42 +3028,44 @@ public void SetConstantZ() public void ShapePreservingArea() { - // cref: Calculate area of geometry on surface of Earth's ellipsoid - ShapePreservingArea;ArcGIS.Core.Geometry.GeometryEngine.ShapePreservingArea(ArcGIS.Core.Geometry.Geometry) - // cref: Calculate area of geometry on surface of Earth's ellipsoid - ShapePreservingArea;ArcGIS.Core.Geometry.IGeometryEngine.ShapePreservingArea(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ShapePreservingArea(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.AreaUnit) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ShapePreservingArea(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ShapePreservingArea(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.AreaUnit) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ShapePreservingArea(ArcGIS.Core.Geometry.Geometry) #region Calculate area of geometry on surface of Earth's ellipsoid - ShapePreservingArea // pt - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0, SpatialReferences.WebMercator); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 3.0, SpatialReferences.WebMercator); double area = GeometryEngine.Instance.ShapePreservingArea(pt); // area = 0 List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3, 3, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3, 3, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0, 3.0)); // multipoint - Multipoint mPt = MultipointBuilder.CreateMultipoint(pts); + Multipoint mPt = MultipointBuilderEx.CreateMultipoint(pts); area = GeometryEngine.Instance.ShapePreservingArea(mPt); // area = 0 // polyline - Polyline polyline = PolylineBuilder.CreatePolyline(pts); + Polyline polyline = PolylineBuilderEx.CreatePolyline(pts); area = GeometryEngine.Instance.ShapePreservingArea(polyline); // area = 0 // polygon - Polygon polygon = PolygonBuilder.CreatePolygon(pts, SpatialReferences.WGS84); + Polygon polygon = PolygonBuilderEx.CreatePolygon(pts, SpatialReferences.WGS84); area = GeometryEngine.Instance.ShapePreservingArea(polygon); - polygon = PolygonBuilder.CreatePolygon(pts, SpatialReferences.WebMercator); + polygon = PolygonBuilderEx.CreatePolygon(pts, SpatialReferences.WebMercator); area = GeometryEngine.Instance.ShapePreservingArea(polygon); - polygon = PolygonBuilder.CreatePolygon(new[] + polygon = PolygonBuilderEx.CreatePolygon(new[] { - MapPointBuilder.CreateMapPoint( -170, 45), - MapPointBuilder.CreateMapPoint( 170, 45), - MapPointBuilder.CreateMapPoint( 170, -45), - MapPointBuilder.CreateMapPoint( -170, -54) + MapPointBuilderEx.CreateMapPoint( -170, 45), + MapPointBuilderEx.CreateMapPoint( 170, 45), + MapPointBuilderEx.CreateMapPoint( 170, -45), + MapPointBuilderEx.CreateMapPoint( -170, -54) }, SpatialReferences.WGS84); var area_meters = GeometryEngine.Instance.ShapePreservingArea(polygon);// , AreaUnits.SquareMeters); @@ -3073,38 +3079,40 @@ public void ShapePreservingArea() public void ShapePreservingLength() { - // cref: Calculate length of geometry on surface of Earth's ellipsoid - ShapePreservingLength;ArcGIS.Core.Geometry.GeometryEngine.ShapePreservingLength(ArcGIS.Core.Geometry.Geometry) - // cref: Calculate length of geometry on surface of Earth's ellipsoid - ShapePreservingLength;ArcGIS.Core.Geometry.IGeometryEngine.ShapePreservingLength(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ShapePreservingLength(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.GeometryEngine.ShapePreservingLength(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ShapePreservingLength(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.LinearUnit) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.ShapePreservingLength(ArcGIS.Core.Geometry.Geometry) #region Calculate length of geometry on surface of Earth's ellipsoid - ShapePreservingLength // pt - MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 3.0, SpatialReferences.WebMercator); + MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 3.0, SpatialReferences.WebMercator); double len = GeometryEngine.Instance.ShapePreservingLength(pt); // len = 0 List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 3.0, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3, 3, 3.0)); - pts.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3, 3, 3.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0, 3.0)); // multipoint - Multipoint mPt = MultipointBuilder.CreateMultipoint(pts); + Multipoint mPt = MultipointBuilderEx.CreateMultipoint(pts); len = GeometryEngine.Instance.ShapePreservingLength(mPt); // len = 0 // polyline - Polyline polyline = PolylineBuilder.CreatePolyline(pts, SpatialReferences.WGS84); + Polyline polyline = PolylineBuilderEx.CreatePolyline(pts, SpatialReferences.WGS84); len = GeometryEngine.Instance.ShapePreservingLength(polyline); // polygon - Polygon polygon = PolygonBuilder.CreatePolygon(pts, SpatialReferences.WGS84); + Polygon polygon = PolygonBuilderEx.CreatePolygon(pts, SpatialReferences.WGS84); len = GeometryEngine.Instance.ShapePreservingLength(polygon); - polyline = PolylineBuilder.CreatePolyline(new[] + polyline = PolylineBuilderEx.CreatePolyline(new[] { - MapPointBuilder.CreateMapPoint( -170, 0), - MapPointBuilder.CreateMapPoint( 170, 0) + MapPointBuilderEx.CreateMapPoint( -170, 0), + MapPointBuilderEx.CreateMapPoint( 170, 0) }, SpatialReferences.WGS84); @@ -3119,8 +3127,8 @@ public void ShapePreservingLength() public void SideBuffer() { - // cref: SideBuffer;ArcGIS.Core.Geometry.GeometryEngine.SideBuffer(ArcGIS.Core.Geometry.Polyline,System.Double,ArcGIS.Core.Geometry.LeftOrRightSide,ArcGIS.Core.Geometry.LineCapType) - // cref: SideBuffer;ArcGIS.Core.Geometry.IGeometryEngine.SideBuffer(ArcGIS.Core.Geometry.Polyline,System.Double,ArcGIS.Core.Geometry.LeftOrRightSide,ArcGIS.Core.Geometry.LineCapType) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SideBuffer(ArcGIS.Core.Geometry.Polyline,System.Double,ArcGIS.Core.Geometry.LeftOrRightSide,ArcGIS.Core.Geometry.LineCapType) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SideBuffer(ArcGIS.Core.Geometry.Polyline,System.Double,ArcGIS.Core.Geometry.LeftOrRightSide,ArcGIS.Core.Geometry.LineCapType) #region SideBuffer // right side, round caps @@ -3134,12 +3142,12 @@ public void SideBuffer() new Coordinate2D(1300, 5700) }; - Polyline polyline = PolylineBuilder.CreatePolyline(coords, sr); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords, sr); Polygon output = GeometryEngine.Instance.SideBuffer(polyline, 20, LeftOrRightSide.RightSide, LineCapType.Round) as Polygon; #endregion - // cref: SideBuffer Many;ArcGIS.Core.Geometry.GeometryEngine.SideBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Polyline},System.Double,ArcGIS.Core.Geometry.LeftOrRightSide,ArcGIS.Core.Geometry.LineCapType) - // cref: SideBuffer Many;ArcGIS.Core.Geometry.IGeometryEngine.SideBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Polyline},System.Double,ArcGIS.Core.Geometry.LeftOrRightSide,ArcGIS.Core.Geometry.LineCapType) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SideBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Polyline},System.Double,ArcGIS.Core.Geometry.LeftOrRightSide,ArcGIS.Core.Geometry.LineCapType) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SideBuffer(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Polyline},System.Double,ArcGIS.Core.Geometry.LeftOrRightSide,ArcGIS.Core.Geometry.LineCapType) #region SideBuffer Many SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(102010); @@ -3152,14 +3160,14 @@ public void SideBuffer() new Coordinate2D(1300, 5700) }; - Polyline polyline1 = PolylineBuilder.CreatePolyline(coordinates, spatialReference); + Polyline polyline1 = PolylineBuilderEx.CreatePolyline(coordinates, spatialReference); coordinates.Clear(); coordinates.Add(new Coordinate2D(1400, 6050)); coordinates.Add(new Coordinate2D(1600, 6150)); coordinates.Add(new Coordinate2D(1800, 6050)); - Polyline polyline2 = PolylineBuilder.CreatePolyline(coordinates, spatialReference); + Polyline polyline2 = PolylineBuilderEx.CreatePolyline(coordinates, spatialReference); List polylines = new List() { polyline1, polyline2 }; IReadOnlyList outGeometries = GeometryEngine.Instance.SideBuffer(polylines, 10, LeftOrRightSide.RightSide, LineCapType.Round); #endregion @@ -3167,11 +3175,11 @@ public void SideBuffer() public void SimplifyAsFeature() { - // cref: Simplify a polygon;ArcGIS.Core.Geometry.GeometryEngine.SimplifyAsFeature(ArcGIS.Core.Geometry.Geometry,System.Boolean) - // cref: Simplify a polygon;ArcGIS.Core.Geometry.IGeometryEngine.SimplifyAsFeature(ArcGIS.Core.Geometry.Geometry,System.Boolean) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SimplifyAsFeature(ArcGIS.Core.Geometry.Geometry,System.Boolean) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SimplifyAsFeature(ArcGIS.Core.Geometry.Geometry,System.Boolean) #region Simplify a polygon - var g1 = PolygonBuilder.FromJson("{\"rings\": [ [ [0, 0], [10, 0], [10, 10], [0, 10] ] ] }"); + var g1 = PolygonBuilderEx.FromJson("{\"rings\": [ [ [0, 0], [10, 0], [10, 10], [0, 10] ] ] }"); var result = GeometryEngine.Instance.Area(g1); // result = -100.0 - negative due to wrong ring orientation // simplify it var result2 = GeometryEngine.Instance.Area(GeometryEngine.Instance.SimplifyAsFeature(g1, true)); @@ -3181,8 +3189,8 @@ public void SimplifyAsFeature() public void SimplifyPolyline() { - // cref: Simplify a polyline with intersections, overlaps;ArcGIS.Core.Geometry.GeometryEngine.SimplifyPolyline(ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.SimplifyType,System.Boolean) - // cref: Simplify a polyline with intersections, overlaps;ArcGIS.Core.Geometry.IGeometryEngine.SimplifyPolyline(ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.SimplifyType,System.Boolean) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SimplifyPolyline(ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.SimplifyType,System.Boolean) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SimplifyPolyline(ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.Geometry.SimplifyType,System.Boolean) #region Simplify a polyline with intersections, overlaps List coords = new List() @@ -3198,7 +3206,7 @@ public void SimplifyPolyline() SpatialReference sr = SpatialReferences.WGS84; // build a line that has segments that cross over each other - Polyline polyline = PolylineBuilder.CreatePolyline(coords, sr); + Polyline polyline = PolylineBuilderEx.CreatePolyline(coords, sr); // polyline.PartCount = 1 ReadOnlyPartCollection parts = polyline.Parts; ReadOnlySegmentCollection segments = parts[0]; @@ -3231,8 +3239,8 @@ public void SlicePolygonIntoEqualParts() { Polygon polygon = null; - // cref: Slice a Polygon into equal parts;ArcGIS.Core.Geometry.GeometryEngine.SlicePolygonIntoEqualParts(ArcGIS.Core.Geometry.Polygon,System.Int32,System.Double,ArcGIS.Core.Geometry.SliceType) - // cref: Slice a Polygon into equal parts;ArcGIS.Core.Geometry.IGeometryEngine.SlicePolygonIntoEqualParts(ArcGIS.Core.Geometry.Polygon,System.Int32,System.Double,ArcGIS.Core.Geometry.SliceType) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SlicePolygonIntoEqualParts(ArcGIS.Core.Geometry.Polygon,System.Int32,System.Double,ArcGIS.Core.Geometry.SliceType) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SlicePolygonIntoEqualParts(ArcGIS.Core.Geometry.Polygon,System.Int32,System.Double,ArcGIS.Core.Geometry.SliceType) #region Slice a Polygon into equal parts var slices = GeometryEngine.Instance.SlicePolygonIntoEqualParts(polygon, 3, 0, SliceType.Blocks); @@ -3246,7 +3254,7 @@ public void SlicePolygonIntoEqualParts() list2D.Add(new Coordinate2D(2.0, 2.0)); list2D.Add(new Coordinate2D(2.0, 1.0)); - Polygon p = PolygonBuilder.CreatePolygon(list2D); + Polygon p = PolygonBuilderEx.CreatePolygon(list2D); slices = GeometryEngine.Instance.SlicePolygonIntoEqualParts(p, 2, 0, SliceType.Strips); // slice[0] coordinates - (1.0, 1.0), (1.0, 1.5), (2.0, 1.5), (2.0, 1.0), (1.0, 1.0) @@ -3262,18 +3270,18 @@ public void SlicePolygonIntoEqualParts() public void SplitAtPoint() { - // cref: Split multipart at point;ArcGIS.Core.Geometry.GeometryEngine.SplitAtPoint(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.MapPoint,System.Boolean,System.Boolean,System.Boolean@,System.Int32@,System.Int32@) - // cref: Split multipart at point;ArcGIS.Core.Geometry.IGeometryEngine.SplitAtPoint(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.MapPoint,System.Boolean,System.Boolean,System.Boolean@,System.Int32@,System.Int32@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.SplitAtPoint(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.MapPoint,System.Boolean,System.Boolean,System.Boolean@,System.Int32@,System.Int32@) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.SplitAtPoint(ArcGIS.Core.Geometry.Multipart,ArcGIS.Core.Geometry.MapPoint,System.Boolean,System.Boolean,System.Boolean@,System.Int32@,System.Int32@) #region Split multipart at point // define a polyline - MapPoint startPointZ = MapPointBuilder.CreateMapPoint(1, 1, 5); - MapPoint endPointZ = MapPointBuilder.CreateMapPoint(20, 1, 5); + MapPoint startPointZ = MapPointBuilderEx.CreateMapPoint(1, 1, 5); + MapPoint endPointZ = MapPointBuilderEx.CreateMapPoint(20, 1, 5); - Polyline polylineZ = PolylineBuilder.CreatePolyline(new List() { startPointZ, endPointZ }); + Polyline polylineZ = PolylineBuilderEx.CreatePolyline(new List() { startPointZ, endPointZ }); // define a split point - MapPoint splitPointAboveLine = MapPointBuilder.CreateMapPoint(10, 10, 10); + MapPoint splitPointAboveLine = MapPointBuilderEx.CreateMapPoint(10, 10, 10); bool splitOccurred; int partIndex; @@ -3327,7 +3335,7 @@ public void SplitAtPoint() // try to split with a point that won't split the line - pt extends beyond the line // - var pointAfterLine = MapPointBuilder.CreateMapPoint(50, 1, 10); + var pointAfterLine = MapPointBuilderEx.CreateMapPoint(50, 1, 10); splitPolyline = GeometryEngine.Instance.SplitAtPoint(polylineZ, pointAfterLine, false, false, out splitOccurred, out partIndex, out segmentIndex); // splitOccurred = false @@ -3355,21 +3363,15 @@ public void SplitAtPoint() new Coordinate3D(40,20,10), }; - Polygon multipart = null; + var builder = new PolygonBuilderEx(); + builder.HasZ = true; + builder.AddPart(coordsZ); + builder.AddPart(coordsZ_2ndPart); - // Builder constructors need to run on the MCT. - ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => - { - var builder = new PolygonBuilder(); - builder.HasZ = true; - builder.AddPart(coordsZ); - builder.AddPart(coordsZ_2ndPart); - - multipart = builder.ToGeometry(); - }); + Polygon multipart = builder.ToGeometry(); // pointA is closer to the first part of the multipart - the split occurs in the first part - var pointA = MapPointBuilder.CreateMapPoint(22, 18, 7); + var pointA = MapPointBuilderEx.CreateMapPoint(22, 18, 7); var splitPolygon = GeometryEngine.Instance.SplitAtPoint(multipart, pointA, false, false, out splitOccurred, out partIndex, out segmentIndex); // splitPolygon.PointCount = 12 @@ -3378,7 +3380,7 @@ public void SplitAtPoint() // pointB is midPoint between the 2 parts - no split will occur - var pointB = MapPointBuilder.CreateMapPoint(25, 20, 7); + var pointB = MapPointBuilderEx.CreateMapPoint(25, 20, 7); splitPolygon = GeometryEngine.Instance.SplitAtPoint(multipart, pointB, true, false, out splitOccurred, out partIndex, out segmentIndex); // splitOccurred = false @@ -3390,22 +3392,22 @@ public void SplitAtPoint() public void Touches() { - // cref: Polygon touches another Polygon;ArcGIS.Core.Geometry.GeometryEngine.Touches(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Polygon touches another Polygon;ArcGIS.Core.Geometry.IGeometryEngine.Touches(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Touches(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Touches(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Polygon touches another Polygon // two disjoint polygons - Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(4.0, 4.0), MapPointBuilder.CreateMapPoint(8, 8)); - Polygon poly1 = PolygonBuilder.CreatePolygon(env); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(4.0, 4.0), MapPointBuilderEx.CreateMapPoint(8, 8)); + Polygon poly1 = PolygonBuilderEx.CreatePolygon(env); - Envelope env2 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(5, 5)); - Polygon poly2 = PolygonBuilder.CreatePolygon(env2); + Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(5, 5)); + Polygon poly2 = PolygonBuilderEx.CreatePolygon(env2); bool touches = GeometryEngine.Instance.Touches(poly1, poly2); // touches = false // another polygon that touches the first - Envelope env3 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4)); - Polygon poly3 = PolygonBuilder.CreatePolygon(env3); + Envelope env3 = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4)); + Polygon poly3 = PolygonBuilderEx.CreatePolygon(env3); touches = GeometryEngine.Instance.Touches(poly1, poly3); // touches = true #endregion @@ -3413,8 +3415,8 @@ public void Touches() public void Transform2D() { - // cref: Transform2D;ArcGIS.Core.Geometry.GeometryEngine.Transform2D(ArcGIS.Core.Geometry.Coordinate2D[],ArcGIS.Core.Geometry.ProjectionTransformation,ArcGIS.Core.Geometry.Coordinate2D[]@,System.Boolean) - // cref: Transform2D;ArcGIS.Core.Geometry.IGeometryEngine.Transform2D(ArcGIS.Core.Geometry.Coordinate2D[],ArcGIS.Core.Geometry.ProjectionTransformation,ArcGIS.Core.Geometry.Coordinate2D[]@,System.Boolean) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Transform2D(ArcGIS.Core.Geometry.Coordinate2D[],ArcGIS.Core.Geometry.ProjectionTransformation,ArcGIS.Core.Geometry.Coordinate2D[]@,System.Boolean) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Transform2D(ArcGIS.Core.Geometry.Coordinate2D[],ArcGIS.Core.Geometry.ProjectionTransformation,ArcGIS.Core.Geometry.Coordinate2D[]@,System.Boolean) #region Transform2D // Not all of the input points are transformed as some of them are outside of the GCS horizon. @@ -3470,8 +3472,8 @@ public void Transform2D() public void Transform3D() { - // cref: Transform3D;ArcGIS.Core.Geometry.GeometryEngine.Transform3D(ArcGIS.Core.Geometry.Coordinate3D[],ArcGIS.Core.Geometry.ProjectionTransformation,ArcGIS.Core.Geometry.Coordinate3D[]@) - // cref: Transform3D;ArcGIS.Core.Geometry.IGeometryEngine.Transform3D(ArcGIS.Core.Geometry.Coordinate3D[],ArcGIS.Core.Geometry.ProjectionTransformation,ArcGIS.Core.Geometry.Coordinate3D[]@) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Transform3D(ArcGIS.Core.Geometry.Coordinate3D[],ArcGIS.Core.Geometry.ProjectionTransformation,ArcGIS.Core.Geometry.Coordinate3D[]@,System.Boolean) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Transform3D(ArcGIS.Core.Geometry.Coordinate3D[],ArcGIS.Core.Geometry.ProjectionTransformation,ArcGIS.Core.Geometry.Coordinate3D[]@,System.Boolean) #region Transform3D // Not all of the input points are transformed as some of them are outside of the GCS horizon. @@ -3511,12 +3513,12 @@ public void Transform3D() public void UnionMapPoints() { - // cref: Union two MapPoints - creates a Multipoint;ArcGIS.Core.Geometry.GeometryEngine.Union(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Union two MapPoints - creates a Multipoint;ArcGIS.Core.Geometry.IGeometryEngine.Union(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Union(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Union(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Union two MapPoints - creates a Multipoint - MapPoint pt1 = MapPointBuilder.CreateMapPoint(1.0, 1.0); - MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.5); + MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2.0, 2.5); Geometry geometry = GeometryEngine.Instance.Union(pt1, pt2); Multipoint multipoint = geometry as Multipoint; // multipoint has point count of 2 @@ -3525,23 +3527,23 @@ public void UnionMapPoints() public void UnionPolygons() { - // cref: Union two Polygons;ArcGIS.Core.Geometry.GeometryEngine.Union(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: Union two Polygons;ArcGIS.Core.Geometry.IGeometryEngine.Union(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Union(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Union(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region Union two Polygons // union two polygons List polyPts = new List(); - polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0)); - polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 2.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 6.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 6.0)); + polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 2.0)); - Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts); + Polygon poly1 = PolygonBuilderEx.CreatePolygon(polyPts); bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(poly1); - Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(4.0, 4.0), MapPointBuilder.CreateMapPoint(8, 8)); - Polygon poly2 = PolygonBuilder.CreatePolygon(env); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(4.0, 4.0), MapPointBuilderEx.CreateMapPoint(8, 8)); + Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); isSimple = GeometryEngine.Instance.IsSimpleAsFeature(poly2); Geometry g = GeometryEngine.Instance.Union(poly1, poly2); @@ -3551,8 +3553,8 @@ public void UnionPolygons() public void UnionManyPolylines() { - // cref: Union many Polylines;ArcGIS.Core.Geometry.GeometryEngine.Union(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) - // cref: Union many Polylines;ArcGIS.Core.Geometry.IGeometryEngine.Union(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Union(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Union(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) #region Union many Polylines // union many polylines @@ -3568,9 +3570,9 @@ public void UnionManyPolylines() // create Disjoint lines List manyLines = new List { - PolylineBuilder.CreatePolyline(new List(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84), - PolylineBuilder.CreatePolyline(new List(){coords[3], coords[4], coords[5]}), - PolylineBuilder.CreatePolyline(new List(){coords[6], coords[7], coords[8]}) + PolylineBuilderEx.CreatePolyline(new List(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84), + PolylineBuilderEx.CreatePolyline(new List(){coords[3], coords[4], coords[5]}), + PolylineBuilderEx.CreatePolyline(new List(){coords[6], coords[7], coords[8]}) }; Polyline polyline = GeometryEngine.Instance.Union(manyLines) as Polyline; @@ -3579,8 +3581,8 @@ public void UnionManyPolylines() public void UnionManyPolygons() { - // cref: Union many Polygons;ArcGIS.Core.Geometry.GeometryEngine.Union(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) - // cref: Union many Polygons;ArcGIS.Core.Geometry.IGeometryEngine.Union(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Union(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Union(System.Collections.Generic.IEnumerable{ArcGIS.Core.Geometry.Geometry}) #region Union many Polygons // union many polygons @@ -3596,9 +3598,9 @@ public void UnionManyPolygons() // create polygons List manyPolygonsZ = new List { - PolygonBuilder.CreatePolygon(new List(){coordsZ[0], coordsZ[1], coordsZ[2]}, SpatialReferences.WGS84), - PolygonBuilder.CreatePolygon(new List(){coordsZ[3], coordsZ[4], coordsZ[5]}), - PolygonBuilder.CreatePolygon(new List(){coordsZ[6], coordsZ[7], coordsZ[8]}) + PolygonBuilderEx.CreatePolygon(new List(){coordsZ[0], coordsZ[1], coordsZ[2]}, SpatialReferences.WGS84), + PolygonBuilderEx.CreatePolygon(new List(){coordsZ[3], coordsZ[4], coordsZ[5]}), + PolygonBuilderEx.CreatePolygon(new List(){coordsZ[6], coordsZ[7], coordsZ[8]}) }; Polygon polygon = GeometryEngine.Instance.Union(manyPolygonsZ) as Polygon; @@ -3607,47 +3609,47 @@ public void UnionManyPolygons() public void Within() { - // cref: MapPoints, Polylines, Polygons within Polygon;ArcGIS.Core.Geometry.GeometryEngine.Within(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) - // cref: MapPoints, Polylines, Polygons within Polygon;ArcGIS.Core.Geometry.IGeometryEngine.Within(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.GeometryEngine.Within(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Core.Geometry.IGeometryEngine.Within(ArcGIS.Core.Geometry.Geometry,ArcGIS.Core.Geometry.Geometry) #region MapPoints, Polylines, Polygons within Polygon // build a polygon List pts = new List(); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 1.0)); - pts.Add(MapPointBuilder.CreateMapPoint(1.0, 2.0)); - pts.Add(MapPointBuilder.CreateMapPoint(2.0, 2.0)); - pts.Add(MapPointBuilder.CreateMapPoint(2.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 2.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 2.0)); + pts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0)); - Polygon poly = PolygonBuilder.CreatePolygon(pts); + Polygon poly = PolygonBuilderEx.CreatePolygon(pts); // an inner point - MapPoint innerPt = MapPointBuilder.CreateMapPoint(1.5, 1.5); + MapPoint innerPt = MapPointBuilderEx.CreateMapPoint(1.5, 1.5); bool within = GeometryEngine.Instance.Within(innerPt, poly); // within = true // point on a boundary within = GeometryEngine.Instance.Within(pts[0], poly); // within = false // an interior line - MapPoint innerPt2 = MapPointBuilder.CreateMapPoint(1.25, 1.75); + MapPoint innerPt2 = MapPointBuilderEx.CreateMapPoint(1.25, 1.75); List innerLinePts = new List(); innerLinePts.Add(innerPt); innerLinePts.Add(innerPt2); - Polyline polyline = PolylineBuilder.CreatePolyline(innerLinePts); + Polyline polyline = PolylineBuilderEx.CreatePolyline(innerLinePts); within = GeometryEngine.Instance.Within(polyline, poly); // within = true // a line that crosses the boundary - MapPoint outerPt = MapPointBuilder.CreateMapPoint(3, 1.5); + MapPoint outerPt = MapPointBuilderEx.CreateMapPoint(3, 1.5); List crossingLinePts = new List(); crossingLinePts.Add(innerPt); crossingLinePts.Add(outerPt); - polyline = PolylineBuilder.CreatePolyline(crossingLinePts); + polyline = PolylineBuilderEx.CreatePolyline(crossingLinePts); within = GeometryEngine.Instance.Within(polyline, poly); // within = false // polygon in polygon - Envelope env = EnvelopeBuilder.CreateEnvelope(innerPt, innerPt2); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(innerPt, innerPt2); within = GeometryEngine.Instance.Within(env, poly); // within = true #endregion } diff --git a/Examples/Geoprocessing/GeoProcessing.csproj b/Examples/Geoprocessing/GeoProcessing.csproj new file mode 100644 index 0000000..98b623c --- /dev/null +++ b/Examples/Geoprocessing/GeoProcessing.csproj @@ -0,0 +1,80 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/Geoprocessing/Geoprocessing_Examples.cs b/Examples/Geoprocessing/Geoprocessing_Examples.cs index fd96079..0026a75 100644 --- a/Examples/Geoprocessing/Geoprocessing_Examples.cs +++ b/Examples/Geoprocessing/Geoprocessing_Examples.cs @@ -32,9 +32,16 @@ class GeoprocessinExamples { public async void FieldMapping() { - #region FieldMappings + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MAKEENVIRONMENTARRAY + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.ShowMessageBox + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GPEXECUTETOOLFLAGS + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region FieldMappings - var environment = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true); + var environment = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true); var prj = Project.Current; var map = MapView.Active; @@ -69,10 +76,16 @@ public async void FieldMapping() // Setting environments, MakeEnvironmentArray public async void SetEnvironment() // Task { - // cref: gp_environments;ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.MakeEnvironmentArray(System.Nullable{System.Int32},System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Nullable{System.Boolean},System.Object,System.Object,System.Nullable{System.Boolean},System.Object,System.Object,System.Object,System.Object,System.Object,System.Nullable{System.Boolean},System.Double[],System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Nullable{System.Boolean},System.Object,System.Object,System.Object) - #region gp_environments - // get the syntax of the tool from Python window or from tool help page - string in_features = @"C:\data\data.gdb\HighwaysWeb84"; + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MAKEENVIRONMENTARRAY + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.ShowMessageBox + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GPEXECUTETOOLFLAGS + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region gp_environments + // get the syntax of the tool from Python window or from tool help page + string in_features = @"C:\data\data.gdb\HighwaysWeb84"; string out_features = @"C:\data\data.gdb\HighwaysUTM"; var param_values = Geoprocessing.MakeValueArray(in_features, out_features); @@ -95,10 +108,16 @@ public async void SetEnvironment() // Task public async void ProgressDialogExample() { - // cref: progress_dialog;ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(System.String,System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}},ArcGIS.Desktop.Framework.Threading.Tasks.CancelableProgressor,ArcGIS.Desktop.Core.Geoprocessing.GPExecuteToolFlags) - #region progress_dialog - var progDlg = new ProgressDialog("Running Geoprocessing Tool", "Cancel", 100, true); + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.PROGRESSDIALOG + // cref: ARCGIS.DESKTOP.FRAMEWORK.THREADING.TASKS.PROGRESSDIALOG._ctor + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region progress_dialog + + var progDlg = new ProgressDialog("Running Geoprocessing Tool", "Cancel", 100, true); progDlg.Show(); var progSrc = new CancelableProgressorSource(progDlg); @@ -173,9 +192,12 @@ public async void ExecuteEBK() public async void ShowMessageBox() { - // cref: message_box;ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ShowMessageBox(System.Collections.Generic.IEnumerable{ArcGIS.Desktop.Core.Geoprocessing.IGPMessage},System.String,ArcGIS.Desktop.Core.Geoprocessing.GPMessageBoxStyle,System.String,System.String,ArcGIS.Desktop.Framework.Contracts.ViewModelBase) - #region message_box - var gp_result = await Geoprocessing.ExecuteToolAsync("management.GetCount", Geoprocessing.MakeValueArray(@"C:\data\f.gdb\hello")); + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + // cref: message_box;ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ShowMessageBox(System.Collections.Generic.IEnumerable{ArcGIS.Desktop.Core.Geoprocessing.IGPMessage},System.String,ArcGIS.Desktop.Core.Geoprocessing.GPMessageBoxStyle,System.String,System.String,ArcGIS.Desktop.Framework.Contracts.ViewModelBase) + #region message_box + var gp_result = await Geoprocessing.ExecuteToolAsync("management.GetCount", Geoprocessing.MakeValueArray(@"C:\data\f.gdb\hello")); // this icon shows up left of content_header string icon_src = @"C:\data\Icons\ModifyLink32.png"; Geoprocessing.ShowMessageBox(gp_result.Messages, "Content Header", GPMessageBoxStyle.Error, "Window Title", icon_src); @@ -184,9 +206,10 @@ public async void ShowMessageBox() private void OpenBufferToolDialog() { - // cref: open_dialog;ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.OpenToolDialog(System.String,System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}},System.Boolean,ArcGIS.Desktop.Core.Geoprocessing.GPToolExecuteEventHandler) - #region open_dialog - string input_points = @"C:\data\ca_ozone.gdb\ozone_points"; + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: open_dialog;ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.OpenToolDialog(System.String,System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}},System.Boolean,ArcGIS.Desktop.Core.Geoprocessing.GPToolExecuteEventHandler) + #region open_dialog + string input_points = @"C:\data\ca_ozone.gdb\ozone_points"; string output_polys = @"C:\data\ca_ozone.gdb\ozone_buff"; string buffer_dist = "2000 Meters"; diff --git a/Examples/Geoprocessing/ProSnippets.cs b/Examples/Geoprocessing/ProSnippets.cs index 3d9f5e3..f58eb94 100644 --- a/Examples/Geoprocessing/ProSnippets.cs +++ b/Examples/Geoprocessing/ProSnippets.cs @@ -42,10 +42,13 @@ class GeoprocessingCodeExamples public async void CodeExamples() { - - #region How to execute a Model tool - // get the model tool's parameter syntax from the model's help - string input_roads = @"C:\data\Input.gdb\PlanA_Roads"; + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region How to execute a Model tool + // get the model tool's parameter syntax from the model's help + string input_roads = @"C:\data\Input.gdb\PlanA_Roads"; string buff_dist_field = "Distance"; // use values from a field string input_vegetation = @"C:\data\Input.gdb\vegetation"; string output_data = @"C:\data\Output.gdb\ClippedFC2"; @@ -56,19 +59,24 @@ public async void CodeExamples() var args = Geoprocessing.MakeValueArray(input_roads, buff_dist_field, input_vegetation, output_data); var result = await Geoprocessing.ExecuteToolAsync(tool_path, args); - #endregion - + #endregion - #region Set Geoprocessing extent environment + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MAKEENVIRONMENTARRAY + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region Set Geoprocessing extent environment - var parameters = Geoprocessing.MakeValueArray(@"C:\data\data.gdb\HighwaysUTM11", @"C:\data\data.gdb\Highways_extent"); + var parameters = Geoprocessing.MakeValueArray(@"C:\data\data.gdb\HighwaysUTM11", @"C:\data\data.gdb\Highways_extent"); var ext = Geoprocessing.MakeEnvironmentArray(extent: "460532 3773964 525111 3827494"); var gp_result = await Geoprocessing.ExecuteToolAsync("management.CopyFeatures", parameters, ext); - #endregion - + #endregion - #region Open a script tool dialog in Geoprocessing pane - string input_data = @"C:\data\data.gdb\Population"; + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.OpenToolDialog(System.String,System.Collections.Generic.IEnumerable{System.String},System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}},System.Boolean,ArcGIS.Desktop.Core.Geoprocessing.GPToolExecuteEventHandler) + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + #region Open a script tool dialog in Geoprocessing pane + string input_data = @"C:\data\data.gdb\Population"; string out_pdf = @"C:\temp\Reports.pdf"; string field_name = "INCOME"; // use defaults for other parameters - no need to pass any value @@ -77,11 +85,11 @@ public async void CodeExamples() string toolpath = @"C:\data\WorkflowTools.tbx\MakeHistogram"; Geoprocessing.OpenToolDialog(toolpath, arguments); - #endregion - + #endregion - #region Get Geoprocessing project items - var gpItems = CoreModule.CurrentProject.Items.OfType(); + // cref: ARCGIS.DESKTOP.GEOPROCESSING.GEOPROCESSINGPROJECTITEM + #region Get Geoprocessing project items + var gpItems = CoreModule.CurrentProject.Items.OfType(); // go through all the available toolboxes foreach (var gpItem in gpItems) @@ -96,28 +104,46 @@ public async void CodeExamples() // for example, add to a list to track or use them later } } - #endregion + #endregion - #region Stop a feature class created with GP from automatically adding to the map - // However, settings in Pro App's Geoprocessing Options will override option set in code - // for example, in Pro App's Options > Geoprocessing dialog, if you check 'Add output datasets to an open map' - // then the output WILL BE added to history overriding settings in code - var CopyfeaturesParams = Geoprocessing.MakeValueArray("C:\\data\\Input.gdb\\PlanA_Roads", "C:\\data\\Input.gdb\\Roads_copy"); + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GPEXECUTETOOLFLAGS + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region Stop a feature class created with GP from automatically adding to the map + // However, settings in Pro App's Geoprocessing Options will override option set in code + // for example, in Pro App's Options > Geoprocessing dialog, if you check 'Add output datasets to an open map' + // then the output WILL BE added to history overriding settings in code + var CopyfeaturesParams = Geoprocessing.MakeValueArray("C:\\data\\Input.gdb\\PlanA_Roads", "C:\\data\\Input.gdb\\Roads_copy"); IGPResult gpResult = await Geoprocessing.ExecuteToolAsync("management.CopyFeatures", CopyfeaturesParams, null, null, null, GPExecuteToolFlags.None); - #endregion + #endregion - #region GPExecuteToolFlags.AddToHistory will add the execution messages to Hisotry - // However, settings in Pro App's Geoprocessing Options will override option set in code - // for example, if in Options > Geoprocessing dialog, if you uncheck 'Write geoprocessing operations to Geoprocessing History' - // then the output will not be added to history. - var args2 = Geoprocessing.MakeValueArray("C:\\data\\Vegetation.shp", "NewField", "TEXT"); + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GPEXECUTETOOLFLAGS + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region GPExecuteToolFlags.AddToHistory will add the execution messages to Hisotry + // However, settings in Pro App's Geoprocessing Options will override option set in code + // for example, if in Options > Geoprocessing dialog, if you uncheck 'Write geoprocessing operations to Geoprocessing History' + // then the output will not be added to history. + var args2 = Geoprocessing.MakeValueArray("C:\\data\\Vegetation.shp", "NewField", "TEXT"); var result2 = await Geoprocessing.ExecuteToolAsync("management.AddField", args2, null, null, null, GPExecuteToolFlags.AddToHistory); - #endregion + #endregion - #region Multi Ring Buffer - //The data referenced in this snippet can be downloaded from the arcgis-pro-sdk-community-samples repo - //https://github.com/Esri/arcgis-pro-sdk-community-samples - async Task CreateRings(EditingTemplate currentTemplate) + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.IGPRESULT + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.IGPRESULT.RETURNVALUE + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.IGPRESULT.ERRORMESSAGES + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GPEXECUTETOOLFLAGS + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region Multi Ring Buffer + //The data referenced in this snippet can be downloaded from the arcgis-pro-sdk-community-samples repo + //https://github.com/Esri/arcgis-pro-sdk-community-samples + async Task CreateRings(EditingTemplate currentTemplate) { var paramsArray = Geoprocessing.MakeValueArray(currentTemplate.MapMember.Name, @"C:\Data\FeatureTest\FeatureTest.gdb\Points_MultipleRingBuffer", @@ -131,12 +157,18 @@ async Task CreateRings(EditingTemplate currentTemplate) return ringsResult; } - #endregion + #endregion - #region Non-blocking execution of a Geoprocessing tool - //The data referenced in this snippet can be downloaded from the arcgis-pro-sdk-community-samples repo - //https://github.com/Esri/arcgis-pro-sdk-community-samples - string in_data = @"C:\tools\data.gdb\cities"; + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.IGPRESULT + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GPEXECUTETOOLFLAGS + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region Non-blocking execution of a Geoprocessing tool + //The data referenced in this snippet can be downloaded from the arcgis-pro-sdk-community-samples repo + //https://github.com/Esri/arcgis-pro-sdk-community-samples + string in_data = @"C:\tools\data.gdb\cities"; string cities_buff = @"E:\data\data.gdb\cities_2km"; var valueArray = Geoprocessing.MakeValueArray(in_data, cities_buff, "2000 Meters"); @@ -146,10 +178,17 @@ async Task CreateRings(EditingTemplate currentTemplate) // GPExecuteToolFlags flags = GPExecuteToolFlags.GPThread; // instruct the tool run non-blocking GPThread IGPResult bufferResult = await Geoprocessing.ExecuteToolAsync("Analysis.Buffer", valueArray, null, null, null, flags); - #endregion + #endregion - #region How to pass parameter with multiple or complex input values - var environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true); + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.ShowMessageBox + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GPEXECUTETOOLFLAGS + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MAKEENVIRONMENTARRAY + // cref: ARCGIS.DESKTOP.CORE.GEOPROCESSING.GEOPROCESSING.MakeValueArray + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},NULLABLE{CANCELLATIONTOKEN},GPTOOLEXECUTEEVENTHANDLER,GPEXECUTETOOLFLAGS) + // cref: ArcGIS.Desktop.Core.Geoprocessing.Geoprocessing.ExecuteToolAsync(STRING,IENUMERABLE{STRING},IENUMERABLE{KEYVALUEPAIR{STRING,STRING}},CANCELABLEPROGRESSOR,GPEXECUTETOOLFLAGS) + #region How to pass parameter with multiple or complex input values + var environments = Geoprocessing.MakeEnvironmentArray(overwriteoutput: true); string toolName = "Snap_edit"; // or use edit.Snap @@ -176,6 +215,8 @@ async Task CreateRings(EditingTemplate currentTemplate) public void GeoprocessingOptions() { + // cref: ArcGIS.Desktop.Core.GeoprocessingOptions + // cref: ArcGIS.Desktop.Core.ApplicationOptions.GeoprocessingOptions #region Get GeoprocessingOptions //These options are for behavior of interactive GP tools _only_. @@ -187,6 +228,8 @@ public void GeoprocessingOptions() #endregion + // cref: ArcGIS.Desktop.Core.GeoprocessingOptions + // cref: ArcGIS.Desktop.Core.ApplicationOptions.GeoprocessingOptions #region Set GeoprocessingOptions //Note: changing these options modifies behavior of interactive GP tools _only_. //Use the ArcGIS.Desktop.Core.Geoprocessing.GPExecuteToolFlags enum parameter diff --git a/Examples/GraphicsLayers.csproj b/Examples/GraphicsLayers.csproj deleted file mode 100644 index fed3af3..0000000 --- a/Examples/GraphicsLayers.csproj +++ /dev/null @@ -1,198 +0,0 @@ - - - - - Debug - AnyCPU - {E63AE9CD-D208-DDD3-BB9C-4DFAA709B938} - Library - Properties - GraphicsLayers - GraphicsLayers - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\GraphicsLayers\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\GraphicsLayers\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - - \ No newline at end of file diff --git a/Examples/GraphicsLayers.lua b/Examples/GraphicsLayers.lua deleted file mode 100644 index 6276b97..0000000 --- a/Examples/GraphicsLayers.lua +++ /dev/null @@ -1,23 +0,0 @@ -project "GraphicsLayers" - kind "SharedLib" - language "C#" - targetdir "bin/%{cfg.buildcfg}" - dotnetframework "4.8" - - files { "GraphicsLayers/**.cs","GraphicsLayers/**.xaml"} - - links { - -} - - filter "configurations:Debug" - defines { "DEBUG" } - --flags { "Symbols" } - - filter "configurations:Release" - defines { "NDEBUG" } - optimize "On" - - filter { "platforms:x64" } - system "Windows" - architecture "x64" \ No newline at end of file diff --git a/Examples/GraphicsLayers/GraphicsLayers.csproj b/Examples/GraphicsLayers/GraphicsLayers.csproj new file mode 100644 index 0000000..ca94596 --- /dev/null +++ b/Examples/GraphicsLayers/GraphicsLayers.csproj @@ -0,0 +1,80 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/GraphicsLayers/ProSnippet.cs b/Examples/GraphicsLayers/ProSnippet.cs index a239952..90510d6 100644 --- a/Examples/GraphicsLayers/ProSnippet.cs +++ b/Examples/GraphicsLayers/ProSnippet.cs @@ -11,12 +11,16 @@ using System.Text; using System.Threading.Tasks; -namespace GraphicsLayer.GraphicsLayer +namespace GraphicsLayerExamples { class ProSnippet : MapTool { public void CreateGraphicsLayer() { + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateGroupLayer(ArcGIS.Desktop.Mapping.ILayerContainerEdit, System.Int32, System.String) #region Create GraphicsLayer var map = MapView.Active.Map; if (map.MapType != MapType.Map) @@ -29,14 +33,18 @@ public void CreateGraphicsLayer() var graphicsLayer = LayerFactory.Instance.CreateLayer(gl_param, map); //Add to the bottom of the TOC - LayerFactory.Instance.CreateLayer(gl_param, map, - LayerPosition.AddToBottom); + gl_param.MapMemberIndex = -1; //bottom + LayerFactory.Instance.CreateLayer(gl_param, map); //Add a graphics layer to a group layer... var group_layer = map.GetLayersAsFlattenedList().OfType().First(); LayerFactory.Instance.CreateLayer(gl_param, group_layer); - //TODO...use the graphics layer + //TODO...use the graphics layer + // + + // or use the specific CreateGroupLayer method + LayerFactory.Instance.CreateGroupLayer(map, -1, "Graphics Layer"); }); #endregion } @@ -46,6 +54,8 @@ public void AccessingGraphicLayer() var map = MapView.Active.Map; if (map.MapType != MapType.Map) return;// not 2D + + // cref: ArcGIS.Desktop.Mapping.GraphicsLayer #region Accessing GraphicsLayer //get the first graphics layer in the map's collection of graphics layers var graphicsLayer = map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); @@ -59,6 +69,9 @@ public void CopyGraphicsLayer() { var sourceGraphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().Where(gl => gl.Name == "SourceLayer").FirstOrDefault(); var targetGraphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().Where(gl => gl.Name == "TargetLayer").FirstOrDefault(); + + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.FindElements + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.CopyElements #region Copy Graphic elements //on the QueuedTask var elems = sourceGraphicsLayer.FindElements(new List() { "Point 1", "Line 3", "Text 1" }); @@ -68,6 +81,10 @@ public void CopyGraphicsLayer() public void RemoveGraphicsLayer() { var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); + + // cref: ArcGIS.Desktop.Mapping.GraphicsLayer + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.RemoveElements + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetSelectedElements #region Remove Graphic elements //on the QueuedTask graphicsLayer.RemoveElements(graphicsLayer.GetSelectedElements()); @@ -78,6 +95,10 @@ public void RemoveGraphicsLayer() public void CreateGraphicElementUsingCIMGraphic() { + + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,CIMGraphic,String,Boolean,ElementInfo) + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,Geometry,CIMSymbol,String,Boolean,ElementInfo) #region Point Graphic Element using CIMGraphic var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType().FirstOrDefault(); @@ -111,6 +132,9 @@ public void CreateLineGraphic() return; QueuedTask.Run(() => { + // cref: ARCGIS.CORE.CIM.CIMLineGraphic + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,CIMGraphic,String,Boolean,ElementInfo) + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,Geometry,CIMSymbol,String,Boolean,ElementInfo) #region Line Graphic Element using CIMGraphic //On the QueuedTask //Place a line symbol using the extent's lower left and upper right corner. @@ -121,7 +145,7 @@ public void CreateLineGraphic() var pointToCoordinates = new Coordinate2D(extent.XMax, extent.YMax); List points = new List { pointFromCoordinates, pointToCoordinates }; //create the polyline - var lineSegment = PolylineBuilder.CreatePolyline(points); + var lineSegment = PolylineBuilderEx.CreatePolyline(points); //specify a symbol var line_symbol = SymbolFactory.Instance.ConstructLineSymbol( @@ -144,6 +168,9 @@ public void CreatePolyGraphic() return; QueuedTask.Run(() => { + // cref: ARCGIS.CORE.CIM.CIMPolygonGraphic + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,CIMGraphic,String,Boolean,ElementInfo) + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,Geometry,CIMSymbol,String,Boolean,ElementInfo) #region Polygon Graphic Element using CIMGraphic //On the QueuedTask //Place a polygon symbol using the mapview extent geometry @@ -151,7 +178,7 @@ public void CreatePolyGraphic() //Contract the extent var polygonEnv = extent.Expand(-100000, -90000, false); //create a polygon using the envelope - var polygon = PolygonBuilder.CreatePolygon(polygonEnv); + var polygon = PolygonBuilderEx.CreatePolygon(polygonEnv); //specify a symbol var poly_symbol = SymbolFactory.Instance.ConstructPolygonSymbol( @@ -174,6 +201,9 @@ public void CreateMultiPointGraphics() return; QueuedTask.Run(() => { + // cref: ARCGIS.CORE.CIM.CIMMultipointGraphic + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,CIMGraphic,String,Boolean,ElementInfo) + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,Geometry,CIMSymbol,String,Boolean,ElementInfo) #region Multi-point Graphic Element using CIMGraphic //On the QueuedTask //Place a multipoint graphic using the mapview extent geometry @@ -181,9 +211,9 @@ public void CreateMultiPointGraphics() //Contract the extent var polygonEnv = extent.Expand(-100000, -90000, false); //create a polygon using the envelope - var polygon = PolygonBuilder.CreatePolygon(polygonEnv); + var polygon = PolygonBuilderEx.CreatePolygon(polygonEnv); //Create MultipPoints from the polygon - var multiPoints = MultipointBuilder.CreateMultipoint(polygon); + var multiPoints = MultipointBuilderEx.CreateMultipoint(polygon); //specify a symbol var point_symbol = SymbolFactory.Instance.ConstructPointSymbol( ColorFactory.Instance.GreenRGB); @@ -200,6 +230,8 @@ public void CreateMultiPointGraphics() } public void CreateGraphicElementUsingCIMSymbol() { + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,CIMGraphic,String,Boolean,ElementInfo) + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,Geometry,CIMSymbol,String,Boolean,ElementInfo) #region Graphic Element using CIMSymbol var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType().FirstOrDefault(); @@ -221,6 +253,7 @@ public void CreateGraphicElementUsingCIMSymbol() public void CreateTextGraphicElement() { + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement(GraphicsLayer,MapPoint,CIMTextSymbol,String,String,Boolean,ElementInfo) #region Text Graphic Element var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType().FirstOrDefault(); @@ -236,12 +269,15 @@ public void CreateTextGraphicElement() var text_symbol = SymbolFactory.Instance.ConstructTextSymbol (ColorFactory.Instance.BlackRGB, 8.5, "Corbel", "Regular"); - graphicsLayer.AddElement(location, "Text Example", text_symbol); + graphicsLayer.AddElement(location, text_symbol, "Text Example"); }); #endregion } private void BulkGraphicsCreation() { + // cref: ARCGIS.CORE.CIM.CIMGRAPHIC.SYMBOL + // cref: ARCGIS.CORE.CIM.CIMPointGraphic + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElements #region Bulk Graphics creation //Point Feature layer to convert into graphics var lyr = MapView.Active?.Map?.GetLayersAsFlattenedList().OfType().FirstOrDefault(); @@ -288,6 +324,9 @@ private void BulkGraphicsCreation() #endregion public void ProgrammaticSelection() { + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.SelectElement + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.SelectElements + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetElementsAsFlattenedList #region Select Graphic Elements var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType().FirstOrDefault(); @@ -307,6 +346,9 @@ public void FindGraphicElement() { var graphicsLayer = MapView.Active?.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); QueuedTask.Run( () => { + + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetElementsAsFlattenedList + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.FindElements #region Find Graphic elements //on the QueuedTask //Find elements by name @@ -325,6 +367,10 @@ public void FindGraphicElement() #endregion }); } + + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.SelectElements + // cref: ArcGIS.Desktop.Mapping.SelectionCombinationMethod + // cref: ARCGIS.DESKTOP.MAPPING.MAPTOOL.ONSKETCHCOMPLETEASYNC #region Spatial selection of elements in all Graphics Layers //Map Tool is used to perform Spatial selection. //Graphic selection uses the selection geometry @@ -346,6 +392,11 @@ public void SpatialSelection() { var graphicsLayer = MapView.Active?.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); QueuedTask.Run(() => { + + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.SelectElements + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.SelectElements(MapView,GraphicsLayer,Geometry,SelectionCombinationMethod,Boolean) + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.SelectElements(MapView,Geometry,SelectionCombinationMethod,Boolean) + // cref: ArcGIS.Desktop.Mapping.SelectionCombinationMethod #region Spatial selection of elements in one graphics layer //on the QueuedTask //Create an extent to use for the spatial selection @@ -359,6 +410,11 @@ public void SpatialSelection() public void SelectTextGraphicElements() { + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetElementsAsFlattenedList + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.SelectElements + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.SelectElements(MapView,GraphicsLayer,Geometry,SelectionCombinationMethod,Boolean) + // cref: ArcGIS.Desktop.Mapping.MappingExtensions.SelectElements(MapView,Geometry,SelectionCombinationMethod,Boolean) + // cref: ArcGIS.Desktop.Mapping.SelectionCombinationMethod #region Select Text Graphic Elements var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType().FirstOrDefault(); @@ -371,6 +427,11 @@ public void SelectTextGraphicElements() public void UnSelectGraphicElements() { + + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.ClearSelection + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetSelectedElements + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.UnSelectElement + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.UnSelectElements #region Un-Select Graphic elements var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType().FirstOrDefault(); @@ -394,13 +455,16 @@ public void UnSelectGraphicElements() #endregion public void SubscribeElementSelectionChanged() { + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetSelectedElements + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Elements #region Subscribe to ElementSelectionChangedEvent - ArcGIS.Desktop.Mapping.Events.ElementSelectionChangedEvent.Subscribe((args) => { + ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { //check if the container is a graphics layer - could be a Layout (or even map view) - if (args.ElementContainer is ArcGIS.Desktop.Mapping.GraphicsLayer graphicsLayer) + if (args.Container is ArcGIS.Desktop.Mapping.GraphicsLayer graphicsLayer) { //get the total selection count for the container - var count = args.SelectedElementCount; + var count = args.Elements.Count(); //Check count - could have been an unselect or clearselect if (count > 0) { @@ -422,6 +486,8 @@ public void SubscribeElementSelectionChanged() public void GroupUnGroupElements() { QueuedTask.Run( () => { + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetSelectedElements + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GroupElements #region Group Graphic Elements var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType().FirstOrDefault(); @@ -434,6 +500,8 @@ public void GroupUnGroupElements() var groupElement = graphicsLayer.GroupElements(elemsToGroup); #endregion + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetSelectedElements + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.UnGroupElements #region Un-Group Graphic Elements var selectedElements = graphicsLayer.GetSelectedElements().ToList(); ; if (selectedElements?.Any() == false)//must be at least 1. @@ -448,9 +516,11 @@ public void GroupUnGroupElements() if (elementsToUnGroup.Count() == 0) return; //UnGroup - graphicsLayer.UnGroupElements(elementsToUnGroup); + graphicsLayer.UnGroupElements(elementsToUnGroup); #endregion + // cref: ArcGIS.Desktop.Layouts.GroupElement.ELEMENTS + // cref: ArcGIS.Desktop.Layouts.Element.GetParent #region Parent of GroupElement //check the parent var parent = groupElement.Elements.First().GetParent();//will be the group element @@ -458,6 +528,13 @@ public void GroupUnGroupElements() var top_most = groupElement.Elements.First().GetParent(true);//will be the GraphicsLayer #endregion + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetSelectedElements + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.BringForward + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.BringForward(GraphicsLayer,Element) + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.BringForward(GraphicsLayer,IEnumerable{Element}) + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.SendBackward + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.SendBackward(GraphicsLayer,Element) + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.SendBackward(GraphicsLayer,IEnumerable{Element}) #region Ordering: Send backward and Bring forward //On the QueuedTask //get the current selection set @@ -479,11 +556,13 @@ public void GroupUnGroupElements() } #endregion + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetSelectedElements + // cref: ArcGIS.Desktop.Layouts.Element.ZOrder #region Get Z-Order var selElementsZOrder = graphicsLayer.GetSelectedElements(); //list out the z order foreach (var elem in selElementsZOrder) - System.Diagnostics.Debug.WriteLine($"{elem.Name}: z-order {elem.GetZOrder()}"); + System.Diagnostics.Debug.WriteLine($"{elem.Name}: z-order {elem.ZOrder}"); #endregion }); } @@ -494,6 +573,9 @@ public void MoveGraphicElements() var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList() .OfType().FirstOrDefault(); QueuedTask.Run( () => { + + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.GetSelectedElements + // cref: ArcGIS.Desktop.Layouts.Element.SetAnchorPoint #region Move Graphic Elements //Each selected element will move to a set distance to the upper right. var selElements = graphicsLayer.GetSelectedElements(); @@ -502,7 +584,7 @@ public void MoveGraphicElements() foreach (var selElement in selElements) { //Get the element's bounds - var elementPoly = PolygonBuilder.CreatePolygon(selElement.GetBounds()); + var elementPoly = PolygonBuilderEx.CreatePolygon(selElement.GetBounds()); //get the coordinates of the element bounding envelope. var pointsList = elementPoly.Copy2DCoordinatesToList(); //Move the element's Anchor point to the upper right. @@ -517,6 +599,10 @@ public void ChangeGraphicSymbology() { var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); QueuedTask.Run( () => { + + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.FindElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ARCGIS.DESKTOP.LAYOUTS.GRAPHICELEMENT.SETGRAPHIC #region Modify symbology of a Graphic Element //within a queued Task //get the first line element in the layer diff --git a/Examples/GraphicsLayers/Properties/AssemblyInfo.cs b/Examples/GraphicsLayers/Properties/AssemblyInfo.cs deleted file mode 100644 index fe5a273..0000000 --- a/Examples/GraphicsLayers/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("GraphicsLayer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("GraphicsLayer")] -[assembly: AssemblyCopyright("Copyright © 2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("7db197a0-e3c2-49f3-90e1-6339d5d57f9a")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Examples/Layouts.csproj b/Examples/Layouts.csproj deleted file mode 100644 index 0ce7dab..0000000 --- a/Examples/Layouts.csproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - AnyCPU - {D67F1AC9-425F-9964-4B77-243BB7D5FFC5} - Library - Properties - Layouts - Layouts - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\Layouts\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\Layouts\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Examples/Layouts/ElementClass.cs b/Examples/Layouts/ElementClass.cs index 34da5a1..e3472b2 100644 --- a/Examples/Layouts/ElementClass.cs +++ b/Examples/Layouts/ElementClass.cs @@ -53,6 +53,12 @@ async public static void MethodSnippets() // cref: Element_ConvertToGraphics;ArcGIS.Desktop.Layouts.Element.ConvertToGraphics + // cref: Element_ConvertToGraphics;ArcGIS.Desktop.Mapping.IElement.ConvertToGraphics + // cref: ArcGIS.Desktop.Layouts.GroupElement.ELEMENTS + // cref: ArcGIS.Desktop.Layouts.Element.GETY + // cref: ArcGIS.Desktop.Layouts.Element.SETY + // cref: ArcGIS.Desktop.Layouts.Element.Name + // cref: ArcGIS.Desktop.Layouts.Element.SetTOCPositionAbsolute #region Element_ConvertToGraphics //Convert a legend to a graphic and move the Title to the bottom of the legend and also move //the label in the contents pane to the bottom of the list. @@ -74,8 +80,11 @@ await QueuedTask.Run(() => }); #endregion Element_ConvertToGraphics - // cref: Element_GetSetAnchor;ArcGIS.Desktop.Layouts.Element.GetAnchor - // cref: Element_GetSetAnchor;ArcGIS.Desktop.Layouts.Element.SetAnchor(ArcGIS.Core.CIM.Anchor) + // cref: ArcGIS.Core.CIM.Anchor + // cref: ArcGIS.Desktop.Layouts.Element.GetAnchor + // cref: ArcGIS.Desktop.Layouts.Element.SetAnchor(ArcGIS.Core.CIM.Anchor) + // cref: ArcGIS.Desktop.Mapping.IElement.SetAnchor(ArcGIS.Core.CIM.Anchor) + // cref: ArcGIS.Desktop.Mapping.IElement.GetAnchor #region Element_GetSetAnchor //Change the element's anchor position @@ -89,8 +98,8 @@ await QueuedTask.Run(() => }); #endregion Element_GetSetAnchor - // cref: Element_GetCustomProperty;ArcGIS.Desktop.Layouts.Element.GetCustomProperties // cref: Element_GetCustomProperty;ArcGIS.Desktop.Layouts.Element.GetCustomProperty(System.String) + // cref: Element_GetCustomProperty;ArcGIS.Desktop.Mapping.IElement.GetCustomProperty(System.String) #region Element_GetCustomProperty //Get a custom property that has been previously set. @@ -101,8 +110,11 @@ await QueuedTask.Run(() => }); #endregion Element_GetCustomProperty + // cref: Element_GetSetDefinition;ArcGIS.Core.CIM.CIMElement // cref: Element_GetSetDefinition;ArcGIS.Desktop.Layouts.Element.GetDefinition // cref: Element_GetSetDefinition;ArcGIS.Desktop.Layouts.Element.SetDefinition(ArcGIS.Core.CIM.CIMElement) + // cref: Element_GetSetDefinition;ArcGIS.Desktop.Mapping.IElement.GetDefinition + // cref: Element_GetSetDefinition;ArcGIS.Desktop.Mapping.IElement.SetDefinition(ArcGIS.Core.CIM.CIMElement) #region Element_GetSetDefinition //Modify an element's CIM properties. @@ -119,6 +131,8 @@ await QueuedTask.Run(() => // cref: Element_GetSetHeight;ArcGIS.Desktop.Layouts.Element.GetHeight // cref: Element_GetSetHeight;ArcGIS.Desktop.Layouts.Element.SetHeight(System.Double) + // cref: Element_GetSetHeight;ArcGIS.Desktop.Mapping.IElement.SetHeight(System.Double) + // cref: Element_GetSetHeight;ArcGIS.Desktop.Mapping.IElement.GetHeight #region Element_GetSetHeight //Modify an element's hieght. @@ -133,6 +147,9 @@ await QueuedTask.Run(() => #endregion Element_GetSetHeight // cref: Element_SetLocked;ArcGIS.Desktop.Layouts.Element.SetLocked(System.Boolean) + // cref: ArcGIS.Desktop.Layouts.Element.IsLocked + // cref: Element_SetLocked;ArcGIS.Desktop.Mapping.IElement.SetLocked(System.Boolean) + // cref: Element_SetLocked;ArcGIS.Desktop.Mapping.IElement.IsLocked #region Element_SetLocked //Modify an element's locked state if it isn't already @@ -148,6 +165,8 @@ await QueuedTask.Run(() => // cref: Element_GetSetLockedAspectRatio;ArcGIS.Desktop.Layouts.Element.GetLockedAspectRatio // cref: Element_GetSetLockedAspectRatio;ArcGIS.Desktop.Layouts.Element.SetLockedAspectRatio(System.Boolean) + // cref: Element_GetSetLockedAspectRatio;ArcGIS.Desktop.Mapping.IElement.SetLockedAspectRatio(System.Boolean) + // cref: Element_GetSetLockedAspectRatio;ArcGIS.Desktop.Mapping.IElement.GetLockedAspectRatio #region Element_GetSetLockedAspectRatio //Modify an element's aspect ratio. @@ -163,6 +182,8 @@ await QueuedTask.Run(() => // cref: Element_GetSetRotation;ArcGIS.Desktop.Layouts.Element.GetRotation // cref: Element_GetSetRotation;ArcGIS.Desktop.Layouts.Element.SetRotation(System.Double) + // cref: Element_GetSetRotation;ArcGIS.Desktop.Mapping.IElement.SetRotation(System.Double) + // cref: Element_GetSetRotation;ArcGIS.Desktop.Mapping.IElement.GetRotation #region Element_GetSetRotation //Modify and element's rotation value. @@ -178,6 +199,8 @@ await QueuedTask.Run(() => // cref: Element_GetSetWidth;ArcGIS.Desktop.Layouts.Element.GetWidth // cref: Element_GetSetWidth;ArcGIS.Desktop.Layouts.Element.SetWidth(System.Double) + // cref: Element_GetSetWidth;ArcGIS.Desktop.Mapping.IElement.SetWidth(System.Double) + // cref: Element_GetSetWidth;ArcGIS.Desktop.Mapping.IElement.GetWidth #region Element_GetSetWidth //Modify an element's width. @@ -193,6 +216,8 @@ await QueuedTask.Run(() => // cref: Element_GetSetX;ArcGIS.Desktop.Layouts.Element.GetX // cref: Element_GetSetX;ArcGIS.Desktop.Layouts.Element.SetX(System.Double) + // cref: Element_GetSetX;ArcGIS.Desktop.Mapping.IElement.SetX(System.Double) + // cref: Element_GetSetX;ArcGIS.Desktop.Mapping.IElement.GetX #region Element_GetSetX //Modify an element's X position. @@ -209,6 +234,8 @@ await QueuedTask.Run(() => // cref: Element_GetSetY;ArcGIS.Desktop.Layouts.Element.GetY // cref: Element_GetSetY;ArcGIS.Desktop.Layouts.Element.SetY(System.Double) + // cref: Element_GetSetY;ArcGIS.Desktop.Mapping.IElement.SetY(System.Double) + // cref: Element_GetSetY;ArcGIS.Desktop.Mapping.IElement.GetY #region Element_GetSetY //Modify an element's Y position. @@ -223,7 +250,7 @@ await QueuedTask.Run(() => #endregion Element_GetSetY // cref: Element_SetCustomProperty;ArcGIS.Desktop.Layouts.Element.SetCustomProperty(System.String,System.String) - // cref: Element_SetCustomProperty;ArcGIS.Desktop.Layouts.Element.SetCustomProperty(System.String[],System.String[]) + // cref: Element_SetCustomProperty;ArcGIS.Desktop.Mapping.IElement.SetCustomProperty(System.String,System.String) #region Element_SetCustomProperty //Set a custom property on an element. @@ -235,6 +262,7 @@ await QueuedTask.Run(() => #endregion Element_SetCustomProperty // cref: Element_SetName;ArcGIS.Desktop.Layouts.Element.SetName(System.String) + // cref: Element_SetName;ArcGIS.Desktop.Mapping.IElement.SetName(System.String) #region Element_SetName //Modify an element's name. @@ -245,7 +273,8 @@ await QueuedTask.Run(() => }); #endregion Element_SetName - // cref: Element_SetTOCPositionAbsolute;ArcGIS.Desktop.Layouts.Element.SetTOCPositionAbsolute(ArcGIS.Desktop.Layouts.ILayoutElementContainer,System.Boolean) + // cref: Element_SetTOCPositionAbsolute;ArcGIS.Desktop.Layouts.Element.SetTOCPositionAbsolute + // cref: Element_SetTOCPositionAbsolute;ArcGIS.Desktop.Mapping.IElement.SetTOCPositionAbsolute #region Element_SetTOCPositionAbsolute //Move an element to the top of the TOC @@ -256,7 +285,8 @@ await QueuedTask.Run(() => }); #endregion Element_SetTOCPositionAbsolute - // cref: Element_SetTOCPositionRelative;ArcGIS.Desktop.Layouts.Element.SetTOCPositionRelative(ArcGIS.Desktop.Layouts.Element,System.Boolean) + // cref: Element_SetTOCPositionRelative;ArcGIS.Desktop.Layouts.Element.SetTOCPositionRelative + // cref: Element_SetTOCPositionRelative;ArcGIS.Desktop.Mapping.IElement.SetTOCPositionRelative #region Element_SetTOCPositionRelative //Move a layout element above an existing layout element. @@ -267,7 +297,8 @@ await QueuedTask.Run(() => }); #endregion Element_SetTOCPositionRelative - // cref: Element_SetVisible;ArcGIS.Desktop.Layouts.Element.SetVisible(System.Boolean) + // cref: Element_SetVisible;ArcGIS.Desktop.Layouts.Element.SetVisible + // cref: Element_SetVisible;ArcGIS.Desktop.Mapping.IElement.SetVisible #region Element_SetVisible //Modify an element's visibility. @@ -296,10 +327,13 @@ async public static void CreateElementSnippets() LayoutView lytView = LayoutView.Active; Layout layout = lytView.Layout; - // cref: Create_BezierCurve;ArcGIS.Desktop.Layouts.IElementFactory.CreateBezierCurveGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.CIM.CIMLineSymbol) - // cref: Create_BezierCurve;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateBezierCurveGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.CIM.CIMLineSymbol) + // cref: Create_BezierCurve;ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: Create_BezierCurve;ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: Create_BezierCurve;ArcGIS.Desktop.Layouts.GraphicElement + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ToSegment #region Create_BezierCurve - //Create a beizier curve element with a simple line style. + //Create a bezier curve element with a simple line style. //Construct on the worker thread await QueuedTask.Run(() => @@ -309,19 +343,24 @@ await QueuedTask.Run(() => Coordinate2D pt2 = new Coordinate2D(1.66, 8); Coordinate2D pt3 = new Coordinate2D(2.33, 7.1); Coordinate2D pt4 = new Coordinate2D(3, 7.5); - CubicBezierBuilder bez = new CubicBezierBuilder(pt1, pt2, pt3, pt4); + //At 2.x - CubicBezierBuilder bez = new CubicBezierBuilder(pt1, pt2, pt3, pt4); + var bez = new CubicBezierBuilderEx(pt1, pt2, pt3, pt4); CubicBezierSegment bezSeg = bez.ToSegment(); - Polyline bezPl = PolylineBuilder.CreatePolyline(bezSeg); + //At 2.x - Polyline bezPl = PolylineBuilder.CreatePolyline(bezSeg); + Polyline bezPl = PolylineBuilderEx.CreatePolyline(bezSeg); //Set symbology, create and add element to layout CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.RedRGB, 4.0, SimpleLineStyle.DashDot); - GraphicElement bezElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, bezPl, lineSym); - bezElm.SetName("New Bezier Curve"); + //At 2.x - GraphicElement bezElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, bezPl, lineSym); + // bezElm.SetName("New Bezier Curve"); + GraphicElement bezElm = ElementFactory.Instance.CreateGraphicElement(layout, bezPl, lineSym, "New Bezier Curve"); }); #endregion Create_BezierCurve - // cref: Create_freehand;ArcGIS.Desktop.Layouts.IElementFactory.CreateFreehandGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.CIM.CIMLineSymbol) - // cref: Create_freehand;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateFreehandGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.CIM.CIMLineSymbol) + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline #region Create_freehand //Create a graphic freehand element with a simple line style. @@ -338,17 +377,21 @@ await QueuedTask.Run(() => plCoords.Add(new Coordinate2D(0.5, 1)); plCoords.Add(new Coordinate2D(0.75, 2)); plCoords.Add(new Coordinate2D(1, 1)); - Polyline linePl = PolylineBuilder.CreatePolyline(plCoords); + //At 2.x - Polyline linePl = PolylineBuilder.CreatePolyline(plCoords); + Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords); //Set symbolology, create and add element to layout CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid); - GraphicElement lineElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, linePl, lineSym); - lineElm.SetName("New Freehand"); + //At 2.x - GraphicElement lineElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, linePl, lineSym); + // lineElm.SetName("New Freehand"); + GraphicElement lineElm = ElementFactory.Instance.CreateGraphicElement(layout, linePl, lineSym, "New Freehand"); }); #endregion Create_freehand - // cref: Create_polygon_poly;ArcGIS.Desktop.Layouts.IElementFactory.CreatePolygonGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,ArcGIS.Core.CIM.CIMPolygonSymbol) - // cref: Create_polygon_poly;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePolygonGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,ArcGIS.Core.CIM.CIMPolygonSymbol) + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon #region Create_polygon_poly //Create a polygon graphic with simple line and fill styles. @@ -363,18 +406,26 @@ await QueuedTask.Run(() => plyCoords.Add(new Coordinate2D(3, 6.7)); plyCoords.Add(new Coordinate2D(3, 6.1)); plyCoords.Add(new Coordinate2D(1, 6.1)); - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); + //At 2.x - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); //Set symbolology, create and add element to layout CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.DashDotDot); CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline); - GraphicElement polyElm = LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, poly, polySym); - polyElm.SetName("New Polygon"); + //At 2.x - GraphicElement polyElm = LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, poly, polySym); + // polyElm.SetName("New Polygon"); + GraphicElement polyElm = ElementFactory.Instance.CreateGraphicElement(layout, poly, polySym, "New Polygon"); }); #endregion Create_polygon_poly - // cref: Create_polygon_env;ArcGIS.Desktop.Layouts.IElementFactory.CreatePolygonGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Core.CIM.CIMPolygonSymbol) - // cref: Create_polygon_env;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePolygonGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Core.CIM.CIMPolygonSymbol) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructStroke + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol + // cref: ArcGIS.Core.CIM.CIMStroke + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope #region Create_polygon_env //Create a polygon graphic using an envelope with simple line and fill styles. @@ -384,18 +435,33 @@ await QueuedTask.Run(() => //Build 2D envelope Coordinate2D env_ll = new Coordinate2D(1.0, 4.75); Coordinate2D env_ur = new Coordinate2D(3.0, 5.75); - Envelope env = EnvelopeBuilder.CreateEnvelope(env_ll, env_ur); + //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(env_ll, env_ur); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(env_ll, env_ur); //Set symbolology, create and add element to layout - CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.DashDotDot); - CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline); - GraphicElement polyElm = LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, env, polySym); - polyElm.SetName("New Polygon"); + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.DashDotDot); + CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline); + //At 2.x - GraphicElement polyElm = + // LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, env, polySym); + // polyElm.SetName("New Polygon"); + GraphicElement polyElm = ElementFactory.Instance.CreateGraphicElement( + layout, env, polySym, "New Polygon"); }); #endregion Create_polygon_env - // cref: Create_circle;ArcGIS.Desktop.Layouts.IElementFactory.CreateCircleGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,ArcGIS.Core.CIM.CIMPolygonSymbol) - // cref: Create_circle;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateCircleGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,ArcGIS.Core.CIM.CIMPolygonSymbol) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.ToSegment + // cref: ArcGIS.Core.Geometry.EllipticArcSegment + // cref: ArcGIS.Core.Geometry.ArcOrientation + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructStroke + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol + // cref: ArcGIS.Core.CIM.CIMStroke + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement #region Create_circle //Create a circle graphic element using a simple line and fill styles. @@ -404,19 +470,33 @@ await QueuedTask.Run(() => { //Build geometry Coordinate2D center = new Coordinate2D(2, 4); - EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise); + //At 2.x - EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise); + var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise); EllipticArcSegment cir = eabCir.ToSegment(); //Set symbolology, create and add element to layout CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Dash); CIMPolygonSymbol circleSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline); - GraphicElement cirElm = LayoutElementFactory.Instance.CreateCircleGraphicElement(layout, cir, circleSym); - cirElm.SetName("New Circle"); + //At 2.x - GraphicElement cirElm = LayoutElementFactory.Instance.CreateCircleGraphicElement(layout, cir, circleSym); + // cirElm.SetName("New Circle"); + + var polyLine = PolylineBuilderEx.CreatePolyline(cir); + GraphicElement cirElm = ElementFactory.Instance.CreateGraphicElement(layout, polyLine, circleSym, "New Circle"); }); #endregion - // cref: Create_ellipse;ArcGIS.Desktop.Layouts.IElementFactory.CreateEllipseGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,ArcGIS.Core.CIM.CIMPolygonSymbol) - // cref: Create_ellipse;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateEllipseGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,ArcGIS.Core.CIM.CIMPolygonSymbol) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.ToSegment + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline + // cref: ArcGIS.Core.Geometry.EllipticArcSegment + // cref: ArcGIS.Core.Geometry.ArcOrientation + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructStroke + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol + // cref: ArcGIS.Core.CIM.CIMStroke + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement #region Create_ellipse //Create an ellipse graphic with simple line and fill styles. @@ -425,19 +505,26 @@ await QueuedTask.Run(() => { //Build geometry Coordinate2D center = new Coordinate2D(2, 2.75); - EllipticArcBuilder eabElp = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise); + //At 2.x - EllipticArcBuilder eabElp = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise); + var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise); EllipticArcSegment ellipse = eabElp.ToSegment(); //Set symbolology, create and add element to layout CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.GreenRGB, 2.0, SimpleLineStyle.Dot); CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical, outline); - GraphicElement elpElm = LayoutElementFactory.Instance.CreateEllipseGraphicElement(layout, ellipse, ellipseSym); - elpElm.SetName("New Ellipse"); + //At 2.x - GraphicElement elpElm = LayoutElementFactory.Instance.CreateEllipseGraphicElement(layout, ellipse, ellipseSym); + // elpElm.SetName("New Ellipse"); + + var polyLine = PolylineBuilderEx.CreatePolyline(ellipse); + GraphicElement elpElm = ElementFactory.Instance.CreateGraphicElement(layout, polyLine, ellipseSym, "New Ellipse"); }); #endregion - // cref: Create_lasso;ArcGIS.Desktop.Layouts.IElementFactory.CreateLassoGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,ArcGIS.Core.CIM.CIMPolygonSymbol) - // cref: Create_lasso;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateLassoGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,ArcGIS.Core.CIM.CIMPolygonSymbol) + + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement #region Create_lasso //Create a graphic lasso element with simple line and fill styles. @@ -455,20 +542,28 @@ await QueuedTask.Run(() => plyCoords.Add(new Coordinate2D(2.5, 1.1)); plyCoords.Add(new Coordinate2D(2.75, 2)); plyCoords.Add(new Coordinate2D(3, 1)); - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); + //At 2.x - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); //Set symbolology, create and add element to layout CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid); CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline); - GraphicElement polyElm = LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, poly, polySym); - polyElm.SetName("New Lasso"); + //At 2.x - GraphicElement polyElm = LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, poly, polySym); + // polyElm.SetName("New Lasso"); + GraphicElement polyElm = ElementFactory.Instance.CreateGraphicElement(layout, poly, polySym, "New Lasso"); }); #endregion Create_lasso - // cref: Create_CurveText;ArcGIS.Desktop.Layouts.IElementFactory.CreateCurvedTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,System.String) - // cref: Create_CurveText;ArcGIS.Desktop.Layouts.IElementFactory.CreateCurvedTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,System.String,ArcGIS.Core.CIM.CIMTextSymbol) - // cref: Create_CurveText;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateCurvedTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,System.String) - // cref: Create_CurveText;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateCurvedTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,System.String,ArcGIS.Core.CIM.CIMTextSymbol) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ToSegment + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline + // cref: ArcGIS.Core.Geometry.CubicBezierSegment + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Core.CIM.CIMTextSymbol + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement + // cref: ArcGIS.Desktop.Layouts.TextType #region Create_CurveText //Create curve text with basic text properties. @@ -480,21 +575,34 @@ await QueuedTask.Run(() => Coordinate2D pt2 = new Coordinate2D(4.26, 8); Coordinate2D pt3 = new Coordinate2D(4.93, 7.1); Coordinate2D pt4 = new Coordinate2D(5.6, 7.5); - CubicBezierBuilder bez = new CubicBezierBuilder(pt1, pt2, pt3, pt4); + //At 2.x - CubicBezierBuilder bez = new CubicBezierBuilder(pt1, pt2, pt3, pt4); + var bez = new CubicBezierBuilderEx(pt1, pt2, pt3, pt4); CubicBezierSegment bezSeg = bez.ToSegment(); - Polyline bezPl = PolylineBuilder.CreatePolyline(bezSeg); + //At 2.x - Polyline bezPl = PolylineBuilder.CreatePolyline(bezSeg); + Polyline bezPl = PolylineBuilderEx.CreatePolyline(bezSeg); //Set symbolology, create and add element to layout CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 24, "Comic Sans MS", "Regular"); - GraphicElement bezTxtElm = LayoutElementFactory.Instance.CreateCurvedTextGraphicElement(layout, bezPl, "Curved Text", sym); - bezTxtElm.SetName("New Splinned Text"); + //At 2.x - GraphicElement bezTxtElm = LayoutElementFactory.Instance.CreateCurvedTextGraphicElement(layout, bezPl, "Curved Text", sym); + // bezTxtElm.SetName("New Splinned Text"); + GraphicElement bezTxtElm = ElementFactory.Instance.CreateTextGraphicElement( + layout, TextType.SplinedText, bezPl, sym, "Curved Text", "New Splinned Text"); }); #endregion Create_CurveText - // cref: Create_PolygonText;ArcGIS.Desktop.Layouts.IElementFactory.CreatePolygonParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,System.String) - // cref: Create_PolygonText;ArcGIS.Desktop.Layouts.IElementFactory.CreatePolygonParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,System.String,ArcGIS.Core.CIM.CIMTextSymbol) - // cref: Create_PolygonText;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePolygonParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,System.String) - // cref: Create_PolygonText;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePolygonParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,System.String,ArcGIS.Core.CIM.CIMTextSymbol) + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ARCGIS.DESKTOP.LAYOUTS.GRAPHICELEMENT.SETGRAPHIC + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Core.CIM.CIMTextSymbol + // cref: ArcGIS.Core.CIM.CIMGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic.Frame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame.BorderSymbol + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement + // cref: ArcGIS.Desktop.Layouts.TextType #region Create_PolygonText //Create polygon paragraph text with basic text properties. @@ -509,13 +617,16 @@ await QueuedTask.Run(() => plyCoords.Add(new Coordinate2D(5.5, 6.7)); plyCoords.Add(new Coordinate2D(5.5, 6.1)); plyCoords.Add(new Coordinate2D(3.5, 6.1)); - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); + //At 2.x - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); //Set symbolology, create and add element to layout CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular"); string text = "Some Text String that is really long and is forced to wrap to other lines so that we can see the effects." as String; - GraphicElement polyTxtElm = LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(layout, poly, text, sym); - polyTxtElm.SetName("New Polygon Text"); + //At 2.x - GraphicElement polyTxtElm = LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(layout, poly, text, sym); + // polyTxtElm.SetName("New Polygon Text"); + GraphicElement polyTxtElm = ElementFactory.Instance.CreateTextGraphicElement( + layout, TextType.RectangleParagraph, poly, sym, text, "New Polygon Text"); //(Optionally) Modify paragraph border CIMGraphic polyTxtGra = polyTxtElm.GetGraphic(); @@ -527,10 +638,19 @@ await QueuedTask.Run(() => #endregion Create_PolygonText - // cref: Create_CircleText;ArcGIS.Desktop.Layouts.IElementFactory.CreateCircleParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,System.String) - // cref: Create_CircleText;ArcGIS.Desktop.Layouts.IElementFactory.CreateCircleParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,System.String,ArcGIS.Core.CIM.CIMTextSymbol) - // cref: Create_CircleText;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateCircleParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,System.String) - // cref: Create_CircleText;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateCircleParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,System.String,ArcGIS.Core.CIM.CIMTextSymbol) + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ARCGIS.DESKTOP.LAYOUTS.GRAPHICELEMENT.SETGRAPHIC + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Core.CIM.CIMTextSymbol + // cref: ArcGIS.Core.CIM.CIMGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic.Frame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame.BorderSymbol + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement + // cref: ArcGIS.Desktop.Layouts.TextType #region Create_CircleText //Create circle paragraph text with basic text settings and optionally a modified border. @@ -539,14 +659,19 @@ await QueuedTask.Run(() => { //Build geometry Coordinate2D center = new Coordinate2D(4.5, 4); - EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise); + //At 2.x - EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise); + var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise); EllipticArcSegment cir = eabCir.ToSegment(); + var polyCir = PolygonBuilderEx.CreatePolygon( + PolylineBuilderEx.CreatePolyline(cir)); //Set symbolology, create and add element to layout CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreenRGB, 10, "Arial", "Regular"); string text = "Circle, circle, circle, circle, circle, circle, circle, circle, circle, circle, circle"; - GraphicElement cirTxtElm = LayoutElementFactory.Instance.CreateCircleParagraphGraphicElement(layout, cir, text, sym); - cirTxtElm.SetName("New Circle Text"); + //At 2.x - GraphicElement cirTxtElm = LayoutElementFactory.Instance.CreateCircleParagraphGraphicElement(layout, cir, text, sym); + // cirTxtElm.SetName("New Circle Text"); + GraphicElement cirTxtElm = ElementFactory.Instance.CreateTextGraphicElement( + layout, TextType.CircleParagraph, polyCir, sym, text, "New Circle Text"); //(Optionally) Modify paragraph border CIMGraphic cirTxtGra = cirTxtElm.GetGraphic(); @@ -557,10 +682,19 @@ await QueuedTask.Run(() => }); #endregion - // cref: Create_EllipseText;ArcGIS.Desktop.Layouts.IElementFactory.CreateEllipseParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,System.String) - // cref: Create_EllipseText;ArcGIS.Desktop.Layouts.IElementFactory.CreateEllipseParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,System.String,ArcGIS.Core.CIM.CIMTextSymbol) - // cref: Create_EllipseText;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateEllipseParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,System.String) - // cref: Create_EllipseText;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateEllipseParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.EllipticArcSegment,System.String,ArcGIS.Core.CIM.CIMTextSymbol) + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ARCGIS.DESKTOP.LAYOUTS.GRAPHICELEMENT.SETGRAPHIC + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Core.CIM.CIMTextSymbol + // cref: ArcGIS.Core.CIM.CIMGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic.Frame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame.BorderSymbol + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicElement + // cref: ArcGIS.Desktop.Layouts.TextType #region Create_EllipseText //Create ellipse paragraph text with basic text settings and optionally a modified border. @@ -569,14 +703,19 @@ await QueuedTask.Run(() => { //Build geometry Coordinate2D center = new Coordinate2D(4.5, 2.75); - EllipticArcBuilder eabElp = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise); + //At 2.x - EllipticArcBuilder eabElp = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise); + var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise); EllipticArcSegment ellipse = eabElp.ToSegment(); + var polyElp = PolygonBuilderEx.CreatePolygon( + PolylineBuilderEx.CreatePolyline(ellipse)); //Set symbolology, create and add element to layout CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlueRGB, 10, "Arial", "Regular"); string text = "Ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse, ellipse"; - GraphicElement elpTxtElm = LayoutElementFactory.Instance.CreateEllipseParagraphGraphicElement(layout, ellipse, text, sym); - elpTxtElm.SetName("New Ellipse Text"); + //At 2.x - GraphicElement elpTxtElm = LayoutElementFactory.Instance.CreateEllipseParagraphGraphicElement(layout, ellipse, text, sym); + // elpTxtElm.SetName("New Ellipse Text"); + GraphicElement elpTxtElm = ElementFactory.Instance.CreateTextGraphicElement( + layout, TextType.EllipseParagraph, polyElp, sym, text, "New Ellipse Text"); //(Optionally) Modify paragraph border CIMGraphic elpTxtGra = elpTxtElm.GetGraphic(); @@ -589,6 +728,10 @@ await QueuedTask.Run(() => MapFrame mfElm = null; + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateMapFrameElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapFrameElement + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetCamera(Layer,Boolean) #region Create_MapFrame //Creates a new map frame and changes the camera's scale. @@ -598,13 +741,15 @@ await QueuedTask.Run(() => //Build geometry Coordinate2D ll = new Coordinate2D(6.0, 8.5); Coordinate2D ur = new Coordinate2D(8.0, 10.5); - Envelope env = EnvelopeBuilder.CreateEnvelope(ll, ur); + //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(ll, ur); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); //Reference map, create MF and add to layout MapProjectItem mapPrjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("Map")); Map mfMap = mapPrjItem.GetMap(); - mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, env, mfMap); - mfElm.SetName("New Map Frame"); + //At 2.x - mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, env, mfMap); + // mfElm.SetName("New Map Frame"); + mfElm = ElementFactory.Instance.CreateMapFrameElement(layout, env, mfMap, "New Map Frame"); //Set the camera Camera camera = mfElm.Camera; @@ -613,9 +758,20 @@ await QueuedTask.Run(() => }); #endregion Create_MapFrame - // cref: Create_ScaleBar;ArcGIS.Desktop.Layouts.IElementFactory.CreateScaleBar(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Desktop.Layouts.MapFrame,ArcGIS.Desktop.Mapping.ScaleBarStyleItem) - // cref: Create_ScaleBar;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateScaleBar(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Desktop.Layouts.MapFrame,ArcGIS.Desktop.Mapping.ScaleBarStyleItem) - // cref: Create_ScaleBar;ArcGIS.Desktop.Layouts.ScaleBar + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.ScaleBarStyleItem + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ArcGIS.Desktop.Layouts.MapFrame + // cref: ArcGIS.Desktop.Layouts.ScaleBarInfo + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Layouts.ScaleBarInfo.ScaleBarStyleItem + // cref: ArcGIS.Desktop.Layouts.ScaleBar + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSCALEBARS + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.Element.SETX + // cref: ArcGIS.Desktop.Layouts.Element.SETY + // cref: ArcGIS.Desktop.Layouts.Element.SETWIDTH #region Create_ScaleBar //Create a scale bar for a specific map frame and assign a scale bar style item. @@ -636,17 +792,41 @@ await QueuedTask.Run(() => ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING"); return; } - ScaleBar sbElm = LayoutElementFactory.Instance.CreateScaleBar(layout, center, mf, sbStyleItm); - sbElm.SetName("New Scale Bar"); + + //At 2.x - + //ScaleBar sbElm = LayoutElementFactory.Instance.CreateScaleBar(layout, center, mf, sbStyleItm); + //sbElm.SetName("New Scale Bar"); + //sbElm.SetWidth(2); + //sbElm.SetX(6); + //sbElm.SetY(7.5); + + var sbInfo = new ScaleBarInfo() + { + MapFrameName = mf.Name, + ScaleBarStyleItem = sbStyleItm + }; + var sbElm = ElementFactory.Instance.CreateMapSurroundElement( + layout, center.ToMapPoint(), sbInfo, "New Scale Bar") as ScaleBar; sbElm.SetWidth(2); sbElm.SetX(6); sbElm.SetY(7.5); }); #endregion Create_ScaleBar - // cref: Create_NorthArrow;ArcGIS.Desktop.Layouts.IElementFactory.CreateNorthArrow(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Desktop.Layouts.MapFrame,ArcGIS.Desktop.Mapping.NorthArrowStyleItem) - // cref: Create_NorthArrow;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateNorthArrow(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Desktop.Layouts.MapFrame,ArcGIS.Desktop.Mapping.NorthArrowStyleItem) - // cref: Create_NorthArrow;ArcGIS.Desktop.Layouts.NorthArrow + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.NorthArrowStyleItem + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ArcGIS.Desktop.Layouts.MapFrame + // cref: ArcGIS.Desktop.Layouts.NorthArrowInfo + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Layouts.NorthArrowInfo.NorthArrowStyleItem + // cref: ArcGIS.Desktop.Layouts.NorthArrow + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHNORTHARROWS + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.Element.SETX + // cref: ArcGIS.Desktop.Layouts.Element.SETY + // cref: ArcGIS.Desktop.Layouts.Element.SetHeight #region Create_NorthArrow //Create a north arrow for a specific map frame and assign a north arrow style item. @@ -667,16 +847,30 @@ await QueuedTask.Run(() => ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING"); return; } - NorthArrow arrowElm = LayoutElementFactory.Instance.CreateNorthArrow(layout, center, mf, naStyleItm); - arrowElm.SetName("New North Arrow"); + //At 2.x - + //NorthArrow arrowElm = LayoutElementFactory.Instance.CreateNorthArrow(layout, center, mf, naStyleItm); + //arrowElm.SetName("New North Arrow"); + //arrowElm.SetHeight(1.75); + //arrowElm.SetX(7); + //arrowElm.SetY(6); + + var naInfo = new NorthArrowInfo() + { + MapFrameName = mf.Name, + NorthArrowStyleItem = naStyleItm + }; + + var arrowElm = ElementFactory.Instance.CreateMapSurroundElement( + layout, center.ToMapPoint(), naInfo, "New North Arrow") as NorthArrow; arrowElm.SetHeight(1.75); arrowElm.SetX(7); arrowElm.SetY(6); }); #endregion Create_NorthArrow - // cref: Create_Empty_Group_Root;ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer) - // cref: Create_Empty_Group_Root;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateGroupElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer) + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.GroupElement #region Create_Empty_Group_Root //Create an empty group element at the root level of the contents pane. @@ -684,11 +878,16 @@ await QueuedTask.Run(() => //Construct on the worker thread await QueuedTask.Run(() => { - GroupElement emptyGroupAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout); - emptyGroupAtRoot.SetName("Empty group at root"); + //At 2.x - GroupElement emptyGroupAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout); + // emptyGroupAtRoot.SetName("Empty group at root"); + GroupElement emptyGroupAtRoot = ElementFactory.Instance.CreateGroupElement(layout, null, "Empty group at root"); }); #endregion + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.GroupElement + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement #region Create_Empty_Group_Group //Create an empty group element at the root level of another group element. @@ -698,13 +897,19 @@ await QueuedTask.Run(() => //Construct on the worker thread await QueuedTask.Run(() => { - GroupElement emptyGroupInGroupAtRoot = LayoutElementFactory.Instance.CreateGroupElement(existingGroupAtRoot); - emptyGroupInGroupAtRoot.SetName("Empty group in group at root"); + //At 2.x - GroupElement emptyGroupInGroupAtRoot = LayoutElementFactory.Instance.CreateGroupElement(existingGroupAtRoot); + // emptyGroupInGroupAtRoot.SetName("Empty group in group at root"); + GroupElement emptyGroupInGroupAtRoot = ElementFactory.Instance.CreateGroupElement( + existingGroupAtRoot, null, "Empty group in group at root"); + }); #endregion - // cref: Create_Group_With_Single_Element_Root;ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Desktop.Layouts.Element) - // cref: Create_Group_With_Single_Element_Root;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateGroupElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Desktop.Layouts.Element) + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.GroupElement + // cref: ArcGIS.Desktop.Layouts.Element + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement #region Create_Group_With_Single_Element_Root //Create a group with a single element at the root level of the contents pane. @@ -714,13 +919,18 @@ await QueuedTask.Run(() => //Construct on the worker thread await QueuedTask.Run(() => { - GroupElement groupWithSingleElementAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, titleElm); - groupWithSingleElementAtRoot.SetName("Group with single element at root"); + //At 2.x - GroupElement groupWithSingleElementAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, titleElm); + // groupWithSingleElementAtRoot.SetName("Group with single element at root"); + GroupElement groupWithSingleElementAtRoot = + ElementFactory.Instance.CreateGroupElement(layout, new List() { titleElm }, "Group with single element at root"); }); #endregion - // cref: Create_Group_With_List_Elements_Root;ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,System.Collections.Generic.IList{ArcGIS.Desktop.Layouts.Element}) - // cref: Create_Group_With_List_Elements_Root;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateGroupElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,System.Collections.Generic.IList{ArcGIS.Desktop.Layouts.Element}) + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.GroupElement + // cref: ArcGIS.Desktop.Layouts.Element + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement #region Create_Group_With_List_Elements_Root //Create a group with a list of elements at the root level of the contents pane. @@ -740,13 +950,17 @@ await QueuedTask.Run(() => //Construct on the worker thread await QueuedTask.Run(() => { - GroupElement groupWithListOfElementsAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmList); - groupWithListOfElementsAtRoot.SetName("Group with list of elements at root"); + //At 2.x - GroupElement groupWithListOfElementsAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmList); + // groupWithListOfElementsAtRoot.SetName("Group with list of elements at root"); + GroupElement groupWithListOfElementsAtRoot = + ElementFactory.Instance.CreateGroupElement(layout, elmList, "Group with list of elements at root"); }); #endregion - // cref: Create_Group_With_List_Element_Names_Root;ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,System.String[]) - // cref: Create_Group_With_List_Element_Names_Root;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateGroupElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,System.String[]) + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGroupElement + // cref: ArcGIS.Desktop.Layouts.GroupElement + // cref: ArcGIS.Desktop.Layouts.Layout.FindElements #region Create_Group_With_List_Element_Names_Root //Create a group using a list of element names at the root level of the contents pane. @@ -756,8 +970,13 @@ await QueuedTask.Run(() => //Construct on the worker thread await QueuedTask.Run(() => { - GroupElement groupWithListOfElementNamesAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmNameList); - groupWithListOfElementNamesAtRoot.SetName("Group with list of element names at root"); + //GroupElement groupWithListOfElementNamesAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmNameList); + //groupWithListOfElementNamesAtRoot.SetName("Group with list of element names at root"); + + //At 3.x use FindElements to retrieve the respective elements first + var elems = layout.FindElements(elmNameList); + GroupElement groupWithListOfElementNamesAtRoot = + ElementFactory.Instance.CreateGroupElement(layout, elems, "Group with list of element names at root"); }); #endregion diff --git a/Examples/Layouts/ExportCodeSamples.cs b/Examples/Layouts/ExportCodeSamples.cs index 6c69f4e..5438074 100644 --- a/Examples/Layouts/ExportCodeSamples.cs +++ b/Examples/Layouts/ExportCodeSamples.cs @@ -39,6 +39,16 @@ async public static void ExportLayoutToPDF() Layout layout = await QueuedTask.Run(() => layoutItem.GetLayout()); String filePath = null; + // cref: ArcGIS.Desktop.Layouts.Layout.Export + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ArcGIS.Desktop.Mapping.PDFFormat.ImageCompression + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.IMAGEQUALITY + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.LAYERSANDATTRIBUTES + // cref: ARCGIS.DESKTOP.MAPPING.ImageCompression + // cref: ARCGIS.DESKTOP.MAPPING.ImageQuality + // cref: ARCGIS.DESKTOP.MAPPING.LayersAndAttributes #region Layout_ExportPDF //Export a layout to PDF @@ -67,14 +77,14 @@ async public static void ExportLayoutToPDF() } - - - - - namespace Layout_HelpExamples { - // cref: ExportBMP_Layout;ArcGIS.Desktop.Mapping.BMPFormat + // cref: ArcGIS.Desktop.Mapping.BMPFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportBMP_Layout //This example demonstrates how to export a layout to BMP. @@ -114,6 +124,13 @@ public static Task ExportLayoutToBMPAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.BMPFormat + // cref: ArcGIS.Desktop.Mapping.BMPFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportBMP_MapFrame //This example demonstrates how to export an individual map frame on a layout to BMP. @@ -156,6 +173,15 @@ public static Task ExportMapFrameToBMPAsync(string LayoutName, string MFName, st namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.BMPFormat + // cref: ArcGIS.Desktop.Mapping.BMPFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Height + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Width + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportBMP_ActiveMap //This example demonstrates how to export the active mapview to BMP. @@ -193,7 +219,12 @@ public static Task ExportActiveMapToBMPAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportEMF_Layout;ArcGIS.Desktop.Mapping.EMFFormat + // cref: ArcGIS.Desktop.Mapping.EMFFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportEMF_Layout //This example demonstrates how to export a layout to EMF. @@ -233,6 +264,13 @@ public static Task ExportLayoutToEMFAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + + // cref: ArcGIS.Desktop.Mapping.EMFFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportEMF_MapFrame //This example demonstrates how to export an individual map frame on a layout to EMF. @@ -274,6 +312,12 @@ public static Task ExportMapFrameToEMFAsync(string LayoutName, string MFName, st namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.EMFFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportEMF_ActiveMap //This example demonstrates how to export the active mapview to EMF. @@ -310,7 +354,12 @@ public static Task ExportActiveMapToEMFAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportEPS_Layout;ArcGIS.Desktop.Mapping.EPSFormat + // cref: ArcGIS.Desktop.Mapping.EPSFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportEPS_Layout //This example demonstrates how to export a layout to EPS. @@ -350,6 +399,12 @@ public static Task ExportLayoutToEPSAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.EPSFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportEPS_MapFrame //This example demonstrates how to export an individual map frame on a layout to EPS. @@ -391,6 +446,12 @@ public static Task ExportMapFrameToEPSAsync(string LayoutName, string MFName, st namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.EPSFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportEPS_ActiveMap //This example demonstrates how to export the active mapview to EPS. @@ -405,7 +466,7 @@ public static Task ExportActiveMapToEPSAsync(string Path) return QueuedTask.Run(() => { //Reference the active map view - MapView map = MapView.Active; + MapView mapv = MapView.Active; //Create EMF format with appropriate settings EPSFormat EPS = new EPSFormat(); @@ -417,7 +478,7 @@ public static Task ExportActiveMapToEPSAsync(string Path) //Export active map view if (EPS.ValidateOutputFilePath()) { - map.Export(EPS); + mapv.Export(EPS); } }); } @@ -427,7 +488,12 @@ public static Task ExportActiveMapToEPSAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportGIF_Layout;ArcGIS.Desktop.Mapping.GIFFormat + // cref: ArcGIS.Desktop.Mapping.GIFFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportGIF_Layout //This example demonstrates how to export a layout to GIF. @@ -467,6 +533,13 @@ public static Task ExportLayoutToGIFAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.GIFFormat + // cref: ArcGIS.Desktop.Mapping.GIFFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportGIF_MapFrame //This example demonstrates how to export an individual map frame on a layout to GIF. @@ -509,6 +582,15 @@ public static Task ExportMapFrameToGIFAsync(string LayoutName, string MFName, st namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.GIFFormat + // cref: ArcGIS.Desktop.Mapping.GIFFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Height + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Width + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportGIF_ActiveMap //This example demonstrates how to export the active mapview to GIF. @@ -523,7 +605,7 @@ public static Task ExportActiveMapToGIFAsync(string Path) return QueuedTask.Run(() => { //Reference the active map view - MapView map = MapView.Active; + MapView mapv = MapView.Active; //Create GIF format with appropriate settings GIFFormat GIF = new GIFFormat(); @@ -536,7 +618,7 @@ public static Task ExportActiveMapToGIFAsync(string Path) //Export active map view if (GIF.ValidateOutputFilePath()) { - map.Export(GIF); + mapv.Export(GIF); } }); } @@ -546,7 +628,12 @@ public static Task ExportActiveMapToGIFAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportJPEG_Layout;ArcGIS.Desktop.Mapping.JPEGFormat + // cref: ArcGIS.Desktop.Mapping.JPEGFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportJPEG_Layout //This example demonstrates how to export a layout to JPEG. @@ -586,6 +673,13 @@ public static Task ExportLayoutToJPEGAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.JPEGFormat + // cref: ArcGIS.Desktop.Mapping.JPEGFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportJPEG_MapFrame //This example demonstrates how to export an individual map frame on a layout to JPEG. @@ -615,7 +709,6 @@ public static Task ExportMapFrameToJPEGAsync(string LayoutName, string MFName, s //Export MapFrame Layout lyt = layoutItem.GetLayout(); //Loads and returns the layout associated with a LayoutItem MapFrame mf = lyt.FindElement(MFName) as MapFrame; - JPEG.OutputFileName = Path; if (JPEG.ValidateOutputFilePath()) { mf.Export(JPEG); @@ -628,6 +721,13 @@ public static Task ExportMapFrameToJPEGAsync(string LayoutName, string MFName, s namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.JPEGFormat + // cref: ArcGIS.Desktop.Mapping.JPEGFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportJPEG_ActiveMap //This example demonstrates how to export the active mapview to JPEG. @@ -642,7 +742,7 @@ public static Task ExportActiveMapToJPEGAsync(string Path) return QueuedTask.Run(() => { //Reference the active map view - MapView map = MapView.Active; + MapView mapv = MapView.Active; //Create JPEG format with appropriate settings JPEGFormat JPEG = new JPEGFormat(); @@ -655,7 +755,7 @@ public static Task ExportActiveMapToJPEGAsync(string Path) //Export active map view if (JPEG.ValidateOutputFilePath()) { - map.Export(JPEG); + mapv.Export(JPEG); } }); } @@ -665,7 +765,13 @@ public static Task ExportActiveMapToJPEGAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportPDF_Layout;ArcGIS.Desktop.Mapping.PDFFormat + // cref: ArcGIS.Desktop.Mapping.PDFFormat + // cref: ArcGIS.Desktop.Mapping.PDFFormat.Password + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportPDF_Layout //This example demonstrates how to export a layout to PDF. @@ -706,6 +812,13 @@ public static Task ExportLayoutToPDFAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.PDFFormat + // cref: ArcGIS.Desktop.Mapping.PDFFormat.Password + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportPDF_MapFrame //This example demonstrates how to export an individual map frame on a layout to PDF. @@ -728,6 +841,7 @@ public static Task ExportMapFrameToPDFAsync(string LayoutName, string MFName, st PDFFormat PDF = new PDFFormat(); PDF.Resolution = 300; PDF.OutputFileName = Path; + //PDF.Password = "xxx"; return QueuedTask.Run(() => { @@ -747,6 +861,12 @@ public static Task ExportMapFrameToPDFAsync(string LayoutName, string MFName, st namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.PDFFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportPDF_ActiveMap //This example demonstrates how to export the active mapview to PDF. @@ -761,7 +881,7 @@ public static Task ExportActiveMapToPDFAsync(string Path) return QueuedTask.Run(() => { //Reference the active map view - MapView map = MapView.Active; + MapView mapv = MapView.Active; //Create PDF format with appropriate settings PDFFormat PDF = new PDFFormat(); @@ -773,7 +893,7 @@ public static Task ExportActiveMapToPDFAsync(string Path) //Export active map view if (PDF.ValidateOutputFilePath()) { - map.Export(PDF); + mapv.Export(PDF); } }); } @@ -783,7 +903,12 @@ public static Task ExportActiveMapToPDFAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportPNG_Layout;ArcGIS.Desktop.Mapping.PNGFormat + // cref: ArcGIS.Desktop.Mapping.PNGFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportPNG_Layout //This example demonstrates how to export a layout to PNG. @@ -823,6 +948,12 @@ public static Task ExportLayoutToPNGAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.PNGFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportPNG_MapFrame //This example demonstrates how to export an individual map frame on a layout to PNG. @@ -864,6 +995,12 @@ public static Task ExportMapFrameToPNGAsync(string LayoutName, string MFName, st namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.PNGFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportPNG_ActiveMap //This example demonstrates how to export the active mapview to PNG. @@ -878,7 +1015,7 @@ public static Task ExportActiveMapToPNGAsync(string Path) return QueuedTask.Run(() => { //Reference the active map view - MapView map = MapView.Active; + MapView mapv = MapView.Active; //Create PNG format with appropriate settings PNGFormat PNG = new PNGFormat(); @@ -890,7 +1027,7 @@ public static Task ExportActiveMapToPNGAsync(string Path) //Export active map view if (PNG.ValidateOutputFilePath()) { - map.Export(PNG); + mapv.Export(PNG); } }); } @@ -900,7 +1037,12 @@ public static Task ExportActiveMapToPNGAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportSVG_Layout;ArcGIS.Desktop.Mapping.SVGFormat + // cref: ArcGIS.Desktop.Mapping.SVGFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportSVG_Layout //This example demonstrates how to export a layout to SVG. @@ -940,6 +1082,12 @@ public static Task ExportLayoutToSVGAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.SVGFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportSVG_MapFrame //This example demonstrates how to export an individual map frame on a layout to SVG. @@ -981,6 +1129,12 @@ public static Task ExportMapFrameToSVGAsync(string LayoutName, string MFName, st namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.SVGFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportSVG_ActiveMap //This example demonstrates how to export the active mapview to SVG. @@ -995,7 +1149,7 @@ public static Task ExportActiveMapToSVGAsync(string Path) return QueuedTask.Run(() => { //Reference the active map view - MapView map = MapView.Active; + MapView mapv = MapView.Active; //Create SVG format with appropriate settings SVGFormat SVG = new SVGFormat(); @@ -1007,7 +1161,7 @@ public static Task ExportActiveMapToSVGAsync(string Path) //Export active map view if (SVG.ValidateOutputFilePath()) { - map.Export(SVG); + mapv.Export(SVG); } }); } @@ -1017,7 +1171,12 @@ public static Task ExportActiveMapToSVGAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportTGA_Layout;ArcGIS.Desktop.Mapping.TGAFormat + // cref: ArcGIS.Desktop.Mapping.TGAFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportTGA_Layout //This example demonstrates how to export a layout to TGA. @@ -1057,6 +1216,12 @@ public static Task ExportLayoutToTGAAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.TGAFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportTGA_MapFrame //This example demonstrates how to export an individual map frame on a layout to TGA. @@ -1098,6 +1263,12 @@ public static Task ExportMapFrameToTGAAsync(string LayoutName, string MFName, st namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.TGAFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportTGA_ActiveMap //This example demonstrates how to export the active mapview to TGA. @@ -1112,7 +1283,7 @@ public static Task ExportActiveMapToTGAAsync(string Path) return QueuedTask.Run(() => { //Reference the active map view - MapView map = MapView.Active; + MapView mapv = MapView.Active; //Create TGA format with appropriate settings TGAFormat TGA = new TGAFormat(); @@ -1124,7 +1295,7 @@ public static Task ExportActiveMapToTGAAsync(string Path) //Export active map view if (TGA.ValidateOutputFilePath()) { - map.Export(TGA); + mapv.Export(TGA); } }); } @@ -1134,7 +1305,12 @@ public static Task ExportActiveMapToTGAAsync(string Path) namespace Layout_HelpExamples { - // cref: ExportTIFF_Layout;ArcGIS.Desktop.Mapping.TIFFFormat + // cref: ArcGIS.Desktop.Mapping.TIFFFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region ExportTIFF_Layout //This example demonstrates how to export a layout to TIFF. @@ -1174,6 +1350,12 @@ public static Task ExportLayoutToTIFFAsync(string LayoutName, string Path) namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.TIFFFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export #region ExportTIFF_MapFrame //This example demonstrates how to export an individual map frame on a layout to TIFF. @@ -1215,6 +1397,12 @@ public static Task ExportMapFrameToTIFFAsync(string LayoutName, string MFName, s namespace Layout_HelpExamples { + // cref: ArcGIS.Desktop.Mapping.TIFFFormat + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Mapping.MapView.Export #region ExportTIFF_ActiveMap //This example demonstrates how to export the active mapview to TIFF. @@ -1229,7 +1417,7 @@ public static Task ExportActiveMapToTIFFAsync(string Path) return QueuedTask.Run(() => { //Reference the active map view - MapView map = MapView.Active; + MapView mapv = MapView.Active; //Create TIFF format with appropriate settings TIFFFormat TIFF = new TIFFFormat(); @@ -1241,7 +1429,7 @@ public static Task ExportActiveMapToTIFFAsync(string Path) //Export active map view if (TIFF.ValidateOutputFilePath()) { - map.Export(TIFF); + mapv.Export(TIFF); } }); } diff --git a/Examples/Layouts/GraphicElementClass.cs b/Examples/Layouts/GraphicElementClass.cs index 2549c8d..617ed57 100644 --- a/Examples/Layouts/GraphicElementClass.cs +++ b/Examples/Layouts/GraphicElementClass.cs @@ -1,145 +1,155 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; - -namespace Layout_HelpExamples +/* + + Copyright 2018 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; + +namespace Layout_HelpExamples { // cref: CIMGraphic;ArcGIS.Desktop.Layouts.GraphicElement - #region CIMGraphic + // cref: CIMGraphic;ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: CIMGraphic;ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ARCGIS.DESKTOP.LAYOUTS.GRAPHICELEMENT.SETGRAPHIC + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ARCGIS.CORE.CIM.CIMGRAPHIC.TRANSPARENCY + #region CIMGraphic //This example references a graphic element on a layout and sets its Transparency property (which is not available in the managed API) //by accessing the element's CIMGraphic. //Added references - using ArcGIS.Core.CIM; //CIM - using ArcGIS.Desktop.Core; //Project - using ArcGIS.Desktop.Layouts; //Layout class - using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask - - public class GraphicElementExample1 - { - public static Task UpdateElementTransparencyAsync(string LayoutName, string ElementName, int TransValue) - { - //Reference a layoutitem in a project by name - LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(LayoutName)); - if (layoutItem == null) - return Task.FromResult(false); - - return QueuedTask.Run(() => - { - //Reference and load the layout associated with the layout item - Layout lyt = layoutItem.GetLayout(); - - //Reference a element by name - GraphicElement graElm = lyt.FindElement(ElementName) as GraphicElement; - if (graElm == null) - return false; - - //Modify the Transparency property that exists only in the CIMGraphic class. - CIMGraphic CIMGra = graElm.GetGraphic() as CIMGraphic; - CIMGra.Transparency = TransValue; //e.g., TransValue = 50 - graElm.SetGraphic(CIMGra); - - return true; - }); - } - } - #endregion CIMGraphic -} - - -namespace Layout_HelpExamples + using ArcGIS.Core.CIM; //CIM + using ArcGIS.Desktop.Core; //Project + using ArcGIS.Desktop.Layouts; //Layout class + using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask + + public class GraphicElementExample1 + { + public static Task UpdateElementTransparencyAsync(string LayoutName, string ElementName, int TransValue) + { + //Reference a layoutitem in a project by name + LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(LayoutName)); + if (layoutItem == null) + return Task.FromResult(false); + + return QueuedTask.Run(() => + { + //Reference and load the layout associated with the layout item + Layout lyt = layoutItem.GetLayout(); + + //Reference a element by name + GraphicElement graElm = lyt.FindElement(ElementName) as GraphicElement; + if (graElm == null) + return false; + + //Modify the Transparency property that exists only in the CIMGraphic class. + CIMGraphic CIMGra = graElm.GetGraphic() as CIMGraphic; + CIMGra.Transparency = TransValue; //e.g., TransValue = 50 + graElm.SetGraphic(CIMGra); + + return true; + }); + } + } + #endregion CIMGraphic +} + + +namespace Layout_HelpExamples { - #region CloneGraphic + // cref: ARCGIS.DESKTOP.LAYOUTS.GRAPHICELEMENT + // cref: ARCGIS.DESKTOP.LAYOUTS.GRAPHICELEMENT.CLONE + // cref: ArcGIS.Desktop.Layouts.Element.SETX + // cref: ArcGIS.Desktop.Layouts.Element.SETY + #region CloneGraphic //This example finds a layout element by name and clones it a specified number of times and applies an accumlative offset for each //cloned element. //Added references - using ArcGIS.Core.CIM; //CIM - using ArcGIS.Desktop.Core; //Project - using ArcGIS.Desktop.Layouts; //Layout class - using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask - - public class GraphicElementExample2 - { - public static Task CloneElementAsync(string LayoutName, string ElementName, double offset, int numCopies) - { - //Reference a layoutitem in a project by name - LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(LayoutName)); - if (layoutItem == null) - return Task.FromResult(false); - - return QueuedTask.Run(() => - { - //Reference and load the layout associated with the layout item - Layout lyt = layoutItem.GetLayout(); - - //Reference a element by name - GraphicElement graElm = lyt.FindElement(ElementName) as GraphicElement; - if (graElm == null) - return false; - - //Loop through the number of copies, clone, and set the offsets for each new element - double orig_offset = offset; - while (numCopies != 0) - { - GraphicElement cloneElm = graElm.Clone("Clone"); - cloneElm.SetX(cloneElm.GetX() + offset); - cloneElm.SetY(cloneElm.GetY() - offset); - offset = offset + orig_offset; - numCopies = numCopies - 1; - } - - return true; - }); - } - } - #endregion CloneGraphic -} - - -namespace Layout_HelpExamples -{ - internal class GraphicElementClass : Button - { - async protected override void OnClick() - { - //Set Transparency - bool b1 = await GraphicElementExample1.UpdateElementTransparencyAsync("Layout Name", "Rectangle", 50); - if (b1) - System.Windows.MessageBox.Show("Successfully Changed Transparency "); - else - System.Windows.MessageBox.Show("Could Not Change Transparency"); - - - //Clone Element - bool b2 = await GraphicElementExample2.CloneElementAsync("Layout Name", "Rectangle", 0.25, 5); - if (b2) - System.Windows.MessageBox.Show("Successfully Cloned Element "); - else - System.Windows.MessageBox.Show("Could Not Clone Element"); - - } - } -} + using ArcGIS.Core.CIM; //CIM + using ArcGIS.Desktop.Core; //Project + using ArcGIS.Desktop.Layouts; //Layout class + using ArcGIS.Desktop.Framework.Threading.Tasks; //QueuedTask + + public class GraphicElementExample2 + { + public static Task CloneElementAsync(string LayoutName, string ElementName, double offset, int numCopies) + { + //Reference a layoutitem in a project by name + LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(LayoutName)); + if (layoutItem == null) + return Task.FromResult(false); + + return QueuedTask.Run(() => + { + //Reference and load the layout associated with the layout item + Layout lyt = layoutItem.GetLayout(); + + //Reference a element by name + GraphicElement graElm = lyt.FindElement(ElementName) as GraphicElement; + if (graElm == null) + return false; + + //Loop through the number of copies, clone, and set the offsets for each new element + double orig_offset = offset; + while (numCopies != 0) + { + GraphicElement cloneElm = graElm.Clone("Clone"); + cloneElm.SetX(cloneElm.GetX() + offset); + cloneElm.SetY(cloneElm.GetY() - offset); + offset = offset + orig_offset; + numCopies = numCopies - 1; + } + + return true; + }); + } + } + #endregion CloneGraphic +} + + +namespace Layout_HelpExamples +{ + internal class GraphicElementClass : Button + { + async protected override void OnClick() + { + //Set Transparency + bool b1 = await GraphicElementExample1.UpdateElementTransparencyAsync("Layout Name", "Rectangle", 50); + if (b1) + System.Windows.MessageBox.Show("Successfully Changed Transparency "); + else + System.Windows.MessageBox.Show("Could Not Change Transparency"); + + + //Clone Element + bool b2 = await GraphicElementExample2.CloneElementAsync("Layout Name", "Rectangle", 0.25, 5); + if (b2) + System.Windows.MessageBox.Show("Successfully Cloned Element "); + else + System.Windows.MessageBox.Show("Could Not Clone Element"); + + } + } +} diff --git a/Examples/Layouts/LayoutClass.cs b/Examples/Layouts/LayoutClass.cs index 44a5700..e941c92 100644 --- a/Examples/Layouts/LayoutClass.cs +++ b/Examples/Layouts/LayoutClass.cs @@ -47,6 +47,8 @@ public class LayoutClassSamples { async public static void MethodSnippets() { + // cref: ARCGIS.DESKTOP.LAYOUTS.LAYOUTPROJECTITEM + // cref: ARCGIS.DESKTOP.LAYOUTS.LAYOUTPROJECTITEM.GetLayout #region LayoutProjectItem_GetLayout //Reference the layout associated with a layout project item. @@ -87,9 +89,9 @@ await QueuedTask.Run(() => TextElement txtElm = layout.FindElement("Text") as TextElement; #endregion Layout_FindElement - // cref: Layout_GetSetDefinition;ArcGIS.Desktop.Layouts.Layout.GetDefinition // cref: Layout_GetSetDefinition;ArcGIS.Desktop.Layouts.Layout.SetDefinition(ArcGIS.Core.CIM.CIMLayout) + // cref: ArcGIS.Core.CIM.CIMLayout #region Layout_GetSetDefinition //Modify a layout's CIM definition @@ -107,6 +109,7 @@ await QueuedTask.Run(() => // cref: Layout_GetSetPage;ArcGIS.Desktop.Layouts.Layout.GetPage // cref: Layout_GetSetPage;ArcGIS.Desktop.Layouts.Layout.SetPage(ArcGIS.Core.CIM.CIMPage) + // cref: ArcGIS.Core.CIM.CIMPage #region Layout_GetSetPage //Modify a layouts page settings. @@ -122,13 +125,21 @@ await QueuedTask.Run(() => }); #endregion Layout_GetSetPage - String filePath = null; - #region Layout_ExportPDF - //See ProSnippets "Export layout to PDF" - #endregion Layout_ExportPDF - + // cref: ArcGIS.Desktop.Layouts.Layout.Export + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ArcGIS.Desktop.Mapping.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.DoCompressVectorGraphics + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportPages + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.CustomPages + // cref: ArcGIS.Desktop.Mapping.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.ExportPages #region Layout_ExportMS_PDF //Export multiple map series pages to PDF @@ -156,7 +167,19 @@ await QueuedTask.Run(() => } #endregion Layout_ExportMS_PDF - + // cref: ArcGIS.Desktop.Layouts.Layout.Export + // cref: ARCGIS.DESKTOP.MAPPING.TIFFFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.TIFFFORMAT.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.TIFFFORMAT.HasGeoTiffTags + // cref: ARCGIS.DESKTOP.MAPPING.TIFFFORMAT.ColorMode + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.RESOLUTION + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportPages + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ShowSelectedSymbology + // cref: ArcGIS.Desktop.Mapping.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.ExportPages + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH #region Layout_ExportMS_TIFF //Export multiple map series pages to TIFF @@ -165,7 +188,7 @@ await QueuedTask.Run(() => { Resolution = 300, OutputFileName = filePath, - ColorMode = ColorMode.TwentyFourBitTrueColor, + ColorMode = TIFFColorMode.TwentyFourBitTrueColor, HasGeoTiffTags = true, HasWorldFile = true }; @@ -205,7 +228,7 @@ await QueuedTask.Run(() => //Perform on the worker thread await QueuedTask.Run(() => { - layout.SaveAsFile(filePath); + layout.SaveAsFile(filePath, true); }); #endregion Layout_SaveAsFile @@ -236,6 +259,8 @@ await QueuedTask.Run(() => // cref: Layout_ShowProperties;ArcGIS.Desktop.Layouts.Layout.ShowProperties + // cref: ARCGIS.DESKTOP.LAYOUTS.LAYOUTPROJECTITEM + // cref: ARCGIS.DESKTOP.LAYOUTS.LAYOUTPROJECTITEM.GetLayout #region Layout_ShowProperties //Open the layout properties dialog. diff --git a/Examples/Layouts/LayoutEvents.cs b/Examples/Layouts/LayoutEvents.cs index 0f886f2..6ce4cd5 100644 --- a/Examples/Layouts/LayoutEvents.cs +++ b/Examples/Layouts/LayoutEvents.cs @@ -45,292 +45,617 @@ async protected override Task InitializeAsync() { LayoutView lytView = LayoutView.Active; await ProApp.Panes.CreateLayoutPaneAsync(lytView.Layout); - // cref: ActivateMapFrameEvent;ArcGIS.Desktop.Layouts.Events.ActivateMapFrameEvent - #region ActivateMapFrameEvent + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventHint + #region ElementEvent_MapFrameActivated_Deactivated //Report the event args when a map frame is activated or deactivated. - ArcGIS.Desktop.Layouts.Events.ActivateMapFrameEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.ActivateMapFrameEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("ActiveMapFrameEvent:" + + // Environment.NewLine + + // " arg IsActivated: " + args.IsActivated.ToString() + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name + + // Environment.NewLine + + // " arg MapFrame: " + args.MapFrame.Name); + //}); + + ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("ActiveMapFrameEvent:" + - Environment.NewLine + - " arg IsActivated: " + args.IsActivated.ToString() + - Environment.NewLine + - " arg Layout: " + args.Layout.Name + - Environment.NewLine + - " arg MapFrame: " + args.MapFrame.Name); + var mapFrameName = args.Elements[0].Name; + if (args.Hint == ElementEventHint.MapFrameActivated) + { + System.Diagnostics.Debug.WriteLine($"ElementEventHint.MapFrameActivated: {mapFrameName}"); + } + else if (args.Hint == ElementEventHint.MapFrameDeactivated) + { + System.Diagnostics.Debug.WriteLine($"ElementEventHint.MapFrameDeactivated: {mapFrameName}"); + } }); - #endregion ActivateMapFrameEvent - - // cref: ActiveLayoutViewChangedEvent;ArcGIS.Desktop.Layouts.Events.ActiveLayoutViewChangedEvent - #region ActiveLayoutViewChangedEvent + #endregion + + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventHint + #region LayoutViewEvent_Activated_Deactivated //Report the event args when a the layout view has changed. - ArcGIS.Desktop.Layouts.Events.ActiveLayoutViewChangedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.ActiveLayoutViewChangedEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("ActiveLayoutViewChangedEvent:" + + // Environment.NewLine + + // " arg Layoutview: " + args.LayoutView.Layout.Name + + // Environment.NewLine + + // " arg Type: " + args.Type.ToString()); + //}); + + ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("ActiveLayoutViewChangedEvent:" + - Environment.NewLine + - " arg Layoutview: " + args.LayoutView.Layout.Name + - Environment.NewLine + - " arg Type: " + args.Type.ToString()); + //this is the view being activated + var layout = args.LayoutView?.Layout?.Name ?? "null"; + + if (args.Hint == LayoutViewEventHint.Activated) + { + System.Diagnostics.Debug.WriteLine($"LayoutViewEventHint.Activated: {layout}"); + } + else if (args.Hint == LayoutViewEventHint.Deactivated) + { + System.Diagnostics.Debug.WriteLine($"LayoutViewEventHint.Deactivated: {layout}"); + } }); - #endregion ActiveLayoutViewChangedEvent + #endregion - // cref: ElementAddedEvent;ArcGIS.Desktop.Layouts.Events.ElementAddedEvent - #region ElementAddedEvent + + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventHint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Elements + #region ElementEvent_ElementAdded //Report the event args when an element is added to the layout. - ArcGIS.Desktop.Layouts.Events.ElementAddedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementAddedEvent.Subscribe((args) => + //{ + // var elements = args.Elements; + // string elemNames = "null"; + // if (elements != null && elements.Count() > 0) + // { + // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + // } + // System.Windows.MessageBox.Show("ElementAddedEvent:" + + // Environment.NewLine + + // " arg Elements: " + elemNames.ToString() + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + + ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { - var elements = args.Elements; string elemNames = "null"; - if (elements != null && elements.Count() > 0) + if (args.Elements?.Count() > 0) + { + elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); + } + if (args.Hint == ElementEventHint.ElementAdded) { - elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + System.Diagnostics.Debug.WriteLine($"ElementEventHint.ElementAdded: {elemNames}"); } - System.Windows.MessageBox.Show("ElementAddedEvent:" + - Environment.NewLine + - " arg Elements: " + elemNames.ToString() + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); }); - #endregion ElementAddedEvent + #endregion - // cref: ElementRemovedEvent;ArcGIS.Desktop.Layouts.Events.ElementRemovedEvent - #region ElementRemovedEvent + + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventHint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Elements + #region ElementEvent_ElementRemoved //Report the event args when an element is removed from the layout. - ArcGIS.Desktop.Layouts.Events.ElementRemovedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementRemovedEvent.Subscribe((args) => + //{ + // var elements = args.Elements; + // string elemNames = "null"; + // if (elements != null && elements.Count() > 0) + // { + // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + // } + // System.Windows.MessageBox.Show("ElementRemovedEvent:" + + // Environment.NewLine + + // " arg Elements: " + elemNames.ToString() + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + + ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { - var elements = args.Elements; string elemNames = "null"; - if (elements != null && elements.Count() > 0) + if (args.Elements?.Count() > 0) + { + elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); + } + if (args.Hint == ElementEventHint.ElementRemoved) { - elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + System.Diagnostics.Debug.WriteLine($"ElementEventHint.ElementRemoved: {elemNames}"); } - System.Windows.MessageBox.Show("ElementRemovedEvent:" + - Environment.NewLine + - " arg Elements: " + elemNames.ToString() + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); }); - #endregion ElementRemovedEvent + #endregion - // cref: ElementsPlacementChangedEvent;ArcGIS.Desktop.Layouts.Events.ElementsPlacementChangedEvent - #region ElementsPlacementChangedEvent + + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventHint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Elements + #region ElementEvent_PlacementChanged //Report the event args when an element's placement properties are changed. - ArcGIS.Desktop.Layouts.Events.ElementsPlacementChangedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementsPlacementChangedEvent.Subscribe((args) => + //{ + // var elements = args.Elements; + // string elemNames = "null"; + // if (elements != null && elements.Count() > 0) + // { + // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + // } + // System.Windows.MessageBox.Show("ElementsPlacementChangedEvent:" + + // Environment.NewLine + + // " arg Elements: " + elemNames.ToString() + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + + ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { - var elements = args.Elements; string elemNames = "null"; - if (elements != null && elements.Count() > 0) + if (args.Elements?.Count() > 0) + { + elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); + } + if (args.Hint == ElementEventHint.PlacementChanged) { - elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + System.Diagnostics.Debug.WriteLine($"ElementEventHint.PlacementChanged: {elemNames}"); } - System.Windows.MessageBox.Show("ElementsPlacementChangedEvent:" + - Environment.NewLine + - " arg Elements: " + elemNames.ToString() + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); }); - #endregion ElementsPlacementChangedEvent + #endregion - // cref: ElementStyleChangedEvent;ArcGIS.Desktop.Layouts.Events.ElementStyleChangedEvent - #region ElementStyleChangedEvent + + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventHint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Elements + #region ElementEvent_StyleChanged //Report the event args when an element's style is changed. - ArcGIS.Desktop.Layouts.Events.ElementStyleChangedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementStyleChangedEvent.Subscribe((args) => + //{ + // var elements = args.Elements; + // string elemNames = "null"; + // if (elements != null && elements.Count() > 0) + // { + // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + // } + // System.Windows.MessageBox.Show("ElementStyleChangedEvent:" + + // Environment.NewLine + + // " arg Elements: " + elemNames.ToString() + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { - var elements = args.Elements; string elemNames = "null"; - if (elements != null && elements.Count() > 0) + if (args.Elements?.Count() > 0) { - elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); + } + if (args.Hint == ElementEventHint.StyleChanged) + { + System.Diagnostics.Debug.WriteLine($"ElementEventHint.StyleChanged: {elemNames}"); } - System.Windows.MessageBox.Show("ElementStyleChangedEvent:" + - Environment.NewLine + - " arg Elements: " + elemNames.ToString() + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); }); - #endregion ElementStyleChangedEvent + #endregion + + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Container + // cref: ArcGIS.Desktop.Mapping.IElementContainer.GetSelectedElements + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventHint + #region ElementEvent_SelectionChanged + //Report the event args when a layout's selection has changed. + + //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutSelectionChangedEvent.Subscribe((args) => { + // var elements = args.Elements; + // string elemNames = "null"; + // if (elements != null && elements.Count() > 0) + // { + // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + // } + // System.Windows.MessageBox.Show("LayoutSelectionChangedEvent:" + + // Environment.NewLine + + // " arg Elements: " + elemNames.ToString() + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + + ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => + { + if (args.Hint == ElementEventHint.SelectionChanged) + { + if (args.Container.GetSelectedElements()?.Count() > 0) + { + var elemNames = string.Join(",", args.Container.GetSelectedElements().Select(e => e.Name).ToList()); + System.Diagnostics.Debug.WriteLine($"ElementEventHint.SelectionChanged: {elemNames}"); + } + } - // cref: ElementsUpdatedEvent;ArcGIS.Desktop.Layouts.Events.ElementsUpdatedEvent - #region ElementsUpdatedEvent + }); + #endregion LayoutSelectionChangedEvent + + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent + // cref: ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventHint + // cref: ArcGIS.Desktop.Layouts.Events.ElementEventArgs.Container + // cref: ArcGIS.Desktop.Mapping.IElementContainer.GetSelectedElements + #region ElementEvent_PropertyChanged //Report the event args when an element has been updated. - ArcGIS.Desktop.Layouts.Events.ElementsUpdatedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.ElementsUpdatedEvent.Subscribe((args) => + //{ + // var elements = args.Elements; + // string elemNames = "null"; + // if (elements != null && elements.Count() > 0) + // { + // elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + // } + // System.Windows.MessageBox.Show("ElementsUpdatedEvent:" + + // Environment.NewLine + + // " arg Elements: " + elemNames.ToString() + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + ArcGIS.Desktop.Layouts.Events.ElementEvent.Subscribe((args) => { - var elements = args.Elements; string elemNames = "null"; - if (elements != null && elements.Count() > 0) + //can be null if the name was changed + if (args.Elements?.Count() > 0) { - elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); + elemNames = string.Join(",", args.Elements.Select(e => e.Name).ToList()); + } + else if (args.Container.GetSelectedElements()?.Count() > 0) + { + elemNames = string.Join(",", args.Container.GetSelectedElements().Select(e => e.Name).ToList()); } - System.Windows.MessageBox.Show("ElementsUpdatedEvent:" + - Environment.NewLine + - " arg Elements: " + elemNames.ToString() + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); - }); - #endregion ElementsUpdatedEvent - // cref: LayoutAddedEvent;ArcGIS.Desktop.Layouts.Events.LayoutAddedEvent - #region LayoutAddedEvent + if (args.Hint == ElementEventHint.PropertyChanged) + { + System.Diagnostics.Debug.WriteLine($"ElementEventHint.PropertyChanged: {elemNames}"); + } + }); + #endregion + + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Subscribe + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEventArgs + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEventArgs.Action + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout + #region LayoutAdded_ProjectItemsChangedEvent_Add //Report the event args when a layout is added. - ArcGIS.Desktop.Layouts.Events.LayoutAddedEvent.Subscribe((args) => - { - System.Windows.MessageBox.Show("LayoutAddedEvent:" + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); + //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutAddedEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("LayoutAddedEvent:" + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + + //Use ProjectItemsChangedEvent at 3.x + ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Subscribe((args) => { + //Layout added. Layout removed would be NotifyCollectionChangedAction.Remove + if (args.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add && + args.ProjectItem is LayoutProjectItem layoutProjectItem) + { + var layout_name = layoutProjectItem.Name; + var layout = layoutProjectItem.GetLayout(); + System.Diagnostics.Debug.WriteLine($"Layout Added: {layout_name}"); + } }); - #endregion LayoutAddedEvent - // cref: LayoutChangedEvent;ArcGIS.Desktop.Layouts.Events.LayoutChangedEvent - #region LayoutChangedEvent + #endregion + + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Subscribe + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEventArgs + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEventArgs.Action + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout + #region LayoutRemoved_ProjectItemsChangedEvent_Remove + //Report the event args when a layout is removed. + + //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutRemovedEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("LayoutViewEvent:" + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + + //Use ProjectItemsChangedEvent at 3.x + ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Subscribe((args) => { + //Layout added. Layout removed would be NotifyCollectionChangedAction.Remove + if (args.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove && + args.ProjectItem is LayoutProjectItem layoutProjectItem) + { + var layout_name = layoutProjectItem.Name; + System.Diagnostics.Debug.WriteLine($"Layout Removed: {layout_name}"); + } + }); + + #endregion + + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventHint + #region LayoutEvent_PropertyChanged //Report the event args when a layout is changed. - ArcGIS.Desktop.Layouts.Events.LayoutChangedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutChangedEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("LayoutChangedEvent:" + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name); + //}); + + ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("LayoutChangedEvent:" + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); + var layout = args.Layout; + if (args.Hint == LayoutEventHint.PropertyChanged) + { + System.Diagnostics.Debug.WriteLine($"Layout PropertyChanged: {layout.Name}"); + } }); - #endregion LayoutChangedEvent - // cref: LayoutClosedEvent;ArcGIS.Desktop.Layouts.Events.LayoutClosedEvent - #region LayoutClosedEvent + #endregion + + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventHint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.LayoutView + #region LayoutViewEvent_LayoutClosed //Report the event args when a layout is closed. - ArcGIS.Desktop.Layouts.Events.LayoutClosedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutClosedEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("LayoutClosedEvent:" + + // Environment.NewLine + + // " arg LayoutPane: " + args.LayoutPane.Caption); + //}); + + ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("LayoutClosedEvent:" + - Environment.NewLine + - " arg LayoutPane: " + args.LayoutPane.Caption); + var lv = args.LayoutView; + var layoutName = lv?.Layout?.Name ?? "null"; + if (args.Hint == LayoutViewEventHint.Closed) + { + System.Diagnostics.Debug.WriteLine($"LayoutViewEventHint.Closed: {layoutName}"); + } }); - #endregion LayoutClosedEvent - // cref: LayoutClosingEvent;ArcGIS.Desktop.Layouts.Events.LayoutClosingEvent - #region LayoutClosingEvent - //Report the event args when a layout is closing. + #endregion - ArcGIS.Desktop.Layouts.Events.LayoutClosingEvent.Subscribe((args) => - { - System.Windows.MessageBox.Show("LayoutClosingEvent:" + - Environment.NewLine + - " arg Layout: " + args.Layout.Name + - Environment.NewLine + - " arg LayoutPane: " + args.LayoutPane.Caption); - }); - #endregion LayoutClosingEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventHint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.LayoutView + #region LayoutViewEvent_LayoutClosing + //Report the event args when a layout is closing. - // cref: LayoutPauseDrawingChangedEvent;ArcGIS.Desktop.Layouts.Events.LayoutPauseDrawingChangedEvent - #region LayoutPauseDrawingChangedEvent - //Report the event args when a layout's paused state is changed. + //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutClosingEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("LayoutClosingEvent:" + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name + + // Environment.NewLine + + // " arg LayoutPane: " + args.LayoutPane.Caption); + //}); - ArcGIS.Desktop.Layouts.Events.LayoutPauseDrawingChangedEvent.Subscribe((args) => + ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("LayoutPauseDrawingChangedEvent:" + - Environment.NewLine + - " arg Layoutview: " + args.LayoutView.Layout.Name + - Environment.NewLine + - " arg Type: " + args.Paused.ToString()); + var lv = args.LayoutView; + var layoutName = lv?.Layout?.Name ?? "null"; + if (args.Hint == LayoutViewEventHint.Closing) + { + System.Diagnostics.Debug.WriteLine($"LayoutViewEventHint.Closing: {layoutName}"); + } }); - #endregion LayoutPauseDrawingChangedEvent + #endregion + + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventHint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.LayoutView + #region LayoutViewEvent_PauseDrawingChanged + //Report the event args when a layout's paused state is changed. - // cref: LayoutRemovedEvent;ArcGIS.Desktop.Layouts.Events.LayoutRemovedEvent - #region LayoutRemovedEvent - //Report the event args when a layout is removed. + //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutPauseDrawingChangedEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("LayoutPauseDrawingChangedEvent:" + + // Environment.NewLine + + // " arg Layoutview: " + args.LayoutView.Layout.Name + + // Environment.NewLine + + // " arg Type: " + args.Paused.ToString()); + //}); - ArcGIS.Desktop.Layouts.Events.LayoutRemovedEvent.Subscribe((args) => + //At 3.x use LayoutViewEvent + ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("LayoutViewEvent:" + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); + var lv = args.LayoutView; + var layout = args.LayoutView?.Layout; + + switch (args.Hint) + { + case LayoutViewEventHint.PauseDrawingChanged: + System.Diagnostics.Debug.WriteLine($"LayoutViewEvent ElementEventHint: {args.Hint.ToString()}"); + break; + } }); - #endregion LayoutRemovedEvent - // cref: LayoutRemovingEvent;ArcGIS.Desktop.Layouts.Events.LayoutRemovingEvent - #region LayoutRemovingEvent + #endregion + + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEvent.Subscribe + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEventArgs + // cref: ArcGIS.Desktop.Core.Events.ProjectItemsChangedEventArgs.Action + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout + #region LayoutRemoved_ProjectItemsChangedEvent_Removing //Report the event args when a layout is about to be removed. - ArcGIS.Desktop.Layouts.Events.LayoutRemovingEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.LayoutRemovingEvent.Subscribe((args) => + //{ + // if (args.LayoutPath == "CIMPATH=layout.xml") + // { + // args.Cancel = true; + // } + // return Task.FromResult(0); + //}); + + //At 3.x use ProjectItemRemovingEvent + ArcGIS.Desktop.Core.Events.ProjectItemRemovingEvent.Subscribe((args) => { - if (args.LayoutPath == "CIMPATH=layout.xml") + var layoutItems = args.ProjectItems.ToList().OfType() ?? new List(); + var layoutName = "DontDeleteThisOne"; + foreach(var layoutItem in layoutItems) { - args.Cancel = true; + if (layoutItem.Name == layoutName) + { + args.Cancel = true;//Cancel the remove + break; + } } return Task.FromResult(0); }); - #endregion LayoutRemovingEvent - // cref: LayoutSelectionChangedEvent;ArcGIS.Desktop.Layouts.Events.LayoutSelectionChangedEvent - #region LayoutSelectionChangedEvent - //Report the event args when a layout's selection has changed. - - ArcGIS.Desktop.Layouts.Events.LayoutSelectionChangedEvent.Subscribe((args) => { - var elements = args.Elements; - string elemNames = "null"; - if (elements != null && elements.Count() > 0) - { - elemNames = string.Join(",", elements.Select(e => e.Name).ToList()); - } - System.Windows.MessageBox.Show("LayoutSelectionChangedEvent:" + - Environment.NewLine + - " arg Elements: " + elemNames.ToString() + - Environment.NewLine + - " arg Layout: " + args.Layout.Name); - }); - #endregion LayoutSelectionChangedEvent + #endregion - // cref: LayoutViewEvent;ArcGIS.Desktop.Layouts.Events.LayoutViewEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventHint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutViewEventArgs.LayoutView #region LayoutViewEvent //Report the event args for the different types of layout view events. ArcGIS.Desktop.Layouts.Events.LayoutViewEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("LayoutViewEvent:" + - Environment.NewLine + - " arg Layoutview: " + args.LayoutView.Layout.Name + - Environment.NewLine + - " arg Type: " + args.Type.ToString()); - }); - #endregion LayoutViewEvent + var lv = args.LayoutView; + var layout = args.LayoutView?.Layout; - // cref: MapSeriesEvent;ArcGIS.Desktop.Layouts.Events.MapSeriesEvent - #region MapSeriesEvent + switch(args.Hint) + { + case LayoutViewEventHint.PauseDrawingChanged: + case LayoutViewEventHint.DrawingComplete: + case LayoutViewEventHint.ExtentChanged: + case LayoutViewEventHint.Activated: + case LayoutViewEventHint.Deactivated: + case LayoutViewEventHint.Closed: + case LayoutViewEventHint.Closing: + case LayoutViewEventHint.Opened: + System.Diagnostics.Debug.WriteLine($"LayoutViewEvent ElementEventHint: {args.Hint.ToString()}"); + break; + } + }); + #endregion + + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventHint + // cref: ArcGIS.Desktop.Layouts.Layout.MapSeries + #region LayoutEvent_MapSeries //Report the event args when the map series properties have changed. - ArcGIS.Desktop.Layouts.Events.MapSeriesEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.MapSeriesEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("MapSeriesEvent:" + + // Environment.NewLine + + // " arg CurrentPageName: " + args.CurrentPageName.ToString() + + // Environment.NewLine + + // " arg CurrentlPageNumber: " + args.CurrentPageNumber.ToString() + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name + + // Environment.NewLine + + // " arg Type: " + args.Type.ToString()); + //}); + + ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("MapSeriesEvent:" + - Environment.NewLine + - " arg CurrentPageName: " + args.CurrentPageName.ToString() + - Environment.NewLine + - " arg CurrentlPageNumber: " + args.CurrentPageNumber.ToString() + - Environment.NewLine + - " arg Layout: " + args.Layout.Name + - Environment.NewLine + - " arg Type: " + args.Type.ToString()); + var layout = args.Layout; + if (args.Hint == LayoutEventHint.MapSeriesRefreshed || + args.Hint == LayoutEventHint.MapSeriesPageChanged) + { + var ms = layout.MapSeries; + System.Diagnostics.Debug.WriteLine($"LayoutEvent {args.Hint.ToString()}: {layout.Name}"); + } }); - #endregion MapSeriesEvent - // cref: PageChangedEvent;ArcGIS.Desktop.Layouts.Events.PageChangedEvent - #region PageChangedEvent + #endregion + + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEvent + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventArgs + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventArgs.Hint + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventArgs.OldPage + // cref: ArcGIS.Desktop.Layouts.Events.LayoutEventHint + #region LayoutEvent_PageChanged //Report the event args when a layout page properties are changed. - ArcGIS.Desktop.Layouts.Events.PageChangedEvent.Subscribe((args) => + //At 2.x - ArcGIS.Desktop.Layouts.Events.PageChangedEvent.Subscribe((args) => + //{ + // System.Windows.MessageBox.Show("PageChangedEvent:" + + // Environment.NewLine + + // " arg Layout: " + args.Layout.Name + + // Environment.NewLine + + // " arg New CIMPage (height): " + args.NewPage.Height.ToString() + + // Environment.NewLine + + // " arg Old CIMPage (height): " + args.OldPage.Height.ToString()); + //}); + + ArcGIS.Desktop.Layouts.Events.LayoutEvent.Subscribe((args) => { - System.Windows.MessageBox.Show("PageChangedEvent:" + - Environment.NewLine + - " arg Layout: " + args.Layout.Name + - Environment.NewLine + - " arg New CIMPage (height): " + args.NewPage.Height.ToString() + - Environment.NewLine + - " arg Old CIMPage (height): " + args.OldPage.Height.ToString()); + var layout = args.Layout; + if (args.Hint == LayoutEventHint.PageChanged) + { + var cimPage = args.OldPage; + System.Diagnostics.Debug.WriteLine($"LayoutEvent {args.Hint.ToString()}: {layout.Name}"); + } }); - #endregion PageChangedEvent + + #endregion } diff --git a/Examples/Layouts/LayoutFactory.cs b/Examples/Layouts/LayoutFactory.cs index 457864c..25341f9 100644 --- a/Examples/Layouts/LayoutFactory.cs +++ b/Examples/Layouts/LayoutFactory.cs @@ -1,140 +1,150 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; -using ArcGIS.Desktop.Layouts; -using ArcGIS.Core.Geometry; - -namespace Layout_HelpExamples +/* + + Copyright 2018 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; +using ArcGIS.Desktop.Layouts; +using ArcGIS.Core.Geometry; + +namespace Layout_HelpExamples +{ + // cref: ArcGIS.Desktop.Layouts.ILayoutFactory.CreateLayout(System.Double,System.Double,ArcGIS.Core.Geometry.LinearUnit,System.Boolean,System.Double) + // cref: ArcGIS.Desktop.Layouts.LayoutFactory.CreateLayout(System.Double,System.Double,ArcGIS.Core.Geometry.LinearUnit,System.Boolean,System.Double) + // cref: ArcGIS.Desktop.Layouts.Layout.SetName + // cref: ArcGIS.Desktop.Core.LayoutFrameworkExtender.CreateLayoutPaneAsync + #region CreateLayout_WITH_WD_AND_HT + //This example creates a new layout using a minimum set of parameters. + + //Added references + using ArcGIS.Desktop.Layouts; + using ArcGIS.Desktop.Framework.Threading.Tasks; + using ArcGIS.Desktop.Core; + + public class CreateLayoutEx1 + { + async public static Task CreateBasicLayout(double width, double height, LinearUnit units, string LayoutName) + { + Layout layout = null; + await QueuedTask.Run(() => + { + layout = LayoutFactory.Instance.CreateLayout(width, height, units); + layout.SetName(LayoutName); + }); + + //Open the layout in a pane on the UI! + await ProApp.Panes.CreateLayoutPaneAsync(layout); + + return layout; + } + } + #endregion +} + + +namespace Layout_HelpExamples { - // cref: CreateLayoutExample1;ArcGIS.Desktop.Layouts.ILayoutFactory.CreateLayout(System.Double,System.Double,ArcGIS.Core.Geometry.LinearUnit,System.Boolean,System.Double) - // cref: CreateLayoutExample1;ArcGIS.Desktop.Layouts.LayoutFactory.CreateLayout(ArcGIS.Core.CIM.CIMPage) - // cref: CreateLayoutExample1;ArcGIS.Desktop.Layouts.LayoutFactory - #region CreateLayoutExample1 - //This example creates a new layout using a minimum set of parameters. - - //Added references - using ArcGIS.Desktop.Layouts; - using ArcGIS.Desktop.Framework.Threading.Tasks; - using ArcGIS.Desktop.Core; - - public class CreateLayoutEx1 - { - async public static Task CreateBasicLayout(double width, double height, LinearUnit units, string LayoutName) - { - Layout layout = null; - await QueuedTask.Run(() => - { - layout = LayoutFactory.Instance.CreateLayout(width, height, units); - layout.SetName(LayoutName); - }); - - //Open the layout in a pane - await ProApp.Panes.CreateLayoutPaneAsync(layout); - - return layout; - } - } - #endregion CreateLayoutExample1 -} - - -namespace Layout_HelpExamples -{ - // cref: CreateLayoutExample2;ArcGIS.Desktop.Layouts.ILayoutFactory.CreateLayout(ArcGIS.Core.CIM.CIMPage) - // cref: CreateLayoutExample2;ArcGIS.Desktop.Layouts.LayoutFactory.CreateLayout(System.Double,System.Double,ArcGIS.Core.Geometry.LinearUnit,System.Boolean,System.Double) - #region CreateLayoutExample2 + // cref: ArcGIS.Desktop.Layouts.ILayoutFactory.CreateLayout(ArcGIS.Core.CIM.CIMPage) + // cref: ArcGIS.Desktop.Layouts.LayoutFactory.CreateLayout(ArcGIS.Core.CIM.CIMPage) + // cref: ArcGIS.Core.CIM.CIMPAGE + // cref: ArcGIS.Core.CIM.CIMPAGE.ShowGuides + // cref: ArcGIS.Core.CIM.CIMPAGE.ShowRulers + // cref: ArcGIS.Core.CIM.CIMPAGE.Guides + // cref: ArcGIS.Core.CIM.CIMGUIDE + // cref: ArcGIS.Core.CIM.CIMGUIDE.Position + // cref: ArcGIS.Core.CIM.CIMGUIDE.Orientation + // cref: ArcGIS.Core.CIM.Orientation + // cref: ArcGIS.Desktop.Core.LayoutFrameworkExtender.CreateLayoutPaneAsync + #region CreateLayout_With_CIMPAGE //This example creates a new layout using a CIM page definion with rulers and guides included. //Added references - using ArcGIS.Desktop.Layouts; - using ArcGIS.Desktop.Framework.Threading.Tasks; - using ArcGIS.Desktop.Core; - using ArcGIS.Core.CIM; - - public class CreateLayoutEx2 - { - async public static Task CreateCIMLayout(double width, double height, LinearUnit units, string LayoutName) - { - Layout CIMlayout = null; - await QueuedTask.Run(() => - { - //Set up a page - CIMPage newPage = new CIMPage(); - - //required - newPage.Width = width; - newPage.Height = height; - newPage.Units = units; - - //optional rulers - newPage.ShowRulers = true; - newPage.SmallestRulerDivision = 5; - - //optional guides - newPage.ShowGuides = true; - CIMGuide guide1 = new CIMGuide(); - guide1.Position = 25; - guide1.Orientation = Orientation.Vertical; - CIMGuide guide2 = new CIMGuide(); - guide2.Position = 185; - guide2.Orientation = Orientation.Vertical; - CIMGuide guide3 = new CIMGuide(); - guide3.Position = 25; - guide3.Orientation = Orientation.Horizontal; - CIMGuide guide4 = new CIMGuide(); - guide4.Position = 272; - guide4.Orientation = Orientation.Horizontal; - - List guideList = new List(); - guideList.Add(guide1); - guideList.Add(guide2); - guideList.Add(guide3); - guideList.Add(guide4); - newPage.Guides = guideList.ToArray(); - - Layout layout = LayoutFactory.Instance.CreateLayout(newPage); - - layout.SetName(LayoutName); - }); - - //Open the layout in a pane - await ProApp.Panes.CreateLayoutPaneAsync(CIMlayout); - return CIMlayout; - } - } - #endregion CreateLayoutExample2 -} - -namespace Layout_HelpExamples -{ - internal class LayoutFactoryClass : Button - { - async protected override void OnClick() - { - Layout lyt1 = await CreateLayoutEx1.CreateBasicLayout(210, 297, LinearUnit.Millimeters, "A4 Layout"); - Layout lyt2 = await CreateLayoutEx1.CreateBasicLayout(17, 11, LinearUnit.Inches, "17x11 Layout"); - } - } -} + using ArcGIS.Desktop.Layouts; + using ArcGIS.Desktop.Framework.Threading.Tasks; + using ArcGIS.Desktop.Core; + using ArcGIS.Core.CIM; + + public class CreateLayoutEx2 + { + async public static Task CreateCIMLayout(double width, double height, LinearUnit units, string LayoutName) + { + Layout CIMlayout = null; + await QueuedTask.Run(() => + { + //Set up a page + CIMPage newPage = new CIMPage(); + + //required + newPage.Width = width; + newPage.Height = height; + newPage.Units = units; + + //optional rulers + newPage.ShowRulers = true; + newPage.SmallestRulerDivision = 5; + + //optional guides + newPage.ShowGuides = true; + CIMGuide guide1 = new CIMGuide(); + guide1.Position = 25; + guide1.Orientation = Orientation.Vertical; + CIMGuide guide2 = new CIMGuide(); + guide2.Position = 185; + guide2.Orientation = Orientation.Vertical; + CIMGuide guide3 = new CIMGuide(); + guide3.Position = 25; + guide3.Orientation = Orientation.Horizontal; + CIMGuide guide4 = new CIMGuide(); + guide4.Position = 272; + guide4.Orientation = Orientation.Horizontal; + + List guideList = new List(); + guideList.Add(guide1); + guideList.Add(guide2); + guideList.Add(guide3); + guideList.Add(guide4); + newPage.Guides = guideList.ToArray(); + + Layout layout = LayoutFactory.Instance.CreateLayout(newPage); + + layout.SetName(LayoutName); + }); + + //Open the layout in a pane on the UI! + await ProApp.Panes.CreateLayoutPaneAsync(CIMlayout); + return CIMlayout; + } + } + #endregion +} + +namespace Layout_HelpExamples +{ + internal class LayoutFactoryClass : Button + { + async protected override void OnClick() + { + Layout lyt1 = await CreateLayoutEx1.CreateBasicLayout(210, 297, LinearUnit.Millimeters, "A4 Layout"); + Layout lyt2 = await CreateLayoutEx1.CreateBasicLayout(17, 11, LinearUnit.Inches, "17x11 Layout"); + } + } +} diff --git a/Examples/Layouts/LayoutProjectItemClass.cs b/Examples/Layouts/LayoutProjectItemClass.cs index f2d6c9f..5ae3aca 100644 --- a/Examples/Layouts/LayoutProjectItemClass.cs +++ b/Examples/Layouts/LayoutProjectItemClass.cs @@ -54,7 +54,10 @@ limitations under the License. namespace Layout_HelpExamples { - #region DeleteLayout + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Core.Project.RemoveItem + #region Delete_Layout //This example deletes a layout in a project after finding it by name. //Added references @@ -76,7 +79,7 @@ public static Task DeleteLayoutAsync(string LayoutName) return Task.FromResult(Project.Current.RemoveItem(layoutItem)); } } - #endregion DeleteLayout + #endregion } namespace Layout_HelpExamples diff --git a/Examples/Layouts/LayoutViewClass.cs b/Examples/Layouts/LayoutViewClass.cs index 344ebd5..b56618f 100644 --- a/Examples/Layouts/LayoutViewClass.cs +++ b/Examples/Layouts/LayoutViewClass.cs @@ -51,7 +51,8 @@ async public static void MethodSnippets() { LayoutView layoutView = LayoutView.Active; - // cref: LayoutView_ZoomTo_Extent;ArcGIS.Desktop.Layouts.LayoutView.ZoomTo(ArcGIS.Core.Geometry.Geometry,System.Nullable{System.TimeSpan}) + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomTo + // cref: ArcGIS.Desktop.Layouts.LayoutView.Extent #region LayoutView_ZoomTo_Extent //Set the page extent for a layout view. @@ -63,7 +64,7 @@ await QueuedTask.Run(() => }); #endregion LayoutView_ZoomTo_Extent - // cref: LayoutView_ZoomTo_Percent;ArcGIS.Desktop.Layouts.LayoutView.ZoomTo100Percent(System.Nullable{System.TimeSpan}) + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomTo100Percent(System.Nullable{System.TimeSpan}) #region LayoutView_ZoomTo_Percent //Set the layout view to 100 percent. @@ -74,7 +75,7 @@ await QueuedTask.Run(() => }); #endregion LayoutView_ZoomTo_Percent - // cref: LayoutView_ZoomTo_Next;ArcGIS.Desktop.Layouts.LayoutView.ZoomToNext(System.Nullable{System.TimeSpan}) + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomToNext(System.Nullable{System.TimeSpan}) #region LayoutView_ZoomTo_Next //Advance the layout view extent to the previous forward extent @@ -85,7 +86,7 @@ await QueuedTask.Run(() => }); #endregion LayoutView_ZoomTo_Next - // cref: LayoutView_ZoomTo_PageWidth;ArcGIS.Desktop.Layouts.LayoutView.ZoomToPageWidth(System.Nullable{System.TimeSpan}) + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomToPageWidth(System.Nullable{System.TimeSpan}) #region LayoutView_ZoomTo_PageWidth //Set the layout view extent to accomodate the width of the page. @@ -96,7 +97,7 @@ await QueuedTask.Run(() => }); #endregion LayoutView_ZoomTo_PageWidth - // cref: LayoutView_ZoomTo_Previous;ArcGIS.Desktop.Layouts.LayoutView.ZoomToPrevious(System.Nullable{System.TimeSpan}) + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomToPrevious(System.Nullable{System.TimeSpan}) #region LayoutView_ZoomTo_Previous //Set the layout view extent to the previous extent. @@ -107,7 +108,7 @@ await QueuedTask.Run(() => }); #endregion LayoutView_ZoomTo_Previous - // cref: LayoutView_ZoomTo_SelectedElements;ArcGIS.Desktop.Layouts.LayoutView.ZoomToSelectedElements(System.Nullable{System.TimeSpan}) + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomToSelectedElements(System.Nullable{System.TimeSpan}) #region LayoutView_ZoomTo_SelectedElements //Set the layout view extent to the selected elements. @@ -118,7 +119,7 @@ await QueuedTask.Run(() => }); #endregion LayoutView_ZoomTo_SelectedElements - // cref: LayoutView_ZoomTo_WholePage;ArcGIS.Desktop.Layouts.LayoutView.ZoomToWholePage(System.Nullable{System.TimeSpan}) + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomToWholePage(System.Nullable{System.TimeSpan}) #region LayoutView_ZoomTo_WholePage //Set the layout view extent to fit the entire page. @@ -129,7 +130,7 @@ await QueuedTask.Run(() => }); #endregion LayoutView_ZoomTo_WholePage - // cref: LayoutView_Refresh;ArcGIS.Desktop.Layouts.LayoutView.Refresh + // cref: ArcGIS.Desktop.Layouts.LayoutView.Refresh #region LayoutView_Refresh //Refresh the layout view. @@ -137,45 +138,55 @@ await QueuedTask.Run(() => await QueuedTask.Run(() => layoutView.Refresh()); #endregion - // cref: LayoutView_GetSelection;ArcGIS.Desktop.Layouts.LayoutView.GetSelectedElements + // cref: ArcGIS.Desktop.Layouts.LayoutView.GetSelectedElements #region LayoutView_GetSelection //Get the selected layout elements. var selectedElements = layoutView.GetSelectedElements(); #endregion - // cref: LayoutView_SetSelection;ArcGIS.Desktop.Layouts.LayoutView.SelectElements(System.Collections.Generic.IReadOnlyList{ArcGIS.Desktop.Layouts.Element}) + // cref: ArcGIS.Desktop.Layouts.LayoutView.Layout + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ArcGIS.Desktop.Layouts.LayoutView.SelectElements(System.Collections.Generic.IReadOnlyList{ArcGIS.Desktop.Layouts.Element}) #region LayoutView_SetSelection //Set the layout's element selection. - Element rec = layoutView.Layout.FindElement("Rectangle"); - Element rec2 = layoutView.Layout.FindElement("Rectangle 2"); + await QueuedTask.Run(() => + { + Element rec = layoutView.Layout.FindElement("Rectangle"); + Element rec2 = layoutView.Layout.FindElement("Rectangle 2"); - List elmList = new List(); - elmList.Add(rec); - elmList.Add(rec2); + List elmList = new List(); + elmList.Add(rec); + elmList.Add(rec2); - layoutView.SelectElements(elmList); + layoutView.SelectElements(elmList); + }); #endregion LayoutView_SetSelection - // cref: LayoutView_SelectAll;ArcGIS.Desktop.Layouts.LayoutView.SelectAllElements + // cref: ArcGIS.Desktop.Layouts.LayoutView.SelectAllElements #region LayoutView_SelectAll //Select all element on a layout. - layoutView.SelectAllElements(); + await QueuedTask.Run(() => layoutView.SelectAllElements()); + #endregion LayoutView_SelectAll - // cref: LayoutView_ClearSelection;ArcGIS.Desktop.Layouts.LayoutView.ClearElementSelection + // cref: ArcGIS.Desktop.Layouts.LayoutView.ClearElementSelection #region LayoutView_ClearSelection //Clear the layout's element selection. - layoutView.ClearElementSelection(); + await QueuedTask.Run(() => layoutView.ClearElementSelection()); + #endregion LayoutView_ClearSelection Layout layout = LayoutFactory.Instance.CreateLayout(5, 5, LinearUnit.Inches); - // cref: LayoutView_FindAndCloseLayoutPanes;ArcGIS.Desktop.Core.LayoutFrameworkExtender.CloseLayoutPanes(ArcGIS.Desktop.Framework.PaneCollection,System.String) - // cref: LayoutView_FindAndCloseLayoutPanes;ArcGIS.Desktop.Core.LayoutFrameworkExtender.FindLayoutPanes(ArcGIS.Desktop.Framework.PaneCollection,ArcGIS.Desktop.Layouts.Layout) + + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout + // cref: ArcGIS.Desktop.Core.LayoutFrameworkExtender.CloseLayoutPanes(ArcGIS.Desktop.Framework.PaneCollection,System.String) + // cref: ArcGIS.Desktop.Core.LayoutFrameworkExtender.FindLayoutPanes(ArcGIS.Desktop.Framework.PaneCollection,ArcGIS.Desktop.Layouts.Layout) #region LayoutView_FindAndCloseLayoutPanes //Find and close all layout panes associated with a specific layout. @@ -189,6 +200,14 @@ await QueuedTask.Run(() => } #endregion LayoutView_FindandCloseLayoutPanes + // cref: ArcGIS.Desktop.Core.LayoutFrameworkExtender.CreateLayoutPaneAsync + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout + // cref: ArcGIS.Desktop.Layouts.ILayoutPane + // cref: ArcGIS.Desktop.Layouts.ILayoutPane.Caption + // cref: ArcGIS.Desktop.Layouts.ILayoutPane.LayoutView + // cref: ArcGIS.Desktop.Framework.Contracts.Pane.Activate + // cref: ArcGIS.Desktop.Layouts.LayoutView.Layout + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomTo100Percent #region LayoutView_LayoutFrameWorkExtender //This sample checks to see if a layout project item already has an open application pane. //If it does, it checks if it is the active layout view, if not, it creates, activates and opens a new pane. @@ -223,6 +242,11 @@ await QueuedTask.Run(() => async public static void LayoutViewExample() { + // cref: ArcGIS.Desktop.Layouts.LayoutView.Active + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ArcGIS.Desktop.Layouts.LayoutView.Layout + // cref: ArcGIS.Desktop.Layouts.LayoutView.SelectElements + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomToSelectedElements #region LayoutViewClassExample1 //This example references the active layout view. Next it finds a couple of elements and adds them to a collection. //The elements in the collection are selected within the layout view. Finally, the layout view is zoomed to the @@ -259,9 +283,14 @@ public class LayoutViewExample2 { async public static Task SetLayoutViewSelection() { -#region LayoutViewClassExample2 - // Make sure the active pane is a layout view and then reference it - if (LayoutView.Active != null) + // cref: ArcGIS.Desktop.Layouts.LayoutView.Active + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ArcGIS.Desktop.Layouts.LayoutView.Layout + // cref: ArcGIS.Desktop.Layouts.LayoutView.SelectElements + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomToSelectedElements + #region LayoutViewClassExample2 + // Make sure the active pane is a layout view and then reference it + if (LayoutView.Active != null) { LayoutView lytView = LayoutView.Active; //Reference the layout associated with the layout view diff --git a/Examples/Layouts/Layouts.csproj b/Examples/Layouts/Layouts.csproj new file mode 100644 index 0000000..60d248a --- /dev/null +++ b/Examples/Layouts/Layouts.csproj @@ -0,0 +1,80 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/Layouts/MapFrameClass.cs b/Examples/Layouts/MapFrameClass.cs index f739086..869f0d3 100644 --- a/Examples/Layouts/MapFrameClass.cs +++ b/Examples/Layouts/MapFrameClass.cs @@ -38,22 +38,10 @@ async public static void MethodSnippets() { Layout layout = LayoutView.Active.Layout; - #region MapFrame_Export - //See ProSnippets.cs "Export a map frame to JPG" - #endregion MapFrame_Export - - - #region MapFrame_GetMapView - //see ProSnippets "Export the map view associated with a map frame to BMP" - #endregion MapFrame_GetMapView - - - #region MapFrame_SetCamera_Camera - // see ProSnippets "Change map frames camera settings" - #endregion MapFrame_SetCamera_Camera - - - // cref: MapFrame_SetCamera_Bookmark;ArcGIS.Desktop.Layouts.MapFrame.SetCamera(ArcGIS.Desktop.Mapping.Bookmark) + // cref: ArcGIS.Desktop.Layouts.MapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetCamera(ArcGIS.Desktop.Mapping.Bookmark) + // cref: ArcGIS.Desktop.Layouts.MapFrame.Map + // cref: ArcGIS.Desktop.Mapping.Map.GetBookmarks #region MapFrame_SetCamera_Bookmark //Set the extent of a map frame to a bookmark. @@ -73,7 +61,11 @@ await QueuedTask.Run(() => #endregion MapFrame_SetCamera_Bookmark - // cref: MapFrame_SetCamera_Envelope;ArcGIS.Desktop.Layouts.MapFrame.SetCamera(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetCamera(ArcGIS.Core.Geometry.Envelope) + // cref: ArcGIS.Desktop.Layouts.MapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.Map + // cref: ArcGIS.Desktop.Mapping.Map.FindLayers + // cref: ARCGIS.DESKTOP.MAPPING.LAYER.QUERYEXTENT #region MapFrame_SetCamera_Envelope //Set the extent of a map frame to the envelope of a feature. @@ -94,18 +86,10 @@ await QueuedTask.Run(() => }); #endregion MapFrame_SetCamera_Envelope - - #region MapFrame_SetCamera_Layer - //See ProSnppets "Zoom map frame to extent of a single layer" - #endregion MapFrame_SetCamera_Layer - - - #region MapFrame_SetCamera_Layers - //See ProSnippets "Change map frame extent to selected features in multiple layers" - #endregion MapFrame_SetCamera_Layers - MapFrame mf = null; Map map = null; + + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetMap #region MapFrame_SetMap //Set the map that is associated with a map frame. diff --git a/Examples/Layouts/MapSeries.cs b/Examples/Layouts/MapSeries.cs index 8301449..58d54b5 100644 --- a/Examples/Layouts/MapSeries.cs +++ b/Examples/Layouts/MapSeries.cs @@ -25,9 +25,9 @@ limitations under the License. using ArcGIS.Desktop.Framework.Contracts; //Added references -using ArcGIS.Core.CIM; -using ArcGIS.Desktop.Layouts; -using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Core.CIM; +using ArcGIS.Desktop.Layouts; +using ArcGIS.Desktop.Framework.Threading.Tasks; using ArcGIS.Desktop.Mapping; using ArcGIS.Core.Data; @@ -45,7 +45,13 @@ public class MapSeriesClassExamples { async public static void MethodSnippets() { - // cref: MapSeries_Constructor1;ArcGIS.Desktop.Layouts.MapSeriesExportOptions.#ctor + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportPages + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.CustomPages + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ShowSelectedSymbology + // cref: ArcGIS.Desktop.Mapping.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.ExportPages #region MapSeries_Constructor1 //Set up map series export options @@ -58,7 +64,12 @@ async public static void MethodSnippets() }; #endregion MapSeries_Constructor1 - + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportPages + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ShowSelectedSymbology + // cref: ArcGIS.Desktop.Mapping.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.ExportPages #region MapSeries_Constructor2 //Set up map series export options @@ -72,7 +83,13 @@ async public static void MethodSnippets() - // cref: MapSeries_FindpageNumber;ArcGIS.Desktop.Layouts.MapSeries.FindPageNumber(System.String) + // cref: ArcGIS.Desktop.Layouts.MapSeries.FindPageNumber(System.String) + // cref: ArcGIS.Desktop.Layouts.LayoutView.Active + // cref: ArcGIS.Desktop.Layouts.Layout.MapSeries + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.CurrentRow + // cref: ArcGIS.Core.Data.Row.GetOriginalValue + // cref: ArcGIS.Core.Data.Row.FindField #region MapSeries_FindPageNumber //Return the page number that corresponds to the page name field for an index feature @@ -87,9 +104,13 @@ await QueuedTask.Run(() => }); #endregion MapSeries_FindPageNumber - - // cref: MapSeries_GetSetDefinition;ArcGIS.Desktop.Layouts.MapSeries.GetDefinition - // cref: MapSeries_GetSetDefinition;ArcGIS.Desktop.Layouts.MapSeries.SetDefinition(ArcGIS.Core.CIM.CIMMapSeries) + // cref: ArcGIS.Desktop.Layouts.Layout.MapSeries + // cref: ArcGIS.Desktop.Layouts.MapSeries + // cref: ArcGIS.Desktop.Layouts.MapSeries.GetDefinition + // cref: ArcGIS.Desktop.Layouts.MapSeries.SetDefinition + // cref: ArcGIS.Core.CIM.CIMMapSeries + // cref: ArcGIS.Core.CIM.CIMMapSeries.Enabled + // cref: ArcGIS.Desktop.Layouts.Layout.SetMapSeries #region MapSeries_GetSetDefinition //Get and modify a map series CIM definition and set the changes back to the layout @@ -105,7 +126,8 @@ await QueuedTask.Run(() => #endregion MapSeries_GetSetDefinition - // cref: MapSeries_SetCurrentPageNumber;ArcGIS.Desktop.Layouts.MapSeries.SetCurrentPageNumber(System.String) + // cref: ArcGIS.Desktop.Layouts.MapSeries.SetCurrentPageNumber(System.String) + // cref: ArcGIS.Desktop.Layouts.Layout.MapSeries #region MapSeries_SetCurrentPageNumber //Set the current page to match a specific page number diff --git a/Examples/Layouts/MapSurroundClass.cs b/Examples/Layouts/MapSurroundClass.cs index 82179a0..d685c01 100644 --- a/Examples/Layouts/MapSurroundClass.cs +++ b/Examples/Layouts/MapSurroundClass.cs @@ -34,7 +34,9 @@ limitations under the License. namespace Layout_HelpExamples { - // cref: MapSurroundExample;ArcGIS.Desktop.Layouts.MapSurround + // cref: ArcGIS.Desktop.Layouts.MapSurround + // cref: ArcGIS.Desktop.Layouts.MapSurround.SetMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame #region MapSurroundExample //Added references using ArcGIS.Desktop.Core; //Project @@ -89,7 +91,16 @@ public class TableFrameClassSamples async public static void CreateNew() { - // cref: TableFrame_CreateNew;ArcGIS.Desktop.Layouts.TableFrame + // cref: ArcGIS.Desktop.Layouts.TableFrame + // cref: ArcGIS.Desktop.Layouts.TableFrameInfo + // cref: ArcGIS.Desktop.Layouts.TableFrameInfo.FieldNames + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapMemberUri + // cref: ArcGIS.Desktop.Layouts.MapSurround.SetMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.Map + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateMapSurroundElement #region TableFrame_CreateNew //Create a new table frame on the active layout. @@ -101,7 +112,8 @@ await QueuedTask.Run(() => //Build 2D envelope geometry Coordinate2D rec_ll = new Coordinate2D(1.0, 3.5); Coordinate2D rec_ur = new Coordinate2D(7.5, 4.5); - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur); + //At 2.x - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur); + Envelope rec_env = EnvelopeBuilderEx.CreateEnvelope(rec_ll, rec_ur); //Reference map frame MapFrame mf = layout.FindElement("Map Frame") as MapFrame; @@ -114,17 +126,27 @@ await QueuedTask.Run(() => var fields = new[] { "NAME", "Shape_Area", "Shape_Length" }; //Construct the table frame - TableFrame tabFrame = LayoutElementFactory.Instance.CreateTableFrame(layout, rec_env, mf, lyr, fields); + //At 2.x - TableFrame tabFrame = LayoutElementFactory.Instance.CreateTableFrame(layout, rec_env, mf, lyr, fields); + var surroundInfo = new TableFrameInfo() + { + FieldNames = fields, + MapFrameName = mf.Name, + MapMemberUri = lyr.URI + }; + var tabFrame = ElementFactory.Instance.CreateMapSurroundElement(layout, rec_env, surroundInfo) as TableFrame; }); #endregion TableFrame_CreateNew } - - - async public static void ModifyExisting() { + // cref: ArcGIS.Desktop.Layouts.Element.GetDefinition + // cref: ArcGIS.Desktop.Layouts.Element.SetDefinition + // cref: ArcGIS.Desktop.Layouts.TableFrame + // cref: ArcGIS.Core.CIM.CIMTableFrame + // cref: ArcGIS.Core.CIM.CIMTableFrame.Alternate1RowBackgroundCount + // cref: ArcGIS.Core.CIM.CIMTableFrame.Alternate2RowBackgroundCount #region TableFrame_ModifyExisting //Modify an existing tableframe using CIM properties. diff --git a/Examples/Layouts/MethodSnippets.cs b/Examples/Layouts/MethodSnippets.cs index 7aa7d34..7bcd899 100644 --- a/Examples/Layouts/MethodSnippets.cs +++ b/Examples/Layouts/MethodSnippets.cs @@ -390,19 +390,23 @@ async public static void GraphicElementSnippets() Layout lyt = await QueuedTask.Run(() => layoutItem.GetLayout()); GraphicElement graElm = lyt.FindElement("Rectangle") as GraphicElement; - CIMGraphic CIMGra = graElm.GetGraphic() as CIMGraphic; - await QueuedTask.Run(() => { - // cref: GraphicElement_Clone;ArcGIS.Desktop.Layouts.GraphicElement.Clone(System.String) + // cref: ArcGIS.Desktop.Layouts.GraphicElement.Clone(System.String) #region GraphicElement_Clone //Note: call within QueuedTask.Run() GraphicElement cloneElm = graElm.Clone("Clone"); #endregion GraphicElement_Clone - // cref: GraphicElement_SetGraphic;ArcGIS.Desktop.Layouts.GraphicElement.SetGraphic(ArcGIS.Core.CIM.CIMGraphic) - #region GraphicElement_SetGraphic - //Note: call within QueuedTask.Run() + // cref: ArcGIS.Desktop.Layouts.GraphicElement.SetGraphic(ArcGIS.Core.CIM.CIMGraphic) + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic(ArcGIS.Core.CIM.CIMGraphic) + // cref: ArcGIS.Core.CIM.CIMGraphic + #region GraphicElement_Get_And_SetGraphic + + //Note: must call within QueuedTask.Run() + var CIMGra = graElm.GetGraphic() as CIMGraphic; + //TODO - make changes to CIMGraphic + //... graElm.SetGraphic(CIMGra); #endregion GraphicElement_SetGraphic }); @@ -411,22 +415,32 @@ await QueuedTask.Run(() => async public static void TextElementSnippets() { LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("Layout Name")); - Layout lyt = await QueuedTask.Run(() => layoutItem.GetLayout()); - TextElement txtElm = lyt.FindElement("Text") as TextElement; + Layout layout = await QueuedTask.Run(() => layoutItem.GetLayout()); + + // cref: ArcGIS.Desktop.Layouts.TextProperties + // cref: ArcGIS.Desktop.Layouts.TextProperties._CTOR #region TextElement_TextPropertiesConstructor TextProperties txtProp = new TextProperties("String", "Times New Roman", 24, "Regular"); #endregion TextElement_TextPropertiesConstructor + // cref: ArcGIS.Desktop.Layouts.TextElement + // cref: ArcGIS.Desktop.Layouts.TextElement.SetTextProperties #region TextElement_SetTextProperties - txtElm.SetTextProperties(txtProp); + await QueuedTask.Run(() => + { + TextElement txtElm = layout.FindElement("Text") as TextElement; + txtElm.SetTextProperties(txtProp); + }); + #endregion TextElement_SetTextProperties } async public static void PictureElementSnippets() { - // cref: PictureElement_SetSourcePath;ArcGIS.Desktop.Layouts.PictureElement.SetSourcePath(System.String) + // cref: ArcGIS.Desktop.Layouts.PictureElement + // cref: ArcGIS.Desktop.Layouts.PictureElement.SetSourcePath(System.String) #region PictureElement_SetSourcePath LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("Layout Name")); await QueuedTask.Run(() => @@ -434,18 +448,20 @@ await QueuedTask.Run(() => Layout layout = layoutItem.GetLayout(); PictureElement picElm = layout.FindElement("Rectangle") as PictureElement; - picElm.SetSourcePath(@"C:\Some\New\Path\And\file.ext"); + picElm.SetSourcePath(@"C:\Some\New\Path\And\file_pic.png"); }); #endregion PictureElement_SetSourcePath } async public static void MapSurroundSnippets() { - // cref: MapSurround_SetMapFrame;ArcGIS.Desktop.Layouts.MapSurround.SetMapFrame(ArcGIS.Desktop.Layouts.MapFrame) + // cref: ArcGIS.Desktop.Layouts.MapSurround.SetMapFrame(ArcGIS.Desktop.Layouts.MapFrame) + // cref: ArcGIS.Desktop.Layouts.MapFrame #region MapSurround_SetMapFrame await QueuedTask.Run(() => { - LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("Layout Name")); + LayoutProjectItem layoutItem = Project.Current.GetItems() + .FirstOrDefault(item => item.Name.Equals("Layout Name")); Layout lyt = layoutItem.GetLayout(); MapFrame mf = lyt.FindElement("Map1 Map Frame") as MapFrame; MapSurround ms = lyt.FindElement("Scale Bar") as MapSurround; @@ -457,56 +473,67 @@ await QueuedTask.Run(() => async public static void ExportSnippets() { - LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("Layout Name")); + LayoutProjectItem layoutItem = Project.Current.GetItems() + .FirstOrDefault(item => item.Name.Equals("Layout Name")); Layout lyt = await QueuedTask.Run(() => layoutItem.GetLayout()); MapFrame mf = lyt.FindElement("Map1 Map Frame") as MapFrame; + // cref: BMP_Constructor;ArcGIS.Desktop.Mapping.BMPFormat // cref: BMP_Constructor;ArcGIS.Desktop.Mapping.BMPFormat.#ctor #region BMP_Constructor BMPFormat BMP = new BMPFormat(); #endregion BMP_Constructor + // cref: EMF_Constructor;ArcGIS.Desktop.Mapping.EMFFormat // cref: EMF_Constructor;ArcGIS.Desktop.Mapping.EMFFormat.#ctor #region EMF_Constructor EMFFormat EMF = new EMFFormat(); #endregion EMF_Constructor + // cref: EPS_Constructor;ArcGIS.Desktop.Mapping.EPSFormat // cref: EPS_Constructor;ArcGIS.Desktop.Mapping.EPSFormat.#ctor #region EPS_Constructor EPSFormat EPS = new EPSFormat(); #endregion EPS_Constructor + // cref: GIF_Constructor;ArcGIS.Desktop.Mapping.GIFFormat // cref: GIF_Constructor;ArcGIS.Desktop.Mapping.GIFFormat.#ctor #region GIF_Constructor GIFFormat GIF = new GIFFormat(); #endregion GIF_Constructor + // cref: JPEG_Constructor;ArcGIS.Desktop.Mapping.JPEGFormat // cref: JPEG_Constructor;ArcGIS.Desktop.Mapping.JPEGFormat.#ctor #region JPEG_Constructor JPEGFormat JPEG = new JPEGFormat(); #endregion JPEG_Constructor + // cref: PNG_Constructor;ArcGIS.Desktop.Mapping.PNGFormat // cref: PNG_Constructor;ArcGIS.Desktop.Mapping.PNGFormat.#ctor #region PNG_Constructor PNGFormat PNG = new PNGFormat(); #endregion PNG_Constructor + // cref: PDF_Constructor;ArcGIS.Desktop.Mapping.PDFFormat // cref: PDF_Constructor;ArcGIS.Desktop.Mapping.PDFFormat.#ctor #region PDF_Constructor PDFFormat PDF = new PDFFormat(); #endregion PDF_Constructor + // cref: SVG_Constructor;ArcGIS.Desktop.Mapping.SVGFormat // cref: SVG_Constructor;ArcGIS.Desktop.Mapping.SVGFormat.#ctor #region SVG_Constructor SVGFormat SVG = new SVGFormat(); #endregion SVG_Constructor + // cref: TGA_Constructor;ArcGIS.Desktop.Mapping.TGAFormat // cref: TGA_Constructor;ArcGIS.Desktop.Mapping.TGAFormat.#ctor #region TGA_Constructor TGAFormat TGA = new TGAFormat(); #endregion TGA_Constructor + // cref: TIFF_Constructor;ArcGIS.Desktop.Mapping.TIFFFormat // cref: TIFF_Constructor;ArcGIS.Desktop.Mapping.TIFFFormat.#ctor #region TIFF_Constructor TIFFFormat TIFF = new TIFFFormat(); @@ -515,8 +542,10 @@ async public static void ExportSnippets() PDF.OutputFileName = @"C:\Temp\output.pdf"; + // cref: ArcGIS.Desktop.Layouts.Layout.Export #region PDF_lyt_Export - lyt.Export(PDF); + await QueuedTask.Run(() => lyt.Export(PDF)); + #endregion PDF_lyt_Export } diff --git a/Examples/Layouts/PictureElementClass.cs b/Examples/Layouts/PictureElementClass.cs index c96fd7a..f4752c4 100644 --- a/Examples/Layouts/PictureElementClass.cs +++ b/Examples/Layouts/PictureElementClass.cs @@ -1,78 +1,79 @@ -/* +/* + + Copyright 2018 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Contracts; + +namespace Layout_HelpExamples +{ + // cref: ArcGIS.Desktop.Layouts.PictureElement + // cref: ArcGIS.Desktop.Layouts.PictureElement.SetSourcePath + #region PictureElementExample + ///This example references a PictureElement on a layout and changes the picture by setting a path to a file on disk using the + + //Added references + using ArcGIS.Desktop.Core; + using ArcGIS.Desktop.Layouts; + using ArcGIS.Desktop.Framework.Threading.Tasks; - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; - -namespace Layout_HelpExamples -{ - // cref: PictureElementExample;ArcGIS.Desktop.Layouts.PictureElement - #region PictureElementExample - ///This example references a PictureElement on a layout and changes the picture by setting a path to a file on disk using the - - //Added references - using ArcGIS.Desktop.Core; - using ArcGIS.Desktop.Layouts; - using ArcGIS.Desktop.Framework.Threading.Tasks; - - public class PictureElementExample - { - public static Task UpdatePictureElementAsync(string LayoutName, string PictureName, string PicturePath) - { - //Reference a layoutitem in a project by name - LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(LayoutName)); - if (layoutItem == null) - return Task.FromResult(false); - - return QueuedTask.Run(() => + public class PictureElementExample + { + public static Task UpdatePictureElementAsync(string LayoutName, string PictureName, string PicturePath) + { + //Reference a layoutitem in a project by name + LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(LayoutName)); + if (layoutItem == null) + return Task.FromResult(false); + + return QueuedTask.Run(() => { - //Reference and load the layout associated with the layout item - Layout lyt = layoutItem.GetLayout(); + //Reference and load the layout associated with the layout item + Layout lyt = layoutItem.GetLayout(); - //Reference a picture element by name - PictureElement picElm = lyt.FindElement(PictureName) as PictureElement; - if (picElm == null) + //Reference a picture element by name + PictureElement picElm = lyt.FindElement(PictureName) as PictureElement; + if (picElm == null) return false; - //Change the path to a new source - picElm.SetSourcePath(PicturePath); - - return true; - }); - } - } - #endregion PictureElementExample - - internal class PictureElementClass : Button - { - async protected override void OnClick() - { - string some_new_path; - some_new_path = @"D:\Active\Layout\SDK\2.0\Layout_HelpExamples\WhitePass.jpg"; - - bool x = await PictureElementExample.UpdatePictureElementAsync("Layout Name", "Picture", some_new_path); - if (x == false) - System.Windows.MessageBox.Show("Object Not found"); - } - } -} + //Change the path to a new source + picElm.SetSourcePath(PicturePath); + + return true; + }); + } + } + #endregion PictureElementExample + + internal class PictureElementClass : Button + { + async protected override void OnClick() + { + string some_new_path; + some_new_path = @"D:\Active\Layout\SDK\2.0\Layout_HelpExamples\WhitePass.jpg"; + + bool x = await PictureElementExample.UpdatePictureElementAsync("Layout Name", "Picture", some_new_path); + if (x == false) + System.Windows.MessageBox.Show("Object Not found"); + } + } +} diff --git a/Examples/Layouts/ProSnippets.cs b/Examples/Layouts/ProSnippets.cs index f356bb5..376f810 100644 --- a/Examples/Layouts/ProSnippets.cs +++ b/Examples/Layouts/ProSnippets.cs @@ -41,37 +41,44 @@ class Snippets #endregion async public void snippets_ProjectItems() { - // cref: Reference layout project items and their associated layout;ArcGIS.Desktop.Layouts.Layout - // cref: Reference layout project items and their associated layout;ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem #region Reference layout project items and their associated layout //Reference layout project items and their associated layout. - //A layout project item is an item that appears in the Layouts folder in the Catalog pane. + //A layout project item is an item that appears in the Layouts + //folder in the Catalog pane. //Reference all the layout project items - IEnumerable layouts = Project.Current.GetItems(); + IEnumerable layouts = + Project.Current.GetItems(); //Or reference a specific layout project item by name - LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("MyLayout")); + LayoutProjectItem layoutItem = Project.Current.GetItems() + .FirstOrDefault(item => item.Name.Equals("MyLayout")); #endregion - // cref: Open a layout project item in a new view;ArcGIS.Desktop.Core.LayoutFrameworkExtender.CreateLayoutPaneAsync(ArcGIS.Desktop.Framework.PaneCollection,ArcGIS.Desktop.Layouts.Layout) - // cref: Open a layout project item in a new view;ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout - // cref: Open a layout project item in a new view;ArcGIS.Desktop.Core.LayoutFrameworkExtender - // cref: Open a layout project item in a new view;ArcGIS.Desktop.Layouts.LayoutView + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout + // cref: ArcGIS.Desktop.Core.LayoutFrameworkExtender.CreateLayoutPaneAsync #region Open a layout project item in a new view //Open a layout project item in a new view. //A layout project item may exist but it may not be open in a view. //Reference a layout project item by name - LayoutProjectItem someLytItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("MyLayout")); + LayoutProjectItem someLytItem = Project.Current.GetItems() + .FirstOrDefault(item => item.Name.Equals("MyLayout")); //Get the layout associated with the layout project item Layout layout = await QueuedTask.Run(() => someLytItem.GetLayout()); //Worker thread - //Create the new pane + //Create the new pane - call on UI ILayoutPane iNewLayoutPane = await ProApp.Panes.CreateLayoutPaneAsync(layout); //GUI thread #endregion + // cref: ArcGIS.Desktop.Layouts.ILayoutPane + // cref: ArcGIS.Desktop.Layouts.ILayoutPane.LayoutView + // cref: ArcGIS.Desktop.FRAMEWORK.FRAMEWORKAPPLICATION.Panes + // cref: ArcGIS.Desktop.FRAMEWORK.Contracts.Pane.Activate #region Activate an already open layout view //Activate an already open layout view. //A layout view may be open but it may not be active. @@ -83,7 +90,7 @@ async public void snippets_ProjectItems() var layoutPane = pane as ILayoutPane; if (layoutPane == null) //if not a layout view, continue to the next pane continue; - if (layoutPane.LayoutView.Layout == layout) //if there is a match, activate the view + if (layoutPane.LayoutView.Layout == layout) //activate the view { (layoutPane as Pane).Activate(); return; @@ -91,10 +98,13 @@ async public void snippets_ProjectItems() } #endregion + // cref: ArcGIS.Desktop.Layouts.LayoutView + // cref: ArcGIS.Desktop.Layouts.LayoutView.Active #region Reference the active layout view //Reference the active layout view. - //Confirm if the current, active view is a layout view. If it is, do something. + //Confirm if the current, active view is a layout view. + //If it is, do something. LayoutView activeLayoutView = LayoutView.Active; if (activeLayoutView != null) { @@ -102,43 +112,73 @@ async public void snippets_ProjectItems() } #endregion + // cref: ArcGIS.Desktop.Core.IProjectItem + // cref: ArcGIS.Desktop.Core.ItemFactory + // cref: ArcGIS.Desktop.Core.ItemFactory.Create + // cref: ArcGIS.Desktop.Core.Project.AddItem #region Import a pagx into a project //Import a pagx into a project. //Create a layout project item from importing a pagx file - IProjectItem pagx = ItemFactory.Instance.Create(@"C:\Temp\Layout.pagx") as IProjectItem; - Project.Current.AddItem(pagx); + await QueuedTask.Run(() => + { + IProjectItem pagx = ItemFactory.Instance.Create( + @"C:\Temp\Layout.pagx") as IProjectItem; + Project.Current.AddItem(pagx); + }); #endregion + // cref: ArcGIS.Desktop.Core.Project.RemoveItem #region Remove a layout project item //Remove a layout project item. //Remove the layout fro the project - Project.Current.RemoveItem(layoutItem); + await QueuedTask.Run(() => Project.Current.RemoveItem(layoutItem)); #endregion + // cref: ArcGIS.Desktop.Layouts.LayoutFactory + // cref: ArcGIS.Desktop.Layouts.LayoutFactory.CreateLayout + // cref: ArcGIS.Desktop.Layouts.Layout.SetName + // cref: ArcGIS.Desktop.Core.LayoutFrameworkExtender.CreateLayoutPaneAsync #region Create a new, basic layout and open it //Create a new, basic layout and open it. //Create layout with minimum set of parameters on the worker thread - Layout newLayout = await QueuedTask.Run(() => + Layout lyt = await QueuedTask.Run(() => { - newLayout = LayoutFactory.Instance.CreateLayout(8.5, 11, LinearUnit.Inches); + var newLayout = LayoutFactory.Instance.CreateLayout(8.5, 11, LinearUnit.Inches); newLayout.SetName("New 8.5x11 Layout"); return newLayout; }); //Open new layout on the GUI thread - await ProApp.Panes.CreateLayoutPaneAsync(newLayout); + await ProApp.Panes.CreateLayoutPaneAsync(lyt); #endregion + // cref: ArcGIS.Desktop.Layouts.ILayoutFactory.CreateLayout(ArcGIS.Core.CIM.CIMPage) + // cref: ArcGIS.Desktop.Layouts.LayoutFactory.CreateLayout(ArcGIS.Core.CIM.CIMPage) + // cref: ArcGIS.Core.CIM.CIMPAGE + // cref: ArcGIS.Core.CIM.CIMPAGE.ShowGuides + // cref: ArcGIS.Core.CIM.CIMPAGE.ShowRulers + // cref: ArcGIS.Core.CIM.CIMPAGE.SmallestRulerDivision + // cref: ArcGIS.Core.CIM.CIMPAGE.Guides + // cref: ArcGIS.Core.CIM.CIMPAGE.Units + // cref: ArcGIS.Core.CIM.CIMPAGE.Width + // cref: ArcGIS.Core.CIM.CIMPAGE.Height + // cref: ArcGIS.Core.CIM.CIMGUIDE + // cref: ArcGIS.Core.CIM.CIMGUIDE.Position + // cref: ArcGIS.Core.CIM.CIMGUIDE.Orientation + // cref: ArcGIS.Core.CIM.Orientation + // cref: ArcGIS.Desktop.Core.LayoutFrameworkExtender.CreateLayoutPaneAsync + // cref: ArcGIS.Core.Geometry.LinearUnit #region Create a new layout using a modified CIM and open it //Create a new layout using a modified CIM and open it. - //The CIM exposes additional members that may not be available through the managed API. + //The CIM exposes additional members that may not be + //available through the managed API. //In this example, optional guides are added. //Create a new CIMLayout on the worker thread - Layout newCIMLayout = await QueuedTask.Run(() => + Layout newCIMLayout = await QueuedTask.Run(() => { //Set up a CIM page CIMPage newPage = new CIMPage @@ -186,20 +226,27 @@ async public void snippets_ProjectItems() newPage.Guides = guideList.ToArray(); //Construct the new layout using the customized cim definitions - newCIMLayout = LayoutFactory.Instance.CreateLayout(newPage); - newCIMLayout.SetName("New 8.5x11 Layout"); - return newCIMLayout; + var layout_local = LayoutFactory.Instance.CreateLayout(newPage); + layout_local.SetName("New 8.5x11 Layout"); + return layout_local; }); //Open new layout on the GUI thread await ProApp.Panes.CreateLayoutPaneAsync(newCIMLayout); #endregion + // cref: ArcGIS.Desktop.Layouts.LayoutProjectItem.GetLayout + // cref: ArcGIS.Desktop.Layouts.Layout.GetPage + // cref: ArcGIS.Desktop.Layouts.Layout.SetPage + // cref: ArcGIS.Core.CIM.CIMPAGE + // cref: ArcGIS.Core.CIM.CIMPAGE.Width + // cref: ArcGIS.Core.CIM.CIMPAGE.Height #region Change the layout page size //Change the layout page size. //Reference the layout project item - LayoutProjectItem lytItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("MyLayout")); + LayoutProjectItem lytItem = Project.Current.GetItems() + .FirstOrDefault(item => item.Name.Equals("MyLayout")); if (layoutItem != null) { await QueuedTask.Run(() => @@ -220,42 +267,556 @@ await QueuedTask.Run(() => } #endregion } - #region ProSnippet Group: Create Layout Elements - #endregion - public async void snippets_CreateLayoutElements() + + #region ProSnippet Group CIM Graphics and GraphicFactory + #endregion + + public static void CreateCircleGraphic(IElementContainer container) { - LayoutView layoutView = LayoutView.Active; - Layout layout = layoutView.Layout; - await QueuedTask.Run(() => + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleGraphic + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.CreateCircle + // cref: ArcGIS.Core.Geometry.ArcOrientation + #region Create Circle Graphic + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D center = new Coordinate2D(2, 4); + EllipticArcSegment circle_seg = EllipticArcBuilderEx.CreateCircle( + new Coordinate2D(2, 4), 0.5, ArcOrientation.ArcClockwise, null); + var circle_poly = PolygonBuilderEx.CreatePolygon(PolylineBuilderEx.CreatePolyline(circle_seg)); + + //PolylineBuilderEx.CreatePolyline(cir, AttributeFlags.AllAttributes)); + //Set symbolology, create and add element to layout + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Dash); + + CIMPolygonSymbol circleSym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline); + SymbolFactory.Instance.ConstructPolygonSymbol(null, + SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2)); + + var circleGraphic = GraphicFactory.Instance.CreateSimpleGraphic(circle_poly, circleSym); + + //Make an element to add to GraphicsLayer or Layout + //var elemInfo = new ElementInfo() { Anchor = Anchor.CenterPoint }; + //GraphicElement cirElm = ElementFactory.Instance.CreateGraphicElement( + // container, circleGraphic, "New Circle", true, elemInfo); + + #endregion + } + + public static void CreateCircleTextGraphic(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleTextGraphic + // cref: ArcGIS.Desktop.Layouts.TextType + #region Create Circle Text Graphic + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D center = new Coordinate2D(4.5, 4); + var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise); + var cir = eabCir.ToSegment(); + + var poly = PolygonBuilderEx.CreatePolygon( + PolylineBuilderEx.CreatePolyline(cir, AttributeFlags.AllAttributes)); + + //Set symbolology, create and add element to layout + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.GreenRGB, 10, "Arial", "Regular"); + string text = "Circle, circle, circle"; + + var graphic = GraphicFactory.Instance.CreateSimpleTextGraphic( + TextType.CircleParagraph, poly, sym, text); + + //Make an element to add to GraphicsLayer or Layout + //var ge = ElementFactory.Instance.CreateGraphicElement(container, graphic, + // "New Circle Text", true); + #endregion + } + + public static void CreateBezierTextGraphic(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleTextGraphic + // cref: ArcGIS.Desktop.Layouts.TextType + #region Create Bezier Graphic + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D pt1 = new Coordinate2D(3.5, 7.5); + Coordinate2D pt2 = new Coordinate2D(4.16, 8); + Coordinate2D pt3 = new Coordinate2D(4.83, 7.1); + Coordinate2D pt4 = new Coordinate2D(5.5, 7.5); + var bez = new CubicBezierBuilderEx(pt1, pt2, pt3, pt4); + var bezSeg = bez.ToSegment(); + Polyline bezPl = PolylineBuilderEx.CreatePolyline(bezSeg, AttributeFlags.AllAttributes); + + //Set symbolology, create and add element to layout + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.BlackRGB, 24, "Comic Sans MS", "Regular"); + + var graphic = GraphicFactory.Instance.CreateSimpleTextGraphic( + TextType.SplinedText, bezPl, sym, "Splined text"); + + //Make an element to add to GraphicsLayer or Layout + //var ge = ElementFactory.Instance.CreateGraphicElement(container, graphic); + #endregion + } + + public static void CreateLegendPatchGraphic(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateLegendPatchGraphic + // cref: ArcGIS.Core.CIM.PatchShape + #region Create Legend Patch Graphic + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + List plyCoords = new List(); + plyCoords.Add(new Coordinate2D(1, 1)); + plyCoords.Add(new Coordinate2D(1.25, 2)); + plyCoords.Add(new Coordinate2D(1.5, 1.1)); + plyCoords.Add(new Coordinate2D(1.75, 2)); + plyCoords.Add(new Coordinate2D(2, 1.1)); + plyCoords.Add(new Coordinate2D(2.25, 2)); + plyCoords.Add(new Coordinate2D(2.5, 1.1)); + plyCoords.Add(new Coordinate2D(2.75, 2)); + plyCoords.Add(new Coordinate2D(3, 1)); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); + + //Set symbolology, create and add element to layout + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid); + CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline); + + var graphic = GraphicFactory.Instance.CreateLegendPatchGraphic( + PatchShape.AreaBoundary, poly.Extent, polySym); + + //Make an element to add to GraphicsLayer or Layout + // + //var elemInfo = new ElementInfo() + //{ + // CustomProperties = null, + // Anchor = Anchor.LeftMidPoint + //}; + //var ge = ElementFactory.Instance.CreateGraphicElement(container, graphic, + // "New Legend Patch", true, elemInfo); + #endregion + } + + public static void CreateLineArrowGraphic(IElementContainer container) + { + + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleGraphic + // cref: ArcGIS.Desktop.Layouts.ArrowInfo + // cref: ArcGIS.Desktop.Layouts.ArrowInfo.ArrowHeadKey + // cref: ArcGIS.Desktop.Layouts.ArrowInfo.ArrowOnBothEnds + // cref: ArcGIS.Desktop.Layouts.ArrowInfo.ArrowSizePoints + // cref: ArcGIS.Desktop.Layouts.ArrowInfo.LineWidthPoints + #region Create Arrow Graphic + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + List plCoords = new List(); + plCoords.Add(new Coordinate2D(1, 8.5)); + plCoords.Add(new Coordinate2D(1.66, 9)); + plCoords.Add(new Coordinate2D(2.33, 8.1)); + plCoords.Add(new Coordinate2D(3, 8.5)); + Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords); + + //Set up the arrow info + var arrowInfo = new ArrowInfo() { - #region Create Element using the CIMElement - //on the QueuedTask - //Place symbol on the layout - MapPoint point = MapPointBuilder.CreateMapPoint(new Coordinate2D(9, 1)); + ArrowHeadKey = ArrowInfo.DefaultArrowHeadKeys[1], + ArrowOnBothEnds = true, + ArrowSizePoints = 30, + LineWidthPoints = 15 + }; - //specify a symbol - var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol( - ColorFactory.Instance.GreenRGB); + var graphic = GraphicFactory.Instance.CreateArrowGraphic(linePl, arrowInfo); - //create a CIMGraphic - var graphic = new CIMGraphicElement() - { - Graphic = new CIMPointGraphic() - { - Symbol = pt_symbol.MakeSymbolReference(), - Location = point //A point in the layout - } - }; - LayoutElementFactory.Instance.CreateElement(layout, graphic); - #endregion - }); + //Make an element to add to GraphicsLayer or Layout + //var ge = ElementFactory.Instance.CreateGraphicElement( + // container, graphic, "Arrow Line", false); + #endregion + } + + public static void CreatePictureGraphic(Layout layout, string picPath) + { + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreatePictureGraphic + #region Create Picture Graphic + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(3.5, 1); + Coordinate2D ur = new Coordinate2D(5.5, 2); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Create and add element to layout + //string picPath = ApplicationUtilities.BASEPATH + _settings.baseFolder + "irefusetowatchthismovi.jpg"; + var graphic = GraphicFactory.Instance.CreatePictureGraphic(env.Center, picPath); + + //Make an element to add to GraphicsLayer or Layout + //var ge = ElementFactory.Instance.CreateGraphicElement(layout, graphic); + #endregion + } + + + #region ProSnippet Group: Create Layout Graphic Elements + #endregion + + public static void CreateEllipseElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Core.CIM.CIMStroke + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + // cref: ArcGIS.Desktop.Mapping.SimpleLineStyle + // cref: ArcGIS.Desktop.Mapping.SimpleFillStyle + // cref: ArcGIS.Desktop.Mapping.ColorFactory + // cref: ArcGIS.Desktop.Mapping.ColorFactory.GreyRGB + #region Create Ellipse Graphic Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D center = new Coordinate2D(2, 2.75); + var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, + ArcOrientation.ArcClockwise); + var ellipse = eabElp.ToSegment(); + + //Set symbolology, create and add element to layout + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.GreenRGB, 2.0, + SimpleLineStyle.Dot); + CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical, + outline); + + var poly = PolygonBuilderEx.CreatePolygon( + PolylineBuilderEx.CreatePolyline(ellipse, AttributeFlags.AllAttributes)); + + var elpElm = ElementFactory.Instance.CreateGraphicElement( + container, poly, ellipseSym, "New Ellipse"); + #endregion + + } + + public static void CreateLassoOpenElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Core.CIM.CIMLineSymbol + // cref: ArcGIS.Desktop.Mapping.SimpleLineStyle + // cref: ArcGIS.Desktop.Mapping.ColorFactory.BlackRGB + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline + #region Create Lasso Line, Freehand Graphic Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + List plCoords = new List(); + plCoords.Add(new Coordinate2D(1.5, 10.5)); + plCoords.Add(new Coordinate2D(1.25, 9.5)); + plCoords.Add(new Coordinate2D(1, 10.5)); + plCoords.Add(new Coordinate2D(0.75, 9.5)); + plCoords.Add(new Coordinate2D(0.5, 10.5)); + plCoords.Add(new Coordinate2D(0.5, 1)); + plCoords.Add(new Coordinate2D(0.75, 2)); + plCoords.Add(new Coordinate2D(1, 1)); + Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords); + + //Set symbolology, create and add element to layout + CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol( + ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid); + //var graphic = GraphicFactory.Instance.CreateShapeGraphic(linePl, lineSym); + + var ge = ElementFactory.Instance.CreateGraphicElement( + container, linePl, lineSym, "New Freehand"); + #endregion + } + + public static void CreateLassoElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Core.CIM.CIMStroke + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + // cref: ArcGIS.Desktop.Mapping.SimpleLineStyle + // cref: ArcGIS.Desktop.Mapping.SimpleFillStyle + // cref: ArcGIS.Desktop.Mapping.ColorFactory.BlackRGB + // cref: ArcGIS.Desktop.Mapping.ColorFactory.RedRGB + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon + #region Create Lasso Polygon, Freehand Element + + //Must be on QueuedTask.Run(() => { ... + + List plyCoords = new List(); + plyCoords.Add(new Coordinate2D(1, 1)); + plyCoords.Add(new Coordinate2D(1.25, 2)); + plyCoords.Add(new Coordinate2D(1.5, 1.1)); + plyCoords.Add(new Coordinate2D(1.75, 2)); + plyCoords.Add(new Coordinate2D(2, 1.1)); + plyCoords.Add(new Coordinate2D(2.25, 2)); + plyCoords.Add(new Coordinate2D(2.5, 1.1)); + plyCoords.Add(new Coordinate2D(2.75, 2)); + plyCoords.Add(new Coordinate2D(3, 1)); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); + + //Set symbolology, create and add element to layout + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid); + CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline); + + ElementFactory.Instance.CreateGraphicElement( + container, poly, polySym, "New Lasso"); + #endregion + } + + public static void CreateLineElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.StyleItemType + // cref: ARCGIS.DESKTOP.MAPPING.SymbolStyleItem.Symbol + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSYMBOLS + // cref: ARCGIS.DESKTOP.MAPPING.SYMBOLEXTENSIONMETHODS.SETSIZE + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline + #region Create Line Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + List plCoords = new List(); + plCoords.Add(new Coordinate2D(1, 8.5)); + plCoords.Add(new Coordinate2D(1.66, 9)); + plCoords.Add(new Coordinate2D(2.33, 8.1)); + plCoords.Add(new Coordinate2D(3, 8.5)); + Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords); + + //Reference a line symbol in a style + var ProjectStyles = Project.Current.GetItems(); + StyleProjectItem style = ProjectStyles.First(x => x.Name == "ArcGIS 2D"); + var symStyle = style.SearchSymbols(StyleItemType.LineSymbol, "Line with 2 Markers")[0]; + CIMLineSymbol lineSym = symStyle.Symbol as CIMLineSymbol; + lineSym.SetSize(20); + + //Set symbolology, create and add element to layout + //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid); + ElementFactory.Instance.CreateGraphicElement( + container, linePl, lineSym, "New Line"); + + #endregion + } + + public static void CreatePointElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleGraphic + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.StyleItemType + // cref: ArcGIS.Core.CIM.Anchor + // cref: ARCGIS.DESKTOP.MAPPING.SymbolStyleItem.Symbol + // cref: ArcGIS.Core.CIM.CIMStringMap + // cref: ArcGIS.Core.CIM.CIMStringMap.Key + // cref: ArcGIS.Core.CIM.CIMStringMap.Value + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSYMBOLS + // cref: ARCGIS.DESKTOP.MAPPING.SYMBOLEXTENSIONMETHODS.SETSIZE + // cref: ArcGIS.Desktop.Layouts.ElementInfo + // cref: ArcGIS.Desktop.Layouts.ElementInfo.CustomProperties + // cref: ArcGIS.Desktop.Layouts.ElementInfo.Anchor + // cref: ArcGIS.Desktop.Layouts.ElementInfo.Rotation + #region Create Point Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D coord2D = new Coordinate2D(2.0, 10.0); + + //Reference a point symbol in a style + StyleProjectItem stylePrjItm = Project.Current.GetItems() + .FirstOrDefault(item => item.Name == "ArcGIS 2D"); + SymbolStyleItem symStyleItm = stylePrjItm.SearchSymbols( + StyleItemType.PointSymbol, "City Hall")[0]; + CIMPointSymbol pointSym = symStyleItm.Symbol as CIMPointSymbol; + pointSym.SetSize(50); + + var elemInfo = new ElementInfo() + { + CustomProperties = new List() { + new CIMStringMap() { Key = "Key1", Value = "Value1"}, + new CIMStringMap() { Key = "Key2", Value = "Value2"} + }, + Anchor = Anchor.TopRightCorner, + Rotation = 45.0 + }; + + var graphic = GraphicFactory.Instance.CreateSimpleGraphic( + coord2D.ToMapPoint(), pointSym); + + ElementFactory.Instance.CreateGraphicElement( + container, graphic, "New Point", true, elemInfo); + + #endregion + } + + public static void CreatePolygonElement(IElementContainer container) + { + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + #region Create Polygon Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + List plyCoords = new List(); + plyCoords.Add(new Coordinate2D(1, 7)); + plyCoords.Add(new Coordinate2D(2, 7)); + plyCoords.Add(new Coordinate2D(2, 6.7)); + plyCoords.Add(new Coordinate2D(3, 6.7)); + plyCoords.Add(new Coordinate2D(3, 6.1)); + plyCoords.Add(new Coordinate2D(1, 6.1)); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); + + //Set symbolology, create and add element to layout + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.DashDotDot); + CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline); + + ElementFactory.Instance.CreateGraphicElement( + container, poly, polySym, "New Polygon", false); + + #endregion + } + + public static void CreateRectangleElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleGraphic + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope + // cref: ArcGIS.Core.CIM.Anchor + // cref: ArcGIS.Desktop.Layouts.ElementInfo + // cref: ArcGIS.Desktop.Layouts.ElementInfo.Anchor + // cref: ArcGIS.Desktop.Layouts.ElementInfo.Rotation + // cref: ArcGIS.Desktop.Layouts.ElementInfo.CornerRounding + #region Create Rectangle Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(1.0, 4.75); + Coordinate2D ur = new Coordinate2D(3.0, 5.75); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Set symbolology, create and add element to layout + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid); + CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline); + + var ge = GraphicFactory.Instance.CreateSimpleGraphic(env, polySym); + var elemInfo = new ElementInfo() + { + Anchor = Anchor.CenterPoint, + Rotation = 45.0, + CornerRounding = 5.0 + }; + + ElementFactory.Instance.CreateGraphicElement( + container, env, polySym, "New Rectangle", false, elemInfo); + #endregion + } + + public static void CreateBezierElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.CreateCubicBezierSegment(Coordinate2D,Coordinate2D,Coordinate2D,Coordinate2D,SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ToSegment + // cref: ArcGIS.Core.Geometry.PolylineBuilderEx.CreatePolyline(Segment,SpatialReference) + #region Create Bezier Curve Element + + //Must be on QueuedTask.Run(() => { ... + //Build geometry + Coordinate2D pt1 = new Coordinate2D(1, 7.5); + Coordinate2D pt2 = new Coordinate2D(1.66, 8); + Coordinate2D pt3 = new Coordinate2D(2.33, 7.1); + Coordinate2D pt4 = new Coordinate2D(3, 7.5); + var bez = new CubicBezierBuilderEx(pt1, pt2, pt3, pt4); + var bezSeg = bez.ToSegment(); + Polyline bezPl = PolylineBuilderEx.CreatePolyline(bezSeg, AttributeFlags.AllAttributes); + + //Set symbology, create and add element to layout + CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol( + ColorFactory.Instance.RedRGB, 4.0, SimpleLineStyle.DashDot); + + ElementFactory.Instance.CreateGraphicElement(container, bezPl, lineSym, "New Bezier"); + + #endregion + } + + public static void CreateGraphicElements(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleGraphic + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElements + #region Create Graphic Elements + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + List plyCoords = new List(); + plyCoords.Add(new Coordinate2D(1, 7)); + plyCoords.Add(new Coordinate2D(2, 7)); + plyCoords.Add(new Coordinate2D(2, 6.7)); + plyCoords.Add(new Coordinate2D(3, 6.7)); + plyCoords.Add(new Coordinate2D(3, 6.1)); + plyCoords.Add(new Coordinate2D(1, 6.1)); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); + + //Build geometry + Coordinate2D ll = new Coordinate2D(1.0, 4.75); + Coordinate2D ur = new Coordinate2D(3.0, 5.75); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Build geometry + Coordinate2D coord2D = new Coordinate2D(2.0, 10.0); + + var g1 = GraphicFactory.Instance.CreateSimpleGraphic(poly); + var g2 = GraphicFactory.Instance.CreateSimpleGraphic(env); + var g3 = GraphicFactory.Instance.CreateSimpleGraphic(coord2D.ToMapPoint()); + + var ge = ElementFactory.Instance.CreateGraphicElements( + container, new List() { g1, g2, g3 }, + new List() { "Poly", "Envelope", "MapPoint" }, + true); + #endregion + } + + public async void snippets_CreateLayoutGraphicElements() + { + LayoutView layoutView = LayoutView.Active; + Layout container = layoutView.Layout; await QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.GraphicFactory + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleGraphic + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC.Location + // cref: ARCGIS.CORE.CIM.CIMGRAPHIC.Symbol + // cref: ArcGIS.CORE.CIM.CIMGraphicElement + // cref: ArcGIS.CORE.CIM.CIMGraphicElement.Graphic #region Create Graphic Element using CIMGraphic //on the QueuedTask //Place symbol on the layout - MapPoint location = MapPointBuilder.CreateMapPoint(new Coordinate2D(9, 1)); + //At 2.x - MapPoint location = MapPointBuilder.CreateMapPoint( + // new Coordinate2D(9, 1)); + MapPoint location = MapPointBuilderEx.CreateMapPoint(new Coordinate2D(9, 1)); //specify a symbol var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol( @@ -267,30 +828,58 @@ await QueuedTask.Run(() => Symbol = pt_symbol.MakeSymbolReference(), Location = location //center of map }; - LayoutElementFactory.Instance.CreateGraphicElement(layout, graphic); + //Or use GraphicFactory + var graphic2 = GraphicFactory.Instance.CreateSimpleGraphic(location, pt_symbol); + + //At 2.x - LayoutElementFactory.Instance.CreateGraphicElement(layout, graphic); + ElementFactory.Instance.CreateGraphicElement(container, graphic); + ElementFactory.Instance.CreateGraphicElement(container, graphic2); #endregion - }); + }); await QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC #region Create Graphic Element using CIMSymbol - //on the QueuedTask + + //Must be on QueuedTask.Run(() => { ... + //Place symbol on the layout - MapPoint location = MapPointBuilder.CreateMapPoint(new Coordinate2D(9, 1)); + //At 2.x - MapPoint location = MapPointBuilder.CreateMapPoint( + // new Coordinate2D(9, 1)); + MapPoint location = MapPointBuilderEx.CreateMapPoint(new Coordinate2D(9, 1)); //specify a symbol var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol( ColorFactory.Instance.GreenRGB); - LayoutElementFactory.Instance.CreateGraphicElement(layout, location, pt_symbol); + //At 2.x - + // LayoutElementFactory.Instance.CreateGraphicElement( + // layout, location, pt_symbol); + + ElementFactory.Instance.CreateGraphicElement(container, location, pt_symbol); #endregion }); + await QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElements + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElements + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC.Location + // cref: ARCGIS.CORE.CIM.CIMGRAPHIC.Symbol + // cref: ArcGIS.Desktop.Layouts.GraphicFactory + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleGraphic #region Bulk Element creation - //on the QueuedTask + + //Must be on QueuedTask.Run(() => { ... + //List of Point graphics var listGraphics = new List(); + var listGraphics2 = new List(); //Symbol - var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.BlackRGB); + var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol( + ColorFactory.Instance.BlackRGB); //Define size of the array int dx = 5; int dy = 5; @@ -300,24 +889,73 @@ await QueuedTask.Run(() => { { for (int col = 0; col <= dy; ++col) { - point = MapPointBuilder.CreateMapPoint(col, row); + //At 2.x - point = MapPointBuilder.CreateMapPoint(col, row); + point = MapPointBuilderEx.CreateMapPoint(col, row); //create a CIMGraphic var graphic = new CIMPointGraphic() { Symbol = pointSymbol.MakeSymbolReference(), - Location = point + Location = point }; listGraphics.Add(graphic); + //Or use GraphicFactory + var graphic2 = GraphicFactory.Instance.CreateSimpleGraphic( + point, pointSymbol) as CIMPointGraphic; + listGraphics2.Add(graphic2); } } //Draw the array of graphics - var bulkgraphics = LayoutElementFactory.Instance.CreateGraphicElements(layout, listGraphics, null); + //At 2.x - var bulkgraphics = + // LayoutElementFactory.Instance.CreateGraphicElements( + // layout, listGraphics, null); + + var bulkgraphics = ElementFactory.Instance.CreateGraphicElements( + container, listGraphics); + var bulkgraphics2 = ElementFactory.Instance.CreateGraphicElements( + container, listGraphics2); + #endregion + + }); + + await QueuedTask.Run(() => + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateElement + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC.Location + // cref: ARCGIS.CORE.CIM.CIMGRAPHIC.Symbol + // cref: ArcGIS.CORE.CIM.CIMGraphicElement + // cref: ArcGIS.CORE.CIM.CIMGraphicElement.Graphic + #region Create Element using a CIMGraphicElement + + //Must be on QueuedTask.Run(() => { ... + + //Place symbol on the layout + //At 2.x - MapPoint point = MapPointBuilder.CreateMapPoint(new Coordinate2D(9, 1)); + MapPoint point = MapPointBuilderEx.CreateMapPoint(new Coordinate2D(9, 1)); + + //specify a symbol + var pt_symbol = SymbolFactory.Instance.ConstructPointSymbol( + ColorFactory.Instance.GreenRGB); + + //create a CIMGraphic + var graphic = new CIMGraphicElement() + { + Graphic = new CIMPointGraphic() + { + Symbol = pt_symbol.MakeSymbolReference(), + Location = point //A point in the layout + } + }; + //At 2.x - LayoutElementFactory.Instance.CreateElement(layout, graphic); + ElementFactory.Instance.CreateElement(container, graphic); #endregion }); - // cref: Create point graphic with symbology;ArcGIS.Desktop.Layouts.IElementFactory.CreatePointGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.CIM.CIMPointSymbol) - // cref: Create point graphic with symbology;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePointGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,ArcGIS.Core.CIM.CIMPointSymbol) - // cref: Create point graphic with symbology;ArcGIS.Desktop.Layouts.LayoutElementFactory + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSYMBOLS + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ARCGIS.DESKTOP.MAPPING.SYMBOLEXTENSIONMETHODS.SETSIZE #region Create point graphic with symbology //Create a simple 2D point graphic and apply an existing point style item as the symbology. @@ -328,26 +966,40 @@ await QueuedTask.Run(() => Coordinate2D coord2D = new Coordinate2D(2.0, 10.0); //(optionally) Reference a point symbol in a style - StyleProjectItem ptStylePrjItm = Project.Current.GetItems().FirstOrDefault(item => item.Name == "ArcGIS 2D"); - SymbolStyleItem ptSymStyleItm = ptStylePrjItm.SearchSymbols(StyleItemType.PointSymbol, "City Hall")[0]; + StyleProjectItem ptStylePrjItm = Project.Current.GetItems() + .FirstOrDefault(item => item.Name == "ArcGIS 2D"); + SymbolStyleItem ptSymStyleItm = ptStylePrjItm.SearchSymbols( + StyleItemType.PointSymbol, "City Hall")[0]; CIMPointSymbol pointSym = ptSymStyleItm.Symbol as CIMPointSymbol; pointSym.SetSize(50); //Set symbolology, create and add element to layout - //An alternative simple symbol is also commented out below. This would elminate the four - //optional lines of code above that reference a style. + //An alternative simple symbol is also commented out below. + //This would elminate the four optional lines of code above that + //reference a style. + + //CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol( + // ColorFactory.Instance.RedRGB, 25.0, SimpleMarkerStyle.Star); + //At 2.x - GraphicElement ptElm = + // LayoutElementFactory.Instance.CreatePointGraphicElement( + // layout, coord2D, pointSym); - //CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 25.0, SimpleMarkerStyle.Star); //Alternative simple symbol - GraphicElement ptElm = LayoutElementFactory.Instance.CreatePointGraphicElement(layout, coord2D, pointSym); + GraphicElement ptElm = ElementFactory.Instance.CreateGraphicElement( + container, coord2D.ToMapPoint(), pointSym); ptElm.SetName("New Point"); }); #endregion - // cref: Create line graphic with symbology;ArcGIS.Desktop.Layouts.IElementFactory.CreateLineGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.CIM.CIMLineSymbol) - // cref: Create line graphic with symbology;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateLineGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polyline,ArcGIS.Core.CIM.CIMLineSymbol) + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem + // cref: ArcGIS.Core.CIM.CIMLineSymbol + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSYMBOLS + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ARCGIS.DESKTOP.MAPPING.SYMBOLEXTENSIONMETHODS.SETSIZE #region Create line graphic with symbology - //Create a simple 2D line graphic and apply an existing line style item as the symbology. + //Create a simple 2D line graphic and apply an existing line + //style item as the symbology. //Construct on the worker thread await QueuedTask.Run(() => @@ -358,29 +1010,51 @@ await QueuedTask.Run(() => plCoords.Add(new Coordinate2D(1.66, 9)); plCoords.Add(new Coordinate2D(2.33, 8.1)); plCoords.Add(new Coordinate2D(3, 8.5)); - Polyline linePl = PolylineBuilder.CreatePolyline(plCoords); + //At 2.x - Polyline linePl = PolylineBuilder.CreatePolyline(plCoords); + Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords); //(optionally) Reference a line symbol in a style - StyleProjectItem lnStylePrjItm = Project.Current.GetItems().FirstOrDefault(item => item.Name == "ArcGIS 2D"); - SymbolStyleItem lnSymStyleItm = lnStylePrjItm.SearchSymbols(StyleItemType.LineSymbol, "Line with 2 Markers")[0]; + StyleProjectItem lnStylePrjItm = Project.Current.GetItems() + .FirstOrDefault(item => item.Name == "ArcGIS 2D"); + SymbolStyleItem lnSymStyleItm = lnStylePrjItm.SearchSymbols( + StyleItemType.LineSymbol, "Line with 2 Markers")[0]; CIMLineSymbol lineSym = lnSymStyleItm.Symbol as CIMLineSymbol; lineSym.SetSize(20); //Set symbolology, create and add element to layout - //An alternative simple symbol is also commented out below. This would elminate the four - //optional lines of code above that reference a style. - - //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid); //Alternative simple symbol - GraphicElement lineElm = LayoutElementFactory.Instance.CreateLineGraphicElement(layout, linePl, lineSym); + //An alternative simple symbol is also commented out below. + //This would elminate the four optional lines of code above that + //reference a style. + // + //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol( + // ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid); + //At 2.x - GraphicElement lineElm = + // LayoutElementFactory.Instance.CreateLineGraphicElement( + // layout, linePl, lineSym); + + GraphicElement lineElm = ElementFactory.Instance.CreateGraphicElement( + container, linePl, lineSym); lineElm.SetName("New Line"); }); #endregion - // cref: Create rectangle graphic with simple symbology;ArcGIS.Desktop.Layouts.IElementFactory.CreateRectangleGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Core.CIM.CIMPolygonSymbol) - // cref: Create rectangle graphic with simple symbology;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateRectangleGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Core.CIM.CIMPolygonSymbol) + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructStroke(CIMCOLOR,DOUBLE,SIMPLELINESTYLE) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol(CIMCOLOR,SIMPLEFILLSTYLE,CIMSTROKE) + // cref: ArcGIS.Desktop.Mapping.SimpleLineStyle + // cref: ArcGIS.Desktop.Mapping.SimpleFillStyle + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem + // cref: ArcGIS.Core.CIM.CIMStroke + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreatePredefinedShapeGraphicElement + // cref: ArcGIS.Desktop.Layouts.PredefinedShape + // cref: ArcGIS.Desktop.Layouts.GraphicElement #region Create rectangle graphic with simple symbology - //Create a simple 2D rectangle graphic and apply simple fill and outline symbols. + //Create a simple 2D rectangle graphic and apply simple fill and + //outline symbols. //Construct on the worker thread await QueuedTask.Run(() => @@ -388,24 +1062,51 @@ await QueuedTask.Run(() => //Build 2D envelope geometry Coordinate2D rec_ll = new Coordinate2D(1.0, 4.75); Coordinate2D rec_ur = new Coordinate2D(3.0, 5.75); - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur); + //At 2.x - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur); + Envelope rec_env = EnvelopeBuilderEx.CreateEnvelope(rec_ll, rec_ur); //Set symbolology, create and add element to layout - CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid); - CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline); - GraphicElement recElm = LayoutElementFactory.Instance.CreateRectangleGraphicElement(layout, rec_env, polySym); - recElm.SetName("New Rectangle"); + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid); + CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline); + + //At 2.x - GraphicElement recElm = + // LayoutElementFactory.Instance.CreateRectangleGraphicElement( + // layout, rec_env, polySym); + // recElm.SetName("New Rectangle"); + // + GraphicElement recElm = ElementFactory.Instance.CreateGraphicElement( + container, rec_env, polySym, "New Rectangle"); + //Or use Predefined shape + GraphicElement recElm2 = ElementFactory.Instance.CreatePredefinedShapeGraphicElement( + container, PredefinedShape.Rectangle, rec_env, polySym, + "New Rectangle2"); }); #endregion - // cref: Create text element with basic font properties;ArcGIS.Desktop.Layouts.IElementFactory.CreatePointTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,System.String) - // cref: Create text element with basic font properties;ArcGIS.Desktop.Layouts.IElementFactory.CreatePointTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,System.String,ArcGIS.Core.CIM.CIMTextSymbol) - // cref: Create text element with basic font properties;ArcGIS.Desktop.Layouts.IElementFactory.CreatePointTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,System.String,ArcGIS.Core.CIM.CIMTextSymbol,ArcGIS.Core.CIM.Anchor) - // cref: Create text element with basic font properties;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePointTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,System.String) - // cref: Create text element with basic font properties;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePointTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,System.String,ArcGIS.Core.CIM.CIMTextSymbol) - // cref: Create text element with basic font properties;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePointTextGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Coordinate2D,System.String,ArcGIS.Core.CIM.CIMTextSymbol,ArcGIS.Core.CIM.Anchor) - // cref: Create text element with basic font properties;ArcGIS.Desktop.Layouts.TextElement - #region Create text element with basic font properties + } + + #region ProSnippet Group: Create Text Graphic Elements + #endregion + + public async void snippets_CreateTextElements() + { + LayoutView layoutView = LayoutView.Active; + Layout container = layoutView.Layout; + + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol(CIMPOLYGONSYMBOL,DOUBLE,STRING,STRING) + // cref: ArcGIS.Core.CIM.CIMTextSymbol + // cref: ArcGIS.Core.CIM.Anchor + // cref: ArcGIS.Desktop.Layouts.ElementInfo + // cref: ArcGIS.Desktop.Layouts.ElementInfo.Anchor + // cref: ArcGIS.Desktop.Layouts.ElementInfo.Rotation + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.TextType + // cref: ArcGIS.Desktop.Layouts.Element.SetX + // cref: ArcGIS.Desktop.Layouts.Element.SetY + #region Create Point Text Element 1 //Create a simple point text element and assign basic symbology and text settings. //Construct on the worker thread @@ -415,24 +1116,47 @@ await QueuedTask.Run(() => Coordinate2D coord2D = new Coordinate2D(3.5, 10); //Set symbolology, create and add element to layout - CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.RedRGB, 32, "Arial", "Regular"); + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.RedRGB, 32, "Arial", "Regular"); string textString = "Point text"; - GraphicElement ptTxtElm = LayoutElementFactory.Instance.CreatePointTextGraphicElement(layout, coord2D, textString, sym); - ptTxtElm.SetName("New Point Text"); + //At 2.x - GraphicElement ptTxtElm = + // LayoutElementFactory.Instance.CreatePointTextGraphicElement( + // layout, coord2D, textString, sym); + //ptTxtElm.SetName("New Point Text"); + //ptTxtElm.SetAnchor(Anchor.CenterPoint); + //ptTxtElm.SetX(4.5); + //ptTxtElm.SetY(9.5); + //ptTxtElm.SetRotation(45); + + //use ElementInfo to set placement properties during create + var elemInfo = new ElementInfo() + { + Anchor = Anchor.CenterPoint, + Rotation = 45 + }; + var ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement( + container, TextType.PointText, coord2D.ToMapPoint(), sym, textString, + "New Point Text", true, elemInfo); //Change additional text properties - ptTxtElm.SetAnchor(Anchor.CenterPoint); ptTxtElm.SetX(4.5); ptTxtElm.SetY(9.5); - ptTxtElm.SetRotation(45); }); #endregion - // cref: Create rectangle text with more advanced symbol settings;ArcGIS.Desktop.Layouts.IElementFactory.CreateRectangleParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,System.String) - // cref: Create rectangle text with more advanced symbol settings;ArcGIS.Desktop.Layouts.IElementFactory.CreateRectangleParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,System.String,ArcGIS.Core.CIM.CIMTextSymbol) - // cref: Create rectangle text with more advanced symbol settings;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateRectangleParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,System.String) - // cref: Create rectangle text with more advanced symbol settings;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateRectangleParagraphGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,System.String,ArcGIS.Core.CIM.CIMTextSymbol) - #region Create rectangle text with more advanced symbol settings + // cref: ArcGIS.Core.Geometry.PolygonBuilderEx.CreatePolygon(IEnumerable{Coordinate3D},SpatialReference) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol(CIMPOLYGONSYMBOL,DOUBLE,STRING,STRING) + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.TextType + // cref: ArcGIS.Core.CIM.CIMTextSymbol + // cref: ArcGIS.Core.CIM.CIMGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic.Frame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame.BorderSymbol + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ArcGIS.Desktop.Layouts.GraphicElement.SetGraphic + #region Create Rectangle Paragraph Text Element 1 //Create rectangle text with background and border symbology. //Construct on the worker thread @@ -446,27 +1170,417 @@ await QueuedTask.Run(() => plyCoords.Add(new Coordinate2D(5.5, 6.7)); plyCoords.Add(new Coordinate2D(5.5, 6.1)); plyCoords.Add(new Coordinate2D(3.5, 6.1)); - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); + //At 2.x - Polygon poly = PolygonBuilder.CreatePolygon(plyCoords); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); //Set symbolology, create and add element to layout //Also notice how formatting tags are using within the text string. - CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular"); - string text = "Some Text String that is really long and is forced to wrap to other lines so that we can see the effects." as String; - GraphicElement polyTxtElm = LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement(layout, poly, text, sym); - polyTxtElm.SetName("New Polygon Text"); + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular"); + string text = "Some Text String that is really long and is " + + "forced to wrap to other lines so that " + + "we can see the effects." as String; + //At 2.x - GraphicElement polyTxtElm = + // LayoutElementFactory.Instance.CreatePolygonParagraphGraphicElement( + // layout, poly, text, sym); + // polyTxtElm.SetName("New Polygon Text"); + + GraphicElement polyTxtElm = ElementFactory.Instance.CreateTextGraphicElement( + container, TextType.RectangleParagraph, poly, sym, text, "Polygon Paragraph"); //(Optionally) Modify paragraph border CIMGraphic polyTxtGra = polyTxtElm.GetGraphic(); CIMParagraphTextGraphic cimPolyTxtGra = polyTxtGra as CIMParagraphTextGraphic; cimPolyTxtGra.Frame.BorderSymbol = new CIMSymbolReference(); - cimPolyTxtGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid); + cimPolyTxtGra.Frame.BorderSymbol.Symbol = + SymbolFactory.Instance.ConstructLineSymbol( + ColorFactory.Instance.GreyRGB, 1.0, SimpleLineStyle.Solid); polyTxtElm.SetGraphic(polyTxtGra); }); #endregion - // cref: Create a new picture element with advanced symbol settings;ArcGIS.Desktop.Layouts.IElementFactory.CreatePictureGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,System.String) - // cref: Create a new picture element with advanced symbol settings;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateAttachmentFrameElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,System.String) - // cref: Create a new picture element with advanced symbol settings;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreatePictureGraphicElement(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,System.String) + // cref: ArcGIS.Desktop.Layouts.TextElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Layouts.TextElement.SetTextProperties + // cref: ArcGIS.Desktop.Layouts.TextProperties + #region Create a Dynamic Point Text Element + //Create a dynamic text element. + + //Set the string with tags and the location + String title = @""; + Coordinate2D llTitle = new Coordinate2D(6, 2.5); + + //Construct element on worker thread + await QueuedTask.Run(() => + { + //Create with default text properties + //At 2.x - TextElement titleGraphics = + // LayoutElementFactory.Instance.CreatePointTextGraphicElement( + // layout, llTitle, null) as TextElement; + TextElement titleGraphics = ElementFactory.Instance.CreateTextGraphicElement( + container, TextType.PointText, llTitle.ToMapPoint()) as TextElement; + + //Modify the text properties + titleGraphics.SetTextProperties(new TextProperties(title, "Arial", 24, "Bold")); + }); + #endregion + } + + public static void CreatePointTextElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Desktop.Layouts.TextType + // cref: ArcGIS.Desktop.Layouts.ElementInfo.Anchor + #region Create Point Text Element 2 + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D coord2D = new Coordinate2D(3.5, 10); + + //Set symbolology, create and add element to layout + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.RedRGB, 32, "Arial", "Regular"); + string textString = "Point text"; + + var elemInfo = new ElementInfo() { Anchor = Anchor.BottomLeftCorner }; + GraphicElement ptTxtElm = ElementFactory.Instance.CreateTextGraphicElement( + container, TextType.PointText, coord2D.ToMapPoint(), sym, textString, + "New Point Text", true, elemInfo); + + #endregion + } + + public static void CreatePolygonTextElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Desktop.Layouts.TextType + #region Create Polygon Paragraph Text Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + List plyCoords = new List(); + plyCoords.Add(new Coordinate2D(3.5, 7)); + plyCoords.Add(new Coordinate2D(4.5, 7)); + plyCoords.Add(new Coordinate2D(4.5, 6.7)); + plyCoords.Add(new Coordinate2D(5.5, 6.7)); + plyCoords.Add(new Coordinate2D(5.5, 6.1)); + plyCoords.Add(new Coordinate2D(3.5, 6.1)); + Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords); + + //Set symbolology, create and add element to layout + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.GreyRGB, 10, "Arial", "Regular"); + string text = "Some text string that is really long and " + + "wraps to other lines" + + " so that we can see the effects."; + + var ge = ElementFactory.Instance.CreateTextGraphicElement( + container, TextType.PolygonParagraph, poly, sym, text, + "New Polygon Text", true); + #endregion + } + + public static void CreateRectangleText(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Desktop.Layouts.TextType + #region Create Rectangle Paragraph Text Element 2 + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(3.5, 4.75); + Coordinate2D ur = new Coordinate2D(5.5, 5.75); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Set symbolology, create and add element to layout + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.WhiteRGB, 10, "Arial", "Regular"); + string text = "Some text string that is really long and " + + "wraps to other lines" + + " so that we can see the effects."; + + //(Optionally) Modify border and background with 50% transparency + //CIMGraphic recTxtGra = recTxtElm.Graphic; + //CIMParagraphTextGraphic cimRecTxtGra = recTxtGra as CIMParagraphTextGraphic; + //CIMSymbolReference cimRecTxtBorder = cimRecTxtGra.Frame.BorderSymbol; + // + //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol( + // ColorFactory.Instance.BlackRGB, 1.0, SimpleLineStyle.Solid); + //cimRecTxtBorder.Symbol = lineSym; + // + //CIMSymbolReference cimRecTxtBkgrd = cimRecTxtGra.Frame.BackgroundSymbol; + //CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol( + // ColorFactory.Instance.GreyRGB, SimpleFillStyle.Solid); + // + //CIMColor symCol = polySym.GetColor(IElementContainer container); + //symCol.SetAlphaValue(50); + //cimRecTxtBkgrd.Symbol = polySym; + //recTxtElm.SetGraphic(recTxtGra); + + var ge = ElementFactory.Instance.CreateTextGraphicElement(container, + TextType.RectangleParagraph, env, sym, text, "New Rectangle Text"); + #endregion + } + + public static void CreateCircleTextElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Desktop.Layouts.TextType + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx._ctor + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.ToSegment + #region Create Circle Text Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D center = new Coordinate2D(4.5, 4); + var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise); + var cir = eabCir.ToSegment(); + + var poly = PolygonBuilderEx.CreatePolygon( + PolylineBuilderEx.CreatePolyline(cir, AttributeFlags.AllAttributes)); + + //Set symbolology, create and add element to layout + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.GreenRGB, 10, "Arial", "Regular"); + string text = "Circle, circle, circle"; + + GraphicElement cirTxtElm = ElementFactory.Instance.CreateTextGraphicElement( + container, TextType.CircleParagraph, poly, sym, text, "New Circle Text", false); + + #endregion + } + + public static void CreateBezierTextElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Desktop.Layouts.TextType + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx._ctor(Coordinate2D,Coordinate2D,Coordinate2D,Coordinate2D,SpatialReference) + // cref: ArcGIS.Core.Geometry.CubicBezierBuilderEx.ToSegment + #region Create Bezier Text Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D pt1 = new Coordinate2D(3.5, 7.5); + Coordinate2D pt2 = new Coordinate2D(4.16, 8); + Coordinate2D pt3 = new Coordinate2D(4.83, 7.1); + Coordinate2D pt4 = new Coordinate2D(5.5, 7.5); + var bez = new CubicBezierBuilderEx(pt1, pt2, pt3, pt4); + var bezSeg = bez.ToSegment(); + Polyline bezPl = PolylineBuilderEx.CreatePolyline(bezSeg, AttributeFlags.AllAttributes); + + //Set symbolology, create and add element to layout + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.BlackRGB, 24, "Comic Sans MS", "Regular"); + + var ge = ElementFactory.Instance.CreateTextGraphicElement( + container, TextType.SplinedText, bezPl, sym, "this is the bezier text", + "New Bezier Text", true, new ElementInfo() { Anchor = Anchor.CenterPoint }); + + #endregion + } + + public static void CreateEllipseTextElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateTextGraphicElement + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol + // cref: ArcGIS.Desktop.Layouts.TextType + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx._ctor(Coordinate2D,Double,Double,Double,ArcOrientation,SpatialReference) + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx.ToSegment + // cref: ArcGIS.Core.Geometry.ArcOrientation + #region Create Ellipse Text Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D center = new Coordinate2D(4.5, 2.75); + var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise); + var ellipse = eabElp.ToSegment(); + + var poly = PolygonBuilderEx.CreatePolygon( + PolylineBuilderEx.CreatePolyline(ellipse, AttributeFlags.AllAttributes)); + + //Set symbolology, create and add element to layout + CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol( + ColorFactory.Instance.BlueRGB, 10, "Arial", "Regular"); + string text = "Ellipse, ellipse, ellipse"; + + GraphicElement ge = ElementFactory.Instance.CreateTextGraphicElement( + container, TextType.PolygonParagraph, poly, sym, text, "New Ellipse Text", false); + + #endregion + } + + #region ProSnippet Group: Create Predefined Shapes And Arrows + #endregion + + public static void CreatePredefinedShapeElement(IElementContainer container) + { + PredefinedShape shapeType = PredefinedShape.Circle; + + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreatePredefinedShapeGraphicElement + // cref: ArcGIS.Desktop.Layouts.PredefinedShape + #region Create Predefined Shape Graphic Element + + //Must be on QueuedTask.Run(() => { ... + + //PredefinedShape shapeType = + // PredefinedShape.Circle | Cloud | Cross |Circle | Triangle | ... ; + + //Build geometry + Coordinate2D ll = new Coordinate2D(4, 2.5); + Coordinate2D ur = new Coordinate2D(6, 4.5); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + var outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.BlueRGB, 2); + var poly_sym = SymbolFactory.Instance.ConstructPolygonSymbol( + null, outline); + + var ge = ElementFactory.Instance.CreatePredefinedShapeGraphicElement( + container, shapeType, env.Center, env.Width, env.Height, + poly_sym, shapeType.ToString(), true); + + #endregion + } + + public static void CreatePredefinedRoundedRectElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreatePredefinedShapeGraphicElement + // cref: ArcGIS.Desktop.Layouts.PredefinedShape + #region Create Predefined Shape Graphic Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(6.5, 7); + Coordinate2D ur = new Coordinate2D(9, 9); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + var outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.GreenRGB, 2); + var poly_sym = SymbolFactory.Instance.ConstructPolygonSymbol( + null, outline); + + var ge = ElementFactory.Instance.CreatePredefinedShapeGraphicElement( + container, PredefinedShape.RoundedRectangle, env, poly_sym, "Rounded Rect", true); + #endregion + } + + public static void CreatePredefinedEllipseElement(IElementContainer container) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreatePredefinedShapeGraphicElement + // cref: ArcGIS.Desktop.Layouts.PredefinedShape + // cref: ArcGIS.Core.Geometry.EllipticArcBuilderEx._ctor(MapPoint,MapPoint,Double,Double,Double,MinorOrMajor,ArcOrientation,SpatialReference) + // cref: ArcGIS.Core.Geometry.ArcOrientation + #region Create Predefined Shape Graphic Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D center = new Coordinate2D(2, 2.75); + var eabElp = new EllipticArcBuilderEx( + center, 0, 1, 0.45, ArcOrientation.ArcClockwise); + var ellipse = eabElp.ToSegment(); + + //Set symbolology, create and add element to layout + CIMStroke outline = SymbolFactory.Instance.ConstructStroke( + ColorFactory.Instance.GreenRGB, 2.0, SimpleLineStyle.Dot); + CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical, outline); + + var poly = PolygonBuilderEx.CreatePolygon( + PolylineBuilderEx.CreatePolyline(ellipse, AttributeFlags.AllAttributes)); + + var ge = ElementFactory.Instance.CreatePredefinedShapeGraphicElement( + container, PredefinedShape.Ellipse, poly.Extent.Center, 0, 0, ellipseSym, + "New Ellipse2", false, new ElementInfo() { Anchor = Anchor.TopRightCorner }); + #endregion + } + + public static void CreateLineArrowElement(IElementContainer container) + { + + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateArrowGraphicElement + // cref: ArcGIS.Desktop.Layouts.ArrowInfo + // cref: ArcGIS.Desktop.Layouts.ArrowInfo.ArrowHeadKey + // cref: ArcGIS.Desktop.Layouts.ArrowInfo.ArrowOnBothEnds + // cref: ArcGIS.Desktop.Layouts.ArrowInfo.ArrowSizePoints + // cref: ArcGIS.Desktop.Layouts.ArrowInfo.LineWidthPoints + // cref: ArcGIS.Desktop.Layouts.ElementInfo.Rotation + #region Create Line Arrow Element + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + List plCoords = new List(); + plCoords.Add(new Coordinate2D(1, 8.5)); + plCoords.Add(new Coordinate2D(1.66, 9)); + plCoords.Add(new Coordinate2D(2.33, 8.1)); + plCoords.Add(new Coordinate2D(3, 8.5)); + Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords); + + var arrowInfo = new ArrowInfo() + { + ArrowHeadKey = ArrowInfo.DefaultArrowHeadKeys[8], + ArrowOnBothEnds = true, + ArrowSizePoints = 24, + LineWidthPoints = 12 + }; + + //Create and add element to layout + GraphicElement lineElm = ElementFactory.Instance.CreateArrowGraphicElement( + container, linePl, arrowInfo, "Arrow Line", true, + new ElementInfo() { Rotation = 15.0 }); + //lineElm.SetName("New Line"); + + #endregion + } + + #region ProSnippet Group: Picture Elements + #endregion + + public static void CreatePictureElement(Layout layout, string picPath) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement + // cref: ArcGIS.Desktop.Layouts.IElementFactory.CreateGraphicElement + // cref: ARCGIS.CORE.CIM.CIMPOINTGRAPHIC + #region Create Picture Graphic Element using CIMSymbol + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(0.5, 1); + Coordinate2D ur = new Coordinate2D(2.5, 2); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Create and add element to layout + //string picPath = ApplicationUtilities.BASEPATH + _settings.baseFolder + "irefusetowatchthismovi.jpg"; + var pic_gr = ElementFactory.Instance.CreatePictureGraphicElement( + layout, env.Center, picPath, "New Picture", true, new ElementInfo() { Anchor = Anchor.CenterPoint }); + #endregion + } + + public async void snippets_CreateLayoutElements() + { + LayoutView layoutView = LayoutView.Active; + Layout layout = layoutView.Layout; + + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreatePictureGraphicElement + // cref: ArcGIS.Core.CIM.CIMPictureGraphic + // cref: ArcGIS.Core.CIM.CIMPictureGraphic.Frame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame.BorderSymbol + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ArcGIS.Desktop.Layouts.GraphicElement.SetGraphic #region Create a new picture element with advanced symbol settings //Create a picture element and also set background and border symbology. @@ -476,33 +1590,54 @@ await QueuedTask.Run(() => //Build 2D envelope geometry Coordinate2D pic_ll = new Coordinate2D(6, 1); Coordinate2D pic_ur = new Coordinate2D(8, 2); - Envelope env = EnvelopeBuilder.CreateEnvelope(pic_ll, pic_ur); + //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(pic_ll, pic_ur); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(pic_ll, pic_ur); //Create and add element to layout string picPath = @"C:\Temp\WhitePass.jpg"; - GraphicElement picElm = LayoutElementFactory.Instance.CreatePictureGraphicElement(layout, env, picPath); - picElm.SetName("New Picture"); + //At 2.x - GraphicElement picElm = + // LayoutElementFactory.Instance.CreatePictureGraphicElement( + // layout, env, picPath); + // picElm.SetName("New Picture"); + // + GraphicElement picElm = ElementFactory.Instance.CreatePictureGraphicElement( + layout, env, picPath, "New Picture"); //(Optionally) Modify the border and shadow CIMGraphic picGra = picElm.GetGraphic(); CIMPictureGraphic cimPicGra = picGra as CIMPictureGraphic; cimPicGra.Frame.BorderSymbol = new CIMSymbolReference(); - cimPicGra.Frame.BorderSymbol.Symbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid); + cimPicGra.Frame.BorderSymbol.Symbol = + SymbolFactory.Instance.ConstructLineSymbol( + ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid); cimPicGra.Frame.ShadowSymbol = new CIMSymbolReference(); - cimPicGra.Frame.ShadowSymbol.Symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlackRGB, SimpleFillStyle.Solid); + cimPicGra.Frame.ShadowSymbol.Symbol = + SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.BlackRGB, SimpleFillStyle.Solid); //Update the element picElm.SetGraphic(picGra); }); #endregion + } + + #region ProSnippet Group: Create MapFrame and Surrounds + #endregion + + public async void snippets_CreateLayoutElements2() + { + LayoutView layoutView = LayoutView.Active; + Layout layout = layoutView.Layout; - // cref: Create a map frame and zoom to a bookmark;ArcGIS.Desktop.Layouts.IElementFactory.CreateMapFrame(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Desktop.Mapping.Map) - // cref: Create a map frame and zoom to a bookmark;ArcGIS.Desktop.Layouts.IElementFactory.CreateMapFrame(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,ArcGIS.Desktop.Mapping.Map) - // cref: Create a map frame and zoom to a bookmark;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateMapFrame(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Desktop.Mapping.Map) - // cref: Create a map frame and zoom to a bookmark;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateMapFrame(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Polygon,ArcGIS.Desktop.Mapping.Map) - // cref: Create a map frame and zoom to a bookmark;ArcGIS.Desktop.Layouts.MapFrame - #region Create a map frame and zoom to a bookmark + // cref: ArcGIS.Core.Geometry.EnvelopeBuilderEx.CreateEnvelope(Coordinate2D,Coordinate2D,SpatialReference) + // cref: ArcGIS.Desktop.Mapping.MapProjectItem + // cref: ArcGIS.Desktop.Mapping.MapProjectItem.GetMap + // cref: ArcGIS.Desktop.Mapping.Map.GetBookmarks + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapFrameElement + // cref: ArcGIS.Desktop.Layouts.MapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetCamera(BOOKMARK) + #region Create Map Frame and Set Camera //Create a map frame and set its camera by zooming to the extent of an existing bookmark. //Construct on the worker thread @@ -511,88 +1646,445 @@ await QueuedTask.Run(() => //Build 2D envelope geometry Coordinate2D mf_ll = new Coordinate2D(6.0, 8.5); Coordinate2D mf_ur = new Coordinate2D(8.0, 10.5); - Envelope mf_env = EnvelopeBuilder.CreateEnvelope(mf_ll, mf_ur); + //At 2.x - Envelope mf_env = EnvelopeBuilder.CreateEnvelope(mf_ll, mf_ur); + Envelope mf_env = EnvelopeBuilderEx.CreateEnvelope(mf_ll, mf_ur); //Reference map, create MF and add to layout - MapProjectItem mapPrjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("Map")); + MapProjectItem mapPrjItem = Project.Current.GetItems() + .FirstOrDefault(item => item.Name.Equals("Map")); Map mfMap = mapPrjItem.GetMap(); - Bookmark bookmark = mfMap.GetBookmarks().FirstOrDefault(b => b.Name == "Great Lakes"); + Bookmark bookmark = mfMap.GetBookmarks().FirstOrDefault( + b => b.Name == "Great Lakes"); - MapFrame mfElm = LayoutElementFactory.Instance.CreateMapFrame(layout, mf_env, mfMap); - mfElm.SetName("New Map Frame"); + //At 2.x - MapFrame mfElm = + // LayoutElementFactory.Instance.CreateMapFrame( + // layout, mf_env, mfMap); + // mfElm.SetName("New Map Frame"); + // + MapFrame mfElm = ElementFactory.Instance.CreateMapFrameElement( + layout, mf_env, mfMap, "New Map Frame"); //Zoom to bookmark mfElm.SetCamera(bookmark); }); #endregion - #region Apply a background color to a MapFrame element - //Apply a background color to the map frame element using the CIM. + // cref: ArcGIS.Desktop.Layouts.Legend + // cref: ArcGIS.Desktop.Layouts.LegendInfo + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + #region Create Legend + //Create a legend for an associated map frame. - //Perform on the worker thread + //Construct on the worker thread await QueuedTask.Run(() => { - //Get the layout - var myLayout = Project.Current.GetItems()?.First().GetLayout(); - if (myLayout == null) return; + //Build 2D envelope geometry + Coordinate2D leg_ll = new Coordinate2D(6, 2.5); + Coordinate2D leg_ur = new Coordinate2D(8, 4.5); + //At 2.x - Envelope leg_env = EnvelopeBuilder.CreateEnvelope(leg_ll, leg_ur); + Envelope leg_env = EnvelopeBuilderEx.CreateEnvelope(leg_ll, leg_ur); - //Get the map frame in the layout - MapFrame mapFrame = myLayout.FindElement("New Map Frame") as MapFrame; + //Reference MF, create legend and add to layout + MapFrame mapFrame = layout.FindElement("New Map Frame") as MapFrame; if (mapFrame == null) { - ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING"); + //TODO handle null map frame return; } + //At 2.x - Legend legendElm = LayoutElementFactory.Instance.CreateLegend( + // layout, leg_env, mapFrame); + // legendElm.SetName("New Legend"); + var legendInfo = new LegendInfo() + { + MapFrameName = mapFrame.Name + }; + Legend legendElm = ElementFactory.Instance.CreateMapSurroundElement( + layout, leg_env, legendInfo, "New Legend") as Legend; + }); + #endregion - //Get the map frame's definition in order to modify the background. - var mapFrameDefn = mapFrame.GetDefinition() as CIMMapFrame; + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.ScaleBarStyleItem + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSCALEBARS + // cref: ArcGIS.Desktop.Layouts.ScaleBarInfo + // cref: ArcGIS.Desktop.Layouts.ScaleBarInfo.ScaleBarStyleItem + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + #region Create Scale Bar From StyleItem + //Create a scale bar using a style. - //Construct the polygon symbol to use to create a background - var polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.BlueRGB, SimpleFillStyle.Solid); + //Search for a style project item by name + StyleProjectItem arcgis_2dStyle = Project.Current.GetItems() + .First(si => si.Name == "ArcGIS 2D"); + + //Construct on the worker thread + await QueuedTask.Run(() => + { + //Reference the specific scale bar by name + ScaleBarStyleItem scaleBarItem = arcgis_2dStyle.SearchScaleBars( + "Double Alternating Scale Bar").FirstOrDefault(); + + //Reference the map frame and define the location + MapFrame myMapFrame = layout.FindElement("Map Frame") as MapFrame; + Coordinate2D coord2D = new Coordinate2D(10.0, 7.0); + + //Construct the scale bar + //At 2.x - LayoutElementFactory.Instance.CreateScaleBar( + // layout, coord2D, myMapFrame, scaleBarItem); + var sbarInfo = new ScaleBarInfo() + { + MapFrameName = myMapFrame.Name, + ScaleBarStyleItem = scaleBarItem + }; + ElementFactory.Instance.CreateMapSurroundElement( + layout, coord2D.ToMapPoint(), sbarInfo); + }); + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.NorthArrowStyleItem + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SearchNorthArrows + // cref: ArcGIS.Desktop.Layouts.NorthArrowInfo + // cref: ArcGIS.Desktop.Layouts.NorthArrowInfo.NorthArrowStyleItem + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + #region Create North Arrow From StyleItem 1 + //Create a north arrow using a style. + + //Search for a style project item by name + StyleProjectItem arcgis2dStyles = Project.Current.GetItems() + .First(si => si.Name == "ArcGIS 2D"); + + //Construct on the worker thread + await QueuedTask.Run(() => + { + NorthArrowStyleItem naStyleItem = arcgis2dStyles.SearchNorthArrows( + "ArcGIS North 13").FirstOrDefault(); + + //Reference the map frame and define the location + MapFrame newFrame = layout.FindElement("New Map Frame") as MapFrame; + Coordinate2D nArrow = new Coordinate2D(6, 2.5); + + //Construct the north arrow + //At 2.x - var newNorthArrow = LayoutElementFactory.Instance.CreateNorthArrow( + // layout, nArrow, newFrame, naStyleItem); + + var naInfo = new NorthArrowInfo() + { + MapFrameName = newFrame.Name, + NorthArrowStyleItem = naStyleItem + }; + var newNorthArrow = ElementFactory.Instance.CreateMapSurroundElement( + layout, nArrow.ToMapPoint(), naInfo); + }); + #endregion + + // cref: ArcGIS.Desktop.Layouts.TableFrameInfo + // cref: ArcGIS.Desktop.Layouts.TableFrameInfo.FieldNames + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapMemberUri + // cref: ArcGIS.Desktop.Layouts.TableFrame + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Mapping.Map.FindLayers + #region Create Table Frame + //Create a table frame. + + //Construct on the worker thread + await QueuedTask.Run(() => + { + //Build 2D envelope geometry + Coordinate2D rec_ll = new Coordinate2D(1.0, 3.5); + Coordinate2D rec_ur = new Coordinate2D(7.5, 4.5); + //At 2.x - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur); + Envelope rec_env = EnvelopeBuilderEx.CreateEnvelope(rec_ll, rec_ur); + + //Reference map frame and layer + MapFrame mf = layout.FindElement("Map Frame") as MapFrame; + FeatureLayer lyr = mf.Map.FindLayers("GreatLakes").First() as FeatureLayer; + + //Build fields list + var fields = new[] { "NAME", "Shape_Area", "Shape_Length" }; + + //Construct the table frame + //At 2.x - TableFrame tabFrame = LayoutElementFactory.Instance.CreateTableFrame( + // layout, rec_env, mf, lyr, fields); + + var tableFrameInfo = new TableFrameInfo() + { + FieldNames = fields, + MapFrameName = mf.Name, + MapMemberUri = lyr.URI + }; + var tabFrame = ElementFactory.Instance.CreateMapSurroundElement( + layout, rec_env, tableFrameInfo) as TableFrame; + }); + #endregion + } + + public static void CreateMapFrameElement(Layout layout, Map map) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapFrameElement + // cref: ArcGIS.Desktop.Layouts.MapFrame + #region Create Map Frame 1 + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(2.0, 4.5); + Coordinate2D ur = new Coordinate2D(4.0, 6.5); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Reference map, create MF and add to layout + //var map = MapView.Active.Map; + //var map = mapProjectItem.GetMap(); + //... + + MapFrame mfElm = ElementFactory.Instance.CreateMapFrameElement( + layout, env, map); + #endregion + } + + public static void CreateMapFrameElement2(Layout layout, Map map) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapFrameElement + // cref: ArcGIS.Desktop.Layouts.MapFrame + #region Create Map Frame 2 + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(4.0, 2.5); + Coordinate2D ur = new Coordinate2D(7.0, 5.5); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Reference map, create MF and add to layout + //var map = MapView.Active.Map; + //var map = mapProjectItem.GetMap(); + //... + MapFrame mfElm = ElementFactory.Instance.CreateMapFrameElement( + layout, env.Center, map); + #endregion + } + + public static void CreateLegendElement(Layout layout, string mapFrameName) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.LegendInfo + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Layouts.Element.SetName + // cref: ArcGIS.Desktop.Layouts.Legend + #region Create Legend 2 + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(6, 2.5); + Coordinate2D ur = new Coordinate2D(8, 4.5); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Reference MF, create legend and add to layout + MapFrame mf = layout.FindElement(mapFrameName) as MapFrame; + var surroundInfo = new LegendInfo() + { + MapFrameName = mf.Name + }; + + var legendElm = ElementFactory.Instance.CreateMapSurroundElement( + layout, env.Center, surroundInfo) as Legend; + legendElm.SetName("New Legend"); + #endregion + } + + public static void CreateNorthArrowElement(Layout layout, string MapFrameName) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.NorthArrowInfo + // cref: ArcGIS.Desktop.Layouts.NorthArrowInfo.NorthArrowStyleItem + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Layouts.Element.SetName + // cref: ArcGIS.Desktop.Layouts.Element.SetHeight + // cref: ArcGIS.Desktop.Layouts.Element.SetX + // cref: ArcGIS.Desktop.Layouts.Element.SetY + // cref: ArcGIS.Desktop.Layouts.NorthArrow + // cref: ArcGIS.Desktop.Mapping.NorthArrowStyleItem + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SearchNorthArrows + #region Create North Arrow From StyleItem 2 + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D center = new Coordinate2D(7, 5.5); + + //Reference a North Arrow in a style + StyleProjectItem stylePrjItm = Project.Current.GetItems() + .FirstOrDefault(item => item.Name == "ArcGIS 2D"); + NorthArrowStyleItem naStyleItm = stylePrjItm.SearchNorthArrows( + "ArcGIS North 10")[0]; + + //Reference MF, create north arrow and add to layout + //var mf = container.FindElement("New Map Frame") as MapFrame; + var mf = layout.FindElement(MapFrameName) as MapFrame; + var narrow_info = new NorthArrowInfo() + { + MapFrameName = mf.Name, + NorthArrowStyleItem = naStyleItm + }; + var arrowElm = (NorthArrow)ElementFactory.Instance.CreateMapSurroundElement( + layout, center.ToMapPoint(), narrow_info) as NorthArrow; + arrowElm.SetName("New North Arrow"); + arrowElm.SetHeight(1.75); + arrowElm.SetX(7); + arrowElm.SetY(6); + #endregion + } + + public static void CreateTableFrameElement(Layout layout, string mapFrameName, string uri) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.TableFrameInfo + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapMemberUri + // cref: ArcGIS.Core.CIM.CIMStringMap.Key + // cref: ArcGIS.Core.CIM.CIMStringMap.Value + // cref: ArcGIS.Desktop.Layouts.ElementInfo.CustomProperties + // cref: ArcGIS.Desktop.Layouts.TableFrame + #region Create Table Frame + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(1, 1); + Coordinate2D ur = new Coordinate2D(4, 4); + Envelope env = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + var tableFrameInfo = new TableFrameInfo() + { + MapFrameName = mapFrameName, + MapMemberUri = uri + }; + var attribs = new List(); + for (int i = 1; i < 6; i++) + { + attribs.Add(new CIMStringMap + { + Key = $"Key {i}", + Value = $"Value {i}" + }); + } + var elemInfo = new ElementInfo() + { + CustomProperties = attribs + }; + var tableFrameElem = ElementFactory.Instance.CreateMapSurroundElement( + layout, env.Center, tableFrameInfo, + "New Table Frame", false, elemInfo) as TableFrame; + #endregion + } - //Set the background - mapFrameDefn.GraphicFrame.BackgroundSymbol = polySymbol.MakeSymbolReference(); + public static void CreateScaleBar(IElementContainer layout, MapFrame mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.ScaleBarInfo + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.ScaleBarStyleItem + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSCALEBARS + // cref: ArcGIS.Desktop.Layouts.ScaleBar + #region Create Scale Bar + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(5.0, 6); + Coordinate2D ur = new Coordinate2D(6.0, 7); + Envelope sbEnv = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Reference a Scale Bar in a style + StyleProjectItem stylePrjItm = Project.Current.GetItems() + .FirstOrDefault(item => item.Name == "ArcGIS 2D"); + ScaleBarStyleItem sbStyleItm = stylePrjItm.SearchScaleBars( + "Alternating Scale Bar 1")[0]; + //ScaleBarStyleItem sbStyleItm = stylePrjItm.SearchScaleBars( + // "Double Alternating Scale Bar 1")[0]; + //ScaleBarStyleItem sbStyleItm = stylePrjItm.SearchScaleBars( + // "Hollow Scale Bar 1")[0]; + + //Create Scale Bar + ScaleBarInfo sbInfo = new ScaleBarInfo() + { + MapFrameName = mapFrame.Name + }; - //Set the map frame definition - mapFrame.SetDefinition(mapFrameDefn); - }); + var sbElm = ElementFactory.Instance.CreateMapSurroundElement( + layout, sbEnv, sbInfo) as ScaleBar; #endregion + } - // cref: Create a legend for a specific map frame;ArcGIS.Desktop.Layouts.IElementFactory.CreateLegend(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Desktop.Layouts.MapFrame) - // cref: Create a legend for a specific map frame;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateLegend(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Desktop.Layouts.MapFrame) - // cref: Create a legend for a specific map frame;ArcGIS.Desktop.Layouts.Legend - #region Create a legend for a specific map frame - //Create a legend for an associated map frame. - - //Construct on the worker thread - await QueuedTask.Run(() => + public static void CreateScaleLine(IElementContainer layout, MapFrame mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateMapSurroundElement + // cref: ArcGIS.Desktop.Layouts.ScaleBarInfo + // cref: ArcGIS.Desktop.Layouts.ScaleBarInfo.ScaleBarStyleItem + // cref: ArcGIS.Desktop.Layouts.MapSurroundInfo.MapFrameName + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + // cref: ArcGIS.Desktop.Mapping.ScaleBarStyleItem + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSCALEBARS + // cref: ArcGIS.Desktop.Layouts.ScaleBar + #region Create Scale Line + + //Must be on QueuedTask.Run(() => { ... + + //Build geometry + Coordinate2D ll = new Coordinate2D(5.0, 8); + Coordinate2D ur = new Coordinate2D(6.0, 9); + Envelope sbEnv = EnvelopeBuilderEx.CreateEnvelope(ll, ur); + + //Reference a Scale Bar in a style + StyleProjectItem stylePrjItm = Project.Current.GetItems() + .FirstOrDefault(item => item.Name == "ArcGIS 2D"); + ScaleBarStyleItem sbStyleItm = stylePrjItm.SearchScaleBars( + "Scale Line 1")[0]; + //ScaleBarStyleItem sbStyleItm = stylePrjItm.SearchScaleBars( + // "Stepped Scale Line")[0]; + //ScaleBarStyleItem sbStyleItm = stylePrjItm.SearchScaleBars( + // "Scale Line 2")[0]; + + //Create Scale Bar + ScaleBarInfo sbInfo = new ScaleBarInfo() { - //Build 2D envelope geometry - Coordinate2D leg_ll = new Coordinate2D(6, 2.5); - Coordinate2D leg_ur = new Coordinate2D(8, 4.5); - Envelope leg_env = EnvelopeBuilder.CreateEnvelope(leg_ll, leg_ur); + MapFrameName = mapFrame.Name, + ScaleBarStyleItem = sbStyleItm + }; - //Reference MF, create legend and add to layout - MapFrame mapFrame = layout.FindElement("New Map Frame") as MapFrame; - if (mapFrame == null) - { - ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING"); - return; - } - Legend legendElm = LayoutElementFactory.Instance.CreateLegend(layout, leg_env, mapFrame); - legendElm.SetName("New Legend"); - }); + var sbElm = ElementFactory.Instance.CreateMapSurroundElement( + layout, sbEnv, sbInfo, "ScaleBar Line") as ScaleBar; #endregion + } + + #region ProSnippet Group: Group Elements + #endregion - // cref: Creating empty group elements;ArcGIS.Desktop.Layouts.GroupElement + public async void snippets_CreateGroupElements() + { + LayoutView layoutView = LayoutView.Active; + Layout container = layoutView.Layout; + + // cref: ArcGIS.Desktop.Layouts.GroupElement + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGroupElement #region Creating empty group elements //Create an empty group element at the root level of the contents pane //Create on worker thread await QueuedTask.Run(() => { - GroupElement grp1 = LayoutElementFactory.Instance.CreateGroupElement(layout); - grp1.SetName("Group"); + //At 2.x - GroupElement grp1 = + // LayoutElementFactory.Instance.CreateGroupElement(layout); + // grp1.SetName("Group"); + + //container is IElementContainer - GroupLayer or Layout + GroupElement grp1 = ElementFactory.Instance.CreateGroupElement( + container, null, "Group"); }); // *** or *** @@ -600,148 +2092,86 @@ await QueuedTask.Run(() => //Create a group element inside another group element //Find an existing group element - GroupElement existingGroup = layout.FindElement("Group") as GroupElement; - + //container is IElementContainer - GroupLayer or Layout + GroupElement existingGroup = container.FindElement("Group") as GroupElement; + //Create on worker thread await QueuedTask.Run(() => { - GroupElement grp2 = LayoutElementFactory.Instance.CreateGroupElement(existingGroup); - grp2.SetName("Group in Group"); + //At 2.x - GroupElement grp2 = + // LayoutElementFactory.Instance.CreateGroupElement(existingGroup); + // grp2.SetName("Group in Group"); + GroupElement grp2 = ElementFactory.Instance.CreateGroupElement( + existingGroup, null, "Group in Group"); }); #endregion + // cref: ArcGIS.Desktop.Layouts.GroupElement + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ArcGIS.Desktop.Layouts.Layout.FindElements + // cref: ArcGIS.Desktop.Mapping.IElementContainer.FindElement + // cref: ArcGIS.Desktop.Mapping.IElementContainer.FindElements + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGroupElement #region Create a group element with elements //Create a group with a list of elements at the root level of the contents pane. //Find an existing elements - Element scaleBar = layout.FindElement("Scale Bar") as Element; - Element northArrow = layout.FindElement("North Arrow") as Element; - Element legend = layout.FindElement("Legend") as Element; + //container is IElementContainer - GroupLayer or Layout + var elem1 = container.FindElement("Polygon 1"); + var elem2 = container.FindElement("Bezier Text"); + var elem3 = container.FindElement("Cloud Shape 2"); //Construct a list and add the elements - List elmList = new List + var elmList = new List { - scaleBar, - northArrow, - legend + elem1, + elem2, + elem3 }; //Perform on the worker thread await QueuedTask.Run(() => { - GroupElement groupWithListOfElementsAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmList); - groupWithListOfElementsAtRoot.SetName("Group with list of elements at root"); + //At 2.x - GroupElement groupWithListOfElementsAtRoot = + // LayoutElementFactory.Instance.CreateGroupElement(layout, elmList); + //groupWithListOfElementsAtRoot.SetName("Group with list of elements at root"); + // + GroupElement groupWithListOfElementsAtRoot = + ElementFactory.Instance.CreateGroupElement( + container, elmList, "Group with list of elements at root"); }); - // *** or *** - //Create a group using a list of element names at the root level of the contents pane. //List of element names - var elmNameList = new[] { "Table Frame", "Chart Frame" }; + var elmNameList = new[] { "Para Text1", "Line 3" }; //Perform on the worker thread await QueuedTask.Run(() => { - GroupElement groupWithListOfElementNamesAtRoot = LayoutElementFactory.Instance.CreateGroupElement(layout, elmNameList); - groupWithListOfElementNamesAtRoot.SetName("Group with list of element names at root"); - }); - #endregion - - #region Create a scale bar using a style - //Create a scale bar using a style. - - //Search for a style project item by name - StyleProjectItem arcgis_2dStyle = Project.Current.GetItems().First(si => si.Name == "ArcGIS 2D"); - - //Construct on the worker thread - await QueuedTask.Run(() => - { - //Reference the specific scale bar by name - ScaleBarStyleItem scaleBarItem = arcgis_2dStyle.SearchScaleBars("Double Alternating Scale Bar").FirstOrDefault(); - - //Reference the map frame and define the location - MapFrame myMapFrame = layout.FindElement("Map Frame") as MapFrame; - Coordinate2D coord2D = new Coordinate2D(10.0, 7.0); - - //Construct the scale bar - LayoutElementFactory.Instance.CreateScaleBar(layout, coord2D, myMapFrame, scaleBarItem); - }); - #endregion - - #region Create a north arrow using a style - //Create a north arrow using a style. - - //Search for a style project item by name - StyleProjectItem arcgis2dStyles = Project.Current.GetItems().First(si => si.Name == "ArcGIS 2D"); - - //Construct on the worker thread - await QueuedTask.Run(() => - { - NorthArrowStyleItem naStyleItem = arcgis2dStyles.SearchNorthArrows("ArcGIS North 13").FirstOrDefault(); - - //Reference the map frame and define the location - MapFrame newFrame = layout.FindElement("New Map Frame") as MapFrame; - Coordinate2D nArrow = new Coordinate2D(6, 2.5); - - //Construct the north arrow - var newNorthArrow = LayoutElementFactory.Instance.CreateNorthArrow(layout, nArrow, newFrame, naStyleItem); - }); - #endregion - - #region Create a dynamic text element - //Create a dynamic text element. - - //Set the string with tags and the location - String title = @""; - Coordinate2D llTitle = new Coordinate2D(6, 2.5); - - //Construct element on worker thread - await QueuedTask.Run(() => - { - //Create with default text properties - TextElement titleGraphics = LayoutElementFactory.Instance.CreatePointTextGraphicElement(layout, llTitle, null) as TextElement; - - //Modify the text properties - titleGraphics.SetTextProperties(new TextProperties(title, "Arial", 24, "Bold")); + //At 2.x - GroupElement groupWithListOfElementNamesAtRoot = + // LayoutElementFactory.Instance.CreateGroupElement(layout, elmNameList); + // groupWithListOfElementNamesAtRoot.SetName( + // "Group with list of element names at root"); + + //At 3.x, use the names to find the relevant elements first + //container is IElementContainer - GroupLayer or Layout + var elems = container.FindElements(elmNameList); + GroupElement groupWithListOfElementNamesAtRoot = + ElementFactory.Instance.CreateGroupElement( + container, elems, "Group with list of element names at root"); }); #endregion - - // cref: Create a table frame;ArcGIS.Desktop.Layouts.IElementFactory.CreateTableFrame(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Desktop.Layouts.MapFrame,ArcGIS.Desktop.Mapping.MapMember,System.String[]) - // cref: Create a table frame;ArcGIS.Desktop.Layouts.LayoutElementFactory.CreateTableFrame(ArcGIS.Desktop.Layouts.ILayoutElementContainer,ArcGIS.Core.Geometry.Envelope,ArcGIS.Desktop.Layouts.MapFrame,ArcGIS.Desktop.Mapping.MapMember,System.String[]) - #region Create a table frame - //Create a table frame. - - //Construct on the worker thread - await QueuedTask.Run(() => - { - //Build 2D envelope geometry - Coordinate2D rec_ll = new Coordinate2D(1.0, 3.5); - Coordinate2D rec_ur = new Coordinate2D(7.5, 4.5); - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur); - - //Reference map frame and layer - MapFrame mf = layout.FindElement("Map Frame") as MapFrame; - Map m = mf.Map; - FeatureLayer lyr = m.FindLayers("GreatLakes").First() as FeatureLayer; - - //Build fields list - var fields = new[] { "NAME", "Shape_Area", "Shape_Length" }; - - //Construct the table frame - TableFrame tabFrame = LayoutElementFactory.Instance.CreateTableFrame(layout, rec_env, mf, lyr, fields); - }); - #endregion } - - #region ProSnippet Group: Layout Elements and Selection - #endregion - public void snippets_elements( Layout layout) + #region ProSnippet Group: Layout Elements and Selection + #endregion + public void snippets_elements( Layout layout) { - // cref: Find an element on a layout;ArcGIS.Desktop.Layouts.Element + // cref: ArcGIS.Desktop.Layouts.Layout.FindElement + // cref: ArcGIS.Desktop.Layouts.Layout.Elements #region Find an element on a layout //Find an element on a layout. @@ -764,7 +2194,13 @@ public void snippets_elements( Layout layout) }); } #endregion + QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Layouts.Layout.FindElements + // cref: ArcGIS.Desktop.Layouts.Layout.GetElements + // cref: ArcGIS.Desktop.Layouts.Layout.GetElementsAsFlattenedList + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ArcGIS.Desktop.Layouts.GraphicElement #region Find layout elements //on the QueuedTask //Find elements by name @@ -790,6 +2226,9 @@ public void snippets_elements( Layout layout) }); Element element = null; + + // cref: ArcGIS.Desktop.Layouts.Element.SetName + // cref: ArcGIS.Desktop.Layouts.Element.SetVisible #region Update element properties //Update an element's properties. @@ -804,6 +2243,8 @@ public void snippets_elements( Layout layout) }); #endregion { + // cref: ArcGIS.Desktop.Layouts.LayoutView + // cref: ArcGIS.Desktop.Layouts.LayoutView.GetSelectedElements #region Get element selection count //Get element's selection count. @@ -817,6 +2258,8 @@ public void snippets_elements( Layout layout) #endregion } { + // cref: ArcGIS.Desktop.Layouts.LayoutView + // cref: ArcGIS.Desktop.Layouts.LayoutView.SelectElements #region Set element selection //Set the active layout view's selection to include 2 rectangle elements. @@ -849,6 +2292,10 @@ public void snippets_elements( Layout layout) } #endregion } + + // cref: ArcGIS.Desktop.Layouts.Layout.FindElements + // cref: ArcGIS.Desktop.Layouts.Layout.UnSelectElement + // cref: ArcGIS.Desktop.Layouts.Layout.UnSelectElements #region UnSelect elements on the Layout //Unselect one element. var elementToUnSelect = layout.FindElements(new List() { "MyPoint" }).FirstOrDefault(); @@ -858,6 +2305,10 @@ public void snippets_elements( Layout layout) layout.UnSelectElements(elementsToUnSelect); #endregion + // cref: ArcGIS.Desktop.Layouts.LayoutView.Active + // cref: ArcGIS.Desktop.Layouts.Layout.FindElements + // cref: ArcGIS.Desktop.Layouts.LayoutView.UnSelectElement + // cref: ArcGIS.Desktop.Layouts.LayoutView.UnSelectElements #region UnSelect elements on the LayoutView LayoutView layoutView = LayoutView.Active; //Unselect one element. @@ -869,6 +2320,7 @@ public void snippets_elements( Layout layout) #endregion { + // cref: ArcGIS.Desktop.Layouts.LayoutView.ClearElementSelection #region Clear the selection in a layout view //If the a layout view is active, clear its selection LayoutView activeLayoutView = LayoutView.Active; @@ -877,6 +2329,8 @@ public void snippets_elements( Layout layout) activeLayoutView.ClearElementSelection(); } #endregion + + // cref: ArcGIS.Desktop.Layouts.Layout.ClearElementSelection #region Clear the selection in a layout //Clear the layout selection. layout.ClearElementSelection(); @@ -885,16 +2339,23 @@ public void snippets_elements( Layout layout) Layout aLayout = null; Element elm = null; + // cref: ArcGIS.Desktop.Layouts.Layout.CopyElements #region Copy Layout Elements //on the QueuedTask var elems = layout.FindElements(new List() { "Point 1", "Line 3", "Text 1" }); var copiedElements = layout.CopyElements(elems); #endregion + + // cref: ArcGIS.Desktop.Layouts.Layout.GetSelectedElements + // cref: ArcGIS.Desktop.Layouts.Layout.DeleteElements #region Delete Layout Elements //on the QueuedTask var elementsToRemove = layout.GetSelectedElements(); layout.DeleteElements(elementsToRemove); #endregion + + // cref: ArcGIS.Desktop.Layouts.Layout.DeleteElement + // cref: ArcGIS.Desktop.Layouts.Layout.DeleteElements #region Delete an element or elements on a layout //Delete an element or elements on a layout. @@ -912,6 +2373,8 @@ public void snippets_elements( Layout layout) }); #endregion + // cref: ArcGIS.Desktop.Layouts.Layout.FindElements + // cref: ArcGIS.Desktop.Layouts.LayoutView.ZoomToElements #region Zoom to elements LayoutView lytView = LayoutView.Active; //Zoom to an element @@ -923,8 +2386,13 @@ public void snippets_elements( Layout layout) #endregion - - + // cref: ArcGIS.Desktop.Layouts.Element.GetDefinition + // cref: ArcGIS.Desktop.Layouts.Element.SetDefinition + // cref: ArcGIS.Desktop.Layouts.LayoutView.GetSelectedElements + // cref: ArcGIS.Core.CIM.CIMMarkerNorthArrow + // cref: ArcGIS.Core.CIM.CIMMarkerNorthArrow.PointSymbol + // cref: ArcGIS.Core.CIM.CIMPointSymbol.HaloSymbol + // cref: ArcGIS.Core.CIM.CIMPointSymbol.HaloSize #region Set halo property of north arrow //Set the CIM halo properties of a north arrow. @@ -952,14 +2420,16 @@ public void snippets_elements( Layout layout) northArrow.SetDefinition(cim); }); #endregion - } + private void groupingElements(Layout layout) { #region ProSnippet Group: Grouping and Ordering Graphic Elements #endregion QueuedTask.Run(() => { - + + // cref: ArcGIS.Desktop.Layouts.Layout.GroupElements + // cref: ArcGIS.Desktop.Layouts.Layout.GetSelectedElements #region Group Graphic Elements //on the QueuedTask var elemsToGroup = layout.GetSelectedElements(); @@ -968,6 +2438,8 @@ private void groupingElements(Layout layout) var groupElement = layout.GroupElements(elemsToGroup); #endregion + // cref: ArcGIS.Desktop.Layouts.Layout.UnGroupElement + // cref: ArcGIS.Desktop.Layouts.Layout.UnGroupElements #region Un-Group Graphic Elements var selectedElements = layout.GetSelectedElements().ToList(); if (selectedElements?.Any() == false)//must be at least 1. @@ -987,17 +2459,27 @@ private void groupingElements(Layout layout) layout.UnGroupElement(elementsToUnGroup.FirstOrDefault()); #endregion + // cref: ArcGIS.Desktop.Layouts.GroupElement.Elements + // cref: ArcGIS.Desktop.Layouts.Element.GetParent #region Parent of GroupElement //check the parent var parent = groupElement.Elements.First().GetParent();//will be the group element //top-most parent - var top_most = groupElement.Elements.First().GetParent(true);//will be the GraphicsLayer + //will be a GraphicsLayer or Layout + var top_most = groupElement.Elements.First().GetParent(true); #endregion + + // cref: ArcGIS.Desktop.Layouts.GroupElement.GetElementsAsFlattenedList #region Children in a Group Element // Nested groups within ArcGIS.Desktop.Layouts.GroupElement are not preserved. var children = groupElement.GetElementsAsFlattenedList(); #endregion + // cref: ArcGIS.Desktop.Layouts.Layout.GetSelectedElements + // cref: ArcGIS.Desktop.Layouts.Layout.CanBringForward + // cref: ArcGIS.Desktop.Layouts.Layout.BringForward + // cref: ArcGIS.Desktop.Layouts.Layout.CanSendBackward + // cref: ArcGIS.Desktop.Layouts.Layout.SendBackward #region Ordering: Send backward and Bring forward //On the QueuedTask //get the current selection set @@ -1019,29 +2501,39 @@ private void groupingElements(Layout layout) } #endregion + // cref: ArcGIS.Desktop.Layouts.Layout.GetSelectedElements + // cref: ArcGIS.Desktop.Layouts.Element.ZOrder #region Get Z-Order var selElementsZOrder = layout.GetSelectedElements(); //list out the z order foreach (var elem in selElementsZOrder) - System.Diagnostics.Debug.WriteLine($"{elem.Name}: z-order {elem.GetZOrder()}"); + //At 2.x - System.Diagnostics.Debug.WriteLine($"{elem.Name}: z-order {elem.GetZOrder()}"); + System.Diagnostics.Debug.WriteLine($"{elem.Name}: z-order {elem.ZOrder}"); #endregion }); } #region ProSnippet Group: Update Layout Elements #endregion + public void snippets_UpdateElements() { double x = 0; double y = 0; - // cref: Update text element properties;ArcGIS.Desktop.Layouts.TextElement.SetTextProperties(ArcGIS.Desktop.Layouts.TextProperties) - // cref: Update text element properties;ArcGIS.Desktop.Layouts.TextProperties.#ctor(System.String,System.String,System.Double,System.String) + // cref: ArcGIS.Desktop.Layouts.TextElement.SetTextProperties(ArcGIS.Desktop.Layouts.TextProperties) + // cref: ArcGIS.Desktop.Layouts.TextProperties.#ctor(System.String,System.String,System.Double,System.String) + // cref: ArcGIS.Desktop.Layouts.TextElement + // cref: ArcGIS.Desktop.Layouts.Element.SetX + // cref: ArcGIS.Desktop.Layouts.Element.SetY + // cref: ArcGIS.Desktop.Layouts.Element.SetAnchor + // cref: ArcGIS.Core.CIM.Anchor #region Update text element properties //Update text element properties for an existing text element. // Reference a layoutitem in a project by name - LayoutProjectItem layoutItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("MyLayout")); + LayoutProjectItem layoutItem = Project.Current.GetItems() + .FirstOrDefault(item => item.Name.Equals("MyLayout")); if (layoutItem != null) { @@ -1062,7 +2554,8 @@ public void snippets_UpdateElements() txtElm.SetY(y); // Change TextProperties - TextProperties txtProperties = new TextProperties("Hello world", "Times New Roman", 48, "Regular"); + TextProperties txtProperties = new TextProperties( + "Hello world", "Times New Roman", 48, "Regular"); txtElm.SetTextProperties(txtProperties); } } @@ -1070,6 +2563,8 @@ public void snippets_UpdateElements() } #endregion + // cref: ArcGIS.Desktop.Layouts.PictureElement + // cref: ArcGIS.Desktop.Layouts.PictureElement.SetSourcePath #region Update a picture element //Update a picture element. @@ -1089,6 +2584,48 @@ public void snippets_UpdateElements() }); #endregion + // cref: ArcGIS.Desktop.Layouts.Element.GETDEFINITION + // cref: ArcGIS.Desktop.Layouts.Element.SETDEFINITION + // cref: ArcGIS.Core.CIM.CIMMapFrame + // cref: ArcGIS.Core.CIM.CIMFrameElement.GraphicFrame + // cref: ArcGIS.Core.CIM.CIMGraphicFrame.BackgroundSymbol + #region Apply a Background Color to a MapFrame + //Apply a background color to the map frame element using the CIM. + + //Perform on the worker thread + QueuedTask.Run(() => + { + //Get the layout + var myLayout = Project.Current.GetItems()?.First().GetLayout(); + if (myLayout == null) return; + + //Get the map frame in the layout + MapFrame mapFrame = myLayout.FindElement("New Map Frame") as MapFrame; + if (mapFrame == null) + { + //TODO Handle null mapframe + return; + } + + //Get the map frame's definition in order to modify the background. + var mapFrameDefn = mapFrame.GetDefinition() as CIMMapFrame; + + //Construct the polygon symbol to use to create a background + var polySymbol = SymbolFactory.Instance.ConstructPolygonSymbol( + ColorFactory.Instance.BlueRGB, SimpleFillStyle.Solid); + + //Set the background + mapFrameDefn.GraphicFrame.BackgroundSymbol = + polySymbol.MakeSymbolReference(); + + //Set the map frame definition + mapFrame.SetDefinition(mapFrameDefn); + }); + #endregion + + // cref: ArcGIS.Desktop.Layouts.MapSurround + // cref: ArcGIS.Desktop.Layouts.ScaleBar + // cref: ArcGIS.Desktop.Layouts.MapSurround.SetMapFrame #region Update a map surround //Update a map surround. @@ -1112,9 +2649,14 @@ public void snippets_UpdateElements() }); #endregion + // cref: ArcGIS.Desktop.Layouts.Element.GetDefinition + // cref: ArcGIS.Desktop.Layouts.Element.SetDefinition + // cref: ArcGIS.Core.CIM.CIMElement + // cref: ArcGIS.Core.CIM.CIMElement.Locked #region Lock an element - // The Locked property is displayed in the TOC as a lock symbol next to each element. - // If locked the element can't be selected in the layout using the graphic selection tools. + // The Locked property is displayed in the TOC as a lock symbol next + // to each element. If locked the element can't be selected in the layout + // using the graphic selection tools. //Perform on the worker thread QueuedTask.Run(() => @@ -1137,6 +2679,10 @@ public void snippets_UpdateElements() #endregion + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ArcGIS.Desktop.Layouts.GraphicElement.SetGraphic + // cref: ArcGIS.Core.CIM.CIMGraphic + // cref: ArcGIS.Core.CIM.CIMGraphic.Transparency #region Update an elements transparency //Update an element's transparency using the CIM. @@ -1153,7 +2699,7 @@ public void snippets_UpdateElements() { // Modify the Transparency property that exists only in the CIMGraphic class. CIMGraphic CIMGraphic = graphicElement.GetGraphic() as CIMGraphic; - CIMGraphic.Transparency = 50; // mark it 50% transparent + CIMGraphic.Transparency = 50; // mark it 50% transparent graphicElement.SetGraphic(CIMGraphic); } } @@ -1162,6 +2708,12 @@ public void snippets_UpdateElements() double xOffset = 0; double yOffset = 0; + + // cref: ArcGIS.Desktop.Layouts.GraphicElement.Clone + // cref: ArcGIS.Desktop.Layouts.Element.SetX + // cref: ArcGIS.Desktop.Layouts.Element.SetY + // cref: ArcGIS.Desktop.Layouts.Element.GetX + // cref: ArcGIS.Desktop.Layouts.Element.GetY #region Clone an element //Clone a layout graphic element and apply an offset. @@ -1173,7 +2725,8 @@ public void snippets_UpdateElements() if (layout != null) { // Reference a graphic element by name - GraphicElement graphicElement = layout.FindElement("MyElement") as GraphicElement; + GraphicElement graphicElement = + layout.FindElement("MyElement") as GraphicElement; if (graphicElement != null) { @@ -1187,11 +2740,61 @@ public void snippets_UpdateElements() #endregion } + #region ProSnippet Group: Layout Snapping + #endregion + + private void LayoutSnapping() + { + + // cref: ArcGIS.Desktop.Layouts.LayoutSnapping.IsEnabled + #region Configure Snapping - Turn Snapping on or off + + //enable snapping + ArcGIS.Desktop.Layouts.LayoutSnapping.IsEnabled = true; + + // disable snapping + ArcGIS.Desktop.Layouts.LayoutSnapping.IsEnabled = false; + #endregion + + // cref: ArcGIS.Desktop.Layouts.LayoutSnapping.SetSnapModes(System.Collections.Generic.IEnumerable) + // cref: ArcGIS.Desktop.Layouts.LayoutSnapping.SetSnapMode(ArcGIS.Desktop.Layouts.LayoutSnapMode, System.Boolean) + // cref: ArcGIS.Desktop.Layouts.LayoutSnapping.SnapModes + // cref: ArcGIS.Desktop.Layouts.LayoutSnapping.GetSnapMode(ArcGIS.Desktop.Layouts.LayoutSnapMode) + // cref: ArcGIS.Desktop.Layouts.LayoutSnapMode + #region Configure Snapping - Application SnapModes + + // sets only the Guide snapping mode + ArcGIS.Desktop.Layouts.LayoutSnapping.SetSnapModes(new[] { LayoutSnapMode.Guide }); + // sets only Element and Page snapping modes + ArcGIS.Desktop.Layouts.LayoutSnapping.SetSnapModes(new[] { LayoutSnapMode.Element, LayoutSnapMode.Page }); + + // clear all snap modes + ArcGIS.Desktop.Layouts.LayoutSnapping.SetSnapModes(null); + + + // set snap modes one at a time + ArcGIS.Desktop.Layouts.LayoutSnapping.SetSnapMode(LayoutSnapMode.Margins, true); + ArcGIS.Desktop.Layouts.LayoutSnapping.SetSnapMode(LayoutSnapMode.Guide, true); + /// LayoutSnapping.SetSnapModes(new[]{ LayoutSnapMode.Guide }); // sets only the Guide snapping mode + + // get current snap modes + var snapModes = ArcGIS.Desktop.Layouts.LayoutSnapping.SnapModes; + + // get state of a specific snap mode + bool isOn = ArcGIS.Desktop.Layouts.LayoutSnapping.GetSnapMode(LayoutSnapMode.Guide); + + #endregion + + } + #region ProSnippet Group: Layout Metadata #endregion private void LayoutMetadata(Layout layout) { + // cref: ArcGIS.Desktop.Layouts.Layout.GetMetadata + // cref: ArcGIS.Desktop.Layouts.Layout.GetCanEditMetadata + // cref: ArcGIS.Desktop.Layouts.Layout.SetMetadata #region Layout Metadata //var layout = ...; //Must be on the QueuedTask.Run() @@ -1208,11 +2811,12 @@ private void LayoutMetadata(Layout layout) #region ProSnippet Group: Layout MapFrame #endregion + async public void snippets_MapFrame() { Layout layout = LayoutView.Active.Layout; - // cref: Change the map associated with a map frame;ArcGIS.Desktop.Layouts.MapFrame.SetMap(ArcGIS.Desktop.Mapping.Map) + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetMap(ArcGIS.Desktop.Mapping.Map) #region Change the map associated with a map frame //Change the map associated with a map frame @@ -1231,7 +2835,8 @@ await QueuedTask.Run(() => #endregion - // cref: Change map frame camera settings;ArcGIS.Desktop.Layouts.MapFrame.SetCamera(ArcGIS.Desktop.Mapping.Camera) + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetCamera(ArcGIS.Desktop.Mapping.Camera) + // cref: ArcGIS.Desktop.Mapping.Camera.Scale #region Change map frame camera settings //Change a map frame's camera settings. @@ -1250,7 +2855,9 @@ await QueuedTask.Run(() => }); #endregion - // cref: Zoom map frame to extent of a single layer;ArcGIS.Desktop.Layouts.MapFrame.SetCamera(ArcGIS.Desktop.Mapping.Layer,System.Boolean) + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetCamera(ArcGIS.Desktop.Mapping.Layer,System.Boolean) + // cref: ArcGIS.Desktop.Layouts.MapFrame.Map + // cref: ArcGIS.Desktop.Mapping.Map.FindLayers #region Zoom map frame to extent of a single layer //Zoom map frame to the extent of a single layer. @@ -1269,7 +2876,8 @@ await QueuedTask.Run(() => }); #endregion - // cref: Change map frame extent to selected features in multiple layers;ArcGIS.Desktop.Layouts.MapFrame.SetCamera(System.Collections.Generic.IEnumerable{ArcGIS.Desktop.Mapping.Layer},System.Boolean) + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetCamera(System.Collections.Generic.IEnumerable{ArcGIS.Desktop.Mapping.Layer},System.Boolean) + // cref: ArcGIS.Desktop.Mapping.Map.FindLayers #region Change map frame extent to selected features in multiple layers //Change the extent of a map frame to the selected features multiple layers. @@ -1291,6 +2899,10 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.Map.FindLayers + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetCamera + // cref: ArcGIS.Core.Data.Feature.GetShape + // cref: ArcGIS.Desktop.Mapping.Camera.Scale #region Change map frame extent to single feature with 15 percent buffer //Change map frame extent to single feature with 10 percent buffer @@ -1336,6 +2948,10 @@ private void TranslatePointInMapFrameToMapView() QueuedTask.Run(() => { var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.BlackRGB, 8); var graphicsLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); + + // cref: ArcGIS.Desktop.Layouts.Element.GetBounds + // cref: ArcGIS.Desktop.Layouts.MapFrame.PageToMap + // cref: ArcGIS.Desktop.Mapping.GraphicsLayerExtensions.AddElement #region Translates a point in page coordinates to a point in map coordinates. //On the QueuedTask var layout = Project.Current.GetItems().FirstOrDefault().GetLayout(); @@ -1344,7 +2960,8 @@ private void TranslatePointInMapFrameToMapView() //Get a point in the center of the Map frame var mapFrameCenterPoint = mapFrame.GetBounds().CenterCoordinate; //Convert to MapPoint - var pointInMapFrame = MapPointBuilder.CreateMapPoint(mapFrameCenterPoint); + //At 2.x - var pointInMapFrame = MapPointBuilder.CreateMapPoint(mapFrameCenterPoint); + var pointInMapFrame = MapPointBuilderEx.CreateMapPoint(mapFrameCenterPoint); //Find the corresponding point in the MapView var pointOnMap = mapFrame.PageToMap(pointInMapFrame); @@ -1359,6 +2976,14 @@ private void TranslatePointInMapFrameToMapView() #endregion }); } + + // cref: ARCGIS.DESKTOP.MAPPING.MAPTOOL.ONTOOLMOUSEDOWN + // cref: ARCGIS.DESKTOP.MAPPING.MAPTOOL.HandleMouseDownAsync + // cref: ARCGIS.DESKTOP.MAPPING.MapViewMouseButtonEventArgs + // cref: ARCGIS.DESKTOP.MAPPING.MapView.ClientToMap + // cref: ArcGIS.Desktop.Layouts.MapFrame.MapToPage + // cref: ArcGIS.Desktop.Layouts.GraphicFactory.CreateSimpleGraphic + // cref: ArcGIS.Desktop.Layouts.ElementFactory.CreateGraphicElement #region Translates a point in map coordinates to a point in page coordinates internal class GetMapCoordinates : MapTool { @@ -1389,21 +3014,34 @@ protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e) Location = pointOnLayoutFrame, Symbol = pointSymbol.MakeSymbolReference() }; - LayoutElementFactory.Instance.CreateGraphicElement(layout, cimGraphicElement); + //Or use GraphicFactory + var cimGraphicElement2 = GraphicFactory.Instance.CreateSimpleGraphic( + pointOnLayoutFrame, pointSymbol); + + //At 2.x - LayoutElementFactory.Instance.CreateGraphicElement(layout, cimGraphicElement); + + ElementFactory.Instance.CreateGraphicElement(layout, cimGraphicElement); + ElementFactory.Instance.CreateGraphicElement(layout, cimGraphicElement2); + }); } } #endregion + #region ProSnippet Group: Layout MapSeries #endregion async public void snippets_MapSeries() { Layout layout = LayoutView.Active.Layout; - // cref: Modify an existing map series;ArcGIS.Desktop.Layouts.MapSeries - // cref: Modify an existing map series;ArcGIS.Desktop.Layouts.SpatialMapSeries + // cref: ArcGIS.Desktop.Layouts.MapSeries + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.SortField + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.SortAscending + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.PageNumberField + // cref: ArcGIS.Desktop.Layouts.Layout.SetMapSeries #region Modify an existing map series //Modify the currently active map series and changes its sort field and page number field. @@ -1420,7 +3058,21 @@ await QueuedTask.Run(() => }); #endregion - // cref: Create a new spatial map series;ArcGIS.Desktop.Layouts.MapSeries.CreateSpatialMapSeries(ArcGIS.Desktop.Layouts.Layout,ArcGIS.Desktop.Layouts.MapFrame,ArcGIS.Desktop.Mapping.BasicFeatureLayer,System.String) + // cref: ArcGIS.Desktop.Layouts.MapSeries.CreateSpatialMapSeries(ArcGIS.Desktop.Layouts.Layout,ArcGIS.Desktop.Layouts.MapFrame,ArcGIS.Desktop.Mapping.BasicFeatureLayer,System.String) + // cref: ArcGIS.Desktop.Layouts.MapFrame + // cref: ArcGIS.Desktop.Layouts.MapSeries + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.SortField + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.SortAscending + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.CategoryField + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.ExtentOptions + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.MarginType + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.MarginUnits + // cref: ArcGIS.Desktop.Layouts.SpatialMapSeries.ScaleRounding + // cref: ArcGIS.Desktop.Layouts.Layout.SetMapSeries + // cref: ArcGIS.Core.CIM.UnitType + // cref: ArcGIS.Core.CIM.ExtentFitType + // cref: ArcGIS.Core.Geometry.LinearUnit #region Create a new spatial map series // This example create a new spatial map series and then applies it to the active layout. This will automatically // overwrite an existing map series if one is already present. @@ -1448,6 +3100,7 @@ await QueuedTask.Run(() => }); #endregion } + #region ProSnippet Group: Layout Export #endregion async public void snippets_StandardExport() @@ -1456,7 +3109,20 @@ async public void snippets_StandardExport() Layout layout = await QueuedTask.Run(() => layoutItem.GetLayout()); String filePath = null; - // cref: Export a layout to PDF;ArcGIS.Desktop.Layouts.Layout.Export(ArcGIS.Desktop.Mapping.ExportFormat) + // cref: ArcGIS.Desktop.Layouts.Layout.Export(ArcGIS.Desktop.Mapping.ExportFormat) + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.DoCompressVectorGraphics + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.DoEmbedFonts + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.HasGeoRefInfo + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.ImageCompression + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.ImageQuality + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.LayersAndAttributes + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.ImageCompression + // cref: ARCGIS.DESKTOP.MAPPING.ImageQuality + // cref: ARCGIS.DESKTOP.MAPPING.LayersAndAttributes #region Export a layout to PDF //Export a single page layout to PDF. @@ -1481,18 +3147,37 @@ async public void snippets_StandardExport() } #endregion - // cref: Export a map frame to JPG;ArcGIS.Desktop.Layouts.MapFrame.Export(ArcGIS.Desktop.Mapping.ExportFormat) + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export(ArcGIS.Desktop.Mapping.ExportFormat) + // cref: ARCGIS.DESKTOP.MAPPING.JPEGFormat + // cref: ARCGIS.DESKTOP.MAPPING.JPEGFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.JPEGFormat.ColorMode + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Height + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Width + // cref: ARCGIS.DESKTOP.MAPPING.JPEGColorMode #region Export a map frame to JPG //Export a map frame to JPG. //Create JPEG format with appropriate settings //BMP, EMF, EPS, GIF, PDF, PNG, SVG, TGA, and TFF formats are also available for export + //at 2.x - JPEGFormat JPG = new JPEGFormat() + //{ + // HasWorldFile = true, + // Resolution = 300, + // OutputFileName = filePath, + // JPEGColorMode = JPEGColorMode.TwentyFourBitTrueColor, + // Height = 800, + // Width = 1200 + //}; JPEGFormat JPG = new JPEGFormat() { HasWorldFile = true, Resolution = 300, OutputFileName = filePath, - JPEGColorMode = JPEGColorMode.TwentyFourBitTrueColor, + ColorMode = JPEGColorMode.TwentyFourBitTrueColor, Height = 800, Width = 1200 }; @@ -1511,7 +3196,17 @@ await QueuedTask.Run(() => }); #endregion - // cref: Export the map view associated with a map frame to BMP;ArcGIS.Desktop.Layouts.MapFrame.GetMapView(ArcGIS.Desktop.Layouts.LayoutView) + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetMapView(ArcGIS.Desktop.Layouts.LayoutView) + // cref: ArcGIS.Desktop.Layouts.MapFrame.Export(ArcGIS.Desktop.Mapping.ExportFormat) + // cref: ARCGIS.DESKTOP.MAPPING.BMPFormat + // cref: ARCGIS.DESKTOP.MAPPING.BMPFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Resolution + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Height + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.Width + // cref: ARCGIS.DESKTOP.MAPPING.MapView.Export #region Export the map view associated with a map frame to BMP //Export the map view associated with a map frame to BMP. @@ -1555,9 +3250,27 @@ async public void snippets_Export() Layout layout = await QueuedTask.Run(() => layoutItem.GetLayout()); String filePath = null; - // cref: Export a map series to single PDF;ArcGIS.Desktop.Layouts.Layout.Export(ArcGIS.Desktop.Mapping.ExportFormat,ArcGIS.Desktop.Layouts.MapSeriesExportOptions) - // cref: Export a map series to single PDF;ArcGIS.Desktop.Layouts.ExportPages - // cref: Export a map series to single PDF;ArcGIS.Desktop.Layouts.MapSeriesExportOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportPages + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.CustomPages + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ShowSelectedSymbology + // cref: ArcGIS.Desktop.Layouts.Layout.Export(ArcGIS.Desktop.Mapping.ExportFormat) + // cref: ArcGIS.Desktop.Layouts.ExportPages + // cref: ArcGIS.Desktop.MAPPING.ExportFileOptions + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.DoCompressVectorGraphics + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.DoEmbedFonts + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.HasGeoRefInfo + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.ImageCompression + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.ImageQuality + // cref: ARCGIS.DESKTOP.MAPPING.PDFFORMAT.LayersAndAttributes + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.ImageCompression + // cref: ARCGIS.DESKTOP.MAPPING.ImageQuality + // cref: ARCGIS.DESKTOP.MAPPING.LayersAndAttributes #region Export a map series to single PDF //Export a map series with multiple pages to a single PDF. @@ -1594,6 +3307,22 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportPages + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ExportFileOptions + // cref: ArcGIS.Desktop.Layouts.MapSeriesExportOptions.ShowSelectedSymbology + // cref: ArcGIS.Desktop.Layouts.Layout.Export(ArcGIS.Desktop.Mapping.ExportFormat) + // cref: ArcGIS.Desktop.Layouts.ExportPages + // cref: ArcGIS.Desktop.MAPPING.ExportFileOptions + // cref: ARCGIS.DESKTOP.MAPPING.TIFFFormat + // cref: ARCGIS.DESKTOP.MAPPING.TIFFFormat.ColorMode + // cref: ARCGIS.DESKTOP.MAPPING.TIFFFormat.ImageCompression + // cref: ARCGIS.DESKTOP.MAPPING.TIFFFormat.HasWorldFile + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.OutputFileName + // cref: ARCGIS.DESKTOP.MAPPING.EXPORTFORMAT.VALIDATEOUTPUTFILEPATH + // cref: ARCGIS.DESKTOP.MAPPING.TIFFColorMode + // cref: ARCGIS.DESKTOP.MAPPING.TIFFImageCompression #region Export a map series to individual TIFF files //Export each page of a map series to an individual TIFF file. @@ -1602,10 +3331,10 @@ await QueuedTask.Run(() => { OutputFileName = filePath, Resolution = 300, - ColorMode = ColorMode.TwentyFourBitTrueColor, + ColorMode = TIFFColorMode.TwentyFourBitTrueColor, HasGeoTiffTags = true, HasWorldFile = true, - TIFFImageCompression = TIFFImageCompression.LZW + ImageCompression = TIFFImageCompression.LZW }; //Set up map series export options @@ -1633,8 +3362,14 @@ await QueuedTask.Run(() => public void LayoutOptions1() { + // cref: ArcGIS.Desktop.Core.ApplicationOptions + // cref: ArcGIS.Desktop.Core.ApplicationOptions.LayoutOptions + // cref: ArcGIS.Desktop.Core.LayoutOptions + // cref: ArcGIS.Desktop.Core.LayoutOptions.KeepLastToolActive + // cref: ArcGIS.Desktop.Core.LayoutOptions.WarnAboutAssociatedSurrounds + // cref: ArcGIS.Desktop.Core.LayoutOptions.LayoutTemplatePath #region Get LayoutOptions - + var lastToolActive = ApplicationOptions.LayoutOptions.KeepLastToolActive; var warnOnSurrounds = ApplicationOptions.LayoutOptions.WarnAboutAssociatedSurrounds; //eg \Resources\LayoutTemplates\en-US @@ -1642,6 +3377,12 @@ public void LayoutOptions1() #endregion + // cref: ArcGIS.Desktop.Core.ApplicationOptions + // cref: ArcGIS.Desktop.Core.ApplicationOptions.LayoutOptions + // cref: ArcGIS.Desktop.Core.LayoutOptions + // cref: ArcGIS.Desktop.Core.LayoutOptions.KeepLastToolActive + // cref: ArcGIS.Desktop.Core.LayoutOptions.WarnAboutAssociatedSurrounds + // cref: ArcGIS.Desktop.Core.LayoutOptions.LayoutTemplatePath #region Set LayoutOptions //keep graphic element insert tool active @@ -1661,6 +3402,10 @@ public void LayoutOptions1() public void TextAndGraphicsElementsOptions() { + // cref: ArcGIS.Desktop.Core.ApplicationOptions + // cref: ArcGIS.Desktop.Core.ApplicationOptions.TextAndGraphicsElementsOptions + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.GetAvailableFonts #region Get All Available Fonts //Note: see also SymbolFactory.Instance.GetAvailableFonts() which returns the @@ -1683,6 +3428,14 @@ public void TextAndGraphicsElementsOptions() #endregion + // cref: ArcGIS.Desktop.Core.ApplicationOptions + // cref: ArcGIS.Desktop.Core.ApplicationOptions.TextAndGraphicsElementsOptions + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.GetDefaultFont + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.GetDefaultPointSymbol + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.GetDefaultLineSymbol + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.GetDefaultPolygonSymbol + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.GetDefaultTextSymbol #region Get TextAndGraphicsElementsOptions QueuedTask.Run(() => @@ -1701,6 +3454,13 @@ public void TextAndGraphicsElementsOptions() #endregion + // cref: ArcGIS.Desktop.Core.ApplicationOptions + // cref: ArcGIS.Desktop.Core.ApplicationOptions.TextAndGraphicsElementsOptions + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.SetDefaultPointSymbol + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.SetDefaultLineSymbol + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.SetDefaultPolygonSymbol + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.SetDefaultTextSymbol #region Set TextAndGraphicsElementsOptions QueuedTask.Run(() => @@ -1730,6 +3490,417 @@ public void TextAndGraphicsElementsOptions() #endregion } + #region ProSnippet Group: MapFrame_Display_Constraints + #endregion + + public void SetAutoCameraNone(string mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.AutoCameraSource + #region SetAutoCameraNone + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.None; + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraFixedExtent(string mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetViewExtent + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Extent + #region SetAutoCameraFixedExtent + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.Fixed; + autoCamera.AutoCameraType = AutoCameraType.Extent; + + var mf_extent = mf.GetViewExtent(); + + var extent = EnvelopeBuilderEx.CreateEnvelope( + 400748.62, 800296.4, 1310669.05, 1424520.74, mf.Map.SpatialReference); + autoCamera.Extent = extent; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraFixedCenter(string mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetViewCenter + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetMapView + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMViewCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.IntersectLayerPath + // cref: ArcGIS.Desktop.Mapping.MapView.Camera + #region SetAutoCameraFixedCenter + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.Fixed; + autoCamera.AutoCameraType = AutoCameraType.Center; + + var camera = mf.GetMapView(LayoutView.Active).Camera; + var center = mf.GetViewCenter(); + + //var extent = EnvelopeBuilderEx.CreateEnvelope( + // 400748.62, 800296.4, 1310669.05, 1424520.74, mf.Map.SpatialReference); + //autoCamera.Extent = extent; + + var camera2 = new CIMViewCamera() + { + Heading = 0, + Pitch = -90, + Roll = 0, + Scale = 21169571, + X = 855708, + Y = 1112409, + Z = double.NaN + }; + autoCamera.Camera = camera2; + var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); + autoCamera.IntersectLayerPath = states.URI; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraFixedCenterAndScale(string mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetViewCenter + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetMapView + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMViewCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.IntersectLayerPath + // cref: ArcGIS.Desktop.Mapping.MapView.Camera + #region SetAutoCameraFixedCenterAndScale + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.Fixed; + autoCamera.AutoCameraType = AutoCameraType.CenterAndScale; + + var camera = mf.GetMapView(LayoutView.Active).Camera; + var center = mf.GetViewCenter(); + + //var extent = EnvelopeBuilderEx.CreateEnvelope( + // 400748.62, 800296.4, 1310669.05, 1424520.74, mf.Map.SpatialReference); + //autoCamera.Extent = extent; + + var camera2 = new CIMViewCamera() + { + Heading = 0, + Pitch = -90, + Roll = 0, + Scale = 21169571, + X = 1310669.0 + ((400748.5 - 1310669.0) / 2.0), + Y = 800296.4 + ((1424520.74 - 800296.4) / 2.0), + Z = double.NaN + }; + autoCamera.Camera = camera2; + var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); + //autoCamera.IntersectLayerPath = states.URI; + + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraFixedScale(string mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetViewCenter + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetMapView + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMViewCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.IntersectLayerPath + // cref: ArcGIS.Desktop.Mapping.MapView.Camera + #region SetAutoCameraFixedScale + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.Fixed; + autoCamera.AutoCameraType = AutoCameraType.Scale; + + var camera = mf.GetMapView(LayoutView.Active).Camera; + var center = mf.GetViewCenter(); + + //var extent = EnvelopeBuilderEx.CreateEnvelope( + // 400748.62, 800296.4, 1310669.05, 1424520.74, mf.Map.SpatialReference); + //autoCamera.Extent = extent; + + var camera2 = new CIMViewCamera() + { + Heading = 0, + Pitch = -90, + Roll = 0, + Scale = 20000571, + X = 1310669.0 + ((400748.5 - 1310669.0) / 2.0), + Y = 800296.4 + ((1424520.74 - 800296.4) / 2.0), + Z = double.NaN + }; + autoCamera.Camera = camera2; + var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); + //autoCamera.IntersectLayerPath = states.URI; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraLinkedExtent(string mapFrame, string mapFrameLink) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.MapFrameLinkName + #region SetAutoCameraLinkedExtent + + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.MapFrameLink; + autoCamera.AutoCameraType = AutoCameraType.Extent; + autoCamera.MapFrameLinkName = mapFrameLink; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraLinkedCenter(string mapFrame, string mapFrameLink) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.MapFrameLinkName + // cref: ArcGIS.Core.CIM.CIMAutoCamera.IntersectLayerPath + #region SetAutoCameraLinkedCenter + + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.MapFrameLink; + autoCamera.AutoCameraType = AutoCameraType.Center; + autoCamera.MapFrameLinkName = mapFrameLink; + var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); + autoCamera.IntersectLayerPath = states.URI; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraLinkedCenterAndScale(string mapFrame, string mapFrameLink) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.MapFrameLinkName + // cref: ArcGIS.Core.CIM.CIMAutoCamera.IntersectLayerPath + #region SetAutoCameraLinkedCenterAndScale + + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.MapFrameLink; + autoCamera.AutoCameraType = AutoCameraType.CenterAndScale; + autoCamera.MapFrameLinkName = mapFrameLink; + var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); + autoCamera.IntersectLayerPath = states.URI; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraLinkedScale(string mapFrame, string mapFrameLink) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.MapFrameLinkName + // cref: ArcGIS.Core.CIM.CIMAutoCamera.IntersectLayerPath + #region SetAutoCameraLinkedScale + + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.MapFrameLink; + autoCamera.AutoCameraType = AutoCameraType.Scale; + autoCamera.MapFrameLinkName = mapFrameLink; + var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); + autoCamera.IntersectLayerPath = states.URI; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraLinkedMapSeriesShape(string mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.IntersectLayerPath + #region SetAutoCameraLinkedMapSeriesShape + + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.MapSeriesLink; + autoCamera.AutoCameraType = AutoCameraType.Extent; + //autoCamera.MapFrameLinkName = mapFrameLink; + var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); + autoCamera.IntersectLayerPath = states.URI; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } + + public void SetAutoCameraLinkedMapSeriesCenter(string mapFrame) + { + // cref: ArcGIS.Desktop.Layouts.MapFrame.GetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.SetAutoCamera + // cref: ArcGIS.Desktop.Layouts.MapFrame.IsMapSeriesMapFrame + // cref: ArcGIS.Desktop.Layouts.MapFrame.ValidateAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Source + // cref: ArcGIS.Core.CIM.CIMAutoCamera.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraType + // cref: ArcGIS.Core.CIM.AutoCameraSource + // cref: ArcGIS.Core.CIM.CIMAutoCamera.Camera + // cref: ArcGIS.Core.CIM.CIMAutoCamera.IntersectLayerPath + #region SetAutoCameraLinkedMapSeriesCenter + + var layout = LayoutView.Active.Layout; + var mf = layout.GetElementsAsFlattenedList().OfType() + .First(mf => mf.Name == mapFrame); + var autoCamera = mf.GetAutoCamera(); + autoCamera.Source = AutoCameraSource.MapSeriesLink; + autoCamera.AutoCameraType = AutoCameraType.Center; + + var states = mf.Map.GetLayersAsFlattenedList().First(l => l.Name == "State_Polygons"); + autoCamera.IntersectLayerPath = states.URI; + + if (mf.ValidateAutoCamera(autoCamera) && + !mf.IsMapSeriesMapFrame()) + mf.SetAutoCamera(autoCamera); + + #endregion + } } } diff --git a/Examples/Layouts/ProSnippetsReports.cs b/Examples/Layouts/ProSnippetsReports.cs index e9a1d15..4728864 100644 --- a/Examples/Layouts/ProSnippetsReports.cs +++ b/Examples/Layouts/ProSnippetsReports.cs @@ -16,233 +16,322 @@ namespace ReportAPITesting { - internal static class ReportHelper + internal static class ReportHelper + { + #region ProSnippet Group: Report Project Items + #endregion + + public static void GetAllReports() { - #region ProSnippet Group: Report Project Items - #endregion + // cref: ArcGIS.Desktop.Reports.ReportProjectItem + #region Gets all the reports in the current project + var projectReports = Project.Current.GetItems(); + foreach (var reportItem in projectReports) + { + //Do Something with the report + } + #endregion + + } + + public static async void GetReport(string reportName) + { + // cref: ArcGIS.Desktop.Reports.ReportProjectItem + // cref: ArcGIS.Desktop.Reports.ReportProjectItem.GetReport + #region Get a specific report + ReportProjectItem reportProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(reportName)); + Report report = reportProjItem?.GetReport(); + #endregion - public static void GetAllReports() - { - #region Gets all the reports in the current project - var projectReports = Project.Current.GetItems(); - foreach (var reportItem in projectReports) - { - //Do Something with the report - } - #endregion - - } - - public static async void GetReport(string reportName) - { - #region Get a specific report - ReportProjectItem reportProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(reportName)); - Report report = reportProjItem?.GetReport(); - #endregion - #region Open a Report project item in a new view - //Open a report project item in a new view. - //A report project item may exist but it may not be open in a view. - - //Reference a report project item by name - ReportProjectItem reportPrjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("MyReport")); - - //Get the report associated with the report project item - Report reportToOpen = await QueuedTask.Run(() => reportPrjItem.GetReport()); - - //Create the new pane - IReportPane iNewReporttPane = await ProApp.Panes.CreateReportPaneAsync(reportToOpen); //GUI thread - #endregion + // cref: ArcGIS.Desktop.Reports.ReportProjectItem + // cref: ArcGIS.Desktop.Reports.ReportProjectItem.GetReport + // cref: ArcGIS.Desktop.Core.ReportFrameworkExtender.CreateReportPaneAsync + #region Open a Report project item in a new view + //Open a report project item in a new view. + //A report project item may exist but it may not be open in a view. + + //Reference a report project item by name + ReportProjectItem reportPrjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals("MyReport")); + + //Get the report associated with the report project item + Report reportToOpen = await QueuedTask.Run(() => reportPrjItem.GetReport()); + + //Create the new pane + IReportPane iNewReporttPane = await ProApp.Panes.CreateReportPaneAsync(reportToOpen); //GUI thread + #endregion } public static void ReportMethods() - { - // cref: Activate an already open report view;ArcGIS.Desktop.Reports.ReportView - #region Activate an already open report view - Report report = Project.Current.GetItems().FirstOrDefault().GetReport(); - var reportPane = FrameworkApplication.Panes.FindReportPanes(report).Last(); - if (reportPane == null) - return; - //Activate the pane - (reportPane as ArcGIS.Desktop.Framework.Contracts.Pane).Activate(); - //Get the "ReportView" associated with the Report Pane. - ReportView reportView = reportPane.ReportView; - #endregion - #region Reference the active report view - //Confirm if the current, active view is a report view. If it is, do something. - ReportView activeReportView = ReportView.Active; - if (activeReportView != null) - { - // do something - } - #endregion - // cref: Refresh the report view;ArcGIS.Desktop.Reports.ReportView.Refresh - #region Refresh the report view - if (reportView == null) - return; - QueuedTask.Run(() => reportView.Refresh()); - #endregion - // cref: Zoom to whole page;ArcGIS.Desktop.Reports.ReportView.ZoomToWholePage - #region Zoom to whole page - QueuedTask.Run(() => reportView.ZoomToWholePage()); + { + // cref: ArcGIS.Desktop.Reports.IReportPane + // cref: ArcGIS.Desktop.Reports.IReportPane.ReportView + // cref: ArcGIS.Desktop.Reports.ReportProjectItem + // cref: ArcGIS.Desktop.Core.ReportFrameworkExtender.FindReportPanes + // cref: ArcGIS.Desktop.Framework.Contracts.Pane.Activate + #region Activate an already open report view + Report report = Project.Current.GetItems().FirstOrDefault().GetReport(); + var reportPane = FrameworkApplication.Panes.FindReportPanes(report).Last(); + if (reportPane == null) + return; + //Activate the pane + (reportPane as ArcGIS.Desktop.Framework.Contracts.Pane).Activate(); + //Get the "ReportView" associated with the Report Pane. + ReportView reportView = reportPane.ReportView; + #endregion + + // cref: ArcGIS.Desktop.Reports.ReportView + // cref: ArcGIS.Desktop.Reports.ReportView.Active + #region Reference the active report view + //Confirm if the current, active view is a report view. If it is, do something. + ReportView activeReportView = ReportView.Active; + if (activeReportView != null) + { + // do something + } + #endregion + + // cref: ArcGIS.Desktop.Reports.ReportView.Refresh + #region Refresh the report view + if (reportView == null) + return; + QueuedTask.Run(() => reportView.Refresh()); + #endregion + // cref: Zoom to whole page;ArcGIS.Desktop.Reports.ReportView.ZoomToWholePage + #region Zoom to whole page + QueuedTask.Run(() => reportView.ZoomToWholePage()); #endregion - // cref: Zoom to specific location on Report view;ArcGIS.Desktop.Reports.ReportView.ZoomTo(ArcGIS.Core.Geometry.Geometry) + + // cref: ArcGIS.Desktop.Reports.ReportDetails + // cref: ArcGIS.Desktop.Reports.ReportSection + // cref: ArcGIS.Desktop.Layouts.Element.GetBounds + // cref: ArcGIS.Desktop.Reports.ReportView.ZoomTo(ArcGIS.Core.Geometry.Geometry) #region Zoom to specific location on Report view - //On the QueuedTask - var detailsSection = report.Elements.OfType().FirstOrDefault().Elements.OfType().FirstOrDefault(); - var bounds = detailsSection.GetBounds(); - ReportView.Active.ZoomTo(bounds); + //On the QueuedTask + var detailsSection = report.Elements.OfType().FirstOrDefault().Elements.OfType().FirstOrDefault(); + var bounds = detailsSection.GetBounds(); + ReportView.Active.ZoomTo(bounds); #endregion // cref: Zoom to page width;ArcGIS.Desktop.Reports.ReportView.ZoomToPageWidth #region Zoom to page width //Process on worker thread - QueuedTask.Run(() => reportView.ZoomToPageWidth()); - #endregion + QueuedTask.Run(() => reportView.ZoomToPageWidth()); + #endregion } #region ProSnippet Group: Create Report #endregion public static async void GenerateReport(FeatureLayer featureLayer) - { - #region Create report - //Note: Call within QueuedTask.Run() - //The fields in the datasource used for the report - //This uses a US Cities dataset - var listFields = new List { + { + // cref: ArcGIS.Core.CIM.CIMReportField + // cref: ArcGIS.Core.CIM.CIMTableField + // cref: ArcGIS.Core.CIM.CIMTableField.Name + // cref: ArcGIS.Core.CIM.CIMTableField.FieldOrder + // cref: ArcGIS.Core.CIM.CIMTableField.Group + // cref: ArcGIS.Core.CIM.CIMTableField.SortInfo + // cref: ArcGIS.Core.CIM.FieldSortInfo + // cref: ArcGIS.Desktop.Reports.ReportDataSource + // cref: ArcGIS.Core.CIM.CIMPage + // cref: ArcGIS.Core.CIM.CIMPage.Height + // cref: ArcGIS.Core.CIM.CIMPage.StretchElements + // cref: ArcGIS.Core.CIM.CIMPage.Width + // cref: ArcGIS.Core.CIM.CIMPage.ShowRulers + // cref: ArcGIS.Core.CIM.CIMPage.ShowGuides + // cref: ArcGIS.Core.CIM.CIMPage.Margin + // cref: ArcGIS.Core.CIM.CIMPage.Units + // cref: ArcGIS.Core.CIM.CIMMargin + // cref: ArcGIS.Core.CIM.CIMMargin.Bottom + // cref: ArcGIS.Core.CIM.CIMMargin.Left + // cref: ArcGIS.Core.CIM.CIMMargin.Right + // cref: ArcGIS.Core.CIM.CIMMargin.Top + // cref: ArcGIS.Core.Geometry.LinearUnit + // cref: ArcGIS.Desktop.Reports.ReportTemplateManager + // cref: ArcGIS.Desktop.Reports.ReportTemplateManager.GetTemplatesAsync + // cref: ArcGIS.Desktop.Reports.ReportStylingManager + // cref: ArcGIS.Desktop.Reports.ReportStylingManager.GetStylingsAsync + // cref: ArcGIS.Desktop.Reports.ReportTemplate + // cref: ArcGIS.Desktop.Reports.ReportTemplate.Name + // cref: ArcGIS.Desktop.Reports.ReportFieldStatistic + // cref: ArcGIS.Desktop.Reports.ReportFieldStatistic.Field + // cref: ArcGIS.Desktop.Reports.ReportFieldStatistic.Statistic + // cref: ArcGIS.Core.CIM.FieldStatisticsFlag + // cref: ArcGIS.Desktop.Reports.ReportFactory + // cref: ArcGIS.Desktop.Reports.ReportFactory.CreateReport + #region Create report + //Note: Call within QueuedTask.Run() + //The fields in the datasource used for the report + //This uses a US Cities dataset + var listFields = new List { //Grouping should be the first field new CIMReportField{Name = "STATE_NAME", FieldOrder = 0, Group = true, SortInfo = FieldSortInfo.Desc}, //Group cities using STATES new CIMReportField{Name = "CITY_NAME", FieldOrder = 1}, new CIMReportField{Name = "POP1990", FieldOrder = 2, }, }; - //Definition query to use for the data source - var defQuery = "STATE_NAME LIKE 'C%'"; - //Define the Datasource - //pass true to use the selection set - var reportDataSource = new ReportDataSource(featureLayer, defQuery, false, listFields); - //The CIMPage defintion - page size, units, etc - var cimReportPage = new CIMPage - { - Height = 11, - StretchElements = false, - Width = 6.5, - ShowRulers = true, - ShowGuides = true, - Margin = new CIMMargin { Bottom = 1, Left = 1, Right = 1, Top = 1 }, - Units = LinearUnit.Inches - }; + //Definition query to use for the data source + var defQuery = "STATE_NAME LIKE 'C%'"; + //Define the Datasource + //pass true to use the selection set + var reportDataSource = new ReportDataSource(featureLayer, defQuery, false, listFields); + //The CIMPage defintion - page size, units, etc + var cimReportPage = new CIMPage + { + Height = 11, + StretchElements = false, + Width = 6.5, + ShowRulers = true, + ShowGuides = true, + Margin = new CIMMargin { Bottom = 1, Left = 1, Right = 1, Top = 1 }, + Units = LinearUnit.Inches + }; - //Report template - var reportTemplates = await ReportTemplateManager.GetTemplatesAsync(); - var reportTemplate = reportTemplates.Where(r => r.Name == "Attribute List with Grouping").First(); + //Report template + var reportTemplates = await ReportTemplateManager.GetTemplatesAsync(); + var reportTemplate = reportTemplates.Where(r => r.Name == "Attribute List with Grouping").First(); - //Report Styling - var reportStyles = await ReportStylingManager.GetStylingsAsync(); - var reportStyle = reportStyles.Where(s => s == "Cool Tones").First(); + //Report Styling + var reportStyles = await ReportStylingManager.GetStylingsAsync(); + var reportStyle = reportStyles.Where(s => s == "Cool Tones").First(); - //Field Statistics - var fieldStatisticsList = new List { + //Field Statistics + var fieldStatisticsList = new List { new ReportFieldStatistic{ Field = "POP1990", Statistic = FieldStatisticsFlag.Sum} //Note: NoStatistics option for FieldStatisticsFlag is not supported. }; - var report = ReportFactory.Instance.CreateReport("USAReport", reportDataSource, cimReportPage, fieldStatisticsList, reportTemplate, reportStyle); - #endregion - - } - public static void ExportAReport(Report report, string path, bool useSelection = true) - { - if (report == null) return; - #region Export report to pdf - //Note: Call within QueuedTask.Run() - //Define Export Options - var exportOptions = new ReportExportOptions - { - ExportPageOption = ExportPageOptions.ExportAllPages, - TotalPageNumberOverride = 0 + var report = ReportFactory.Instance.CreateReport("USAReport", reportDataSource, cimReportPage, fieldStatisticsList, reportTemplate, reportStyle); + #endregion - }; - //Create PDF format with appropriate settings - PDFFormat pdfFormat = new PDFFormat(); - pdfFormat.Resolution = 300; - pdfFormat.OutputFileName = path; - report.ExportToPDF($"{report.Name}", pdfFormat, exportOptions, useSelection); - #endregion - } - - public static void ImportAReport(string reportFile) - { - #region Import a report file - //Note: Call within QueuedTask.Run() - Item reportToImport = ItemFactory.Instance.Create(reportFile); - Project.Current.AddItem(reportToImport as IProjectItem); - #endregion - - } - - public static Task DeleteReport(string reportName) - { - #region Delete a report - //Note: Call within QueuedTask.Run() - //Reference a reportitem in a project by name - ReportProjectItem reportItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(reportName)); - - //Check for report item - if (reportItem == null) - return Task.FromResult(false); - - //Delete the report from the project - return Task.FromResult(Project.Current.RemoveItem(reportItem)); - #endregion - } - #region ProSnippet Group: Modify Reports - #endregion - public static void ModifyReport(Report report, string reportName, FeatureLayer featureLayer) - { - - #region Rename Report - //Note: Call within QueuedTask.Run() - ReportProjectItem reportProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(reportName)); - reportProjItem.GetReport().SetName("RenamedReport"); - #endregion - - #region Modify the Report datasource - //Note: Call within QueuedTask.Run() - //Remove Groups - // The fields in the datasource used for the report - var listFields = new List { + } + public static void ExportAReport(Report report, string path, bool useSelection = true) + { + if (report == null) return; + + // cref: ArcGIS.Desktop.Reports.ReportExportOptions + // cref: ArcGIS.Desktop.Reports.ReportExportOptions.ExportPageOption + // cref: ArcGIS.Desktop.Reports.ReportExportOptions.TotalPageNumberOverride + // cref: ArcGIS.Desktop.Mapping.ExportPageOptions + // cref: ArcGIS.Desktop.Mapping.PDFFormat + // cref: ArcGIS.Desktop.Mapping.ExportFormat.Resolution + // cref: ArcGIS.Desktop.Mapping.ExportFormat.OutputFileName + // cref: ArcGIS.Desktop.Reports.Report.ExportToPDF + #region Export report to pdf + //Note: Call within QueuedTask.Run() + //Define Export Options + var exportOptions = new ReportExportOptions + { + ExportPageOption = ExportPageOptions.ExportAllPages, + TotalPageNumberOverride = 0 + + }; + //Create PDF format with appropriate settings + PDFFormat pdfFormat = new PDFFormat(); + pdfFormat.Resolution = 300; + pdfFormat.OutputFileName = path; + report.ExportToPDF($"{report.Name}", pdfFormat, exportOptions, useSelection); + #endregion + } + + public static void ImportAReport(string reportFile) + { + // cref: ArcGIS.Desktop.Core.ItemFactory + // cref: ArcGIS.Desktop.Core.ItemFactory.Create + // cref: ArcGIS.Desktop.Core.IProjectItem + #region Import a report file + //Note: Call within QueuedTask.Run() + Item reportToImport = ItemFactory.Instance.Create(reportFile); + Project.Current.AddItem(reportToImport as IProjectItem); + #endregion + + } + + public static Task DeleteReport(string reportName) + { + // cref: ArcGIS.Desktop.Reports.ReportProjectItem + // cref: ArcGIS.Desktop.Core.Project.GetItems + // cref: ArcGIS.Desktop.Core.Project.RemoveItem + #region Delete a report + //Note: Call within QueuedTask.Run() + //Reference a reportitem in a project by name + ReportProjectItem reportItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(reportName)); + + //Check for report item + if (reportItem == null) + return Task.FromResult(false); + + //Delete the report from the project + return Task.FromResult(Project.Current.RemoveItem(reportItem)); + #endregion + } + #region ProSnippet Group: Modify Reports + #endregion + public static void ModifyReport(Report report, string reportName, FeatureLayer featureLayer) + { + // cref: ArcGIS.Desktop.Reports.Report.SetName + #region Rename Report + //Note: Call within QueuedTask.Run() + ReportProjectItem reportProjItem = Project.Current.GetItems().FirstOrDefault(item => item.Name.Equals(reportName)); + reportProjItem.GetReport().SetName("RenamedReport"); + #endregion + + // cref: ArcGIS.Desktop.Reports.Report.RemoveGroups + // cref: ArcGIS.Desktop.Reports.Report.AddGroup + // cref: ArcGIS.Desktop.Reports.Report.SetDefinitionQuery + // cref: ArcGIS.Desktop.Reports.Report.RemoveGroups + #region Modify the Report DefinitionQuery + //Note: Call within QueuedTask.Run() + //Remove Groups + // The fields in the datasource used for the report + var listFields = new List { "STATE_NAME" }; - report.RemoveGroups(listFields); - - //Add Group - report.AddGroup("STATE_NAME", true, true, ""); - - //Modify the Definition Query - var defQuery = "STATE_NAME LIKE 'C%'"; - report.SetDefinitionQuery(defQuery); - #endregion - - #region Modify the report Page - //Note: Call within QueuedTask.Run() - var cimReportPage = new CIMPage - { - Height = 12, - StretchElements = false, - Width = 6.5, - ShowRulers = true, - ShowGuides = true, - Margin = new CIMMargin { Bottom = 1, Left = 1, Right = 1, Top = 1 }, - Units = LinearUnit.Inches - }; - report.SetPage(cimReportPage); - //Change only the report's page height - report.SetPageHeight(12); - #endregion + report.RemoveGroups(listFields); - } + //Add Group + report.AddGroup("STATE_NAME", true, true, ""); + + //Modify the Definition Query + var defQuery = "STATE_NAME LIKE 'C%'"; + report.SetDefinitionQuery(defQuery); + #endregion + + // cref: ArcGIS.Desktop.Reports.Report.SetPage + // cref: ArcGIS.Desktop.Reports.Report.SetPageHeight + // cref: ArcGIS.Core.CIM.CIMPage + // cref: ArcGIS.Core.CIM.CIMPage.Height + // cref: ArcGIS.Core.CIM.CIMPage.StretchElements + // cref: ArcGIS.Core.CIM.CIMPage.Width + // cref: ArcGIS.Core.CIM.CIMPage.ShowRulers + // cref: ArcGIS.Core.CIM.CIMPage.ShowGuides + // cref: ArcGIS.Core.CIM.CIMPage.Margin + // cref: ArcGIS.Core.CIM.CIMPage.Units + // cref: ArcGIS.Core.CIM.CIMMargin + // cref: ArcGIS.Core.CIM.CIMMargin.Bottom + // cref: ArcGIS.Core.CIM.CIMMargin.Left + // cref: ArcGIS.Core.CIM.CIMMargin.Right + // cref: ArcGIS.Core.CIM.CIMMargin.Top + #region Modify the report Page + //Note: Call within QueuedTask.Run() + var cimReportPage = new CIMPage + { + Height = 12, + StretchElements = false, + Width = 6.5, + ShowRulers = true, + ShowGuides = true, + Margin = new CIMMargin { Bottom = 1, Left = 1, Right = 1, Top = 1 }, + Units = LinearUnit.Inches + }; + report.SetPage(cimReportPage); + //Change only the report's page height + report.SetPageHeight(12); + #endregion + + } public static void AddSubReport() { - QueuedTask.Run(() => { + QueuedTask.Run(() => + { + // cref: ArcGIS.Desktop.Reports.Report.AddSubReport #region Add SubReport //Note: Call within QueuedTask.Run() var mainReport = Project.Current.GetItems().FirstOrDefault(r => r.Name == "USAReports")?.GetReport(); @@ -256,46 +345,57 @@ public static void AddSubReport() #endregion }); } - #region ProSnippet Group: Report Design - #endregion + #region ProSnippet Group: Report Design + #endregion + + public static async Task GetReportTemplates(string reportTemplateName) + { + // cref: ArcGIS.Desktop.Reports.ReportTemplateManager + // cref: ArcGIS.Desktop.Reports.ReportTemplateManager.GetTemplatesAsync + // cref: ArcGIS.Desktop.Reports.ReportTemplate.Name + #region Get a report template + //Report Template Styles: + //Attribute List + //Attribute List with Grouping + //Basic Summary + //Basic Summary with Grouping + //Page Per Feature + var reportTemplates = await ReportTemplateManager.GetTemplatesAsync(); + var reportTemplate = reportTemplates.Where(r => r.Name == reportTemplateName).First(); + #endregion - public static async Task GetReportTemplates(string reportTemplateName) - { - #region Get a report template - //Report Template Styles: - //Attribute List - //Attribute List with Grouping - //Basic Summary - //Basic Summary with Grouping - //Page Per Feature - var reportTemplates = await ReportTemplateManager.GetTemplatesAsync(); - var reportTemplate = reportTemplates.Where(r => r.Name == reportTemplateName).First(); - #endregion - - System.Diagnostics.Debug.WriteLine(reportTemplate.Name); - return reportTemplate; - - } - - public static async Task GetReportStyling(string reportStyleName) - { - #region Get a report styling - //Report Styling: - //Black and White - //Cool Tones - //Warm Tones - var reportStyles = await ReportStylingManager.GetStylingsAsync(); - var reportStyle = reportStyles.Where(s => s == reportStyleName).First(); - #endregion - System.Diagnostics.Debug.WriteLine(reportStyle.ToString()); - - return reportStyle; - } + System.Diagnostics.Debug.WriteLine(reportTemplate.Name); + return reportTemplate; + + } + + public static async Task GetReportStyling(string reportStyleName) + { + // cref: ArcGIS.Desktop.Reports.ReportStylingManager + // cref: ArcGIS.Desktop.Reports.ReportStylingManager.GetStylingsAsync + #region Get a report styling + //Report Styling: + //Black and White + //Cool Tones + //Warm Tones + var reportStyles = await ReportStylingManager.GetStylingsAsync(); + var reportStyle = reportStyles.Where(s => s == reportStyleName).First(); + #endregion + System.Diagnostics.Debug.WriteLine(reportStyle.ToString()); + + return reportStyle; + } #region ProSnippet Group: Report Elements #endregion public static void ElementFactory(Report report, ReportView reportView) { + // cref: ArcGIS.Desktop.Reports.ReportSection + // cref: ArcGIS.Desktop.Reports.ReportHeader + // cref: ArcGIS.Desktop.Reports.ReportPageHeader + // cref: ArcGIS.Desktop.Reports.ReportDetails + // cref: ArcGIS.Desktop.Reports.ReportPageFooter + // cref: ArcGIS.Desktop.Reports.ReportFooter #region Get various Report sections //Get the "ReportSection element" //ReportSectionElement contains the ReportHeader, ReportPageHeader, ReportDetails. ReportPageFooter, ReportFooter sections. @@ -317,51 +417,69 @@ public static void ElementFactory(Report report, ReportView reportView) var reportFooter = mainReportSection?.Elements.OfType().FirstOrDefault(); #endregion - // cref: Select elements;ArcGIS.Desktop.Reports.ReportView.SelectElements(System.Collections.Generic.IReadOnlyList{ArcGIS.Desktop.Layouts.Element}) + // cref: ArcGIS.Desktop.Reports.ReportDetails + // cref: ArcGIS.Desktop.Layouts.GroupElement.Elements + // cref: ArcGIS.Desktop.Reports.ReportView.SelectElements(System.Collections.Generic.IReadOnlyList{ArcGIS.Desktop.Layouts.Element}) #region Select elements //ReportDetailsSection contains the "Fields" - var elements = reportDetailsSection.GetElementsAsFlattenedList(); + + var elements = reportDetailsSection.Elements; reportDetailsSection.SelectElements(elements); #endregion - // cref: Select all elements;ArcGIS.Desktop.Reports.ReportView.SelectAllElements + // cref: ArcGIS.Desktop.Reports.ReportPageFooter + // cref: ArcGIS.Desktop.Reports.ReportSectionElement.SelectAllElements #region Select all elements //Select all elements in the Report Footer. ReportPageFooter pageFooterSection = report.Elements.OfType().FirstOrDefault().Elements.OfType().FirstOrDefault(); pageFooterSection.SelectAllElements(); #endregion - // cref: Get selected elements;ArcGIS.Desktop.Reports.ReportView.GetSelectedElements + // cref: ArcGIS.Desktop.Reports.ReportView.GetSelectedElements + // cref: ArcGIS.Desktop.Reports.Report.GetSelectedElements #region Get selected elements IReadOnlyList selectedElements = report.GetSelectedElements(); //Can also use the active ReportView IReadOnlyList selectedElementsFromView = ReportView.Active.GetSelectedElements(); #endregion - // cref: Zoom to selected elements;ArcGIS.Desktop.Reports.ReportView.ZoomToSelectedElements + // cref: ArcGIS.Desktop.Reports.ReportView.ZoomToSelectedElements #region Zoom to selected elements QueuedTask.Run(() => reportView.ZoomToSelectedElements()); #endregion Zoom to selected elements - // cref: Clear element selection;ArcGIS.Desktop.Reports.ReportView.ClearElementSelection + // cref: ArcGIS.Desktop.Reports.ReportView.ClearElementSelection #region Clear element selection reportView.ClearElementSelection(); #endregion + // cref: ArcGIS.Desktop.Reports.Report.FindElements #region Find specific elements in the report based on their Name. var reportElementsToFind = new List { "ReportText1", "ReportText2" }; var textReportElements = report.FindElements(reportElementsToFind); #endregion + // cref: ArcGIS.Desktop.Reports.Report.DeleteElements #region Delete Elements - report.DeleteElements(textReportElements); + + QueuedTask.Run(() => report.DeleteElements(textReportElements)); #endregion } private static void CreateField(Report report) { + // cref: ArcGIS.Desktop.Reports.ReportSection + // cref: ArcGIS.Desktop.Reports.ReportDetails + // cref: ArcGIS.Desktop.Layouts.GroupElement.Elements + // cref: ArcGIS.Core.CIM.CIMReportField + // cref: ArcGIS.Core.CIM.CIMTableField.Name + // cref: ArcGIS.Core.CIM.CIMTableField.FieldOrder + // cref: ArcGIS.Desktop.Layouts.GraphicElement.GetGraphic + // cref: ArcGIS.Core.CIM.CIMParagraphTextGraphic + // cref: ArcGIS.Desktop.Layouts.Element.GetBounds + // cref: ArcGIS.Desktop.Reports.ReportElementFactory.CreateFieldValueTextElement #region Create a new field in the report - //This is the gap between two fields. + //This is the gap between two fields double fieldIncrement = 0.9388875113593206276389; //On the QueuedTask //New field to add. @@ -396,9 +514,14 @@ private static void CreateField(Report report) var xMaxOfFieldEnvelope = graphicBounds.XMax; var YMaxOfFieldEnvelope = graphicBounds.YMax; //create the new Envelope to be offset from the existing field - MapPoint newMinPoint = MapPointBuilder.CreateMapPoint(xMinOfFieldEnvelope + fieldIncrement, yMinOfFieldEnvelope); - MapPoint newMaxPoint = MapPointBuilder.CreateMapPoint(xMaxOfFieldEnvelope + fieldIncrement, YMaxOfFieldEnvelope); - Envelope newFieldEnvelope = EnvelopeBuilder.CreateEnvelope(newMinPoint, newMaxPoint); + //At 2.x + //MapPoint newMinPoint = MapPointBuilder.CreateMapPoint(xMinOfFieldEnvelope + fieldIncrement, yMinOfFieldEnvelope); + //MapPoint newMaxPoint = MapPointBuilder.CreateMapPoint(xMaxOfFieldEnvelope + fieldIncrement, YMaxOfFieldEnvelope); + //Envelope newFieldEnvelope = EnvelopeBuilder.CreateEnvelope(newMinPoint, newMaxPoint); + + MapPoint newMinPoint = MapPointBuilderEx.CreateMapPoint(xMinOfFieldEnvelope + fieldIncrement, yMinOfFieldEnvelope); + MapPoint newMaxPoint = MapPointBuilderEx.CreateMapPoint(xMaxOfFieldEnvelope + fieldIncrement, YMaxOfFieldEnvelope); + Envelope newFieldEnvelope = EnvelopeBuilderEx.CreateEnvelope(newMinPoint, newMaxPoint); //Create field GraphicElement fieldGraphic = ReportElementFactory.Instance.CreateFieldValueTextElement(reportDetailsSection, newFieldEnvelope, newReportField); diff --git a/Examples/Layouts/TextElementClass.cs b/Examples/Layouts/TextElementClass.cs index 2b78351..f4cc741 100644 --- a/Examples/Layouts/TextElementClass.cs +++ b/Examples/Layouts/TextElementClass.cs @@ -31,29 +31,19 @@ limitations under the License. namespace Layout_HelpExamples { - internal class TextElementClass : Button - { - protected override void OnClick() - { - TextElementClassExamples.MethodSnippets(); - } - } public class TextElementClassExamples { - public static void MethodSnippets() - { - #region TextElement_SetTextProperties - //see Prosnippets.cs: "Update text element properties" - #endregion - - #region TextProperties_Constuctor - //see Prosnippets.cs: "Update text element properties" - #endregion - } async public static void TextPropertiesExample() { + // cref: ArcGIS.Desktop.Layouts.TextElement + // cref: ArcGIS.Desktop.Layouts.TextElement.SetTextProperties + // cref: ArcGIS.Desktop.Layouts.TextElement.TextProperties + // cref: ArcGIS.Desktop.Layouts.TextProperties + // cref: ArcGIS.Desktop.Layouts.TextProperties.Font + // cref: ArcGIS.Desktop.Layouts.TextProperties.FontSize + // cref: ArcGIS.Desktop.Layouts.TextProperties.Text #region Modify existing text element properties //Modify the text properties for an existing text element. @@ -85,7 +75,13 @@ await QueuedTask.Run(() => } async public static void TextPropertiesExample2() //TODO fis duplicated item above because of inconsistent region name use in TextElement.cs file in layout solution. { - // cref: Modify existing text properties;ArcGIS.Desktop.Layouts.TextProperties + // cref: ArcGIS.Desktop.Layouts.TextElement + // cref: ArcGIS.Desktop.Layouts.TextElement.SetTextProperties + // cref: ArcGIS.Desktop.Layouts.TextElement.TextProperties + // cref: ArcGIS.Desktop.Layouts.TextProperties + // cref: ArcGIS.Desktop.Layouts.TextProperties.Font + // cref: ArcGIS.Desktop.Layouts.TextProperties.FontSize + // cref: ArcGIS.Desktop.Layouts.TextProperties.Text #region Modify existing text properties //Modify the text properties for an existing text element. diff --git a/Examples/MapAuthoring.csproj b/Examples/MapAuthoring.csproj deleted file mode 100644 index 415eb75..0000000 --- a/Examples/MapAuthoring.csproj +++ /dev/null @@ -1,203 +0,0 @@ - - - - - Debug - AnyCPU - {14FC59C8-005F-E96C-A9E4-21239526B5EF} - Library - Properties - MapAuthoring - MapAuthoring - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\MapAuthoring\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\MapAuthoring\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Examples/MapAuthoring/CartoFeatures/Carto_SDK_Examples.cs b/Examples/MapAuthoring/CartoFeatures/Carto_SDK_Examples.cs index f94b011..43abb53 100644 --- a/Examples/MapAuthoring/CartoFeatures/Carto_SDK_Examples.cs +++ b/Examples/MapAuthoring/CartoFeatures/Carto_SDK_Examples.cs @@ -1,122 +1,133 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using ArcGIS.Core.CIM; -using ArcGIS.Desktop.Framework.Threading.Tasks; -using ArcGIS.Desktop.Mapping; -using System.Threading.Tasks; - -namespace Carto_SDK_Examples -{ - class Carto_SDK_Examples - { - public async void Examples() - { - // cref: Get symbol from SymbolStyleItem;ArcGIS.Desktop.Mapping.SymbolStyleItem.Symbol - #region Get symbol from SymbolStyleItem - SymbolStyleItem symbolItem = null; - CIMSymbol symbol = await QueuedTask.Run(() => - { - return symbolItem.Symbol; - }); - #endregion - - // cref: Get color from ColorStyleItem;ArcGIS.Desktop.Mapping.ColorStyleItem.Color - #region Get color from ColorStyleItem - ColorStyleItem colorItem = null; - CIMColor color = await QueuedTask.Run(() => - { - return colorItem.Color; - }); - #endregion - - // cref: Get color ramp from ColorRampStyleItem;ArcGIS.Desktop.Mapping.ColorRampStyleItem.ColorRamp - #region Get color ramp from ColorRampStyleItem - ColorRampStyleItem colorRampItem = null; - CIMColorRamp colorRamp = await QueuedTask.Run(() => - { - return colorRampItem.ColorRamp; - }); - #endregion - - // cref: Get north arrow from NorthArrowStyleItem;ArcGIS.Desktop.Mapping.NorthArrowStyleItem.NorthArrow - #region Get north arrow from NorthArrowStyleItem - NorthArrowStyleItem northArrowItem = null; - CIMNorthArrow northArrow = await QueuedTask.Run(() => - { - return northArrowItem.NorthArrow; - }); - #endregion - - // cref: Get scale bar from ScaleBarStyleItem;ArcGIS.Desktop.Mapping.ScaleBarStyleItem.ScaleBar - #region Get scale bar from ScaleBarStyleItem - ScaleBarStyleItem scaleBarItem = null; - CIMScaleBar scaleBar = await QueuedTask.Run(() => - { - return scaleBarItem.ScaleBar; - }); - #endregion - - // cref: Get label placement from LabelPlacementStyleItem;ArcGIS.Desktop.Mapping.LabelPlacementStyleItem.LabelPlacement - #region Get label placement from LabelPlacementStyleItem - LabelPlacementStyleItem labelPlacementItem = null; - CIMLabelPlacementProperties labelPlacement = await QueuedTask.Run(() => - { - return labelPlacementItem.LabelPlacement; - }); - #endregion - - // cref: Get grid from GridStyleItem;ArcGIS.Desktop.Mapping.GridStyleItem.Grid - #region Get grid from GridStyleItem - GridStyleItem gridItem = null; - CIMMapGrid grid = await QueuedTask.Run(() => - { - return gridItem.Grid; - }); - #endregion - - // cref: Get legend from LegendStyleItem;ArcGIS.Desktop.Mapping.LegendStyleItem.Legend - #region Get legend from LegendStyleItem - LegendStyleItem legendStyleItem = null; - CIMLegend legend = await QueuedTask.Run(() => - { - return legendStyleItem.Legend; +/* + + Copyright 2018 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using ArcGIS.Core.CIM; +using ArcGIS.Desktop.Framework.Threading.Tasks; +using ArcGIS.Desktop.Mapping; +using System.Threading.Tasks; + +namespace Carto_SDK_Examples +{ + class Carto_SDK_Examples + { + public async void Examples() + { + // cref: Get symbol from SymbolStyleItem;ArcGIS.Desktop.Mapping.SymbolStyleItem.Symbol + // cref: Get symbol from SymbolStyleItem;ArcGIS.Desktop.Mapping.SymbolStyleItem.Symbol + #region Get symbol from SymbolStyleItem + SymbolStyleItem symbolItem = null; + CIMSymbol symbol = await QueuedTask.Run(() => + { + return symbolItem.Symbol; + }); + #endregion + + // cref: Get color from ColorStyleItem;ArcGIS.Desktop.Mapping.ColorStyleItem.Color + // cref: Get color from ColorStyleItem;ArcGIS.Desktop.Mapping.ColorStyleItem.Color + #region Get color from ColorStyleItem + ColorStyleItem colorItem = null; + CIMColor color = await QueuedTask.Run(() => + { + return colorItem.Color; + }); + #endregion + + // cref: Get color ramp from ColorRampStyleItem;ArcGIS.Desktop.Mapping.ColorRampStyleItem.ColorRamp + // cref: Get color ramp from ColorRampStyleItem;ArcGIS.Desktop.Mapping.ColorRampStyleItem.ColorRamp + #region Get color ramp from ColorRampStyleItem + ColorRampStyleItem colorRampItem = null; + CIMColorRamp colorRamp = await QueuedTask.Run(() => + { + return colorRampItem.ColorRamp; + }); + #endregion + + // cref: Get north arrow from NorthArrowStyleItem;ArcGIS.Desktop.Mapping.NorthArrowStyleItem.NorthArrow + // cref: Get north arrow from NorthArrowStyleItem;ArcGIS.Desktop.Mapping.NorthArrowStyleItem.NorthArrow + #region Get north arrow from NorthArrowStyleItem + NorthArrowStyleItem northArrowItem = null; + CIMNorthArrow northArrow = await QueuedTask.Run(() => + { + return northArrowItem.NorthArrow; + }); + #endregion + + // cref: Get scale bar from ScaleBarStyleItem;ArcGIS.Desktop.Mapping.ScaleBarStyleItem.ScaleBar + // cref: Get scale bar from ScaleBarStyleItem;ArcGIS.Desktop.Mapping.ScaleBarStyleItem.ScaleBar + #region Get scale bar from ScaleBarStyleItem + ScaleBarStyleItem scaleBarItem = null; + CIMScaleBar scaleBar = await QueuedTask.Run(() => + { + return scaleBarItem.ScaleBar; + }); + #endregion + + // cref: Get label placement from LabelPlacementStyleItem;ArcGIS.Desktop.Mapping.LabelPlacementStyleItem.LabelPlacement + // cref: Get label placement from LabelPlacementStyleItem;ArcGIS.Desktop.Mapping.LabelPlacementStyleItem.LabelPlacement + #region Get label placement from LabelPlacementStyleItem + LabelPlacementStyleItem labelPlacementItem = null; + CIMLabelPlacementProperties labelPlacement = await QueuedTask.Run(() => + { + return labelPlacementItem.LabelPlacement; + }); + #endregion + + // cref: Get grid from GridStyleItem;ArcGIS.Desktop.Mapping.GridStyleItem.Grid + // cref: Get grid from GridStyleItem;ArcGIS.Desktop.Mapping.GridStyleItem.Grid + #region Get grid from GridStyleItem + GridStyleItem gridItem = null; + CIMMapGrid grid = await QueuedTask.Run(() => + { + return gridItem.Grid; }); - #endregion + #endregion + // cref: Get legend from LegendStyleItem;ArcGIS.Desktop.Mapping.LegendStyleItem.Legend + // cref: Get legend from LegendStyleItem;ArcGIS.Desktop.Mapping.LegendStyleItem.Legend + #region Get legend from LegendStyleItem + LegendStyleItem legendStyleItem = null; + CIMLegend legend = await QueuedTask.Run(() => + { + return legendStyleItem.Legend; + }); + #endregion + + // cref: Get legend item from LegendItemStyleItem;ArcGIS.Desktop.Mapping.LegendItemStyleItem.LegendItem // cref: Get legend item from LegendItemStyleItem;ArcGIS.Desktop.Mapping.LegendItemStyleItem.LegendItem - #region Get legend item from LegendItemStyleItem - LegendItemStyleItem legendItemStyleItem = null; - CIMLegendItem legendItem = await QueuedTask.Run(() => - { - return legendItemStyleItem.LegendItem; - }); - #endregion - - // cref: Get table frame from TableFrameStyleItem;ArcGIS.Desktop.Mapping.TableFrameStyleItem.TableFrame - #region Get table frame from TableFrameStyleItem - TableFrameStyleItem tableFrameItem = null; - CIMTableFrame tableFrame = await QueuedTask.Run(() => - { - return tableFrameItem.TableFrame; + #region Get legend item from LegendItemStyleItem + LegendItemStyleItem legendItemStyleItem = null; + CIMLegendItem legendItem = await QueuedTask.Run(() => + { + return legendItemStyleItem.LegendItem; }); - #endregion + #endregion + // cref: Get table frame from TableFrameStyleItem;ArcGIS.Desktop.Mapping.TableFrameStyleItem.TableFrame + // cref: Get table frame from TableFrameStyleItem;ArcGIS.Desktop.Mapping.TableFrameStyleItem.TableFrame + #region Get table frame from TableFrameStyleItem + TableFrameStyleItem tableFrameItem = null; + CIMTableFrame tableFrame = await QueuedTask.Run(() => + { + return tableFrameItem.TableFrame; + }); + #endregion + + // cref: Get table frame field from TableFrameFieldStyleItem;ArcGIS.Desktop.Mapping.TableFrameFieldStyleItem.TableFrameField // cref: Get table frame field from TableFrameFieldStyleItem;ArcGIS.Desktop.Mapping.TableFrameFieldStyleItem.TableFrameField #region Get table frame field from TableFrameFieldStyleItem TableFrameFieldStyleItem tableFrameFieldItem = null; @@ -124,57 +135,60 @@ public async void Examples() { return tableFrameFieldItem.TableFrameField; }); - #endregion - - // cref: Get map surround from MapSurroundStyleItem;ArcGIS.Desktop.Mapping.MapSurroundStyleItem.MapSurround - #region Get map surround from MapSurroundStyleItem - MapSurroundStyleItem mapSurroundItem = null; - CIMMapSurround mapSurround = await QueuedTask.Run(() => - { - return mapSurroundItem.MapSurround; - }); - #endregion - - // cref: Get dimension style from DimensionStyleStyleItem;ArcGIS.Desktop.Mapping.DimensionStyleStyleItem.DimensionStyle - #region Get dimension style from DimensionStyleStyleItem - DimensionStyleStyleItem dimensionStyleStyleItem = null; - CIMDimensionStyle dimensionStyle = await QueuedTask.Run(() => - { - return dimensionStyleStyleItem.DimensionStyle; - }); - #endregion - - } - - - // cref: GetSetObject;ArcGIS.Desktop.Mapping.StyleItem.SetObject(System.Object) - #region GetSetObject - //Creates a new style item and sets its properties from an existing style item - public Task CreateNewStyleItemAsync(StyleItem existingItem) - { - if (existingItem == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => - { - StyleItem item = new StyleItem(); - - //Get object from existing style item - object obj = existingItem.GetObject(); - - //New style item's properties are set from the existing item - item.SetObject(obj); - - //Key, Name, Tags and Category for the new style item have to be set - //These values are NOT populated from the object passed in to SetObject - item.Key = "KeyOfTheNewItem"; - item.Name = "NameOfTheNewItem"; - item.Tags = "TagsForTheNewItem"; - item.Category = "CategoryOfTheNewItem"; - - return item; - }); - } - #endregion - } -} + #endregion + + // cref: Get map surround from MapSurroundStyleItem;ArcGIS.Desktop.Mapping.MapSurroundStyleItem.MapSurround + // cref: Get map surround from MapSurroundStyleItem;ArcGIS.Desktop.Mapping.MapSurroundStyleItem.MapSurround + #region Get map surround from MapSurroundStyleItem + MapSurroundStyleItem mapSurroundItem = null; + CIMMapSurround mapSurround = await QueuedTask.Run(() => + { + return mapSurroundItem.MapSurround; + }); + #endregion + + // cref: Get dimension style from DimensionStyleStyleItem;ArcGIS.Desktop.Mapping.DimensionStyleStyleItem.DimensionStyle + // cref: Get dimension style from DimensionStyleStyleItem;ArcGIS.Desktop.Mapping.DimensionStyleStyleItem.DimensionStyle + #region Get dimension style from DimensionStyleStyleItem + DimensionStyleStyleItem dimensionStyleStyleItem = null; + CIMDimensionStyle dimensionStyle = await QueuedTask.Run(() => + { + return dimensionStyleStyleItem.DimensionStyle; + }); + #endregion + + } + + + // cref: GetSetObject;ArcGIS.Desktop.Mapping.StyleItem.SetObject(System.Object) + // cref: GetSetObject;ArcGIS.Desktop.Mapping.StyleItem.SetObject(System.Object) + #region GetSetObject + //Creates a new style item and sets its properties from an existing style item + public Task CreateNewStyleItemAsync(StyleItem existingItem) + { + if (existingItem == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => + { + StyleItem item = new StyleItem(); + + //Get object from existing style item + object obj = existingItem.GetObject(); + + //New style item's properties are set from the existing item + item.SetObject(obj); + + //Key, Name, Tags and Category for the new style item have to be set + //These values are NOT populated from the object passed in to SetObject + item.Key = "KeyOfTheNewItem"; + item.Name = "NameOfTheNewItem"; + item.Tags = "TagsForTheNewItem"; + item.Category = "CategoryOfTheNewItem"; + + return item; + }); + } + #endregion + } +} diff --git a/Examples/MapAuthoring/CartoFeatures/ProSnippet.cs b/Examples/MapAuthoring/CartoFeatures/ProSnippet.cs index b4fdeec..7daf53c 100644 --- a/Examples/MapAuthoring/CartoFeatures/ProSnippet.cs +++ b/Examples/MapAuthoring/CartoFeatures/ProSnippet.cs @@ -1,384 +1,437 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Desktop.Core; -using ArcGIS.Core.CIM; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Threading.Tasks; -using System.Drawing; -using System.Drawing.Imaging; - -namespace CartoFeatures.ProSnippet -{ - class ProSnippet - { - //style management - #region ProSnippet Group: Style Management - #endregion - public void GetStyleInProjectByName() - { - #region How to get a style in project by name - - //Get all styles in the project - var ProjectStyles = Project.Current.GetItems(); - - //Get a specific style in the project by name - StyleProjectItem style = ProjectStyles.First(x => x.Name == "NameOfTheStyle"); - #endregion - } - - public async void CreateNewStyle() - { - // cref: How to create a new style;ArcGIS.Desktop.Mapping.StyleHelper.CreateMobileStyle(ArcGIS.Desktop.Core.Project,System.String) - // cref: How to create a new style;ArcGIS.Desktop.Mapping.StyleHelper.CreateStyle(ArcGIS.Desktop.Core.Project,System.String) - #region How to create a new style - - //Full path for the new style file (.stylx) to be created - string styleToCreate = @"C:\Temp\NewStyle.stylx"; - await QueuedTask.Run(() => StyleHelper.CreateStyle(Project.Current, styleToCreate)); - #endregion - } - - public async void AddStyleToProject() - { - // cref: How to add a style to project;ArcGIS.Desktop.Mapping.StyleHelper.AddStyle(ArcGIS.Desktop.Core.Project,System.String) - #region How to add a style to project - - //For ArcGIS Pro system styles, just pass in the name of the style to add to the project - await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, "3D Vehicles")); - - //For custom styles, pass in the full path to the style file on disk - string customStyleToAdd = @"C:\Temp\CustomStyle.stylx"; - await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, customStyleToAdd)); - - #endregion - } - - public async void RemoveStyleFromProject() - { - // cref: How to remove a style from project;ArcGIS.Desktop.Mapping.StyleHelper.RemoveStyle(ArcGIS.Desktop.Core.Project,System.String) - #region How to remove a style from project - - //For ArcGIS Pro system styles, just pass in the name of the style to remove from the project - await QueuedTask.Run(() => StyleHelper.RemoveStyle(Project.Current, "3D Vehicles")); - - //For custom styles, pass in the full path to the style file on disk - string customStyleToAdd = @"C:\Temp\CustomStyle.stylx"; - await QueuedTask.Run(() => StyleHelper.RemoveStyle(Project.Current, customStyleToAdd)); - - #endregion - } - - // cref: How to add a style item to a style;ArcGIS.Desktop.Mapping.StyleHelper.AddItem(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItem) - #region How to add a style item to a style - public Task AddStyleItemAsync(StyleProjectItem style, StyleItem itemToAdd) - { - return QueuedTask.Run(() => - { - if (style == null || itemToAdd == null) - throw new System.ArgumentNullException(); - - //Add the item to style - style.AddItem(itemToAdd); - }); - } - #endregion - - // cref: How to remove a style item from a style;ArcGIS.Desktop.Mapping.StyleHelper.RemoveItem(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItem) - #region How to remove a style item from a style - public Task RemoveStyleItemAsync(StyleProjectItem style, StyleItem itemToRemove) - { - return QueuedTask.Run(() => - { - if (style == null || itemToRemove == null) - throw new System.ArgumentNullException(); - - //Remove the item from style - style.RemoveItem(itemToRemove); - }); - } - #endregion - - #region How to determine if a style can be upgraded - //Pass in the full path to the style file on disk - public async Task CanUpgradeStyleAsync(string stylePath) - { - //Add the style to the current project - await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath)); - StyleProjectItem style = Project.Current.GetItems().First(x => x.Path == stylePath); - - //returns true if style can be upgraded - return style.CanUpgrade; - } - #endregion - - #region How to determine if a style is read-only - //Pass in the full path to the style file on disk - public async Task IsReadOnly(string stylePath) - { - //Add the style to the current project - await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath)); - StyleProjectItem style = Project.Current.GetItems().First(x => x.Path == stylePath); - - //returns true if style is read-only - return style.IsReadOnly; - } - #endregion - - #region How to determine if a style is current - //Pass in the full path to the style file on disk - public async Task IsCurrent(string stylePath) - { - //Add the style to the current project - await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath)); - StyleProjectItem style = Project.Current.GetItems().First(x => x.Path == stylePath); - - //returns true if style matches the current Pro version - return style.IsCurrent; - } - #endregion - - #region How to upgrade a style - //Pass in the full path to the style file on disk - public async Task UpgradeStyleAsync(string stylePath) - { - bool success = false; - - //Add the style to the current project - await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath)); - StyleProjectItem style = Project.Current.GetItems().First(x => x.Path == stylePath); - - //Verify that style can be upgraded - if (style.CanUpgrade) - { - success = await QueuedTask.Run(() => StyleHelper.UpgradeStyle(style)); - } - //return true if style was upgraded - return success; - } - #endregion - - //construct point symbol - #region ProSnippet Group: Symbols - #endregion - public async Task ConstructPointSymbol_1() - { - // cref: How to construct a point symbol of a specific color and size;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMColor,System.Double) - #region How to construct a point symbol of a specific color and size - - await QueuedTask.Run(() => - { - CIMPointSymbol pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 10.0); - }); - #endregion - } - - public async Task ConstructPointSymbol_2() - { - // cref: How to construct a point symbol of a specific color, size and shape;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMColor,System.Double,ArcGIS.Desktop.Mapping.SimpleMarkerStyle) - #region How to construct a point symbol of a specific color, size and shape - - await QueuedTask.Run(() => - { - CIMPointSymbol starPointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 10.0, SimpleMarkerStyle.Star); - }); - #endregion - } - - public async Task ConstructPointSymbol_3() - { - // cref: How to construct a point symbol from a marker;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarker(ArcGIS.Core.CIM.CIMColor,System.Double,ArcGIS.Desktop.Mapping.SimpleMarkerStyle) - // cref: How to construct a point symbol from a marker;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMMarker) - #region How to construct a point symbol from a marker - - await QueuedTask.Run(() => - { - CIMMarker marker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.GreenRGB, 8.0, SimpleMarkerStyle.Pushpin); - CIMPointSymbol pointSymbolFromMarker = SymbolFactory.Instance.ConstructPointSymbol(marker); - }); - #endregion - } - - public async Task ConstructPointSymbol_4() - { - // cref: How to construct a point symbol from a file on disk;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarkerFromBitmapSource(System.Windows.Media.Imaging.BitmapSource) - // cref: How to construct a point symbol from a file on disk;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarkerFromFile(System.String) - #region How to construct a point symbol from a file on disk - - //The following file formats can be used to create the marker: DAE, 3DS, FLT, EMF, JPG, PNG, BMP, GIF - CIMMarker markerFromFile = await QueuedTask.Run(() => SymbolFactory.Instance.ConstructMarkerFromFile(@"C:\Temp\fileName.dae")); - - CIMPointSymbol pointSymbolFromFile = SymbolFactory.Instance.ConstructPointSymbol(markerFromFile); - - #endregion - } - - public void ConstructPointSymbolFromMarkerStream() - { - #region How to construct a point symbol from a in memory graphic - //Create a stream for the image - Image newImage = Image.FromFile(@"C:\PathToImage\Image.png"); - var stream = new System.IO.MemoryStream(); - newImage.Save(stream, ImageFormat.Png); - stream.Position = 0; - //Create marker using the stream - CIMMarker markerFromStream = SymbolFactory.Instance.ConstructMarkerFromStream(stream); - //Create the point symbol from the marker - CIMPointSymbol pointSymbolFromStream = SymbolFactory.Instance.ConstructPointSymbol(markerFromStream); - #endregion - } - - - //construct polygon symbol - public void ConstructPolygonSymbol_1() - { - // cref: How to construct a polygon symbol of specific color and fill style;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol(ArcGIS.Core.CIM.CIMColor,ArcGIS.Desktop.Mapping.SimpleFillStyle) - #region How to construct a polygon symbol of specific color and fill style - - CIMPolygonSymbol polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid); - - #endregion - } - - public void ConstructPolygonSymbol_2() - { - // cref: How to construct a polygon symbol of specific color, fill style and outline;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol(ArcGIS.Core.CIM.CIMColor,ArcGIS.Desktop.Mapping.SimpleFillStyle,ArcGIS.Core.CIM.CIMStroke) - #region How to construct a polygon symbol of specific color, fill style and outline - - CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid); - CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline); - - #endregion - } - - public void ConstructPolygonSymbol_3() - { - #region How to construct a polygon symbol without an outline - - CIMPolygonSymbol fillWithoutOutline = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, null); - - #endregion - } - - //construct line symbol - public void ContructLineSymbol_1() - { - // cref: How to construct a line symbol of specific color, size and line style;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructLineSymbol(ArcGIS.Core.CIM.CIMColor,System.Double,ArcGIS.Desktop.Mapping.SimpleLineStyle) - #region How to construct a line symbol of specific color, size and line style - - CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid); - - #endregion - } - - public void ContructLineSymbol_2() - { - // cref: How to construct a line symbol from a stroke;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructLineSymbol(ArcGIS.Core.CIM.CIMStroke) - // cref: How to construct a line symbol from a stroke;ArcGIS.Desktop.Mapping.SymbolFactory.ConstructStroke(ArcGIS.Core.CIM.CIMColor,System.Double) - #region How to construct a line symbol from a stroke - - CIMStroke stroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0); - CIMLineSymbol lineSymbolFromStroke = SymbolFactory.Instance.ConstructLineSymbol(stroke); - - #endregion - } - - //multilayer symbols - public void ContructMultilayerLineSymbol_1() - { - #region How to construct a multilayer line symbol with circle markers on the line ends - - //These methods must be called within the lambda passed to QueuedTask.Run - var lineStrokeRed = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 4.0); - var markerCircle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Circle); - markerCircle.MarkerPlacement = new CIMMarkerPlacementOnVertices() - { - AngleToLine = true, - PlaceOnEndPoints = true, - Offset = 0 - }; - var lineSymbolWithCircles = new CIMLineSymbol() - { - SymbolLayers = new CIMSymbolLayer[2] { markerCircle, lineStrokeRed } - }; - - #endregion - } - - public void ContructMultilayerLineSymbol_2() - { - #region How to construct a multilayer line symbol with an arrow head on the end - - //These methods must be called within the lambda passed to QueuedTask.Run - var markerTriangle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Triangle); - markerTriangle.Rotation = -90; // or -90 - markerTriangle.MarkerPlacement = new CIMMarkerPlacementOnLine() { AngleToLine = true, RelativeTo = PlacementOnLineRelativeTo.LineEnd }; - - var lineSymbolWithArrow = new CIMLineSymbol() - { - SymbolLayers = new CIMSymbolLayer[2] { markerTriangle, - SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2) - } - }; - - #endregion - } - - //symbol reference - public void GetSymbolReference() - { - // cref: How to get symbol reference from a symbol;ArcGIS.Desktop.Mapping.SymbolExtensionMethods.MakeSymbolReference(ArcGIS.Core.CIM.CIMSymbol) - #region How to get symbol reference from a symbol - - CIMPolygonSymbol symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB); - - //Get symbol reference from the symbol - CIMSymbolReference symbolReference = symbol.MakeSymbolReference(); - - #endregion - } - - - private static void GetSymbol() - { - #region Modify a point symbol created from a character marker - //create marker from the Font, char index,size,color - var cimMarker = SymbolFactory.Instance.ConstructMarker(125, "Wingdings 3", "Regular", 6, ColorFactory.Instance.BlueRGB) as CIMCharacterMarker; - var polygonMarker = cimMarker.Symbol; - //modifying the polygon's outline and fill - //This is the outline - polygonMarker.SymbolLayers[0] = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.GreenRGB, 2, SimpleLineStyle.Solid); - //This is the fill - polygonMarker.SymbolLayers[1] = SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.BlueRGB); - //create a symbol from the marker - //Note this overload of ConstructPointSymbol does not need to be run within QueuedTask.Run. - var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(cimMarker); - #endregion - } - -private void Fonts() +/* + + Copyright 2018 Esri + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and + limitations under the License. + +*/ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ArcGIS.Desktop.Mapping; +using ArcGIS.Desktop.Core; +using ArcGIS.Core.CIM; +using ArcGIS.Desktop.Framework; +using ArcGIS.Desktop.Framework.Threading.Tasks; + + +namespace CartoFeatures.ProSnippet +{ + class ProSnippet + { + //style management + #region ProSnippet Group: Style Management + #endregion + public void GetStyleInProjectByName() + { + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem + #region How to get a style in project by name + + //Get all styles in the project + var ProjectStyles = Project.Current.GetItems(); + + //Get a specific style in the project by name + StyleProjectItem style = ProjectStyles.First(x => x.Name == "NameOfTheStyle"); + #endregion + } + + public async void CreateNewStyle() + { + // cref: ArcGIS.Desktop.Mapping.StyleHelper.CreateStyle(ArcGIS.Desktop.Core.Project,System.String) + #region How to create a new style + + //Full path for the new style file (.stylx) to be created + string styleToCreate = @"C:\Temp\NewStyle.stylx"; + await QueuedTask.Run(() => StyleHelper.CreateStyle(Project.Current, styleToCreate)); + #endregion + } + + public async void AddStyleToProject() + { + // cref:ArcGIS.Desktop.Mapping.StyleHelper.AddStyle(ArcGIS.Desktop.Core.Project,System.String) + #region How to add a style to project + + //For ArcGIS Pro system styles, just pass in the name of the style to add to the project + await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, "3D Vehicles")); + + //For custom styles, pass in the full path to the style file on disk + string customStyleToAdd = @"C:\Temp\CustomStyle.stylx"; + await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, customStyleToAdd)); + + #endregion + } + + public async void RemoveStyleFromProject() + { + // cref: ArcGIS.Desktop.Mapping.StyleHelper.RemoveStyle(ArcGIS.Desktop.Core.Project,System.String) + #region How to remove a style from project + + //For ArcGIS Pro system styles, just pass in the name of the style to remove from the project + await QueuedTask.Run(() => StyleHelper.RemoveStyle(Project.Current, "3D Vehicles")); + + //For custom styles, pass in the full path to the style file on disk + string customStyleToAdd = @"C:\Temp\CustomStyle.stylx"; + await QueuedTask.Run(() => StyleHelper.RemoveStyle(Project.Current, customStyleToAdd)); + + #endregion + } + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.AddItem(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItem) + #region How to add a style item to a style + public Task AddStyleItemAsync(StyleProjectItem style, StyleItem itemToAdd) + { + return QueuedTask.Run(() => + { + if (style == null || itemToAdd == null) + throw new System.ArgumentNullException(); + + //Add the item to style + style.AddItem(itemToAdd); + }); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.RemoveItem(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItem) + #region How to remove a style item from a style + public Task RemoveStyleItemAsync(StyleProjectItem style, StyleItem itemToRemove) + { + return QueuedTask.Run(() => + { + if (style == null || itemToRemove == null) + throw new System.ArgumentNullException(); + + //Remove the item from style + style.RemoveItem(itemToRemove); + }); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem.CanUpgrade + #region How to determine if a style can be upgraded + //Pass in the full path to the style file on disk + public async Task CanUpgradeStyleAsync(string stylePath) + { + //Add the style to the current project + await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath)); + StyleProjectItem style = Project.Current.GetItems().First(x => x.Path == stylePath); + + //returns true if style can be upgraded + return style.CanUpgrade; + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem.IsReadOnly + #region How to determine if a style is read-only + //Pass in the full path to the style file on disk + public async Task IsReadOnly(string stylePath) + { + //Add the style to the current project + await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath)); + StyleProjectItem style = Project.Current.GetItems().First(x => x.Path == stylePath); + + //returns true if style is read-only + return style.IsReadOnly; + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem.IsCurrent + #region How to determine if a style is current + //Pass in the full path to the style file on disk + public async Task IsCurrent(string stylePath) + { + //Add the style to the current project + await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath)); + StyleProjectItem style = Project.Current.GetItems().First(x => x.Path == stylePath); + + //returns true if style matches the current Pro version + return style.IsCurrent; + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleProjectItem.CanUpgrade + // cref: ArcGIS.Desktop.Mapping.StyleHelper.UpgradeStyle(ArcGIS.Desktop.Mapping.StyleProjectItem) + #region How to upgrade a style + //Pass in the full path to the style file on disk + public async Task UpgradeStyleAsync(string stylePath) + { + bool success = false; + + //Add the style to the current project + await QueuedTask.Run(() => StyleHelper.AddStyle(Project.Current, stylePath)); + StyleProjectItem style = Project.Current.GetItems().First(x => x.Path == stylePath); + + //Verify that style can be upgraded + if (style.CanUpgrade) + { + success = await QueuedTask.Run(() => StyleHelper.UpgradeStyle(style)); + } + //return true if style was upgraded + return success; + } + #endregion + + //construct point symbol + #region ProSnippet Group: Symbols + #endregion + public async Task ConstructPointSymbol_1() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMColor,System.Double) + // cref: ArcGIS.Core.CIM.CIMPointSymbol + #region How to construct a point symbol of a specific color and size + + await QueuedTask.Run(() => + { + CIMPointSymbol pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 10.0); + }); + #endregion + } + + public async Task ConstructPointSymbol_2() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMColor,System.Double,ArcGIS.Desktop.Mapping.SimpleMarkerStyle) + // cref: ArcGIS.Core.CIM.CIMPointSymbol + #region How to construct a point symbol of a specific color, size and shape + + await QueuedTask.Run(() => + { + CIMPointSymbol starPointSymbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 10.0, SimpleMarkerStyle.Star); + }); + #endregion + } + + public async Task ConstructPointSymbol_3() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarker(ArcGIS.Core.CIM.CIMColor,System.Double,ArcGIS.Desktop.Mapping.SimpleMarkerStyle) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMMarker) + // cref: ArcGIS.Core.CIM.CIMMarker + // cref: ArcGIS.Core.CIM.CIMPointSymbol + #region How to construct a point symbol from a marker + + await QueuedTask.Run(() => + { + CIMMarker marker = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.GreenRGB, 8.0, SimpleMarkerStyle.Pushpin); + CIMPointSymbol pointSymbolFromMarker = SymbolFactory.Instance.ConstructPointSymbol(marker); + }); + #endregion + } + + public async Task ConstructPointSymbol_4() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarkerFromFile(System.String) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMMarker) + // cref: ArcGIS.Core.CIM.CIMMarker + // cref: ArcGIS.Core.CIM.CIMPointSymbol + #region How to construct a point symbol from a file on disk + + //The following file formats can be used to create the marker: DAE, 3DS, FLT, EMF, JPG, PNG, BMP, GIF + CIMMarker markerFromFile = await QueuedTask.Run(() => SymbolFactory.Instance.ConstructMarkerFromFile(@"C:\Temp\fileName.dae")); + + CIMPointSymbol pointSymbolFromFile = SymbolFactory.Instance.ConstructPointSymbol(markerFromFile); + + #endregion + } + + public void ConstructPointSymbolFromMarkerStream() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarkerFromStream(System.IO.Stream) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMMarker) + // cref: ArcGIS.Core.CIM.CIMMarker + // cref: ArcGIS.Core.CIM.CIMPointSymbol + #region How to construct a point symbol from a in memory graphic + //Create a stream for the image + //At 3.0 you need https://www.nuget.org/packages/Microsoft.Windows.Compatibility + //System.Drawing + + System.Drawing.Image newImage = System.Drawing.Image.FromFile(@"C:\PathToImage\Image.png"); + var stream = new System.IO.MemoryStream(); + newImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png); + stream.Position = 0; + //Create marker using the stream + CIMMarker markerFromStream = SymbolFactory.Instance.ConstructMarkerFromStream(stream); + //Create the point symbol from the marker + CIMPointSymbol pointSymbolFromStream = SymbolFactory.Instance.ConstructPointSymbol(markerFromStream); + #endregion + } + + + //construct polygon symbol + public void ConstructPolygonSymbol_1() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol(ArcGIS.Core.CIM.CIMColor,ArcGIS.Desktop.Mapping.SimpleFillStyle) + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + #region How to construct a polygon symbol of specific color and fill style + + CIMPolygonSymbol polygonSymbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid); + + #endregion + } + + public void ConstructPolygonSymbol_2() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructStroke(ArcGIS.Core.CIM.CIMColor,System.Double, ArcGIS.Desktop.Mapping.SimpleLineStyle) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol(ArcGIS.Core.CIM.CIMColor,ArcGIS.Desktop.Mapping.SimpleFillStyle,ArcGIS.Core.CIM.CIMStroke) + // cref: ArcGIS.Core.CIM.CIMStroke + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + #region How to construct a polygon symbol of specific color, fill style and outline + + CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid); + CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline); + + #endregion + } + + public void ConstructPolygonSymbol_3() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPolygonSymbol(ArcGIS.Core.CIM.CIMColor,ArcGIS.Desktop.Mapping.SimpleFillStyle,ArcGIS.Core.CIM.CIMStroke) + // cref: ArcGIS.Core.CIM.CIMPolygonSymbol + #region How to construct a polygon symbol without an outline + + CIMPolygonSymbol fillWithoutOutline = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, null); + + #endregion + } + + //construct line symbol + public void ContructLineSymbol_1() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructLineSymbol(ArcGIS.Core.CIM.CIMColor,System.Double,ArcGIS.Desktop.Mapping.SimpleLineStyle) + // cref: ArcGIS.Core.CIM.CIMLineSymbol + #region How to construct a line symbol of specific color, size and line style + + CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid); + + #endregion + } + + public void ContructLineSymbol_2() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructStroke(ArcGIS.Core.CIM.CIMColor,System.Double) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructLineSymbol(ArcGIS.Core.CIM.CIMStroke) + // cref: ArcGIS.Core.CIM.CIMStroke + // cref: ArcGIS.Core.CIM.CIMLineSymbol + #region How to construct a line symbol from a stroke + + CIMStroke stroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0); + CIMLineSymbol lineSymbolFromStroke = SymbolFactory.Instance.ConstructLineSymbol(stroke); + + #endregion + } + + //multilayer symbols + public void ContructMultilayerLineSymbol_1() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructStroke(ArcGIS.Core.CIM.CIMColor,System.Double) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarker(ArcGIS.Core.CIM.CIMColor,System.Double, ArcGIS.Desktop.Mapping.SimpleMarkerStyle) + // cref: ArcGIS.Core.CIM.CIMMarkerPlacementOnVertices + // cref: ArcGIS.Core.CIM.CIMMarkerPlacementOnVertices.#ctor + // cref: ArcGIS.Core.CIM.CIMMarkerStrokePlacement.AngleToLine + // cref: ArcGIS.Core.CIM.CIMMarkerPlacementOnVertices.PlaceOnEndPoints + // cref: ArcGIS.Core.CIM.CIMMarkerStrokePlacement.Offset + // cref: ArcGIS.Core.CIM.CIMLineSymbol + // cref: ArcGIS.Core.CIM.CIMLineSymbol.#ctor + // cref: ArcGIS.Core.CIM.CIMSymbolLayer + #region How to construct a multilayer line symbol with circle markers on the line ends + + //These methods must be called within the lambda passed to QueuedTask.Run + var lineStrokeRed = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 4.0); + var markerCircle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Circle); + markerCircle.MarkerPlacement = new CIMMarkerPlacementOnVertices() + { + AngleToLine = true, + PlaceOnEndPoints = true, + Offset = 0 + }; + var lineSymbolWithCircles = new CIMLineSymbol() + { + SymbolLayers = new CIMSymbolLayer[2] { markerCircle, lineStrokeRed } + }; + + #endregion + } + + public void ContructMultilayerLineSymbol_2() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarker(ArcGIS.Core.CIM.CIMColor,System.Double, ArcGIS.Desktop.Mapping.SimpleMarkerStyle) + // cref: ArcGIS.Core.CIM.CIMMarker.Rotation + // cref: ArcGIS.Core.CIM.CIMMarker.MarkerPlacement + // cref: ArcGIS.Core.CIM.CIMMarkerPlacementOnLine + // cref: ArcGIS.Core.CIM.CIMMarkerPlacementOnLine.#ctor + // cref: ArcGIS.Core.CIM.CIMMarkerStrokePlacement.AngleToLine + // cref: ArcGIS.Core.CIM.CIMMarkerPlacementOnLine.RelativeTo + // cref: ArcGIS.Core.CIM.CIMLineSymbol + // cref: ArcGIS.Core.CIM.CIMLineSymbol.#ctor + // cref: ArcGIS.Core.CIM.CIMSymbolLayer + #region How to construct a multilayer line symbol with an arrow head on the end + + //These methods must be called within the lambda passed to QueuedTask.Run + var markerTriangle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Triangle); + markerTriangle.Rotation = -90; // or -90 + markerTriangle.MarkerPlacement = new CIMMarkerPlacementOnLine() { AngleToLine = true, RelativeTo = PlacementOnLineRelativeTo.LineEnd }; + + var lineSymbolWithArrow = new CIMLineSymbol() + { + SymbolLayers = new CIMSymbolLayer[2] { markerTriangle, + SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2) + } + }; + + #endregion + } + + //symbol reference + public void GetSymbolReference() + { + // cref: ArcGIS.Desktop.Mapping.SymbolExtensionMethods.MakeSymbolReference(ArcGIS.Core.CIM.CIMSymbol) + // cref: ArcGIS.Core.CIM.CIMSymbolReference + #region How to get symbol reference from a symbol + + CIMPolygonSymbol symbol = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB); + + //Get symbol reference from the symbol + CIMSymbolReference symbolReference = symbol.MakeSymbolReference(); + + #endregion + } + + + private static void GetSymbol() + { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructMarker(System.Int32, system.String, System.String, System.Int32, ArcGIS.Core.CIM.CIMColor) + // cref: ArcGIS.Core.CIM.CIMCharacterMarker + // cref: ArcGIS.Core.CIM.CIMCharacterMarker.Symbol + // cref: ArcGIS.Core.CIM.CIMMultiLayerSymbol.SymbolLayers + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructPointSymbol(ArcGIS.Core.CIM.CIMMarker) + #region Modify a point symbol created from a character marker + //create marker from the Font, char index,size,color + var cimMarker = SymbolFactory.Instance.ConstructMarker(125, "Wingdings 3", "Regular", 6, ColorFactory.Instance.BlueRGB) as CIMCharacterMarker; + var polygonMarker = cimMarker.Symbol; + //modifying the polygon's outline and fill + //This is the outline + polygonMarker.SymbolLayers[0] = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.GreenRGB, 2, SimpleLineStyle.Solid); + //This is the fill + polygonMarker.SymbolLayers[1] = SymbolFactory.Instance.ConstructSolidFill(ColorFactory.Instance.BlueRGB); + //create a symbol from the marker + //Note this overload of ConstructPointSymbol does not need to be run within QueuedTask.Run. + var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(cimMarker); + #endregion + } + + private void Fonts() { + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.GetAvailableFonts() #region Get a List of Available Fonts //Must use QueuedTask.Run(...) //returns a tuple per font: (string fontName, List fontStyles) @@ -391,6 +444,9 @@ private void Fonts() #endregion + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.DefaultFont + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.SetDefaultFont(System.String) + // cref: ArcGIS.Desktop.Core.TextAndGraphicsElementsOptions.SetDefaultFont(System.String, System.String) #region Get/Set Default Font //Must use QueuedTask.Run(...) @@ -404,6 +460,13 @@ private void Fonts() #endregion + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol() + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol(ArcGIS.Core.CIM.CIMColor, System.Double) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol(System.String) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol(System.String, System.STring) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.GetAvailableFonts() + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol(ArcGIS.Core.CIM.CIMColor, System.Double,System.String, System.STring) + // cref: ArcGIS.Desktop.Mapping.SymbolFactory.ConstructTextSymbol(ArcGIS.Core.CIM.CIMPolygonSymbol, SSystem.Double, System.String) #region Construct a Text Symbol With Options QueuedTask.Run(() => @@ -445,344 +508,407 @@ private void Fonts() #endregion } - private static Task CreateSymbolSwatch() - { - return QueuedTask.Run(() => { - #region Create a Swatch for a given symbol - - //Note: call within QueuedTask.Run() - CIMSymbol symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreenRGB, 1.0, SimpleMarkerStyle.Circle); - //You can generate a swatch for a text symbols also. - var si = new SymbolStyleItem() - { - Symbol = symbol, - PatchHeight = 64, - PatchWidth = 64 - }; - return si.PreviewImage; - #endregion - }); - } - - - private static void SymbolLookup(FeatureLayer featureLayer) - { - #region Lookup Symbol - //Note: Run within QueuedTask.Run - //Get the selection - var selection = featureLayer.GetSelection(); - //Get the first Object ID - var firstOID = selection.GetObjectIDs().FirstOrDefault(); - //Determine whether the layer's renderer type supports symbol lookup. - if (featureLayer.CanLookupSymbol()) - { - //Looks up the symbol for the corresponding feature identified by the object id. - var symbol = featureLayer.LookupSymbol(firstOID, MapView.Active); - var jSon = symbol.ToJson(); //Create a JSON encoding of the symbol - //Do something with symbol - } - #endregion - } - #region ProSnippet Group: Symbol Search - #endregion - //symbol search - // cref: How to search for a specific item in a style;ArcGIS.Desktop.Mapping.StyleHelper.LookupItem(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItemType,System.String) - #region How to search for a specific item in a style - public Task GetSymbolFromStyleAsync(StyleProjectItem style, string key) - { - return QueuedTask.Run(() => - { - if (style == null) - throw new System.ArgumentNullException(); - - //Search for a specific point symbol in style - SymbolStyleItem item = (SymbolStyleItem)style.LookupItem(StyleItemType.PointSymbol, key); - return item; - }); - } - #endregion - - // cref: How to search for point symbols in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchSymbols(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItemType,System.String) - #region How to search for point symbols in a style - public Task> GetPointSymbolsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - //Search for point symbols - return QueuedTask.Run(() => style.SearchSymbols(StyleItemType.PointSymbol, searchString)); - } - #endregion - - #region How to search for line symbols in a style - public Task> GetLineSymbolsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - //Search for line symbols - return QueuedTask.Run(() => style.SearchSymbols(StyleItemType.LineSymbol, searchString)); - } - #endregion - - #region How to search for polygon symbols in a style - public async Task> GetPolygonSymbolsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - //Search for polygon symbols - return await QueuedTask.Run(() => style.SearchSymbols(StyleItemType.PolygonSymbol, searchString)); - } - #endregion - - // cref: How to search for colors in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchColors(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for colors in a style - public async Task> GetColorsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - //Search for colors - return await QueuedTask.Run(() => style.SearchColors(searchString)); - } - #endregion - - // cref: How to search for color ramps in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchColorRamps(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for color ramps in a style - public async Task> GetColorRampsFromStyleAsync(StyleProjectItem style, string searchString) - { - //StyleProjectItem can be "ColorBrewer Schemes (RGB)", "ArcGIS 2D"... - if (style == null) - throw new System.ArgumentNullException(); - - //Search for color ramps - //Color Ramp searchString can be "Spectral (7 Classes)", "Pastel 1 (3 Classes)", "Red-Gray (10 Classes)".. - return await QueuedTask.Run(() => style.SearchColorRamps(searchString)); - } - #endregion - - // cref: How to search for north arrows in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchNorthArrows(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for north arrows in a style - public Task> GetNorthArrowsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - //Search for north arrows - return QueuedTask.Run(() => style.SearchNorthArrows(searchString)); - } - #endregion - - // cref: How to search for scale bars in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchScaleBars(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for scale bars in a style - public Task> GetScaleBarsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - //Search for scale bars - return QueuedTask.Run(() => style.SearchScaleBars(searchString)); - } - #endregion - - // cref: How to search for label placements in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchLabelPlacements(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItemType,System.String) - #region How to search for label placements in a style - public Task> GetLabelPlacementsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - //Search for standard label placement - return QueuedTask.Run(() => style.SearchLabelPlacements(StyleItemType.StandardLabelPlacement, searchString)); - } - #endregion - - // cref: How to search for legends in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchLegends(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for legends in a style - public Task> GetLegendFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => style.SearchLegends(searchString)); + + private static Task CreateSymbolSwatch() + { + return QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem.#ctor + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem.Symbol + // cref: ArcGIS.Desktop.Mapping.StyleItem.PatchHeight + // cref: ArcGIS.Desktop.Mapping.StyleItem.PatchWidth + // cref: ArcGIS.Desktop.Mapping.StyleItem.PreviewImage + #region Create a Swatch for a given symbol + + //Note: call within QueuedTask.Run() + CIMSymbol symbol = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreenRGB, 1.0, SimpleMarkerStyle.Circle); + //You can generate a swatch for a text symbols also. + var si = new SymbolStyleItem() + { + Symbol = symbol, + PatchHeight = 64, + PatchWidth = 64 + }; + return si.PreviewImage; + #endregion + }); + } + + + private static void SymbolLookup(FeatureLayer featureLayer) + { + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CanLookupSymbol() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.LookupSymbol(System.Long, ArcGIS.Desktop.Mapping.MapView) + #region Lookup Symbol + //Note: Run within QueuedTask.Run + //Get the selection + var selection = featureLayer.GetSelection(); + //Get the first Object ID + var firstOID = selection.GetObjectIDs().FirstOrDefault(); + //Determine whether the layer's renderer type supports symbol lookup. + if (featureLayer.CanLookupSymbol()) + { + //Looks up the symbol for the corresponding feature identified by the object id. + var symbol = featureLayer.LookupSymbol(firstOID, MapView.Active); + var jSon = symbol.ToJson(); //Create a JSON encoding of the symbol + //Do something with symbol + } + #endregion + } + + + #region ProSnippet Group: Symbol Search + #endregion + //symbol search + // cref: ArcGIS.Desktop.Mapping.StyleHelper.LookupItem(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItemType,System.String) + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem + #region How to search for a specific item in a style + public Task GetSymbolFromStyleAsync(StyleProjectItem style, string key) + { + return QueuedTask.Run(() => + { + if (style == null) + throw new System.ArgumentNullException(); + + //Search for a specific point symbol in style + SymbolStyleItem item = (SymbolStyleItem)style.LookupItem(StyleItemType.PointSymbol, key); + return item; + }); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchSymbols(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItemType,System.String) + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem + #region How to search for point symbols in a style + public Task> GetPointSymbolsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + //Search for point symbols + return QueuedTask.Run(() => style.SearchSymbols(StyleItemType.PointSymbol, searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchSymbols(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItemType,System.String) + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem + #region How to search for line symbols in a style + public Task> GetLineSymbolsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + //Search for line symbols + return QueuedTask.Run(() => style.SearchSymbols(StyleItemType.LineSymbol, searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchSymbols(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItemType,System.String) + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem + #region How to search for polygon symbols in a style + public async Task> GetPolygonSymbolsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + //Search for polygon symbols + return await QueuedTask.Run(() => style.SearchSymbols(StyleItemType.PolygonSymbol, searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchColors(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.ColorStyleItem + #region How to search for colors in a style + public async Task> GetColorsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + //Search for colors + return await QueuedTask.Run(() => style.SearchColors(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchColorRamps(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.ColorRampStyleItem + #region How to search for color ramps in a style + public async Task> GetColorRampsFromStyleAsync(StyleProjectItem style, string searchString) + { + //StyleProjectItem can be "ColorBrewer Schemes (RGB)", "ArcGIS 2D"... + if (style == null) + throw new System.ArgumentNullException(); + + //Search for color ramps + //Color Ramp searchString can be "Spectral (7 Classes)", "Pastel 1 (3 Classes)", "Red-Gray (10 Classes)".. + return await QueuedTask.Run(() => style.SearchColorRamps(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchNorthArrows(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.NorthArrowStyleItem + #region How to search for north arrows in a style + public Task> GetNorthArrowsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + //Search for north arrows + return QueuedTask.Run(() => style.SearchNorthArrows(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchScaleBars(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.ScaleBarStyleItem + #region How to search for scale bars in a style + public Task> GetScaleBarsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + //Search for scale bars + return QueuedTask.Run(() => style.SearchScaleBars(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchLabelPlacements(ArcGIS.Desktop.Mapping.StyleProjectItem,ArcGIS.Desktop.Mapping.StyleItemType,System.String) + // cref: ArcGIS.Desktop.Mapping.LabelPlacementStyleItem + #region How to search for label placements in a style + public Task> GetLabelPlacementsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + //Search for standard label placement + return QueuedTask.Run(() => style.SearchLabelPlacements(StyleItemType.StandardLabelPlacement, searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchLegends(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.LegendStyleItem + #region How to search for legends in a style + public Task> GetLegendFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => style.SearchLegends(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchLegendItems(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.LegendItemStyleItem + #region How to search for legend items in a style + public Task> GetLegendItemsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => style.SearchLegendItems(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchGrids(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.GridStyleItem + #region How to search for grids in a style + public Task> GetGridsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => style.SearchGrids(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchMapSurrounds(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.MapSurroundStyleItem + #region How to search for map surrounds in a style + public Task> GetMapSurroundsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => style.SearchMapSurrounds(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchTableFrames(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.TableFrameStyleItem + #region How to search for table frames in a style + public Task> GetTableFramesFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => style.SearchTableFrames(searchString)); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchTableFrameFields(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) + // cref: ArcGIS.Desktop.Mapping.TableFrameFieldStyleItem + #region How to search for table frame fields in a style + public Task> GetTableFrameFieldsFromStyleAsync(StyleProjectItem style, string searchString) + { + if (style == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => style.SearchTableFrameFields(searchString)); + } + #endregion + + + #region ProSnippet Group: Feature Layer Symbology + #endregion + + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetRenderer() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.UsesRealWorldSymbolSizes + // cref: ArcGIS.Core.CIM.CIMSimpleRenderer + #region How to set symbol for a feature layer symbolized with simple renderer + + public Task SetFeatureLayerSymbolAsync(FeatureLayer ftrLayer, CIMSymbol symbolToApply) + { + if (ftrLayer == null || symbolToApply == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => + { + + //Get simple renderer from the feature layer + CIMSimpleRenderer currentRenderer = ftrLayer.GetRenderer() as CIMSimpleRenderer; + if (currentRenderer == null) + return; + + //Set symbol's real world setting to be the same as that of the feature layer + symbolToApply.SetRealWorldUnits(ftrLayer.UsesRealWorldSymbolSizes); + + //Update the symbol of the current simple renderer + currentRenderer.Symbol = symbolToApply.MakeSymbolReference(); + //Update the feature layer renderer + ftrLayer.SetRenderer(currentRenderer); + }); } + #endregion - // cref: How to search for legend items in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchLegendItems(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for legend items in a style - public Task> GetLegendItemsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => style.SearchLegendItems(searchString)); - } - #endregion - - // cref: How to search for grids in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchGrids(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for grids in a style - public Task> GetGridsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => style.SearchGrids(searchString)); - } - #endregion - - // cref: How to search for map surrounds in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchMapSurrounds(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for map surrounds in a style - public Task> GetMapSurroundsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => style.SearchMapSurrounds(searchString)); - } - #endregion - - // cref: How to search for table frames in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchTableFrames(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for table frames in a style - public Task> GetTableFramesFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => style.SearchTableFrames(searchString)); - } - #endregion - - // cref: How to search for table frame fields in a style;ArcGIS.Desktop.Mapping.StyleHelper.SearchTableFrameFields(ArcGIS.Desktop.Mapping.StyleProjectItem,System.String) - #region How to search for table frame fields in a style - public Task> GetTableFrameFieldsFromStyleAsync(StyleProjectItem style, string searchString) - { - if (style == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => style.SearchTableFrameFields(searchString)); - } - #endregion - - #region ProSnippet Group: Feature Layer Symbology - #endregion - - //feature layer symbology - #region How to set symbol for a feature layer symbolized with simple renderer - - public Task SetFeatureLayerSymbolAsync(FeatureLayer ftrLayer, CIMSymbol symbolToApply) - { - if (ftrLayer == null || symbolToApply == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => - { - - //Get simple renderer from the feature layer - CIMSimpleRenderer currentRenderer = ftrLayer.GetRenderer() as CIMSimpleRenderer; - if (currentRenderer == null) - return; - - //Set symbol's real world setting to be the same as that of the feature layer - symbolToApply.SetRealWorldUnits(ftrLayer.UsesRealWorldSymbolSizes); - - //Update the symbol of the current simple renderer - currentRenderer.Symbol = symbolToApply.MakeSymbolReference(); - //Update the feature layer renderer - ftrLayer.SetRenderer(currentRenderer); - }); - } - - #endregion - - #region How to apply a symbol from style to a feature layer - - public Task SetFeatureLayerSymbolFromStyleItemAsync(FeatureLayer ftrLayer, SymbolStyleItem symbolItem) - { - if (ftrLayer == null || symbolItem == null) - throw new System.ArgumentNullException(); - - return QueuedTask.Run(() => - { - //Get simple renderer from the feature layer - CIMSimpleRenderer currentRenderer = ftrLayer.GetRenderer() as CIMSimpleRenderer; - if (currentRenderer == null) - return; - //Get symbol from the SymbolStyleItem - CIMSymbol symbol = symbolItem.Symbol; - - //Set symbol's real world setting to be the same as that of the feature layer - symbol.SetRealWorldUnits(ftrLayer.UsesRealWorldSymbolSizes); - - //Update the symbol of the current simple renderer - currentRenderer.Symbol = symbol.MakeSymbolReference(); - //Update the feature layer renderer - ftrLayer.SetRenderer(currentRenderer); - }); - } - - #endregion - - #region How to apply a point symbol from a style to a feature layer - - // var map = MapView.Active.Map; - // if (map == null) - // return; - // var pointFeatureLayer = - // map.GetLayersAsFlattenedList() - // .OfType() - // .Where(fl => fl.ShapeType == esriGeometryType.esriGeometryPoint); - // await ApplySymbolToFeatureLayerAsync(pointFeatureLayer.FirstOrDefault(), "Fire Station"); - - public Task ApplySymbolToFeatureLayerAsync(FeatureLayer featureLayer, string symbolName) - { - return QueuedTask.Run(async () => - { - //Get the ArcGIS 2D System style from the Project - var arcGIS2DStyle = Project.Current.GetItems().FirstOrDefault(s => s.Name == "ArcGIS 2D"); - - //Search for the symbolName style items within the ArcGIS 2D style project item. - var items = await QueuedTask.Run(() => arcGIS2DStyle.SearchSymbols(StyleItemType.PointSymbol, symbolName)); - - //Gets the CIMSymbol - CIMSymbol symbol = items.FirstOrDefault().Symbol; - - //Get the renderer of the point feature layer - CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; - - //Set symbol's real world setting to be the same as that of the feature layer - symbol.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes); - - //Apply the symbol to the feature layer's current renderer - renderer.Symbol = symbol.MakeSymbolReference(); - - //Appy the renderer to the feature layer - featureLayer.SetRenderer(renderer); - }); - } - #endregion - #region How to apply a color ramp from a style to a feature layer - - public async Task ApplyColorRampAsync(FeatureLayer featureLayer, string[] fields) - { - - StyleProjectItem style = - Project.Current.GetItems().FirstOrDefault(s => s.Name == "ColorBrewer Schemes (RGB)"); - if (style == null) return; - var colorRampList = await QueuedTask.Run(() => style.SearchColorRamps("Red-Gray (10 Classes)")); - if (colorRampList == null || colorRampList.Count == 0) return; - CIMColorRamp cimColorRamp = null; - CIMRenderer renderer = null; - await QueuedTask.Run(() => - { - cimColorRamp = colorRampList[0].ColorRamp; - var rendererDef = new UniqueValueRendererDefinition(fields, null, cimColorRamp); - renderer = featureLayer?.CreateRenderer(rendererDef); - featureLayer?.SetRenderer(renderer); - }); - - } - #endregion - - } -} + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetRenderer() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.UsesRealWorldSymbolSizes + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem.Symbol + // cref: ArcGIS.Core.CIM.CIMSimpleRenderer + // cref: ArcGIS.Core.CIM.CIMSimpleRenderer.Symbol + // cref: ArcGIS.Core.CIM.CIMSymbol.MakeSymbolReference + // cref: ArcGIS.Core.CIM.CIMSymbol.SetRealWorldUnits + #region How to apply a symbol from style to a feature layer + + public Task SetFeatureLayerSymbolFromStyleItemAsync( + FeatureLayer ftrLayer, SymbolStyleItem symbolItem) + { + if (ftrLayer == null || symbolItem == null) + throw new System.ArgumentNullException(); + + return QueuedTask.Run(() => + { + //Get simple renderer from the feature layer + CIMSimpleRenderer currentRenderer = ftrLayer.GetRenderer() as CIMSimpleRenderer; + if (currentRenderer == null) + return; + //Get symbol from the SymbolStyleItem + CIMSymbol symbol = symbolItem.Symbol; + + //Set symbol's real world setting to be the same as that of the feature layer + symbol.SetRealWorldUnits(ftrLayer.UsesRealWorldSymbolSizes); + + //Update the symbol of the current simple renderer + currentRenderer.Symbol = symbol.MakeSymbolReference(); + //Update the feature layer renderer + ftrLayer.SetRenderer(currentRenderer); + }); + } + + #endregion + + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetRenderer() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer() + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SEARCHSYMBOLS + // cref: ArcGIS.Desktop.Mapping.SymbolStyleItem.Symbol + // cref: ArcGIS.Desktop.Mapping.StyleItemType + // cref: ArcGIS.Core.CIM.CIMSimpleRenderer.Symbol + // cref: ArcGIS.Core.CIM.CIMSymbol.MakeSymbolReference + // cref: ArcGIS.Core.CIM.CIMSymbol.SetRealWorldUnits + #region How to apply a point symbol from a style to a feature layer + + // var map = MapView.Active.Map; + // if (map == null) + // return; + // var pointFeatureLayer = + // map.GetLayersAsFlattenedList() + // .OfType() + // .Where(fl => fl.ShapeType == esriGeometryType.esriGeometryPoint); + // await ApplySymbolToFeatureLayerAsync(pointFeatureLayer.FirstOrDefault(), "Fire Station"); + + public Task ApplySymbolToFeatureLayerAsync(FeatureLayer featureLayer, string symbolName) + { + return QueuedTask.Run(async () => + { + //Get the ArcGIS 2D System style from the Project + var arcGIS2DStyle = + Project.Current.GetItems().FirstOrDefault(s => s.Name == "ArcGIS 2D"); + + //Search for the symbolName style items within the ArcGIS 2D style project item. + var items = await QueuedTask.Run(() => + arcGIS2DStyle.SearchSymbols(StyleItemType.PointSymbol, symbolName)); + + //Gets the CIMSymbol + CIMSymbol symbol = items.FirstOrDefault().Symbol; + + //Get the renderer of the point feature layer + CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer; + + //Set symbol's real world setting to be the same as that of the feature layer + symbol.SetRealWorldUnits(featureLayer.UsesRealWorldSymbolSizes); + + //Apply the symbol to the feature layer's current renderer + renderer.Symbol = symbol.MakeSymbolReference(); + + //Appy the renderer to the feature layer + featureLayer.SetRenderer(renderer); + }); + } + #endregion + + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchColorRamps(StyleProjectItem, System.String) + // cref: ArcGIS.Core.CIM.CIMColorRamp + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CreateRenderer() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer() + // cref: ARCGIS.DESKTOP.MAPPING.STYLEHELPER.SearchColorRamps + // cref: ArcGIS.Desktop.Mapping.UniqueValueRendererDefinition._CTOR + // cref: ArcGIS.Desktop.Mapping.ColorRampStyleItem.ColorRamp + // cref: ArcGIS.Core.CIM.CIMSimpleRenderer.Symbol + // cref: ArcGIS.Core.CIM.CIMSymbol.MakeSymbolReference + // cref: ArcGIS.Core.CIM.CIMSymbol.SetRealWorldUnits + #region How to apply a color ramp from a style to a feature layer + + public async Task ApplyColorRampAsync(FeatureLayer featureLayer, List fields) + { + + StyleProjectItem style = + Project.Current.GetItems() + .FirstOrDefault(s => s.Name == "ColorBrewer Schemes (RGB)"); + if (style == null) return; + var colorRampList = await QueuedTask.Run(() => + style.SearchColorRamps("Red-Gray (10 Classes)")); + if (colorRampList == null || colorRampList.Count == 0) return; + CIMColorRamp cimColorRamp = null; + CIMRenderer renderer = null; + await QueuedTask.Run(() => + { + cimColorRamp = colorRampList[0].ColorRamp; + var rendererDef = new UniqueValueRendererDefinition(fields, null, cimColorRamp); + renderer = featureLayer?.CreateRenderer(rendererDef); + featureLayer?.SetRenderer(renderer); + }); + + } + #endregion + + } +} diff --git a/Examples/MapAuthoring/MapAuthoring.csproj b/Examples/MapAuthoring/MapAuthoring.csproj new file mode 100644 index 0000000..0caae50 --- /dev/null +++ b/Examples/MapAuthoring/MapAuthoring.csproj @@ -0,0 +1,85 @@ + + + net6.0-windows + true + win10-x64 + false + true + CA1416 + + + + + + + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll + False + + + C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll + False + + + \ No newline at end of file diff --git a/Examples/MapAuthoring/ProSnippet.cs b/Examples/MapAuthoring/ProSnippet.cs index e870b21..a6c5afc 100644 --- a/Examples/MapAuthoring/ProSnippet.cs +++ b/Examples/MapAuthoring/ProSnippet.cs @@ -42,6 +42,9 @@ class ProSnippet #endregion public void GetActiveMapAsync() { + // cref: ArcGIS.Desktop.Mapping.MapView.Active + // cref: ArcGIS.Desktop.Mapping.MapView.Map + // cref: ArcGIS.Desktop.Mapping.Map #region Get the active map Map map = MapView.Active.Map; @@ -52,8 +55,8 @@ public void GetActiveMapAsync() public async Task CreateMapAsync(string mapName) { - // cref: Create a new map with a default basemap layer;ArcGIS.Desktop.Mapping.MapFactory.CreateMap(System.String,ArcGIS.Core.CIM.MapType,ArcGIS.Core.CIM.MapViewingMode,ArcGIS.Desktop.Mapping.Basemap) - // cref: Create a new map with a default basemap layer;ArcGIS.Desktop.Mapping.Map + // cref: ArcGIS.Desktop.Mapping.MapFactory.CreateMap(System.String,ArcGIS.Core.CIM.MapType,ArcGIS.Core.CIM.MapViewingMode,ArcGIS.Desktop.Mapping.Basemap) + // cref: ArcGIS.Desktop.Mapping.Map #region Create a new map with a default basemap layer await QueuedTask.Run(() => @@ -65,7 +68,10 @@ await QueuedTask.Run(() => #endregion } - // cref: Find a map within a project and open it;ArcGIS.Desktop.Mapping.Map + // cref: ArcGIS.Desktop.Mapping.MapProjectItem + // cref: ArcGIS.Desktop.Mapping.MapProjectItem.GetMap() + // cref: ArcGIS.Desktop.Mapping.Map + // cref: ArcGIS.Desktop.Core.FrameworkExtender.CreateMapPaneAsync(ArcGIS.Desktop.Framework.PaneCollection, ArcGIS.Desktop.Mapping.Map, ArcGIS.Desktop.Mapping.MapViewingMode, ArcGIS.Desktop.Mapping.TimeRange) #region Find a map within a project and open it public static async Task FindOpenExistingMapAsync(string mapName) { @@ -94,8 +100,10 @@ public static async Task FindOpenExistingMapAsync(string mapName) public async Task OpenWebMapAsync() { - // cref: Open a webmap;ArcGIS.Desktop.Mapping.MapFactory.CreateMapFromItem(ArcGIS.Desktop.Core.Item) - // cref: Open a webmap;ArcGIS.Desktop.Mapping.Map + // cref: ArcGIS.Desktop.Mapping.MapFactory.CanCreateMapFrom(ArcGIS.Desktop.Core.Item) + // cref: ArcGIS.Desktop.Mapping.MapFactory.CreateMapFromItem(ArcGIS.Desktop.Core.Item) + // cref: ArcGIS.Desktop.Mapping.Map + // cref: ArcGIS.Desktop.Core.FrameworkExtender.CreateMapPaneAsync(ArcGIS.Desktop.Framework.PaneCollection, ArcGIS.Desktop.Mapping.Map, ArcGIS.Desktop.Mapping.MapViewingMode, ArcGIS.Desktop.Mapping.TimeRange) #region Open a webmap Map map = null; @@ -114,6 +122,7 @@ public async Task OpenWebMapAsync() return map; } + // cref: ArcGIS.Desktop.Mapping.IMapPane #region Get Map Panes public static IEnumerable GetMapPanes() { @@ -122,6 +131,9 @@ public static IEnumerable GetMapPanes() } #endregion + // cref: ArcGIS.Desktop.Mapping.IMapPane + // cref: ArcGIS.Desktop.Mapping.IMapPane.MapView + // cref: ArcGIS.Desktop.Mapping.Map.URI #region Get the Unique List of Maps From the Map Panes public static IReadOnlyList GetMapsFromMapPanes() { @@ -142,12 +154,14 @@ public void ModifyMapAndPane() { QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.Map.SetName #region Change the Map name ////Note: call within QueuedTask.Run() MapView.Active.Map.SetName("Test"); #endregion }); + // cref: ArcGIS.Desktop.Framework.Contracts.Pane.Caption #region Renames the caption of the pane ProApp.Panes.ActivePane.Caption = "Caption"; #endregion @@ -159,6 +173,9 @@ private Task ConvertMapToScene(Map map) if (map == null) return Task.FromResult(0); return QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.MapFactory.CanConvertMap(ArcGIS.Desktop.Mapping.Map, ArcGIS.Desktop.Mapping.MapConversionType) + // cref: ArcGIS.Desktop.Mapping.MapConversionType + // cref: ArcGIS.Desktop.Mapping.MapFactory.ConvertMap(ArcGIS.Desktop.Mapping.Map, ArcGIS.Desktop.Mapping.MapConversionType, System.Boolean) #region Convert Map to Local Scene //Note: Run within the context of QueuedTask.Run bool canConvertMap = MapFactory.Instance.CanConvertMap(map, MapConversionType.SceneLocal); @@ -170,6 +187,8 @@ private Task ConvertMapToScene(Map map) private async void GetBasemaps() { + // cref: ArcGIS.Desktop.Core.ArcGISPortalExtensions.GetBasemapsAsync(ArcGIS.Desktop.Core.ArcGISPortal) + // cref: ArcGIS.Desktop.Core.Portal.PortalItem #region Get Basemaps //Basemaps stored locally in the project. This is usually an empty collection @@ -196,12 +215,14 @@ private void SaveMap() { Map map = null; + // cref: ArcGIS.Desktop.Mapping.Map.SaveAsFile(System.String, System.Boolean) #region Save Map as MapX - map.SaveAsFile(@"C:\Data\MyMap.mapx"); + map.SaveAsFile(@"C:\Data\MyMap.mapx", true); #endregion + // cref: ArcGIS.Desktop.Mapping.Map.SaveAsWebMapFile(System.String) #region Save 2D Map as WebMap on Disk //2D maps only @@ -214,10 +235,11 @@ private void SaveMap() } - private void ClipMap() + private void ClipMap() { QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.Map.SetClipGeometry(ArcGIS.Core.Geometry.Polygon, ArcGIS.Core.CIM.CIMLineSymbol) #region Clip Map to the provided clip polygon //Run within QueuedTask var map = MapView.Active.Map; @@ -225,7 +247,7 @@ private void ClipMap() var lyrOfInterest = MapView.Active.Map.GetLayersAsFlattenedList().OfType().Where(l => l.Name == "TestPoly").FirstOrDefault(); //Get the polygon to use to clip the map var extent = lyrOfInterest.QueryExtent(); - var polygonForClipping = PolygonBuilder.CreatePolygon(extent); + var polygonForClipping = PolygonBuilderEx.CreatePolygon(extent); //Clip the map using the layer's extent map.SetClipGeometry(polygonForClipping, SymbolFactory.Instance.ConstructLineSymbol( @@ -239,6 +261,7 @@ private void ClearClipMap() { QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.Map.ClearClipGeometry() #region Clear the current map clip geometry //Run within QueuedTask var map = MapView.Active.Map; @@ -253,6 +276,7 @@ private void GetClipMapGeometry() { QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.Map.GetClipGeometry() #region Get the map clipping geometry var map = MapView.Active.Map; //If clipping is set to ArcGIS.Core.CIM.ClippingMode.None or ArcGIS.Core.CIM.ClippingMode.MapSeries null is returned @@ -275,9 +299,13 @@ private void GetClipMapGeometry() } public void LocationUnit1() - { + { Map map = null; + // cref: ArcGIS.Desktop.Mapping.Map.GetLocationUnitFormat() + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat.DisplayName + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat.UnitCode #region Get the Current Map Location Unit //var map = MapView.Active.Map; @@ -295,6 +323,8 @@ public void LocationUnit1b() { Map map = null; + // cref: ArcGIS.Desktop.Mapping.Map.GetAvailableLocationUnitFormats() + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat #region Get the Available List of Map Location Units //var map = MapView.Active.Map; @@ -309,6 +339,9 @@ public void LocationUnit1b() public void LocationUnit2() { + // cref: ArcGIS.Desktop.Mapping.Map.GetLocationUnitFormat() + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat.FormatLocation(ArcGIs.Core.Geometry.Coordinate2D, ArcGIS.Core.Geometry.SpatialReference) #region Format a Location Using the Current Map Location Unit var mv = MapView.Active; @@ -331,6 +364,9 @@ public void LocationUnit2() public void LocationUnit3() { + // cref: ArcGIS.Desktop.Mapping.Map.GetAvailableLocationUnitFormats() + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat + // cref: ArcGIS.Desktop.Mapping.Map.SetLocationUnitFormat(ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat) #region Set the Location Unit for the Current Map var mv = MapView.Active; @@ -353,6 +389,8 @@ public void ElevationUnit1() { Map map = null; + // cref: ArcGIS.Desktop.Mapping.Map.GetElevationUnitFormat() + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat #region Get the Current Map Elevation Unit //var map = MapView.Active.Map; @@ -371,6 +409,8 @@ public void ElevationUnit1b() { Map map = null; + // cref: ArcGIS.Desktop.Mapping.Map.GetAvailableElevationUnitFormats() + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat #region Get the Available List of Map Elevation Units //var map = MapView.Active.Map; @@ -385,6 +425,9 @@ public void ElevationUnit1b() public void ElevationUnit2() { + // cref: ArcGIS.Desktop.Mapping.Map.GetElevationUnitFormat() + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat.FormatValue(System.Double) #region Format an Elevation Using the Current Map Elevation Unit var mv = MapView.Active; @@ -407,6 +450,9 @@ public void ElevationUnit2() public void ElevationUnit3() { + // cref: ArcGIS.Desktop.Mapping.Map.GetAvailableElevationUnitFormats() + // cref: ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat + // cref: ArcGIS.Desktop.Mapping.Map.SetElevationUnitFormat( ArcGIS.Desktop.Core.UnitFormats.DisplayUnitFormat) #region Set the Elevation Unit for the Current Map var map = MapView.Active.Map; @@ -415,25 +461,26 @@ public void ElevationUnit3() { //Trying to set the elevation unit on a map other than //a scene will throw an InvalidOperationException - if (map.IsScene) - { - //Get the list of available elevation unit formats - //for the current map - var loc_units = map.GetAvailableElevationUnitFormats(); + if (map.IsScene) + { + //Get the list of available elevation unit formats + //for the current map + var loc_units = map.GetAvailableElevationUnitFormats(); //arbitrarily use the last unit in the list map.SetElevationUnitFormat(loc_units.Last()); } - + }); #endregion } - #region ProSnippet Group: Offline Map - #endregion + #region ProSnippet Group: Offline Map + #endregion public void OfflineMaps1() - { + { + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetCanGenerateReplicas(ArcGIS.Desktop.Mapping.Map) #region Check Map Has Sync-Enabled Content //namespace ArcGIS.Desktop.Mapping.Offline @@ -444,15 +491,21 @@ public void OfflineMaps1() { var hasSyncEnabledContent = GenerateOfflineMap.Instance.GetCanGenerateReplicas(map); if (hasSyncEnabledContent) - { + { //TODO - use status... - } + } }); #endregion } public void OfflineMaps2() { + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetCanGenerateReplicas(ArcGIS.Desktop.Mapping.Map) + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GenerateReplicas(ArcGIS.Desktop.Mapping.Map, ArcGIS.Desktop.Mapping.Offline.GenerateReplicaParams) + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateReplicaParams + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateReplicaParams.#ctor + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateReplicaParams.Extent + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateReplicaParams.DestinationFolder #region Generate Replicas for Sync-Enabled Content //namespace ArcGIS.Desktop.Mapping.Offline @@ -487,6 +540,7 @@ public void OfflineMaps2() public void OfflineMaps3() { + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetCanSynchronizeReplicas(ArcGIS.Desktop.Mapping.Map) #region Check Map Has Local Syncable Content //namespace ArcGIS.Desktop.Mapping.Offline @@ -507,6 +561,8 @@ public void OfflineMaps3() public void OfflineMaps4() { + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetCanSynchronizeReplicas(ArcGIS.Desktop.Mapping.Map) + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.SynchronizeReplicas(ArcGIS.Desktop.Mapping.Map) #region Synchronize Replicas for Syncable Content //namespace ArcGIS.Desktop.Mapping.Offline @@ -530,6 +586,8 @@ public void OfflineMaps4() public void OfflineMaps5() { + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetCanRemoveReplicas(ArcGIS.Desktop.Mapping.Map) + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.RemoveReplicas(ArcGIS.Desktop.Mapping.Map) #region Remove Replicas for Syncable Content //namespace ArcGIS.Desktop.Mapping.Offline @@ -558,6 +616,14 @@ public void OfflineMaps5() public void OfflineMaps6() { + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetCanExportRasterTileCache(ArcGIS.Desktop.Mapping.Map) + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetExportRasterTileCacheScales(ArcGIS.Desktop.Mapping.Map, ArcGIs.Core.Geometry.Envelope) + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams.#ctor + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams.Extent + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams.MaximumUserDefinedScale + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams.DestinationFolder + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.ExportRasterTileCache(ArcGIS.Desktop.Mapping.Map, ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams) #region Export Map Raster Tile Cache Content //namespace ArcGIS.Desktop.Mapping.Offline @@ -598,6 +664,14 @@ public void OfflineMaps6() public void OfflineMaps7() { + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetCanExportVectorTileCache(ArcGIS.Desktop.Mapping.Map) + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.GetExportVectorTileCacheScales(ArcGIS.Desktop.Mapping.Map, ArcGIs.Core.Geometry.Envelope) + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams.#ctor + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams.Extent + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams.MaximumUserDefinedScale + // cref: ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams.DestinationFolder + // cref: ArcGIS.Desktop.Mapping.Offline.GenerateOfflineMap.ExportVectorTileCache(ArcGIS.Desktop.Mapping.Map, ArcGIS.Desktop.Mapping.Offline.ExportTileCacheParams) #region Export Map Vector Tile Cache Content //namespace ArcGIS.Desktop.Mapping.Offline @@ -642,8 +716,7 @@ public async Task AddLayerAsync() { Map map = null; - // cref: Create and add a layer to the active map;ArcGIS.Desktop.Mapping.LayerFactory - // cref: Create and add a layer to the active map;ArcGIS.Desktop.Mapping.Map + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(System.Uri, ArcGIS.Desktop.Mapping.ILayerContainerEdit, System.Int32, System.String) #region Create and add a layer to the active map /* @@ -665,7 +738,12 @@ public async Task AddLayerAsync() #endregion - // cref: Create layer with create-params;ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer``1(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit,ArcGIS.Desktop.Mapping.LayerPosition) + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams.#ctor(System.Uri) + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams.DefinitionQuery + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams.RendererDefinition + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create layer with create-params var flyrCreatnParam = new FeatureLayerCreationParams(new Uri(@"c:\data\world.gdb\cities")) { @@ -673,11 +751,12 @@ public async Task AddLayerAsync() IsVisible = false, MinimumScale = 1000000, MaximumScale = 5000, - DefinitionFilter = new CIMDefinitionFilter() - { - DefinitionExpression = "Population > 100000", - Name = "More than 100k" - }, + // At 2.x - DefinitionFilter = new CIMDefinitionFilter() + //{ + // DefinitionExpression = "Population > 100000", + // Name = "More than 100k" + //}, + DefinitionQuery = new DefinitionQuery(whereClause: "Population > 100000", name: "More than 100k"), RendererDefinition = new SimpleRendererDefinition() { SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol( @@ -686,13 +765,19 @@ public async Task AddLayerAsync() }; var featureLayer = LayerFactory.Instance.CreateLayer( - flyrCreatnParam, map, LayerPosition.AutoArrange); + flyrCreatnParam, map); #endregion } public static void CreateLayerWithParams() { + // cref: ArcGIS.Desktop.Mapping.LayerDocument + // cref: ArcGIS.Desktop.Mapping.LayerDocument.#ctor(System.String) + // cref: ArcGIS.Desktop.Mapping.LayerDocument.GetCIMLayerDocument() + // cref: ArcGIS.Desktop.Mapping.LayerCreationParams.#ctor(ArcGIS.Core.CIM.CIMLayerDocument) + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create FeatureLayer and add to Map using LayerCreationParams //Note: Call within QueuedTask.Run() var layerDoc = new LayerDocument(@"E:\Data\SDK\Default2DPointSymbols.lyrx"); @@ -740,16 +825,21 @@ public static FeatureLayer CreateLayerWithOptions() //The catalog path of the feature layer to add to the map var featureClassUriDefinition = new Uri(@"C:\Data\Admin\AdminData.gdb\USA\cities"); //Define the Feature Layer's parameters. + //At 2.x - var layerParamsQueryDefn = new FeatureLayerCreationParams(featureClassUriDefinition) + //{ + // IsVisible = true, + // DefinitionFilter = new CIMDefinitionFilter() + // { + // Name = "CACities", + // DefinitionExpression = "STATE_NAME = 'California'" + // } + //}; var layerParamsQueryDefn = new FeatureLayerCreationParams(featureClassUriDefinition) { IsVisible = true, - DefinitionFilter = new CIMDefinitionFilter() - { - Name = "CACities", - DefinitionExpression = "STATE_NAME = 'California'" - } - + DefinitionQuery = new DefinitionQuery(whereClause: "STATE_NAME = 'California'", name: "CACities") }; + //Create the layer with the feature layer parameters and add it to the active map var createdFCWithQueryDefn = LayerFactory.Instance.CreateLayer(layerParamsQueryDefn, MapView.Active.Map); #endregion @@ -759,16 +849,21 @@ public static FeatureLayer CreateLayerWithOptions() private async void MapNotesAPI() { + // cref: ArcGIS.Desktop.Mapping.Map.LayerTemplatePackages + // cref: ArcGIS.Desktop.Mapping.LayerCreationParams.#ctor(ArcGIS.Desktop.Core.Item) + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Add MapNotes to the active map //Gets the collection of layer template packages installed with Pro for use with maps - var items = MapView.Active.Map.LayerTemplatePackages; + var items = MapView.Active.Map.LayerTemplatePackages; //Iterate through the collection of items to add each Map Note to the active map foreach (var item in items) { //Create a parameter item for the map note var layer_params = new LayerCreationParams(item); layer_params.IsVisible = false; - await QueuedTask.Run(() => { + await QueuedTask.Run(() => + { //Create a feature layer for the map note var layer = LayerFactory.Instance.CreateLayer(layer_params, MapView.Active.Map); }); @@ -778,9 +873,14 @@ await QueuedTask.Run(() => { public static void CreateLayerUsingDocument() { + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetRenderer() + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams.#ctor(ArcGIS.Core.CIM.CIMDataConnection) + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams.RendererDefinition + // cref: ArcGIS.Desktop.Mapping.SimpleRendererDefinition #region Apply Symbology from a Layer in the TOC //Note: Call within QueuedTask.Run() if (MapView.Active.Map == null) return; + //Get an existing Layer. This layer has a symbol you want to use in a new layer. var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType() .Where(l => l.ShapeType == esriGeometryType.esriGeometryPoint).FirstOrDefault(); @@ -799,14 +899,22 @@ public static void CreateLayerUsingDocument() }; //create the new layer LayerFactory.Instance.CreateLayer( - featureLayerParams, MapView.Active.Map, LayerPosition.AutoArrange); + featureLayerParams, MapView.Active.Map); #endregion } private void CreateSubTypeLayers() { - // cref: Create a new SubTypeGroupLayer;ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer``1(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit,ArcGIS.Desktop.Mapping.LayerPosition) - // cref: Create a new SubTypeGroupLayer;ArcGIS.Desktop.Mapping.SubtypeGroupLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.SubtypeGroupLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.SubtypeGroupLayerCreationParams.#ctor(System.Uri) + // cref: ArcGIS.Desktop.Mapping.SubtypeGroupLayerCreationParams.SubtypeLayers + // cref: ArcGIS.Desktop.Mapping.SubtypeFeatureLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.SubtypeFeatureLayerCreationParams.#ctor(ArcGIS.Desktop.Mapping.RendererDefinition, System.Int32) + // cref: ArcGIS.Desktop.Mapping.SubtypeGroupLayerCreationParams.SubtypeLayers + // cref: ArcGIS.Desktop.Mapping.SubtypeGroupLayerCreationParams.DefinitionQuery + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory + // cref: ArcGIS.Desktop.Mapping.SubtypeGroupLayer #region Create a new SubTypeGroupLayer var subtypeGroupLayerCreateParam = new SubtypeGroupLayerCreationParams ( @@ -814,33 +922,30 @@ private void CreateSubTypeLayers() ); // Define Subtype layers + //At 2.x - var rendererDefn1 = new UniqueValueRendererDefinition(new string[] { "type" }); + var rendererDefn1 = new UniqueValueRendererDefinition(new List { "type" }); + var renderDefn2 = new SimpleRendererDefinition() + { + SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol( + CIMColor.CreateRGBColor(255, 0, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference() + }; subtypeGroupLayerCreateParam.SubtypeLayers = new List() { //define first subtype layer with unique value renderer - new SubtypeFeatureLayerCreationParams() - { - SubtypeId = 1, - RendererDefinition = new UniqueValueRendererDefinition(new string[] { "type" }) - }, + //At 2.x - new SubtypeFeatureLayerCreationParams(new UniqueValueRendererDefinition(new string[] { "type" }), 1), + new SubtypeFeatureLayerCreationParams(new UniqueValueRendererDefinition(new List { "type" }), 1), //define second subtype layer with simple symbol renderer - new SubtypeFeatureLayerCreationParams() - { - SubtypeId = 2, - RendererDefinition = new SimpleRendererDefinition() - { - SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol( - CIMColor.CreateRGBColor(255, 0, 0), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference() - } - } + new SubtypeFeatureLayerCreationParams(renderDefn2, 2) }; // Define additional parameters - subtypeGroupLayerCreateParam.DefinitionFilter = new CIMDefinitionFilter() - { - Name = "IsActive", - DefinitionExpression = "Enabled = 1" - }; + //At - 2.x subtypeGroupLayerCreateParam.DefinitionFilter = new CIMDefinitionFilter() + //{ + // Name = "IsActive", + // DefinitionExpression = "Enabled = 1" + //}; + subtypeGroupLayerCreateParam.DefinitionQuery = new DefinitionQuery(whereClause: "Enabled = 1", name: "IsActive"); subtypeGroupLayerCreateParam.IsVisible = true; subtypeGroupLayerCreateParam.MinimumScale = 50000; @@ -853,8 +958,15 @@ public async Task CreateLayerFromALyrxFile() { Map map = null; - // cref: create layer from a lyrx file;ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer``1(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit,ArcGIS.Desktop.Mapping.LayerPosition) - // cref: create layer from a lyrx file;ArcGIS.Desktop.Mapping.LayerDocument + // cref: ArcGIS.Desktop.Mapping.LayerDocument + // cref: ArcGIS.Desktop.Mapping.LayerDocument.#ctor(System.String) + // cref: ArcGIS.Desktop.Mapping.LayerDocument.GetCIMLayerDocument + // cref: ArcGIS.Core.CIM.CIMLayerDocument.LayerDefinitions + // cref: ArcGIS.Desktop.Mapping.LayerDocument.Save(System.String) + // cref: ArcGIS.Desktop.Mapping.LayerDocument.AsJson() + // cref: ArcGIS.Desktop.Mapping.LayerDocument.Load(System.String) + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create layer from a lyrx file var lyrDocFromLyrxFile = new LayerDocument(@"d:\data\cities.lyrx"); var cimLyrDoc = lyrDocFromLyrxFile.GetCIMLayerDocument(); @@ -875,15 +987,22 @@ public async Task CreateLayerFromALyrxFile() //create a layer and add it to a map var lcp = new LayerCreationParams(cimLyrDoc); - var lyr = LayerFactory.Instance.CreateLayer(lcp, map, LayerPosition.AutoArrange); + var lyr = LayerFactory.Instance.CreateLayer(lcp, map); #endregion } + private static async Task ModifyLayerSymbologyFromLyrFileAsync(IEnumerable featureLayers, string layerFile) { await QueuedTask.Run(() => { foreach (var featureLayer in featureLayers) { + // cref: ArcGIS.Desktop.Mapping.LayerDocument + // cref: ArcGIS.Desktop.Mapping.LayerDocument.#ctor(System.String) + // cref: ArcGIS.Desktop.Mapping.LayerDocument.GetCIMLayerDocument + // cref: ArcGIS.Core.CIM.CIMLayerDocument.LayerDefinitions + // cref: ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.Renderer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(ArcGIS.Core.CIM.CIMRenderer) #region Apply Symbology to a layer from a Layer file //Note: Run within QueuedTask.Run //Get the Layer Document from the lyrx file @@ -906,20 +1025,38 @@ await QueuedTask.Run(() => public async Task AddWMSLayerAsync() { { + // cref: ArcGIS.Core.CIM.CIMInternetServerConnection + // cref: ArcGIS.Core.CIM.CIMInternetServerConnection.#ctor + // cref: ArcGIS.Core.CIM.CIMWMSServiceConnection + // cref: ArcGIS.Core.CIM.CIMWMSServiceConnection.#ctor + // cref: ArcGIS.Desktop.Mapping.LayerCreationParams.#ctor(ArcGIS.Core.CIM.CIMDataConnection) + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Add a WMS service // Create a connection to the WMS server var serverConnection = new CIMInternetServerConnection { URL = "URL of the WMS service" }; var connection = new CIMWMSServiceConnection { ServerConnection = serverConnection }; // Add a new layer to the map + var layerParams = new LayerCreationParams(connection); await QueuedTask.Run(() => { - var layer = LayerFactory.Instance.CreateLayer(connection, MapView.Active.Map); + var layer = LayerFactory.Instance.CreateLayer(layerParams, MapView.Active.Map); }); #endregion } { + // cref: ArcGIS.Core.CIM.CIMStandardDataConnection + // cref: ArcGIS.Core.CIM.CIMStandardDataConnection.#ctor + // cref: ArcGIS.Core.CIM.CIMStandardDataConnection.WorkspaceConnectionString + // cref: ArcGIS.Core.CIM.CIMStandardDataConnection.WorkspaceFactory + // cref: ArcGIS.Core.CIM.CIMStandardDataConnection.Dataset + // cref: ArcGIS.Core.CIM.CIMStandardDataConnection.DatasetType + // cref: ArcGIS.Core.CIM.esriDatasetType + // cref: ArcGIS.Desktop.Mapping.LayerCreationParams.#ctor(ArcGIS.Core.CIM.CIMDataConnection) + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Add a WFS Service CIMStandardDataConnection cIMStandardDataConnection = new CIMStandardDataConnection() { @@ -930,18 +1067,63 @@ await QueuedTask.Run(() => }; // Add a new layer to the map + var layerPamsDC = new LayerCreationParams(cIMStandardDataConnection); await QueuedTask.Run(() => { - Layer layer = LayerFactory.Instance.CreateLayer(cIMStandardDataConnection, MapView.Active.Map); + Layer layer = LayerFactory.Instance.CreateLayer(layerPamsDC, MapView.Active.Map); }); #endregion } } + + + public async Task StyleWMSLayer() + { + // cref: ArcGIS.Desktop.Mapping.MapMemberPosition + // cref: ArcGIS.Desktop.Mapping.WMSLayer + // cref: ArcGIS.Desktop.Mapping.ServiceCompositeSubLayer + // cref: ArcGIS.Desktop.Mapping.WMSSubLayer + // cref: ArcGIS.Desktop.Mapping.WMSSubLayer.GetStyleNames + // cref: ArcGIS.Desktop.Mapping.WMSSubLayer.SetStyleName(System.String) + #region Adding and changing styles for WMS Service Layer + var serverConnection = new CIMInternetServerConnection { URL = "https://spritle.esri.com/arcgis/services/sanfrancisco_sld/MapServer/WMSServer" }; + var connection = new CIMWMSServiceConnection { ServerConnection = serverConnection }; + LayerCreationParams parameters = new LayerCreationParams(connection); + parameters.MapMemberPosition = MapMemberPosition.AddToBottom; + await QueuedTask.Run(() => + { + var compositeLyr = LayerFactory.Instance.CreateLayer(parameters, MapView.Active.Map); + //wms layer in ArcGIS Pro always has a composite layer inside it + var wmsLayers = compositeLyr.Layers[0] as ServiceCompositeSubLayer; + //each wms sublayer belongs in that composite layer + var highwayLayerWMSSub = wmsLayers.Layers[1] as WMSSubLayer; + //toggling a sublayer's visibility + if ((highwayLayerWMSSub != null)) + { + bool visibility = highwayLayerWMSSub.IsVisible; + highwayLayerWMSSub.SetVisibility(!visibility); + } + //applying an existing style to a wms sub layer + var pizzaLayerWMSSub = wmsLayers.Layers[0] as WMSSubLayer; + var currentStyles = pizzaLayerWMSSub.GetStyleNames(); + pizzaLayerWMSSub.SetStyleName(currentStyles[1]); + }); + #endregion + } public async Task AddQuerylayerAsync() { - // cref: Create a query layer;ArcGIS.Desktop.Mapping.LayerFactory.CreateFeatureLayer(ArcGIS.Core.CIM.CIMDataConnection,ArcGIS.Desktop.Mapping.ILayerContainerEdit,ArcGIS.Desktop.Mapping.LayerPosition,System.String,ArcGIS.Desktop.Mapping.RendererDefinition) - // cref: Create a query layer;ArcGIS.Desktop.Mapping.LayerFactory.CreateFeatureLayer(ArcGIS.Core.CIM.CIMDataConnection,ArcGIS.Desktop.Mapping.ILayerContainerEdit,System.Int32,System.String,ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Core.CIM.CIMSqlQueryDataConnection + // cref: ArcGIS.Core.CIM.CIMSqlQueryDataConnection.#ctor + // cref: ArcGIS.Core.CIM.CIMSqlQueryDataConnection.WorkspaceConnectionString + // cref: ArcGIS.Core.CIM.CIMSqlQueryDataConnection.GeometryType + // cref: ArcGIS.Core.CIM.CIMSqlQueryDataConnection.OIDFields + // cref: ArcGIS.Core.CIM.CIMSqlQueryDataConnection.Srid + // cref: ArcGIS.Core.CIM.CIMSqlQueryDataConnection.SqlQuery + // cref: ArcGIS.Core.CIM.CIMSqlQueryDataConnection.Dataset + // cref: ArcGIS.Desktop.Mapping.LayerCreationParams.#ctor(ArcGIS.Core.CIM.CIMDataConnection) + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams,ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create a query layer await QueuedTask.Run(() => { @@ -956,32 +1138,54 @@ await QueuedTask.Run(() => SqlQuery = "select * from MySDE.dbo.STATES", Dataset = "States" }; - FeatureLayer flyr = (FeatureLayer)LayerFactory.Instance.CreateLayer(sqldc, map, layerName: "States"); + var lcp = new LayerCreationParams(sqldc) + { + Name = "States" + }; + FeatureLayer flyr = LayerFactory.Instance.CreateLayer(lcp, map); }); #endregion } public async Task AddFeatureLayerClasBreaksAsync() { - - // cref: Create a feature layer with class breaks renderer with defaults;ArcGIS.Desktop.Mapping.LayerFactory.CreateFeatureLayer(System.Uri,ArcGIS.Desktop.Mapping.ILayerContainerEdit,ArcGIS.Desktop.Mapping.LayerPosition,System.String,ArcGIS.Desktop.Mapping.RendererDefinition) - // cref: Create a feature layer with class breaks renderer with defaults;ArcGIS.Desktop.Mapping.LayerFactory.CreateFeatureLayer(System.Uri,ArcGIS.Desktop.Mapping.ILayerContainerEdit,System.Int32,System.String,ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Desktop.Mapping.GraduatedColorsRendererDefinition + // cref: ArcGIS.Core.CIM.ClassificationMethod + // cref: ArcGIS.Desktop.Mapping.GraduatedColorsRendererDefinition.#ctor(System.String, ArcGIS.Core.CIM.ClassificationMethod, System.Int32, ArcGIS.Core.CIM.CIMColorRamp, ArcGIS.Core.CIM.CIMSymbolReference) #region Create a feature layer with class breaks renderer with defaults await QueuedTask.Run(() => - LayerFactory.Instance.CreateFeatureLayer( - new Uri(@"c:\data\countydata.gdb\counties"), - MapView.Active.Map, - layerName: "Population Density (sq mi) Year 2010", - rendererDefinition: new GraduatedColorsRendererDefinition("POP10_SQMI") - ) - ); + { + var featureLayerCreationParams = new FeatureLayerCreationParams(new Uri(@"c:\data\countydata.gdb\counties")) + { + Name = "Population Density (sq mi) Year 2010", + RendererDefinition = new GraduatedColorsRendererDefinition("POP10_SQMI") + }; + LayerFactory.Instance.CreateLayer( + featureLayerCreationParams, + MapView.Active.Map + ); + }); #endregion } public async Task AddFeatureLayerClasBreaksExAsync() { - // cref: Create a feature layer with class breaks renderer;ArcGIS.Desktop.Mapping.LayerFactory.CreateFeatureLayer(System.Uri,ArcGIS.Desktop.Mapping.ILayerContainerEdit,ArcGIS.Desktop.Mapping.LayerPosition,System.String,ArcGIS.Desktop.Mapping.RendererDefinition) - // cref: Create a feature layer with class breaks renderer;ArcGIS.Desktop.Mapping.LayerFactory.CreateFeatureLayer(System.Uri,ArcGIS.Desktop.Mapping.ILayerContainerEdit,System.Int32,System.String,ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Desktop.Mapping.GraduatedColorsRendererDefinition + // cref: ArcGIS.Core.CIM.ClassificationMethod + // cref: ArcGIS.Desktop.Mapping.GraduatedColorsRendererDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.GraduatedColorsRendererDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.GraduatedColorsRendererDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.ClassBreaksRendererDefinition.ClassificationField + // cref: ArcGIS.Desktop.Mapping.ClassBreaksRendererDefinition.ClassificationMethod + // cref: ArcGIS.Desktop.Mapping.ClassBreaksRendererDefinition.BreakCount + // cref: ArcGIS.Desktop.Mapping.ClassBreaksRendererDefinition.ColorRamp + // cref: ArcGIS.Desktop.Mapping.ClassBreaksRendererDefinition.SymbolTemplate + // cref: ArcGIS.Desktop.Mapping.ClassBreaksRendererDefinition.ExclusionClause + // cref: ArcGIS.Desktop.Mapping.ClassBreaksRendererDefinition.ExclusionSymbol + // cref: ArcGIS.Desktop.Mapping.ClassBreaksRendererDefinition.ExclusionLabel + // cref: ArcGIS.Desktop.Mapping.ColorRampStyleItem + // cref: ArcGIS.Desktop.Mapping.ColorRampStyleItem.ColorRamp + // cref: ArcGIS.Desktop.Mapping.StyleHelper.SearchColorRamps(ArcGIS.Desktop.Mapping.StyleProjectItem, System.String) #region Create a feature layer with class breaks renderer string colorBrewerSchemesName = "ColorBrewer Schemes (RGB)"; @@ -1008,9 +1212,12 @@ await QueuedTask.Run(() => ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, null).MakeSymbolReference(), ExclusionLabel = "No yield", }; - - LayerFactory.Instance.CreateFeatureLayer(new Uri(@"c:\Data\CountyData.gdb\Counties"), - MapView.Active.Map, layerName: "Crop", rendererDefinition: gcDef); + var featureLayerCreationParams = new FeatureLayerCreationParams((new Uri(@"c:\Data\CountyData.gdb\Counties"))) + { + Name = "Crop", + RendererDefinition = gcDef + }; + LayerFactory.Instance.CreateLayer(featureLayerCreationParams, MapView.Active.Map); }); #endregion @@ -1022,11 +1229,12 @@ private void BaseMap() { Map aMap = null; + // cref: ArcGIS.Desktop.Mapping.Map.SetBasemapLayers(ArcGIS.Desktop.Mapping.Basemap) #region Update a map's basemap layer aMap.SetBasemapLayers(Basemap.Gray); #endregion - // cref: Remove basemap layer from a map;ArcGIS.Desktop.Mapping.Map.SetBasemapLayers(ArcGIS.Desktop.Mapping.Basemap) + // cref: ArcGIS.Desktop.Mapping.Map.SetBasemapLayers(ArcGIS.Desktop.Mapping.Basemap) #region Remove basemap layer from a map aMap.SetBasemapLayers(Basemap.None); #endregion @@ -1039,12 +1247,22 @@ public void Simple() { Map aMap = null; - // cref: Get a list of layers filtered by layer type from a map;ArcGIS.Desktop.Mapping.Map.GetLayersAsFlattenedList + // cref: ArcGIS.Desktop.Mapping.Map.GetLayersAsFlattenedList #region Get a list of layers filtered by layer type from a map List featureLayerList = aMap.GetLayersAsFlattenedList().OfType().ToList(); #endregion - // cref: Find a layer;ArcGIS.Desktop.Mapping.Map.FindLayer(System.String,System.Boolean) + // cref: ArcGIS.Desktop.Mapping.Map.GetLayersAsFlattenedList + // cref: ArcGIS.Desktop.Mapping.BasicFeatureLayer.ShapeType + #region Get a layer of a certain geometry type + //Get an existing Layer. This layer has a symbol you want to use in a new layer. + var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType() + .Where(l => l.ShapeType == esriGeometryType.esriGeometryPoint).FirstOrDefault(); + #endregion + + // cref: ArcGIS.Desktop.Mapping.Map.FindLayer(System.String,System.Boolean) + // cref: ArcGIS.Desktop.Mapping.Map.FindLayers(System.String,System.Boolean) + // cref: ArcGIS.Desktop.Mapping.Map.GetLayersAsFlattenedList #region Find a layer //Finds layers by name and returns a read only list of Layers IReadOnlyList layers = aMap.FindLayers("cities", true); @@ -1058,14 +1276,24 @@ public void Simple() .OfType().Any(f => f.Name == "U.S. States (Generalized)"); #endregion + // cref: ArcGIS.Desktop.Mapping.Map.FindStandaloneTable(System.String) + // cref: ArcGIS.Desktop.Mapping.Map.FindStandaloneTables(System.String) + // cref: ArcGIS.Desktop.Mapping.Map.StandaloneTables #region Find a standalone table + + // these routines find a standalone table whether it is a child of the Map or a GroupLayer + var tblFind = aMap.FindStandaloneTable("CIMPATH=map/address_audit.xml"); + IReadOnlyList tables = aMap.FindStandaloneTables("addresses"); + + // this method finds a standalone table as a child of the map only + var table = aMap.StandaloneTables.FirstOrDefault(t => t.Name == "Addresses"); #endregion } public List FindLayersWithPartialName(string partialName) { - // cref: Find a layer using partial name search;ArcGIS.Desktop.Mapping.Map.GetLayersAsFlattenedList + // cref: ArcGIS.Desktop.Mapping.Map.GetLayersAsFlattenedList #region Find a layer using partial name search Map map = MapView.Active.Map; @@ -1080,9 +1308,36 @@ public List FindLayersWithPartialName(string partialName) return layers; } + internal void ChangeProperties(Layer layer) + { + // cref: ArcGIS.Desktop.Mapping.Layer.IsVisible + // cref: ArcGIS.Desktop.Mapping.Layer.SetVisibility(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.BasicFeatureLayer.IsEditable + // cref: ArcGIS.Desktop.Mapping.BasicFeatureLayer.SetEditable(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.IsSnappable + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetSnappable(System.Boolean) + #region Change layer visibility, editability, snappability + if (!layer.IsVisible) + layer.SetVisibility(true); + + if (layer is FeatureLayer featureLayer) + { + if (!featureLayer.IsEditable) + featureLayer.SetEditable(true); + + if (!featureLayer.IsSnappable) + featureLayer.SetSnappable(true); + } + #endregion + } + public void CreateLyrx() { Layer layer = null; + + // cref: ArcGIS.Desktop.Mapping.LayerDocument + // cref: ArcGIS.Desktop.Mapping.LayerDocument.#ctor(ArcGIS.Desktop.Mapping.MapMember) + // cref: ArcGIS.Desktop.Mapping.LayerDocument.Save(System.String) #region Create a Lyrx file LayerDocument layerDocument = new LayerDocument(layer); @@ -1093,7 +1348,8 @@ public void MiscOneLiners() { Map aMap = MapView.Active.Map; - #region Count the features selected in a map + // cref: ArcGIS.Desktop.Mapping.BasicFeatureLayer.SelectionCount + #region Count the features selected on a layer var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); var noFeaturesSelected = lyr.SelectionCount; #endregion @@ -1101,6 +1357,10 @@ public void MiscOneLiners() public void AccessDisplayField() { + // cref: ArcGIS.Core.CIM.CIMBasicFeatureLayer + // cref: ArcGIS.Core.CIM.CIMBasicFeatureLayer.FeatureTable + // cref: ArcGIS.Core.CIM.CIMFeatureTable + // cref: ArcGIS.Core.CIM.CIMDisplayTable.DisplayField #region Access the display field for a layer var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -1117,6 +1377,8 @@ public void AccessDisplayField() public void EnableLabeling() { + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.IsLabelVisible + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetLabelVisibility(System.Boolean) #region Enable labeling on a layer var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => @@ -1129,6 +1391,7 @@ public void EnableLabeling() public static void MoveLayerTo3D() { + // cref: ArcGIS.Core.CIM.CIMBasicFeatureLayer.IsFlattened #region Move a layer in the 2D group to the 3D Group in a Local Scene //The layer in the 2D group to move to the 3D Group in a Local Scene var layer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); @@ -1146,6 +1409,10 @@ public static void MoveLayerTo3D() private static void ResetDataConnectionFeatureService(Layer dataConnectionLayer, string newConnectionString) { + // cref: ArcGIS.Desktop.Mapping.MapMember.GetDataConnection() + // cref: ArcGIS.Core.CIM.CIMStandardDataConnection + // cref: ArcGIS.Core.CIM.CIMStandardDataConnection.WorkspaceConnectionString + // cref: ArcGIS.Desktop.Mapping.MapMember.SetDataConnection(ArcGIS.Core.CIM.CIMDataConnection, System.Boolean) #region Reset the URL of a feature service layer CIMStandardDataConnection dataConnection = dataConnectionLayer.GetDataConnection() as CIMStandardDataConnection; dataConnection.WorkspaceConnectionString = newConnectionString; @@ -1154,6 +1421,8 @@ private static void ResetDataConnectionFeatureService(Layer dataConnectionLayer, } private static void ReplaceDataSource() { + // cref: ArcGIS.Desktop.Mapping.Layer.FindAndReplaceWorkspacePath(System.String, System.String, System.Boolean) + // cref: ArcGIS.Core.Data.Datastore.GetConnectionString() #region Change the underlying data source of a feature layer - same workspace type //This is the existing layer for which we want to switch the underlying datasource var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); @@ -1173,32 +1442,32 @@ private static void ReplaceDataSource() public async Task ChangeGDBVersion2Async() { - // cref: Change Geodatabase Version of layers off a specified version in a map;ArcGIS.Desktop.Mapping.Map.ChangeVersion(ArcGIS.Core.Data.Version,ArcGIS.Core.Data.Version) + // cref: ArcGIS.Desktop.Mapping.Map.ChangeVersion(ArcGIS.Core.Data.VersionBase,ArcGIS.Core.Data.VersionBase) #region Change Geodatabase Version of layers off a specified version in a map await QueuedTask.Run(() => { - //Getting the current version name from the first feature layer of the map - FeatureLayer flyr = MapView.Active.Map.GetLayersAsFlattenedList() - .OfType().FirstOrDefault(); //first feature layer - Datastore dataStore = flyr.GetFeatureClass().GetDatastore(); //getting datasource - Geodatabase geodatabase = dataStore as Geodatabase; //casting to Geodatabase - if (geodatabase == null) + //Getting the current version name from the first feature layer of the map + FeatureLayer flyr = MapView.Active.Map.GetLayersAsFlattenedList() + .OfType().FirstOrDefault(); //first feature layer + Datastore dataStore = flyr.GetFeatureClass().GetDatastore(); //getting datasource + Geodatabase geodatabase = dataStore as Geodatabase; //casting to Geodatabase + if (geodatabase == null) return; VersionManager versionManager = geodatabase.GetVersionManager(); ArcGIS.Core.Data.Version currentVersion = versionManager.GetCurrentVersion(); - //Getting all available versions except the current one - IEnumerable versions = versionManager.GetVersions() - .Where(v => !v.GetName().Equals(currentVersion.GetName(), StringComparison.CurrentCultureIgnoreCase)); + //Getting all available versions except the current one + IEnumerable versions = versionManager.GetVersions() + .Where(v => !v.GetName().Equals(currentVersion.GetName(), StringComparison.CurrentCultureIgnoreCase)); - //Assuming there is at least one other version we pick the first one from the list - ArcGIS.Core.Data.Version toVersion = versions.FirstOrDefault(); + //Assuming there is at least one other version we pick the first one from the list + ArcGIS.Core.Data.Version toVersion = versions.FirstOrDefault(); if (toVersion != null) { - //Changing version - MapView.Active.Map.ChangeVersion(currentVersion, toVersion); + //Changing version + MapView.Active.Map.ChangeVersion(currentVersion, toVersion); } }); #endregion @@ -1207,9 +1476,8 @@ await QueuedTask.Run(() => public async void SearchAndGetFeatureCount() { - // cref: Querying a feature layer;ArcGIS.Desktop.Mapping.BasicFeatureLayer.Search(ArcGIS.Core.Data.QueryFilter) - // cref: Querying a feature layer;ArcGIS.Desktop.Mapping.BasicFeatureLayer.Search(ArcGIS.Core.Data.QueryFilter,ArcGIS.Desktop.Mapping.TimeRange,ArcGIS.Desktop.Mapping.RangeExtent) - // cref: Querying a feature layer;ArcGIS.Desktop.Mapping.BasicFeatureLayer.Search(ArcGIS.Core.Data.QueryFilter,ArcGIS.Desktop.Mapping.TimeRange,ArcGIS.Desktop.Mapping.RangeExtent,ArcGIS.Core.CIM.CIMFloorFilterSettings) + // cref: ArcGIS.Core.Data.QueryFilter + // cref: ArcGIS.Desktop.Mapping.BasicFeatureLayer.Search(ArcGIS.Core.Data.QueryFilter, ArcGIS.Desktop.Mapping.TimeRange, ArcGIS.Desktop.Mapping.RangeExtent, ArcGIS.Core.CIM.CIMFloorFilterSettings) #region Querying a feature layer var count = await QueuedTask.Run(() => @@ -1219,13 +1487,13 @@ public async void SearchAndGetFeatureCount() WhereClause = "Class = 'city'" }; - //Getting the first selected feature layer of the map view - var flyr = (FeatureLayer)MapView.Active.GetSelectedLayers() - .OfType().FirstOrDefault(); + //Getting the first selected feature layer of the map view + var flyr = (FeatureLayer)MapView.Active.GetSelectedLayers() + .OfType().FirstOrDefault(); using (RowCursor rows = flyr.Search(qf)) //execute - { - //Looping through to count - int i = 0; + { + //Looping through to count + int i = 0; while (rows.MoveNext()) i++; return i; @@ -1240,6 +1508,8 @@ public async void SearchAndGetFeatureCount() public static void GetRotationFieldOfRenderer() { + // cref: ArcGIS.Core.CIM.CIMRotationVisualVariable + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.VisualVariables #region Get the attribute rotation field of a layer var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); QueuedTask.Run(() => @@ -1248,79 +1518,92 @@ public static void GetRotationFieldOfRenderer() var cimRotationVariable = cimRenderer.VisualVariables.OfType().FirstOrDefault(); var rotationInfoZ = cimRotationVariable.VisualVariableInfoZ; var rotationExpression = rotationInfoZ.ValueExpressionInfo.Expression; // this expression stores the field name - }); + }); #endregion } public void FindConnectedAttribute() { + // cref: ArcGIS.Core.CIM.CIMRotationVisualVariable + // cref: ArcGIS.Core.CIM.CIMSimpleRenderer.VisualVariables #region Find connected attribute field for rotation var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - // get the CIM renderer from the layer - var cimRenderer = featureLayer.GetRenderer() as ArcGIS.Core.CIM.CIMSimpleRenderer; - // get the collection of connected attributes for rotation - var cimRotationVariable = cimRenderer.VisualVariables.OfType().FirstOrDefault(); - // the z direction is describing the heading rotation - var rotationInfoZ = cimRotationVariable.VisualVariableInfoZ; + // get the CIM renderer from the layer + var cimRenderer = featureLayer.GetRenderer() as ArcGIS.Core.CIM.CIMSimpleRenderer; + // get the collection of connected attributes for rotation + var cimRotationVariable = cimRenderer.VisualVariables.OfType().FirstOrDefault(); + // the z direction is describing the heading rotation + var rotationInfoZ = cimRotationVariable.VisualVariableInfoZ; var rotationExpression = rotationInfoZ.Expression; // this expression stores the field name - }); + }); #endregion } public void ScaleSymbols() { + // cref: ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.ScaleSymbols #region Toggle "Scale layer symbols when reference scale is set" var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - // get the CIM layer definition - var cimFeatureLayer = featureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMFeatureLayer; - // turn on the option to scale the symbols in this layer based in the map's reference scale - cimFeatureLayer.ScaleSymbols = true; + // get the CIM layer definition + var cimFeatureLayer = featureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMFeatureLayer; + // turn on the option to scale the symbols in this layer based in the map's reference scale + cimFeatureLayer.ScaleSymbols = true; }); #endregion } public void SetLayerCache() { + // cref: ArcGIS.Desktop.Mapping.LayerCacheType + // cref: ArcGIS.Desktop.Mapping.Layer.SetCacheOptions(ArcGIS.Desktop.Mapping.LayerCacheType) + // cref: ArcGIS.Desktop.Mapping.Layer.SetDisplayCacheMaxAge(System.TimeSpan) #region Set the layer cache var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - // change the layer cache type to maximum age - featureLayer.SetDisplayCacheType(ArcGIS.Core.CIM.DisplayCacheType.MaxAge); - // change from the default 5 min to 2 min - featureLayer.SetDisplayCacheMaxAge(TimeSpan.FromMinutes(2)); + // change the layer cache type to maximum age + //At 2.x - featureLayer.SetDisplayCacheType(ArcGIS.Core.CIM.DisplayCacheType.MaxAge); + featureLayer.SetCacheOptions(LayerCacheType.MaxAge); + // change from the default 5 min to 2 min + featureLayer.SetDisplayCacheMaxAge(TimeSpan.FromMinutes(2)); }); #endregion } public void ChangeSelectionColor() { + // cref: ArcGIS.Core.CIM.CIMBasicFeatureLayer.UseSelectionSymbol + // cref: ArcGIS.Core.CIM.CIMBasicFeatureLayer.SelectionColor + // cref: ArcGIS.Desktop.Mapping.MapView.SelectFeatures(ArcGIS.Core.Geometry.Geometry, ArcGIS.Desktop.Mapping.SelectionCombinationMethod, System.Boolean, System.Boolean) #region Change the layer selection color var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(); ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { - // get the CIM definition of the layer - var layerDef = featureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMBasicFeatureLayer; - // disable the default symbol - layerDef.UseSelectionSymbol = false; - // assign a new color - layerDef.SelectionColor = ColorFactory.Instance.RedRGB; - // apply the definition to the layer - featureLayer.SetDefinition(layerDef); + // get the CIM definition of the layer + var layerDef = featureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMBasicFeatureLayer; + // disable the default symbol + layerDef.UseSelectionSymbol = false; + // assign a new color + layerDef.SelectionColor = ColorFactory.Instance.RedRGB; + // apply the definition to the layer + featureLayer.SetDefinition(layerDef); - if (!featureLayer.IsVisible) featureLayer.SetVisibility(true); - //Do a selection + if (!featureLayer.IsVisible) + featureLayer.SetVisibility(true); + //Do a selection - MapView.Active.SelectFeatures(MapView.Active.Extent); + MapView.Active.SelectFeatures(MapView.Active.Extent); }); #endregion } public async void RemoveAllUncheckedLayers() { + // cref: ArcGIS.Desktop.Mapping.Map.RemoveLayers(System.Collections.Generic.Enumerable) + // cref: ArcGIS.Desktop.Mapping.Map.RemoveLayer(ArcGIS.Desktop.Mapping.Layer) #region Removes all layers that are unchecked var map = MapView.Active.Map; if (map == null) @@ -1355,6 +1638,9 @@ public async void RemoveAllUncheckedLayers() } public async void RemoveEmptyGroups() { + // cref: ArcGIS.Desktop.Mapping.Map.RemoveLayer(ArcGIS.Desktop.Mapping.Layer) + // cref: ArcGIS.Desktop.Mapping.GroupLayer + // cref: ArcGIS.Desktop.Mapping.CompositeLayer.Layers #region Remove empty groups var map = MapView.Active.Map; if (map == null) @@ -1370,8 +1656,21 @@ public async void RemoveEmptyGroups() } } #endregion - } + + // cref: ArcGIS.Core.CIM.CIMMap.GeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexDictionaryEntry + // cref: ArcGIS.Core.CIM.CIMMaplexDictionaryEntry.#ctor + // cref: ArcGIS.Core.CIM.CIMMaplexDictionaryEntry.Abbreviation + // cref: ArcGIS.Core.CIM.CIMMaplexDictionaryEntry.Text + // cref: ArcGIS.Core.CIM.CIMMaplexDictionaryEntry.MaplexAbbreviationType + // cref: ArcGIS.Core.CIM.MaplexAbbreviationType + // cref: ArcGIS.Core.CIM.CIMMaplexDictionary + // cref: ArcGIS.Core.CIM.CIMMaplexDictionary.#ctor + // cref: ArcGIS.Core.CIM.CIMMaplexDictionary.Name + // cref: ArcGIS.Core.CIM.CIMMaplexDictionary.MaplexDictionary + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.Dictionaries #region Create and apply Abbreviation Dictionary in the Map Definition to a layer public static void CreateDictionary() { @@ -1446,6 +1745,9 @@ private static void ApplyDictionary() public void SetTablePaneZoom() { + // cref: ArcGIS.Desktop.Mapping.ITablePane + // cref: ArcGIS.Desktop.Mapping.ITablePane.ZoomLevel + // cref: ArcGIS.Desktop.Mapping.ITablePane.SetZoomLevel #region Set zoom level for Attribute Table if (FrameworkApplication.Panes.ActivePane is ITablePane tablePane) { @@ -1460,23 +1762,45 @@ public void SetTablePaneZoom() public static Task ActiveCellContents() { - #region Retrieve the values of selected cell in the attribute table - if (FrameworkApplication.Panes.ActivePane is ITablePane tablePane) { - var mapMember = tablePane.MapMember; - var oid = tablePane.ActiveObjectID; - if (oid.HasValue && oid.Value != -1 && mapMember != null) + // cref: ArcGIS.Desktop.Mapping.ITablePane + // cref: ArcGIS.Desktop.Mapping.ITablePane.MapMember + // cref: ArcGIS.Desktop.Mapping.ITablePane.ActiveObjectID + // cref: ArcGIS.Desktop.Mapping.ITablePane.ActiveColumn + #region Retrieve the values of selected cell in the attribute table + if (FrameworkApplication.Panes.ActivePane is ITablePane tablePane) { - var activeField = tablePane.ActiveColumn; - return QueuedTask.Run(() => + var mapMember = tablePane.MapMember; + var oid = tablePane.ActiveObjectID; + if (oid.HasValue && oid.Value != -1 && mapMember != null) { - // TODO: Use core objects to retrieve record and get value + var activeField = tablePane.ActiveColumn; + return QueuedTask.Run(() => + { + // TODO: Use core objects to retrieve record and get value - return null; - }); + return null; + }); + } + } + #endregion + } + + { + // cref: ArcGIS.Desktop.Mapping.ITablePane + // cref: ArcGIS.Desktop.Mapping.ITablePane.BringIntoView + #region Move to a particular row + if (FrameworkApplication.Panes.ActivePane is ITablePane tablePane) + { + // move to first row + tablePane.BringIntoView(0); + + // move to sixth row + tablePane.BringIntoView(5); } } #endregion + return Task.FromResult(null); } @@ -1484,6 +1808,9 @@ public static Task ActiveCellContents() #endregion private void MapLayerMetadata() { + // cref: ArcGIS.Desktop.Mapping.Map.GetMetadata() + // cref: ArcGIS.Desktop.Mapping.Map.GetCanEditMetadata() + // cref: ArcGIS.Desktop.Mapping.Map.SetMetadata(System.String) #region Get and Set Map Metadata var map = MapView.Active.Map; if (map == null) return; @@ -1496,6 +1823,12 @@ private void MapLayerMetadata() map.SetMetadata(mapMetadata); #endregion + // cref: ArcGIS.Desktop.Mapping.MapMember.GetUseSourceMetadata() + // cref: ArcGIS.Desktop.Mapping.MapMember.SetUseSourceMetadata(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.MapMember.SupportsMetadata + // cref: ArcGIS.Desktop.Mapping.MapMember.GetMetadata() + // cref: ArcGIS.Desktop.Mapping.MapMember.GetCanEditMetadata() + // cref: ArcGIS.Desktop.Mapping.MapMember.SetMetadata(System.String) #region Layer Metadata MapMember mapMember = map.GetLayersAsFlattenedList().FirstOrDefault(); //Search for only layers/tables here if needed. if (mapMember == null) return; @@ -1526,24 +1859,27 @@ private void MapLayerMetadata() #endregion public async Task SetUniqueValueRendererAsync() { - - - // cref: Set unique value renderer to the selected feature layer of the active map;ArcGIS.Desktop.Mapping.FeatureLayer.CreateRenderer(ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Desktop.Mapping.UniqueValueRendererDefinition + // cref: ArcGIS.Desktop.Mapping.UniqueValueRendererDefinition.#ctor(System.Collections.Generic.List, ArcGIS.Core.CIM.CIMSymbolReference, ArcGIS.Core.CIM.CIMColorRamp, ArcGIS.Core.CIM.CIMSymbolReference, System.Boolean) + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CreateRenderer(ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(ArcGIS.Core.CIM.CIMRenderer) #region Set unique value renderer to the selected feature layer of the active map await QueuedTask.Run(() => { - String[] fields = new string[] { "Type" }; //field to be used to retrieve unique values + var fields = new List { "Type" }; //field to be used to retrieve unique values CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol( ColorFactory.Instance.GreenRGB, 16.0, SimpleMarkerStyle.Pushpin); //constructing a point symbol as a template symbol CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference(); //constructing renderer definition for unique value renderer - UniqueValueRendererDefinition uniqueValueRendererDef = new UniqueValueRendererDefinition(fields, symbolPointTemplate); + UniqueValueRendererDefinition uniqueValueRendererDef = + new UniqueValueRendererDefinition(fields, symbolPointTemplate); //creating a unique value renderer var flyr = MapView.Active.GetSelectedLayers()[0] as FeatureLayer; - CIMUniqueValueRenderer uniqueValueRenderer = (CIMUniqueValueRenderer)flyr.CreateRenderer(uniqueValueRendererDef); + CIMUniqueValueRenderer uniqueValueRenderer = flyr.CreateRenderer(uniqueValueRendererDef) as CIMUniqueValueRenderer; //setting the renderer to the feature layer flyr.SetRenderer(uniqueValueRenderer); @@ -1554,16 +1890,38 @@ await QueuedTask.Run(() => internal static Task UniqueValueRenderer(FeatureLayer featureLayer) { + // cref: ArcGIS.Core.CIM.CIMUniqueValue + // cref: ArcGIS.Core.CIM.CIMUniqueValue.#ctor + // cref: ArcGIS.Core.CIM.CIMUniqueValue.FieldValues + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.#ctor + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Editable + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Label + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Patch + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Symbol + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Visible + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Values + // cref: ArcGIS.Core.CIM.CIMUniqueValueGroup + // cref: ArcGIS.Core.CIM.CIMUniqueValueGroup.#ctor + // cref: ArcGIS.Core.CIM.CIMUniqueValueGroup.Classes + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.#ctor + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.UseDefaultSymbol + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.DefaultLabel + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.DefaultSymbol + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.Groups + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.Fields + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(ArcGIS.Core.CIM.CIMRenderer) #region Create a UniqueValueRenderer to specify symbols to values return QueuedTask.Run(() => { - //The goal is to construct the CIMUniqueValueRenderer which will be applied to the feature layer. - // To do this, the following are the objects we need to set the renderer up with the fields and symbols. - // As a reference, this is the USCities dataset. Snippet will create a unique value renderer that applies - // specific symbols to all the cities in California and Alabama. The rest of the cities will use a default symbol. + //The goal is to construct the CIMUniqueValueRenderer which will be applied to the feature layer. + // To do this, the following are the objects we need to set the renderer up with the fields and symbols. + // As a reference, this is the USCities dataset. Snippet will create a unique value renderer that applies + // specific symbols to all the cities in California and Alabama. The rest of the cities will use a default symbol. - // First create a "CIMUniqueValueClass" for the cities in Alabama. - List listUniqueValuesAlabama = new List { new CIMUniqueValue { FieldValues = new string[] { "Alabama" } } }; + // First create a "CIMUniqueValueClass" for the cities in Alabama. + List listUniqueValuesAlabama = new List { new CIMUniqueValue { FieldValues = new string[] { "Alabama" } } }; CIMUniqueValueClass alabamaUniqueValueClass = new CIMUniqueValueClass { Editable = true, @@ -1574,8 +1932,8 @@ internal static Task UniqueValueRenderer(FeatureLayer featureLayer) Values = listUniqueValuesAlabama.ToArray() }; - // Create a "CIMUniqueValueClass" for the cities in California. - List listUniqueValuescalifornia = new List { new CIMUniqueValue { FieldValues = new string[] { "California" } } }; + // Create a "CIMUniqueValueClass" for the cities in California. + List listUniqueValuescalifornia = new List { new CIMUniqueValue { FieldValues = new string[] { "California" } } }; CIMUniqueValueClass californiaUniqueValueClass = new CIMUniqueValueClass { Editable = true, @@ -1585,19 +1943,19 @@ internal static Task UniqueValueRenderer(FeatureLayer featureLayer) Visible = true, Values = listUniqueValuescalifornia.ToArray() }; - //Create a list of the above two CIMUniqueValueClasses - List listUniqueValueClasses = new List + //Create a list of the above two CIMUniqueValueClasses + List listUniqueValueClasses = new List { alabamaUniqueValueClass, californiaUniqueValueClass }; - //Create a list of CIMUniqueValueGroup - CIMUniqueValueGroup uvg = new CIMUniqueValueGroup + //Create a list of CIMUniqueValueGroup + CIMUniqueValueGroup uvg = new CIMUniqueValueGroup { Classes = listUniqueValueClasses.ToArray(), }; List listUniqueValueGroups = new List { uvg }; - //Create the CIMUniqueValueRenderer - CIMUniqueValueRenderer uvr = new CIMUniqueValueRenderer + //Create the CIMUniqueValueRenderer + CIMUniqueValueRenderer uvr = new CIMUniqueValueRenderer { UseDefaultSymbol = true, DefaultLabel = "all other values", @@ -1605,14 +1963,24 @@ internal static Task UniqueValueRenderer(FeatureLayer featureLayer) Groups = listUniqueValueGroups.ToArray(), Fields = new string[] { "STATE_NAME" } }; - //Set the feature layer's renderer. - featureLayer.SetRenderer(uvr); + //Set the feature layer's renderer. + featureLayer.SetRenderer(uvr); }); #endregion } public async void CreateHeatMapRenderer() { - // cref: Create a Heatmap Renderer;ArcGIS.Desktop.Mapping.HeatMapRendererDefinition + // cref: ArcGIS.Desktop.Mapping.HeatMapRendererDefinition + // cref: ArcGIS.Desktop.Mapping.HeatMapRendererDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.HeatMapRendererDefinition.Radius + // cref: ArcGIS.Desktop.Mapping.HeatMapRendererDefinition.WeightField + // cref: ArcGIS.Desktop.Mapping.HeatMapRendererDefinition.ColorRamp + // cref: ArcGIS.Desktop.Mapping.HeatMapRendererDefinition.RendereringQuality + // cref: ArcGIS.Desktop.Mapping.HeatMapRendererDefinition.UpperLabel + // cref: ArcGIS.Desktop.Mapping.HeatMapRendererDefinition.LowerLabel + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CreateRenderer(ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Core.CIM.CIMHeatMapRenderer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(ArcGIS.Core.CIM.CIMRenderer) #region Create a Heatmap Renderer string colorBrewerSchemesName = "ArcGIS Colors"; StyleProjectItem style = Project.Current.GetItems().First(s => s.Name == colorBrewerSchemesName); @@ -1625,8 +1993,8 @@ public async void CreateHeatMapRenderer() await QueuedTask.Run(() => { - //defining a heatmap renderer that uses values from Population field as the weights - HeatMapRendererDefinition heatMapDef = new HeatMapRendererDefinition() + //defining a heatmap renderer that uses values from Population field as the weights + HeatMapRendererDefinition heatMapDef = new HeatMapRendererDefinition() { Radius = 20, WeightField = "Population", @@ -1637,7 +2005,7 @@ await QueuedTask.Run(() => }; FeatureLayer flyr = MapView.Active.Map.Layers[0] as FeatureLayer; - CIMHeatMapRenderer heatMapRndr = (CIMHeatMapRenderer)flyr.CreateRenderer(heatMapDef); + CIMHeatMapRenderer heatMapRndr = flyr.CreateRenderer(heatMapDef) as CIMHeatMapRenderer; flyr.SetRenderer(heatMapRndr); }); #endregion @@ -1645,7 +2013,13 @@ await QueuedTask.Run(() => public async void CreateUnclassedRenderer() { - // cref: Create an Unclassed Renderer;ArcGIS.Desktop.Mapping.UnclassedColorsRendererDefinition + // cref: ArcGIS.Desktop.Mapping.UnclassedColorsRendererDefinition + // cref: ArcGIS.Desktop.Mapping.UnclassedColorsRendererDefinition.#ctor(System.String, ArcGIS.Core.CIM.CIMSymbolReference, ArcGIS.Core.CIM.CIMColorRamp, System.String, System.String, System.Double, System.Double) + // cref: ArcGIS.Desktop.Mapping.UnclassedColorsRendererDefinition.ShowNullValues + // cref: ArcGIS.Desktop.Mapping.UnclassedColorsRendererDefinition.NullValueLabel + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CreateRenderer(ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Core.CIM.CIMClassBreaksRenderer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(ArcGIS.Core.CIM.CIMRenderer) #region Create an Unclassed Renderer string colorBrewerSchemesName = "ArcGIS Colors"; StyleProjectItem style = Project.Current.GetItems().First(s => s.Name == colorBrewerSchemesName); @@ -1661,21 +2035,21 @@ await QueuedTask.Run(() => CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreenRGB, 16.0, SimpleMarkerStyle.Diamond); CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference(); - //defining an unclassed renderer with custom upper and lower stops - //all features with value >= 5,000,000 will be drawn with the upper color from the color ramp - //all features with value <= 50,000 will be drawn with the lower color from the color ramp - UnclassedColorsRendererDefinition unclassRndrDef = new UnclassedColorsRendererDefinition - ("Population", symbolPointTemplate, colorRamp.ColorRamp, "Highest", "Lowest", 5000000, 50000) + //defining an unclassed renderer with custom upper and lower stops + //all features with value >= 5,000,000 will be drawn with the upper color from the color ramp + //all features with value <= 50,000 will be drawn with the lower color from the color ramp + UnclassedColorsRendererDefinition unclassRndrDef = new UnclassedColorsRendererDefinition + ("Population", symbolPointTemplate, colorRamp.ColorRamp, "Highest", "Lowest", 5000000, 50000) { - //drawing features with null values with a different symbol - ShowNullValues = true, + //drawing features with null values with a different symbol + ShowNullValues = true, NullValueLabel = "Unknown" }; CIMPointSymbol nullSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.RedRGB, 16.0, SimpleMarkerStyle.Circle); unclassRndrDef.NullValueSymbol = nullSym.MakeSymbolReference(); FeatureLayer flyr = MapView.Active.Map.Layers[0] as FeatureLayer; - CIMClassBreaksRenderer cbRndr = (CIMClassBreaksRenderer)flyr.CreateRenderer(unclassRndrDef); + CIMClassBreaksRenderer cbRndr = flyr.CreateRenderer(unclassRndrDef) as CIMClassBreaksRenderer; flyr.SetRenderer(cbRndr); }); #endregion @@ -1683,7 +2057,13 @@ await QueuedTask.Run(() => public async void CreateProportionaRenderer() { - // cref: Create a Proportion Renderer with max and min symbol size capped;ArcGIS.Desktop.Mapping.ProportionalRendererDefinition + // cref: ArcGIS.Desktop.Mapping.ProportionalRendererDefinition + // cref: ArcGIS.Desktop.Mapping.ProportionalRendererDefinition.#ctor(System.String, ArcGIS.Core.CIM.CIMSymbolReference, System.Double, System.Double, System.Boolean) + // cref: ArcGIS.Desktop.Mapping.ProportionalRendererDefinition.UpperSizeStop + // cref: ArcGIS.Desktop.Mapping.ProportionalRendererDefinition.LowerSizeStop + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CreateRenderer(ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Core.CIM.CIMProportionalRenderer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(ArcGIS.Core.CIM.CIMRenderer) #region Create a Proportion Renderer with max and min symbol size capped string colorBrewerSchemesName = "ArcGIS Colors"; StyleProjectItem style = Project.Current.GetItems().First(s => s.Name == colorBrewerSchemesName); @@ -1699,16 +2079,16 @@ await QueuedTask.Run(() => CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreenRGB, 1.0, SimpleMarkerStyle.Circle); CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference(); - //minimum symbol size is capped to 4 point while the maximum symbol size is set to 50 point - ProportionalRendererDefinition prDef = new ProportionalRendererDefinition("POPULATION", symbolPointTemplate, 4, 50, true) + //minimum symbol size is capped to 4 point while the maximum symbol size is set to 50 point + ProportionalRendererDefinition prDef = new ProportionalRendererDefinition("POPULATION", symbolPointTemplate, 4, 50, true) { - //setting upper and lower size stops to stop symbols growing or shrinking beyond those thresholds - UpperSizeStop = 5000000, //features with values >= 5,000,000 will be drawn with maximum symbol size - LowerSizeStop = 50000 //features with values <= 50,000 will be drawn with minimum symbol size - }; + //setting upper and lower size stops to stop symbols growing or shrinking beyond those thresholds + UpperSizeStop = 5000000, //features with values >= 5,000,000 will be drawn with maximum symbol size + LowerSizeStop = 50000 //features with values <= 50,000 will be drawn with minimum symbol size + }; FeatureLayer flyr = MapView.Active.Map.Layers[0] as FeatureLayer; - CIMProportionalRenderer propRndr = (CIMProportionalRenderer)flyr.CreateRenderer(prDef); + CIMProportionalRenderer propRndr = flyr.CreateRenderer(prDef) as CIMProportionalRenderer; flyr.SetRenderer(propRndr); }); @@ -1717,7 +2097,12 @@ await QueuedTask.Run(() => public async void CreateTrueProportionaRenderer() { - // cref: Create a True Proportion Renderer;ArcGIS.Desktop.Mapping.ProportionalRendererDefinition + + // cref: ArcGIS.Desktop.Mapping.ProportionalRendererDefinition + // cref: ArcGIS.Desktop.Mapping.ProportionalRendererDefinition.#ctor(System.String, ArcGIS.Core.CIM.esriUnits, ArcGIS.Core.CIM.CIMSymbolReference, ArcGIS.Core.CIM.SymbolShapes, ArcGIS.Core.CIM.ValueRepresentations) + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CreateRenderer(ArcGIS.Desktop.Mapping.RendererDefinition) + // cref: ArcGIS.Core.CIM.CIMProportionalRenderer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(ArcGIS.Core.CIM.CIMRenderer) #region Create a True Proportion Renderer string colorBrewerSchemesName = "ArcGIS Colors"; StyleProjectItem style = Project.Current.GetItems().First(s => s.Name == colorBrewerSchemesName); @@ -1733,11 +2118,11 @@ await QueuedTask.Run(() => CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(ColorFactory.Instance.GreenRGB, 1.0, SimpleMarkerStyle.Circle); CIMSymbolReference symbolPointTemplate = pointSym.MakeSymbolReference(); - //Defining proportional renderer where size of symbol will be same as its value in field used in the renderer. - ProportionalRendererDefinition prDef = new ProportionalRendererDefinition("POPULATION", esriUnits.esriMeters, symbolPointTemplate, SymbolShapes.Square, ValueRepresentations.Radius); + //Defining proportional renderer where size of symbol will be same as its value in field used in the renderer. + ProportionalRendererDefinition prDef = new ProportionalRendererDefinition("POPULATION", esriUnits.esriMeters, symbolPointTemplate, SymbolShapes.Square, ValueRepresentations.Radius); FeatureLayer flyr = MapView.Active.Map.Layers[0] as FeatureLayer; - CIMProportionalRenderer propRndr = (CIMProportionalRenderer)flyr.CreateRenderer(prDef); + CIMProportionalRenderer propRndr = flyr.CreateRenderer(prDef) as CIMProportionalRenderer; flyr.SetRenderer(propRndr); }); @@ -1749,6 +2134,13 @@ await QueuedTask.Run(() => protected static void ArcadeRenderer() { + // cref: ArcGIS.Core.CIM.CIMExpressionInfo + // cref: ArcGIS.Core.CIM.CIMExpressionInfo.#ctor + // cref: ArcGIS.Core.CIM.CIMExpressionInfo.Expression + // cref: ArcGIS.Core.CIM.CIMExpressionInfo.Title + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.ValueExpressionInfo + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetRenderer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer #region Modify renderer using Arcade var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(f => f.ShapeType == esriGeometryType.esriGeometryPolygon); if (lyr == null) return; @@ -1775,6 +2167,11 @@ protected static void ArcadeRenderer() } protected static void ArcadeLabeling() { + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetRenderer + // cref: ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.LabelClasses + // cref: ArcGIS.Core.CiM.CIMLabelClass + // cref: ArcGIS.Core.CiM.CIMLabelClass.Expression + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer #region Modify label expression using Arcade var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType().FirstOrDefault(f => f.ShapeType == esriGeometryType.esriGeometryPolygon); if (lyr == null) return; @@ -1796,13 +2193,32 @@ protected static void ArcadeLabeling() #endregion } - #region ProSnippet Group: Elevation Surface + #region ProSnippet Group: Elevation Surface Layers #endregion + private void CreateScene() + { + Uri groundSourceUri = null; + + // cref: ArcGIS.Desktop.Mapping.MapFactory.CreateScene(System.String, System.Uri, ArcGIS.Core.CIM.MapViewingMode, ArcGIS.Desktop.Mapping.Basemap) + #region Create a scene with a ground surface layer + + // wrap in QueuedTask.Run + var scene = MapFactory.Instance.CreateScene("My scene", groundSourceUri, MapViewingMode.SceneGlobal); + + #endregion + } + private Task CreateNewElevationSurface() { return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.ElevationSurfaceLayer + // cref: ArcGIS.Desktop.Mapping.ElevationLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.ElevationLayerCreationParams.#ctor(ArcGIS.Core.CIM.CIMDataConnection) + // cref: ArcGIS.Desktop.Mapping.Map.GetGroundElevationSurfaceLayer + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams, ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create a New Elevation Surface //Note: call within QueuedTask.Run() //Define a ServiceConnection to use for the new Elevation surface @@ -1820,38 +2236,36 @@ private Task CreateNewElevationSurface() ServerConnection = serverConnection }; //Defines a new elevation source set to the CIMAGSServiceConnection defined above - var newElevationSource = new ArcGIS.Core.CIM.CIMElevationSource - { - VerticalUnit = ArcGIS.Core.Geometry.LinearUnit.Meters, - DataConnection = serviceConnection, - Name = "WorldElevation/Terrain", - Visibility = true - }; + //At 2.x - var newElevationSource = new ArcGIS.Core.CIM.CIMElevationSource + //{ + // VerticalUnit = ArcGIS.Core.Geometry.LinearUnit.Meters, + // DataConnection = serviceConnection, + // Name = "WorldElevation/Terrain", + // Visibility = true + //}; //The elevation surface - var newElevationSurface = new ArcGIS.Core.CIM.CIMMapElevationSurface - { - Name = "New Elevation Surface", - BaseSources = new ArcGIS.Core.CIM.CIMElevationSource[1] { newElevationSource }, - Visibility = true, - ElevationMode = ElevationMode.CustomSurface, - VerticalExaggeration = 1, - EnableSurfaceShading = false, - SurfaceTINShadingMode = SurfaceTINShadingMode.Smooth, - Expanded = false, - MapElevationID = "{3DEC3CC5-7C69-4132-A700-DCD5BDED14D6}" - }; + //At 2.x - var newElevationSurface = new ArcGIS.Core.CIM.CIMMapElevationSurface + //{ + // Name = "New Elevation Surface", + // BaseSources = new ArcGIS.Core.CIM.CIMElevationSource[1] { newElevationSource }, + // Visibility = true, + // ElevationMode = ElevationMode.CustomSurface, + // VerticalExaggeration = 1, + // EnableSurfaceShading = false, + // SurfaceTINShadingMode = SurfaceTINShadingMode.Smooth, + // Expanded = false, + // MapElevationID = "{3DEC3CC5-7C69-4132-A700-DCD5BDED14D6}" + //}; //Get the active map var map = MapView.Active.Map; - //Get the active map's definition - var definition = map.GetDefinition(); //Get the elevation surfaces defined in the map - var listOfElevationSurfaces = definition.ElevationSurfaces.ToList(); + //At 2.x - var listOfElevationSurfaces = definition.ElevationSurfaces.ToList(); + var listOfElevationSurfaces = map.GetElevationSurfaceLayers(); //Add the new elevation surface - listOfElevationSurfaces.Add(newElevationSurface); - //Set the map definitions to ElevationSurface (this has the new elevation surface) - definition.ElevationSurfaces = listOfElevationSurfaces.ToArray(); - //Set the map definition - map.SetDefinition(definition); + //At 2.x - listOfElevationSurfaces.Add(newElevationSurface); + var elevationLyrCreationParams = new ElevationLayerCreationParams(serviceConnection); + var elevationSurface = LayerFactory.Instance.CreateLayer( + elevationLyrCreationParams, map); #endregion }); } @@ -1860,25 +2274,111 @@ private Task SetElevationSurfaceToLayer(FeatureLayer featureLayer) { return QueuedTask.Run(() => { - #region Set a custom elevation surface to a Z-Aware layer + // cref: ArcGIS.Core.CIM.CIMLayerElevationSurface + // cref: ArcGIS.Core.CIM.CIMBaselayer.LayerElevation + #region Set a custom elevation surface to a Z-Aware layer - //Define the custom elevation surface to use - var layerElevationSurface = new CIMLayerElevationSurface + //Define the custom elevation surface to use + //At 2.x - var layerElevationSurface = new CIMLayerElevationSurface + //{ + // MapElevationID = "{3DEC3CC5-7C69-4132-A700-DCD5BDED14D6}" + //}; + var layerElevationSurface = new CIMLayerElevationSurface { - MapElevationID = "{3DEC3CC5-7C69-4132-A700-DCD5BDED14D6}" + ElevationSurfaceLayerURI = "https://elevation3d.arcgis.com/arcgis/services/WorldElevation3D/Terrain3D/ImageServer" }; - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMBasicFeatureLayer; - //Set the layer's elevation surface - lyrDefn.LayerElevation = layerElevationSurface; - //Set the layer's definition - featureLayer.SetDefinition(lyrDefn); - #endregion - }); + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMBasicFeatureLayer; + //Set the layer's elevation surface + lyrDefn.LayerElevation = layerElevationSurface; + //Set the layer's definition + featureLayer.SetDefinition(lyrDefn); + #endregion + }); } + private Task AddSourceToElevationSurfaceLayer() + { + return QueuedTask.Run(() => + { + ElevationSurfaceLayer surfaceLayer = null; + + // cref: ArcGIS.Desktop.Mapping.ElevationLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.ElevationLayerCreationParams.#ctor(System.Uri) + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams, ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory + #region Add an elevation source to an existing elevation surface layer + + // wrap in QueuendTask.Run + + // surfaceLayer could also be the ground layer + + string uri = "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"; + var createParams = new ElevationLayerCreationParams(new Uri(uri)); + createParams.Name = "Terrain 3D"; + var eleSourceLayer = LayerFactory.Instance.CreateLayer(createParams, surfaceLayer); + #endregion + }); + } + + private void ElevationSurfaceLayers(Map map) + { + { + // cref: ArcGIS.Desktop.Mapping.ElevationSurfaceLayer + // cref: ArcGIS.Desktop.Mapping.Map.GetElevationSurfaceLayers + // cref: ArcGIS.Desktop.Mapping.Map.GetGroundElevationSurfaceLayer + #region Get the elevation surface layers and elevation source layers from a map + + // retrieve the elevation surface layers in the map including the Ground + var surfaceLayers = map.GetElevationSurfaceLayers(); + + // retrieve the single ground elevation surface layer in the map + var groundSurfaceLayer = map.GetGroundElevationSurfaceLayer(); + + // determine the number of elevation sources in the ground elevation surface layer + int numberGroundSources = groundSurfaceLayer.Layers.Count; + // get the first elevation source layer from the ground elevation surface layer + var groundSourceLayer = groundSurfaceLayer.Layers.FirstOrDefault(); + + #endregion + } + { + string layerUri = ""; + + // cref: ArcGIS.Desktop.Mapping.ElevationSurfaceLayer + // cref: ArcGIS.Desktop.Mapping.Map.GetElevationSurfaceLayers + // cref: ArcGIS.Desktop.Mapping.Map.FindElevationSurfaceLayer(System.String) + #region Find an elevation surface layer + var surfaceLayers = map.GetElevationSurfaceLayers(); + var surfaceLayer = surfaceLayers.FirstOrDefault(l => l.Name == "Surface2"); + + surfaceLayer = map.FindElevationSurfaceLayer(layerUri); + #endregion + + } + { + Layer surfaceLayer = null; + + // cref: ArcGIS.Desktop.Mapping.Map.ClearElevationSurfaceLayers + #region Remove elevation surface layers + + // wrap in a QueuedTask.Run + + map.ClearElevationSurfaceLayers(); //Ground will not be removed + + map.RemoveLayer(surfaceLayer);//Cannot remove ground + map.RemoveLayers(map.GetElevationSurfaceLayers()); //Ground will not be removed + + #endregion + } + } + + + private static async Task GetZValue() { + // cref: ArcGIS.Desktop.Mapping.Map.GetZsFromSurfaceAsync(ArcGIS.Core.Geometry.Geometry) + // cref: ArcGIS.Desktop.Mapping.SurfaceZsResult #region Get Z values from a surface var geometry = await QueuedTask.Run(() => { @@ -1901,16 +2401,25 @@ public async Task RasterLayers() CIMColorRamp colorRamp = null; RasterLayer rasterLayer = null; + // cref: ArcGIS.Desktop.Mapping.RasterLayer + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(System.Uri, ArcGIS.Desktop.Mapping.ILayerContainerEdit, Saystem.Int32, System.String) #region Create a raster layer string url = @"C:\Images\Italy.tif"; await QueuedTask.Run(() => { // Create a raster layer using a path to an image. // Note: You can create a raster layer from a url, project item, or data connection. - rasterLayer = (RasterLayer)LayerFactory.Instance.CreateLayer(new Uri(url), aMap); + rasterLayer = LayerFactory.Instance.CreateLayer(new Uri(url), aMap) as RasterLayer; }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetColorizer() + // cref: ArcGIS.Core.CIM.CIMRasterColorizer + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.Brightness + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.Contrast + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.ResamplingType + // cref: ArcGIS.Core.CIM.RasterResamplingType + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Update the raster colorizer on a raster layer await QueuedTask.Run(() => { @@ -1925,23 +2434,29 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetColorizer() + // cref: ArcGIS.Core.CIM.CIMRasterRGBColorizer + // cref: ArcGIS.Core.CIM.CIMRasterRGBColorizer.StretchType + // cref: ArcGIS.Core.CIM.RasterStretchType + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Update the RGB colorizer on a raster layer await QueuedTask.Run(() => { // Get the colorizer from the raster layer. CIMRasterColorizer rColorizer = rasterLayer.GetColorizer(); // Check if the colorizer is an RGB colorizer. - if (rColorizer is CIMRasterRGBColorizer) + if (rColorizer is CIMRasterRGBColorizer rasterRGBColorizer) { - CIMRasterRGBColorizer rasterRGBColorizer = (CIMRasterRGBColorizer)rColorizer; // Update RGB colorizer properties. rasterRGBColorizer.StretchType = RasterStretchType.ESRI; // Update the raster layer with the changed colorizer. - rasterLayer.SetColorizer((CIMRasterColorizer)rasterRGBColorizer); + rasterLayer.SetColorizer(rasterRGBColorizer); } }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType #region Check if a certain colorizer can be applied to a raster layer await QueuedTask.Run(() => { @@ -1953,6 +2468,13 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.CreateColorizerAsync(ArcGIS.Desktop.Mapping.RasterColorizerDefinition) + // cref: ArcGIS.core.CIM.CIMRasterStretchColorizer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Create a new colorizer based on a default colorizer definition and apply it to the raster layer await QueuedTask.Run(async () => { @@ -1970,6 +2492,13 @@ await QueuedTask.Run(async () => }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor(System.Int32, ArcGIS.Core.CIM.RasterStretchType, System.Double, ArcGIS.Core.CIM.CIMColorRamp) + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.CreateColorizerAsync(ArcGIS.Desktop.Mapping.RasterColorizerDefinition) + // cref: ArcGIS.core.CIM.CIMRasterStretchColorizer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Create a new colorizer based on a custom colorizer definition and apply it to the raster layer await QueuedTask.Run(async () => { @@ -1989,18 +2518,32 @@ await QueuedTask.Run(async () => }); #endregion + // cref: ArcGIS.Desktop.Mapping.RasterLayer + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams.#ctor(System.Uri) + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams.ColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams, ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create a raster layer with a new colorizer definition // Create a new stretch colorizer definition using default constructor. StretchColorizerDefinition stretchColorizerDef = new StretchColorizerDefinition(); + var rasterLayerCreationParams = new RasterLayerCreationParams(new Uri(url)) + { + ColorizerDefinition = stretchColorizerDef, + Name = layerName, + MapMemberIndex = 0 + }; await QueuedTask.Run(() => { // Create a raster layer using the colorizer definition created above. // Note: You can create a raster layer from a url, project item, or data connection. RasterLayer rasterLayerfromURL = - LayerFactory.Instance.CreateRasterLayer(new Uri(url), aMap, 0, layerName, stretchColorizerDef) as RasterLayer; + LayerFactory.Instance.CreateLayer(rasterLayerCreationParams, aMap); }); #endregion } + #region ProSnippet Group: Mosaic Layers #endregion public async Task MosaicLayers() @@ -2009,6 +2552,8 @@ public async Task MosaicLayers() string layerName = null; CIMColorRamp colorRamp = null; + // cref: ArcGIS.Desktop.Mapping.MosaicLayer + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(System.Uri, ArcGIS.Desktop.Mapping.ILayerContainerEdit, Saystem.Int, System.String) #region Create a mosaic layer MosaicLayer mosaicLayer = null; string url = @"C:\Images\countries.gdb\Italy"; @@ -2016,10 +2561,19 @@ await QueuedTask.Run(() => { // Create a mosaic layer using a path to a mosaic dataset. // Note: You can create a mosaic layer from a url, project item, or data connection. - mosaicLayer = (MosaicLayer)LayerFactory.Instance.CreateLayer(new Uri(url), aMap); + mosaicLayer = LayerFactory.Instance.CreateLayer(new Uri(url), aMap) as MosaicLayer; }); #endregion + // cref: ArcGIS.Desktop.Mapping.MosaicLayer.GetImageLayer() + // cref: ArcGIS.Desktop.Mapping.ImageMosaicSubLayer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetColorizer() + // cref: ArcGIS.Core.CIM.CIMRasterColorizer + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.Brightness + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.Contrast + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.ResamplingType + // cref: ArcGIS.Core.CIM.RasterResamplingType + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Update the raster colorizer on a mosaic layer await QueuedTask.Run(() => { @@ -2036,6 +2590,13 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.MosaicLayer.GetImageLayer() + // cref: ArcGIS.Desktop.Mapping.ImageMosaicSubLayer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetColorizer() + // cref: ArcGIS.Core.CIM.CIMRasterRGBColorizer + // cref: ArcGIS.Core.CIM.CIMRasterRGBColorizer.StretchType + // cref: ArcGIS.Core.CIM.RasterStretchType + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Update the RGB colorizer on a mosaic layer await QueuedTask.Run(() => { @@ -2044,18 +2605,20 @@ await QueuedTask.Run(() => // Get the colorizer from the image sub-layer. CIMRasterColorizer rColorizer = mosaicImageSubLayer.GetColorizer(); // Check if the colorizer is an RGB colorizer. - if (rColorizer is CIMRasterRGBColorizer) + if (rColorizer is CIMRasterRGBColorizer rasterRGBColorizer) { - // Cast colorizer type from CIMRasterColorizer into CIMRasterRGBColorizer. - CIMRasterRGBColorizer rasterRGBColorizer = (CIMRasterRGBColorizer)rColorizer; // Update RGB colorizer properties. rasterRGBColorizer.StretchType = RasterStretchType.ESRI; // Update the image sub-layer with the changed colorizer. - mosaicImageSubLayer.SetColorizer((CIMRasterColorizer)rasterRGBColorizer); + mosaicImageSubLayer.SetColorizer(rasterRGBColorizer); } }); #endregion + // cref: ArcGIS.Desktop.Mapping.MosaicLayer.GetImageLayer() + // cref: ArcGIS.Desktop.Mapping.ImageMosaicSubLayer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType #region Check if a certain colorizer can be applied to a mosaic layer await QueuedTask.Run(() => { @@ -2070,6 +2633,15 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.MosaicLayer.GetImageLayer() + // cref: ArcGIS.Desktop.Mapping.ImageMosaicSubLayer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.CreateColorizerAsync(ArcGIS.Desktop.Mapping.RasterColorizerDefinition) + // cref: ArcGIS.core.CIM.CIMRasterStretchColorizer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Create a new colorizer based on a default colorizer definition and apply it to the mosaic layer await QueuedTask.Run(async () => { @@ -2089,6 +2661,15 @@ await QueuedTask.Run(async () => }); #endregion + // cref: ArcGIS.Desktop.Mapping.MosaicLayer.GetImageLayer() + // cref: ArcGIS.Desktop.Mapping.ImageMosaicSubLayer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor(System.Int32, ArcGIS.Core.CIM.RasterStretchType, System.Double, ArcGIS.Core.CIM.CIMColorRamp) + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.CreateColorizerAsync(ArcGIS.Desktop.Mapping.RasterColorizerDefinition) + // cref: ArcGIS.core.CIM.CIMRasterStretchColorizer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Create a new colorizer based on a custom colorizer definition and apply it to the mosaic layer await QueuedTask.Run(async () => { @@ -2110,23 +2691,43 @@ await QueuedTask.Run(async () => }); #endregion + // cref: ArcGIS.Desktop.Mapping.MosaicLayer + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams.#ctor(System.Uri) + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams.ColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams, ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create a mosaic layer with a new colorizer definition // Create a new colorizer definition using default constructor. StretchColorizerDefinition stretchColorizerDef = new StretchColorizerDefinition(); + var rasterLayerCreationParams = new RasterLayerCreationParams(new Uri(url)) + { + Name = layerName, + ColorizerDefinition = stretchColorizerDef, + MapMemberIndex = 0 + + }; await QueuedTask.Run(() => { // Create a mosaic layer using the colorizer definition created above. // Note: You can create a mosaic layer from a url, project item, or data connection. MosaicLayer newMosaicLayer = - LayerFactory.Instance.CreateMosaicLayer(new Uri(url), aMap, 0, layerName, stretchColorizerDef) as MosaicLayer; + LayerFactory.Instance.CreateLayer(rasterLayerCreationParams, aMap); }); #endregion + // cref: ArcGIS.Desktop.Mapping.MosaicLayer.GetImageLayer() + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer.GetMosaicRule() + // cref: ArcGIS.Core.CIM.CIMMosaicRule + // cref: ArcGIS.Core.CIM.CIMMosaicRule.MosaicMethod + // cref: ArcGIS.Core.CIM.RasterMosaicMethod + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer.SetMosaicRule(ArcGIS.Core.CIM.CIMMosaicRule) #region Update the sort order - mosaic method on a mosaic layer await QueuedTask.Run(() => { // Get the image sub-layer from the mosaic layer. - ImageServiceLayer mosaicImageSubLayer = (ImageServiceLayer)mosaicLayer.GetImageLayer(); + ImageServiceLayer mosaicImageSubLayer = mosaicLayer.GetImageLayer() as ImageServiceLayer; // Get the mosaic rule. CIMMosaicRule mosaicingRule = mosaicImageSubLayer.GetMosaicRule(); // Set the Mosaic Method to Center. @@ -2136,11 +2737,17 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.MosaicLayer.GetImageLayer() + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer.GetMosaicRule() + // cref: ArcGIS.Core.CIM.CIMMosaicRule + // cref: ArcGIS.Core.CIM.CIMMosaicRule.MosaicOperatorType + // cref: ArcGIS.Core.CIM.RasterMosaicOperatorType + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer.SetMosaicRule(ArcGIS.Core.CIM.CIMMosaicRule) #region Update the resolve overlap - mosaic operator on a mosaic layer await QueuedTask.Run(() => { // Get the image sub-layer from the mosaic layer. - ImageServiceLayer mosaicImageSublayer = (ImageServiceLayer)mosaicLayer.GetImageLayer(); + ImageServiceLayer mosaicImageSublayer = mosaicLayer.GetImageLayer() as ImageServiceLayer; // Get the mosaic rule. CIMMosaicRule mosaicRule = mosaicImageSublayer.GetMosaicRule(); // Set the Mosaic Operator to Mean. @@ -2150,6 +2757,7 @@ await QueuedTask.Run(() => }); #endregion } + #region ProSnippet Group: Image Service Layers #endregion public async Task ImageServiceLayers() @@ -2158,6 +2766,8 @@ public async Task ImageServiceLayers() string layerName = null; CIMColorRamp colorRamp = null; + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(System.Uri, ArcGIS.Desktop.Mapping.ILayerContainerEdit, Saystem.Int32, System.String) #region Create an image service layer ImageServiceLayer isLayer = null; string url = @@ -2165,10 +2775,17 @@ public async Task ImageServiceLayers() await QueuedTask.Run(() => { // Create an image service layer using the url for an image service. - isLayer = (ImageServiceLayer)LayerFactory.Instance.CreateLayer(new Uri(url), aMap); + isLayer = LayerFactory.Instance.CreateLayer(new Uri(url), aMap) as ImageServiceLayer; }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetColorizer() + // cref: ArcGIS.Core.CIM.CIMRasterColorizer + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.Brightness + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.Contrast + // cref: ArcGIS.Core.CIM.CIMRasterColorizer.ResamplingType + // cref: ArcGIS.Core.CIM.RasterResamplingType + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Update the raster colorizer on an image service layer await QueuedTask.Run(() => { @@ -2183,16 +2800,20 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetColorizer() + // cref: ArcGIS.Core.CIM.CIMRasterColorizer + // cref: ArcGIS.Core.CIM.CIMRasterRGBColorizer + // cref: ArcGIS.Core.CIM.CIMRasterRGBColorizer.StretchType + // cref: ArcGIS.Core.CIM.RasterStretchType + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Update the RGB colorizer on an image service layer await QueuedTask.Run(() => { // Get the colorizer from the image service layer. CIMRasterColorizer rColorizer = isLayer.GetColorizer(); // Check if the colorizer is an RGB colorizer. - if (rColorizer is CIMRasterRGBColorizer) + if (rColorizer is CIMRasterRGBColorizer rasterRGBColorizer) { - // Cast colorizer type from CIMRasterColorizer to CIMRasterRGBColorizer. - CIMRasterRGBColorizer rasterRGBColorizer = (CIMRasterRGBColorizer)rColorizer; // Update RGB colorizer properties. rasterRGBColorizer.StretchType = RasterStretchType.ESRI; // Update the image service layer with the changed colorizer. @@ -2201,6 +2822,8 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType #region Check if a certain colorizer can be applied to an image service layer await QueuedTask.Run(() => { @@ -2212,6 +2835,13 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.CreateColorizerAsync(ArcGIS.Desktop.Mapping.RasterColorizerDefinition) + // cref: ArcGIS.core.CIM.CIMRasterStretchColorizer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Create a new colorizer based on a default colorizer definition and apply it to the image service layer await QueuedTask.Run(async () => { @@ -2229,6 +2859,13 @@ await QueuedTask.Run(async () => }); #endregion + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.GetApplicableColorizers() + // cref: ArcGIS.Desktop.Mapping.RasterColorizerType + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor(System.Int32, ArcGIS.Core.CIM.RasterStretchType, System.Double, ArcGIS.Core.CIM.CIMColorRamp) + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.CreateColorizerAsync(ArcGIS.Desktop.Mapping.RasterColorizerDefinition) + // cref: ArcGIS.core.CIM.CIMRasterStretchColorizer + // cref: ArcGIS.Desktop.Mapping.BasicRasterLayer.SetColorizer(ArcGIS.Core.CIM.CIMRasterColorizer) #region Create a new colorizer based on a custom colorizer definition and apply it to the image service layer await QueuedTask.Run(async () => { @@ -2248,17 +2885,34 @@ await QueuedTask.Run(async () => }); #endregion + // cref: ArcGIS.Desktop.Mapping.StretchColorizerDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams.#ctor(System.Uri) + // cref: ArcGIS.Desktop.Mapping.RasterLayerCreationParams.ColorizerDefinition + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer(ArcGIS.Desktop.Mapping.LayerCreationParams, ArcGIS.Desktop.Mapping.ILayerContainerEdit) + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create an image service layer with a new colorizer definition // Create a new colorizer definition using default constructor. StretchColorizerDefinition stretchColorizerDef = new StretchColorizerDefinition(); + var rasterLayerCreationParams = new RasterLayerCreationParams(new Uri(url)) + { + Name = layerName, + ColorizerDefinition = stretchColorizerDef, + MapMemberIndex = 0 + }; await QueuedTask.Run(() => { // Create an image service layer using the colorizer definition created above. ImageServiceLayer imageServiceLayer = - LayerFactory.Instance.CreateRasterLayer(new Uri(url), aMap, 0, layerName, stretchColorizerDef) as ImageServiceLayer; + LayerFactory.Instance.CreateLayer(rasterLayerCreationParams, aMap); }); #endregion + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer.GetMosaicRule() + // cref: ArcGIS.Core.CIM.CIMMosaicRule + // cref: ArcGIS.Core.CIM.CIMMosaicRule.MosaicMethod + // cref: ArcGIS.Core.CIM.RasterMosaicMethod + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer.SetMosaicRule(ArcGIS.Core.CIM.CIMMosaicRule) #region Update the sort order - mosaic method on an image service layer await QueuedTask.Run(() => { @@ -2271,6 +2925,11 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer.GetMosaicRule() + // cref: ArcGIS.Core.CIM.CIMMosaicRule + // cref: ArcGIS.Core.CIM.CIMMosaicRule.MosaicOperatorType + // cref: ArcGIS.Core.CIM.RasterMosaicOperatorType + // cref: ArcGIS.Desktop.Mapping.ImageServiceLayer.SetMosaicRule(ArcGIS.Core.CIM.CIMMosaicRule) #region Update the resolve overlap - mosaic operator on an image service layer await QueuedTask.Run(() => { @@ -2289,7 +2948,12 @@ await QueuedTask.Run(() => #endregion public void StandaloneTables1() - { + { + // cref: ArcGIS.Desktop.Mapping.StandaloneTableFactory.CreateStandaloneTable(System.Uri, ArcGIS.Desktop.Mapping.IStandaloneTableContainerEdit, Saystem.Int32, System.String) + // cref: ArcGIS.Desktop.Mapping.StandaloneTableCreationParams + // cref: ArcGIS.Desktop.Mapping.StandaloneTableCreationParams.#ctor(ArcGIS.Desktop.Core.Item) + // cref: ArcGIS.Desktop.Mapping.StandaloneTableCreationParams.DefinitionQuery + // cref: ArcGIS.Desktop.Mapping.StandaloneTableFactory.CreateStandaloneTable(ArcGIS.Desktop.Mapping.StandaloneTableCreationParams, ArcGIS.Desktop.Mapping.IStandaloneTableContainerEdit) #region Create a StandaloneTable //container can be a map or group layer @@ -2308,18 +2972,20 @@ public void StandaloneTables1() container); //Use an item var item = ItemFactory.Instance.Create(@"C:\Temp\Data\SDK.gdb\ParcelOwners"); - var table3 = StandaloneTableFactory.Instance.CreateStandaloneTable(item, container); + var tableCreationParams = new StandaloneTableCreationParams(item); + var table3 = StandaloneTableFactory.Instance.CreateStandaloneTable(tableCreationParams, container); //use table creation params var table_params = new StandaloneTableCreationParams(item) { - DefinitionFilter = new CIMDefinitionFilter() - { - //optional - use a filter - DefinitionExpression = "LAND_USE = 3" - } + // At 2.x - DefinitionFilter = new CIMDefinitionFilter() + //{ + // //optional - use a filter + // DefinitionExpression = "LAND_USE = 3" + //} + DefinitionQuery = new DefinitionQuery(whereClause: "LAND_USE = 3", name: "Landuse") }; - var table4 = StandaloneTableFactory.Instance.CreateStandaloneTable(table_params, + var table4 = StandaloneTableFactory.Instance.CreateStandaloneTable(table_params, container); }); @@ -2330,6 +2996,13 @@ public void StandaloneTables1() public void StandaloneTables2() { + // cref: ArcGIS.Desktop.Mapping.Map.GetStandaloneTablesAsFlattenedList() + // cref: ArcGIS.Desktop.Mapping.Map.FindStandaloneTables(System.String) + // cref: ArcGIS.Desktop.Mapping.Map.StandaloneTables + // cref: ArcGIS.Desktop.Mapping.CompositeLayerWithTables.FindStandaloneTables(System.String) + // cref: ArcGIS.Desktop.Mapping.CompositeLayerWithTables.GetStandaloneTablesAsFlattenedList() + // cref: ArcGIS.Desktop.Mapping.CompositeLayerWithTables.StandaloneTables + // cref: ArcGIS.Desktop.Core.FrameworkExtender.OpenTablePane(ArcGIS.Desktop.Framework.PaneCollection,ArcGIS.Desktop.Mapping.MapMember, ArcGIS.Desktop.Mapping.TableViewMode) #region Retrieve a table from its container var container = MapView.Active.Map; @@ -2351,7 +3024,12 @@ public void StandaloneTables2() } public void StandaloneTables3() - { + { + // cref: ArcGIS.Desktop.Mapping.GroupLayer.MoveStandaloneTable(ArcGIS.Desktop.Mapping.StandaloneTable, System.Int32) + // cref: ArcGIS.Desktop.Mapping.Map.StandaloneTables + // cref: ArcGIS.Desktop.Mapping.Map.MoveStandaloneTable(ArcGIS.Desktop.Mapping.StandaloneTable, ArcGIS.Desktop.Mapping.CompositeLayerWithTables, System.Int32) + // cref: ArcGIS.Desktop.Mapping.CompositeLayerWithTables.FindStandaloneTables(System.String) + // cref: ArcGIS.Desktop.Mapping.Map.MoveStandaloneTable(ArcGIS.Desktop.Mapping.StandaloneTable, System.Int32) #region Move a Standalone table //get the first group layer that has at least one table @@ -2382,7 +3060,15 @@ public void StandaloneTables3() } public void StandaloneTables4() - { + { + // cref: ArcGIS.Desktop.Mapping.Map.GetStandaloneTablesAsFlattenedList() + // cref: ArcGIS.Desktop.Mapping.Map.StandaloneTables + // cref: ArcGIS.Desktop.Mapping.Map.RemoveStandaloneTable(ArcGIS.Desktop.Mapping.StandaloneTable) + // cref: ArcGIS.Desktop.Mapping.Map.RemoveStandaloneTables(System.IEnumerable) + // cref: ArcGIS.Desktop.Mapping.CompositeLayerWithTables.GetStandaloneTablesAsFlattenedList() + // cref: ArcGIS.Desktop.Mapping.CompositeLayerWithTables.StandaloneTables + // cref: ArcGIS.Desktop.Mapping.GroupLayer.RemoveStandaloneTable(ArcGIS.Desktop.Mapping.StandaloneTable) + // cref: ArcGIS.Desktop.Mapping.GroupLayer.RemoveStandaloneTables(System.IEnumerable) #region Remove a Standalone table //get the first group layer that has at least one table @@ -2396,7 +3082,7 @@ public void StandaloneTables4() var tables = map.GetStandaloneTablesAsFlattenedList(); //delete the first... if (tables.Count() > 0) - { + { map.RemoveStandaloneTable(tables.First()); //or delete all of them map.RemoveStandaloneTables(tables); @@ -2410,14 +3096,18 @@ public void StandaloneTables4() #endregion } - #region ProSnippet Group: Symbol Layer Drawing, SLD + #region ProSnippet Group: Symbol Layer Drawing (SLD) #endregion public void SLD1() - { + { FeatureLayer featLayer = null; GroupLayer groupLayer = null; + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CanAddSymbolLayerDrawing() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.AddSymbolLayerDrawing() + // cref: ArcGIS.Desktop.Mapping.GroupLayer.CanAddSymbolLayerDrawing() + // cref: ArcGIS.Desktop.Mapping.GroupLayer.AddSymbolLayerDrawing() #region Add SLD QueuedTask.Run(() => @@ -2434,6 +3124,8 @@ public void SLD1() #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.HasSymbolLayerDrawingAdded() + // cref: ArcGIS.Desktop.Mapping.GroupLayer.HasSymbolLayerDrawingAdded() #region Determine if a layer has SLD added //SLD can be added to feature layers and group layers @@ -2447,11 +3139,11 @@ public void SLD1() //Check if the layer has SLD added -returns a tuple var tuple = featLayer.HasSymbolLayerDrawingAdded(); if (tuple.addedOnLayer) - { + { //SLD is added on the layer - } + } else if (tuple.addedOnParent) - { + { //SLD is added on the parent (group layer) - //check parent...this can be recursive var parentLayer = GetParentLayerWithSLD(featLayer.Parent as GroupLayer); @@ -2476,6 +3168,12 @@ public GroupLayer GetParentLayerWithSLD(GroupLayer groupLayer) #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.HasSymbolLayerDrawingAdded() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetUseSymbolLayerDrawing() + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetUseSymbolLayerDrawing(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.GroupLayer.HasSymbolLayerDrawingAdded() + // cref: ArcGIS.Desktop.Mapping.GroupLayer.GetUseSymbolLayerDrawing() + // cref: ArcGIS.Desktop.Mapping.GroupLayer.SetUseSymbolLayerDrawing(System.Boolean) #region Enable/Disable SLD QueuedTask.Run(() => @@ -2484,16 +3182,16 @@ public GroupLayer GetParentLayerWithSLD(GroupLayer groupLayer) //HasSymbolLayerDrawingAdded returns a tuple - to check //the layer has SLD (not its parent) check addedOnLayer if (featLayer.HasSymbolLayerDrawingAdded().addedOnLayer) - { + { //the layer has SLD but is the layer currently using it? //GetUseSymbolLayerDrawing returns a tuple - useOnLayer for //the layer (and useOnParent for the parent layer) if (!featLayer.GetUseSymbolLayerDrawing().useOnLayer) - { + { //enable it featLayer.SetUseSymbolLayerDrawing(true); - } - } + } + } //Enable/Disable SLD on a layer parent if (featLayer.HasSymbolLayerDrawingAdded().addedOnParent) @@ -2543,6 +3241,13 @@ public GroupLayer GetParentLayerWithSLD(GroupLayer groupLayer) public async Task GNSS() { { + // cref: ArcGIS.Desktop.Core.DeviceLocation.SerialPortDeviceLocationSource.#ctor + // cref: ArcGIS.Desktop.Core.DeviceLocation.SerialPortDeviceLocationSource.ComPort + // cref: ArcGIS.Desktop.Core.DeviceLocation.SerialPortDeviceLocationSource.BaudRate + // cref: ArcGIS.Desktop.Core.DeviceLocation.SerialPortDeviceLocationSource.AntennaHeight + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationProperties.#ctor + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationProperties.AccuracyThreshold + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.Open() #region Connect to a Device Location Source var newSrc = new SerialPortDeviceLocationSource(); @@ -2568,16 +3273,18 @@ await QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.GetSource() #region Get the Current Device Location Source var source = DeviceLocationService.Instance.GetSource(); if (source == null) - { + { //There is no current source - } + } #endregion + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.Close() #region Close the Current Device Location Source //Is there a current device source? var src = DeviceLocationService.Instance.GetSource(); @@ -2593,6 +3300,13 @@ await QueuedTask.Run(() => } { + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.IsDeviceConnected() + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.GetSource() + // cref: ArcGIS.Desktop.Core.DeviceLocation.SerialPortDeviceLocationSource + // cref: ArcGIS.Desktop.Core.DeviceLocation.SerialPortDeviceLocationSource.GetSpatialReference() + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.GetProperties() + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationProperties + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationProperties.AccuracyThreshold #region Get Current Device Location Source and Properties bool isConnected = DeviceLocationService.Instance.IsDeviceConnected(); @@ -2617,12 +3331,16 @@ await QueuedTask.Run(() => } var dlProps = DeviceLocationService.Instance.GetProperties(); var accuracy = dlProps.AccuracyThreshold; - + #endregion } { + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.GetProperties() + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationProperties + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationProperties.AccuracyThreshold + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.UpdateProperties(ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationProperties) #region Update Properties on the Current Device Location Source await QueuedTask.Run(() => @@ -2635,11 +3353,56 @@ await QueuedTask.Run(() => }); #endregion } + } + + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.DeviceLocationPropertiesUpdatedEvent + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.DeviceLocationPropertiesUpdatedEvent.Subscribe + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.DeviceLocationPropertiesUpdatedEventArgs + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.DeviceLocationPropertiesUpdatedEventArgs.DeviceLocationProperties + #region Subscribe to DeviceLocationPropertiesUpdated event + private void SubscribeToPropertiesEvents() + { + DeviceLocationPropertiesUpdatedEvent.Subscribe(OnDeviceLocationPropertiesUpdated); + } + private void OnDeviceLocationPropertiesUpdated(DeviceLocationPropertiesUpdatedEventArgs args) + { + if (args == null) + return; + + var properties = args.DeviceLocationProperties; + + // TODO - something with the updated properties + } + #endregion + + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.DeviceLocationSourceChangedEvent + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.DeviceLocationSourceChangedEvent.Subscribe + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.DeviceLocationSourceChangedEventArgs + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.DeviceLocationSourceChangedEventArgs.DeviceLocationSource + #region Subscribe to DeviceLocationSourceChanged event + private void SubscribeToSourceEvents() + { + DeviceLocationSourceChangedEvent.Subscribe(OnDeviceLocationSourceChanged); + } + private void OnDeviceLocationSourceChanged(DeviceLocationSourceChangedEventArgs args) + { + if (args == null) + return; + + var source = args.DeviceLocationSource; + // TODO - something with the updated source properties + } + #endregion + + public async Task GNSS_Map() + { #region ProSnippet Group: Map Device Location Options #endregion { + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationService.IsDeviceLocationEnabled + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationService.SetDeviceLocationEnabled(System.Boolean) #region Enable/Disable Current Device Location Source For the Map bool enabled = MapDeviceLocationService.Instance.IsDeviceLocationEnabled; @@ -2653,6 +3416,13 @@ await QueuedTask.Run(() => } { + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationService.GetDeviceLocationOptions() + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions.DeviceLocationVisibility + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions.NavigationMode + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions.TrackUpNavigation + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions.ShowAccuracyBuffer + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MappingDeviceLocationNavigationMode #region Get Current Map Device Location Options var options = MapDeviceLocationService.Instance.GetDeviceLocationOptions(); @@ -2660,22 +3430,27 @@ await QueuedTask.Run(() => var visibility = options.DeviceLocationVisibility; var navMode = options.NavigationMode; var trackUp = options.TrackUpNavigation; + var showBuffer = options.ShowAccuracyBuffer; #endregion } - { + { + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationService.IsDeviceLocationEnabled #region Check if The Current Device Location Is Enabled On The Map if (MapDeviceLocationService.Instance.IsDeviceLocationEnabled) - { + { //The Device Location Source is Enabled - } + } #endregion } - { + { + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationService.SetDeviceLocationOptions(ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions) + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions.#ctor + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MappingDeviceLocationNavigationMode #region Set Current Map Device Location Options //Must be on the QueuedTask.Run() @@ -2699,10 +3474,11 @@ await QueuedTask.Run(() => NavigationMode = MappingDeviceLocationNavigationMode.KeepAtCenter, TrackUpNavigation = true }); - + #endregion } { + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationService.ZoomOrPanToCurrentLocation(System.Boolean) #region Zoom/Pan The Map To The Most Recent Location //Must be on the QueuedTask.Run() @@ -2721,6 +3497,7 @@ await QueuedTask.Run(() => { GraphicsLayer graphicsLayer = null; + // cref: ArcGIS.Desktop.Core.DeviceLocation.DeviceLocationService.GetCurrentSnapshot() #region Add the Most Recent Location To A Graphics Layer //var graphicsLayer = ... ; @@ -2729,7 +3506,7 @@ await QueuedTask.Run(() => // get the last location var pt = DeviceLocationService.Instance.GetCurrentSnapshot()?.GetPositionAsMapPoint(); if (pt != null) - { + { //Create a point symbol var ptSymbol = SymbolFactory.Instance.ConstructPointSymbol( CIMColor.CreateRGBColor(125, 125, 0), 10, SimpleMarkerStyle.Triangle); @@ -2742,10 +3519,41 @@ await QueuedTask.Run(() => #endregion } + { + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationService.GetDeviceLocationOptions() + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions.DeviceLocationVisibility + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions.NavigationMode + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MappingDeviceLocationNavigationMode + // cref: ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationService.SetDeviceLocationOptions(ArcGIS.Desktop.Mapping.DeviceLocation.MapDeviceLocationOptions) + #region Set map view to always be centered on the device location + var currentOptions = MapDeviceLocationService.Instance.GetDeviceLocationOptions(); + if (currentOptions == null) + return; + + currentOptions.DeviceLocationVisibility = true; + currentOptions.NavigationMode = MappingDeviceLocationNavigationMode.KeepAtCenter; + + await QueuedTask.Run(() => + { + MapDeviceLocationService.Instance.SetDeviceLocationOptions(currentOptions); + }); + #endregion + } } + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.SnapshotchangedEvent + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.SnapshotchangedEvent.Subscribe(Action action, System.Boolean) + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.SnapshotChangedEventArgs + // cref: ArcGIS.Desktop.Core.DeviceLocation.Events.SnapshotChangedEventArgs.Snapshot + // cref: ArcGIS.Desktop.Core.DeviceLocation.NMEASnapshot + // cref: ArcGIS.Desktop.Core.DeviceLocation.NMEASnapshot.GetPositionAsMapPoint() + // cref: ArcGIS.Desktop.Core.DeviceLocation.NMEASnapshot.Altitude + // cref: ArcGIS.Desktop.Core.DeviceLocation.NMEASnapshot.DateTime + // cref: ArcGIS.Desktop.Core.DeviceLocation.NMEASnapshot.VDOP + // cref: ArcGIS.Desktop.Core.DeviceLocation.NMEASnapshot.HDOP #region Subscribe to Location Snapshot event - private void SubscribeToEvents() + private void SubscribeToSnapshotEvents() { SnapshotChangedEvent.Subscribe(OnSnapshotChanged); } @@ -2781,6 +3589,8 @@ private void OnSnapshotChanged(SnapshotChangedEventArgs args) public void Masking1() { + // cref: ArcGIS.Desktop.Mapping.BasicFeaturelayer.GetDrawingOutline(System.Int64, ArcGIs.Desktop.Mapping.MapView, ArcGIS.Desktop.Mapping.DrawingOutlineType) + // cref: ArcGIS.Desktop.Mapping.DrawingOutlineType #region Get the Mask Geometry for a Feature var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList() @@ -2792,22 +3602,26 @@ public void Masking1() QueuedTask.Run(() => { - //get the first feature... - //...assuming at least one feature gets selected - var rc = featureLayer.GetTable().Search(); - rc.MoveNext(); - var oid = rc.Current.GetObjectID(); + using (var table = featureLayer.GetTable()) + { + using (var rc = table.Search()) + { + //get the first feature... + //...assuming at least one feature gets retrieved + rc.MoveNext(); + var oid = rc.Current.GetObjectID(); - //Use DrawingOutlineType.BoundingEnvelope to retrieve a generalized - //mask geometry or "Box". The mask will be in the same SpatRef as the map - var mask_geom = featureLayer.QueryDrawingOutline(oid, mv, DrawingOutlineType.Exact); + //Use DrawingOutlineType.BoundingEnvelope to retrieve a generalized + //mask geometry or "Box". The mask will be in the same SpatRef as the map + //At 2.x - var mask_geom = featureLayer.QueryDrawingOutline(oid, mv, DrawingOutlineType.Exact); + var mask_geom = featureLayer.GetDrawingOutline(oid, mv, DrawingOutlineType.Exact); - //TODO - use the mask geometry... - rc.Dispose(); + //TODO - use the mask geometry... + } + } }); #endregion } } - } diff --git a/Examples/MapAuthoring/ProSnippetAnnotation.cs b/Examples/MapAuthoring/ProSnippetAnnotation.cs index 1d82996..d3df052 100644 --- a/Examples/MapAuthoring/ProSnippetAnnotation.cs +++ b/Examples/MapAuthoring/ProSnippetAnnotation.cs @@ -88,8 +88,8 @@ internal Task CreatePolylineFromPointAsync(MapPoint pt, double toleran { // create a polyline from a starting point //use a tolerance to construct the second point - MapPoint pt2 = MapPointBuilder.CreateMapPoint(pt.X + tolerance, pt.Y, pt.SpatialReference); - return PolylineBuilder.CreatePolyline(new List() { pt, pt2 }); + MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(pt.X + tolerance, pt.Y, pt.SpatialReference); + return PolylineBuilderEx.CreatePolyline(new List() { pt, pt2 }); }); } @@ -103,6 +103,9 @@ internal async void UpdateTextString() BasicFeatureLayer annoLayer = MapView.Active.Map.GetLayersAsFlattenedList().First() as BasicFeatureLayer; var oid = 1; + // cref: ArcGIS.Desktop.Editing.Attributes.Attribute + // cref: ArcGIS.Desktop.Editing.Inspector.Load + // cref: ArcGIS.Desktop.Editing.EditOperation.Modify #region Update Annotation Text via attribute. Caveat: The TEXTSTRING Anno attribute must exist //See "Change Annotation Text Graphic" for an alternative if TEXTSTRING is missing from the schema @@ -136,6 +139,12 @@ await QueuedTask.Run(() => }); #endregion + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature.GetGraphic() + // cref: ArcGIS.Core.CIM.CIMTextGraphic + // cref: ArcGIS.Core.CIM.CIMTextGraphicBase.Shape + // cref: ArcGIS.Core.Geometry.GeometryEngine.Centroid + // cref: ArcGIS.Core.Geometry.GeometryEngine.Rotate #region Rotate or Move the Annotation await QueuedTask.Run(() => @@ -161,7 +170,8 @@ await QueuedTask.Run(() => { if (rowCursor.MoveNext()) { - using (var annoFeature = rowCursor.Current as ArcGIS.Core.Data.Mapping.AnnotationFeature) + using (var annoFeature = rowCursor.Current as + ArcGIS.Core.Data.Mapping.AnnotationFeature) { var graphic = annoFeature.GetGraphic(); var textGraphic = graphic as CIMTextGraphic; @@ -183,69 +193,29 @@ await QueuedTask.Run(() => #endregion + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature.GetGraphic() + // cref: ArcGIS.Desktop.Mapping.BasicFeatureLayer.GetTable #region Get the Annotation Text Graphic await QueuedTask.Run(() => { - var rc = annoLayer.GetTable().Search(); - rc.MoveNext(); - var af = rc.Current as AnnotationFeature; - var graphic = af.GetGraphic(); - var textGraphic = graphic as CIMTextGraphic; - - //Note: - //var outline_geom = af.GetGraphicOutline(); - //gets the anno text outline geometry... - af.Dispose(); - rc.Dispose(); - }); - - #endregion - - #region Change Annotation Text Graphic - - await QueuedTask.Run(() => - { - - EditOperation op = new EditOperation(); - op.Name = "Change annotation graphic"; - - //At 2.1 we must use an edit operation Callback... - op.Callback(context => + using (var table = annoLayer.GetTable()) { - QueryFilter qf = new QueryFilter() + using (var rc = table.Search()) { - WhereClause = "OBJECTID = 1" - }; - //Cursor must be non-recycling. Use the table ~not~ the layer..i.e. "GetTable().Search()" - //annoLayer is ~your~ Annotation layer - using (var rowCursor = annoLayer.GetTable().Search(qf, false)) - { - if (rowCursor.MoveNext()) - { - using (var annoFeature = rowCursor.Current as ArcGIS.Core.Data.Mapping.AnnotationFeature) - { - //Get the graphic from the anno feature - var graphic = annoFeature.GetGraphic(); - var textGraphic = graphic as CIMTextGraphic; - - // change the text and the color - textGraphic.Text = "hello world"; - var symbol = textGraphic.Symbol.Symbol; - symbol.SetColor(ColorFactory.Instance.RedRGB); - textGraphic.Symbol = symbol.MakeSymbolReference(); - // update the graphic - annoFeature.SetGraphic(textGraphic); - // store is required - annoFeature.Store(); - //refresh layer cache - context.Invalidate(annoFeature); - } - } - } - }, annoLayer.GetTable()); - - op.Execute(); + rc.MoveNext(); + using (var af = rc.Current as AnnotationFeature) + { + var graphic = af.GetGraphic(); + var textGraphic = graphic as CIMTextGraphic; + + //Note: + //var outline_geom = af.GetGraphicOutline(); + //gets the anno text outline geometry... + } + } + } }); #endregion @@ -253,6 +223,8 @@ await QueuedTask.Run(() => public void Masking1() { + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature + // cref: ArcGIS.Core.Data.Mapping.AnnotationFeature.GetGraphicOutline() #region Get the Outline Geometry for an Annotation var annoLayer = MapView.Active.Map.GetLayersAsFlattenedList() @@ -264,18 +236,22 @@ public void Masking1() { //get the first annotation feature... //...assuming at least one feature gets selected - var rc = annoLayer.GetFeatureClass().Search(); - rc.MoveNext(); - var af = rc.Current as AnnotationFeature; - var outline_geom = af.GetGraphicOutline(); - //TODO - use the outline... - - //Note: - //var graphic = annoFeature.GetGraphic(); - //gets the CIMTextGraphic... - - af.Dispose(); - rc.Dispose(); + using (var fc = annoLayer.GetFeatureClass()) + { + using (var rc = fc.Search()) + { + rc.MoveNext(); + using (var af = rc.Current as AnnotationFeature) + { + var outline_geom = af.GetGraphicOutline(); + //TODO - use the outline... + + //Note: + //var graphic = annoFeature.GetGraphic(); + //gets the CIMTextGraphic... + } + } + } }); #endregion @@ -283,6 +259,8 @@ public void Masking1() public void Masking2() { + // cref: ArcGIS.Desktop.Mapping.BasicFeatureLayer.GetDrawingOutline(System.Int64, ArcGIS.Desktop.Mapping.MapView, ArcGIS.Desktop.Mapping.DrawingOutlineType) + // cref: ArcGIS.Desktop.Mapping.AnnotationLayer.GetFeatureClass #region Get the Mask Geometry for an Annotation var annoLayer = MapView.Active.Map.GetLayersAsFlattenedList() @@ -295,16 +273,24 @@ public void Masking2() { //get the first annotation feature... //...assuming at least one feature gets selected - var rc = annoLayer.GetFeatureClass().Search(); - rc.MoveNext(); - var oid = rc.Current.GetObjectID(); - - //Use DrawingOutlineType.BoundingEnvelope to retrieve a generalized - //mask geometry or "Box". The mask will be in the same SpatRef as the map. - //The mask will be constructed using the anno class reference scale - var mask_geom = annoLayer.QueryDrawingOutline(oid, mv, DrawingOutlineType.Exact); - - rc.Dispose(); + using (var fc = annoLayer.GetFeatureClass()) + { + using (var rc = fc.Search()) + { + rc.MoveNext(); + using (var row = rc.Current) + { + var oid = row.GetObjectID(); + + //Use DrawingOutlineType.BoundingEnvelope to retrieve a generalized + //mask geometry or "Box". The mask will be in the same SpatRef as the map. + //The mask will be constructed using the anno class reference scale + //At 2.x - var mask_geom = annoLayer.QueryDrawingOutline(oid, mv, DrawingOutlineType.Exact); + + var mask_geom = annoLayer.GetDrawingOutline(oid, mv, DrawingOutlineType.Exact); + } + } + } }); #endregion diff --git a/Examples/MapAuthoring/ProSnippetLabeling.cs b/Examples/MapAuthoring/ProSnippetLabeling.cs index fd21b10..c9395b7 100644 --- a/Examples/MapAuthoring/ProSnippetLabeling.cs +++ b/Examples/MapAuthoring/ProSnippetLabeling.cs @@ -30,423 +30,516 @@ limitations under the License. namespace LabelingSnippets { - internal class Label : Button + internal class Label : Button + { + protected override async void OnClick() { - protected override async void OnClick() - { - var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType().Where(f => f.ShapeType == esriGeometryType.esriGeometryPoint).FirstOrDefault() ; - var symbol = await CreateTextSymbolWithHaloAsync(); - await ModifyLabelsLeaderLineAnchorPolygon(lyr); - } - - /// - /// Get the active map's labeling engine - Maplex or Standard labeling engine. - /// - /// - private static Task GetMapLabelEngineAsync() - { - return QueuedTask.Run(() => - { - #region Get the active map's labeling engine - Maplex or Standard labeling engine - //Note: call within QueuedTask.Run() - //Get the active map's definition - CIMMap. - var cimMap = MapView.Active.Map.GetDefinition(); - //Get the labeling engine from the map definition - CIMGeneralPlacementProperties labelEngine = cimMap.GeneralPlacementProperties; - #endregion - return labelEngine; - }); - } - - /// - /// Change the active map's labeling engine from Standard to Maplex or vice versa - /// - /// Switches between the Maplex and Standard labeling engines. The current label engine's properties are stored so they can be restored when swicthed back. - /// - private static Task ChangeLabelEngineAsync() - { - return QueuedTask.Run(() => - { - #region Change the active map's labeling engine from Standard to Maplex or vice versa - //Note: call within QueuedTask.Run() - //Get the active map's definition - CIMMap. - var cimMap = MapView.Active.Map.GetDefinition(); - //Get the labeling engine from the map definition - var cimGeneralPlacement = cimMap.GeneralPlacementProperties; - - if (cimGeneralPlacement is CIMMaplexGeneralPlacementProperties) - { - //Current labeling engine is Maplex labeling engine - //store the current label engine props if needed. - var maplexLabelEngineProps = cimGeneralPlacement; - //Create a new standard label engine properties - var cimStandardPlacementProperties = new CIMStandardGeneralPlacementProperties(); - //Set the CIMMap's GeneralPlacementProperties to the new label engine - cimMap.GeneralPlacementProperties = cimStandardPlacementProperties; - } - else - { - //Current labeling engine is Standard labeling engine - //store the current label engine props if needed. - var standardLabelEngine = cimGeneralPlacement; - //Create a new Maplex label engine properties - var cimMaplexGeneralPlacementProperties = new CIMMaplexGeneralPlacementProperties(); - //Set the CIMMap's GeneralPlacementProperties to the new label engine - cimMap.GeneralPlacementProperties = cimMaplexGeneralPlacementProperties; - } - //Set the map's definition - MapView.Active.Map.SetDefinition(cimMap); - #endregion - }); - } + var lyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType().Where(f => f.ShapeType == esriGeometryType.esriGeometryPoint).FirstOrDefault(); + var symbol = await CreateTextSymbolWithHaloAsync(); + await ModifyLabelsLeaderLineAnchorPolygon(lyr); + } - + /// + /// Get the active map's labeling engine - Maplex or Standard labeling engine. + /// + /// + private static Task GetMapLabelEngineAsync() + { + // cref: ArcGIS.Core.CIM.CIMGeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMap.GeneralPlacementProperties + return QueuedTask.Run(() => + { + #region Get the active map's labeling engine - Maplex or Standard labeling engine + //Note: call within QueuedTask.Run() - /// - /// Apply text symbol to a feature layer. - /// - private static Task ApplyLabelAsync(FeatureLayer featureLayer, CIMTextSymbol textSymbol) - { - return QueuedTask.Run(() => - { - #region Apply text symbol to a feature layer - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //Set the label classes' symbol to the custom text symbol - //Refer to the ProSnippets-TextSymbols wiki page for help with creating custom text symbols. - //Example: var textSymbol = await CreateTextSymbolWithHaloAsync(); - theLabelClass.TextSymbol.Symbol = textSymbol; - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - //set the label's visiblity - featureLayer.SetLabelVisibility(true); - #endregion - }); - } - /// - /// Enable labeling of a layer - /// - /// - /// - private static Task EnableLayerLabelVisibility(FeatureLayer featureLayer) - { - return QueuedTask.Run(() => - { - #region Enable labeling of a layer - //Note: call within QueuedTask.Run() - //set the label's visiblity - featureLayer.SetLabelVisibility(true); - #endregion - }); - } + //Get the active map's definition - CIMMap. + var cimMap = MapView.Active.Map.GetDefinition(); + //Get the labeling engine from the map definition + CIMGeneralPlacementProperties labelEngine = cimMap.GeneralPlacementProperties; + #endregion + return labelEngine; + }); + } - /// - /// Modify the Placement/Position of labels - Point geometry - /// - /// - /// - /// - /// The label placement and positions are modified for a point, line or polygon feature class. - /// The properties modified are based on the Standard or Maplex label engine used on the Map defintion. - /// - private static Task ModifyLabelsPlacementPointAsync(FeatureLayer featureLayer) - { - if (featureLayer.ShapeType != esriGeometryType.esriGeometryPoint) - return Task.FromResult(0); - return QueuedTask.Run(() => - { - #region Modify the Placement/Position of labels - Point geometry - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //Modify label Placement - //Check if the label engine is Maplex or standard. - CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; - if (labelEngine is CIMStandardGeneralPlacementProperties) //Current labeling engine is Standard labeling engine - theLabelClass.StandardLabelPlacementProperties.PointPlacementMethod = StandardPointPlacementMethod.OnTopPoint; - else //Current labeling engine is Maplex labeling engine - theLabelClass.MaplexLabelPlacementProperties.PointPlacementMethod = MaplexPointPlacementMethod.CenteredOnPoint; - - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - #endregion - - }); - } - /// - /// Modify the Placement/Position of labels - Line geometry - /// - /// - /// + /// + /// Change the active map's labeling engine from Standard to Maplex or vice versa + /// + /// Switches between the Maplex and Standard labeling engines. The current label engine's properties are stored so they can be restored when swicthed back. + /// + private static Task ChangeLabelEngineAsync() + { + return QueuedTask.Run(() => + { + // cref: ArcGIS.Core.CIM.CIMGeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMap.GeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMStandardGeneralPlacementProperties + // cref: ArcGIS.Core.CIM.CIMStandardGeneralPlacementProperties.#ctor + // cref: ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.#ctor + #region Change the active map's labeling engine from Standard to Maplex or vice versa + //Note: call within QueuedTask.Run() - private static Task ModifyLabelsPlacementLineAsync(FeatureLayer featureLayer) + //Get the active map's definition - CIMMap. + var cimMap = MapView.Active.Map.GetDefinition(); + //Get the labeling engine from the map definition + var cimGeneralPlacement = cimMap.GeneralPlacementProperties; + + if (cimGeneralPlacement is CIMMaplexGeneralPlacementProperties) { - if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolyline) - return Task.FromResult(0); - return QueuedTask.Run(() => - { - #region Modify the Placement/Position of labels - Line geometry - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //Modify label Placement - //Check if the label engine is Maplex or standard. - CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; - if (labelEngine is CIMStandardGeneralPlacementProperties) - { - //Current labeling engine is Standard labeling engine - var lineLablePosition = new CIMStandardLineLabelPosition - { - Perpendicular = true, - Parallel = false, - ProduceCurvedLabels = false, - Horizontal = false, - OnTop = true - }; - theLabelClass.StandardLabelPlacementProperties.LineLabelPosition = lineLablePosition; - } - else //Current labeling engine is Maplex labeling engine - { - theLabelClass.MaplexLabelPlacementProperties.LinePlacementMethod = MaplexLinePlacementMethod.CenteredPerpendicularOnLine; - theLabelClass.MaplexLabelPlacementProperties.LineFeatureType = MaplexLineFeatureType.General; - } - //theLabelClass.MaplexLabelPlacementProperties.LinePlacementMethod = MaplexLinePlacementMethod.CenteredPerpendicularOnLine; - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - #endregion - }); + //Current labeling engine is Maplex labeling engine + //Create a new standard label engine properties + var cimStandardPlacementProperties = new CIMStandardGeneralPlacementProperties(); + //Set the CIMMap's GeneralPlacementProperties to the new label engine + cimMap.GeneralPlacementProperties = cimStandardPlacementProperties; } - /// - /// Modify the Placement/Position of labels - Polygon geometry - /// - /// - /// - private static Task ModifyLabelsPlacementPolygonAsync(FeatureLayer featureLayer) + else { - if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolygon) - return Task.FromResult(0); - return QueuedTask.Run(() => - { - #region Modify the Placement/Position of labels - Polygon geometry - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //Modify label Placement - //Check if the label engine is Maplex or standard. - CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; - if (labelEngine is CIMStandardGeneralPlacementProperties) - { - //Current labeling engine is Standard Labeling engine - theLabelClass.StandardLabelPlacementProperties.PolygonPlacementMethod = StandardPolygonPlacementMethod.AlwaysHorizontal; - theLabelClass.StandardLabelPlacementProperties.PlaceOnlyInsidePolygon = true; - } - else - { - //Current labeling engine is Maplex labeling engine - theLabelClass.MaplexLabelPlacementProperties.PolygonFeatureType = MaplexPolygonFeatureType.LandParcel; - theLabelClass.MaplexLabelPlacementProperties.AvoidPolygonHoles = true; - theLabelClass.MaplexLabelPlacementProperties.PolygonPlacementMethod = MaplexPolygonPlacementMethod.HorizontalInPolygon; - theLabelClass.MaplexLabelPlacementProperties.CanPlaceLabelOutsidePolygon = true; - } - - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - //set the label's visiblity - featureLayer.SetLabelVisibility(true); - #endregion - - }); + //Current labeling engine is Standard labeling engine + //Create a new Maplex label engine properties + var cimMaplexGeneralPlacementProperties = new CIMMaplexGeneralPlacementProperties(); + //Set the CIMMap's GeneralPlacementProperties to the new label engine + cimMap.GeneralPlacementProperties = cimMaplexGeneralPlacementProperties; } + //Set the map's definition + MapView.Active.Map.SetDefinition(cimMap); + #endregion + }); + } - /// - /// Modify Orientation of a label using the MaplexEngine - Points and Polygon geometry - /// - /// - /// - /// - /// Orientation can be modified for Maplex Label engine only. - /// - private static Task ModifyLabelsOrientationPointPolygonAsync(FeatureLayer featureLayer) - { - if (featureLayer.ShapeType == esriGeometryType.esriGeometryLine) - return Task.FromResult(0); - return QueuedTask.Run( () => - { - //Check if the label engine is Maplex or standard. - CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; - if (labelEngine is CIMStandardGeneralPlacementProperties) - return; - #region Modify Orientation of a label using the MaplexEngine - Points and Polygon geometry - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //Modify label Orientation - theLabelClass.MaplexLabelPlacementProperties.GraticuleAlignment = true; - theLabelClass.MaplexLabelPlacementProperties.GraticuleAlignmentType = MaplexGraticuleAlignmentType.Curved; - - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - #endregion - }); - } - /// - /// Modify Orientation of a label using the MaplexEngine - Line geometry - /// - /// - /// - private static Task ModifyLabelsOrientationLineAsync(FeatureLayer featureLayer) + + /// + /// Apply text symbol to a feature layer. + /// + private static Task ApplyLabelAsync(FeatureLayer featureLayer, CIMTextSymbol textSymbol) + { + return QueuedTask.Run(() => + { + // cref: ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.LabelClasses + // cref: ArcGIS.Core.CIM.CIMLabelClass + // cref: ArcGIS.Core.CIM.CIMLabelClass.TextSymbol + #region Apply text symbol to a feature layer + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + //Set the label classes' symbol to the custom text symbol + //Refer to the ProSnippets-TextSymbols wiki page for help with creating custom text symbols. + //Example: var textSymbol = await CreateTextSymbolWithHaloAsync(); + theLabelClass.TextSymbol.Symbol = textSymbol; + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + //set the label's visiblity + featureLayer.SetLabelVisibility(true); + #endregion + }); + } + /// + /// Enable labeling of a layer + /// + /// + /// + private static Task EnableLayerLabelVisibility(FeatureLayer featureLayer) + { + return QueuedTask.Run(() => + { + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.IsLabelVisible + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetLabelVisibility + #region Enable labeling of a layer + //Note: call within QueuedTask.Run() + + if (!featureLayer.IsLabelVisible) + //set the label's visiblity + featureLayer.SetLabelVisibility(true); + #endregion + }); + } + + /// + /// Modify the Placement/Position of labels - Point geometry + /// + /// + /// + /// + /// The label placement and positions are modified for a point, line or polygon feature class. + /// The properties modified are based on the Standard or Maplex label engine used on the Map defintion. + /// + private static Task ModifyLabelsPlacementPointAsync(FeatureLayer featureLayer) + { + if (featureLayer.ShapeType != esriGeometryType.esriGeometryPoint) + return Task.FromResult(0); + return QueuedTask.Run(() => + { + // cref: ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.LabelClasses + // cref: ArcGIS.Core.CIM.CIMLabelClass + // cref: ArcGIS.Core.CIM.CIMLabelClass.StandardLabelPlacementProperties + // cref: ArcGIS.Core.CIM.CIMLabelClass.MaplexLabelPlacementProperties + // cref : ArcGIS.Core.CIM.CIMMaplexGeneralPlacementProperties.PointPlacementMethod + // cref : ArcGIS.Core.CIM.CIMStandardGeneralPlacementProperties.PointPlacementMethod + // cref : ArcGIS.Core.CIM.StandardPointPlacementMethod + // cref : ArcGIS.Core.CIM.MaplexPointPlacementMethod + // cref : ArcGIS.Core.CIM.CIMMap.GeneralPlacementProperties + #region Modify the Placement/Position of labels - Point geometry + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + + //Modify label Placement + //Check if the label engine is Maplex or standard. + CIMGeneralPlacementProperties labelEngine = + MapView.Active.Map.GetDefinition().GeneralPlacementProperties; + if (labelEngine is CIMStandardGeneralPlacementProperties) //Current labeling engine is Standard labeling engine + theLabelClass.StandardLabelPlacementProperties.PointPlacementMethod = + StandardPointPlacementMethod.OnTopPoint; + else //Current labeling engine is Maplex labeling engine + theLabelClass.MaplexLabelPlacementProperties.PointPlacementMethod = + MaplexPointPlacementMethod.CenteredOnPoint; + + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + #endregion + + }); + } + /// + /// Modify the Placement/Position of labels - Line geometry + /// + /// + /// + + private static Task ModifyLabelsPlacementLineAsync(FeatureLayer featureLayer) + { + if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolyline) + return Task.FromResult(0); + return QueuedTask.Run(() => + { + // cref: ArcGIS.Core.CIM.CIMStandardLineLabelPosition + // cref: ArcGIS.Core.CIM.CIMStandardLineLabelPosition.#ctor + // cref: ArcGIS.Core.CIM.CIMStandardLineLabelPosition.Perpendicular + // cref: ArcGIS.Core.CIM.CIMStandardLineLabelPosition.Parallel + // cref: ArcGIS.Core.CIM.CIMStandardLineLabelPosition.ProduceCurvedLabels + // cref: ArcGIS.Core.CIM.CIMStandardLineLabelPosition.Horizontal + // cref: ArcGIS.Core.CIM.CIMStandardLineLabelPosition.OnTop + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties.LineLabelPosition + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.LinePlacementMethod + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.LineFeatureType + // cref: ArcGIS.Core.CIM.MaplexLinePlacementMethod + // cref: ArcGIS.Core.CIM.MaplexLineFeatureType + #region Modify the Placement/Position of labels - Line geometry + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + //Modify label Placement + //Check if the label engine is Maplex or standard. + CIMGeneralPlacementProperties labelEngine = + MapView.Active.Map.GetDefinition().GeneralPlacementProperties; + if (labelEngine is CIMStandardGeneralPlacementProperties) { - if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolyline) - return Task.FromResult(0); - return QueuedTask.Run(() => - { - //Check if the label engine is Maplex or standard. - CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; - if (labelEngine is CIMStandardGeneralPlacementProperties) - return; - #region Modify Orientation of a label using the MaplexEngine - Line geometry - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //Modify label Orientation - theLabelClass.MaplexLabelPlacementProperties.AlignLabelToLineDirection = true; - - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - #endregion - }); + //Current labeling engine is Standard labeling engine + var lineLablePosition = new CIMStandardLineLabelPosition + { + Perpendicular = true, + Parallel = false, + ProduceCurvedLabels = false, + Horizontal = false, + OnTop = true + }; + theLabelClass.StandardLabelPlacementProperties.LineLabelPosition = + lineLablePosition; } - /// - /// Modify label Rotation (Point geomerty) - /// - /// - /// - private static Task ModifyLabelsRotationPointsAsync(FeatureLayer featureLayer) + else //Current labeling engine is Maplex labeling engine { - if (featureLayer.ShapeType != esriGeometryType.esriGeometryPoint) - return Task.FromResult(0); - return QueuedTask.Run(() => - { - //Check if the label engine is Maplex or standard. - CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; - if (labelEngine is CIMStandardGeneralPlacementProperties) - return; - #region Modify label Rotation - Point geometry - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //Modify label Rotation - CIMMaplexRotationProperties rotationProperties = new CIMMaplexRotationProperties - { - Enable = true, //Enable rotation - RotationField = "ELEVATION", //Field that is used to define rotation angle - AdditionalAngle = 15, //Additional rotation - RotationType = MaplexLabelRotationType.Arithmetic, - AlignmentType = MaplexRotationAlignmentType.Perpendicular, - AlignLabelToAngle = true - }; - theLabelClass.MaplexLabelPlacementProperties.RotationProperties = rotationProperties; - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - #endregion - }); + theLabelClass.MaplexLabelPlacementProperties.LinePlacementMethod = + MaplexLinePlacementMethod.CenteredPerpendicularOnLine; + theLabelClass.MaplexLabelPlacementProperties.LineFeatureType = + MaplexLineFeatureType.General; } - /// - /// Spread labels across Polygon geometry - /// - /// - /// - private static Task ModifyLabelsSpreadLabelPolygon(FeatureLayer featureLayer) + //theLabelClass.MaplexLabelPlacementProperties.LinePlacementMethod = MaplexLinePlacementMethod.CenteredPerpendicularOnLine; + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + #endregion + }); + } + /// + /// Modify the Placement/Position of labels - Polygon geometry + /// + /// + /// + private static Task ModifyLabelsPlacementPolygonAsync(FeatureLayer featureLayer) + { + if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolygon) + return Task.FromResult(0); + return QueuedTask.Run(() => + { + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties.PolygonPlacementMethod + // cref: ArcGIS.Core.CIM.CIMStandardLabelPlacementProperties.PlaceOnlyInsidePolygon + // cref: ArcGIS.Core.CIM.StandardPolygonPlacementMethod + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.PolygonFeatureType + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.AvoidPolygonHoles + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.PolygonPlacementMethod + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.CanPlaceLabelOutsidePolygon + // cref: ArcGIS.Core.CIM.MaplexPolygonFeatureType + // cref: ArcGIS.Core.CIM.MaplexPolygonPlacementMethod + #region Modify the Placement/Position of labels - Polygon geometry + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + //Modify label Placement + //Check if the label engine is Maplex or standard. + CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; + if (labelEngine is CIMStandardGeneralPlacementProperties) { - if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolygon) - return Task.FromResult(0); - return QueuedTask.Run(() => - { - //Check if the label engine is Maplex or standard. - CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; - if (labelEngine is CIMStandardGeneralPlacementProperties) - return; - #region Spread labels across Polygon geometry - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //Spread Labels (words and characters to fill feature) - // Spread words to fill feature - theLabelClass.MaplexLabelPlacementProperties.SpreadWords = true; - //Spread Characters to a fixed limit of 50% - theLabelClass.MaplexLabelPlacementProperties.SpreadCharacters = true; - theLabelClass.MaplexLabelPlacementProperties.MaximumCharacterSpacing = 50.0; - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - #endregion - - }); + //Current labeling engine is Standard Labeling engine + theLabelClass.StandardLabelPlacementProperties.PolygonPlacementMethod = + StandardPolygonPlacementMethod.AlwaysHorizontal; + theLabelClass.StandardLabelPlacementProperties.PlaceOnlyInsidePolygon = true; } - /// - /// Modify label's Leader Line Anchor point properties - Polygon geometry - /// - /// - /// - private static Task ModifyLabelsLeaderLineAnchorPolygon(FeatureLayer featureLayer) + else { - if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolygon) - return Task.FromResult(0); - return QueuedTask.Run(() => - { - //Check if the label engine is Maplex or standard. - CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; - if (labelEngine is CIMStandardGeneralPlacementProperties) - return; - #region Modify label's Leader Line Anchor point properties - Polygon geometry - //Note: call within QueuedTask.Run() - //Get the layer's definition - var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; - //Get the label classes - we need the first one - var listLabelClasses = lyrDefn.LabelClasses.ToList(); - var theLabelClass = listLabelClasses.FirstOrDefault(); - //If TextSymbol is a callout the leader line anachor point can be modified - theLabelClass.MaplexLabelPlacementProperties.PolygonAnchorPointType = MaplexAnchorPointType.Perimeter; - lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back - featureLayer.SetDefinition(lyrDefn); //set the layer's definition - #endregion - }); + //Current labeling engine is Maplex labeling engine + theLabelClass.MaplexLabelPlacementProperties.PolygonFeatureType = + MaplexPolygonFeatureType.LandParcel; + theLabelClass.MaplexLabelPlacementProperties.AvoidPolygonHoles = true; + theLabelClass.MaplexLabelPlacementProperties.PolygonPlacementMethod = + MaplexPolygonPlacementMethod.HorizontalInPolygon; + theLabelClass.MaplexLabelPlacementProperties.CanPlaceLabelOutsidePolygon = true; } - private static Task CreateTextSymbolWithHaloAsync() + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + //set the label's visiblity + featureLayer.SetLabelVisibility(true); + #endregion + + }); + } + + /// + /// Modify Orientation of a label using the MaplexEngine - Points and Polygon geometry + /// + /// + /// + /// + /// Orientation can be modified for Maplex Label engine only. + /// + private static Task ModifyLabelsOrientationPointPolygonAsync(FeatureLayer featureLayer) + { + if (featureLayer.ShapeType == esriGeometryType.esriGeometryLine) + return Task.FromResult(0); + return QueuedTask.Run(() => + { + //Check if the label engine is Maplex or standard. + CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; + if (labelEngine is CIMStandardGeneralPlacementProperties) + return; + + + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.GraticuleAlignment + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.GraticuleAlignmentType + // cref: ArcGIS.Core.CIM.MaplexGraticuleAlignmentType + #region Modify Orientation of a label using the MaplexEngine - Points and Polygon geometry + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + //Modify label Orientation + theLabelClass.MaplexLabelPlacementProperties.GraticuleAlignment = true; + theLabelClass.MaplexLabelPlacementProperties.GraticuleAlignmentType = MaplexGraticuleAlignmentType.Curved; + + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + #endregion + }); + } + + /// + /// Modify Orientation of a label using the MaplexEngine - Line geometry + /// + /// + /// + private static Task ModifyLabelsOrientationLineAsync(FeatureLayer featureLayer) + { + if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolyline) + return Task.FromResult(0); + return QueuedTask.Run(() => + { + //Check if the label engine is Maplex or standard. + CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; + if (labelEngine is CIMStandardGeneralPlacementProperties) + return; + + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.AlignLabelToLineDirection + #region Modify Orientation of a label using the MaplexEngine - Line geometry + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + //Modify label Orientation + theLabelClass.MaplexLabelPlacementProperties.AlignLabelToLineDirection = true; + + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + #endregion + }); + } + + /// + /// Modify label Rotation (Point geomerty) + /// + /// + /// + private static Task ModifyLabelsRotationPointsAsync(FeatureLayer featureLayer) + { + if (featureLayer.ShapeType != esriGeometryType.esriGeometryPoint) + return Task.FromResult(0); + return QueuedTask.Run(() => + { + //Check if the label engine is Maplex or standard. + CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; + if (labelEngine is CIMStandardGeneralPlacementProperties) + return; + + // cref: ArcGIS.Core.CIM.CIMLabelClass.MaplexLabelPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexRotationProperties + // cref: ArcGIS.Core.CIM.CIMMaplexRotationProperties.#ctor + // cref: ArcGIS.Core.CIM.CIMMaplexRotationProperties.Enable + // cref: ArcGIS.Core.CIM.CIMMaplexRotationProperties.RotationField + // cref: ArcGIS.Core.CIM.CIMMaplexRotationProperties.AdditionalAngle + // cref: ArcGIS.Core.CIM.CIMMaplexRotationProperties.RotationType + // cref: ArcGIS.Core.CIM.CIMMaplexRotationProperties.AlignmentType + // cref: ArcGIS.Core.CIM.CIMMaplexRotationProperties.AlignLabelToAngle + // cref: ArcGIS.Core.CIM.MaplexLabelRotationType + // cref ArcGIS.Core.CIM.MaplexRotationAlignmentType + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.RotationProperties + #region Modify label Rotation - Point geometry + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + //Modify label Rotation + CIMMaplexRotationProperties rotationProperties = new CIMMaplexRotationProperties { - return QueuedTask.Run(() => - { - //create a polygon symbol for the halo - var haloPoly = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid); - //create text symbol using the halo polygon - return SymbolFactory.Instance.ConstructTextSymbol(haloPoly, 10, "Arial", "Bold"); - }); - } + Enable = true, //Enable rotation + RotationField = "ELEVATION", //Field that is used to define rotation angle + AdditionalAngle = 15, //Additional rotation + RotationType = MaplexLabelRotationType.Arithmetic, + AlignmentType = MaplexRotationAlignmentType.Perpendicular, + AlignLabelToAngle = true + }; + theLabelClass.MaplexLabelPlacementProperties.RotationProperties = rotationProperties; + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + #endregion + }); + } + /// + /// Spread labels across Polygon geometry + /// + /// + /// + private static Task ModifyLabelsSpreadLabelPolygon(FeatureLayer featureLayer) + { + if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolygon) + return Task.FromResult(0); + return QueuedTask.Run(() => + { + //Check if the label engine is Maplex or standard. + CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; + if (labelEngine is CIMStandardGeneralPlacementProperties) + return; + + // cref: ArcGIS.Core.CIM.CIMLabelClass.MaplexLabelPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.SpreadWords + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.SpreadCharacters + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.MaximumCharacterSpacing + #region Spread labels across Polygon geometry + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + //Spread Labels (words and characters to fill feature) + // Spread words to fill feature + theLabelClass.MaplexLabelPlacementProperties.SpreadWords = true; + //Spread Characters to a fixed limit of 50% + theLabelClass.MaplexLabelPlacementProperties.SpreadCharacters = true; + theLabelClass.MaplexLabelPlacementProperties.MaximumCharacterSpacing = 50.0; + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + #endregion + + }); + } + /// + /// Modify label's Leader Line Anchor point properties - Polygon geometry + /// + /// + /// + private static Task ModifyLabelsLeaderLineAnchorPolygon(FeatureLayer featureLayer) + { + if (featureLayer.ShapeType != esriGeometryType.esriGeometryPolygon) + return Task.FromResult(0); + return QueuedTask.Run(() => + { + //Check if the label engine is Maplex or standard. + CIMGeneralPlacementProperties labelEngine = MapView.Active.Map.GetDefinition().GeneralPlacementProperties; + if (labelEngine is CIMStandardGeneralPlacementProperties) + return; + + // cref: ArcGIS.Core.CIM.CIMLabelClass.MaplexLabelPlacementProperties + // cref: ArcGIS.Core.CIM.CIMMaplexLabelPlacementProperties.PolygonAnchorPointType + // cref: ArcGIS.Core.CIM.MaplexAnchorPointType + #region Modify label's Leader Line Anchor point properties - Polygon geometry + //Note: call within QueuedTask.Run() + + //Get the layer's definition + var lyrDefn = featureLayer.GetDefinition() as CIMFeatureLayer; + //Get the label classes - we need the first one + var listLabelClasses = lyrDefn.LabelClasses.ToList(); + var theLabelClass = listLabelClasses.FirstOrDefault(); + //If TextSymbol is a callout the leader line anachor point can be modified + theLabelClass.MaplexLabelPlacementProperties.PolygonAnchorPointType = MaplexAnchorPointType.Perimeter; + lyrDefn.LabelClasses = listLabelClasses.ToArray(); //Set the labelClasses back + featureLayer.SetDefinition(lyrDefn); //set the layer's definition + #endregion + }); + } + + private static Task CreateTextSymbolWithHaloAsync() + { + return QueuedTask.Run(() => + { + //create a polygon symbol for the halo + var haloPoly = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid); + //create text symbol using the halo polygon + return SymbolFactory.Instance.ConstructTextSymbol(haloPoly, 10, "Arial", "Bold"); + }); } + } } diff --git a/Examples/MapAuthoring/ProSnippetRealtime.cs b/Examples/MapAuthoring/ProSnippetRealtime.cs index bf761f2..71099d3 100644 --- a/Examples/MapAuthoring/ProSnippetRealtime.cs +++ b/Examples/MapAuthoring/ProSnippetRealtime.cs @@ -41,7 +41,10 @@ public async void Example1() Map map = MapView.Active.Map; await QueuedTask.Run(() => { - // cref: Create Stream Layer with URI;ArcGIS.Desktop.Mapping.StreamLayer + // cref: ArcGIS.Desktop.Mapping.StreamLayer + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams._ctor(Uri) + // cref: ArcGIS.Desktop.Mapping.Layer.SetVisibility + // cref: ARCGIS.DESKTOP.MAPPING.ILAYERFACTORY.CREATELAYER(URI,ILAYERCONTAINEREDIT,INT32,STRING) #region Create Stream Layer with URI //Must be on the QueuedTask var url = "https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer"; @@ -64,19 +67,23 @@ public async void Example2() Map map = MapView.Active.Map; await QueuedTask.Run(() => { - - // cref: Create a stream layer with a definition query;ArcGIS.Desktop.Mapping.StreamLayer + + // cref: ArcGIS.Desktop.Mapping.StreamLayer + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams.DefinitionQuery + // cref: ARCGIS.DESKTOP.MAPPING.LAYERFACTORY.CREATELAYER + // cref: ArcGIS.Desktop.Mapping.DefinitionQuery._ctor(String,String) #region Create a stream layer with a definition query //Must be on the QueuedTask var url = "https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer"; var lyrCreateParam = new FeatureLayerCreationParams(new Uri(url)) { IsVisible = true, - DefinitionFilter = new CIMDefinitionFilter() - { - DefinitionExpression = "RWY = '29L'", - Name = "Runway" - } + //At 2.x - DefinitionFilter = new CIMDefinitionFilter() + //{ + // DefinitionExpression = "RWY = '29L'", + // Name = "Runway" + //} + DefinitionQuery = new DefinitionQuery(whereClause: "RWY = '29L'", name: "Runway") }; var streamLayer = LayerFactory.Instance.CreateLayer(lyrCreateParam, map); @@ -89,6 +96,10 @@ public async void Example3() Map map = MapView.Active.Map; await QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams.RendererDefinition + // cref: ARCGIS.DESKTOP.MAPPING.LAYERFACTORY.CREATELAYER + // cref: ArcGIS.Desktop.Mapping.SimpleRendererDefinition + // cref: ArcGIS.Desktop.Mapping.SimpleRendererDefinition.SymbolTemplate #region Create a stream layer with a simple renderer var url = @"https://geoeventsample1.esri.com:6443/arcgis/rest/services/LABus/StreamServer"; var uri = new Uri(url, UriKind.Absolute); @@ -120,12 +131,30 @@ await QueuedTask.Run(() => //StreamLayer streamLayer = null; // - // cref: Setting a unique value renderer for latest observations;ArcGIS.Desktop.Mapping.StreamLayer + // cref: ArcGIS.Desktop.Mapping.FeatureLayerCreationParams.IsVisible + // cref: ARCGIS.DESKTOP.MAPPING.LAYERFACTORY.CREATELAYER + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.Fields + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.UseDefaultSymbol + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.DefaultLabel + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.DefaultSymbol + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.Groups + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Values + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Visible + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Label + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Symbol + // cref: ArcGIS.Core.CIM.CIMUniqueValue + // cref: ArcGIS.Core.CIM.CIMUniqueValue.FieldValues + // cref: ArcGIS.Core.CIM.CIMUniqueValueGroup + // cref: ArcGIS.Core.CIM.CIMUniqueValueGroup.Classes + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(CIMRenderer) #region Setting a unique value renderer for latest observations var url = @"https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer"; var uri = new Uri(url, UriKind.Absolute); //Must be on QueuedTask! + var createParams = new FeatureLayerCreationParams(uri) { IsVisible = false @@ -188,6 +217,7 @@ public async void Example5() Map map = MapView.Active.Map; StreamLayer streamLayer = null; + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.IsTrackAware #region Find all Stream Layers that are Track Aware var trackAwareLayers = MapView.Active.Map.GetLayersAsFlattenedList() @@ -195,6 +225,8 @@ public async void Example5() #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.TrackType + // cref: ArcGIS.Core.Data.TrackType #region Determine the Stream Layer type //spatial or non-spatial? @@ -209,6 +241,8 @@ public async void Example5() #endregion + // cref: ArcGIS.Desktop.Mapping.StreamLayer.IsStreamingConnectionOpen + // cref: ArcGIS.Desktop.Mapping.StreamLayer.StartStreaming #region Check the Stream Layer connection state if (!streamLayer.IsStreamingConnectionOpen) @@ -217,6 +251,8 @@ public async void Example5() #endregion + // cref: ArcGIS.Desktop.Mapping.StreamLayer.StartStreaming + // cref: ArcGIS.Desktop.Mapping.StreamLayer.StopStreaming #region Start and stop streaming //Must be on QueuedTask! //Start... @@ -226,14 +262,18 @@ public async void Example5() #endregion + // cref: ArcGIS.Desktop.Mapping.StreamLayer.GetFeatureClass + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.Truncate #region Delete all current and previous observations //Must be on QueuedTask! //Must be called on the feature class - using(var rfc = streamLayer.GetFeatureClass()) + using (var rfc = streamLayer.GetFeatureClass()) rfc.Truncate(); #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.IsTrackAware + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.TrackIdFieldName #region Get the Track Id Field if (streamLayer.IsTrackAware) @@ -244,6 +284,8 @@ public async void Example5() #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.TrackType + // cref: ArcGIS.Core.Data.TrackType #region Get The Track Type var trackType = streamLayer.TrackType; @@ -257,7 +299,11 @@ public async void Example5() } #endregion - // cref: Set the Maximum Count of Previous Observations to be Stored in Memory;ArcGIS.Desktop.Mapping.StreamLayer.SetExpirationMaxCount(System.UInt64) + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.IsTrackAware + // cref: ArcGIS.Desktop.Mapping.StreamLayer.GetExpirationMethod() + // cref: ArcGIS.Core.CIM.FeatureExpirationMethod + // cref: ArcGIS.Desktop.Mapping.StreamLayer.SetExpirationMethod(ArcGIS.Core.CIM.FeatureExpirationMethod) + // cref: ArcGIS.Desktop.Mapping.StreamLayer.SetExpirationMaxCount(System.UInt64) #region Set the Maximum Count of Previous Observations to be Stored in Memory //Must be on QueuedTask @@ -273,6 +319,11 @@ public async void Example5() #endregion + + // cref: ArcGIS.Desktop.Mapping.StreamLayer.GetExpirationMethod() + // cref: ArcGIS.Core.CIM.FeatureExpirationMethod + // cref: ArcGIS.Desktop.Mapping.StreamLayer.SetExpirationMethod(ArcGIS.Core.CIM.FeatureExpirationMethod) + // cref: ArcGIS.Desktop.Mapping.StreamLayer.SetExpirationMaxCount(System.UInt64) #region Set the Maximum Age of Previous Observations to be Stored in Memory //Must be on QueuedTask @@ -290,6 +341,12 @@ public async void Example5() #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.TrackType + // cref: ArcGIS.Core.Data.TrackType + // cref: ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.PreviousObservationsCount + // cref: ArcGIS.Desktop.Mapping.StreamLayer.GetExpirationMaxCount() + // cref: ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.ShowPreviousObservations + // cref: ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.ShowTracks #region Set Various Stream Layer properties via the CIM //The layer must be track aware and spatial if (streamLayer.TrackType != TrackType.Spatial) @@ -327,11 +384,17 @@ await QueuedTask.Run(() => StreamLayer streamLayer = null; //https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer + // cref: ArcGIS.Desktop.Mapping.UniqueValueRendererDefinition + // cref: ArcGIS.Desktop.Mapping.UniqueValueRendererDefinition.ValueFields + // cref: ArcGIS.Desktop.Mapping.UniqueValueRendererDefinition.SymbolTemplate + // cref: ArcGIS.Desktop.Mapping.UniqueValueRendererDefinition.ValuesLimit + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(CIMRenderer) + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.CreateRenderer #region Defining a unique value renderer definition var uvrDef = new UniqueValueRendererDefinition() { - ValueFields = new string[] { "ACTYPE" }, + ValueFields = new List { "ACTYPE" }, SymbolTemplate = SymbolFactory.Instance.ConstructPointSymbol( ColorFactory.Instance.RedRGB, 10, SimpleMarkerStyle.Hexagon) .MakeSymbolReference(), @@ -343,7 +406,22 @@ await QueuedTask.Run(() => #endregion - // cref: Setting a unique value renderer for latest observations;ArcGIS.Desktop.Mapping.StreamLayer + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.Fields + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.UseDefaultSymbol + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.DefaultLabel + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.DefaultSymbol + // cref: ArcGIS.Core.CIM.CIMUniqueValueRenderer.Groups + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Values + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Visible + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Label + // cref: ArcGIS.Core.CIM.CIMUniqueValueClass.Symbol + // cref: ArcGIS.Core.CIM.CIMUniqueValue + // cref: ArcGIS.Core.CIM.CIMUniqueValue.FieldValues + // cref: ArcGIS.Core.CIM.CIMUniqueValueGroup + // cref: ArcGIS.Core.CIM.CIMUniqueValueGroup.Classes + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(CIMRenderer) #region Setting a unique value renderer for latest observations //Define the classes by hand to avoid using CreateRenderer(...) @@ -377,14 +455,15 @@ await QueuedTask.Run(() => DefaultSymbol = SymbolFactory.Instance.ConstructPointSymbol( CIMColor.CreateRGBColor(185, 185, 185), 8, SimpleMarkerStyle.Hexagon).MakeSymbolReference() }; - //set the renderer. Depending on the current events recieved, the + //set the renderer. Depending on the current events received, the //layer may or may not have events for each of the specified //unique value classes streamLayer.SetRenderer(UVrndr); #endregion - // cref: Setting a unique value renderer for previous observations;ArcGIS.Desktop.Mapping.StreamLayer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(CIMRenderer,FeatureRendererTarget) + // cref: ArcGIS.Desktop.Mapping.FeatureRendererTarget #region Setting a unique value renderer for previous observations //The layer must be track aware and spatial if (streamLayer.TrackType != TrackType.Spatial) @@ -429,10 +508,12 @@ await QueuedTask.Run(() => CIMColor.CreateRGBColor(185, 185, 185), 4, SimpleMarkerStyle.Hexagon) .MakeSymbolReference() }; - + + streamLayer.SetRenderer(UVrndr, FeatureRendererTarget.PreviousObservations); #endregion - // cref: Setting a simple renderer to draw track lines;ArcGIS.Desktop.Mapping.StreamLayer + // cref: ArcGIS.Desktop.Mapping.FeatureRendererTarget + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetRenderer(ArcGIS.Core.CIM.CIMRenderer, ArcGIS.Desktop.Mapping.FeatureRendererTarget) #region Setting a simple renderer to draw track lines //The layer must be track aware and spatial if (streamLayer.TrackType != TrackType.Spatial) @@ -452,6 +533,10 @@ await QueuedTask.Run(() => #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.AreTrackLinesVisible + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetTrackLinesVisibility(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.ArePreviousObservationsVisible + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetPreviousObservationsVisibility(System.Boolean) #region Check Previous Observation and Track Line Visibility //The layer must be track aware and spatial for these settings @@ -466,13 +551,19 @@ await QueuedTask.Run(() => #endregion - // cref: Make Track Lines and Previous Observations Visible;ArcGIS.Desktop.Mapping.StreamLayer + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetPreviousObservationsCount(System.Int32) + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.AreTrackLinesVisible + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetTrackLinesVisibility(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.ArePreviousObservationsVisible + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.SetPreviousObservationsVisibility(System.Boolean) #region Make Track Lines and Previous Observations Visible //The layer must be track aware and spatial for these settings //to have an effect if (streamLayer.TrackType != TrackType.Spatial) return; + //Must be on QueuedTask + //Note: Setting PreviousObservationsCount larger than the //"SetExpirationMaxCount()" has no effect streamLayer.SetPreviousObservationsCount(6); @@ -483,6 +574,7 @@ await QueuedTask.Run(() => #endregion + // cref: ArcGIS.Desktop.Mapping.StreamLayer #region Retrieve the current observation renderer //Must be on QueuedTask! @@ -490,6 +582,8 @@ await QueuedTask.Run(() => #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureRendererTarget + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetRenderer(ArcGIS.Desktop.Mapping.FeatureRendererTarget) #region Retrieve the previous observation renderer //The layer must be track aware and spatial if (streamLayer.TrackType != TrackType.Spatial) @@ -500,6 +594,8 @@ await QueuedTask.Run(() => #endregion + // cref: ArcGIS.Desktop.Mapping.FeatureRendererTarget + // cref: ArcGIS.Desktop.Mapping.FeatureLayer.GetRenderer(ArcGIS.Desktop.Mapping.FeatureRendererTarget) #region Retrieve the track lines renderer //The layer must be track aware and spatial if (streamLayer.TrackType != TrackType.Spatial) @@ -524,8 +620,14 @@ public async void SearchAndSubscribeToStreamData() StreamLayer streamLayer = null; QueryFilter qfilter = null; - // cref: Search And Subscribe for Streaming Data;ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.SearchAndSubscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) - // cref: Search And Subscribe for Streaming Data;ArcGIS.Desktop.Mapping.StreamLayer.SearchAndSubscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Desktop.Mapping.StreamLayer.SearchAndSubscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.WaitForRowsAsync() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.MoveNext() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.Current + // cref: ArcGIS.Core.Data.Realtime.RealtimeRow.GetRowSource() + // cref: ArcGIS.Core.Data.Realtime.RealtimeRowSource + // cref: ArcGIS.Desktop.Mapping.StreamLayer.GetFeatureClass() + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.SearchAndSubscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) #region Search And Subscribe for Streaming Data await QueuedTask.Run(async () => @@ -562,10 +664,10 @@ await QueuedTask.Run(async () => //....or.... //Use the feature class instead of the layer - using(var rfc = streamLayer.GetFeatureClass()) + using (var rfc = streamLayer.GetFeatureClass()) { //non-recycling cursor - 2nd param "false" - using(var rc = rfc.SearchAndSubscribe(qfilter, false)) + using (var rc = rfc.SearchAndSubscribe(qfilter, false)) { //waiting for new features to be streamed //default is no cancellation @@ -578,6 +680,14 @@ await QueuedTask.Run(async () => }); #endregion + // cref: ArcGIS.Desktop.Mapping.StreamLayer.SearchAndSubscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.WaitForRowsAsync() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.MoveNext() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.Current + // cref: ArcGIS.Core.Data.Realtime.RealtimeRow.GetRowSource() + // cref: ArcGIS.Core.Data.Realtime.RealtimeRowSource + // cref: ArcGIS.Desktop.Mapping.StreamLayer.GetFeatureClass() + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.SearchAndSubscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) #region Search And Subscribe With Cancellation await QueuedTask.Run(async () => @@ -618,6 +728,10 @@ private async void Foo() RealtimeCursor rc = null; bool SomeConditionForCancel = false; + // cref: ArcGIS.Desktop.Mapping.StreamLayer.SearchAndSubscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.WaitForRowsAsync(System.Threading.CancellationToken) + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.MoveNext() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.Current #region Explicitly Cancel WaitForRowsAsync //somewhere in our code we create a CancellationTokenSource var cancel = new CancellationTokenSource(); @@ -658,8 +772,14 @@ private async void Foo() public async void CreateStreamLayerFromDatastore() { - // cref: Connect to a real-time feature class from a real-time datastore;ArcGIS.Core.Data.Realtime.RealtimeDatastore.#ctor(ArcGIS.Core.Data.Realtime.RealtimeServiceConnectionProperties) - // cref: Connect to a real-time feature class from a real-time datastore;ArcGIS.Core.Data.Realtime.RealtimeFeatureClass + // cref: ArcGIS.Core.Data.Realtime.RealtimeServiceConnectionProperties + // cref: ArcGIS.Core.Data.Realtime.RealtimeServiceConnectionProperties.#ctor(System.Uri, ArcGIS.Core.Data.Realtime.RealtimeDatastoreType) + // cref: ArcGIS.Core.Data.Realtime.RealtimeDatastoreType + // cref: ArcGIS.Core.Data.Realtime.RealtimeDatastore.#ctor(ArcGIS.Core.Data.Realtime.RealtimeServiceConnectionProperties) + // cref: ArcGIS.Core.Data.Realtime.RealtimeDatastore.GetTableNames() + // cref: ArcGIS.Core.Data.Realtime.RealtimeDatastore.OpenTable(System.String) + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.StartStreaming() #region Connect to a real-time feature class from a real-time datastore var url = "https://geoeventsample1.esri.com:6443/arcgis/rest/services/AirportTraffics/StreamServer"; @@ -692,6 +812,11 @@ public async void Example7() StreamLayer streamLayer = null; await QueuedTask.Run(() => { + // cref: ArcGIS.Desktop.Mapping.StreamLayer.GetFeatureClass() + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.GetDefinition() + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClassDefinition + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClassDefinition.HasTrackIDField() #region Check the Realtime Feature Class is Track Aware using (var rfc = streamLayer.GetFeatureClass()) @@ -705,6 +830,12 @@ await QueuedTask.Run(() => #endregion + // cref: ArcGIS.Desktop.Mapping.StreamLayer.GetFeatureClass() + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.GetDefinition() + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClassDefinition + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClassDefinition.HasTrackIDField() + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClassDefinition.GetTrackIDField() #region Get the Track Id Field from the Realtime Feature class //Must be on QueuedTask using (var rfc = streamLayer.GetFeatureClass()) @@ -729,8 +860,15 @@ public async void SubscribeToStreamData() StreamLayer streamLayer = null; QueryFilter qfilter = null; - // cref: Subscribe to Streaming Data;ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.Subscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) - // cref: Subscribe to Streaming Data;ArcGIS.Desktop.Mapping.StreamLayer.Subscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.Subscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Desktop.Mapping.StreamLayer.Subscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.WaitForRowsAsync() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.MoveNext() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.Current + // cref: ArcGIS.Core.Data.Realtime.RealtimeRow.GetRowSource() + // cref: ArcGIS.Core.Data.Realtime.RealtimeRowSource + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeature + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeature.GetShape() #region Subscribe to Streaming Data //Note: with feature class we can also use a System Task to subscribe and @@ -782,7 +920,14 @@ public async void Example8() StreamLayer streamLayer = null; QueryFilter qfilter = null; - //Don't change this name! harcoded in the Realtime feature class "///" + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeatureClass.Subscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Desktop.Mapping.StreamLayer.Subscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.WaitForRowsAsync() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.MoveNext() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.Current + // cref: ArcGIS.Core.Data.Realtime.RealtimeRow.GetRowSource() + // cref: ArcGIS.Core.Data.Realtime.RealtimeRowSource + // cref: ArcGIS.Core.Data.Realtime.RealtimeFeature #region Search Existing Data and Subscribe for Streaming Data //Note we can use System Task with the Realtime feature class @@ -826,6 +971,12 @@ await System.Threading.Tasks.Task.Run(async () => #endregion + // cref: ArcGIS.Desktop.Mapping.StreamLayer.Subscribe(ArcGIS.Core.Data.QueryFilter,System.Boolean) + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.WaitForRowsAsync(System.Threading.CancellationToken) + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.MoveNext() + // cref: ArcGIS.Core.Data.Realtime.RealtimeCursor.Current + // cref: ArcGIS.Core.Data.Realtime.RealtimeRow.GetRowSource() + // cref: ArcGIS.Core.Data.Realtime.RealtimeRowSource #region Search And Subscribe With Cancellation await System.Threading.Tasks.Task.Run(async () => @@ -867,15 +1018,6 @@ await System.Threading.Tasks.Task.Run(async () => } - public async void Example9() - { - Map map = MapView.Active.Map; - await QueuedTask.Run(() => - { - - }); - } - - + } } diff --git a/Examples/MapAuthoring/ProSnippetVoxelLayers.cs b/Examples/MapAuthoring/ProSnippetVoxelLayers.cs index a9037f6..f197884 100644 --- a/Examples/MapAuthoring/ProSnippetVoxelLayers.cs +++ b/Examples/MapAuthoring/ProSnippetVoxelLayers.cs @@ -1,3 +1,4 @@ + /* Copyright 2018 Esri @@ -36,6 +37,7 @@ limitations under the License. namespace MapAuthoring.VoxelLayers { + class ProSnippetRealtime { #region ProSnippet Group: Create Voxel Layer @@ -46,30 +48,37 @@ public async void Example1() Map map = MapView.Active.Map; await QueuedTask.Run(() => { - #region Check Licensing Level for Advanced - - //Voxels requires an Advanced license level - var canUseVoxels = - (ArcGIS.Core.Licensing.LicenseInformation.Level == ArcGIS.Core.Licensing.LicenseLevels.Advanced); - - #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer + // cref: ArcGIS.Desktop.Mapping.MapView.ViewingMode + // cref: ArcGIS.Core.CIM.MapViewingMode #region Check if a Voxel Layer can be created //Map must be a local scene - bool canCreateVoxel = false; - if (MapView.Active.ViewingMode == MapViewingMode.SceneLocal) - { - //license level must be advanced - canCreateVoxel = (ArcGIS.Core.Licensing.LicenseInformation.Level == - ArcGIS.Core.Licensing.LicenseLevels.Advanced); - } + bool canCreateVoxel = (MapView.Active.ViewingMode == MapViewingMode.SceneLocal); + if (canCreateVoxel) { //TODO - use the voxel api methods } #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer + // cref: ArcGIS.Core.CIM.CIMVoxelDataConnection + // cref: ArcGIS.Core.CIM.CIMVoxelDataConnection.URI + // cref: ArcGIS.Desktop.Mapping.VoxelLayerCreationParams + // cref: ArcGIS.Desktop.Mapping.VoxelLayerCreationParams.Create(ArcGIS.Core.CIM.CIMVoxelDataConnection) + // cref: ArcGIS.Desktop.Mapping.VoxelLayerCreationParams.IsVisible + // cref: ArcGIS.Desktop.Mapping.VoxelLayerCreationParams.Variables + // cref: ArcGIS.Desktop.Mapping.VoxelVariableCreationParams + // cref: ArcGIS.Desktop.Mapping.VoxelVariableCreationParams.Variable + // cref: ArcGIS.Desktop.Mapping.VoxelVariableCreationParams.DataType + // cref: ArcGIS.Desktop.Mapping.VoxelVariableCreationParams.Description + // cref: ArcGIS.Desktop.Mapping.VoxelVariableCreationParams.IsDefault + // cref: ArcGIS.Desktop.Mapping.VoxelVariableCreationParams.IsSelected + // cref: ArcGIS.Desktop.Mapping.VoxelLayerCreationParams.SetDefaultVariable(ArcGIS.Desktop.Mapping.VoxelVariableCreationParams) + // cref: ArcGIS.Desktop.Mapping.LayerFactory.CreateLayer + // cref: ArcGIS.Desktop.Mapping.LayerFactory #region Create Voxel Layer //Must be on the QueuedTask.Run() @@ -99,7 +108,7 @@ await QueuedTask.Run(() => createParams.SetDefaultVariable(variables.Last()); //Create the layer - map must be a local scene - LayerFactory.Instance.CreateLayer(createParams, map); + VoxelLayer voxelLayer = LayerFactory.Instance.CreateLayer(createParams, map); #endregion }); } @@ -111,6 +120,7 @@ public void Example2() { Map map = MapView.Active.Map; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer #region Get a Voxel Layer from the TOC //Get selected layer if a voxel layer is selected var voxelLayer = MapView.Active.GetSelectedLayers().OfType().FirstOrDefault(); @@ -123,6 +133,16 @@ public void Example2() } #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer + // cref: ArcGIS.Desktop.Mapping.Layer.SetExpanded + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetIsosurfaceContainerExpanded(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetIsosurfaceContainerVisibility(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSliceContainerExpanded(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSliceContainerVisibility(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSectionContainerExpanded(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSectionContainerVisibility(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetLockedSectionContainerExpanded(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetLockedSectionContainerVisibility(System.Boolean) #region Manipulate the Voxel Layer TOC Group //var voxelLayer = ... @@ -142,6 +162,18 @@ public void Example2() #endregion + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedIsosurfaces() + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition + // cref: ArcGIS.Desktop.Mapping.MapView.SelectVoxelIsosurface(ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition) + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedSlices() + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition + // cref: ArcGIS.Desktop.Mapping.MapView.SelectVoxelSlice(ArcGIS.Desktop.Mapping.Voxel.SliceDefinition) + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition + // cref: ArcGIS.Desktop.Mapping.MapView.SelectVoxelSection( ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedLockedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition + // cref: ArcGIS.Desktop.Mapping.MapView.SelectVoxelLockedSection(ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition) #region Get/Set Selected Voxel Assets from the TOC var surfaces = MapView.Active.GetSelectedIsosurfaces(); @@ -155,6 +187,8 @@ public void Example2() #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetVisualization(ArcGIS.Core.CIM.VoxelVisualization) + // cref: ArcGIS.Core.CIM.VoxelVisualization #region Change the Voxel Visualization //var voxelLayer = ... ; @@ -169,6 +203,20 @@ public void Example2() voxelLayer.SetVisualization(VoxelVisualization.Surface); #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.CartographicOffset + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetCartographicOffset(System.Double) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.VerticalExaggeration + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetVerticalExaggeration(System.Double) + // cref: ArcGIS.Core.CIM.CIM3DLayerProperties.ExaggerationMode + // cref: ArcGIS.Core.CIM.CIM3DLayerProperties.VerticalExaggeration + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.IsDiffuseLightingEnabled + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetDiffuseLightingEnabled(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.DiffuseLighting + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetDiffuseLighting(System.Double) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.IsSpecularLightingEnabled + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSpecularLightingEnabled(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SpecularLighting + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSpecularLighting(System.Double) #region Lighting Properties, Offset, Vertical Exaggeration //var voxelLayer = ... ; @@ -210,12 +258,25 @@ public void Example2() #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetVolumes + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetVolumeSize() + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SelectedVariableProfile + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SelectedVariableProfile #region Get the Voxel Volume Dimensions - var volume = voxelLayer.GetVolumeSize(); - var x_max = volume.Item1; - var y_max = volume.Item2; - var z_max = volume.Item3; + //At 2.x - var volume = voxelLayer.GetVolumeSize(); + //var x_max = volume.Item1; + //var y_max = volume.Item2; + //var z_max = volume.Item3; + + var x_max = voxelLayer.GetVolumes().Max(v => v.GetVolumeSize().X); + var y_max = voxelLayer.GetVolumes().Max(v => v.GetVolumeSize().Y); + var z_max = voxelLayer.GetVolumes().Max(v => v.GetVolumeSize().Z); + + //Get the dimensions of just one volume + var dimensions = voxelLayer.GetVolumes().FirstOrDefault(); + //Get the dimensions of the volume associated with the selected variable + var dimensions2 = voxelLayer.SelectedVariableProfile.Volume.GetVolumeSize(); #endregion } @@ -225,7 +286,18 @@ public void Example2() public void ExampleEvents() { - + // cref: ArcGIS.Desktop.Mapping.VoxelLayer + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SelectedVariableProfile + // cref: ArcGIS.Desktop.Mapping.VoxelVariableProfile.Variable + // cref: ArcGIS.Desktop.Mapping.VoxelVariableProfile.Renderer + // cref: ArcGIS.Desktop.Mapping.Voxel.Events.MapMemberEventHint + // cref: ArcGIS.Desktop.Mapping.Voxel.Events.MapMemberPropertiesChangedEventArgs.EventHints + // cref: ArcGIS.Desktop.Mapping.Voxel.Events.VoxelAssetChangedEvent.Subscribe + // cref: ArcGIS.Desktop.Mapping.Voxel.Events.VoxelAssetEventArgs + // cref: ArcGIS.Desktop.Mapping.Voxel.Events.VoxelAssetEventArgs.ChangeType + // cref: ArcGIS.Desktop.Mapping.Voxel.Events.VoxelAssetEventArgs.AssetType + // cref: ArcGIS.Desktop.Mapping.Voxel.Events.VoxelAssetEventArgs.VoxelAssetChangeType + // cref: ArcGIS.Desktop.Mapping.Voxel.Events.VoxelAssetEventArgs.VoxelAssetType #region Subscribe for Changes to a Voxel Layer ArcGIS.Desktop.Mapping.Events.MapMemberPropertiesChangedEvent.Subscribe((args) => @@ -234,7 +306,8 @@ public void ExampleEvents() if (voxel == null) return; //Anything changed on a voxel layer? - if (args.EventHints.Any(hint => hint == MapMemberEventHint.VoxelSelectedVariableProfileIndex)) + //At 2.x - if (args.EventHints.Any(hint => hint == MapMemberEventHint.VoxelSelectedVariableProfileIndex)) + if (args.EventHints.Any(hint => hint == MapMemberEventHint.VoxelSelectedVariable)) { //Voxel variable profile selection changed var changed_variable_name = voxel.SelectedVariableProfile.Variable; @@ -295,6 +368,8 @@ public void Example4a() return; } + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SelectedVariableProfile + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.Variable #region Get the Selected Variable Profile //var voxelLayer = ... ; @@ -307,6 +382,9 @@ public void Example4a() #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetVariableProfiles + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.Variable + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSelectedVariableProfile(ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile) #region Change the Selected Variable Profile //var voxelLayer = ... ; @@ -323,6 +401,8 @@ public void Example4a() #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetVariableProfiles + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile #region Get the Variable Profiles //var voxelLayer = ... ; @@ -338,6 +418,14 @@ public void Example4() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetVariableProfiles + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.Renderer + // cref: ArcGIS.Core.CIM.CIMVoxelRenderer + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.DataType + // cref: ArcGIS.Core.CIM.VoxelVariableDataType + // cref: ArcGIS.Core.CIM.CIMVoxelStretchRenderer + // cref: ArcGIS.Core.CIM.CIMVoxelUniqueValueRenderer #region Get the Variable Renderer //var voxelLayer = ... ; @@ -367,6 +455,15 @@ public void Example5b() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SelectedVariableProfile + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.Statistics + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.DataType + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.Renderer + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableStatistics.MinimumValue + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableStatistics.MaximumValue + // cref: ArcGIS.Core.CIM.VoxelVariableDataType + // cref: ArcGIS.Core.CIM.CIMVoxelStretchRenderer.ColorRangeMax + // cref: ArcGIS.Core.CIM.CIMVoxelStretchRenderer.ColorRangeMin #region Access Stats and Color Range for a Stretch Renderer //var voxelLayer = ... ; @@ -377,8 +474,12 @@ public void Example5b() //or use ...voxelLayer.GetVariableProfiles() //Data range - var min = variable.GetVariableStatistics().MinimumValue; - var max = variable.GetVariableStatistics().MaximumValue; + //At 2.x - + //var min = variable.GetVariableStatistics().MinimumValue; + //var max = variable.GetVariableStatistics().MaximumValue; + + var min = variable.Statistics.MinimumValue; + var max = variable.Statistics.MaximumValue; //Color range (Continuous only) double color_min, color_max; @@ -397,6 +498,10 @@ public void Example7() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Core.CIM.CIMVoxelStretchRenderer.ColorRangeMax + // cref: ArcGIS.Core.CIM.CIMVoxelStretchRenderer.ColorRangeMin + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableStatistics.MinimumValue + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableStatistics.MAximumValue #region Change Stretch Renderer Color Range //Typically, the default color range covers the most @@ -419,10 +524,18 @@ public void Example7() color_max += dif; //make sure we do not exceed data range - if (color_min < variable.GetVariableStatistics().MinimumValue) - color_min = variable.GetVariableStatistics().MinimumValue; - if (color_max > variable.GetVariableStatistics().MaximumValue) - color_max = variable.GetVariableStatistics().MaximumValue; + //At 2.x - + //if (color_min < variable.GetVariableStatistics().MinimumValue) + // color_min = variable.GetVariableStatistics().MinimumValue; + //if (color_max > variable.GetVariableStatistics().MaximumValue) + // color_max = variable.GetVariableStatistics().MaximumValue; + + if (color_min < variable.Statistics.MinimumValue) + color_min = variable.Statistics.MinimumValue; + if (color_max > variable.Statistics.MaximumValue) + color_max = variable.Statistics.MaximumValue; + + //variable.Statistics.MinimumValue renderer.ColorRangeMin = color_min; renderer.ColorRangeMax = color_max; @@ -437,6 +550,10 @@ public void Example7b() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Core.CIM.CIMVoxelUniqueValueRenderer + // cref: ArcGIS.Core.CIM.CIMVoxelUniqueValueRenderer.Classes + // cref: ArcGIS.Core.CIM.CIMVoxelColorUniqueValue + // cref: ArcGIS.Core.CIM.CIMVoxelColorUniqueValue.Visible #region Change The Visibility on a CIMVoxelColorUniqueValue class //Get the variable profile whose renderer will be changed @@ -475,6 +592,9 @@ public void Example3() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetVariableProfiles + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.MaxNumberOfIsosurfaces + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.GetIsosurfaces() #region Check the MaxNumberofIsoSurfaces for a Variable //var voxelLayer = ... ; @@ -495,6 +615,8 @@ public void Example3b() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetVariableProfiles + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.DataType #region Check a Variable's Datatype //var voxelLayer = ... ; @@ -515,6 +637,11 @@ public void Example5() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.Visualization + // cref: ArcGIS.Core.CIM.VoxelVisualization + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.CanCreateIsosurface + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetVisualization(ArcGIS.Core.CIM.VoxelVisualization) + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.CanCreateIsosurface #region Check CanCreateIsoSurface //var voxelLayer = ... ; @@ -545,6 +672,15 @@ public void Example6() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.Visualization + // cref: ArcGIS.Core.CIM.VoxelVisualization + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetVisualization(ArcGIS.Core.CIM.VoxelVisualization) + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.CanCreateIsosurface + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.CreateIsosurface(ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition.Name + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition.Value + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition.IsVisible #region Create Isosurface //var voxelLayer = ... ; @@ -566,8 +702,12 @@ public void Example6() //will trigger an InvalidOperationException //Specify a voxel value for the iso surface - var min = variable.GetVariableStatistics().MinimumValue; - var max = variable.GetVariableStatistics().MaximumValue; + //At 2.x - + //var min = variable.GetVariableStatistics().MinimumValue; + //var max = variable.GetVariableStatistics().MaximumValue; + + var min = variable.Statistics.MinimumValue; + var max = variable.Statistics.MaximumValue; var mid = (max + min) / 2; //color range (i.e. values that are being rendered) @@ -604,6 +744,13 @@ public void Example7c() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.GetIsosurfaces() + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition.Value + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition.Color + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition.IsCustomColor + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.UpdateIsosurface(ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition) + // cref: ArcGIS.Core.CIM.CIMVoxelStretchRenderer.ColorRamp + // cref: ArcGIS.Desktop.Mapping.ColorFactory.GenerateColorsFromColorRamp #region How to Change Value and Color on an Isosurface //var voxelLayer = ... ; @@ -639,6 +786,9 @@ public void Example7c() #endregion + // cref: ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition.IsCustomColor + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.GetIsosurfaceColor(System.Double) + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.UpdateIsosurface(ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition) #region Change Isourface Color Back to Default //var voxelLayer = ... ; @@ -661,6 +811,8 @@ public void Example7d() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.GetIsosurfaces() + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.DeleteIsosurface(ArcGIS.Desktop.Mapping.Voxel.IsosurfaceDefinition) #region Delete Isosurface- s //var voxelLayer = ... ; @@ -697,18 +849,32 @@ public void Example8() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.Volume + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetSlices() + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition.IsVisible + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.UpdateSlice(ArcGIS.Desktop.Mapping.Voxel.SliceDefinition) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSliceContainerExpanded(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSliceContainerVisibility(System.Boolean) #region Get the Collection of Slices //var voxelLayer = ... ; //Must be on the QueuedTask.Run() - var slices = voxelLayer.GetSlices(); + //At 2.x - var slices = voxelLayer.GetSlices(); + + //Use the SelectedVariableProfile to get the slices currently in the TOC + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var slices = volume.GetSlices(); //Do something... e.g. make them visible foreach (var slice in slices) { slice.IsVisible = true; - voxelLayer.UpdateSlice(slice); + //at 2.x - voxelLayer.UpdateSlice(slice); + volume.UpdateSlice(slice); } //expand the slice container and make sure container visibility is true @@ -725,13 +891,24 @@ public void Example8g() VoxelLayer voxelLayer = null; var my_slice_id = ""; - #region Get a Slice- s + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile.Volume + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetSlices() + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition + #region Get a Slice //var voxelLayer = ... ; //Must be on the QueuedTask.Run() - var slice = voxelLayer.GetSlices().FirstOrDefault(); - var slice2 = voxelLayer.GetSlices().First(s => s.Id == my_slice_id); + //At 2.x - + //var slice = voxelLayer.GetSlices().FirstOrDefault(); + //var slice2 = voxelLayer.GetSlices().First(s => s.Id == my_slice_id); + + //Use the SelectedVariableProfile to get the slices currently in the TOC + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var slice = volume.GetSlices().FirstOrDefault(); + var slice2 = volume.GetSlices().First(s => s.Id == my_slice_id); #endregion } @@ -744,6 +921,8 @@ public void Example8h() //Must be on the QueuedTask.Run() + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedSlices() + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition var slice = MapView.Active?.GetSelectedSlices()?.FirstOrDefault(); if (slice != null) { @@ -758,6 +937,9 @@ public void Example8i() Map map = MapView.Active.Map; + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedSlices() + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition.Layer #region Get Voxel Layer for the Selected Slice in TOC //Must be on the QueuedTask.Run() @@ -779,6 +961,17 @@ public void Example8b() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSliceContainerExpanded(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSliceContainerVisibility(System.Boolean) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.AutoShowExploreDockPane + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetVolumeSize() + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetNormal(System.Double, System.Double) + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.CreateSlice(ArcGIS.Desktop.Mapping.Voxel.SliceDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition.Name + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition.VoxelPosition + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition.Normal + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition.IsVisible #region Create a Slice //var voxelLayer = ... ; @@ -793,7 +986,12 @@ public void Example8b() voxelLayer.AutoShowExploreDockPane = false; //This is useful if u have your own dockpane currently activated... - var volume = voxelLayer.GetVolumeSize(); + //At 2.x - var volumeSize = voxelLayer.GetVolumeSize(); + + //Use the SelectedVariableProfile to get the slices currently in the TOC + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var volumeSize = volume.GetVolumeSize(); //Orientation 90 degrees (West), Tilt 0.0 (vertical) //Convert to a normal @@ -801,10 +999,21 @@ public void Example8b() //Create the slice at the voxel mid-point. VoxelPosition //is specified in voxel-space coordinates - voxelLayer.CreateSlice(new SliceDefinition() + + //At 2.x - + //voxelLayer.CreateSlice(new SliceDefinition() + //{ + // Name = "Middle Slice", + // VoxelPosition = new Coordinate3D(volume.Item1 / 2, volume.Item2 / 2, volume.Item3 / 2), + // Normal = normal, + // IsVisible = true + //}); + + //Create the slice on the respective volume + volume.CreateSlice(new SliceDefinition() { Name = "Middle Slice", - VoxelPosition = new Coordinate3D(volume.Item1 / 2, volume.Item2 / 2, volume.Item3 / 2), + VoxelPosition = new Coordinate3D(volumeSize.X / 2, volumeSize.Y / 2, volumeSize.Z / 2), Normal = normal, IsVisible = true }); @@ -820,6 +1029,11 @@ public void Example8c() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSliceContainerVisibility + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetOrientationAndTilt(ArcGOS.Core.Geometry.Geometry3D) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetNormal(System.Double, System.Double) + // cref: ArcGIS.Desktop.Mapping.Voxel.SliceDefinition.Normal + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.UpdateSlice(ArcGIS.Desktop.Mapping.Voxel.SliceDefinition) #region Change Tilt on a Slice //var voxelLayer = ... ; @@ -834,13 +1048,19 @@ public void Example8c() voxelLayer.SetVisualization(VoxelVisualization.Volume); voxelLayer.SetSliceContainerVisibility(true); - var slice = voxelLayer.GetSlices().First(s => s.Name == "Change Tilt Slice"); + //At 2.x - var slice = voxelLayer.GetSlices().First(s => s.Name == "Change Tilt Slice"); + + //Use the SelectedVariableProfile to get the slices currently in the TOC + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var slice = volume.GetSlices().First(s => s.Name == "Change Tilt Slice"); (double orientation, double tilt) = voxelLayer.GetOrientationAndTilt(slice.Normal); //Convert orientation and tilt to a normal slice.Normal = voxelLayer.GetNormal(orientation, 45.0); - voxelLayer.UpdateSlice(slice); + //At 2.x - voxelLayer.UpdateSlice(slice); + volume.UpdateSlice(slice); //reset if needed...Normally this might be when your dockpane //was de-activated (ie "closed") @@ -856,19 +1076,35 @@ public void Example8d() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.DeleteSlice(ArcGIS.Desktop.Mapping.Voxel.SliceDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetSlices() #region Delete Slice //var voxelLayer = ... ; //Must be on the QueuedTask.Run() - var last_slice = voxelLayer.GetSlices().LastOrDefault(); + //At 2.x + //var last_slice = voxelLayer.GetSlices().LastOrDefault(); + // if (last_slice != null) + // voxelLayer.DeleteSlice(last_slice); + + // //Delete all slices + // var slices = voxelLayer.GetSlices(); + // foreach (var slice in slices) + // voxelLayer.DeleteSlice(slice); + + //Use the SelectedVariableProfile to get the slices currently in the TOC + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + + var last_slice = volume.GetSlices().LastOrDefault(); if (last_slice != null) - voxelLayer.DeleteSlice(last_slice); + volume.DeleteSlice(last_slice); //Delete all slices - var slices = voxelLayer.GetSlices(); + var slices = volume.GetSlices(); foreach (var slice in slices) - voxelLayer.DeleteSlice(slice); + volume.DeleteSlice(slice); #endregion } @@ -884,13 +1120,23 @@ public void Example9h() VoxelLayer voxelLayer = null; var my_section_id = ""; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition #region Get a Section //var voxelLayer = ... ; //Must be on the QueuedTask.Run() - var section = voxelLayer.GetSections().FirstOrDefault(); - var section2 = voxelLayer.GetSections().First(sec => sec.Id == my_section_id); + //At 2.x - + //var section = voxelLayer.GetSections().FirstOrDefault(); + //var section2 = voxelLayer.GetSections().First(sec => sec.Id == my_section_id); + + //Use the SelectedVariableProfile to get the sections currently in the TOC + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + + var section = volume.GetSections().FirstOrDefault(); + var section2 = volume.GetSections().First(sec => sec.ID == my_section_id); #endregion } @@ -901,6 +1147,8 @@ public void Example9g() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition #region Get the Current Collection of Sections //var voxelLayer = ... ; @@ -911,7 +1159,13 @@ public void Example9g() voxelLayer.SetSectionContainerExpanded(true); voxelLayer.SetSectionContainerVisibility(true); - var sections = voxelLayer.GetSections(); + //At 2.x - var sections = voxelLayer.GetSections(); + + //Use the SelectedVariableProfile to get the sections currently in the TOC + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var sections = volume.GetSections(); + #endregion } @@ -920,8 +1174,9 @@ public void Example9i() { Map map = MapView.Active.Map; - VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition #region Get the Selected Section in TOC //var voxelLayer = ... ; @@ -941,6 +1196,9 @@ public void Example9j() Map map = MapView.Active.Map; + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Layer #region Get Voxel Layer for the Selected Section in TOC //var voxelLayer = ... ; @@ -963,6 +1221,15 @@ public void Example9() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.AutoShowExploreDockPane + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetVolumeSize() + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetNormal(System.Double, System.Double) + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.CreateSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Name + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.VoxelPosition + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Normal + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.isVisible #region Create a Section at the Voxel MidPoint //var voxelLayer = ... ; @@ -979,16 +1246,31 @@ public void Example9() //Normally, it would be set in your dockpane //Create a section that cuts the volume in two on the vertical plane - var volume = voxelLayer.GetVolumeSize(); + + //At 2.x - var volume = voxelLayer.GetVolumeSize(); + + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var volumeSize = volume.GetVolumeSize(); //Orientation 90 degrees (due West), Tilt 0 degrees var normal = voxelLayer.GetNormal(90, 0.0); //Position must be specified in voxel space - voxelLayer.CreateSection(new SectionDefinition() + + //At 2.x - + //voxelLayer.CreateSection(new SectionDefinition() + //{ + // Name = "Middle Section", + // VoxelPosition = new Coordinate3D(volume.Item1 / 2, volume.Item2 / 2, volume.Item3 / 2), + // Normal = normal, + // IsVisible = true + //}); + volume.CreateSection(new SectionDefinition() { Name = "Middle Section", - VoxelPosition = new Coordinate3D(volume.Item1 / 2, volume.Item2 / 2, volume.Item3 / 2), + VoxelPosition = new Coordinate3D(volumeSize.X / 2, volumeSize.Y / 2, volumeSize.Z / 2), Normal = normal, IsVisible = true }); @@ -1006,6 +1288,12 @@ public void Example9a() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetVolumeSize() + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.CreateSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.CreateHorizontalSectionDefinition() + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Name + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.VoxelPosition + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Normal #region Create a Horizontal Section //var voxelLayer = ... ; @@ -1017,16 +1305,23 @@ public void Example9a() voxelLayer.SetSectionContainerVisibility(true); //Create a section that cuts the volume in two on the horizontal plane - var volume = voxelLayer.GetVolumeSize(); + + //At 2.x - var volumeSize = voxelLayer.GetVolumeSize(); + + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var volumeSize = volume.GetVolumeSize(); //Or use normal (0, 0, 1) or (0, 0, -1)... var horz_section = SectionDefinition.CreateHorizontalSectionDefinition(); horz_section.Name = "Horizontal Section"; - horz_section.VoxelPosition = new Coordinate3D(volume.Item1 / 2, volume.Item2 / 2, volume.Item3 / 2); horz_section.IsVisible = true; + horz_section.VoxelPosition = new Coordinate3D(volumeSize.X / 2, volumeSize.Y / 2, volumeSize.Z / 2); - voxelLayer.CreateSection(horz_section); + //At 2.x - voxelLayer.CreateSection(horz_section); + volume.CreateSection(horz_section); #endregion } @@ -1037,6 +1332,13 @@ public void Example9b() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetVolumeSize() + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.CreateSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Name + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.VoxelPosition + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Normal + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.isVisible #region Create Sections in a Circle Pattern //var voxelLayer = ... ; @@ -1047,7 +1349,12 @@ public void Example9b() voxelLayer.SetSectionContainerExpanded(true); voxelLayer.SetSectionContainerVisibility(true); - var volume = voxelLayer.GetVolumeSize(); + //At 2.x - var volumeSize = voxelLayer.GetVolumeSize(); + + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var volumeSize = volume.GetVolumeSize(); //180 degrees orientation is due South. 90 degrees orientation is due west. var south = 180.0; @@ -1059,10 +1366,19 @@ public void Example9b() for (int s = 0; s < num_sections; s++) { var orientation = south * (s * spacing); - voxelLayer.CreateSection(new SectionDefinition() + //At 2.x - + //voxelLayer.CreateSection(new SectionDefinition() + //{ + // Name = $"Circle {s + 1}", + // VoxelPosition = new Coordinate3D(volumeSize.Item1 / 2, volumeSize.Item2 / 2, volumeSize.Item3 / 2), + // Normal = voxelLayer.GetNormal(orientation, 0.0), + // IsVisible = true + //}); + + volume.CreateSection(new SectionDefinition() { Name = $"Circle {s + 1}", - VoxelPosition = new Coordinate3D(volume.Item1 / 2, volume.Item2 / 2, volume.Item3 / 2), + VoxelPosition = new Coordinate3D(volumeSize.X / 2, volumeSize.Y / 2, volumeSize.Z / 2), Normal = voxelLayer.GetNormal(orientation, 0.0), IsVisible = true }); @@ -1077,6 +1393,13 @@ public void Example9c() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetVolumeSize() + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.CreateSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Name + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.VoxelPosition + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Normal + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.isVisible #region Create Sections that Bisect the Voxel //var voxelLayer = ... ; @@ -1087,7 +1410,12 @@ public void Example9c() voxelLayer.SetSectionContainerExpanded(true); voxelLayer.SetSectionContainerVisibility(true); - var volume = voxelLayer.GetVolumeSize(); + //At 2.x - var volumeSize = voxelLayer.GetVolumeSize(); + + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var volumeSize = volume.GetVolumeSize(); //Make three Normals - each is a Unit Vector (x, y, z) var north_south = new Coordinate3D(1, 0, 0); @@ -1099,10 +1427,19 @@ public void Example9c() //the Z plane. foreach (var normal in new List { north_south, east_west, horizontal }) { - voxelLayer.CreateSection(new SectionDefinition() + //At 2.x - + //voxelLayer.CreateSection(new SectionDefinition() + //{ + // Name = $"Cross {++n}", + // VoxelPosition = new Coordinate3D(volumeSize.Item1 / 2, volumeSize.Item2 / 2, volumeSize.Item3 / 2), + // Normal = normal, + // IsVisible = true + //}); + + volume.CreateSection(new SectionDefinition() { Name = $"Cross {++n}", - VoxelPosition = new Coordinate3D(volume.Item1 / 2, volume.Item2 / 2, volume.Item3 / 2), + VoxelPosition = new Coordinate3D(volumeSize.X / 2, volumeSize.Y / 2, volumeSize.Z / 2), Normal = normal, IsVisible = true }); @@ -1117,6 +1454,13 @@ public void Example9d() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetVolumeSize() + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.CreateSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.#ctor + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Name + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.VoxelPosition + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Normal + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.isVisible #region Create Sections Diagonally across the Voxel //var voxelLayer = ... ; @@ -1127,13 +1471,19 @@ public void Example9d() voxelLayer.SetSectionContainerExpanded(true); voxelLayer.SetSectionContainerVisibility(true); - var volume = voxelLayer.GetVolumeSize(); + //At 2.x - var volumeSize = voxelLayer.GetVolumeSize(); + + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var volumeSize = volume.GetVolumeSize(); + //make a diagonal across the voxel - var voxel_pos = new Coordinate3D(0, 0, volume.Item3); - var voxel_pos_ur = new Coordinate3D(volume.Item1, volume.Item2, volume.Item3); + var voxel_pos = new Coordinate3D(0, 0, volumeSize.Z); + var voxel_pos_ur = new Coordinate3D(volumeSize.X, volumeSize.Y, volumeSize.Z); - var lineBuilder = new LineBuilder(voxel_pos, voxel_pos_ur, null); - var diagonal = PolylineBuilder.CreatePolyline(lineBuilder.ToSegment()); + var lineBuilder = new LineBuilderEx(voxel_pos, voxel_pos_ur, null); + var diagonal = PolylineBuilderEx.CreatePolyline(lineBuilder.ToSegment()); var num_sections = 12; var spacing = 1 / (double)num_sections; @@ -1157,10 +1507,19 @@ public void Example9d() end_pt = segments.First().EndCoordinate; } - voxelLayer.CreateSection(new SectionDefinition() + //At 2.x - + //voxelLayer.CreateSection(new SectionDefinition() + //{ + // Name = $"Diagonal {s + 1}", + // VoxelPosition = new Coordinate3D(end_pt.X, end_pt.Y, volumeSize.Item3), + // Normal = normal, + // IsVisible = true + //}); + + volume.CreateSection(new SectionDefinition() { Name = $"Diagonal {s + 1}", - VoxelPosition = new Coordinate3D(end_pt.X, end_pt.Y, volume.Item3), + VoxelPosition = new Coordinate3D(end_pt.X, end_pt.Y, volumeSize.Z), Normal = normal, IsVisible = true }); @@ -1175,6 +1534,9 @@ public void Example9e() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.Normal + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.UpdateSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) #region Update Section Orientation and Tilt //var voxelLayer = ... ; @@ -1185,12 +1547,18 @@ public void Example9e() voxelLayer.SetSectionContainerExpanded(true); voxelLayer.SetSectionContainerVisibility(true); - foreach (var section in voxelLayer.GetSections()) + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + + //At 2.x - foreach (var section in voxelLayer.GetSections()) + foreach (var section in volume.GetSections()) { //set each normal to 45.0 orientation and tilt section.Normal = voxelLayer.GetNormal(45.0, 45.0); //apply the change - voxelLayer.UpdateSection(section); + //At 2.x - voxelLayer.UpdateSection(section); + volume.UpdateSection(section); } #endregion @@ -1202,6 +1570,9 @@ public void Example9k() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.GetSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.SectionDefinition.isVisible + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.UpdateSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) #region Update Section Visibility //var voxelLayer = ... ; @@ -1212,14 +1583,20 @@ public void Example9k() voxelLayer.SetSectionContainerExpanded(true); voxelLayer.SetSectionContainerVisibility(true); - var sections = voxelLayer.GetSections().Where(s => !s.IsVisible); + //At 2.x - var sections = voxelLayer.GetSections().Where(s => !s.IsVisible); + + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + var sections = volume.GetSections().Where(s => !s.IsVisible); //Make them all visible foreach (var section in sections) { section.IsVisible = true; //apply the change - voxelLayer.UpdateSection(section); + //At 2.x - voxelLayer.UpdateSection(section); + volume.UpdateSection(section); } #endregion @@ -1231,13 +1608,20 @@ public void Example9f() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.DeleteSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) #region Delete Sections //var voxelLayer = ... ; //Must be on the QueuedTask.Run() - foreach (var section in voxelLayer.GetSections()) - voxelLayer.DeleteSection(section); + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + + //At 2.x - foreach (var section in voxelLayer.GetSections()) + // voxelLayer.DeleteSection(section); + foreach (var section in volume.GetSections()) + volume.DeleteSection(section); //optional... if (voxelLayer.Visualization != VoxelVisualization.Volume) @@ -1255,6 +1639,8 @@ public void Example10() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetLockedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition #region Get the Current Collection of Locked Sections //var voxelLayer = ... ; @@ -1277,6 +1663,8 @@ public void Example10a() VoxelLayer voxelLayer = null; var my_locked_section_id = -1; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetLockedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition #region Get a Locked Section //var voxelLayer = ... ; @@ -1284,7 +1672,7 @@ public void Example10a() var locked_section = voxelLayer.GetLockedSections().FirstOrDefault(); var locked_section2 = voxelLayer.GetLockedSections() - .First(lsec => lsec.Id == my_locked_section_id); + .First(lsec => lsec.ID == my_locked_section_id); #endregion } @@ -1294,6 +1682,8 @@ public void Example10b() Map map = MapView.Active.Map; + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedLockedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition #region Get Selected Locked Section in TOC //var voxelLayer = ... ; @@ -1313,6 +1703,8 @@ public void Example10c() Map map = MapView.Active.Map; + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedLockedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition.Layer #region Get Voxel Layer for the Selected Locked Section in TOC //var voxelLayer = ... ; @@ -1334,6 +1726,11 @@ public void Example10d() Map map = MapView.Active.Map; + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedLockedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition.Layer + // cref: ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition.VariableName + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetVariableProfile(System.String) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.SetSelectedVariableProfile(ArcGIS.Desktop.Mapping.Voxel.VoxelVariableProfile) #region Set the Variable Profile Active for Selected Locked Section //Must be on the QueuedTask.Run() @@ -1354,6 +1751,9 @@ public void Example10e() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.MapView.GetSelectedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.CanLockSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) + // cref: ArcGIS.Desktop.Mapping.Voxel.VoxelVolume.LockSection(ArcGIS.Desktop.Mapping.Voxel.SectionDefinition) #region Lock a Section/"Create" a Locked Section //var voxelLayer = ... ; @@ -1365,19 +1765,29 @@ public void Example10e() voxelLayer.SetLockedSectionContainerExpanded(true); voxelLayer.SetLockedSectionContainerVisibility(true); + //Use the SelectedVariableProfile to get the sections + //via its associated volume + var volume = voxelLayer.SelectedVariableProfile.Volume; + //get the selected section var section = MapView.Active.GetSelectedSections().FirstOrDefault(); if (section == null) - section = voxelLayer.GetSections().FirstOrDefault(); + { + //At 2.x - section = voxelLayer.GetSections().FirstOrDefault(); + section = volume.GetSections().FirstOrDefault(); + } + if (section == null) return; //Lock the section (Creates a locked section, deletes //the section) - if (voxelLayer.CanLockSection(section)) - voxelLayer.LockSection(section); + //if (voxelLayer.CanLockSection(section)) + // voxelLayer.LockSection(section); + if (volume.CanLockSection(section)) + volume.LockSection(section); - #endregion + #endregion } public void Example10g() @@ -1386,6 +1796,9 @@ public void Example10g() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.GetLockedSections() + // cref: ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition.IsVisible + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.UpdateSection(ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition) #region Update Locked Section Visibility //var voxelLayer = ... ; @@ -1416,6 +1829,8 @@ public void Example10f() Map map = MapView.Active.Map; VoxelLayer voxelLayer = null; + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.CanUnlockSection(ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition) + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.UnlockSection(ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition) #region Unlock a Locked Section //var voxelLayer = ... ; @@ -1441,6 +1856,7 @@ public void Example10f() #endregion + // cref: ArcGIS.Desktop.Mapping.VoxelLayer.DeleteSection(ArcGIS.Desktop.Mapping.Voxel.LockedSectionDefinition) #region Delete a Locked Section //var voxelLayer = ... ; diff --git a/Examples/MapExploration.csproj b/Examples/MapExploration.csproj deleted file mode 100644 index 0c75422..0000000 --- a/Examples/MapExploration.csproj +++ /dev/null @@ -1,244 +0,0 @@ - - - - - Debug - AnyCPU - {7806E446-64D4-D74C-4D68-487339D5B3B1} - Library - Properties - MapExploration - MapExploration - v4.8 - 512 - true - - - x64 - pdbonly - false - bin\Debug\ - obj\x64\Debug\MapExploration\ - $(BaseIntermediateOutputPath) - DEBUG - prompt - 4 - - - x64 - pdbonly - true - bin\Release\ - obj\x64\Release\MapExploration\ - $(BaseIntermediateOutputPath) - NDEBUG - prompt - 4 - - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Core\ArcGIS.Desktop.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Mapping\ArcGIS.Desktop.Mapping.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Framework.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Core.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Editing\ArcGIS.Desktop.Editing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Catalog\ArcGIS.Desktop.Catalog.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DesktopExtensions\ArcGIS.Desktop.Extensions.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.Desktop.Shared.Wpf.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\ArcGISSearch\ArcGIS.Desktop.Search.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataSourcesRaster\ArcGIS.Desktop.DataSourcesRaster.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\GeoProcessing\ArcGIS.Desktop.GeoProcessing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Layout\ArcGIS.Desktop.Layouts.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Sharing\ArcGIS.Desktop.Sharing.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\TaskAssistant\ArcGIS.Desktop.TaskAssistant.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\Workflow\ArcGIS.Desktop.Workflow.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\ArcGIS.CoreHost.dll - False - - - C:\Program Files\ArcGIS\Pro\bin\Extensions\DataReviewer\ArcGIS.Desktop.DataReviewer.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Microsoft.CSharp.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationFramework.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Core.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Data.DataSetExtensions.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Windows.Forms.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xaml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Xml.Linq.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\WindowsBase.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.WebRequest.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ServiceModel.Web.dll - False - - - C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Drawing.dll - False - - - packages\Newtonsoft.Json.11.0.1\lib\net45\Newtonsoft.Json.dll - False - - - - - - MSBuild:Compile - Designer - - - BookmarkDockPane.xaml - Code - - - - - MSBuild:Compile - Designer - - - CameraDockPane.xaml - Code - - - - - - MSBuild:Compile - Designer - - - EmbeddedControl.xaml - Code - - - - - - - - - - - True - Resource1.resx - - - ResXFileCodeGenerator - Resource1.Designer.cs - Designer - - - - - - - - \ No newline at end of file diff --git a/Examples/MapExploration/Animation_Examples.cs b/Examples/MapExploration/Animation_Examples.cs deleted file mode 100644 index 481b8e7..0000000 --- a/Examples/MapExploration/Animation_Examples.cs +++ /dev/null @@ -1,269 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using ArcGIS.Desktop.Framework.Threading.Tasks; -using ArcGIS.Desktop.Mapping; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Examples -{ - class Animation_Examples - { - /// Animation.ScaleDuration(double), Animation.Duration - /// - /// - /// - // cref: Set Animation Length;ArcGIS.Desktop.Mapping.Animation.ScaleDuration(System.Double) - // cref: Set Animation Length;ArcGIS.Desktop.Mapping.Animation.Duration - #region Set Animation Length - public void SetAnimationLength(TimeSpan length) - { - var mapView = MapView.Active; - if (mapView != null) - return; - - var animation = mapView.Map.Animation; - var duration = animation.Duration; - if (duration == TimeSpan.Zero) - return; - - var factor = length.TotalSeconds / duration.TotalSeconds; - animation.ScaleDuration(factor); - } - #endregion - - /// Animation.ScaleDuration(double) - /// - /// - /// - // cref: Scale Animation;ArcGIS.Desktop.Mapping.Animation.ScaleDuration(System.TimeSpan,System.TimeSpan,System.Double) - #region Scale Animation - public void ScaleAnimationAfterTime(TimeSpan afterTime, TimeSpan length) - { - var mapView = MapView.Active; - if (mapView != null) - return; - - var animation = mapView.Map.Animation; - var duration = animation.Duration; - if (duration == TimeSpan.Zero || duration <= afterTime) - return; - - var factor = length.TotalSeconds / (duration.TotalSeconds - afterTime.TotalSeconds); - animation.ScaleDuration(afterTime, duration, factor); - } - #endregion - - /// Animation.Tracks, Track.Keyframes - /// - /// - /// - // cref: Camera Keyframes;ArcGIS.Desktop.Mapping.Animation.Tracks - // cref: Camera Keyframes;ArcGIS.Desktop.Mapping.Track.Keyframes - #region Camera Keyframes - public List GetCameraKeyframes() - { - var mapView = MapView.Active; - if (mapView != null) - return null; - - var animation = mapView.Map.Animation; - var cameraTrack = animation.Tracks.OfType().First(); //There will always be only 1 CameraTrack in the animation. - return cameraTrack.Keyframes.OfType().ToList(); - } - #endregion - - /// Animation.GetCameraAtTime - /// - /// - /// - // cref: Interpolate Camera;ArcGIS.Desktop.Mapping.ViewAnimation.GetCameraAtTime(System.TimeSpan) - #region Interpolate Camera - public Task> GetInterpolatedCameras() - { - //Return the collection representing the camera for each frame in animation. - return QueuedTask.Run(() => - { - var mapView = MapView.Active; - if (mapView != null || mapView.Animation == null) - return null; - - var animation = mapView.Map.Animation; - - var cameras = new List(); - //We will use ticks here rather than milliseconds to get the highest precision possible. - var ticksPerFrame = Convert.ToInt64(animation.Duration.Ticks / (animation.NumberOfFrames - 1)); - for (int i = 0; i < animation.NumberOfFrames; i++) - { - var time = TimeSpan.FromTicks(i * ticksPerFrame); - //Because of rounding for ticks the last calculated time may be greating than the duration. - if (time > animation.Duration) - time = animation.Duration; - cameras.Add(mapView.Animation.GetCameraAtTime(time)); - } - return cameras; - }); - } - #endregion - - /// Animation.GetCurrentTimeAtTime - /// - /// - /// - // cref: Interpolate Time;ArcGIS.Desktop.Mapping.ViewAnimation.GetCurrentTimeAtTime(System.TimeSpan) - #region Interpolate Time - public Task> GetInterpolatedMapTimes() - { - //Return the collection representing the map time for each frame in animation. - return QueuedTask.Run(() => - { - var mapView = MapView.Active; - if (mapView != null || mapView.Animation == null) - return null; - - var animation = mapView.Map.Animation; - - var timeRanges = new List(); - //We will use ticks here rather than milliseconds to get the highest precision possible. - var ticksPerFrame = Convert.ToInt64(animation.Duration.Ticks / (animation.NumberOfFrames - 1)); - for (int i = 0; i < animation.NumberOfFrames; i++) - { - var time = TimeSpan.FromTicks(i * ticksPerFrame); - //Because of rounding for ticks the last calculated time may be greating than the duration. - if (time > animation.Duration) - time = animation.Duration; - timeRanges.Add(mapView.Animation.GetCurrentTimeAtTime(time)); - } - return timeRanges; - }); - } - #endregion - - /// Animation.GetCurrentRangeAtTime - /// - /// - /// - // cref: Interpolate Range;ArcGIS.Desktop.Mapping.ViewAnimation.GetCurrentRangeAtTime(System.TimeSpan) - #region Interpolate Range - public Task> GetInterpolatedMapRanges() - { - //Return the collection representing the map time for each frame in animation. - return QueuedTask.Run(() => - { - var mapView = MapView.Active; - if (mapView != null || mapView.Animation == null) - return null; - - var animation = mapView.Map.Animation; - - var ranges = new List(); - //We will use ticks here rather than milliseconds to get the highest precision possible. - var ticksPerFrame = Convert.ToInt64(animation.Duration.Ticks / (animation.NumberOfFrames - 1)); - for (int i = 0; i < animation.NumberOfFrames; i++) - { - var time = TimeSpan.FromTicks(i * ticksPerFrame); - //Because of rounding for ticks the last calculated time may be greating than the duration. - if (time > animation.Duration) - time = animation.Duration; - ranges.Add(mapView.Animation.GetCurrentRangeAtTime(time)); - } - return ranges; - }); - } - #endregion - - /// CameraTrack.CreateKeyframe - /// - /// - /// - // cref: Create Camera Keyframe;ArcGIS.Desktop.Mapping.CameraTrack.CreateKeyframe(ArcGIS.Desktop.Mapping.Camera,System.TimeSpan,ArcGIS.Core.CIM.AnimationTransition) - // cref: Create Camera Keyframe;ArcGIS.Desktop.Mapping.Animation - // cref: Create Camera Keyframe;ArcGIS.Desktop.Mapping.Keyframe - // cref: Create Camera Keyframe;ArcGIS.Desktop.Mapping.Track - #region Create Camera Keyframe - public void CreateCameraKeyframe(TimeSpan atTime) - { - var mapView = MapView.Active; - if (mapView != null) - return; - - var animation = mapView.Map.Animation; - var cameraTrack = animation.Tracks.OfType().First(); //There will always be only 1 CameraTrack in the animation. - cameraTrack.CreateKeyframe(mapView.Camera, atTime, ArcGIS.Core.CIM.AnimationTransition.FixedArc); - } - #endregion - - /// TimeTrack.CreateKeyframe - /// - /// - /// - // cref: Create Time Keyframe;ArcGIS.Desktop.Mapping.TimeTrack.CreateKeyframe(ArcGIS.Desktop.Mapping.TimeRange,System.TimeSpan,ArcGIS.Core.CIM.AnimationTransition) - #region Create Time Keyframe - public void CreateTimeKeyframe(TimeSpan atTime) - { - var mapView = MapView.Active; - if (mapView != null) - return; - - var animation = mapView.Map.Animation; - var timeTrack = animation.Tracks.OfType().First(); //There will always be only 1 TimeTrack in the animation. - timeTrack.CreateKeyframe(mapView.Time, atTime, ArcGIS.Core.CIM.AnimationTransition.Linear); - } - #endregion - - /// RangeTrack.CreateKeyframe - /// - /// - /// - // cref: Create Range Keyframe;ArcGIS.Desktop.Mapping.RangeTrack.CreateKeyframe(ArcGIS.Desktop.Mapping.Range,System.TimeSpan,ArcGIS.Core.CIM.AnimationTransition) - #region Create Range Keyframe - public void CreateRangeKeyframe(Range range, TimeSpan atTime) - { - var mapView = MapView.Active; - if (mapView != null) - return; - - var animation = mapView.Map.Animation; - var rangeTrack = animation.Tracks.OfType().First(); //There will always be only 1 RangeTrack in the animation. - rangeTrack.CreateKeyframe(range, atTime, ArcGIS.Core.CIM.AnimationTransition.Linear); - } - #endregion - - /// RangeTrack.CreateKeyframe - /// - /// - /// - // cref: Create Layer Keyframe;ArcGIS.Desktop.Mapping.LayerTrack.CreateKeyframe(ArcGIS.Desktop.Mapping.Layer,System.TimeSpan,System.Boolean,System.Double,ArcGIS.Core.CIM.AnimationTransition) - #region Create Layer Keyframe - public void CreateLayerKeyframe(Layer layer, double transparency, TimeSpan atTime) - { - var mapView = MapView.Active; - if (mapView != null) - return; - - var animation = mapView.Map.Animation; - var layerTrack = animation.Tracks.OfType().First(); //There will always be only 1 LayerTrack in the animation. - layerTrack.CreateKeyframe(layer, atTime, true, transparency, ArcGIS.Core.CIM.AnimationTransition.Linear); - } - #endregion - } -} diff --git a/Examples/MapExploration/BookmarkDockPane.xaml b/Examples/MapExploration/BookmarkDockPane.xaml deleted file mode 100644 index 2b5a6af..0000000 --- a/Examples/MapExploration/BookmarkDockPane.xaml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Examples/MapExploration/BookmarkDockPane.xaml.cs b/Examples/MapExploration/BookmarkDockPane.xaml.cs deleted file mode 100644 index bf2024b..0000000 --- a/Examples/MapExploration/BookmarkDockPane.xaml.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Examples -{ - /// - /// Interaction logic for BookmarksView.xaml. - /// - public partial class BookmarkDockPane : UserControl - { - public BookmarkDockPane() - { - InitializeComponent(); - } - - /// - /// Event handler for list box item double-click. - /// - public void ListBoxItem_MouseDoubleClick(object sender, RoutedEventArgs e) - { - var vm = this.DataContext as BookmarkDockPaneViewModel; - if (vm == null) - return; - - vm.ZoomToSelectedBookmarkAsync(); - } - } -} diff --git a/Examples/MapExploration/BookmarkDockPaneViewModel.cs b/Examples/MapExploration/BookmarkDockPaneViewModel.cs deleted file mode 100644 index 9292689..0000000 --- a/Examples/MapExploration/BookmarkDockPaneViewModel.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; -using System.Collections.ObjectModel; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Desktop.Core.Events; -using ArcGIS.Desktop.Core; -using ArcGIS.Desktop.Framework.Threading.Tasks; - -namespace Examples -{ - /// - /// ViewModel for the Bookmarks DockPane. - /// - internal class BookmarkDockPaneViewModel : DockPane - { - /// - /// Subscribe to the ProjectOpenedEvent when the DockPane is created. - /// - protected BookmarkDockPaneViewModel() - { - ProjectOpenedEvent.Subscribe(OnProjectOpened); - } - - /// - /// Unsubscribe from the ProjectOpenedEvent when the DockPane is destroyed. - /// - ~BookmarkDockPaneViewModel() - { - ProjectOpenedEvent.Unsubscribe(OnProjectOpened); - } - - /// - /// Called by the framework when the DockPane initializes. - /// - protected override Task InitializeAsync() - { - return UpdateBookmarksAsync(); - } - - /// - /// Bindable property for the collection of bookmarks for the project. - /// - private ReadOnlyObservableCollection _bookmarks; - public ReadOnlyObservableCollection Bookmarks - { - get { return _bookmarks; } - } - - /// - /// Bindable property for the currently selected bookmark. - /// - private Bookmark _selectedBookmark; - public Bookmark SelectedBookmark - { - get { return _selectedBookmark; } - set - { - SetProperty(ref _selectedBookmark, value, () => SelectedBookmark); - } - } - - /// - /// Zoom the active map view to the selected bookmark. - /// - /// True if the navigation completes successfully. - internal Task ZoomToSelectedBookmarkAsync() - { - if (MapView.Active == null) - return Task.FromResult(false); - - return MapView.Active.ZoomToAsync(SelectedBookmark, TimeSpan.FromSeconds(1.5)); - } - - /// - /// Updates the collection of bookmarks which is called when the DockPane is initialized or a project is opened. - /// - private async Task UpdateBookmarksAsync() - { - _bookmarks = await QueuedTask.Run(() => Project.Current.GetBookmarks()); - NotifyPropertyChanged(() => Bookmarks); - } - - /// - /// Event delegate for the ProjectOpenedEvent - /// - private void OnProjectOpened(ProjectEventArgs obj) - { - Task t = UpdateBookmarksAsync(); - } - } -} diff --git a/Examples/MapExploration/Bookmark_Examples.cs b/Examples/MapExploration/Bookmark_Examples.cs deleted file mode 100644 index 28efb03..0000000 --- a/Examples/MapExploration/Bookmark_Examples.cs +++ /dev/null @@ -1,263 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Desktop.Framework.Threading.Tasks; -using System.Collections.ObjectModel; -using ArcGIS.Desktop.Core; -using ArcGIS.Core.CIM; -using System.Windows.Media.Imaging; - -namespace Examples -{ - class Bookmark_Examples - { - /// Bookmark - /// - /// - /// - /// - /// - - /// ProjectExtender.GetBookmarks() - /// - /// - /// - // cref: Get Project Bookmarks;ArcGIS.Desktop.Core.ProjectExtender.GetBookmarks(ArcGIS.Desktop.Core.Project) - #region Get Project Bookmarks - public Task> GetProjectBookmarksAsync() - { - //Get the collection of bookmarks for the project. - return QueuedTask.Run(() => Project.Current.GetBookmarks()); - } - #endregion - - /// Map.GetBookmarks() - /// - /// - /// - // cref: Get Map Bookmarks;ArcGIS.Desktop.Mapping.Map.GetBookmarks - #region Get Map Bookmarks - public Task> GetActiveMapBookmarksAsync() - { - return QueuedTask.Run(() => - { - //Get the active map view. - var mapView = MapView.Active; - if (mapView == null) - return null; - - //Return the collection of bookmarks for the map. - return mapView.Map.GetBookmarks(); - }); - } - #endregion - - /// Bookmark.AddBookmark(MapView, string) - /// - /// - /// - // cref: Add New Bookmark from MapView;ArcGIS.Desktop.Mapping.Map.AddBookmark(ArcGIS.Desktop.Mapping.MapView,System.String) - // cref: Add New Bookmark from MapView;ArcGIS.Desktop.Mapping.Map.AddBookmark(ArcGIS.Desktop.Mapping.MapView,System.String,System.String) - #region Add New Bookmark from MapView - public Task AddBookmarkAsync(string name) - { - return QueuedTask.Run(() => - { - //Get the active map view. - var mapView = MapView.Active; - if (mapView == null) - return null; - - //Adding a new bookmark using the active view. - return mapView.Map.AddBookmark(mapView, name); - }); - } - #endregion - - /// Bookmark.AddBookmark(CIMBookmark) - /// - /// - /// - // cref: Add New Bookmark from CIMBookmark;ArcGIS.Desktop.Mapping.Map.AddBookmark(ArcGIS.Core.CIM.CIMBookmark) - #region Add New Bookmark from CIMBookmark - public Task AddBookmarkFromCameraAsync(Camera camera, string name) - { - return QueuedTask.Run(() => - { - //Set properties for Camera - CIMViewCamera cimCamera = new CIMViewCamera() - { - X = camera.X, - Y = camera.Y, - Z = camera.Z, - Scale = camera.Scale, - Pitch = camera.Pitch, - Heading = camera.Heading, - Roll = camera.Roll - }; - - //Create new CIM bookmark and populate its properties - var cimBookmark = new CIMBookmark() { Camera = cimCamera, Name = name, ThumbnailImagePath = "" }; - - //Get the active map view. - var mapView = MapView.Active; - if (mapView == null) - return null; - - //Add a new bookmark for the active map. - return mapView.Map.AddBookmark(cimBookmark); - }); - } - #endregion - - /// Map.Remove(Bookmark) - /// - /// - /// - // cref: Remove Bookmark with Name;ArcGIS.Desktop.Mapping.Map.RemoveBookmark(ArcGIS.Desktop.Mapping.Bookmark) - #region Remove Bookmark with Name - public Task RemoveBookmarkAsync(Map map, string name) - { - return QueuedTask.Run(() => - { - //Find the first bookmark with the name - var bookmark = map.GetBookmarks().FirstOrDefault(b => b.Name == name); - if (bookmark == null) - return; - - //Remove the bookmark - map.RemoveBookmark(bookmark); - }); - } - #endregion - - /// Map.Move(Bookmark, int) - /// - /// - /// - // cref: Move Bookmark to the Top;ArcGIS.Desktop.Mapping.Map.MoveBookmark(ArcGIS.Desktop.Mapping.Bookmark,System.Int32) - #region Move Bookmark to the Top - public Task MoveBookmarkToTopAsync(Map map, string name) - { - return QueuedTask.Run(() => - { - //Find the first bookmark with the name - var bookmark = map.GetBookmarks().FirstOrDefault(b => b.Name == name); - if (bookmark == null) - return; - - //Remove the bookmark - map.MoveBookmark(bookmark, 0); - }); - } - #endregion - - /// Bookmark.GetDefinition(), Bookmark.SetDefinition(CIMBookmark) - /// - /// - /// - // cref: Update Extent for a Bookmark;ArcGIS.Desktop.Mapping.Bookmark.GetDefinition - // cref: Update Extent for a Bookmark;ArcGIS.Desktop.Mapping.Bookmark.SetDefinition(ArcGIS.Core.CIM.CIMBookmark) - #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); - }); - } - #endregion - - /// Bookmark.MapURI - /// - /// - /// - // cref: Find Map Bookmarks;ArcGIS.Desktop.Mapping.Bookmark.MapURI - #region Find Map Bookmarks - public IEnumerable FindMapBookmarks(List bookmarks, Map map) - { - //Return all the bookmarks from a collection that are stored with a given map. - return bookmarks.Where(b => b.MapURI == map.URI); - } - #endregion - - /// Bookmark.Update(MapView) - /// - /// - /// - // cref: Update Bookmark;ArcGIS.Desktop.Mapping.Bookmark.Update(ArcGIS.Desktop.Mapping.MapView) - #region Update Bookmark - public Task UpdateBookmarkAsync(Bookmark bookmark) - { - return QueuedTask.Run(() => - { - //Get the active map view. - var mapView = MapView.Active; - if (mapView == null) - return; - - //Update the bookmark using the active map view. - bookmark.Update(mapView); - }); - } - #endregion - - /// Bookmark.Rename(string) - /// - /// - /// - // cref: Rename Bookmark;ArcGIS.Desktop.Mapping.Bookmark.Rename(System.String) - #region Rename Bookmark - public Task RenameBookmarkAsync(Bookmark bookmark, string newName) - { - return QueuedTask.Run(() => bookmark.Rename(newName)); - } - #endregion - - /// Bookmark.SetThumbnail() - /// - /// - /// - // cref: Change Thumbnail;ArcGIS.Desktop.Mapping.Bookmark.SetThumbnail(System.Windows.Media.Imaging.BitmapSource) - #region Change Thumbnail - public Task SetThumbnailAsync(Bookmark bookmark, string imagePath) - { - //Set the thumbnail to an image on disk, ie. C:\Pictures\MyPicture.png. - BitmapImage image = new BitmapImage(new Uri(imagePath, UriKind.RelativeOrAbsolute)); - return QueuedTask.Run(() => bookmark.SetThumbnail(image)); - } - #endregion - } -} - diff --git a/Examples/MapExploration/CameraDockPane.xaml b/Examples/MapExploration/CameraDockPane.xaml deleted file mode 100644 index b229d31..0000000 --- a/Examples/MapExploration/CameraDockPane.xaml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Examples/MapExploration/CameraDockPane.xaml.cs b/Examples/MapExploration/CameraDockPane.xaml.cs deleted file mode 100644 index e55ea77..0000000 --- a/Examples/MapExploration/CameraDockPane.xaml.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 Esri -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - - -namespace Examples -{ - /// - /// Interaction logic for CameraView.xaml - /// - public partial class CameraDockPane : UserControl - { - public CameraDockPane() - { - InitializeComponent(); - } - } -} diff --git a/Examples/MapExploration/CameraDockPaneViewModel.cs b/Examples/MapExploration/CameraDockPaneViewModel.cs deleted file mode 100644 index 40d320f..0000000 --- a/Examples/MapExploration/CameraDockPaneViewModel.cs +++ /dev/null @@ -1,133 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ArcGIS.Desktop.Framework; -using ArcGIS.Desktop.Framework.Contracts; -using ArcGIS.Desktop.Mapping; -using ArcGIS.Desktop.Mapping.Events; -using System.Windows.Input; - -namespace Examples -{ - /// - /// ViewModel for the Camera DockPane. - /// - internal class CameraDockPaneViewModel : DockPane - { - /// - /// Subscribe to the MapViewCameraChangedEvent and ActiveMapViewChangedEvent when the DockPane is created. - /// - public CameraDockPaneViewModel() - { - MapViewCameraChangedEvent.Subscribe(OnCameraChanged); - ActiveMapViewChangedEvent.Subscribe(OnActiveMapViewChanged); - - if (MapView.Active != null) - Camera = MapView.Active.Camera; - } - - /// - /// Unsubscribe from the MapViewCameraChangedEvent and ActiveMapViewChangedEvent when the DockPane is destroyed. - /// - ~CameraDockPaneViewModel() - { - if (_zoomToCmd != null) - _zoomToCmd.Disconnect(); - - if (_panToCmd != null) - _panToCmd.Disconnect(); - - ActiveMapViewChangedEvent.Unsubscribe(OnActiveMapViewChanged); - MapViewCameraChangedEvent.Unsubscribe(OnCameraChanged); - } - - /// - /// Bindable property for the camera in the active map view. - /// - private Camera _camera; - public Camera Camera - { - get { return _camera; } - set - { - SetProperty(ref _camera, value, () => Camera); - } - } - - /// - /// Bindable command for the Pan To button. - /// - private RelayCommand _panToCmd; - public ICommand PanToCmd - { - get - { - if (_panToCmd == null) - { - _panToCmd = new RelayCommand(() => MapView.Active.PanToAsync(Camera, TimeSpan.FromSeconds(1.5)), () => { return MapView.Active != null; }); - } - return _panToCmd; - } - } - - - /// - /// Bindable command for the Zoom To button. - /// - private RelayCommand _zoomToCmd; - public ICommand ZoomToCmd - { - get - { - if (_zoomToCmd == null) - { - _zoomToCmd = new RelayCommand(() => MapView.Active.ZoomToAsync(Camera, TimeSpan.FromSeconds(1.5)), () => { return MapView.Active != null; }); - } - return _zoomToCmd; - } - } - - /// - /// Event delegate for the MapViewCameraChangedEvent - /// - private void OnCameraChanged(MapViewCameraChangedEventArgs obj) - { - if (obj.MapView == MapView.Active) - Camera = obj.CurrentCamera; - } - - /// - /// Event delegate for the ActiveMapViewChangedEvent - /// - private void OnActiveMapViewChanged(ActiveMapViewChangedEventArgs obj) - { - if (obj.IncomingView == null) - { - Camera = null; - return; - } - - Camera = obj.IncomingView.Camera; - } - } -} diff --git a/Examples/MapExploration/Camera_Examples.cs b/Examples/MapExploration/Camera_Examples.cs deleted file mode 100644 index ead08a5..0000000 --- a/Examples/MapExploration/Camera_Examples.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* - - Copyright 2018 Esri - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - - See the License for the specific language governing permissions and - limitations under the License. - -*/ -using ArcGIS.Core.Geometry; -using ArcGIS.Desktop.Framework.Threading.Tasks; -using ArcGIS.Desktop.Mapping; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Examples -{ - class Camera_Examples - { - /// Camera - /// - /// - /// - /// - /// - - /// Camera.Heading - /// - /// - /// - - /// Camera.SpatialReference - /// - /// - /// - // cref: Project Camera;ArcGIS.Desktop.Mapping.Camera.SpatialReference - #region Project Camera - public Task ProjectCamera(Camera camera, ArcGIS.Core.Geometry.SpatialReference spatialReference) - { - return QueuedTask.Run(() => - { - var mapPoint = MapPointBuilder.CreateMapPoint(camera.X, camera.Y, camera.Z, camera.SpatialReference); - var newPoint = GeometryEngine.Instance.Project(mapPoint, spatialReference) as MapPoint; - var newCamera = new Camera() - { - X = newPoint.X, - Y = newPoint.Y, - Z = newPoint.Z, - Scale = camera.Scale, - Pitch = camera.Pitch, - Heading = camera.Heading, - Roll = camera.Roll, - Viewpoint = camera.Viewpoint, - SpatialReference = spatialReference - }; - return newCamera; - }); - } - #endregion - } -} diff --git a/Examples/MapExploration/Config.daml b/Examples/MapExploration/Config.daml deleted file mode 100644 index 95b1450..0000000 --- a/Examples/MapExploration/Config.daml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - ArcGIS.Desktop.Mapping.MapExploration - ArcGIS.Desktop.Mapping.MapExploration - Images\AddinDesktop32.png - Chris Fox - Esri - 5/20/2015 4:33:38 PM, 2015 - Map Exploration - - - - - - - - - - - - - - - + + @@ -529,23 +526,6 @@ ArcGIS Pro SDK for .NET provides the following project and item templates: In general, there is a one-to-one correspondence between a framework UI element extensibility point (e.g. button, tool, menu, dockpane, etc) and an item template. Use the relevant item template to add the corresponding extensibility point to your Add-in. -Note: For the following item templates a further description may be useful: - -##### Drop Handler -The ArcGIS Pro Framework supports drag and drop via two virtual functions: [OnDragOver](https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic10438.html) and [OnDrop](https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic10439.html). Use the Drop Handler template to add basic implementations of these methods to your add-in to help get you started with drag and drop support for your custom panes and dockpanes. -[Excel Drop Handler sample](https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Content/ExcelDropHandler) - -##### Embeddable Control -Use the Embeddable Control template to add a pop-up or similar UI to your custom map tools. When a map tool is activated, its associated embeddable control (if it has one) is displayed on-top-of the active map view. When the map tool is de-activated, the embeddable control is hidden. -[ProGuide: Using Embeddable Controls](https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Using-Embeddable-Controls) -[Basic Map Tool sample](https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/BasicMapTool) -[Map Tool with OverlayControl Sample](https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/MapToolWithOverlayControl) - -##### Map Pane Impersonation -If you want your custom pane to "use" the map TOC content control (and not a custom content control) then you must "impersonate" the map pane. Run this template to generate the necessary code to implement a custom pane with map pane impersonation. -[ProGuide: Map Pane Impersonation](https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Map-Pane-Impersonation) -[ImpersonateMapPane Sample](https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/ImpersonateMapPane) - #### ArcGIS Pro SDK for .NET utilities Package: proapp-sdk-utilities.vsix @@ -558,22 +538,25 @@ Name | Description Pro Fix References utility | Fixes broken references in an ArcGIS Pro add-in, core host, configuration, or plug-in projects. Broken references can be caused when you share add-ins with other colleagues or download add-ins where the ArcGIS Pro assembly references point to a different location from where you installed them. Pro Fix References can be run on individual projects or all projects within a solution. Pro Generate DAML Ids utility| Converts all of the ArcGIS Pro Desktop Application Markup Language (DAML) string IDs into static string properties organized by DAML element types (for example, Button, Dockpane, Tool, Condition, and so on). This allows you to use the IntelliSense feature of Visual Studio within your source code file to add IDs, rather than having to manually type DAML string IDs). -### Getting started +#### ArcGIS Pro SDK for .NET Migration +Package: proapp-sdk-migration.vsix -See [ProGuide: Build your first add-in](https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-Build-Your-First-Add-in) for step-by-step instructions on creating a basic button that appears on the ArcGIS Pro ribbon. +![pro-migration](https://ArcGIS.github.io/arcgis-pro-sdk/images/Home/proapp-sdk-migration.png "ArcGIS Pro SDK(Migration)") -### ProSnippets +ArcGIS Pro SDK for .NET (Migration) provides support to migrate ArcGIS Pro SDK 2.x extensions to ArcGIS Pro SDK 3.0 for .NET. -ProSnippets are ready-made snippets of code you can quickly insert into your ArcGIS Pro add-in. [List of available ProSnippets](https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets). +### Recommended minimum version of Visual Studio 2022 -### Deprecation Information -* ArcGIS Pro 2.9 is the last release with .NET Framework 4.8. ArcGIS Pro **3.0** will introduce support for .NET 6.0, Microsoft's latest edition of .NET. Support for .NET 6.0 will replace support for .NET Framework 4.8. With **3.0**, .NET Framework 4.8 will no longer be supported. This will be **a breaking change**. -* ArcGIS Pro 2.9 SDK is the last release with support for Visual Studio 2017 and 2019. The ArcGIS Pro **3.0** SDK will introduce support for Visual Studio 2022, Microsoft's latest edition of its IDE. Support for Visual Studio 2022 will replace support for Visual Studio 2017 and 2019. With **3.0**, Visual Studio 2017 and 2019 will no longer be supported.. -* ChromiumWebBrowser has been been deprecated at 2.9. If you are currently using ChromiumWebBrowser control, please switch to using WebViewBrowser instead. [WebViewBrowser control](https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Framework#webviewbrowser-control) +We recommend installing a minimum version of 17.2 of Visual Studio. This version includes .NET 6.0.5 as part of the Visual Studio 2022 install (.NET SDK 6.0.3). Installing a lesser version of Visual Studio 2022 may require a separate install of the .NET Desktop Runtime 6.0.5 and/or .NET SDK 6.0.3. Consult Microsoft’s [Download .NET 6.0](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) site for more information. +Additionally, with earlier versions of Visual Studio, you may encounter this message when installing the Pro SDK prosdk_utilitiesPackage.vsix for 3.0. Simply click “No” to continue and consider updating your Visual Studio 2022 version. +![VisualStudioError.png](https://ArcGIS.github.io/arcgis-pro-sdk/images/Home/VisualStudioError.png "Visual Studio error") -## Previous versions +### CopyLocal issue +When compiling your addins you may notice that the CopyLocal behavior of the addin (or Configuration or Plugin) is broken. Even though Pro assemblies (or any assembly) have the CopyLocal=No attribute set in the property UI, the assembly is still copied local (and added to the addin archive). To fix this issue, it is recommended that you upgrade your Visual Studio 2022 to 17.2 or better. After upgrading your Visual Studio 2022, “clean” the addin project and ensure that the “obj” folder, within the project, is deleted. Check all Pro assembly reference properties in the .csproj or .vbproj and ensure that CopyLocal is set to No. Rebuild the project. +### Previous versions +* [ArcGIS Pro 2.9 SDK for .NET](https://github.com/Esri/arcgis-pro-sdk/releases/tag/2.9.0.32739) * [ArcGIS Pro 2.8 SDK for .NET](https://github.com/Esri/arcgis-pro-sdk/releases/tag/2.8.0.29751) * [ArcGIS Pro 2.7 SDK for .NET](https://github.com/Esri/arcgis-pro-sdk/releases/tag/2.7.0.26828) * [ArcGIS Pro 2.6 SDK for .NET](https://github.com/Esri/arcgis-pro-sdk/releases/tag/2.6.0.24783) @@ -588,6 +571,16 @@ ProSnippets are ready-made snippets of code you can quickly insert into your Arc * [ArcGIS Pro 1.2 SDK for .NET](https://github.com/Esri/arcgis-pro-sdk/releases/tag/1.2.0.5023) * [ArcGIS Pro 1.1 SDK for .NET](https://github.com/Esri/arcgis-pro-sdk/releases/tag/1.1.0.3318) +## Resources + +* [API Reference online](https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference) +* [ProSnippets: ready-made snippets of code for your ArcGIS Pro add-ins.](https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets). +* ArcGIS Pro SDK for .NET (pro.arcgis.com) +* [arcgis-pro-sdk-community-samples](http://github.com/Esri/arcgis-pro-sdk-community-samples) +* [ArcGIS Pro DAML ID Reference](http://github.com/Esri/arcgis-pro-sdk/wiki/ArcGIS-Pro-DAML-ID-Reference) +* [FAQ](http://github.com/Esri/arcgis-pro-sdk/wiki/FAQ) +* [ArcGIS Pro SDK icons](https://github.com/Esri/arcgis-pro-sdk/releases/tag/3.0.36056) + ## Contributing Esri welcomes contributions from anyone and everyone. For more information, see our [guidelines for contributing](https://github.com/esri/contributing). @@ -597,7 +590,7 @@ Esri welcomes contributions from anyone and everyone. For more information, see Find a bug or want to request a new feature? Let us know by submitting an issue. ## Licensing -Copyright 2021 Esri +Copyright 2022 Esri Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -614,7 +607,7 @@ limitations under the License. A copy of the license is available in the repository's [license.txt](./License.txt) file. -

pre-req ArcGIS Pro 2.9 SDK for Microsoft .NET Framework

+

pre-req ArcGIS Pro 3.0 SDK for Microsoft .NET Framework

                                                    [Home](https://github.com/Esri/arcgis-pro-sdk/wiki) | API Reference | [Requirements](#requirements) | [Download](#installing-arcgis-pro-sdk-for-net) | Samples
ArcGIS Pro Gallery
ArcGIS Pro Inline-Gallery
N/A ArcGIS Pro Layout Tool
N/A ArcGIS Pro Layout Tray Button
ArcGIS Pro Map Pane Impersonation
ArcGIS Pro Map Tool
N/A ArcGIS Pro Map Tray Button
ArcGIS Pro Menu
ArcGIS Pro Pane
ArcGIS Pro Property Sheet