Using Windows Application Framework: Overview

The Windows Application Framework provides developers with the capability to extend or custome the ArcGIS for Windows application. You can either create tasks to implement your own workflow or extend/customize the existing tasks, extensions, or application. To do so, you need to understand the extensible points within the Windows application, where and how you can plug in your own business logic, and how to use the application framework components (for example, Page, MessageBox) appropriately in your implementation. This section will help you deeply dive into the Windows Application Framework, explain how to extend these extensible or customizable points within the application, and how to use application framework components in detail.

Windows application customizable or extensible points

Menus

The Windows application has five menus: Application menu, GPS menu, Page menu, Feature List menu, and Map menu. They all can be extended with the application framework. The Application menu and GPS menu can be accessed from the application's current instance, MobileApplication.Current:

MobileApplication.Current.MenuItems.Insert(0, amenuItem);   // application menu
MobileApplication.Current.GpsMenuItems.Insert(0, amenuItem);  // application GPS menu

You might notice that MenuItems is a collection of Object, instead of MenuItem. This is because, with WPF, you have the flexibility to add different controls other than just a standard MenuItem.

The page menu located in the middle of the application navigation bar can be accessed from the MobileApplicationPage class's MenuItems property.

Map menu on the map control can be accessed from the MapControl class's MenuItems property. MapControl is, in turn, a property of a map page, for example, ViewMapPage.

ViewMapTask viewMapTask = (ViewMapTask)MobileApplication.Current.Project.Tasks.GetFirstExtensionOfType(typeof(ViewMapTask));
viewMapTask.ViewMapPage.MapControl.MenuItems.Insert(0,amenuitem);

Refer to the "Customizing menus" section and the samples for more details.

The Windows application has several feature list pages including View Worklist, View Updates, and Search Result. A feature list page has a feature list on the left; each feature has a menu that contains functions specific to this feature. This feature list menu can be accessed from BrowserFeaturesControl of the feature list page class, for example, for the View Work list page:

FeatureListBox featureListBox = workListTask.WorkListPage.BrowseFeaturesControl.FeatureList;
featureListBox.MenuItems.Add(aMenuItem);

Also, the application framework allows you to extend the feature list menu for all feature list pages and the map menu on pages with a map control. Refer to the "Customizing menus" section and the MenuCustomizationExtension and ApplicationMenuExtension samples for details.

Tasks

In the ArcGIS Mobile for Windows application, a task starts a workflow that guides you to finish the task step by step. The application framework exposes some extensible points in these steps where you could plug in your own business logic. For example, the Collect Features task, one of the most important and complicated tasks in the application, consists of a series of pages within its workflow and subworkflows. For collecting geometry, you can choose to collect with map, GPS averaging, or GPS streaming methods. For collecting attributes, the application has different pages or subworkflows for different feature types. The application framework provides the following extensible points where you can plug in your own business logic:

  • When feature collection begins and ends: You can plug in your function before or after collecting a feature.
  • When geometry collection begins and ends: You can plug in your function before or after collecting geometry.
  • Where to select a geometry collection method: You can add your own geometry collection method or remove an existing one.
  • GPS averaging/streaming page: You can add a custom command to the GPS data collection panel on the GPS averaging/streaming page to customize the averaging or streaming data collection workflow.
  • After a feature is collected: After a feature is collected, the application displays a page with actions to take: collect another feature, view the map, or go to the task list page. On this page, you can customize these available finish actions: either remove an existing action or add a new one.

For details about these extensible points, refer to the "Customizing Collect Feature task" section, and the CollectFeatureExtension sample. This section explains these extensible points in each task.

Application settings

The application Settings page lists settings for the application and current project. Each button on this page leads to a setting page. If you have some settings to manage for your task or extension, you can create a setting page and have it listed on this settings page.

First, you need to create a page derived from MobileApplicationPage, add UI controls for managing your settings, then add this page to the mobile application's SettingsPages property.

MobileApplication.Current.SettingsPages.Add(new MySettingPage());

Refer to the "Application settings" section and the SettingsExtension sample for details.

Application framework components

Pages

Within the Windows application, MobileApplicationPage is the base class for all pages. To add a new page in your workflow, you need to have the new page derived from MobileApplicationPage too, since it contains the Title, Note, and ImageSource properties that the application needs to display the page appropriately and the navigation commands as well.

