Using ArcGIS Mobile Visual Studio project templates

Complexity: Beginner Data Requirement: Installed with software

This section describes how to use Visual Studio project templates to develop a task and project extension and deploy them using Mobile Project Center.

ArcGIS Mobile ships with two Visual Studio 2008 C# project templates to help you create Visual Studio projects for building a Windows application task or project extension. These templates are integrated with Visual Studio 2008 and can be used just as the Visual Studio built-in project templates. A project created based on the template contains classes for your task or project extension, assembly reference, and project properties.

During this walk-through, you will be guided to

Where to get the samples

Download the HelloWorldTask sample.

Download the AppMenuExtension sample.

Prerequisites

To complete this walk-through, you need the following:

Creating an ArcGIS Mobile application task using Visual Studio project template

In this tutorial, you will be guided to create a Hello World task. The Hello World task appears as a menu item on the View Map page menu. Tap this task menu item, and the application starts the Hello World task workflow and navigates to another page.

Steps:
  1. Start Visual Studio .NET 2008 and click File > New > Project.
  2. Click ArcGIS Mobile under Visual C# in the Project types pane on the New Project dialog box.
  3. Choose .NET Framework 3.5 from the drop-down list at the top right of the dialog box.
  4. Choose Task in the Templates pane.
  5. Name the project HelloWorldTask, specify the location for the project, then click OK.

  6. Visual Studio creates three projects in the solution using this template: one for the Windows application, one for the Windows Mobile application, and one for Mobile Project Center.

    • The Windows and Windows Mobile projects are for developing task assemblies used with the Windows application and Windows Mobile application. Since you do not need the Windows Mobile project, you can delete it from the solution.
    • The Project Center project is for developing an assembly for describing the application's HelloWorldTask assembly. Mobile Project Center needs it to deploy the Hello World task to mobile projects.

  7. In the HelloWorldTask_Win project, rename the name space, task class name, and assembly name.
    1. Open the HelloWorldTask_Win.cs file, right-click the name space CustomArcGISMobileTask. Choose Refactor > Rename. Rename it to CustomizationSamples.
    2. Refactor the task class name from HelloWorldTask_Win to HelloWorldTask in the same way.
    3. Right-click the HelloWorldTask_Win project. Click Properties to open the project Properties dialog box. From the Application tab, change the assembly name to HelloWorldTask.
  8. Look at this HelloWorldTask_Win project. It contains a HelloWorldTask class derived from Task. Task is the base class for all tasks within the ArcGIS Mobile for Windows application. In the constructor, it defines task name and description. Change its name to Hello World Task.

    This HelloWorldTask class also has a function called Execute(), which is called when the Hello World task is launched in the application. Implement this function to navigate the application to another page.

    MobileApplication.Current.Transition(new Page1());

    Page1 is an empty Mobile Application page created from the Task project template.

    Now the HelloWorldTask_Win.cs file looks like this:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ESRI.ArcGIS.Mobile;
    using ESRI.ArcGIS.Mobile.Client;
    namespace CustomizationSamples
    {
      public class HelloWorldTask : Task
      {
         public HelloWorldTask()
        {
          //Name
           Name = "Task Name";
          //Description
          Description = "Task description";
         }
      
         // task icon,
         protected override System.Windows.Media.ImageSource GetImageSource()
        {
           Uri uri = new Uri("pack://application:,,,/HelloWorldTask;Component/TaskIcon72.png");
           return new System.Windows.Media.Imaging.BitmapImage(uri);
         }
        
         public override void Execute()
        { 
           MobileApplication.Current.Transition(new Page1());
         }
       }
    }

  9. Add a button to the empty Page1 by opening the Page1.xaml file and adding a button within the grid as below:

    <MobileClient:MobileApplicationPage
        x:Class="HelloWorldTask.Page1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:MobileClient="clr-namespace:ESRI.ArcGIS.Mobile.Client;assembly=ESRI.ArcGIS.Mobile.Client"
        >
        <Grid>
            <Button Height="100" Width="200" Name="button1" >Hello again</Button>
        </Grid>
    </MobileClient:MobileApplicationPage>

  10. Now, this simple Hello World task is done, compile it to make HelloWorldTask.dll.
  11. To deploy this Hello World task to a mobile project using Mobile Project Center, make a Mobile Project Center assembly.
    1. Open the HelloWorldTask_ProjectCenter.xaml.cs file, as you did for the HelloWorkTask_Win project. Rename its name space CustomizationSamples and rename the class name to HelloWorldTask using the Refactor tool.
    2. In the project's Properties dialog box, on the Application tab, change the assembly name to HelloWorldTask.
    3. From the Build tab, change the output path to <InstallDir>\ArcGIS\Mobile10.0\bin\Extensions. Mobile installer does not create this folder; you need to manually create the Extensions folder here.
    4. Compile the Mobile Project Center project.
  12. Add the Hello World task to a mobile project using Mobile Project Center.
    1. Launch Mobile Project Center and create a new project, or open an existing project.
    2. Click the Tasks tab and click Add. You see the Hello World task listed here. Add it to the project and save the project.

  13. Try the Hello World task in the Windows application.

    In step 11, you compiled HelloWorldTask.dll for the Windows application. To have the application find and load this assembly, copy the assembly to either the application bin folder or application Extensions folder.

    • Location 1: <Install Dir>\ArcGIS\Mobile10.0\bin
    • Location 2: C:\Documents and Settings\All Users\Application Data\ESRI\ArcGIS Mobile\Extensions\ (for Windows XP) or C:ProgramData\ESRI\ArcGIS Mobile\Extensions\ (for Windows Vista or 7)

    NoteNote:

    The mobile installer does not create the Extensions folder; you need to manually create it.

    Launch the ArcGIS Mobile for Windows application and open the project you just created. You see Hello World task is added to the View Map page menu.

    Click Hello World Task and the application navigates to Hello World Page.

