Richard Hopton

The random tech ramblings of Richard Hopton

SEARCH

  • Home
  • Posts RSS
  • Comments RSS

NxtGenUG Fest 10

Monday, 5 July 2010

NxtGenUG are pleased to announce their annual conference Fest10 will be taking place on Bournemouth Pier this year on Friday the  16th July 2010 – It’s a great opportunity to take the family to the Seaside  for the weekend, and catch up on technology. The best thing is attendance to the conference is free to members and just £59.95 for non-members.
 
Speakers
We have a great speaker line up this year, Google’s Jon Skeet will be talking about C#, Microsoft’s Glenn Block is coming over from Redmond to talk about MEF, Ryan Simpson will be giving us the lowdown on F#. We’ll also be having NxtGenUG veterans Mike Taulty, on OData and Chris Hay on Azure, Plus Marcus Perryman will be talking about one of the hottest technologies this year Windows Phone 7.
 
You can find a list of speakers and their sessions here
http://www.nxtgenug.net/fest10/Sessions.aspx
 
To register simply go to the following link and follow the instructions on screen.
http://www.nxtgenug.net/fest10
 
Parking, Hotels and Timings
Upto date Details on parking, hotel accommodation and timings for the day can be found on the Fest10 site. The nearest parking for Bournemouth Pier is either in the Bournemouth International Centre (BIC - 20) car park, the Bournemouth Pavilion car parks (19/24) or the car park next to the Royal Bath hotel (18). However, there is also further car parking available at Eden Glen car park (21), Winter Gardens car park (22) and Beacon Road car park (25). For Hotels, the RusselCourt is where the evening entertainment will be Quote: NxtGenUG when booking, otherwise Bournemouth has a large amount of hotels, including the Best Western Hotel Royale.
http://www.nxtgenug.net/fest10/
 
Geek Dinner
It's the Fest10 geek dinner - normal rules apply - pay for your own food/drink, and engage in great conversation, and eat fish and chips at Harry Ramsden’s. To register for the geek dinner
http://www.nxtgenug.net/ViewEvent.aspx?EventID=322
 
Post Fest Party
We’ll also be having a post Fest Party at the RusselCourt Hotel – If you’ve brought your family down for the weekend feel free to bring them along. Just register on the site and drop us an email on how many people you’ll be bringing with you to enquiries@nxtgenug.net
http://www.nxtgenug.net/ViewEvent.aspx?EventID=325
 
Sponsorship
NxtGenUG would like to thank DevExpress, our gold sponsor, along with Microsoft, RedGate, PluralSight and Apress for their support in making this event possible.

23:57:00 | | 0 Comments

Silverlight Master Class

Wednesday, 28 April 2010

The Silverlight Tour comes to the UK – and it’s called the Masterclass!

This 3 day hands-on training with both designer and developer tracks looks awesome and (uniquely) has two expert trainers per course. 

Currently scheduled in London, Manchester, and the Midlands for June, all courses also come with the chance to win an xbox 360, and Silverlight Spy licences!

Early bird discount of £100 if you book in May, and if you are a member of #SLUGUK or #nxtgenug there are additional discounts to be had.

Full Details are here: http://silverlightmasterclass.net

In addition bbits are holding a raffle for a free ticket for the masterclass. To be eligible to win the ticket (worth £1095!) you MUST paste this text, including all links, into your blog and email Ian@bbits.co.uk with the url to the blog entry.  The draw will be made on June 1st and the winner informed by email and on http://silverlightmasterclass.net

15:54:00 | | 0 Comments

Changing the language of a DevExpress XtraGrid

Thursday, 11 February 2010

Until recently most desktop applications were written in one language, and for the most part this was English.  With the advent of the internet in almost every home more frequently applications would appear on the market in multiple languages, some even giving the end-user a mechanism to translate it to their own language.

Fast forward to 2010 where most are written in multiple languages and often global enterprises will only buy software that either is or can be translated into other languages.  This of course brings a set of challenges for developers who for the most part only know a few languages and the majority of those are programming not spoken ones.  These challenges are even more apparent when 3rd party components are used, such as data grids, editors and such like because translating these isn’t so obvious.

We use the DevExpress XtraGrid which are very configurable so I was shocked to see this code in our app to change the filter popup text:-

