|
Applies to: Download sample Summary: The Pocket PC Today Screen is a great way to display summary information that''s easily viewed and readily accessible. By default, the Pocket PC automatically displays a summary of appointments, messages and tasks on the Today Screen. (17 printed pages) Introduction The Pocket PC Today Screen is a great way to display summary information that''s easily viewed and readily accessible. By default, the Pocket PC automatically displays a summary of appointments, messages and tasks on the Today Screen as shown in Figure 1. Tapping an item then launches the application associated with that item.
Figure 1. The Default Pocket PC Today Screen. The user convenience of the Today Screen makes it a valuable part of any application that needs to display summary data to the user and allow the user to easily access the application that manages the associated details. Unfortunately, the current Pocket PC API requires that Today Screen plug-ins be implemented as Windows DLLs with standard exported entry points. This requirement has historically made creating Today Screen plug-ins difficult as one has had to use Embedded Visual C++ (eVC). Creating Today Screen plug-ins with the .NET Compact Framework is not possible as .NET Compact Framework DLLs can only contain .NET components. They cannot expose standard Windows DLL entry points. The ".NETCF Today Screen Plug-in Host" overcomes this limitation. The Plug-in host is a combination of eVC components, .NET Compact Framework components, a .NET Compact Framework executable and a Visual Studio .NET custom project wizard. Together these pieces enable the creation of a custom Today Screen item by creating an initialization ("Init") .NET component to set the initial content of the Today Screen item and an executable ("Exec") application that can interact with the user and update the Today Screen content. The unmanaged plug-in hosts an HTML window allowing each project to specify the HTML content to appear in the Today Screen. The "Init" project is automatically loaded when the new item is first added to the Today screen. This component need only return the HTML that should initially be displayed in the Today Screen. When the Today Screen content for this item is tapped, the "Exec" project is launched providing a user interface for the user to interact with the associated information. This program can also update the displayed HTML. Using the Today Screen Plug-in Host To use the ".NETCF Today Screen Plug-in Host", you must download and install the sample. Once downloaded, you''ll need to build and install the support components and programs. All projects can be found in the Support sub-folder of the Plug-in host installation folder. For simplicity all of the eVC support projects are contained within a single workspace, TodayScreenSupport_UnManaged . The managed projects are contained within a single Visual Studio .NET solution, TodayScreenSupport_Managed. Building the Today Screen Plug-in Host Note The tasks must be performed in the order specified as there are some dependencies between the eVC and VS.NET projects. Desktop Installation To perform the installation, simply run the TodayScreenWizard.msi contained in the Support\TodayScreenSupport_Managed\TodayScreenWizard_Installer\Release sub folder. The installer will create a new folder structure with a default installation point of C:\Program Files\.NET CF Today Screen Support. TodayScreenWizard.msi installs the following files and folders. Note With the exception of "Custom Today Item.vsz", paths are relative to the newly created installation folder (by default "C:\Program Files\.NET CF Today Screen Support"). Once installed, Visual Studio .NET will contain a "CustomTodayItem" project type as shown in figure 2.
Figure 2. Custom Today Item project in Visual Studio .NET "New Project" dialog. Device Installation For Pocket PC devices, run the TodayScreenSupport.msi install contained in the Support\TodayScreenSupport_Managed\TodayScreenSupport_Installer\Release sub-folder. The installer automatically copies and installs the TodayScreenSupport.ARM.cab file onto the Pocket PC. The TodayScreenSupport.ARM.cab is contained in the Support\TodayScreenSupport_Managed\TodayScreenSupportCab\Release sub-folder. For emulator installations, copy the TodayScreenSupport.X86.cab file to the emulator and expand. The TodayScreenSupport .X86.cab file is located in the Support\TodayScreenSupport_Managed\TodayScreenSupportCab\Release sub-folder. The following files are installed onto the Pocket PC device (or emulator). File Description The Basics From Visual Studio .NET choose File / New / Project. To ease the process of building simple Today Screen items, the generated component automatically returns a basic HTML string. In these cases, you can simply modify the constant "ProgramDisplayText". The text contained in ProgramDisplayText will be displayed in the Today Screen and when tapped will automatically launch the corresponding "Exec" project. The "Exec" project is a Windows executable assembly (EXE) project. This program has no special requirements but will normally display details that correspond to the content in the Today Screen. If this program wishes to update the Today Screen content, it can call the UpdateTodayScreenInfo function (included in the generated class) passing the new HTML and desired Today Screen item height. Installing the Today Screen Plug-in Note The batch file only looks for the Release versions of the assemblies. If you wish to build the CAB using the Debug assemblies, modify the paths in the batch file as appropriate. Although, the installation has created the necessary registry entries, the Today Screen manager must be prodded to re-read the registry in order to be aware of the new content. For the new content to appear, do the following. On the device, tap "Start" Note Because the "Init" project is installed into the GAC, updates can''t be installed by simply copying a new DLL file but rather must be explicitly removed prior to installing the new DLL and GAC file. To remove the assembly use the CGACUTIL.exe program with the /uf option and the full assembly name (the full assembly name for each DLL can be found in the "InitType" entry of the [RegistryEntries] section of the project''s ".inf" file). For example to remove the foo_init assembly from the GAC execute the following command. For these more involved cases, the "Init" project can be modified to perform the necessary logic within the Html property to retrieve the associated content and return the HTML to display. By using HTML as the display format, the .NET Compact Framework Today Screen plug-in provides a rich and versatile content format. To support the launching of one or more support programs, the plug-in architecture uses the HTML anchor tag "<a href=''?>?lt;/a>". This tag allows the Today Screen item to have multiple "hot spots" that can each trigger the same or different programs. (Again, the included "TaskVision" example provides an example of this). These hot spots are identified by the "href" property of the anchor tag and can be any file or URL that the Pocket PC shell is capable of executing such as "exe" files, "htm" files, "pxl" files, etc. For example, to launch the program "\Program Files\My Prog\DisplayDetails.exe" when the user clicks on the word "Details" use the following HTML. <a href=''"\Program Files\My Prog\DisplayDetails.exe"''>Details</a> <a href=''"\Program Files\My Prog\DisplayDetails.exe" /TodayItem={0}''>Details</a> TaskVision Sample Note For details on the desktop/server TaskVision and the .NET Compact Framework Pocket TaskVision projects visit the TaskVision Sample Application Web site. The TaskVision_TodayScreen.sln solution contains the two required Today Screen plug-in projects, TaskVision_TodayScreen_Init and TaskVision_TodayScreen as well as a third project PocketVisionUtil. To build and install the TaskVision Today Screen sample do the following Verify that the steps outlined in the "Device Installation" section of "Installing the Plug-in Host Components" have been completed On the device, tap "Start"
Figure 3. The TaskVision Today Screen The TaskVision Initialization Project public string Html <H3>Task View: <a href=''"\Program Files\TaskVision_TodayScreen\TaskVision_TodayScreen.exe" /TodayItem=TaskVision_TodayScreen''>Acme</a></H3> Note This sample uses the PocketVision program as it was originally released which doesn''t support command line arguments or any other mechanism for passing information. The PocketVision sample could be easily modified to accept some identifying information for the individual task. With this modification, the HTML could be modified to pass the task identifier enabling the PocketVision program to automatically show the details for the selected task.
Figure 4. The TaskVision_TodayScreen program The Task View Execution Project Once the user has made the selection and taps "Apply", the Web service is called, the data is gathered and again formatted by the TaskVisionHtmlHelper.BuildTaskHtml function. Unlike the "Init" component which need only return the desired HTML through the Html property, the "Exec" project must explicitly set the new HTML and height using the UpdateTodayScreenInfo method. The "Apply" button click handler is shown here. private void btnApply_Click(object sender, System.EventArgs e) // Use the PocketVisionUtil classes to gather the data // Format and update the HTML The PocketVisionUtil Project The one thing of note is that because the PocketVisionUtil assembly is used by the TaskVision_TodayScreen_Init assembly which is installed into the GAC, the PocketVisionUtil assembly must also be installed into the GAC. This is a good idea anyway as it is used to by both the TaskVision_TodayScreen_Init and TaskVision_TodayScreen projects. To install the PocketVisionUtil assembly into the GAC, the TaskVision_TodayScreen_Init.gac file has been modified to include both the TaskVision_TodayScreen_Init and PocketVisionUtil assemblies as shown here. \Windows\TaskVision_TodayScreen_Init.dll Components When the Today Screen item is first activated, the Today Screen Plug-in launches the .NET Compact Framework TodayScreenHost.exe executable passing the name of the class and assembly to load which can provide the initial HTML content. The specified class must implement the ITodayScreenDataProvider interface and will normally be the "Init" project created by the Custom Today Item project wizard. The TodayScreenHost program simply loads and creates the specified class reading the Html and Height properties. It then passes the information back to TodayScreenPlugin_NETCFHost.dll. As noted earlier, there are no specific requirements on the format or structure of the HTML although it will normally contain an anchor tag ("<a>") referencing the "Exec" project created by the Custom Today Screen project wizard. When the anchor is tapped, the "Exec" project is launched. The "Exec" project will normally either display the details behind the Today Screen entry or provide options for changing the displayed content. The "Exec" program then uses the contained UpdateTodayScreenInfo method to update the HTML displayed by the TodayScreenPlugin_NETCFHost. Configuration HKLM\Software\Microsoft\Today\Items\TaskVision_TodayScreen HKLM\Software\Microsoft\Today\Items\TaskVision_TodayScreen\ManagedExtension Name Type Description The TodayScreenDataMgr_NETCFHost component displays the HTML content but relies on the .NET Compact Framework portions of the system, which are running in a different process space, to determine the HTML. To make communication between the managed and unmanaged processes as efficient as possible, the system communicates through shared memory using a memory-mapped file. The eVC DLL TodayScreenDataMgr manages the memory-mapped file details. The .NET Compact Framework DLL TodayScreenData provides a .NET Compact Framework friendly layer over TodayScreenDataMgr. The individual components are shielded from the details of communications. In the case of the "Init" project, the component need only return the desired HTML and height through the respective properties. The TodayScreenHost application handles the details of extracting the values from the properties and passing them to the memory-mapped file. In the case of the "Exec" project, the memory details are encapsulated in the UpdateTodayScreenInfo function. The communications architecture is shown in Figure 5.
Figure 5. Communications Architecture Project Wizard As part of the project creation, the wizard dynamically generates a strong name file and a ".gac" file to install the "Init" project in the GAC. It also dynamically builds the ".inf" file and a BuildCab.bat batch file to simplify the creation of CAB files for the new project. As part of the ".inf" file creation the system has to determine the fully qualified assembly name for the "Init" assembly which includes determining the Public Key Token for the strong name file. This requires executing the SN.exe program and dynamically extracting the screen output. The details are contained in the GetPublicKeyToken function. Conclusion Once installed, the system not only makes creating custom Today Screen extension in the .NET Compact Framework possible, it is now easier then ever before in any environment. If you can run a Visual Studio .NET wizard, you can now create a Today Screen extension.
|