Creating an ArcGIS Mobile application project extension using Visual Studio project template

In this tutorial, you will be guided to create a project extension for the Windows application. This project extension adds an About this project menu item to the application menu, which navigates to another page for information about the current project.

Steps:
  1. Start Visual Studio .NET 2008 and click File > New > Project.
  2. Click ArcGIS Mobile under Visual C# in the Project types pane on the New Project dialog box.
  3. Choose .NET Framework 3.5 from the drop-down list at the top right of the dialog box.
  4. Choose Extension in the Templates pane.
  5. Name the project AppMenuExtension, specify the location for the project, then click OK.
  6. The template creates three projects in the solution: one for Windows application, one for Windows Mobile application, and one for Mobile Project Center.

    The Windows and Windows Mobile projects are for developing project extension assemblies used with the Windows application and Windows Mobile application. Since you do not need the Windows Mobile project, you can delete it from the solution.

    The Project Center project is for developing an assembly for describing the application's AppMenuExtension assembly. Mobile Project Center needs it to deploy the App Menu extension to mobile projects.

  7. Modify the AppMenuExtension_Win project.
    1. Open the AppMenuExtension_Win.cs file. Refactor its name space to CustomizationSamples and refactor the class name to AppMenuExtension. Change the assembly name to AppMenuExtension from the project properties dialog box. Then modify this class as described in the project extension walk-through.
    2. Compile the project to build the AppMenuExtension.dll assembly and deploy it to the mobile bin folder or Extensions folder, as you did for the HelloWorldTask assembly.
  8. Modify the AppMenuExtension_ProjectCenter project.
    1. Open the AppMenuExtension_ProjectCenter.xaml.cs file. Refactor its name space to CustomizationSamples and refactor the class name to AppMenuExtension.
    2. In the project properties dialog box, from the Application tab, change the assembly name to AppMenuExtension.
    3. From the Build tab, change the output path to <InstallDir>\ArcGIS\Mobile10.0\bin\Extensions. Mobile installer does not create this folder; you need to manually create the Extensions folder here.
    4. Compile the Mobile Project Center project.
  9. Add the App Menu extension to a mobile project using Mobile Project Center.
    1. Launch Mobile Project Center and create a new project, or open an existing project.
    2. Click Add on the Capabilities tab. You see the App Menu extension listed here. Add it to the project and save the project.
  10. Launch the ArcGIS Mobile for Windows application and open the project. You see the About this project menu item inserted on the application menu.

9/20/2011