Create custom Project and Application settings using the ArcGIS Pro SDK

3000
5
10-09-2017 12:28 PM
UmaHarano
Esri Regular Contributor
1 5 3,000

This blog will discuss defining custom Project and Application level settings using the Pro SDK. Project and Application settings can be accessed off the ArcGIS Pro Options property page dialog.


Custom project settings

Custom project settings are saved in the project and can be accessed each time the project is reopened. This is accomplished by the Module class’ overrides OnReadSettingsAsync and OnWriteSettingsAsync methods. A Property Sheet should be added to the Options dialog in ArcGIS Pro to provide a UI for users to view and modify these settings.
Add an ArcGIS Pro Property sheet item using the Pro SDK to your add-in project. Add any UI elements you need such as check boxes, radio buttons etc that define specific project settings.

Custom project settings

Insert your custom property sheet into the Options dialog by adding it to the property sheet collection of the "esri_core_optionsPropertySheet" (as shown below) in your Config.daml. Set the "group" attribute on your "insertPage" DAML element to "Project". 

</modules>
 <propertySheets>
 <updateSheet refID="esri_core_optionsPropertySheet">
 <!--Use group=Project for the options to appear under the Project section in the settings-->
 <!--assign the viewModel class to the className attribute; assign the view class to the 
 className attribute in the content tag-->
 <insertPage id="esri_sdk_PropertyPageProjectSettings" caption="Sample Project Settings" 
 className="ProjectSettingsViewModel" group="Project">
 <content className="ProjectSettingsView" />
 </insertPage>
</updateSheet>
 </propertySheets>
</ArcGIS>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


The ViewModel of your property sheet should be updated whenever the module OnReadSettingsAsync override gets called. Conversely, the property sheet ViewModel should be queried for its current settings whenever the module OnWriteSettingsAsync override gets called (which is on every project save). The settings themselves are persisted as strings in the project and so must be seriailizable.


Custom application settings

ArcGIS Pro Application level custom settings can be added to the existing Pro application settings via a .NET application settings file. Settings are modified via a Properties.Settings class that you define with your own custom properties and values. Settings are persisted to a user.config file in the logged-on user’s AppData folder and will be read at add-in initialization when the Settings class instance (in your add-in) is instantiated. Settings are saved when you explicitly call “save” on your Settings class instance (e.g. in response to a user changing settings on your custom application property sheet).

Custom application settings


To expose custom application settings in the UI, add another property sheet to the "esri_core_optionsPropertySheet" collection (as before for Project settings). This time set its "group" attribute to “Application”.

</modules>
 <propertySheets>
 <updateSheet refID="esri_core_optionsPropertySheet"> 
 <!--Use group=Application for the options to appear under the Application section in the settings-->
 <!--assign the viewModel class to the className attribute; assign the view class to the className attribute in the content tag-->
 <insertPage id="esri_sdk_PropertyPageAppSettings" caption="Sample App Settings" className="ApplicationSettingsViewModel" group="Application">
 <content className="ApplicationSettingsView" />
 </insertPage>
 </updateSheet>
 </propertySheets>
</ArcGIS>

To read step by step instructions on how to develop an add-in that creates custom project and application settings in ArcGIS Pro refer to the new ProGuide: Custom settings in the arcgis-pro-sdk-wiki.

5 Comments
EliseoCarrillo
New Contributor II

Hi!

What about if we want to edit the value of a standard setting using the ArcGIS Pro SDK?

Thanks in advance,

Eliseo

UmaHarano
Esri Regular Contributor

This is currently not supported.

Thanks

Uma

VidmasKondratas
Esri Contributor

I need to do the same thing: persist Pro Project-level settings for my custom AddIn that are changed dynamically in the AddIn. Using the default database in the Pro Project comes to mind, but is there another way of doing this using the Pro SDK? Saving setting data in the Pro Project for AddIn use so it would persist when they close and re-open the Pro Project?

AbelPerez
Occasional Contributor III

How can I open to view a property sheet from my toolbar? I already created my property sheet and put it in the backstage successfully. Now i want to click a button on my toolbar that will open to it directly.

There seems to be some support for this because if I right-click on any toolbar and then choose "Customize the Ribbon" it displays the property sheet from the backstage.

AbelPerez
Occasional Contributor III