While this week has very much been focussed on Windows Phone 7 so far we also released the latest version of our Mobile In The Hand suite for the .NET Compact Framework. Along with some bug-fixes (several around EmailMessage functionality) and performance improvements there are a lot of new features in this release. These include:-
- Compatibility – We have gone through the entire library and documented which platform versions support which features in a similar way to the MSDN documentation for the underlying APIs. We have also added in more platform checks and workarounds so we are now able to support a much wider range of devices. Pocket PC 2003, Windows Mobile 5.0, Windows Mobile 6, Windows Mobile 6.1, Windows Mobile 6.5, Windows Mobile 6.5.3, Windows CE.NET 4.1, Windows CE 5.0, Windows Embedded CE 6, you get the idea! Basically any device which supports .NET Compact Framework 2.0 or later will be able to use most of the functionality in the suite.
- Better support for .NETCF 3.5 – By adding IEnumerable<T> interfaces to our collection classes you can write slightly simpler LINQ statements. Also we have implemented many features as Extension Methods. These can be used in either .NETCF 2.0 or 3.5 so long as you are using Visual Studio 2008 (The compiler in VS2005 doesn’t support these so you have to call them as static methods).
- New InTheHand.Device.Location.dll library – This is modelled on the .NET 4.0 library and just this week it has been shown that Windows Phone 7 gets a version of the same library. By adding this support we’ve been able to completely re-design our GPS support and you can now write code with the same familiar object model on Windows 7, Windows Phone 7 and Windows Mobile and Windows Embedded CE. In the Evaluation version this shipped as InTheHand.Device.dll but for the full release we changed it to InTheHand.Device.Location.dll to match the Windows Phone 7 name, the namespaces and classes within the assembly are unchanged.
- New InTheHand.Net.dll library – Previously this was released as a separate product but this now joins the suite and has had a number of new features including asynchronous versions of the WebClient methods, support for SMTP email sending, Remote Access (RAS) and some more classes in the NetworkInformation namespace. By integrating with the suite we have been able to share more functionality so for example our Visual Basic “My” extensions now have additional networking methods that are present in the full .NET framework.
- InTheHand.WindowsMobile.Forms.ControlHelper.EnableVisualStyles – This extension method allows you to reskin all the supported controls on Windows Mobile 6.5.3 with their new themed versions.
- InTheHand.WindowsMobile.Forms.Widget – On Windows Mobile 6.5 and later you can interrogate the widgets installed on the device. You can programmatically launch or uninstall Widgets too. There is a new sample application which shows a simple widget manager application.
For more information about Mobile In The Hand see the product page.
There are a number of scenarios in which you want to retrieve the icon associated with a particular executable or other file type. One example is when building a file browser, you might also want to extract the icon associated with your application or another. The full .NET framework contains Icon.ExtractAssociatedIcon() for this very purpose. Mobile In The Hand includes a helper function to achieve the same result from the Compact Framework. Simply use the following code:-
filePath is the full path to any file. The icon will either be the icon associated with a particular file type or in the case of executables will be the embedded application icon (or a generic application icon if not present). The result is a regular System.Drawing.Icon type which you can draw using the Graphics class normally.
One of the new items introduced in version 4.0 is a wrapper for the Email configuration provider. This provides a one-stop-shop to access and modify email account settings. This is used for all email account types except for Exchange synchronisation. Each account is identified by a unique Guid so to work with account settings you’ll need to know this. This is exposed through a property of the EmailAccount object, for example the following code loops through all available EmailAccounts for which there is a unique ID (excludes the Exchange account).
foreach (EmailAccount ea in os.EmailAccounts)
if (ea.Properties[AccountProperty.UniqueStoreID] != null)
The UniqueStoreID is a Guid property and so can be cast to the Guid type (the Properties collection returns items of type object because it caters for all different types of properties).
Guid g = (Guid)ea.Properties[AccountProperty.UniqueStoreID];
The EmailAccountConfiguration class is located in InTheHand.WindowsMobile.Configuration.dll in the InTheHand.WindowsMobile.Configuration.Providers namespace. A new instance is created by passing the Guid into the constructor:-
InTheHand.WindowsMobile.Configuration.Providers.EmailAccountConfiguration eac = new InTheHand.WindowsMobile.Configuration.Providers.EmailAccountConfiguration(g);
Once created you have access to a number of properties which describe the account, you can change any of these and push your changes by calling the Update() method. Properties available include the incoming and outgoing servers, the ServiceType – either “POP3” or “IMAP4”, DownloadDays (number of past days to download) and many more. The documentation for the class is available in the online library. For more information about Mobile In The Hand see the product page.
In Mobile In The Hand 4.0 all the Windows Mobile networking features are found in the InTheHand.WindowsMobile.Net assembly. This contains support for Connection Manager, Internet Sharing and Wireless Manager. This post will look at the Internet Sharing classes. Internet Sharing was introduced in Windows Mobile 5.0 AKU 3 but is generally associated with Windows Mobile 6. You can share an internet connection over a USB connection or over Bluetooth using the PAN (Personal Area Network) profile. To enable or disable a sharing session from your code you need only call a single method which looks like this:-
The first argument is a member of the SharingConnection enumeration which contains values for Bluetooth and Usb. The second argument is the name of the internet connection to use – this is the name of the GPRS connection which will be dialled. A simple Disable method exists to shut down the sharing connection:-
You must remember to disable the connection once you have finished using it.
In the last post on “My” functionality I showed you how to get started adding the My Extensions to your project. In this post I have assembled a detailed tree of all the “My” functionality added in Mobile In The Hand 4.0.
One of the goals of the Mobile In The Hand library has always been to provide a consistent managed API regardless of which specific flavour of Windows Mobile device you are using. One example of this is using the Vibration feature used to alert the user. The APIs are completely different and so we have provided a simple managed API composing of just two static methods:-
You generally won’t want to vibrate the device for very long because it would be both annoying, and a battery drain. To avoid holding up your UI thread you can call the methods on a separate thread. Just remember you must call Stop() to turn off the vibration.
Another example of functionality which is implemented differently between touchscreen and non-touchscreen devices are Profiles. Standard Edition devices can feature a number of profiles for different scenarios, touch screen devices have just three – On, Vibrate only and Off. To retrieve all of the available profiles use the following code:-
foreach(string profile in InTheHand.WindowsMobile.Forms.MobileDevice.Profiles)
You can set the device profile using a call to SetProfile:-
The name of the currently selected profile is available from the CurrentProfile property:-