How to create your own commands and bind them in WPF – Edward Tanguay's piece on commands and WPF… I know that they are supposed to be awesome, but I haven't taken the time to sit down and figure them out yet.
This is an extension of my previous post, WPF Wiimote Library (Now With Project Files!), which has links to the WPF Wiimote Binding Library project files as well as some information vital to getting you started in connecting your application to the Wiimote.
And now for the IR properties:
The Wiimote can track up to 4 infrared (IR) LEDs at a time. If I were a programmer, I would have created an IR LED enum with the following properties as part of each IR LED. But since I’m not, these properties can be accessed with the following convention: IR[#][propertyName]. Each IR LED has the following properties:
IR[#]RawPosition
Type: Point
Summary: The IR camera has a X,Y resolution of 1024, 768. This property will give you the raw X,Y position that the Wiimote is tracking this LED at.
Additional Info: This will work best if your Canvas is the exact dimensions of the Wiimote camera (1024, 768). These properties are automatically converted to take into account the IsMultiPoint setting (described in the Miscellaneous Properties (coming soon)).
IR[#]Position
Type: Point
Summary: This is the X,Y ratio of the position of your IR LED. The best way to use this is in a multi-binding with the width and height of your target Canvas. Fortunately for you, I’ve added a converter that will help with this. Simply add the following code in your resources:
Additional Info: These properties are automatically converted to take into account the IsMultiPoint setting (described in the Miscellaneous Properties (coming soon)).
IR[#]Found
Type: boolean
Summary: This is a property that is “true” if the Wiimote can see the target LED and “false” if it cannot.
Additional Info:This property is also available for the midpoint between the first and second infrared light (MidPointFound) and for the target point (TargetFound) which displays a calculated position of where the Wiimote is being pointed.
IR[#]Size
Type: double
Summary: The Wiimote naturally picks up the size of the LED it is tracking. To get larger sizes(which translates into better reliability) use a small cluster of LEDs (three should do the trick) rather than a single one.
Summary: This item is meant for two way binding. If you want a way to programmatically choose whether or not to show the item that is bound to your IR interface, use this property. It is most useful when used in conjunction with the BoolToVisibility Converter, which can be used by placing this XAML in your resources:
Additional Info:This is a great property to attach to a checkbox (as seen above) to allow user control over which items are to be shown.
In addition to the infrared lights, the WPF Wii library is set up to display two calculated points as well:
A midpoint between IR1 and IR2
A target point (based on the midpoint) which indicates where the Wiimote is being pointed.
These two calculated points still have the position properties listed above (TargetRawPosition, MidPoint RawPosition, TargetPosition, MidPointPosition) as well as the visibility booleans (IsTargetVisible and IsMidPointVisible) and the “found” boolean properties (MidPointFound and IsTargetPossible).
Of course, you can also play around with the items in Intellisense is also a great way to discover all the available properties.
Now that we’ve successfully demoed the Wiimote visualizer in the Open Space at MIX 08 and shown off what we can do at the Show Off event, I need to be a responsible blogger and put the project up… files and all. I have, with Brian Peek’s permission, packaged his managed library in here as well. Please read and respect his licencing agreements.
There are really two parts to the WPF Wiimote Visualizer. The first part is the WPF Wiimote Binding Library, which we’ll cover in this post (or at least make this post the hub of that information). The second part is the Visualizer program itself, which is basically just the WPF Wiimote Library bound to a bunch of XAML elements.
The WPF Wiimote Binding Library will allow simple binding between your Wiimote and your WPF application (I’ve got a whole post on that here). But let me extrapolate a little on what the library has to offer. I’ve seperated out the data into different posts to make it a little more digestible.
Over the weekend, I pieced together a little application that will help us visualize the incoming Wiimote data in a way that would help understand the raw data points a little better as well as help out as we head toward our ultimate goal of multi-point WPF application development. This is what I came up with.
Disclaimer: The source code at this point is a mess. While the interface is all done in XAML and is very WPF, the code-behind is a hacked together mish-mash. I will at some point go back and restructure the code-behind to take advantage of the INotifyPropertyChanged interface. When I do that, I’ll post on it and we’ll see another example of why WPF is so freaking cool.
OK, so I’ve taken note of multi-point WPF a couple times now (both times were in regards to Rick Barraza’s Cynergy demo) and I started noticing that people are really interested in this. So I decided to take some time to create a couple tutorials on creating multi-point interfaces in WPF.
A point of note: I am not a programmer. I am a designer. This means that whatever code I post will probably be a mess. But it also means that if I can make something work in WPF, anyone can.
The first question we need to address is how to pull multi-point interaction data into your system. You could, of course, buy one of these. I don’t have that kind of money, so I decided to try my hand at the poor man’s multi-point: the ever useful Wiimote controller for the Nintendo Wii.
In this post, we’ll go over how exactly to connect your Wii controller to your computer via Bluetooth. (I’m using Vista. Could be different for XP, but I haven’t tried.)
First, open up your Control Panel and double click on “Bluetooth Devices”