Skip to main content

Posts

Showing posts from August, 2011

WP7Contrib: Dialling the phone number shown in a text block

I wanted to be able to dial a phone number shown in a text block on a page inside an app and I knew the WP7Contrib could help. The contrib has a control called Smart Text Block, the author Mike Wolf has already written a posted about the details here . As the name suggest it has the smarts to process the text and provide an action when the highlighted text is clicked. What I wanted to do was show how easy it is to use. There is no difficulty here at all infact, the control hides away all the complexity, like good OOD should. Also I'm no XAML Ninja like @RichGee  (my coffee of choice is not a latte) so I was surprised at how little XAML I had to manipulate. Shown below are three screenshots from the app I'm currently developing. What you can see is an embedded Bing Map (using the WP7Contrib Bing Maps Wrapper service) with a property for rent shown along with a couple of map pins for local medical facilities. When the phone number is clicked in the bottom left hand corner of

WP7Contrib: Criterion Factory - Location by search by latitude & longitude

To kick off the series about the Criterion Factory in the Bing Maps service I thought I'd start with the easiest functionality - searching for a location using latitude & longitude. Firstly here is the code - I have to emphasize how easy this is to use. It has taken only 5 lines of code to get the location information and the only required is a set of WP7Contrib assembly references. private void locationByPointClick ( object sender , RoutedEventArgs e ) { var geoCoordinate = new GeoCoordinate ( Convert . ToDouble ( this . lat . Text ) , Convert . ToDouble ( this . @ long . Text ) ) ;   var criterion = CriterionFactory . CreateLocationSearchForPoint ( geoCoordinate ) ; this . bingMapsService . SearchForLocationUsingPoint ( criterion ) . ObserveOnDispatcher ( ) . Subscribe ( result = > { this . address . Text = result . Locations [ 0 ] . Address . Locality ; this . address . Text + = E

WP7Contrib: Bing Maps REST Services Wrapper - Criterion Factory

Today I'm starting a series of post about Criterion Factory in the Bing Maps service in the WP7Contrib . I'm not sure how many posts there will be but I expect there to be a few, every time I add one I'll update the list below. Rich & I have written several posts already about using the Bing Maps service, these have focused around the  Location, Routes & Search functionality provided by the Bing Maps REST API and how easily you can get data back without having to deal with a single HttpWebRequest!. If you've read any of these posts you'll have notice the use of the Criterion Factory to construct the query passed to the service methods. Put simply the Criterion Factory is there to help construct queries because the number of parameters can be confusing and you won't always need to specify every parameter for a particular use case. A quick refresh, shown below is a prime example of how to use the Bing Maps Wrapper service, it's returning the cur

Using Bouncy Castle on Windows Phone 7

I'm currently working on a port of an application from iPhone onto WP7 and the local content has to be decrypted on the device. The content was original encrypted for a different platform and the cipher & padding used are not supported in the Silverlight version for WP7. The content was encrypted using the AES symmetric algorithm with an ECB cipher and PCKS5 padding. As stated this combination is not supported by the AESManaged  class available in the System.Security.Cryptography namespace. The documentation  states only the following is supported: 'The cipher mode is always CBC, and the padding mode is always PKCS7' I'm not sure why this is, but I'm aware that ECB is no longer viewed a secure cipher - the choice to use this was out of our hands. The next stage was to find OSS library for WP7. After several recommendations we decided to use Bouncy Castle . BC (Bouncy Castle) is a well established cryptography library from the Java world with a port to C#. Th

SharpSerializer for Windows Phone 7

There's a new binary serializer available for WP7 - SharpSerializer. It 's OSS and is currently hosted on CodePlex . Available via NuGet as well. I received an anonymous comment the other day on a blog post about serialisation performance on WP7. So I thought I would re-run the test app and see how it compared, the original post can be found here . My first attempt failed because the NuGet packages were invalid, so after the author had corrected this I decided to run the test again. This time though I got the latest code and explicitly compiled this as  a WP7 class library. So I ran the same test, binary serialize a collection containing 1000 items and display the performance results to the output window in visual studio: The results don't lie, sharpSerializer is good, but SilverlightSerializer still has it for me. Good to see some competition in this space I'll be keeping an eye on this project.

Be careful of the culture when using Bing Maps REST API

