# 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.

#    |
# Monday, February 15, 2010

Bluetooth changes in Windows 7

Since Bluetooth APIs were introduced into Windows (we are talking about the desktop OS here, not Windows CE / Windows Mobile / Windows Phone) there have been numerous updates and changes. Confusingly not all of these have been in Major updates or service packs but some changes are implemented in OEM only packages. We have been working on the 32feet.NET library to ensure we continue to support the new features in the Microsoft Bluetooth stack. There are a number of useful resources which describe the changes. Firstly Alan McFarlane, who has done a lot of really great work on the 32feet.NET library, has put together a detailed description of the changes in Windows 7 including a dive into the native header files. As you'll see one of the main area of changes is the support for Bluetooth 2.1 which introduces new authentication methods. You should read Alan's full article.

I also noticed that Microsoft have published a new FAQ on Bluetooth support in Windows. Interestingly this covers the entire history of Bluetooth on desktop Windows showing which releases implemented which Bluetooth versions. It goes into some depth on developing drivers for Bluetooth devices too - for example if you implement the Device ID profile you are able to integrate into the new Device Stage UI in Windows 7. The Download is a Microsoft Word 2007 document:-

http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/Bth_FAQ.docx

#    |

Developing for Windows Phone 7

I've already had a couple of questions about how to develop applications for Windows Phone 7. At the moment the "developer story" has not been announced but over on the Windows Mobile Developer Blog they have announced that MIX10 will be where they discuss how to develop for Windows Phone 7:-

http://windowsteamblog.com/blogs/wmdev/archive/2010/02/15/windows-phone-7-series-going-big-for-developers-at-mix10.aspx

Attendees will have access to a dedicated Windows Phone track (currently the 12 sessions are unnamed) and access to the Windows Phone 7 developer tools:-

http://live.visitmix.com/News/Exclusive-Windows-Phone-7-Series-Offer-for-MIX10-Attendees-WP7

#    |
# Sunday, January 31, 2010

Win a trip to PDC in Los Angeles

Microsoft New Zealand are running a competition to win a trip to the next Microsoft PDC event in Los Angeles. It is open to all developers living in New Zealand. All you need to do to enter is help them out with questionnaire:-

“Targeted towards NZ developers, we want to get a better understanding and better cater our resources, events and training in the future. The survey is from now until the end of April. One lucky NZ developer will win an all expenses paid trip to the next PDC in LA.”

Click here to complete the survey

#    |
# Tuesday, January 26, 2010

Application and File Icons with Mobile In The Hand 4.0

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:-

  1. Icon i = IconHelper.ExtractAssociatedIcon(filePath);

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.

The documentation for the IconHelper class is available in the online library. For more information about Mobile In The Hand see the product page.

#    |
# Wednesday, January 20, 2010

Interesting Windows Phone News for MIX10

There have been rumours floating around all over the web about Windows Phone future versions. Microsoft have remained tight lipped allowing various tech sites to come up with all sorts of fanciful stories. However a tantalising news snippet has appeared on Microsoft's website for MIX10 the conference for designers and developers coming up in March in Las Vegas:-

http://live.visitmix.com/News/Windows-Phone-at-MIX10

It will definitely be worth keeping an eye on this event, hopefully more information will be released as the sessions and schedule are firmed up:-

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

 

#    |