To create a new page, you can manually add a WPF user control in a Visual Studio project; make it inherited from MobileApplicationPage; and specify its Title, Note, and ImageSource properties for page icons, buttons on the navigation bar, and so on. Refer to the walk-through tutorials for details. You can also use the provided Visual Studio MobileApplicationPage item template to generate an empty page. Refer to the "Visual Studio template for ArcGIS Mobile" section for details.

The buttons on the navigation bar are for navigating from the current page to another. BackCommand is a PageNavigationCommand associated to the Back or Cancel button on the left side of the navigation bar; when it is invoked, the application moves to the previous page. With the BackCommand collection, you could add more buttons to the left of the page menu. Similarly, OkCommand and ForwardCommand are for the buttons to the right of the page menu.

The application provides a help page for each page: HelpSource property defines a URI pointing to the HTML help page, which is located under the <installdir>\ArcGIS\Mobile10.0\Help\ContextHelp\ArcGISMobile folder.

public AboutThisProjectPage()
{
  InitializeComponent();

  // page title
  this.Title = "About this Project";
  // page note, under the title
  this.Note = "Information about this project";

  // specify ImageSource for the page icon
  Uri uri = new Uri(String.Format("pack://application:,,,/AppMenuExtension;Component/{0}", "Tips72.png"));
  this.ImageSource = new System.Windows.Media.Imaging.BitmapImage(uri);

  // add the back command button
  this.BackCommands.Add(this.BackCommand);

  // add a forward command: view map button
  PageNavigationCommand viewMapButton = new PageNavigationCommand(
        PageNavigationCommandType.Positive,   // a positive button in green
        "View Map",
        param => this.viewMapCommandExecute(),
        param => this.CanExecuteViewMapCommand
        );
   this.ForwardCommands.Add(viewMapButton);

}

// navigate to the previous page when click the back button
protected override void OnBackCommandExecute()
{
    MobileApplication.Current.Transition(this.PreviousPage);
}

// check if the viewmap forward button is enabled or not
protected virtual bool CanExecuteViewMapCommand
{
     get { return true; }
}

// navigate to map page when click the viewmap forward button
private void viewMapCommandExecute()
{
    MobileApplication.Current.Transition(new ESRI.ArcGIS.Mobile.Client.Tasks.ViewMap.ViewMapPage());
}

You may notice that on the navigation bar, buttons could have different colors. This color is assigned by specifying its PageNavigationCommandType:

  • PageNavigationCommandType.Default: A default command button, gray color with nighttime skin and white color with daytime skin
  • PageNavigationCommandType.Positive: A command button in green with some positive acknowledgment (for example, Accept, Approve, or Confirm)
  • PageNavigationCommandType.Negative: A command button in red with some negative acknowledgment(for example, Cancel, Deny)
  • PageNavigationCommandType.Highlighted: A command button in blue, with slightly more emphasis than a default command button

In some case, you might want to hide the page navigation bar. To do so, you need to implement the IPageFooter interface in your page class and return Visibility.Collapsed for the FooterVisibility. Keep in mind that you need to implement your own way for page navigation, since the Back and OK buttons are located on the page navigation bar. Refer to the Hello World task sample for more details.

Also, the application framework exposes pages and controls used in each workflow, for example, ViewMapPage, ChooseExtentPage, SearchResultPage, and BrowseFeaturesControl. Refer to the assembly API for all these pages since you might want to reuse them instead of creating your own page.

WPF UI Controls

UI controls in the Windows application are customized for finger touch access and can be skinned for day- or nighttime use. To keep the same user experience, you might want to reuse these WPF UI controls in your workflow. These customized WPF UI controls include Messagebox, Button, CheckBox, Slider, Combobox, TextBox, and Scrollbar. The application framework also provides a virtual keyboard you can reuse in your own pages. For more details on these WPF UI controls, refer to the "WPF UI components" section and samples.

Non-UI components

Besides these UI components, the application framework exposes some non-UI components, for example, in search workflow; Clause; and CauseConnector; and Condition, Search, SearchArea, and StringCondition for querying features.

Refer to the assembly API help for more details about these components.


9/20/2011