Microsoft Australia has a new programming competition, 200 hours (well, 160 hours as of writing this post) called DevSta. It's open to all Australians – professional programmer or not.
Competition Brief
In a nutshell, you have to make something that is is "old school/new cool", it confuses me somewhat. Read the full brief.
Prizes
First prize:
- Return economy airfares to Las Vegas for two people (approx. $7,000 RRP- based on flights from your nearest capital city).
- Five nights’ luxury accommodation, twin share at the Venetian Resort Hotel Casino (valued at $3,190 RRP).
- Two tickets to the MIX09 Developer Conference from 18-20 March 2009 ($3,000 RRP). MIX09 is an international conference for developers and business strategists. Hear from visionary keynote speakers, expand your technical knowledge at targeted sessions, and put it all to practice in hands-on labs and workshops.
- One copy of Microsoft® Visual Studio® 2008 Professional Edition with a 1 year MSDN Premium Subscription valued at $4,355 RRP.
- An Xbox 360 Elite Console package - with Halo® 3, Gears of War® and Saint’s Row games valued at $865 RRP! This premier Xbox 360™ console package includes a huge 120GB hard drive, a high-definition multimedia interface (HDMI) port, a high-definition cable, and a premium black finish. It also includes a black wireless controller and black Xbox Live® headset. It also has enough space for a whole library of Xbox Live Arcade games and downloadable high-definition TV shows, movies, music, and more - available from Xbox Live Marketplace.
- Samsung Omnia mobile phone valued at $849 RRP.
Second prize:
- One copy of Visual Studio 2008 Professional Edition with a 1 year MSDN Premium Subscription valued at $4,355 RRP.
- An Xbox 360 Elite Console package - with Halo 3, Gears of War and Saints Row games valued at $865 RRP.
- A Wireless Entertainment Desktop 8000 valued at $449.95 RRP. Including the ultimate rechargeable keyboard and mouse for Windows Vista and PC entertainment, this great package is designed to make it easier than ever to control PC media from your desk, your lap or even the comfort of your couch!
- A Xbox Live 12-Month Premium Gold Pack valued at $99.95 RRP.
Third prize:
- One copy of Visual Studio 2008 Professional Edition with a 1 year MSDN Premium Subscription valued at $4,355 RRP.
- An Xbox 360 Elite Console package - with Halo 3, Gears of War and Saints Row games valued at $865 RRP .
Fourth prize:
- An Xbox 360 Elite Console package - with Halo 3, Gears of War and Saints Row games valued at $865 RRP.
- One user licensed copy of Microsoft Visual Studio 2008 Professional Edition valued at $1,387 RRP.
Fifth prize:
- One user licensed copy of Microsoft Visual Studio 2008 Professional Edition valued at $1,387 RRP.
- A Wireless Entertainment Desktop 8000 valued at $449.95 RRP. Including the ultimate rechargeable keyboard and mouse for Windows Vista and PC entertainment, this great package is designed to make it easier than ever to control PC media from your desk, your lap or even the comfort of your couch!
Best Windows Mobile application prize:
- Two Samsung Omnia mobile phones valued at $849 RRP each.
- A Samsung 40" series 6LCD TV valued at $3,099 RRP.
It looks interesting, but the site scares me with all the "bling"
No Comments
TweetSaver has slowly been creeping into the CodePlex project for MahTweets over the last week or so, and now the first alpha release of it is live!

