Sunday, October 19, 2008

I’m very excited that Silverlight 2 has been released. I’m too new to Microsoft to claim even the slightest involvement, but it’s wonderful to see the excitement both within Microsoft as outside.
It will be interesting to see what will happen with the (already great) uptake of Silverlight by the market.

As I am spending most of my days knee-deep in Xaml nowadays, I always try to find things that will help me be more productive. It happens quite often that I want to select a complete xaml tag. It’s way too much effort to use the mouse to select it, so I often use the control-m-m shortcut to collapse a tag and then select it. However, a few days ago I took 5 minutes to automate this.

image

When you put your mouse somewhere in the Grid tag, and use my macro, you end up with this:

image

You can even put your mouse in the endtag. I bound it to Control-Q and it has made my life that much better!

The macro is as simple as this:

    Sub SelectXMLTagContents()
        DTE.ActiveDocument.Selection.StartOfLine(VsStartOfLineOptions.VsStartOfLineOptionsFirstColumn)
        DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
        DTE.ActiveDocument.Selection.StartOfLine(VsStartOfLineOptions.VsStartOfLineOptionsFirstColumn)
        DTE.ActiveDocument.Selection.EndOfLine(True)
        DTE.ExecuteCommand("Edit.ToggleOutliningExpansion")
End Sub

It collapses a tag, jumps to the first column, selects the line and then does an uncollapse.

For those using a tool like Karl’s ‘Xaml Power Toys’, it might also be a worthwile addition to their shortcuts.

Sunday, October 19, 2008 9:17:36 PM (Romance Standard Time, UTC+01:00)  #    Comments [26]  |  Trackback
 Friday, October 03, 2008

I’ll slowly try to start blogging again :)  It’s been extremely hectic, and I am slowly ramping up. Lately I’ve not been blogging or been just scribbling non-technical jibberish here. Let’s get back on the train!

Loading assemblies in Silverlight can be a bit hard because everything is packaged up in a Xap file. If you want to get to all the assemblies and start instantiating types, you’ll quickly run into a wall.

However, Windows is about living without walls, and thus there is a workaround! :)

  0    string assemblyname = "System.Windows.Controls";
  1
  2    AssemblyPart part = Deployment.Current.Parts.SingleOrDefault(asmpart => asmpart.GetValue(FrameworkElement.NameProperty).ToString() == assemblyname);
  3
  4    StreamResourceInfo streamInfo = Application.GetResourceStream(new Uri(part.Source, UriKind.Relative));
  5    Assembly asm = part.Load(streamInfo.Stream);
  6

It appears there is a very nice class available: Deployment. It is a list of the deployment section of your App.Manifest. The manifest describes all the ‘DeploymentParts’ in the Xap file. It thus also describes the filenames of the dll’s that are included.

If you know the dll name, that is great, and you can easily load it; skip to line 4.
In my case, I just had the assembly name (which does not mean I have the dll name) and on line 2 you can see me running through the parts that are available to me. The x:Name in the deployment file is the name of my assembly, so I get to it by using the DependencyProperty system: querying for the FrameworkElement.NameProperty.

Once I have an assembly part, I have the actual filename: part.Source. So, on line 4, I can now setup a stream to it, and on line 5 I can easily load my assembly.

From this point on, I can do everything you would expect.

Happy sailing!

Friday, October 03, 2008 7:55:38 AM (Romance Standard Time, UTC+01:00)  #    Comments [12]  |  Trackback
 Sunday, August 31, 2008

I’m kind of a tool freak, and when mouse gestures were added in some browsers, I really felt they added value.
I was interested in using gestures in more applications (like Visual Studio) and found the tool ‘StrokeIt’. It is a great tool, fast, accurate, highly configurable and when I introduce it to team members they tend to giggle. So that’s all cool.

However, it does not work well with UAC and X64, much to the dismay of many users on the strokeIt forums. The tool hasn’t been updated since 2005, so that does not bode well.

Now I have found gMote and it is everything I could ever ask for (well, except for a more fun name).
It works very well and has a very nice workflow for defining gestures and assigning tasks for it. I already setup gestures for navigating tabs, paging up and down, minimizing windows and closing tabs/windows.

One tip: I used to use the right mouse button to draw gestures, but that seems to work less reliable. Instead, I now use the middle mouse button.

Go and download gMote now! I couldn’t be happier.

Sunday, August 31, 2008 7:25:56 PM (Romance Standard Time, UTC+01:00)  #    Comments [0]  |  Trackback
 Thursday, August 28, 2008

I installed IE8 beta 2 yesterday and it rocks. It is much faster than IE7, seems rock stable (fingers crossed) and has all kind of nifty new features. It has taken away my need for Firefox at the moment.

In FF I had a button that allowed me to subscribe to a blog in google reader and it works in Internet explorer as well:

javascript:var%20b=document.body;var%20GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/subscribe-bookmarklet.js');void(b.appendChild(z));}else{location='http://www.google.com/reader/view/feed/'+encodeURIComponent(location.href)}

Basically, you can navigate to a page with a blog in it and just press this bookmark. It will open up reader and it will show you the feed it finds.

But, given those cool accelerators in IE8, I thought it would be a nice exercise to create an accelerator that I can click when I am on a blog.
Here it is:

<?xml version="1.0" encoding="UTF-8"?>
<os:openServiceDescription
    xmlns:os="http://www.microsoft.com/schemas/openservicedescription/1.0">
    <os:homepageUrl>http://www.google.com</os:homepageUrl>
    <os:display>
        <os:name>Subscribe to rss feed </os:name>
        <os:description>View the feed in google reader</os:description>
    </os:display>
    <os:activity category="Blog">
        <os:activityAction context="document">
            <os:execute action="http://www.google.com/reader/view/feed/{documentUrl}" method="get">
            </os:execute>
        </os:activityAction>
    </os:activity>
</os:openServiceDescription>

Since the accelerator api will not recognize an url like this: http://www.sitechno.com/Blog/SyndicationService.asmx/GetRss as a ‘Link’, I had to use the document context. When you install this accelerator, you can navigate to the actual feed and then rightclick anywhere in the page. There should be an option to ‘subscribe to rss feed’ and hitting that will take you to google.

These accelerators have potential: it was very simple to write this and it is well integrated into IE. I hope they extend it so we can get accelerators to work on more ‘stuff’!

Install googlereader subscription accelerator

Thursday, August 28, 2008 8:09:13 PM (Romance Standard Time, UTC+01:00)  #    Comments [7]  |  Trackback