Paul Taylor's blog
Ramblings about technology, music and life...

Car dent…

Friday, 1 April 2011 07:29 by paul taylor

Funnily enough… I like cars. Especially my own so when somehow a dent appears on the roof I am totally gutted.

Anyway, cutting to the chase – if you want someone to fix this up and you live in the London them I can’t recommend this chap enough Dentman. A legend.

Came round and within 20 minutes it was all fixed up. Absolutely Brilliant.

dentman_thumb3

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

Everything search engine

Sunday, 6 March 2011 09:55 by Paul Taylor

Every so often you come across a tool that simply makes your life easier. EVERYONE should install this, VoidTool’s Everything Search engine.

This thing is fabulous for finding files on your local system. If you compare this with WIndows 7 search, it makes it look very embarrassingly slow indeed.

Do yourself a favour, go and install it.

Tags:  
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

WPF attached behaviour for double click

Sunday, 6 March 2011 09:05 by paul taylor

I have been working with WPF for a while and as with any technology it takes time to learn.

Being a good citizen, I have been following the MVVM pattern then I came across a problem that left me scratching my head for some time. How to attach a double click behaviour to a list view item. This should be easy (and it is if you know the answer)

I wasted a good hour of my life not being able to get this working, even examples on the web could not help me out. I was getting a bit stressed out and then thought about actually reaching out for a bit of help. I have not used StackOverflow before to ask a question, always been a consumer of the information there. But what the hell, worth a try.

I think the community there is great, I spent the time putting together an example before posting as I know it is easier for someone to help when the question is detailed and not just a “help! I can’t figure this out” few line post.

I could not believe it, 2 minutes after posting I got an answer. Brilliant. Not to repeat myself, here is the info.

The offending line was fixed with this…

<Window.Resources>
<Style x:Key="listViewItemStyle" TargetType="{x:Type ListViewItem}">
<Setter Property="local:ClickBehavior.DoubleClick"
Value="{Binding DataContext.Foo, 
RelativeSource={RelativeSource AncestorType={x:Type ListView}}}"/>            
</Style>
</Window.Resources>

The DoubleClick behaviour is relatively simple

public class ClickBehavior
{
public static DependencyProperty DoubleClickProperty =
                  DependencyProperty.RegisterAttached("DoubleClick",
typeof(ICommand),
typeof(ClickBehavior),
new FrameworkPropertyMetadata(null,
                  new PropertyChangedCallback(ClickBehavior.DoubleClickChanged)));

public static void SetDoubleClick(DependencyObject target, ICommand value)
{
target.SetValue(DoubleClickProperty, value);
}

public static ICommand GetDoubleClick(DependencyObject target)
{
return (ICommand)target.GetValue(DoubleClickProperty);
}

public static void ElementMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var element = (UIElement)sender;
var command = (ICommand)element.GetValue(DoubleClickProperty);
command.Execute(null);
}

private static void DoubleClickChanged(DependencyObject target,
Technorati Tags:
DependencyPropertyChangedEventArgs e)
{
var element = target as ListViewItem;
if (element != null)
{
if ((e.NewValue != null) && (e.OldValue == null))
{
element.MouseDoubleClick += ElementMouseDoubleClick;
}
else if ((e.NewValue == null) && (e.OldValue != null))
{
element.MouseDoubleClick -= ElementMouseDoubleClick;
}
}
}

Anyway, here is a simple project I put together to help you out if you need it. Enjoy.

John Gossman also has a few great posts with more detailed information on attached behaviours here with a sample.

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Potholes are driving me mad...

Sunday, 6 March 2011 08:31 by Paul Taylor

I know the government is having to cut costs but these damn potholes are simply driving me nuts.

Dear Surrey Council, please send a bloke with some concrete soon.

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Use AutoHotKey for BDD/TDD style naming

Saturday, 19 June 2010 05:45 by Paul Taylor

Does it annoy you having to type the "_" character into your TDD/BDD tests?

