XAML Formatter
# Sunday, February 27, 2011

I’ve been doing a lot of XAML work lately on a WPF project, and the client is really concerned about sloppy / ugly XAML.  The one problem I found was that Visual Studio 2010 is not really all that great at formatting XAML and it certainly does not format it the way I want it formatted.  So I decided to write something that would do the formatting for me, I started with a PowerShell script that I used via PowerConsole.  Worked great, but with some free time I decided why not write a proper VS2010 extension.

The key principle behind the formatter is that it only concerns itself with indentation, not what should be on any given line.  Visual Studio does offer some options in this regard but the closest thing I could get to what I wanted meant that when I formatted, a typical style Setter was 2 or 3 lines.  Multiplying the size of a style by 2 or 3 times makes for a rather large XAML file, not ideal.  So you worry about what goes on what line, and I’ll take care of making it all nicely aligned. 

Comment indentation is not perfect yet, but it usable, maybe v1.1 will have some improvements.

I’m looking into V2 which will simply intercept the Format Code command.  I didn’t go this way in V1 because of the complexity around formatting a selection.  Currently I format the entire document.  When I finish V2 I’ll post both code samples.

NOTE: I originally wrote this extension back in early October 2010, so there might be a similar tool available now.

BEFORE:

PreFormatting

AFTER:

PostFormatting

Feedback: I’d love to hear some feedback, if you have something that does not format correctly and feel comfortable sending me the XAML snippet, please do.   Any questions, comments, or concerns can be sent to XamlFormatter@danno.ca

Download: You can download the latest version of the XamlFormatter from the Visual Studio Gallery

Sunday, February 27, 2011 4:50:48 PM (Eastern Standard Time, UTC-05:00)  #    Comments [4]Trackback
Restoring to a smaller drive using WHS
# Saturday, November 14, 2009

Just to get it out of the way, this will not work in a catastrophic failure situation.  You need to have the original hard drive (or at least a big drive to put it on to start).

 

I just bought an Intel X25-M SSD, what I didn’t realize when I bought it was that it was 160GB and my current drive is 180GB.  My original plan was to simply restore a WHS backup onto the new drive, but I quickly found out that this wouldn’t work.  WHS will only restore to a drive of equal or greater capacity, regardless of the amount of free space on the original drive.  So I figured I should be able to easily shrink the existing drive and restore it.

Vista and Windows7 both have a Shrink option in Computer Management, but it is terrible.  With 35GB of free space it would only shrink the partition by 635mb. 

There is a great article on How-To-Geek that shows how to work around this, none of it worked for me. 

I downloaded Easeus Partition Master Home Edition, which is free, and used it to VERY easily shrink the drive down to 150GB.  Took about 3 minutes and a reboot, it was just that simple.  Once that was done, just ran a backup the new drive (WHS will treat this as a whole new drive) then switched out the drives and did a restore on my new smaller drive.  Couple hours later I’m up and running on my new super fast SSD.

Friday, November 13, 2009 10:11:38 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]Trackback
New stuff
# Monday, July 20, 2009

h3013740_1 I know it has been a while since I posted anything here, my excuse is being busy with a new contract and a new house.  Just realized I don’t really have any pictures of the house but I will post some soon.

 

Also moved the blog over to www.discountasp.net and it was dead simple to get up and running and get dasBlog working on it.  Things might not be working properly for a while but I’m working on it.

Sunday, July 19, 2009 8:59:20 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [3]Trackback
Microsoft Research Stitching Tool
# Wednesday, April 15, 2009

I’m a little late to the game, but Microsoft released a stitching tool called Image Composite Editor (ICE, and please note my restraint in not naming this blog post ‘ICE ICE Baby’), this is also available in Live Photo Gallery apparently (don’t use it myself).  I’ve always used the tool that came with my Canon software because it was easy, but after taking a couple panorama shots in Death Valley while I was at Mix09, I became very disappointed.

  BoraxPano

You can see above the very obvious seems, and that is after I touched it up a little bit.  Destiny provided me link to ICE right after this failed experiment with the Canon tools and I tried it and was blown away.  It can do a lot of very cool things, and most importantly it merged my images without the slightest indication of a seem. 

ms_researchBorax

Tuesday, April 14, 2009 9:00:38 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0]Trackback
DailyLit + Little Brother == Goodness
# Monday, January 12, 2009

If the title of the post doesn’t make any sense to you, I’ll do my best to explain.

DailyLit, is a great site that will email you a few pages of a book every day. These books are all copyright free, either by author choice or due to the fact that they are old enough that the copyright has expired.  I started using the service to read Bran Stokers Dracula a few years back.

Little Brother, is the latest book by Cory Doctrow.  Doctrow is from Toronto and one of the founders of BoingBoing.net which is a great site for everything do with the internet and culture in general.  Doctrow is also big on copyright reform, he has a great short essay you can read on Locust that sums up his views, I strongly recommend you give it a read. 

Goodness, is that Doctrow decided to make his brand new book available to DailyLit, even though it had only been in stores for a few months.  I subscribed to it, but never got around to reading any of the emails for a few weeks so that 4 chapters had built up in my inbox.  Once I got reading it, I just couldn’t stop and immediately ran out to the book store and purchased it.  I have a tendency after reading a great book about important issues to make the grand statement of ‘this should be required reading’ and I made that statement after reading this book.  The book is a spin on 1984 and Big Brother, dealing with the war on terror in a slightly futuristic America. This book tackles the issue of privacy and freedom in the face of terrorism with a worst case scenerio that doesn’t feel too unbelievable.  Benjamin Franklin (coincidently and unrerlated to this book, his biography is next on my reading list) said

They who can give up essential liberty to obtain a little temporary safety, deserve neither liberty nor safety

Monday, January 12, 2009 1:17:37 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0]Trackback