Sunday, 16 May 2010

WP7 and CivicAddressResolver

After having a play with some of the different namespaces and classes within a WP7 project, I tried the CivicAddressResolver.

The following code was taken from Mike Taulty's UK TechDays presentation :-

CivicAddressResolver resolver = new CivicAddressResolver();
GeoCoordinate location = new GeoCoordinate(40.71448, -74.00734);

resolver.ResolveAddressCompleted += (sender, args) =>
if (args.Error == null)
string line1 = args.Address.AddressLine1;
string line2 = args.Address.AddressLine2;
string city = args.Address.City;


Currently the ResolveAddress and ResolveAddressAsync methods are not implemented, as detailed in the following forum post :-

WP7 and Microsoft.Devices.VibrateController

After having a play with some of the different namespaces and classes within a WP7 project, I tried the VibrateController.

Found that the maximum duration for a vibration is 5 seconds.

To start a vibration :-


To stop a vibration :-


Looking forward to being able to test this on a real device.

Monday, 10 May 2010

WP7 and Microsoft.Xna.Framework.Audio.Microphone

I was looking to try out the Microphone functionality as detailed by Peter Foot in the following blog post :-

This is the code that I came up with :-

public partial class MainPage : PhoneApplicationPage
private Microphone currentMic = Microphone.Default;
private byte[] currentData;
private MemoryStream currentStream = new MemoryStream();

public MainPage()

SupportedOrientations = SupportedPageOrientation.Portrait | SupportedPageOrientation.Landscape;

private void m_BufferReady(object sender, EventArgs e)
currentStream.Write(currentData, 0, currentData.Length);

private void Start_Click(object sender, RoutedEventArgs e)
currentMic.BufferDuration = TimeSpan.FromMilliseconds(1000);
currentData = new byte[currentMic.GetSampleSizeInBytes(currentMic.BufferDuration)];
currentMic.BufferReady += new EventHandler(m_BufferReady);


private void Stop_Click(object sender, RoutedEventArgs e)

private void Play_Click(object sender, RoutedEventArgs e)
SoundEffect currentSoundEffect = new SoundEffect(currentStream.ToArray(), currentMic.SampleRate, AudioChannels.Mono);

Saturday, 8 May 2010

WP7 and Silverlight Toolkit

I was interested in trying the Page Transistions sample as detailed in the following blog post :-

However there was a bug with assemblies certificate security using the April Refresh of the Windows Phone 7 CTP, as detailed in the following blog post :-

The particular problem I was experiencing was also reported in the following forum post :-

It was reported that removing the certificate from the System.Windows.Controls.Layout.Toolkit assembly was still not solving the issue, therefore I tried the steps outlined in the previous blog post and my experience was as follows :-

1. The particular powershell script was not running - In the blog post it details that I had to run the "set-executionpolicy remotesigned" command however I also had to unblock the script file which also meant changing the permissions for that file for my particular user on my machine to allow this unblock to occur.

2. Once the assemblies certificate had been removed, the problem reported in the forum post was still occuring so had a look at the Bin directory of the particular project I was using and there were two other DLLs from the Toolkit :-

These other two DLLs also needed their certificates removing. After doing so, I then had to reference these additional two assemblies directly in my project so that they would be the versions that were used (originally I had only referenced the System.Windows.Controls.Layout.Toolkit assembly). After doing this I am now able to test the page transistion sample.

Hopefully others will find this useful.