# Tuesday, May 04, 2010

WP7: Versions in April CTP

I was surprised when I first wrote a hello world application on the MIX CTP that the Environment.OSVersion.Version property was returned as 7.0 when all the media speculation was that it would be based on CE 6. I tweeted about it at the time but some sources are still saying that it runs a customised version of Windows Embedded CE 6.0 R3. However regardless of whether this is a version which pre-dates the eventual release of Windows Embedded Compact 7 (which will be the new name for the successor to Windows Embedded CE 6.0) and any other name changes (remember we have already had Windows CE, Windows CE.NET and Windows Embedded CE) I think it’s safe to say that the core OS in the product is version 7. As we already know Silverlight (and XNA) runs on top of the .NET Compact Framework 3.7 runtime. So just for curiosities sake here are the version properties retrieved in the latest April CTP release:-

April CTP Versions

#    |
# Monday, May 03, 2010

Configuring Microsoft Exchange Server for Mobility

If you want to learn about configuring Exchange Server for mobile devices there is an interactive configuration guide which will work through the actions required depending on your platform and your specific requirements:-

http://wmexchangesetup.com/launcher.aspx

#    |
# Saturday, May 01, 2010

WP7: Writing a Well-Behaved Threaded Application

The latest CTP release of Windows Phone 7 introduces a new managed library which exposes events you can monitor to catch changes in state in your application. The assembly is Microsoft.Phone.Execution.dll. This contains a WindowsPhoneEvents class which exposes two static methods – Pause and Resume. You can handle these events to detect when your application is dismissed and reactivated. This allows you to stop unnecessary processing and be a good citizen. I put together a simple example which shows how to pause a background thread based on these events and you can see the results by running it on the Emulator and switching to the home screen (Windows button) and returning to your application (Back button).

The sample uses a ManualResetEvent to block the background thread to avoid it consuming processor cycles while the app is paused.

WindowsPhoneThreading.zip (22kb)

 

Also in this assembly is the StreamPersister class. Unfortunately there is no documentation for this at the moment but an instance is passed in the Pause and Resume eventargs which will presumably allow you to safely persist state data which you can then load when your app is resumed. Hopefully there will be some official documentation on this to complete the picture.

#    |

WP7: New Capabilities Security Model

Jamie Rodriguez has a post on the new capabilities security model in Windows Phone 7 which is introduced in the latest CTP release:-

http://blogs.msdn.com/jaimer/archive/2010/04/30/windows-phone-capabilities-security-model.aspx

It is interesting to read how this will be handled at runtime, here are the key facts:-

  • If you try to use a feature and you didn’t specify the capability you’ll get an UnauthorizedAccessException when you first call that feature
  • There is no API to check if you have been granted a specific capability
  • The disclosure to the user will vary depending on the capability and marketplace – Either listed on the Marketplace page, a user prompt at purchase or a user prompt when the capability is about to be accessed.
  • A new project created in the latest CTP will request all of the currently documented capabilities (you can remove those you don’t need later)
  • There are other capabilities specific to OEMs and operators which are not documented
  • The table of example features lists a few items yet to be shipped in the developer tools giving an interesting insight into what is still to come – Microsoft.Devices.Radio and Microsoft.Devices.MediaHistory
#    |
# Friday, April 30, 2010

WP7: New CTP and a quick tip

If you haven’t already heard there is a new release of the Windows Phone 7 Developer Tools available which is compatible with the RTM release of Visual Studio. Before you install you need to uninstall the previous version and this is where you might have problems. See this tool for cleaning up your machine:-

http://blogs.msdn.com/astebner/pages/9544320.aspx

Okay, now you’ve safely removed the old bits you can download the new installer from here:-

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=cabcd5ed-7dfc-4731-9d7e-3220603cad14

Read the release notes:-

release notes

In particular there is a breaking change if you open existing projects – the WMAppManifest.xml requires some extra items to describe the application’s capabilities. There is also an issue with including Authenticode signed dlls (this includes official Microsoft libraries), you can read more about it here:-

http://timheuer.com/blog/archive/2010/04/29/windows-phone-tools-update-april-2010-silverlight-xna.aspx

Check out an overview of what is new in this release:-

What's New in Windows Phone 7 CTP Refresh

 

Finally to end on a quick tip – Assuming you install on a machine without Visual Studio 2010 the “Visual Studio 2010 Express for Windows Phone” displays a simpler user interface than its big brother. You can quickly enable extra goodness by going to Tools > Settings > Expert Settings. This enables more menu and toolbar options and is definitely worthwhile if you are already familiar with Visual Studio.