private void gridView1_ShowFilterPopupListBox(object sender, FilterPopupListBoxEventArgs e)
{
//Custom
((FilterItem)e.ComboBox.Items[0]).Text =
_localisedResourceProvider.GetStringResource("GridControl", "FilterPopup.CustomText");
//Blanks
((FilterItem)e.ComboBox.Items[1]).Text =
localisedResourceProvider.GetStringResource("GridControl", "FilterPopup.BlanksText");
//Non blanks
((FilterItem)e.ComboBox.Items[2]).Text =
localisedResourceProvider.GetStringResource("GridControl", "FilterPopup.NonBlanksText");
}
This was more worrying that it didn't ALWAYS work correctly and sometimes would except killing the application.  Having used the DevExpress controls for many years I knew their had to be a better way, and their was in the form of the DevExpress.XtraGrid.Localization.GridLocalizer base class:-
public class XtraGridLocalizer : DevExpress.XtraGrid.Localization.GridLocalizer
{
LocalisedResourceProvider _localisedResourceProvider;
public XtraGridLocalizer(LocalisedResourceProvider localisedResourceProvider)
{
_localisedResourceProvider = localisedResourceProvider;
}

private XtraGridLocalizer() { }

private string GetLocalizedResourceString(String resourceId)
{
return _localisedResourceProvider.GetStringResource("GridControl", resourceId);
}

public override string GetLocalizedString(DevExpress.XtraGrid.Localization.GridStringId id)
{
switch (id)
{
case GridStringId.PopupFilterCustom:
return GetLocalizedResourceString("FilterPopup.CustomText");
case GridStringId.PopupFilterBlanks:
return GetLocalizedResourceString("FilterPopup.BlanksText");
case GridStringId.PopupFilterNonBlanks:
return GetLocalizedResourceString("FilterPopup.NonBlanksText");
// and so on
}
return base.GetLocalizedString(id);
}
}
To use this new localizer all you need to do is this and your done...
DevExpress.XtraGrid.Localization.GridLocalizer.Active = 
new XtraGridLocalizer(localisedResourceProvider);
Nice huh?! for more info visit XtraGrid - UI Localization

10:45:00 | | 0 Comments

Test-driven Development for Beginners

Tuesday, 6 October 2009

On October 6th 2009 I delivered a session at NxtGenUG in Oxford titled Test-driven Development for Beginners. It was a little last minute as the original speaker had to drop out due to illness, and although not fully rounded it was great to do a bit of live coding.

00_Title 02_ThePlan 03_WhatIsTDD 04_TDDGuidelines_1 04_TDDGuidelines_2 04_TDDGuidelines_3 05_The3StepsOfTDD 06_TDDBenefits 07_TDDFrameworks 08_MSTestSyntax_1 08_MSTestSyntax_2 09_TDDApplication

Code samples can be found here

I hope everyone enjoyed the session as much as I enjoyed delivering it.

23:49:00 | | 0 Comments

Responding to media/presentation buttons in WinForms and WPF

Saturday, 29 August 2009

When I first got a laptop I naturally got the obligatory wireless notebook mouse with an included dongle but on two separate occasions I managed to break the dongle. After going through two mice I thought it was about time to buy a mouse without a dongle and stumbled across the Microsoft Wireless Notebook Presenter Mouse 8000 which could connect to my laptops internal Bluetooth radio.

One of the great things about it is the handy presentation buttons and I always wondered how I could go about adding logic to my applications to respond to these buttons. After a set of tweets in Jan 2009 and earlier this month and some outreach through StackOverflow all came up with nothing I decided to see if I could find out myself.

After searching for “Handling IntelliPoint mouse buttons C#” on Google I stumbled across this page which had a good explanation for how IntelliPoint & IntelliType deals with the media buttons on the Microsoft keyboards and mice. I fired up the the sample application and pressed each of the buttons on the underside of the mouse in order (previous, next, volume down, play/pause and volume up) and got the following information back from the it (oddly it shows these messages as coming from the Keyboard/OEM device and not the mouse):-

image

This prompted a search for “WM_APPCOMMAND APPCOMMAND_MEDIA_NEXTTRACK c#” which got me to this forum thread. Being a Delphi programmer I knew all about WndProc and used the suggested method to capture the button presses I was interested in using this page to find the different APPCOMMAND_ values to handle:-

protected override void WndProc(ref Message m)
{
if (m.Msg == 0x319) // WM_APPCOMMAND message
{
// extract cmd from LPARAM (as GET_APPCOMMAND_LPARAM macro does)
int cmd = (int)((uint)m.LParam >> 16 & ~0xf000);
switch (cmd)
{
case 9 : // APPCOMMAND_VOLUME_DOWN
MessageBox.Show("Volume down");
break;
case 10: // APPCOMMAND_VOLUME_UP
MessageBox.Show("Volume up");
break;
case 11: // APPCOMMAND_MEDIA_NEXTTRACK
MessageBox.Show("Next track");
break;
case 12: // APPCOMMAND_MEDIA_PREVIOUSTRACK
MessageBox.Show("Previous track");
break;
case 14: // APPCOMMAND_MEDIA_PLAY_PAUSE
MessageBox.Show("Play-Pause");
break;
default:
break;
}
}
base.WndProc(ref m);
}