When developing the Bing Maps Wrapper service for the WP7Contrib we weren't aware of the importance of the instance of the CultureInfo class used to format the geo-coordinate data when building the URL parameters. This was for the simple reason, being based in the UK we were relying on the default culture, which happens to be 'en-US'  and this culture formats decimal numbers in the required format for calls to the Bing Maps REST API. The documentation on MSDN does state this, but does not make it very clear. Show below is the formatting for a couple of different cultures, what you'll see is the formatting for the Lat & Long for the Netherlands & Russian cultures is different to the rest. They both use commas as the decimal point. When the Lat & Long are used to format the URL parameter they need to be in InvariantCulture so that your URL looks like the following: If I force the Bing Maps Service to use the Netherlands culture with the code shown b

WP7Contrib: Getting debug information from the NuGet packages

When using the WP7Contrib  packages from nuget.org you will be using the release build versions of the assemblies. Unfortunately what you won't get is the debug information generated by the services and other classes in the contrib. What is detailed below is steps you can use to get this debug information when using the packages. I am aware NuGet now supports the publication of PDBs & symbols to  symbolsource.org  (more info can be found here ). We haven't yet got round to factoring this into our publication process. When I say process, I mean when I use NuGet Package Explorer to do the publish to NuGet. I'm not sure the explorer currently supports this feature (hopefully I'm wrong). When this is done you'll be able to step through the contrib code base. We also provide another way to get debug information at runtime via the ILog interface. The caching, communications & services namespaces make use of this interface. Like all dependencies in the contrib

Manipulating web browser scroll position on Windows Phone 7

Manipulating the browser control position on WP7 is relatively straight forward, all you need to is a couple of calls out to javascript using the InvokeScript method on the browser control. In fact this is the same pattern provided in the desktop version of WPF & Silverlight. The only requirement is the ability to include a couple of javascript functions in a web page. Now this is only possible if you either have control over the remote content or you're using local content on the device. Recently I've been working on a phone app that uses local content. This content is designed for a particular profession who need to access to detailed and intricate data in a fast and easy manner. Each page conforms to a standard model with a simple breadcrumb style at the top to help with navigation and very detail data with embedded links. When  a page is bookmarked or the back button is used to navigate the app we are need to get the scroll positions. So shown below is a simple tes

Manually build WP7 solution with MSBuild on win64

When manually building a WP7 solution file on a win64 machine make sure you use the correct version of msbuild.exe - if you don't you'll get the loads of 'failed to load assembly' messages. The message that gives it away is 'Could not load file or assembly PresentationCore': C:\Program Files (x86)\MSBuild\Microsoft\Silverlight for Phone\v4.0\Microsoft.Silverlight.Common.targets(188,9): error MSB4018: S ystem.IO.FileLoadException: Could not load file or assembly 'PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=3 1bf3856ad364e35' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047 )\r [C:\Work\Temp\PhoneApp2\PhoneApp2\PhoneApp2.csproj] So get it to build you have to use the msbuild.exe from the standard .net directory - C:\Windows\Microsoft.NET\Framework\v4.0.30319. So the following will fail: And the following will succeed:

WP7Contrib: 'IsCachable' is here to help!

We've added the method 'IsCachable ()' to the ICacheProvider to help diagnose and test suitability of entities for caching. It can be used in a live application but we expect it to be more likely used during testing. We don't see any problems with exposing this method on the interface as it has no side affects for the entity being tested or for the cache provider being evaluated against. Any exceptions which occur whilst calling this method are caught and not exposed. The complete signature for the method is shown below: bool IsCacheable<T>(T value, ref IEnumerable<Type> failingTypes) where T : class; The suitability for caching will be returned as the boolean result and any failing types are returned via the ref parameter 'faillingTypes'. Obviously the internal implementation is dependent on the cache provider being used. The method will always return true for the In Memory & Null Cache Providers because neither of these implementation

WP7Contrib: Updated version of SilverlightSerializer

Mike Talbot's release a new version of SilverlightSerializer - keep up the great work! Mike's blog can be found here with a list of the improvements for v2. Obviously a performance improvement is always welcomed especially on a mobile device, but for me the biggest change is the friendly exception message support he's added. Several people using the WP7Contrib had said it was difficult to debug serialisation issues when using the Isolated Cache Provider because when it threw an exception invariably it would be the 'MissingMethodException'. At best this was a good pointer to problems with serialisation at worst it gave no really indication of where to look. So the previous version (v1) gave the following output for the Cache Provider demo in the WP7Contrib Spikes directory, when the Isolated Cache Provider is attempting to serialize the cache contents (to isolated storage on a background thread) it's throwing the 'MissingMethodException' exception