Using the Windows application framework overview
The Windows application framework provides you with the capability to extend or customize the ArcGIS for Windows application. You can either create tasks to implement your own workflow or extend or customize existing tasks, extensions, and 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 learn about the Windows application framework, explain how to leverage these extensible or customizable points within the application, and describe how to use application framework components to quickly implement new functionality.
Windows application customizable or extensible points
Menus
The Windows application has the following five menus:
- Application
- GPS
- Page
- Feature List
- Map
MobileApplication.Current.MenuItems.Insert(0, amenuItem); // application menu
MobileApplication.Current.GpsMenuItems.Insert(0, amenuItem); // application GPS menu
MenuItems is a collection of Object, not MenuItem. This is because, with Windows Presentation Foundation (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' MenuItems property.
The Map menu on the map control can be accessed from the MapControl class' 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);
See the Customizing menus topics 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. See the Customizing menus topics and the MenuCustomizationExtension and ApplicationMenuExtension samples for details.
Tasks
In the ArcGIS Mobile for Windows application, a task starts a workflow that guides a user through the task step by step. The application framework exposes some extensible points in these steps where you can 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 collect with map or Global Positioning System (GPS) 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—Plug in your function before or after collecting a feature.
- When geometry collection begins and ends—Plug in your function before or after collecting geometry.
- 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, see 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 user interface (UI) controls for managing your settings, then add this page to the mobile application's SettingsPages property:
MobileApplication.Current.SettingsPages.Add(new MySettingPage());
See the Application settings topics 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, which 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. See the walkthrough tutorials for details. You can also use the provided Visual Studio MobileApplicationPage item template to generate an empty page. See 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 with the Back or Cancel button on the left side of the navigation bar; when it's invoked, the application moves to the previous page. With the BackCommand collection, you can add additional 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 uniform resource identifier (URI) pointing to the Hypertext Markup Language (HTML) help page, which is located under the <installdir>\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());
}
Buttons on the navigation bar can have different colors. The color is assigned by specifying its PageNavigationCommandType:
- PageNavigationCommandType.Default—Default command button, gray color with nighttime skin and white color with daytime skin.
- PageNavigationCommandType.Positive—Command button in green with some positive acknowledgment (for example, Accept, Approve, or Confirm).
- PageNavigationCommandType.Negative—Command button in red with some negative acknowledgment (for example, Cancel, Deny).
- PageNavigationCommandType.Highlighted—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, implement the IPageFooter interface in your page class and return Visibility.Collapsed for the FooterVisibility. You need to implement your own procedure for page navigation, since the Back and OK buttons are located on the page navigation bar. See the Hello World task sample for more details.
The application framework exposes pages and controls used in each workflow, for example, ViewMapPage, ChooseExtentPage, SearchResultPage, and BrowseFeaturesControl. See the assembly application programming interface (API) for these pages if you 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 can 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, see the WPF UI components topic and samples.
Non-UI components
Besides the 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.
See the assembly API help for more details about these components.