#    |
# Tuesday, April 13, 2010

WP7: ApplicationBar CTP Issue

If you have read the UI Guidelines for Windows Phone 7 (If you haven’t, get it now) you notice that in the discussion of the ApplicationBar it states that a maximum of four icons can be added. I noticed inadvertently that if you add five icons in your XAML your app will compile and run but only the first four are shown. If you add a sixth icon the designer will present you with an error:-

appbar6items

It appears that this is a bug in the current CTP release and the control should support only adding four items. It previously supported five but this was reduced based on user feedback, obviously the validation in the current CTP is not strict enough but I expect this will be fixed in the next release.

#    |

KIN: A totally different Windows Phone

Microsoft announced a pair of new phone devices which will be manufactured by Sharp and branded KIN. These are not part of the Windows Phone 7 platform but are still (perhaps confusingly) called Windows Phone. KIN uses a lot of the same underlying technology as Windows Mobile has in the past and Windows Phone will do, however the device is sharply focussed on social networking and the whole user experience revolves around this. The platform has built in support for Facebook, Twitter and MySpace along with the accompanying KIN Studio online service. KIN Studio is a web portal which aggregates everything you create on the phone up in the cloud. It has some cool visualisation of this content too including a timeline view of everything you’ve done. Think of it as a kind of MyPhone on steroids…

16_web

The user experience uses some of the same principles as the Metro user interface visible in Windows Phone 7 however one thing that is instantly noticeable is there is a lot less dead space. Where Windows Phone 7 uses large fonts and generous spacing in a “less is more” approach the KIN user interface packs highly graphical elements closely together. It has been described as a magazine style and certainly tries to catch your eye with everything which is going on in your social networks. Both platforms use a minimal colour scheme – from the flash based demo on the website you can choose one of four highlight colours but these are different to the colours used on the “big brother” Windows Phone 7.

I’m looking forward to seeing the real device, and I hope that some of these innovations (particularly KIN Studio) make it into Windows Phone 7 too! I’m also wondering if there will be any development story for these devices as there is nothing mentioned on the official website or press releases…

#    |
# Friday, April 02, 2010

Introducing "Windows Phone 7"

Microsoft have announced via Twitter that they have officially dropped the epic fail "Series" from the product name. Many have been referring to it as "Windows Phone 7" or "WP7" already and the "Series" was the latest in a series (sorry) of Microsoft adding redundant words to product names to unnecessarily confuse the public...

#    |
# Thursday, April 01, 2010

April Fools: More Details on Windows Phone 7 Cut and Paste Alternative

The news that Windows Phone 7 would release with no Cut and Paste functionality generated a lot of outcry but we were promised an alternative system which can recognise common information types and perform appropriate actions. The actual implementation was not demonstrated however some screenshots have emerged from an upcoming build featuring the “Content Assistant” which give an idea of how the feature will work in the final release. The design is based on extensive user research and experience of providing context aware functionality within other Microsoft products. The designers were keen to continue the friendly and personal design ethic which underpins Windows Phone 7.

“We wanted Windows Phone 7 Content Assistant to have a personality which users could really relate to and feel reassured that help was always on hand when performing common tasks” Avril Belachelijk – Senior User Experiences Ideator

The system will highlight recognised data such as phone numbers and the user can tap to see actions they can perform. The leaked screenshot is available here:-

http://mobileworld.appamundi.com/cfs-filesystemfile.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/peterfoot/assistant.png

#    |
# Friday, March 26, 2010

Audio Recording in WP7

Because it is possible to use the XNA libraries within a Silverlight project you can add audio recording in your application using the Microphone class found in the Microsoft.Xna.Framework.Audio namespace. You can test this on the Emulator as it will work with a microphone attached to the host PC.

First add a reference to Microsoft.Xna.Framework.dll to your project.

Next to make life easier add “using Microsoft.Xna.Framework.Audio;” to the top of your code file. You can access the Microphone through the static Microphone.Default property but for ease I created a local variable called m.

Next you need to decide what you are going to do with recorded audio. I built a simple audio memo application which stores the audio data in memory for instant playback. For simplicity I added MemoryStream to my app. I will write audio data to this and then I can easily get a byte array of the entire buffer to pass to the SoundEffect class to playback later. You could also write to a file in Isolated Storage or send to a web service…

