WPF / XAML: Binding ComboBox directly to enum values

This is a note to remind me how to bind a xaml combo box directly to an enum property defined in the ViewModel. This is handy if the ComboBox values for display match exactly those defined in the backing enum.

So imaging that we have an enum defined as follows:

public enum UserType
{
    Tester,
    Engineer
}

Now imagine that we want to include a ComboBox in our view that allows the selection of these enum values and whose SelectedValue property binds with a property of our view model, in xaml terms:


So we need to add a property to our ViewModel called UserTypes that will enumerate our enum’s values so that they can be displayed in the combo box. We also need a property called UserType that will bind to the ComboBox’s selected value like this:

//
public IList UserTypes
{
    get
    {
        // Will result in a list like {"Tester", "Engineer"}
        return Enum.GetValues(typeof(UserType)).Cast().ToList();
    }
}
public UserType UserType
{
	get;
	set;
}
//

And that should do it…. But knowing WPF and XAML you will probably end up fighting with it for a good few hours! ;-)

Compiling / Building libJpeg for Windows

Here is a record of how I managed to build libJpeg for Windows, Visual Studio 2012:

1.) Download & unzip the source, I downloaded it from here:

http://sourceforge.net/projects/libjpeg/files/latest/download?source=files

2.) Launch the Visual Studio Command console. To launch it, search for ‘command’ in the start menu, and you should see something like ‘Developer Command Prompt for VS2012’, start this.

3.) in the command prompt cd to the directory in which the libJpeg source resides

4.) At the command prompt, run the following commands:

 
set INCLUDE=%INCLUDE%;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
copy jconfig.vc jconfig.h
copy makelib.ds jpeg.mak
copy makeapps.ds apps.mak
nmake /f makefile.vc  nodebug=1 libjpeg.lib
 

In the first command make sure to replace the path with your path to your installation of the windows SDK, you may have to look around for this… If you get an error like this:

.
makefile.vc(11) : fatal error U1052: file 'win32.mak' not found
.

Then you haven’t correctly specified the SDK path.

When the compile finishes you should see libjpeg.lib in the top folder.

.

Have a WPF application remember its size and position between runs

Sometime software development is all about doing the same things over and over again! I keep on forgetting how to get a windows application to remember it size and position in between runs, and I keep on re-finding this handy post that describes how it’s done:

http://stackoverflow.com/questions/847752/net-wpf-remember-window-size-between-sessions

The first answer always works like a charm – copy and paste city! ;-)

Thanks ChrisF!

thecorknews.ie wins Best Online Publication at the Irish Web Awards 2014

irish_web_awards_winner
We were very pleased to hear the thecorknews.ie won the ‘Best Online Publication’ award at the 2014 Irish Web Awards yesterday. Congratulations to The Cork News team!

We are especially proud as we helped Pride Design build the site some years ago. It was technically quite a challenging website to build but as always Drupal was up to the job!

Which OpenCV libraries do I need for VideoWriter ?

I am currently testing some video encoding times for a computer vision project that I am working on using the OpenCV video functionality in windows. I hate wrestling with all of the OpenCV library files, but to use VideoWriter you just need to use the following libs:

opencv_coreXXX.lib
opencv_highguiXXX.lib

Where XXX is the version number of the libs that you are using, so for example on the software project that I am currently working on, I need to include:

opencv_core246.lib
opencv_highgui246.lib

You will need to have the corresponding .dll files on your path as well to run your program.

Nasty Drupal 7 SQL injection vunerability

The register reported today about a nasty SQl injection vulnerability in Drupal 7 (in the Database abstraction API):

http://www.theregister.co.uk/2014/10/16/drupal_megavuln_sql_injection/

Better upgrade to 7.32!

Writing a Software Engineering Spec.? Ditch MS Word for an easier life.

I have been writing a lot of Software Engineering Specifications of late – requirements and functional specs and the like. Microsoft Word has been just driving me mad, it is the most infuriating piece of software ever written and seems to only get worse as time goes on.

I thought to myself, “Why am I putting up with this when there are so many other options available these days”, so I switched to LibreOffice Writer and I am much much happier and productive now.

So my advice to anyone struggling with the modern MS word – just give up and move to a better place! :)

The things a Software Engineer must sometimes do….

Today I am busy installing Windows XP (professional) and Visual Studio 6(!) onto a virtual machine, don’t ask…… I was sure I had seen the back of VB6…..

.

Integrating Intercom to cloud App keeps me out of trouble… (ARM NEON)

I have been busy over the last few days integrating Intercom into a client’s cloud app. I have integrated quite a few SaaS systems of late (and written not a few REST interfaces myself) and I am quite enjoying this integration as the data model is good and the REST interface is reasonably easy to use!

So far so good, and at least it keeps me out of trouble, the specific trouble I have in mind is to attempt to implement a visual programming front-end for the ARM NEON SIMD instructions using the very exciting noFlo Javascript library!!

The ARM NEON instructions are very powerful SIMD instructions that are very useful for optimising image processing and computer vision tasks on ARM devices. They are however quite difficult to use as each instruction has so many variants for the different input and output element types. I reckon it could be a problem well suited to visual/graph flow programming and as far as I can see the most capable people at those races are those in the noFlo team – I am getting seriously excited about their work!

Anyway back to Intercom for the moment!

Interesting group ‘Code for All Ireland’ setup as Chapter of Code for America

Recently a very curious new technology and software centric group called ‘Code for all Ireland‘ was set-up. In their words group aims to:

Code For Ireland develops apps and services to solve community challenges and problems to assist government / public sector bodies become more open, transparent and efficient.

From looking at their website, it is a little hard to figure out exactly who’s behind the group and what their strategy is for making government more open and efficient, but they have been set-up as a chapter of the more established Code for America group whose website is informative contains this Ted talk:

Anyway its an open group and their next meeting is to be held on Saturday 24th. of Feb. so if we want to find out more we should go along!