How to access the current application

A reference to an OperationsDashboard object representing the current application is returned from the static Instance property on the OperationsDashboard class. Use this object to access the types and members correspond to the current operation view in the Operations Dashboard for ArcGIS application if no other reference is available.

For example, the code below demonstrates how you can use the static (Shared in Visual Basic) Instance property to get an OperationsDashboard object, and then uses the Widgets property and a Linq extension method to get the first MapWidget from the collection.

Accessing the first map widget via the OperationsDashboard class

OperationsDashboard opApp = OperationsDashboard.Instance;
 MapWidget mapW = opApp.Widgets.OfType<MapWidget>().FirstOrDefault();

Accessing the first map widget via the OperationsDashboard class

Dim opApp As OperationsDashboard = OperationsDashboard.Instance
Dim mapW As MapWidget = opApp.Widgets.OfType(Of MapWidget).FirstOrDefault()

When to use the application instance

In many cases, it is not necessary to access the application instance directly. For example, a data source consumer widget may only need to use the DataSource object passed to the IDataSourceUpdated.OnRefresh method, in order to access the data source it is configured against and show information for that data source. There is no need in this case to directly access the DataSources property on the application instance class. Similarly, a feature action is passed the data source and feature that it should use in the Execute method.

When a map tool is created, the MapWidget property on the map tool class is set once the map is available, and there may be no need to retrieve the map widget directly from the Widgets property on the application instance class.

However, there are cases where access to other application state is required. For example, the Send to chat feature action checks in the IFeatureAction.CanExecute method if there is a Chat widget present and signed in; if so the method returns true and the feature action is enabled. The Widgets collection on the OperationsDashboard can be used for similar cases in a custom feature action. The DataSources property may be useful where a custom widget is a data source consumer, but the list of data sources is limited to a subset of the available data sources. For example a widget may perhaps only be applicable to data sources provided by feature services in a map; in this case the DataSources property can be used to present a list of data sources to the operation view author instead of using the DataSourceSelector control which lists all data sources.

1/27/2015