In the constructor of my page I added an event handler for the BufferReady event of the Microphone. This is called each time the buffer is full and in the handler I copy the contents to the memory stream.

I created a Record button. I then set the BufferDuration on the Microphone object to 1 second (the maximum value), this is not strictly necessary as you’ll be copying data from the Microphone when it notifies you. Then I call Start to open the Microphone and start recording. Each time the buffer fills it is copied to the memorystream. When a Stop button is pressed I called Stop() on the Microphone to stop recording. Afterwards the MemoryStream is closed and we can now access the underlying buffer for playback.

A third button, you guess it “Play”, uses the SoundEffect class to play back the contents of the buffer. Into the constructor I pass the .ToArray() method of the MemoryStream, the SampleRate from the Microphone and AudioChannels.Mono since we know this is a mono source. You can then either call Play() or if you want to muck about with the sound you can use the overload which accepts volume, pitch and pan values. For example se.Play(0.7f, 0.5f, -1.0f) plays the sound at 70% volume, with pitch raised half an octave and through the left channel. Unless the user is wearing a stereo headset the panning will probably be lost on them. By playing with the pitch property (-1 – one octave lower through to +1 – one octave higher) you can probably find your perfect balance between Brian Blessed and Joe Pasquale…

As Rob Miles noted in his blog there seems to be an issue with pitch values > 0.6 in the current release.

#    |
# Tuesday, March 23, 2010

Windows Phone 7 – For Web Developers

The emulator for Windows Phone 7 includes Internet Explorer so you can test your websites now to see how they are rendered on this device. The emulator gives you a lifesize rendition of the device screen so you can format your pages appropriately. To customise your site for this new device you’ll need to identify it when it hits your server so here are the key facts:-

User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0)

I’ve highlighted the items which indicate the platform and the browser. The browser also sends the UA-pixels header which describes the screen. On the emulator this is 480x800 (regardless of the screen orientation in use at the time) and it has been announced that there will also be devices using 320x480 (HVGA)

#    |
# Monday, March 22, 2010

Windows Phone 7 – Input

The Software Input Panel in Windows Phone 7 is entirely new. Unlike previous versions there will be a single SIP provider and device manufacturers will not be able to customise it. This means you can guarantee the same experience across different device types. With Windows Mobile there were some big differences between the input models of Standard Edition (Smartphone) and Professional Edition (Pocket PC) device types. We had the ability on Professional Edition devices to show or hide the sip and select from available input panels but no further control to customise the panel based on the input type required. For example to get a numerical keypad often required faking a screen press to “shift” the keyboard (unless your device had a specific keypad input panel).

Windows Phone 7 has a standard input panel but it does support different input contexts and will adjust accordingly. So if you mark a TextBox as requiring a Phone Number you’ll get a big numerical keypad. There are a number of different contexts supported, the UI guidelines document describes them but has some errors as the names do not match those you’ll see in Visual Studio and there are no examples of how to set them. I’ve tested a number of different InputScopeName values and have listed those below with a description of their behaviour (this effectively replaces the table on page 20 of the UI guidelines).

InputScopeName Layout
Default QWERTY
Text QWERTY with emoticons
EmailNameOrAddress QWERTY with .com and @ keys
TelephoneNumber 12-key phone pad
Url QWERTY with .com and “Go” enter key
Maps Not present
Search Same as Url – note this is not semi-transparent
SMS Address Not present – use TelephoneNumber

 

Along with these contexts there are others defined, most of which are the same or variations of the above. For example there are a number of numerical inputs such as CurrencyWithSymbol which has the QWERTY keyboard shifted to show numerals with common currency symbols (Dollar, Pound, Euro and Yen). All the ones I tried worked except for Xml which threw an unhandled exception. You can set the context easily in your XAML:-

Code Snippet
  1. <TextBox Height="31" HorizontalAlignment="Left" Margin="16,173,0,0" Name="textBox1" Text="TextBox" VerticalAlignment="Top" Width="449">
  2.     <TextBox.InputScope>
  3.         <InputScope>
  4.             <InputScope.Names>
  5.                                        <InputScopeName NameValue="EmailNameOrAddress"/>
  6.             </InputScope.Names>
  7.         </InputScope>
  8.     </TextBox.InputScope>
  9. </TextBox>
#    |
# Sunday, March 21, 2010

Windows Phone 7 – Theme Aware