Use AutoHotKey to enable easy BDD/TDD naming style.

  • Download and install AutoHotKey
  • Download this script from JP Boodhoo site and name it BDD naming mode.ahk. (If you want a package with icons, get the zip file from David Tchepak' site here)
  • Copy the file BDD naming mode.ahk to your start menu folder (if you want this to run when your machine boots)

clip_image001

  • Double click the file BDD naming mode.ahk to start without rebooting

Now you can turn on/off the BDD naming style using Ctrl+Shift+U. When you switch the script on, just type a space and magically an "_" will appear. Nice.

Tags:  
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Keymaps for ReSharper

Thursday, 17 June 2010 10:20 by Paul Taylor

Do you spend time downloading, printing and sticking up on the wall the ReSharper keymap pdf? Or move away from development for a while doing whilst doing some sales or architecture work and forget which keyboard short cut does what?

Howard Van Rooijen, an old colleague from EMC Consulting/Conchango, has created a fantastic little plug in called Keymaps for Resharper to let you view your keyboard shortcuts.

Once installed, find this handy window in the ReSharper context menu

clip_image001

And up pops your reminder

clip_image001

Brilliant.
Tags:  
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Part 1: Silverlight 3 TwitterSearchMonitor with MVVM : Introduction and project setup

Thursday, 28 January 2010 03:16 by Paul Taylor

This is the first part in a series of posts showing you how to refactor the Silverlight 3 TwitterSearchMonitor application with MVVM.

As mentioned at the start, in this series I am going to work through an example of taking the TwitterSearchMonitor example application, detailed on Tim Heuer’s blog, and refactor this code into an MVVM (Model-View-ViewModel) approach.

Along the way I will also show you have to take advantage of the Silverlight Unit Test Framework, utilise IoC (Inversion of Control) to inject dependencies into your code as well as how to use mocking as you test your ViewModel and associated classes.

Background

If you haven’t already done so, go and take some time to work though Tim’s set of posts to build up the basic application (and get some core learning done) and when you are ready come back here to work through refactoring the application,

If you are completely new to MVVM, then I would suggest running through this Pixel8 podcast which shows creating a simple MVVM application from scratch in Silverlight and also learn from many resources that are already out there.

Frameworks

With all the above out the way, it is time to introduce the tools and frameworks we are going to use in this series. Download and the latest versions of each and extract to a suitable folder:

Solution structure

Now you have the software you need installed, let’s get our solution configured and ready to use. Open up the original codebase for the TwitterSearchMonitor application into Visual Studio, if you followed through all the original tutorials your solution will look like similar to that shown below:

01-initial_solution

I tend to keep all .NET assemblies that are referenced in a separate folder in the solution, this helps keep things local to the solution and ensures that they are included into source control so each developer on the team gets the same version. As we have both .NET framework  assemblies and Silverlight .NET framework assemblies (that can share the same name!) it is obvious that we need to keep these in separate folders.

Therefore create the following folders in your solution – I am using a root folder called “ReferencedAssemblies”, some people like to call this “Lib” or “Depenancies” but it does not matter and choose the terminology you like.

07-ref_assembly_folders

Copy into the folder ReferencedAssemblies\Silverlight the following Silverlight assemblies from the download frameworks for Ninject, RhinoMocks and the Silverlight Unit Test Framework:

For Ninject

  • Ninject.Core.dll

For RhinoMocks

  • Castle.Core-Silverlight.dll
  • Castle.DynamicProxy-Silverlight.dll
  • Rhino.Mocks 3.5.Silverlight.dll

For the Silverlight Unit Test Framework

  • Microsoft.Silverlight.Testing.dll
  • Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll

So these files are included in the solution, add two solution folders; one for the Silverlight assemblies and one for the .NET assemblies. This is done using Add –> New Solution Folder from the solution explorer

08-new_solution_folder

I created a solution folder named ReferencedAssemblies for the .NET framework assemblies and SilverlightReferencedAssemblies for the Silverlight .NET assemblies.

Simple copy the files from the ReferencedAssemblies\Silverlight to SilverlightReferencedAssemblies solution folder – you can simply drag and drop from windows explorer into the solution. The structure for the solution should now look as follows:

09-solution_with_ref_assemblies

Time to add in a new Silverlight Test Project. Follow the steps I detail here and your solution should now have a Silverlight Unit Test project – I named mine TwitterSearchMonitor.Test:

10-solution_with_test

For MVVM, we need to support Commanding – this allows WPF like commands to be used in Silverlight. I will explain this in a bit more detail when we start building our first VIewModel but for the moment simply create a folder call “SLExtensions” and copy the code from the “Input” folder from the Silverlight extensions code base over to your TwitterSearchMonitor project.

Copy the code from the following folder from the extracted Silverlight Extensions code base which was developed for Silverlight 3:

trunk\SLExtensions\SLExtensions\Input

Your solution should look as follows:

11-solution_with_slextensions

Now we need to include references for RhinoMocks (to allow mocking in our tests) and Ninject (to allow IoC and dependency injection) and Ninject (for Ioc) into the solution.

For mocking, we only need to reference RhinoMocks from our test project. Select the TwitterSearchMonitor.Test project and add a reference to Silverlight assembly Rhino.Mocks.3.5.Silverlight.dll

12-rhino_Ref

13-rhino_Ref2

For Ninject, select the TwitterMonitor project and add a reference to the Ninject.Core.dll assembly

14-ninject1

15-ninject2

Rebuild the solution to ensure everything is working as expected.

Our solution is now configured with all the external dependencies we need to start creating the MVVM version of the TwitterSearchMonitor application with testing, mocking and inversion of control.

In the next instalment we can finally start to add some code to the application now we have the basic solution structure in place.

Tags:   ,
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Silverlight 3 TwitterSearchMonitor with MVVM series

Wednesday, 20 January 2010 04:13 by paul taylor

As a way to learn a new technology, I find one of the best approaches is to actually sit down with an existing application and build on top of it. This is what I am going to share with you to hopefully help you learn more about Silverlight and MVVM (Model-View-ViewModel).

Tim Heuer created an excellent set of blog posts showing how to create the TwitterSearchMonitor application. Having run through this some time ago, I thought it would be a good exercise to take this simple application and move it forward to be unit tested along with being developed using the MVVM pattern. Quick disclaimer…

I am not an MVVM guru, I am a technology guy learning and sharing my way through the maze of a relatively new technology stack. I will make mistakes, I will develop things that other people might not think right. It does not matter – this is simply an approach, follow it if you like and feel free to send me feedback.

I will break this down into a number of (hopefully) easily digestible posts so please check back to see how these progress over the coming weeks. Here is a draft break down of the series:

  • Part 1 – Introduction and project setup
  • Part 2 – The first ViewModel with unit testing and mocks
  • Part 3 – Developing and Integration testing our Service
  • Part 4 – Adding the rest of the functionality
  • Part 5 – Wrap-up
Tags:   ,
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Set up Silverlight 3 Unit Testing

Tuesday, 12 January 2010 00:57 by paul taylor

First things first, if you are new to Silverlight unit testing then I highly recommend checking out these excellent introductory videos.

Once you are armed with a bit of back ground leaning, follow these steps to get your machine up and running with the Silverlight 3 Unit Test Framework (assuming you have Visual Studio 2008 SP1 installed):

1) Download the Silverlight Project templates