What is TweetSaver?
- Twitter + Screensaver
- Uses WCF to connect to MahTweets - you can have it on multiple machines with no extra API usage!
- Uses WPF for display
- Name is by Will, so blame him
It uses MahTweets (requires MahTweets "Alpha 3" and up - Alpha 3 is designated by Change Sets 4309 or higher) and WCF for communication (TCP endpoint). Just like MahTweets, TweetSaver will get tweets in real time as MahTweets pushes out the tweets via WCF, which means no more Twitter API calls are made!
The really cool part of this would be if you had one MahTweets 'server' (for lack of a better word), and TweetSaver on an entire office of computers. One connection/set of API calls could do an entire office (of…your twitter feed). If you went to any of the Australian Heroes Happens Here events, you'd have noticed they had lots of twitter screens setup, all logged into the Twitter webpage - this would get around having each one logged in, and look prettier ;)
Requirements
- .NET 3.0
- Twitter account
- Jabber (G-Talk will do) account preconfigured for IM with Twitter
- For TweetSaver to run correctly, MahTweets must be open
Installation
- Download
- Extract
- Run MahTweets, click allow to the Windows Firewall request (if you want TweetSaver to work) and configure MahTweets
- Right click on TweetSav.scr, and select 'Install' - no configuration is needed unless you want to try it out over a network
Disclaimer
You're downloading this of your own free will, so we take no responsibility if your computer crashes, hard drive self formats, you develop a drinking problem, and so on and so forth. While it is an "alpha" release, at worst, it should either crash itself or hog resources - nothing "deadly".
Download the release-build of changeset 4309
No Comments
Many multi-user applications require a database, be it a web app (probably more often a web app!) or win forms. In single user applications, often it is beneficial if there is a database (in speed, complexity and robustness), but the problem is distributing the database server. I've had a few applications that come bundled with MySQL, and it just plain ole sucks.
Some of the reasons for using a database in your application include
- Faster than flat file storage such as XML
- Can have complex relationships
- Can have varying datatypes that don't break an XML parser
- Can then later redeploy in another project, such as a website using SQL Server easier
One of the easier ways to distribute your winform/WPF application with a database is with Microsoft's SQL Compact Edition (SQLCE). It has a fairly low footprint, is very fast, and is reasonably powerful despite the reduced operations (which allows it to be fast/low footprint/etc). Visual Studio's deployment tools even allow you to check for the SQL CE prerequisite on the target machine before installing, and will download SQL CE if it isn't found!
Adding SQL CE to your project
Providing SQL CE was installed during your Visual Studio install (default install settings), to get a SQL CE database in to your project, all you need to do is add a New Item > Local Database to your project. This will automagically add the references your project will need to access SQL CE databases (although you'll still need Using System.Data.SqlServerCE;)


Double clicking on your new database in the Project Explorer will activate the Server Explorer, allowing you to add Tables to the database.

Using SQL CE
The way you access data is nearly identical to a normal SQL Server, except it all lives in the System.Data.SqlServerCE namespace, and usually has SqlCeClass rather than SqlClass. ie:
SqlCeConnection sqlCon = new SqlCeConnection(TestApp.Properties.Settings.Default.TestConnectionString);
SqlCeCommand sqlCom = new SqlCeCommand();
sqlCom.Connection = sqlCon;
sqlCom.CommandText = "SELECT * FROM TestTable";
SqlCeDataAdapter sqlDa = new SqlCeDataAdapter(sqlCom);
DataSet ds = new DataSet();
sqlCon.Open();
sqlDa.Fill(ds);
sqlCon.Close();
Using LINQ with SQL CE
In .NET 3.5, you can also use LINQ against SQL CE. Currently (VS2008) you have to use the SQLMetal tool from the Visual Studio CLI, then add the generated dbml file to your project (Add -> Existing Item)
SqlMetal SqlCeFileName.sdf /dbml:LinqClassName.dbml
In the new version of MahTweetsMediaHorn (correction, thanks Will), I'll be using my own database rather than relying on Windows Media Players database. The LINQ to select all the albums (after generated the dbml via SqlMetal) is..
Music db = new Music(MediaHorn.Properties.Settings.Default.MusicConnectionString);
var album = from a in db.Album select a;
listBox2.ItemsSource = album;
Any and all of the usual tricks for LINQ apply to SQLCE - once you generate the dbml via SQLMetal, it really doesn't care what is underneath. If you want to bind it properly to WPF with automagic updates for when the datasource updates, I strongly recommend looking into the very clever SyncLINQ by the equally clever Paul Stovell, which also supports Silverlight.
Deploying apps with SQL CE
As I mentioned, the Visual Studio "Publish" tool makes sure the target system has all the prerequisites before installing. SQL CE is automatically added to the list, but if you need to modify it, right click on your project, Properties, then down to the Publish tab, and the Prerequisites option will launch a new dialog.

Just make sure you distribute your application via Build -> Publish :)
No Comments
Ever noticed how some applications tend to hang when you perform an operation? For example in MahTweets (my Twitter client), it used to have a looong pause every time it updated the Tweet list, and often the application would go black, almost to the 'not responding' stage. The GUI and application logic shared the same thread, meaning a massive change in GUI or lots of processing in the logic would stop the other.
The way around this is to use a separate thread for anything that requires a lot of processing, or that is bottled by another factor (Disk IO, or network speed, etc).
public delegate void MyDelegate();
// This method could be the method behind a button.clickpublic void InvokingMethod()
{
Thread myThread = new Thread(new ThreadStart(new MyDelegate(MyMethod)));
myThread.Start();
}
public void MyMethod()
{
//Code to execute on new thread goes here
}
There is one caveat, your new thread cannot access the GUI because this could cause some serious synchronisation issues. The way around this (in WPF at least!) is to use the Dispatcher.Invoke method.
public void GuiMethod()
{
if (!Dispatcher.CheckAccess())
{
Dispatcher.Invoke(DispatcherPriority.Normal, new voidDelegate(GuiMethod));
return;
}
//Code that accesses the GUI
}
If you need to pass parameters, one (quick) way is with an anonymous delegate like below, I'll let you figure out the different ways to go about it though.
Thread t = new Thread(delegate() { MyMethod(MyParam); });
If you are having problems with concurrency and synchronisation, that's outside the scope of this post…start looking at wikipedia's article on threading, and go from there.
No Comments
My photo management tool of choice is Live Gallery (WLG): it's fast, free, and fairly featuresome.
One feature that is lacking however, is to upload to your own 'custom' gallery. Oh, sure, you can upload to Flickr, or Live Spaces, but honestly, who uses either of those services, pfft! Unfortunately, there doesn't seem to be a plugin API (yet?) for Live Gallery so it isn't possible to add your own image gallery service to upload - well, not as neatly as Flickr/Live Spaces.
Step 1: Add Your Gallery
To add your own custom gallery uploading to Live Gallery, we need to exploit the Online Printing functionality. Each printing service is actually defined in the registry, and the default "Print@Kodak" is a great starting point to seeing what data we need.
It is located at:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\PublishingWizard\InternetPho
toPrinting\DownloadedProviders\Print@Kodak
The registry values look like:
"displayname"="Print@Kodak"
"description"="Get Kodak photo quality prints from your digital camera!"
"href"="http://print.fotowire.com/webprint/xp/start.asp?WID=25900"
"icon"="fwPrint.ico"
To add your own, it is as simple as creating your own key inside of DownloadedProviders, however either Windows or WLG seems to delete the registry key after closing WLG. Instead of inside DownloadedProviders, create a Providers key (inside InternetPhotoPrinting), and then create your own Provider key, with the same sorts of values (displayname, href, description and icon) as the Kodak Provider.
It should look something like this image when you're done
There is another benefit to doing it this way, under the printing menu, you will now have 'Print', 'Order prints', and 'Order prints from foo'
Step 2: Prepare your gallery
While it is great we've thrown it a random URL, how do we know what data is actually being sent?
Thankfully Elmar Putz had figured out the XP Web Publishing Wizard (which is very, very similar), so that was most of the leg work done.
First, the page set in the Href in Registry. I'm going to cut to the chase and just list the HTML/Javascript, if you want more of an explanation, see Elmar's article (linked above). All you need to do is change the UploadURL and EndUrl
<html>
<head>
<script language="JavaScript">
var UploadURL = "http://mydomain/upload/";
var EndURL = "http://mydomain/aftertheupload.html";
function window.onload()
{
window.external.SetWizardButtons(0,1,0);
}
function window.onback()
{
window.external.FinalBack();
}
function window.onnext()
{
var xml = window.external.Property("TransferManifest");
var files = xml.selectNodes("transfermanifest/filelist/file");
for (i = 0; i < files.length; i++)
{
var postTag = xml.createNode(1, "post", "");
postTag.setAttribute("href", UploadURL);
postTag.setAttribute("name", "myfile");
var dataTag = xml.createNode(1, "formdata", "");
dataTag.setAttribute("name", "MAX_FILE_SIZE");
dataTag.text = "2000000";
postTag.appendChild(dataTag);
var dataTag = xml.createNode(1, "formdata", "");
dataTag.setAttribute("name", "action");
dataTag.text = "Save";
postTag.appendChild(dataTag);
files.item(i).appendChild(postTag);
}
var uploadTag = xml.createNode(1, "uploadinfo", "");
var htmluiTag = xml.createNode(1, "htmlui", "");
htmluiTag.text = EndURL;
uploadTag.appendChild(htmluiTag);
xml.documentElement.appendChild(uploadTag);
window.external.FinalNext();
}
function document.oncontextmenu()
{
return false;
}
</script>
</head>
<body>
<h2>Click Next to upload</h2>
</body>
</html>
The code for the page at UploadURL would look something like…
ASP.NET
String uploadDir = "Images/";
HttpFileCollection hpC = System.Web.HttpContext.Current.Request.Files;
for (int i = 0; i < hpC.Count; i++)
{
HttpPostedFile file = hpC[i];
if (file.FileName != string.Empty)
{
file.SaveAs(Server.MapPath(uploadDir + file.FileName));
}
}
PHP
<?php
foreach ($_FILES["pictures"]["error"] as $key => $error)
{
if ($error == UPLOAD_ERR_OK)
{
$tmp_name = $_FILES["pictures"]["tmp_name"][$key];
$name = $_FILES["pictures"]["name"][$key];
move_uploaded_file($tmp_name, "uploadDirectory/$name");
}
}
?>
Step 3: Reading the file (optional)
If you're writing your own gallery, or simply just want a way to avoid having to FTP in to upload files, it may look as if you've lost the meta-data (specifically I mean tags) from your photos. Fear not, however, as there is a way!
All the tags are stored in 'XMP' format, which is essentially just embedded XML.
.NET 2.0
In .NET 2.0, there is no native way to read in XMP Information, so we need to use some XML parsing to get it. Microsoft blogger Omir Shahine, has a great post on accessing XMP data in .NET 2, including the code/general discussion on the matter.
.NET 3.x+
In .NET 3 and above, inside the Windows Imaging Component, there is the BitmapMetaClass. However this is both more and less complex than using regular expressions (above), in that you nave to use the proper 'paths' for accessing specific data. I won't cover it here, but WIC/BitmapMetaClass is what you should look into if you want the .NET 3+ method of accessing XMP/EXIF data.
PHP
Like .NET 2, there is no native way to read in XMP information. The below code will return an array of XMP Tags.
<?php
function GetTags($filename)
{
$handle = fopen($filename, "r");
$image = fread($handle, filesize($filename));
fclose($handle);
preg_match("/LastKeywordXMP>([\w\W\t\f\s]*)LastKeywordXMP>/i", $image, $matches);
$tags =split("</rdf:li>",$matches[1]);
for ($i=0;$i<count($tags);$i++)
{
$tags[$i] = trim(strip_tags($tags[$i]));
}
return $tags;
}?>
Final Notes
Since there isn't an authentication option in the printing wizard, security is a concern, particularly in a multiuser environment. You could implement any/all of the following however
- Since it is just HTML, there is absolutely no reason that you couldn't add in a HTML form for entering the username and password as the "first stage". The second page would be returned from the server, with the (javascript) settings to allow uploading. It is a hosted IE session, so it should store/access cookies - if they've logged in via IE, they should remain logged in!
- create a 'secure private' hash and append that to the url, ie http://mygallery/upload.php?hash=DADGGSDGFS123
This would mean user would have a separate (auto-generated I'd assume…) REG file to import
- IP based filtering (okay idea, sucks if your IP changes, or if you're on a public network)
1 Comment
I'm not sure if xBlend 2.5 was announced recently, but I happened to see it in one of the slides from the Mix08 keynote, thanks to Long.
Expression Blend 2.5 March Preview supports Silverlight 2 Beta 1, and SL2B1 has a lot more WPF UI Elements in it. For me, this is really exciting, because I really didn't want to be creating buttons, list boxes, etc. If I'm going to create a control, it isn't going to be a 'fundamental' control. Before now, Silverlight 1.1/2 to me was awesome, but pointlessly tedious to develop.
Apart from that exciting news, Expression Studio 2 Beta has been released! The biggest thing that stands out for me is xWeb2 now has PHP Support! That's a huge step in the right direction, and seemed to be one of the biggest complaints at Remix last year.
2 Comments
AMIM
A long time ago I tried making a MSN Messenger (/Windows Live Messenger) service client, using WPF. This was certainly fuelled when Yahoo announced their WPF client for Yahoo's IM Network. Unfortunately, my C# skills at the time certainly did not extend to making a library capable of connecting to MSNP reliably, particularly the later and more interesting versions (ie, v11+). I turned to the MSNPSharp library (which is based on DotMSN), but unfortunately I had difficulty following the logic of it (different authors between MSNPSharp and DotMSN I believe led to some inconsistencies in the code), and with no documentation, I eventually abandoned the project.

The above picture is actually 'live', connected to WLM. Sending/Receiving messages works fine, its just any other automated data that usually crashes it out. Display Pictures worked at one stage, but only from the official client, not Trillian and the like.
Introducing Wabber
Over the past few days/weeks, I was toying with making my own Twitter client like Will, and he suggested a really cool idea of using the 'instant notification' method (rather than scraping 70 times/hour) by connecting via XMPP (GTalk).

To understand the Jabber-Net library, I've sort of blown it more into a Jabber client than just a small addition to my twitter client, named Wabber. It currently only connects to Google's Gmail/GTalk server (hard coded for simplicity), so you'll need an account to get started.
Features
- Filtering contacts (ie, "Search for contact" instantly)
- Yahoo style "tiling of contacts"
- Yahoo style of "resize shows/hides details" (not shown in this version though)
To Do for vNext
- vCard decoding/processing so names are prettier, which will let me show avatars, proper names, etc.
- Simplify multiple contact logins to a single contact, rather than one for every presence (including offline!) notifications
- VoIP (via Jingle)
- Logging
- Error handling/notification of failed logins/etc
- Add/Remove contacts
- "Conversation Manager" doesn't always associate the same person
- Moving of window
- etc
Download
Executable download
(Source to follow, need to add documentation, and more importantly, error handling)
No Comments

In Year 9 at Melbourne High School, the programming (Software Design, I think it was called) subject was Visual Basic 5 or 6, but the book the school has produced for it was based on VB 3 or 4, with screenshots from Win3.11 days (I think?). There were errors upon errors, which as a good student (going through awkward teenage years, who could do with the ego boost from being right) reported each mistake, correcting most of them. The subject was one short semester long, and the second semester students benefited from my fixes - the manual they received had a different colour cover signifying it had updated screenshots, and the code was correct. I enjoyed and dreaded these classes. I was a better programmer than any other in the class, but the subject bored me so much that my academic performance in the subject suffered.
Year 10 was an interesting year for me, both academically and personally. That year I had several weeks off school (or more importantly, off my feet) due to a rather sizable operation on my feet to fix (which it did) chronic ingrown toenails, and later in the year my chronic cough returned which ended the year for me. Before all of that happened however, the programming unit this year involved Turbo Pascal 6. While not the most powerful language, it was a fantastic teaching language. Our "group"/major assignment was to create a basic game. I use the term "group" loosely, as the guy I was partnered with played cards all class, such that I wrote all of the code (except the unit included from Reinout Raymakers).
My assignment was Snake2K+1 (yeah, fantastic title…), which I've recently rediscovered the source code/compiled exe.
It weighs in at about 500 lines of code (from memory it was nearly double the rest of the class which was made up mostly of hangman) and had more colours than the teacher said was possible (he said 256 colours was the limit of Turbo Pascal…mine can handle up to 32,000 colours).
Back in those days, Melbourne High ran entirely off floppy drives (despite having network share capability). When I finally decided to remove all floppy disk drives from the house, I went through and backed everything up onto hard drives. Despite doing that, I had hidden the source code, and it wasn't until recently that I found it while backing up another computer to my wife's laptop.
The next challenge was to get it to run under Vista, which I took a gamble on…and got it to work under DOSBox, albeit with major speed issues. I'll look for a Turbo Pascal compiler so that I can get it running at a decent speed, but for now…

Download
Source Code & Executable
Don't forget to use DOSBox to get it to run!
No Comments
edit: weird wordpress error made this private rather than published, oops.
Given I'm now a MSP who isn't able to do the usual running of sessions, I thought I'd write some blog posts aimed at sharing code/techniques to achieve some coolish things. The first of which will cover how I set the custom status in Windows Live Messenger.
Requirements
- Windows Live Messenger (v8+ should work) with "Show What I'm Listening To" enabled
- Visual Studio (C# Express or greater)
Introduction
Windows Live Messenger (WLM) has the ability to set status messages in two forms, "Personally Messages" (PSMs) where the user sets their status themselves, or "Now Playing" (NPM) messages which can be set programmatically and will be the the focus of this article. While you can set PSMs programmatically, it isn't nearly as interesting, and has some side effects (such as overwriting the original PSM).
Windows Media Player has a "Now Playing" plugin which sets the NPM to the song currently being played. Similar plugins exist for other media players such as WinAMP. There are other uses, such as letting friends know what games you're playing.
How it works

WLM "listens" to Dynamic Data Exchanges over the Windows Messaging Layer; that is, external programs (or addins) pass a message to WLM which then sets the status itself. There isn't a specific managed method for DDE, so Platform Invoke (P/Invoke) is needed. PInvoke allows you to call unmanaged functions within managed code. If you haven't specifically used PInvoke before, it can look a little weird, so here's an example
using System.Runtime.InteropServices;
[DllImport("user32.dll", SetLastError = true)]
private static extern int FindWindow(String lpClassName, String lpWindowName);
This would then allow us to use the function FindWindow from the user32.dll. Our little application uses functions from User32.dll, FindWindow, FindWindowEx, and SendMessage. FindWindowEx finds the WLM "Window" so it know where to send the message, and SendMessage (funnily enough) sends the message.
WLM requires a specific format of the, but within that format there is a bit of wriggle room. You get to send a "format" parameter, which can look like "I'm playing {0} by {1}" where {0} and {1} represent the next two parameters.
I've attached the source code, which includes a sample application, for changing the NPM message. It's all fairly straight forward so there really isn't much more I can write in this article.
Download
Credits
Notes
Lots of applications still use DDE despite it being "superseded" by other communication techniques. I'll come back to DDE in another article, and look at the alternatives.
No Comments
Thanks to encouragement from Nicholas Ellery, I'm now a Microsoft Student Partner, and I'll make a rather unusual one at that because of my health/study status - that is, I'm an off-campus student.
Long story short, I'm to help out Nick with Uni related competitions/etc from Microsoft, and generally try and replace Nick Hodge as a Professional Geek/Enthusiast Evangelist for Microsoft. In return I get some pretty cool stuff, on top of the benefits I'll get form having this on my resume.
- Flown to attend Tech.Ed
- Invited to various other Microsoft events
- A free MSDN subscription (valued at ~$4000)
- An MSDN Welcome pack
- Preferential treatment in recruiting for technical graduate roles at Microsoft
- To be part of the most fun group of people you ever met (seriously)
(source)
On a side note, my finger is still sore from where I mauled it, so the other posts I've been making lately have been just clearing out the backlog. I do have a few code examples/walk-through's lined up for when my finger heals and I can type without pain again.
3 Comments