Windows Phone 7 supports two basic themes each with four highlight colours. This gives the system eight possible colour-schemes. If you look at the templates supplied with the current CTP development tools you'll see that a selection of Colours and Brushes are hard-coded into your App.xaml. This means that even if you change the system theme your app will not follow suit. You may want to test how you application works with both Light (Black text on White background) and Dark (White text on Black background) themes so here is a little trick to help out.

First I am assuming you have an application based on the WindowsPhoneListApplication template (this should hold true for the other template). You need to make a couple of changes to the list template to remove hard-coded values:-

Code Snippet
  1. <ListBox.ItemTemplate>
  2.      <DataTemplate>
  3.          <StackPanel x:Name="DataTemplateStackPanel" Orientation="Horizontal">
  4.              <Border x:Name="DataTemplateBorder" Height="44" Width="44" BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="2.5" CornerRadius="100" Margin="10,16,0,0" VerticalAlignment="Top">
  5.                  <Path x:Name="DataTemplatePath" Height="16" Width="11" Fill="{StaticResource PhoneForegroundBrush}" Stretch="Fill" Margin="4,0,0,0" HorizontalAlignment="Center" VerticalAlignment="Center" UseLayoutRounding="False" Data="M337.59924,129.61948 L337.59924,141.51501 L345.5704,135.87381 z"/>
  6.              </Border>
  7.              <mpc:ListViewItem Layout="TextAndDetailsWithIcon" Text="{Binding LineOne}" Details="{Binding LineTwo}" Style="{StaticResource PhoneListBoxItemLayout}"/>
  8.          </StackPanel>
  9.      </DataTemplate>
  10.  </ListBox.ItemTemplate>

Here you can see we set the BorderBrush of the DataTemplateBorder and the Fill of the DataTemplatePath to the static resource rather than “White”. The simplest way to override the hard coded brush resources from a single location programmatically is to add the following lines in your App.xaml.cs file:-

Code Snippet
  1. SolidColorBrush pfb = (SolidColorBrush)this.Resources["PhoneForegroundBrush"];
  2.             pfb.Color = Colors.Black;

You can see here the only colour we have changed is foreground as the background seems to react to the system setting. Interestingly in the Dark theme the background is not black but a very dark grey, I haven’t found any explanation for this. Running the application now presents the application correctly using the Light theme, but of course the original Dark theme is broken because the text is now Black on Grey. Using knowledge of WPF I thought we should be able to use a member of the SystemColors class in System.Windows. However I quickly found that these are not implemented and all return RGB values equal to Black. There is also no system event to capture if the theme is changed. If we go to the Start menu while the application is running, access settings and change the Theme, when we return to our application it won’t have updated. Based on all the discussions of multi-tasking support I’m not sure if this scenario will be supported as it seems we will be expected to save state and exit when switching out to another application. This is not the case in the current CTP. At the moment it looks like we’ll just have to wait and see how this takes shape. Ideally the default templates will inherit the system theme with no need for extra coding so we only need to modify our app.xaml etc if we want to override the colours in our application. Some of the “hubs” which have been demonstrated use photographic backgrounds and I don’t think any of the released images show separate Light/Dark behaviour for them…

#    |
# Tuesday, March 16, 2010

Mobile In The Hand 4.1

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.

#    |

Windows Phone 7 – For Mobile Developers

We have heard over the last couple of days how the Silverlight development model in Windows Phone 7 means that all developers are now mobile developers. However what does the platform offer beyond the standard Silverlight classes and functionality. Where possible I’ll try to compare this with the .NETCF Windows Mobile approach where applicable.

Location

Windows Phone 7 inherits the System.Device.Location namespace introduced in .NET 4.0. On a desktop machine this supports the new location API in Windows 7 (these classes are non-functional on older versions of Windows). This provides a single location API which can wrap the GPS, WiFi and cell-triangulation support of the phone. The API is incredibly simple to get started with and it is good to see that there is consistency with the full framework object-model. As a side note yesterday we released a new version of Mobile In The Hand (4.1) which adds InTheHand.Device.Location.dll. This exposes the exact same object model as .NET 4.0 and currently works on all devices which expose the GPS Intermediate Driver (Windows Mobile 5.0 and later and Windows Embedded CE 6.0).

Device Hardware

Windows Phone 7 devices must support a standard range of features which were previously optional, for example an Accelerometer. There is now a standard API to access this from your code in the Microsoft.Devices.Sensors.dll. There is no direct equivalent in the .NETCF world as previously these APIs if available were specific to the hardware vendor. There is a Codeplex project which attempts to provide a unified API over these device specific sensors and that goes beyond just the accelerometer. On the new Windows Phone documentation published to MSDN it looks like the sensor support will improve before release “A variety of sensors will return data that can be consumed by developers. For example, multi-touch input, accelerometer, and microphone sensors will all be accessible by APIs.”