Extract the file SilverlightTestProject_CSharp.zip to the directory:
C:\Users\<username>\Documents\Visual Studio 2008\Templates\ProjectTemplates
This installs the VS project template.

04-sltestproject

2) Extract the file SilverlightTestClass_CSharp.zip to the directory:
C:\Users\<username>\Documents\Visual Studio 2008\Templates\ItemTemplates
This installs the VS Silverlight test class template.

 05-sltestclass

3) Download the latest version of the Silverlight Unit Test Framework

4) Add a test project to your solution

  • Right-click on the solution
  • Select the Add > New Project menu item
  • Click on the root “Visual C#” project type node
  • Under “My Templates”, select “Silverlight Test Project” and give your test project a name.

5) Check the references in the test project created. If you have not extracted the Silverlight Test framework assemblies, you will see the following errors.

clip_image001[25]

6) Simply extract the 2 test assemblies:

  • Microsoft.Silverlight.Testing.dll
  • Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll

to your chosen directory and update the references to wherever the framework assemblies are extracted to. I personally have a ReferencedAssemblies\Silverlight folder where all shared assembles are stored within each project solution and add a Visual Studio Solution folder named SilverlightReferencedAssemblies

For reference, here is my initial solution folder

06-solution_with_testproject

7) Setting your newly created the test project as the StartUp project and running, should now allow your to run tests by pressing F5. You will get an error as no tests are in place but this shows all is setup ok.

clip_image001[35]

Here are a few more links to useful information on Silverlight unit testing

I hope this helps!

Tags:   , ,
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Error: Unable to start debugging. The Silverlight managed debugging package isn't installed.

Wednesday, 9 December 2009 02:12 by Paul Taylor

So right now I am looking at Silverlight for a number of clients and as always there is lots to learn here. Having just finished working on Silverlight 3 with my development envioronment working beautifully (see the Silverlight get started page) , I now need to help out on a v2 project.

I uninstalled the Silverlight 3 runtime and browsed to this client's site to see what actulally gets installed when a Silverlight 2 application is requested with no Silverlight runtime installed. Interestingly even though the client has a Silverlight 2 application, the Silverlight 3 runtime is installed via the Microsoft website. Anyhow, I digress.

On now trying to debug the solution (which has been upgraded to a Silverlight 3 project - see Tim's Heur's blog for more info on having v2/3 on the same machine) and after installing the Silverlight 3 runtime again I get the following error in Visual Studio:

 

There are quite a few posts on the web about this issue with the a beta verion of Silverlight 2, but of course this does not help.

Solution:

Close Visual Studio, uninstall Microsoft® Silverlight™ 3 Tools for Visual Studio 2008 SP1.

 and then reinstall. Hope this helps.

What is in the Silverlight Tools for Visual Studio?

Tags:  
Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed