Remote Control 0.7.0-Beta2

By Jerome at March 17, 2007 14:43 Tags:

Download here this new release 0.7.0-Beta2.

Since it's snowing a bit in Montreal, I've had a bit of time to look around problems on the 0.7.0-Beta1 problems.

Most of the reported problems were about Widcomm support. The stack was crashing randomly on server shutdown... I hate those API that don't do what they should : Close means close, and you should be able to destroy the object. Well, not with the widcomm API. Some worker thread is still trying to tell by callback that the connection is being closed... This is a bit annoying where there is no connection !

Anyway, this new Beta should fix this. There's also now in the stats bar a "bluetooth" status, whether it is using Microsoft Stack or Widcomm Stack.

I'm also working on some remote display of the PC screen, and to have some commands executed upon Bluetooth status change... This should be cool ! Wait and see !

Bluetooth Remote Control for Windows Mobile 0.7.0-Beta1 : Widcomm Support

By Jerome at March 08, 2007 18:01 Tags:

There it is ! The support for the Widcomm bluetooth stack on the desktop side.

Download it here : Bluetooth Remote Control for Windows Mobile 0.7.0-Beta1

For now, this is a beta release, but this should work fine. You can now use Bluetooth Remote Control along with your A2DP headphones :)

On the dev side, working with a event driven API with C++ can pose some problems... The widcomm API is pretty different from the Microsoft stack. I have to admit, I prefer the Microsoft way of doing things, where you can call a blocking Receive method, instead of being notified asynchronously by some random thread, where I prefer managing my own threads. Also, handles are not closed if you application crashes, leaving a connection or an advertised service as an orphan. Annoying during the debugging...

Well, it works now. Maybe next time I'll try to updated the mobile side...

Support for Widcomm Stack on the Way !

By Jerome at March 07, 2007 14:41 Tags: ,

This has been the main complaint since the first release of this little piece of software, and since Broadcom (formerly Widcomm) has released its SDK for Bluetooth communication, I'm now updating my software to support it.

Preliminary tests are conclusive, I'm going to include Widcomm stack support in the next release !

For those of you wondering where this SDK is, go download it here for both desktop and mobile sides.

Stay tuned :)

Spending some time in Montréal, QC, CA

By Jerome at March 05, 2007 13:22 Tags:

It's been a while since I've taken any vacations, and I decided to spend some time in a country I don't know : Canada. Montreal, to be a bit more specific.

It's the first time I'm crossing the atlantic and after seven and a half hour, we land in a snow storm. A big one, for what I've been told. 30cm in a few hours, which is more than the road services could handle. But unlike in Paris, where three centimeters of snow are disrupting the traffic, here people just drive slower and safer. Don't get me wrong, I'm not saying that french drivers are bad, only paris' ones :)

Anyway, with all that snow, I couldn't resist taking some pictures. Here is what we're having by the time I'm writing this post, there an other bunch of snow flakes whitening the streets. I don't really want to be outside at this moment :) The wind's push the snow kinda fast.

Fortunately, snow's not always falling from the sky. This is a picture taken from the "La Fontaine" park, where you can experience some ice skating on a frozen lake. I'll definitely try that one !

Drivers have to be handy with the shovel... You can see most of them getting outside their parking lot using the accelerator to go over the huge amounts of snow being pushed by the side by snow plows.

There are a lot of bikes here and there. The fun part is seeing all of these half inside the snow...

I'm intrigued by these big things on top of electric pylons... Anyone knowing what this is ?

Anway, this seems to be quite a nice country. We'll be visiting more parts of the city in the next few days. I'll try to post some more picture here :)

Rest in Peace, TuO

By Jerome at February 26, 2007 02:38 Tags:

Jean-Michel Hervé, aka TuO, has left us yesterday. I've worked with him a few times during my demomaking years when I was an active member of Orion, and I had a lot of respect for the guy.

He was a particularly gifted coder, and will be remembered for many things like the excellent VIP2 invitation demo released in June 2000 when he was a member of the PoPsY TeAm. Lately, he was working in lyon as a developer at Eden Games.

Rest in peace, my friend.

Atlantic Shores of France

By Jerome at February 19, 2007 13:31 Tags:

If you've never been to france, there are some beautiful places facing the atlantic ocean that are worth visiting, for their calm and their beautiful shores.

Cabourg is one of them, and you can see here some shots I've taken there :)

WPF DataBinding and Application Settings

By Jerome at February 15, 2007 21:47 Tags: ,

Well, yet an other post on WPF and some DataBinding. But this time, this is about DataBinding to application settings that are automatically generated by visual studio. These settings come in handy when you want to save your application settings per user, or have some application wide settings. In my case, I wanted to have my application to remember its size and position, as well as the window state.

WinForms were providing an UI to do this, and I wanted to have all that functionality back. It is not all that "visual" as WinForms can do it, but it works rather well. I guess that Orcas will provide a way to do this visually.

All I had to do to use these settings from XAML was to create a resource to be usable for DataBinding, from a separate file :


File: SettingsRes.xaml



<ResourceDictionary xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation

                    xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml 

                    xmlns:settings = "clr-namespace:WindowsApplication2.Properties">

  <ResourceDictionary.MergedDictionaries>

    <ResourceDictionary>

      <settings:Settings x:Key="settings" />

    </ResourceDictionary>

  </ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

WindowsApplication2 is the default namespace for the application, and since the Settings class is automatically generated, the default namespace is used. This resource will be used application wide and is referenced like this :


<Application.Resources>

  <ResourceDictionary>

    <ResourceDictionary.MergedDictionaries>

      <ResourceDictionary Source = "SettingsRes.xaml"/>

    </ResourceDictionary.MergedDictionaries>

  </ResourceDictionary>

</Application.Resources>

This is handy because resources are separated in multiple files. I also add here references to value converters, when I have to use them everywhere in the application. Value converters, yet an other interesting subject. Maybe in an other post :)

Now, about binding the data. We want to bind the Width, Height and WindowState of the default Window to some settings in the ApplicationSettings.

Here's what to do :


<Window x:Class="WindowsApplication2.Window1"

        xmlns = http://schemas.microsoft.com/winfx/2006/xaml/presentation

        xmlns:x = http://schemas.microsoft.com/winfx/2006/xaml

        Height = "{Binding Source={StaticResource settings}, Path=Default.MainWidth, Mode=TwoWay}"

        Width = "{Binding Source={StaticResource settings}, Path=Default.MainHeight, Mode=TwoWay}"

        WindowState = "{Binding Source={StaticResource settings}, Path=Default.MainState, Mode=TwoWay}">

We create three bindings, each for an attribute, and set the source to the "settings" resource. The interesting part here is that the even thought the property we use is static, Settings.Default here, the Binding engine does seem to support it.

Setting the binding path to Default.MainWidth binds to the appropriate property. The last parameter instructs the binding to set the value of the property when the binding destination value changes, which can be the actual window height, for instance. The type of the property does not need to match the destination exact type, and since the type of the WindowState property is not known by VS2005 settings designer by default, setting the type to string seems to be enough.

Simple and easy. Now my application remembers where it was !

The sample here is a bit more complex, since it includes code to actually save the settings. But this is nothing really complex.

Man ! I like WPF... !

WPF DataContext and CurrentItem

By Jerome at February 13, 2007 15:23 Tags: , ,

DataBinding is one of the technologies I like the most. 

Winforms did a fine job introducing the concept, but it was pretty easy to be stuck when trying to perform complex databinding. .NET 2.0 brought the concept of BindingSource, which eased the management of multiple "Current items" on a single form. You might have encountered this when creating multiple master/detail views on the same form. That was the case when you wanted to walk through a set of tables through their relations, say down to three levels.

WPF has a far more advanced DataBinding engine and introduces the concept of DataContext. There's the notion of a hierarchy of DataContexts and a databound control uses the nearest DataContext available.

An example is better than a thousand words. Here's a data source :


<xmldataprovider x:key="ops" xpath="/data/level1">

  <x:XData>

    <data xmlns="">

      <level1 name="1">

        <level2 name="1-1">

          <level3 name="test">Some Value</level3>

          <level3>Yet an other value from level 3</level3>

        </level2>

        <level2 name="1-2">

          <level3>Some other Value</level3>

          <level3>Yet an other Value</level3>

        </level2>

      </level1>

      <level1 name="2">

        <level2 name="2-1">

          <level3>Some Value</level3>

          <level3>Yet an other value from level 3</level3>

        </level2>

        <level2 name="2-2">

          <level3>Some other Value</level3>

          <level3>Yet an other Value</level3>

        </level2>

      </level1>

    </data>

  </x:XData>

</xmldataprovider>


It's a three level hierarchy, and I want to display this data, by recursively selecting each level in a ListBox to see its content.

Now, let's bind this data to a list box, contained in a GroupBox to be a bit more readable :


<GroupBox Header="Level 1" DataContext="{Binding Source={StaticResource ops}}">

  <ListBox ItemsSource="{Binding}"

           DisplayMemberPath="@name"

           IsSynchronizedWithCurrentItem="True" />

</GroupBox>

This performs a binding to the attribute "name" of the level1 node list. The IsSynchronizedWithCurrentItem tells the listbox to set the CurrentItem of the current DataContext, which can be used to fill the next ListBox for the level.

Now, to add a new DataContext level, let's add a new GroupBox, and a stack panel to have a nice layout :


<GroupBox Header="Level 1"

          DataContext="{Binding Source={StaticResource ops}}">

  <StackPanel Orientation="Horizontal">

    <ListBox ItemsSource="{Binding}"

             DisplayMemberPath="@name"

             IsSynchronizedWithCurrentItem="True" />

    <GroupBox Header="Level2"

              DataContext="{Binding Path=CurrentItem}">

      <ListBox ItemsSource="{Binding}"

               DisplayMemberPath="@name"

               IsSynchronizedWithCurrentItem="True" />

    </GroupBox>

  </StackPanel>

</GroupBox>

Now, there is a new DataContext for any children of the second group box, and is having the CurrentItem of the upper DataContext as a root. This is fairly easy to do, so let's do this for the final level.


<GroupBox Header="Level 1"

          DataContext="{Binding Source={StaticResource ops}}">

  <StackPanel Orientation="Horizontal">

    <ListBox ItemsSource="{Binding}"

             DisplayMemberPath="@name"

             IsSynchronizedWithCurrentItem="True" />

    <GroupBox Header="Level2"

              DataContext="{Binding Path=CurrentItem}">

      <StackPanel Orientation="Horizontal">

        <ListBox ItemsSource="{Binding}"

                 DisplayMemberPath="@name"

                 IsSynchronizedWithCurrentItem="True" />

        <GroupBox Header="Level3"

                  DataContext="{Binding Path=CurrentItem}">

          <StackPanel Orientation="Horizontal">

            <ListBox ItemsSource="{Binding}"

                     IsSynchronizedWithCurrentItem="True" />

            <Label Content="{Binding Path=CurrentItem}" />

          </StackPanel>

        </GroupBox>

      </StackPanel>

    </GroupBox>

  </StackPanel>

</GroupBox>

Each time a new DataContext is set, a new CurrentItem is created. That kind of behavior was hard to reproduce using DataBinding with WinForms; WPF allows it only by using a simple declarative syntax. Easy and powerful.

Also there is a fine feature that came up when using this DataContext and CurrentItem : The CurrentItem "chain" for a specific path is -- when the data source does not change -- kept if you change the selection, and come back to that particular path. Pretty interesting.

Here is a working xaml sample of this post.

Did I say that a really like WPF already ? :)

Small blog update, with Url Rewriting

By Jerome at February 11, 2007 16:33 Tags:

Since this little website upgrade to add the blog, posts have been indexed by google with an ugly internal uniqueidentifier of mine.

Incidentally, that does not index well in google. Since the url to a post does not explain what the destination is about, I decided to add an url rewriting HttpHandler, to have the url containing the title of each post or category.

The part about writing the url rewriter has been covered over and over, oh and over, so I won't talk about it here.

Actually, I'm using CrystalTech web hosting -- like my brother Matthieu -- which works really fine, and does a fine job providing ASP.NET 2.0 services.

Their service is providing a tweaked Medium trust level to users, so hosted application have be configured that way. By tweaked, I mean that they re-enabled Reflection, Web, ODBC and OLEDB permissions from the Medium trust profile.

Anyway, you have to deal with Partially Trusted Callers. My application uses a class library in a separate assemnly, which needs to have the AllowPartiallyTrustedCallers attribute set, because of the Medium trust. That avoids this :

[SecurityException: That assembly does not allow partially trusted callers.]

So, if you choose CrystalTech web hosting, remember to try your website under the Medium trust profile to avoid suprises, with this :

<system.web>
   <trust level="Medium"/>
</system.web>

Also, on the side of differences between VS2005 web server and IIS 6.0 behavior : The default handler for any url in VS2005 is ASP.NET and in IIS 6.0 it is the file system. Since my urls are now generated, they definitely don't exist on the file system. I just had to add an ".aspx" at the end of my virtual url to get IIS 6.0 handing it to ASP.NET runtime.

Now I have my nice URLs :)

Sebastien Laban's new website

By Jerome at February 07, 2007 04:45 Tags:

My younger brother has updated his website, with his new demoreel 2007.

Go check it out here http://www.sebastien-laban.com !

About me

My name is Jerome Laban, I am a Software Architect, C# MVP and .NET enthustiast from Montréal, QC. You will find my blog on this site, where I'm adding my thoughts on current events, or the things I'm working on, such as the Remote Control for Windows Phone.