ArcGIS Pro二次开发打开对话框

ArcGIS Pro二次开发打开对话框

 

在ArcGIS Pro的二次开发中,很多时候需要加载或者保存特定格式的数据库,如选择FileGDB中的数据进行加载、选择.sde数据库中的文件进行加载、加载支持的栅格数据等等,很多时候需要需要利用Windows自带的打开或者保存对话框,进行数据的过滤和保存,这样做起来比较繁琐,最新的ArcGIS Pro开发包针对GIS的各种格式,封装了专门的打开和保存的对话框,如下

ArcGIS.Desktop.Catalog.OpenItemDialog

       ArcGIS.Desktop.Catalog.SaveItemDialog

在线的帮助地址为https://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic8992.html

和https://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic9001.html

这两个对话框使用的使用方式简单

如打开对话框

            OpenItemDialog searchGdbDialog = new OpenItemDialog

            {

                Title = "Find GDB",

                InitialLocation = @"C:\Data",

                MultiSelect = false,

                Filter = ItemFilters.geodatabases

            };

 

            var ok = searchGdbDialog.ShowDialog();

            if (ok != true) return;

            var selectedItems = searchGdbDialog.Items;

            foreach (var selectedItem in selectedItems)

                GdbPath = selectedItem.Path;

这个例子是打开GDB的数据,通过Filter属性进行选择过滤,运行结果如下:

ArcGIS Pro二次开发打开对话框_第1张图片

保存对话框如下

              // Create the log file and write the current Folder-Connection's to it

              SaveItemDialog saveDialog = new SaveItemDialog();

              saveDialog.Title = "Export the current selected map series item";

              saveDialog.OverwritePrompt = true;

              saveDialog.DefaultExt = "pdf";

 

              // If the save dialog was not dismissed, create the file

              if (saveDialog.ShowDialog() == true)

              {

                await QueuedTask.Run(() =>

                {

                  Layout layout = layoutItem.GetLayout();

                  if (layout == null)

                    return;

                  // Create PDF format with appropriate settings

                  PDFFormat PDF = new PDFFormat()

                  {

                    Resolution = 300,

                    OutputFileName = saveDialog.FilePath

                  };

                  if (PDF.ValidateOutputFilePath())

                  {

                    layout.Export(PDF);

                  }

                });

这个是保存当前地图为PDF的例子,运行结果如下

ArcGIS Pro二次开发打开对话框_第2张图片

 

可以通过过滤属性Filter进行需要数据格式的过滤操作,支持过滤的格式基本上涵盖了所有GIS支持的格式,支持的格式如下:

Name

Description

annotation

Supports browsing for annotation feature classes  

cad

Supports browsing CAD datasets and the feature classes they contain  

composite_addToMap

Supports browsing for items and datasets that can be added to a map. As a composite filter, the default filter allows you to browse for anything that is supported, but focused filters are also available to browse just for layers or geodatabase items, for example, that you want to add to a map.  

composite_addToStereoMap

Supports browsing for items and datasets that can be added to a stereo map. As a composite filter, the default filter allows you to browse for anything that is supported, but focused filters are also available to browse just for layers or geodatabase items, for example, that you want to add to a stereo map.  

composite_elevationSource

Supports browsing for web layers and datasets that can be used to define the elevation surface of a globe. As a composite filter, the default filter allows you to browse for anything that is supported, but focused filters are also available to browse just for images services, for example, that you want to define the ground.  

composite_maps_import

Supports browsing for maps and layouts that can be imported to a project. As a composite filter, the default filter allows you to browse for anything that is supported, but focused filters are also available to browse just for ArcGIS Pro map or layout files, for example, that you want to import.  

databases

Supports browsing all types of databases supported by ArcGIS Pro. Both database connections in a project and databases stored on a local or network computer can be browsed.  

default_addToMap

Supports browsing all items or datasets that can be added to a map. This is the default filter in the composite_addToMap filter.  

default_addToStereoMap

Supports browsing all items or datasets that can be added to a stereo map. This is the default filter in the composite_addToStereoMap filter.  

default_import

Supports browsing all items that can be imported to a project. This is the default filter in the composite_maps_import filter.  

dimensions

Supports browsing for dimension feature classes  

featureClasses_all

Supports browsing all types of feature classes  

featureDatasets_all

Supports browsing all types of feature datasets  

folders

Supports browsing folder connections in the project and folders on a local or network computer  

geodatabaseItems_all

Supports browsing all types of items stored in a geodatabase  

geodatabases

Supports browsing all types of geodatabases supported by ArcGIS Pro. Both database connections in a project and databases stored on a local or network computer can be browsed.  

kml

Supports browsing Keyhole Markup Language files  

layers_allFileTypes

Supports browsing layer files and layer packages available from the active portal and from a local or network computer  

locators_allTypes

Supports browsing all types of locators, including locator files and ArcGIS Server geocoding services  

maps_all

Supports browsing maps in the project and all types of maps stored on a local or network computer  

packages

Supports browsing all types of packages available from the active portal and stored on a local or network computer  

project_templates

Supports browsing project templates available from the active portal and from a local or network computer  

projects

Supports browsing projects and project packages available from the active portal and from a local or network computer  

rasters

Supports browsing all types of rasters, including mosaic datasets and file-based raster datasets  

services_addToMap

Supports browsing all types of web layers from the active portal and services from server connections in the project that can be added to maps  

services_addToStereoMap

Supports browsing all types of web layers from the active portal and services from server connections in the project that can be added to stereo maps  

services_all

Supports browsing all types of web layers from the active portal and services from server connections in the project that can be used in ArcGIS Pro  

services_feature

Supports browsing feature services from the active portal and services from server connections in the project that can be added to maps  

services_image

Supports browsing image services from the active portal and services from server connections in the project that can be added to maps  

services_map

Supports browsing map services from the active portal and services from server connections in the project that can be added to maps  

shapefiles

Supports browsing for shapefiles stored on a local or network computer  

styleFiles

Supports browsing styles accessed from the active portal or stored on a local or network computer  

tables_all

Supports browsing all types of tables  

taskFiles

Supports browsing for task files stored on a local or network computer  

textFiles

Supports browsing all types of text files  

tinDatasets

Supports browsing for TIN datasets stored on a local or network computer  

toolboxes

Supports browsing for all types of toolboxes  

tools

Supports browsing for tools stored in toolboxes  

videos

Support browsing for video files  

workspaces_all

Supports browsing for all types of workspaces, including folders, geodatabases, and feature datasets  

 

相关地址如下

https://pro.arcgis.com/en/pro-app/sdk/api-reference/#topic8982.html

 

 

 

 

 

 

 

你可能感兴趣的:(ArcGIS,Pro,SDK)