Creating your first custom task

Complexity: Beginner Data Requirement: Installed with software

Introduction

ArcGIS Mobile provides a framework for the out-of-box hand-held application. It allows developers to customize the application by extending existing functions or implementing new functions that embed new business logic. In this walkthrough, you'll learn how to create a simple task for the out-of-box mobile application. Specifically, you'll learn how to add a new task to the SelectTaskPage with a name and description. When the task is tapped, the application will navigate users to a new page. The new page will have a customized look and feel. By using a built-in menu item, your user can go back to SelectTaskPage.

Prerequisites

It would be helpful if you understand the task-based, workflow-driven design of the application before you start extending it. You may also find it useful to take a quick look at the Overview of the Application Framework to get an idea about the architecture of the application framework for the Windows Mobile platform.

To follow this walkthrough, you should have basic knowledge of how to use templates and development of Windows Mobile 5 or 6 applications.

Requirements

To complete this walkthrough, you need to have a development machine and a mobile device (or emulator) running the Windows Mobile 5 or 6 operating system. To learn more about setting up your development machine and mobile device or emulator, see GettingStarted_DevelopmentEnvironment.

Creating an ArcGIS Mobile task using the template

To help you get started with customizing the ArcGIS Mobile application, project templates and item templates (C# only) are included. These templates are installed by the ArcGIS Mobile setup and configured to work seamlessly with Visual Studio 2008.

To verify that the templates have been installed correctly, start Visual Studio and go to File > New > Project.

In the Project types: list box, there is a new project type, ArcGIS Mobile, under the Visual C# category, and on the right panel, there are two project templates available, one for task and the other for extension.

The following steps demonstrate the best practice for creating a task project using the ArcGIS Mobile task template:

Steps:
  1. Choose ArcGIS Mobile Task from the right panel.
  2. Check the Create directory for solution check box.
  3. Ensure that >NET Framework 3.5 is selected in the combo box at the top, and provide a name and location for your project. In this example, it's named MyCustomTask.

    New project menu for selecting a template

  4. Click OK .

    The template creates three projects. The project name you provide in step 3 is used as the solution name for all three projects but with different suffixes:

    • MyCustomTask_Win contains all necessary files for a task on the Windows platform.
    • MyCustomTask_WM contains files for the Windows Mobile platform.
    • MyCustomTask_ProjectCenter contains all files for the Mobile Project Center (MPC).

    If you change one of these project names at any point during development, you must ensure they all change to integrate properly.

    Three projects created using the project template

  5. Compile the solution to ensure correct setup.

    Before modifying any of the code, test the template usage by compiling the solution. All of the projects within the solution should compile with no errors. If there are errors, fix them before changing the code.

  6. In the MyCustomTask_ProjectCenter.xaml.cs file, update m_displayName as desired.

    Update m_displayName

  7. In the MyCustomTask_ProjectCenter.xaml.cs file, check the URI for the Icon property.

    Change the URI

  8. In the MyCustomTask_ProjectCenter.xaml file, update the form to have a label and text box for the attributes of the task.

    This code should be added to the code for the ProjectCenter xml, to allow the attributes to be shown edited in the MPC.

    <Grid Height="490" Width="860" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
        <Label Height="28" HorizontalAlignment="Left" Margin="24,12,0,0" Name="label1" VerticalAlignment="Top" Width="62" Foreground="Gray">Name:</Label>
        <Label Height="28" HorizontalAlignment="Left" Margin="24,62,0,0" Name="label2" VerticalAlignment="Top" Width="87" Foreground="Gray">Description:</Label>
        <TextBox  Margin="29,33.32,30,0" Name="NameTextBox" VerticalAlignment="Top"
                  Text="{Binding DisplayName}"/>
        <TextBox  Margin="29,85.5,30,0" Name="DescriptionTextBox" VerticalAlignment="Top"
                  Text="{Binding Description}"/>
    
      </Grid>
    

  9. Update the solution with any additional changes that you require.

    Refer to the comments, especially those with // TODO notes.

    NoteNote:

    The Task template navigates you to an empty page when the task is executed. You can modify this page as necessary to fit the project requirements.

  10. Compile the solution to ensure your changes were entered correctly.
  11. Make your task usable to the MPC.

    For your custom task to be incorporated into a mobile project and deployed to a Windows Mobile device to be used in the application, the compiled code must be moved to the proper MPC system folders.

    1. Copy the MPC task:

      Copy ..\MyCustomTask\MyCustomTask_ProjectCenter\obj\Debug\MyCustomTask.dll

      to

      C:\ProgramData\ESRI\MobileProjectCenter\Extensions\

    2. Copy the Windows Mobile task:

      Copy ..\MyCustomTask\MyCustomTask_WM\obj\Debug\MyCustomTask.dll

      to

      C:\ProgramData\ESRI\MobileProjectCenter\Extensions\WinCE\

  12. Open the MPC, and add your task extension to a mobile project.

    Select the Task Item in the left hand list of the MPC, then click the Add button at the top of the list. Select your custom task from the popup list to add it to your project.

    Add the task to the MPC

  13. Share your mobile project so that it can be accessed from a mobile device.

    Under the File menu, select the Share item to share this project to a server where it can be transferred to a mobile device.

    The project will need to have data before it can be downloaded to the Mobile Application

  14. Download the shared project onto a Windows Mobile device or emulator.

    Open the ArcGIS for Windows Mobile Application and use the download project menu item to access your shared project.

    The new task is listed on the Task List page

  15. Review your custom task, and determine how to incorporate your requirements.

    Clicking the task opens a blank page, which has the default menu options.

    The task page

1/7/2015