This was all well and good but my application is written in WPF and there is not WndProc to override in WPF. After a quick search for “WndProc WPF” I found this page and implemented the solution as before using his post as guidance:-

public Window1()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(Window1_Loaded);
}

void Window1_Loaded(object sender, RoutedEventArgs e)
{
HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
source.AddHook(new HwndSourceHook(WndProc));
}

private static IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if (msg == 0x319) // WM_APPCOMMAND message
{
// extract cmd from LPARAM (as GET_APPCOMMAND_LPARAM macro does)
int cmd = (int)((uint)lParam >> 16 & ~0xf000);
switch (cmd)
{
case 9: // APPCOMMAND_VOLUME_DOWN
MessageBox.Show("Volume down");
handled = true;
break;
case 10: // APPCOMMAND_VOLUME_UP
MessageBox.Show("Volume up");
handled = true;
break;
case 11: // APPCOMMAND_MEDIA_NEXTTRACK
MessageBox.Show("Next track");
handled = true;
break;
case 12: // APPCOMMAND_MEDIA_PREVIOUSTRACK
MessageBox.Show("Previous track");
handled = true;
break;
case 14: // APPCOMMAND_MEDIA_PLAY_PAUSE
MessageBox.Show("Play-Pause");
handled = true;
break;
default:
break;
}
}
return IntPtr.Zero;
}

I didn’t feel right about adding WndProc in WPF and wondered if there might be a better way. I then remembered that in WPF there are a bunch of MediaCommands that can be used with CommandBindings in XAML linked to methods in the code behind so I gave it a shot and it worked a treat.

The XAML…

<Window.CommandBindings>
<
CommandBinding Command="MediaCommands.PreviousTrack"
Executed="PreviousTrackCommandBinding_Executed"/>
<
CommandBinding Command="MediaCommands.NextTrack"
Executed="NextTrackCommandBinding_Executed"/>
<
CommandBinding Command="MediaCommands.TogglePlayPause"
Executed="TogglePlayPauseCommandBinding_Executed"/>
<
CommandBinding Command="MediaCommands.DecreaseVolume"
Executed="DecreaseVolumeCommandBinding_Executed"/>
<
CommandBinding Command="MediaCommands.IncreaseVolume"
Executed="IncreaseVolumeCommandBinding_Executed"/>
</
Window.CommandBindings>

...and the code behind

private void PreviousTrackCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("Previous track");
}

private void NextTrackCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("Next track");
}

private void TogglePlayPauseCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("Play-Pause");
}

private void DecreaseVolumeCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("Volume down");
}

private void IncreaseVolumeCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("Volume up");
}

I hope this post helps someone… I know there are a few other intrigued by my questions!

00:19:00 | | 0 Comments

Older Posts
Subscribe to: Posts (Atom)


  • Blog Archive

    • ▼ 2010 (3)
      • ▼ July (1)
        • NxtGenUG Fest 10
      • ► April (1)
        • Silverlight Master Class
      • ► February (1)
        • Changing the language of a DevExpress XtraGrid
    • ► 2009 (21)
      • ► October (1)
        • Test-driven Development for Beginners
      • ► August (2)
        • Responding to media/presentation buttons in WinFor...
        • TDD Scholarship For Me?
      • ► May (7)
        • NxtGenUG – From Here To Entity
        • TDD for Beginners – Completed
        • TDD for Beginners – Building the Diamond, part 2
        • TDD for Beginners – Building the Diamond, part 1
        • TDD for Beginners – Input Validation
        • TDD for Beginners – Introduction
        • My #dddscot Sessions
      • ► April (5)
        • WebDD
        • My DDD Scotland Session Plan
        • Fluent Interfaces and Immutable Types
        • NxtGenUG - DLS's in C# 3.5
        • Effective C#: 50 Ways To Improve Your C#
      • ► March (2)
        • Now Thats What I Call… Twittering
        • NxtGenUG - This One Goes Up To 11...
      • ► February (1)
        • The Developers Group (16th February)
      • ► January (3)
        • Installing Windows Home Server, finally!
        • Object Serialization: XAML vs. XML
        • Visual Studio 2008: “The application cannot start”...
    • ► 2008 (3)
      • ► December (3)
        • What happened to “Installing WHS, Part 2”
        • Installing Windows Home Server, Part 3
        • Installing Windows Home Server, Part 1

    Ads



Richard Hopton © 2008 Free Premium Wordpress Themes and BlackQuanta | Bloggerized by : GosuBlogger | Adjusted by : Richard Hopton