For user feedback Windows Phone 7 devices include vibration, it appears that the device spec doesn’t allow for notification LEDs at all. The Microsoft.Devices.dll contains the VibrateController class which allows simple on/off control of vibration up to a maximum of 5 seconds at a time. There is no equivalent .NETCF functionality although it was possible to P/Invoke either the Vibrate or LED APIs depending on whether the device was Standard or Professional Edition. Mobile In The Hand has offered the InTheHand.WindowsMobile.Forms.Vibrate class for the past couple of versions and it has a similar object model. Your application cannot intercept or override the hardware buttons on the device which include power button, volume, camera and the standard three buttons on the front of the device (Back, Home and Search). You can reference the Xna assemblies from a Silverlight project in order to take advantage of Microphone input and SoundEffect output.

Tasks

There are very few hooks to allow your application to integrate with the built in applications. Windows Phone offers a number of tasks – reusable components which kick off specific actions on the phone. These are a bit like common dialogs in the traditional .NET world. Currently all that I have tried in the emulator fail with a COMException, however here is the list of these exposed from Microsoft.Phone.Tasks.dll

Class Name Windows Mobile Equivalent
BingMapsTask  
CameraCaptureTask Microsoft.WindowsMobile.Forms.CameraCaptureDialog
EmailAddressChooserTask Microsoft.WindowsMobile.Forms.ChooseContactDialog
EmailComposeTask Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.DisplayComposeForm
MarketplaceLauncher  
MediaPlayerLauncher  
PhoneCallTask Microsoft.WindowsMobile.Telephony.Phone.Talk
PhoneNumberChooserTask Microsoft.WindowsMobile.Forms.ChooseContactDialog
PhotoChooserTask Microsoft.WindowsMobile.Forms.SelectPictureDialog
SaveEmailAddressTask  
SavePhoneNumberTask  
SearchTask  
SMSComposeTask Microsoft.WindowsMobile.PocketOutlook.MessagingApplication.DisplayComposeForm
WebBrowserTask  

 

Tiles

The old Home Screen and Today Screen models of Windows Mobile Standard and Professional editions are completely replaced. The new shell allows you to create tiles which effectively fill their place. These support not just a method to launch your application but also a method to show status updates (obvious examples are number of messages, missed phone calls etc). The current SDK doesn’t seem to expose this yet. There is a Microsoft.Phone.Shell.ShellEntryPoint class which the documentation indicates is used for this purpose but no details on its usage.

System Status

What appears to be missing entirely (at this point anyway) is some equivalent to the excellent State and Notifications Broker in Windows Mobile. That provides easy access to numerous system properties – Battery, Network connectivity etc with change notifications. There is a certain assumption with Silverlight applications that power is never an issue and you have permanent fast network connectivity (how else did you get to the website hosting a silverlight application). A well designed mobile application will have to behave well under a variety of conditions and perform a certain level of local caching of data rather than just being reliant on a web service to pull back live data. There is no System.Data namespace and no SQL CE database engine to program against so you will be responsible for serializing and deserializing your own data into isolated storage.

To Be Continued

Like most people I’ve only had a day or so to play around with the Windows Phone 7 tools and as noted above there are some gaps in the current CTP release. I’ll be adding more Windows Phone 7 posts over the next few months…

#    |
# Friday, March 05, 2010

Windows Phone Sessions at MIX Announced

The covers have been lifted off of the twelve sessions at MIX in the Windows Phone track. Following on from yesterdays announcements that Windows Phone 7 development consists of Silverlight and XNA, these session descriptions tell more about the entire development experience including the Marketplace:-

http://live.visitmix.com/Sessions#/tags/WindowsPhone

#    |
# Tuesday, February 16, 2010

New Windows Mobile 6.5.3 DTK

http://www.microsoft.com/downloads/details.aspx?FamilyID=c0213f68-2e01-4e5c-a8b2-35e081dcf1ca&displaylang=en

This Developer Tool Kit acts as an add-on to the Windows Mobile 6 SDK. It adds in Windows Mobile 6.5 and 6.5.3 samples, APIs and Emulators. The download link includes separate Professional and Standard Edition packages along with a number of localised emulator images.

#    |