software you can take with you

Peter Foot

Microsoft Windows Phone Development MVP
  • Moving from WinForms to XAML Runtime on Windows Embedded Compact

    I recently found an old set of slides I created for TechEd NZ a few years ago which collected together useful information for moving from Windows Mobile to Windows Phone. It struck me that some of this would also be useful for the Embedded XAML Runtime when considering moving code from a traditional WinForms UI to a XAML based UI using Xaml In The Hand. I've modified the table listing controls in both UI worlds and added it to the Knowledge Base here:-

    http://inthehand.uservoice.com/knowledgebase/articles/209986-winforms-versus-xaml-runtime-controls

    While most of this still applies to Windows Phone (and with a few further changes Windows Store apps) there are items here which are specific to Windows Embedded Compact - The ComboBox control which doesn't exist on Phone (although there is a perfectly good alternative), and the MediaElement and WebBrowser controls which don't exist in the XAML Runtime but for which we have created managed code controls which expose the same XAML and C# interfaces.

  • NFC Text tags on WinRT

    To follow the last post I thought I would quickly round it off by looking at the code required to listen for tags on a Windows 8/RT device. Devices with NFC built in are like hens teeth but one such RT device exists in the Asus VivoTab RT. Because it's an RT device that means running the Remote Debugger and doing the development on a separate Windows 8 PC. The problem with the Windows 8/RT experience is it is not as set in stone as Windows Phone and so issues like this occur (http://social.msdn.microsoft.com/Forums/en-US/tailoringappsfordevices/thread/9da68387-e0cb-4e02-ac71-bad61f6ff7c6) where some devices don't correctly advertise support for all tag types. The good news with the Asus is that it does support subscribing to NDEF messages and you can use the same code as in my previous Windows Phone example to read a Text tag. The same Ndef library is used as this supports both Windows 8/RT and Windows Phone 8.

    One thing which is a little frustrating when remote debugging is that you have to register for a developer license on the tablet before the debug session will continue. So even though you have a license on your development machine you also need one on the tablet (despite the fact you can't actually compile an app on it). There doesn't seem to be a limit to how many devices you can register for a license using your Microsoft ID so this shouldn't become a problem. You will find that you have to renew it regularly though...

    In a future post we will delve into other tag types...

  • NFC - Simple text tags on Windows Phone

    This article follows on from the last post on NFC to dig a little deeper on Windows Phone and Windows 8 (both of which share the same APIs for NFC).

    Requirement or just Capability

    In Windows Phone you have to add the ID_CAP_PROXIMITY capability to your app to use NFC. What about the ID_REQ_NFC requirement? Well the difference here is that when you specify a requirement the app will only be made available to devices with that feature. Whether you use the requirement therefore depends on whether NFC is core to your application or is an optional feature. This means it is valid to submit an app with NFC capabilities to devices which don't have the hardware. Therefore you must always check first if

    ProximityDevice.GetDefault() == null

    Types of NFC Message

    So you've got as far as calling the SubscribeForMessage API to listen for NFC messages, if you check the help file for this function you'll see it refers to the partner method "PublishBinaryMessage" to document the message types supported. Then you look down the list of supported protocols and your heart sinks! It's a long list and there seems to be a lot of duplication - why when we have the NDEF standards are there Windows versions too? Which ones can I use across different platforms? Not to mention the fact that you can't subscribe to all of these message types on Windows Phone so the utopia of a shared NFC API across both Windows APIs is shattered.

    The good news is that the Windows message types are actually helpers over the top of NDEF types and are designed to simplify reading those message types, we'll look into those on Windows 8/RT at a later stage. There is a very good NDEF library on CodePlex (and NuGet) to parse standard NDEF records. For example the way to read a plain text NDEF.Text message is actually using the NDEF message type because the API doesn't provide a subtype specifically for Text tags. When the tag is tapped you'll receive a message payload which you can parse with the NdefLibrary.Ndef.NdefMessage class.

    private void MessageReceived(ProximityDevice device, ProximityMessage message) 
    {
    NdefLibrary.Ndef.NdefMessage.FromByteArray(message.Data.ToArray());
    
    string s = System.Text.Encoding.UTF8.GetString(msg[0].Payload, 0, msg[0].Payload.Length).Substring(2);
    }
    

    The final thing you'll notice from the received text is that it contains the two-character language code at the beginning. Note that there is no error checking in the above sample and it assumes that the text tag is the first record in the message. You can see from the NdefMessage class that it contains a collection of records which can be of a number of specific types. More to follow as we delve deeper...

  • Cross Platform NFC

    NFC support in Windows Phone provides an exciting new way to add interactivity to apps and games. This series of posts will look at the state of NFC across the Windows and Android platforms. There are a number of standard Tag types defined by the NDEF format, for the sake of simplicity we’ll ignore the fact that Android can read other tag types and just concentrate on NDEF as it provides the best interoperability. Representing Windows Phone 8 I’m using the Nokia Lumia 920 although the 820 Developer phone provides the same experience. Representing Windows 8/RT is the Asus VivoTab RT which is one of few tablets with NFC support built in. Representing Android is the Samsung Galaxy S3. Since I’m less familiar with Android there is a possibility that some of the functionality I have discovered is Samsung specific and not part of the core Android OS.

    Sending

    The first table here shows the formats for which sending is supported within the platform. I haven’t included app links as these are platform specific. I was disappointed to find that out of the box the Windows tablet has no capability to share items over NFC from the built in apps. The send behaviour on Android is very seamless – tap the device against another and if the current app can share the screen changes slightly and you tap to share the current item. On Windows Phone you have to go through a few layers of menu first before being prompted to tap a device.

     

     

    Windows Phone

    Windows 8/RT

    Android 4.1

    Uri

    Yes

    Requires 3rd Party App

    Yes

    Mime (vCard)

    Yes

    Requires 3rd Party App

    Yes

    Text

    No

    No

    No

     

    Receiving

    The platforms can receive over NFC so long as the device is not pin locked. The following list shows what types of data (or pre-written tags) you can read on these devices without any specific third-party apps running.

     

    Windows Phone

    Windows 8/RT

    Android 4.1

    Uri

    Yes

    Yes

    Yes

    Mime (vCard)

    Yes

    Yes

    Yes

    Text

    No

    No

    Yes

     

    So from a very high level the three platforms support the basic tag types for Uris and Contacts across the board. Although Android has default behaviour when receiving a Text tag it just displays the text on screen – there is no functionality to do anything with the text. In a future investigation I’ll look into the tag types in more detail. The Uri tag for example is very powerful because you can register custom Uri schemes for your app so that a Uri tag could provide a deep link into your application. The systems maintain support for well-defined Uri schemas like http, tel and sms for example. There are additional platform specific ones on Windows Phone for launching items such as Wifi and Bluetooth Settings pages.

  • Use Team Foundation Service for Embedded Projects

    Microsoft's hosted TFS (http://tfs.visualstudio.com/) provides a cloud hosted TFS project collection which is free for small teams. It works neatly with VS2012 which is fine for Windows Store and Windows Phone project types but for .NET Compact Framework development we are still stuck with using Visual Studio 2008. Luckily with a few patches it is possible to connect to a Team Foundation Service collection from Visual Studio 2008. I recently had to rebuild my Windows 8 desktop machine so for reference thought I would blog the instructions for setting this up. You'll need to install the items in the following order:-

    No before you ask I didn't make up the name of that last one, I actually shortened it for you :-)

    To open a project from the server open your shiny up-to-date VS2008 IDE and go to File > Source Control > Open from Source Control. You'll get a blank dialog with a drop down box for servers and an empty list of projects. Select the Servers... button and then click Add..

    You'll notice that after these updates the dialog allows you to enter a fully formed Url for the server and will grey out the connection details below. You must specify https and include the DefaultCollection indicator, this Uri will always be of the form <yourchosenname>.visualstudio.com. When you click okay VS2008 will connect to the service and then prompt you to authenticate with your Microsoft ID. Once this is successful you'll see the following:-

     

    It will show you the display name of the account you are logged in as at the bottom left (not on this shot) and a Sign Out option. Things get a little complicated if you regularly use different Microsoft IDs because you can get into a situation where VS2008 shows error messages from the service but doesn't show what account it thinks you are logged in as or give the option to log out and back in with different credentials. Still haven't found a neat way around this yet other than making sure you log out from your Microsoft ID in your browser and possibly also the browser within the VS shell. It seems to be a cookie issue and possibly compounded if you use a Windows 8 account signing in with your Microsoft ID. If you've successfully got to this step you can select a project, assign a local path and work as you would with a local TFS back end. As well as the source control the work items sync back and forth with the web front end. I don't think there is any capability to use the "Preview" build services for Embedded projects and doubt if this functionality will be added.

  • Launching PDF Documents

    In Windows Phone 8 the Windows.System.Launcher class allows you to open files with apps which are registered to handle them. On Windows Phone you have built in support for Office documents and audio and video formats. Lets say you want to open a PDF either remotely or downloaded by your app. There isn't a built-in PDF viewer but there are several available including free readers by both Microsoft and Adobe. If your user doesn't already have one installed there are some extra steps. The first thing that happens is that the user is prompted like so:-

    If the user taps yes the phone will display a store search for apps which are associated with the file type:-

     

    Not sure why Adobe Reader isn't in this list and why it looks like the last entry is a game :-) but at least the top couple of entries seem like they will do the job.

  • Odd Issue With Camera Preview on Surface RT

    When directly integrating video capture in your Windows Store app you can use the MediaCapture class. There are a number of methods which affect the video but not all will be supported on all devices. One of these is SetPreviewMirroring

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.media.capture.mediacapture.setpreviewmirroring.aspx?lc=1033

    This mirrors the preview video so that your image is, well, like a mirror. However I've discovered that although the method throws an exception if not supported, it also throws an exception on Surface RT even though it is supported and the video is correctly mirrored. Worse still the GetPreviewMirroring method returns false when the video is currently mirrored :-(

  • Prototyping with Infragistics Indigo

    I recently needed to create a prototype for a Windows Phone application and having recently discovered it I decided to use Indigo Studio to build it. The application is not particularly designed for Windows Phone however it has enough standard UI controls and customisations to make it easy to create phone mockups. They say a picture says a thousand words so why not have a look at a sample I created showing a few screens of an imaginary phone application.

    http://indigo.infragistics.com/prototype/XX47K8P4

    In posting that link I've just highlighted one of the great features - you can build a prototype and then share it (either on Infragistics servers or your own) via the web. The Silverlight magic then gives your clients a rich experience to understand the scope and user flow around the application. I intend to revisit this in a series of blog posts to discuss gotchas and tips for creating Windows Phone prototypes. Oh and one of the best features - it's free!

  • Working with .png Images

    In my previous post I discovered a limitation with using the Share... extension point in the Photos app. The good news is that from within your own app you can open .png files. For this you can use the PhotoChooserTask which has been available since Windows Phone 7. This presents the user with essentially the same UI as the Photos app and you can browse the Screeshots folder and select those .png files. The Completed event returns you a PhotoResult containing the raw stream and the filename which you can use to open the file. Because .png access is available this way it seems an odd decision that it is not supported from the Photos app itself. The moral of the story - provide multiple methods for your user to select files...

  • Photos Extra Share and .png

    On Windows Phone 8 it is possible to register your app with the Share... extension point on the photo viewer. This allows your app to receive an image file and process it whether that is sending it to an online service or manipulating it on the device. I found recently an odd quirk with the feature. I setup the extension following the MSDN documentation. I wanted to test on my captured screenshots on the device so I went into the screenshots folder, selected an image and tapped share. While a range of system extensions were shown my custom app was not. I later discovered that it works in other albums. The reason as it turns out is that all screenshots are captured as .png files and camera images are .jpg and for whatever reason photo extras are not enabled for .png files. I searched online and there was a forum discussion but it is still awaiting a formal confirmation from Microsoft that this is expected behaviour.

    http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/095a3300-111e-46d8-968a-3af1036504b7

  • 32feet.NET for Windows Phone

    With the recent announcement of Windows Embedded Handheld 8 it seems fitting to discuss something related to industrial and line-of-business applications which you can develop now on the Windows Phone platform.

    I've released the first drop of 32feet.NET for Windows Phone 8 to our CodePlex site and NuGet. Because the programming model on Windows Phone (based on Windows Runtime StreamSockets) this is a separate package and doesn't follow the programming model of the main 32feet.NET release. Windows Phone 8 supports Bluetooth programming out-of-the-box it is not straight-forward as it is build around the Windows Runtime Peer networking APIs but is different to the Windows 8 implementation. The aim of the 32feet library for Windows Phone is to simplify common tasks. This initial release adds the following features:-

    • Strongly typed extension methods for ConnectAsync which accept service Guids or numerical port numbers
    • BluetoothDevicePicker which offers an easy way for a user to select a device. Equivalent to the SelectBluetoothDeviceDialog in the core 32feet library.
    • Common Bluetooth service Guids
    • Bluetooth Barcode scanner sample. This sample app connects to a Motorola CS3070 scanner and allows input of Barcodes to the device screen. It should also work with other Bluetooth serial based scanners.

    This is just a first release and we will be continuing to develop the library as well as add further localisation and samples. For example to demonstrate connecting to applications running on the desktop (Sorry not Windows Store apps currently). Your feedback is valuable so please visit the CodePlex project site to provide feedback.

    There is a NuGet package available for the Windows Phone flavour of 32feet.NET to allow you to easily add it to your projects:-

    http://nuget.org/packages/32feet.NET.Phone

  • Persist Bluetooth Addresses on Windows Phone 8

    The Bluetooth API on Windows Phone 8 is based around some customisations to the Proximity APIs which are part of the Windows API introduced with Windows 8. When you "discover" devices you can retrieve a collection of device identifiers for paired devices. The first time you perform a task you will want to use this mechanism to select the appropriate device. However you may want your app to remember a specific device and try to connect again on subsequent attempts. In the old .NET world with 32feet.NET we have a constructor for BluetoothAddress which allows you to supply the address in a variety of string or numeric forms. In the Windows API the Windows.Networking.HostName type is used to represent a host name whether it is for a Bluetooth device or an IP address. Normally the read-only Type property will indicate the type of the host.

    In order to store a Bluetooth address for later use you should save the RawName property which for Bluetooth devices is in the form "(11:22:33:44:55:66)". The dotted hex notation is fairly common but notice the address is wrapped in brackets. Now to restore this address in a HostName instance you can later use to open a socket you can use:-

    HostName storedHostName = new HostName(storedRawName);

    You'll notice that this sets the host name and correctly sets the Type property to Bluetooth.

  • iCalendar Files on Windows Phone 8

    iCalendar files are based on the set of data exchange specifications which also includes vCards. You may come across them either in emails or from a website. For example some sites which sell travel tickets allow you to download your itinerary in an iCalendar file. While Windows Phone has always supported vCards for contact information it doesn't recognise iCal files.

    Since Windows Phone 8 introduced the ability to register for file associations this allowed me to use some old code I wrote back in the days of Pocket Outlook on Windows CE and Windows Mobile. My free iCalendar Import application has just become available in the Store for Windows Phone 8. You can download it from the link below. I'd welcome any feedback. There are some limitations on the supported event types - there is no way to insert recurring appointments into the user's calendar so this supports single events only.

    http://www.windowsphone.com/s?appid=95287e45-05d7-4a63-aa82-619192cb1713

  • WriteableBitmapEx for Windows Embedded Compact 7

    I have ported René Schulte's excellent WriteableBitmapEx project to run on Windows Embedded Compact 7. The original library supports drawing across various XAML user interfaces - Silverlight, Windows Phone, WPF and Windows 8 Apps. Because XAML In The Hand exposes an object model which matches Silverlight there was very little work required to port, it just needed a new Dll project for .NETCF 3.5 and a reference to the XAML In The Hand DLL. This allows a whole range of complex drawing operations to be performed where using Silverlight Paths and Shapes would be inefficient.

    WriteableBitmap for Windows Embedded

    Performance will vary more because the range of hardware platforms available for Windows Embedded Compact varies considerably, both in processing power and screen sizes. I've tested the code on FreeScale development boards at up to 1024x768 and on the new Motorola WT41N1 Wearable Computer which has a small 320x240 resistive touch display with encouraging results. Writing XAML user interfaces for embedded devices is incredibly easy once you've experienced the Windows Phone and desktop tools. With built in support for touch and dynamic layouts and all the animation and data-binding you would expect it allows you to write fluid user interfaces for specialist devices where a consumer phone or tablet would be impractical. More information on XAML In The Hand is available here

     

  • Connect Visual Studio 2008 to TFS2012 or Team Foundation Service Preview

    Now that there is a new release of Team Foundation Server you may consider upgrading. However if you still work on projects for the .NET Compact Framework you'll still be using Visual Studio 2008. Luckily there is an update available to allow VS2008 to connect to a TFS2012 server or the new Team Foundation Service Preview (hosted TFS - why not check it out with a free preview account). You'll need VS2008 Service Pack 1 installed first (but you've got that already right!). The download and instructions are available here:-

    http://support.microsoft.com/kb/2673642

More Posts Next page »
Copyright © 2001-2013 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy. OrcsWeb's Windows Cloud Server Hosting