Friday, 31 August 2007

Google adSense

After having adSense for months (and a total earning of $0.18), the ads are finally showing up something connected with my blog:

  • DataGrid controls from Infragistics
  • The power of .net 3.0 from Xceed
  • Debugging Visual Studio from Microsoft
  • Automating your page composition from Dakota... Uh?

Three out of four is not bad, and it's three companies any .net 3 developer should visit quite often for the latest news, so the ads are in this instance quite useful.

As for automating my page... This is a blog?!? Oh well.

Technorati Tags: , ,

Thursday, 30 August 2007

Programming WPF 2nd Edition is out

Well through Chris Sell's blog, http://www.sellsbrothers.com/news/showTopic.aspx?ixTopic=2122, the new edition is shipping. I liked the previous version, only real reference at the time I started WPF, together with the Petzold.

So I just placed an order for it, and at the same time ordered Nathan's and the other Chris book, so I can have a go at reading them all.

I'll do a comparison of all of them and report here. It's been done before but now that I've been working professionally for what seems like years but is in fact only a year (between the RTM and beta 2), I think I may see things differently.

It will also be fun to compare the first and the 2nd edition of Programming WPF :)

Question is, should I order the 3D Petzold? We'll see after I'm done with the rest.

Anyone wants to commission me to write "Writing controls for WPF: Put some sparkle in your cider!"?

Technorati Tags: , , , ,

Wednesday, 22 August 2007

Funny comment of the day

While coding, found a snippet one of my predecessors left me:

//  Media Player gets its

// knickers in a twist.

Thought it was hilarious!

Friday, 17 August 2007

Using Visual Studio 2008 and Scrum for Team System

If you're using Scrum for Team System and Visual Studio 2008, you may notice that when connecting to a newly created Scrum Team Project, the Work Items node gets a desperate looking red cross.

The solution is to simply connect to TFS using the 2005 Team Explorer. From there, create a new Release. Restart Visual Studio 2008 and your Team Queries will finally show up!

Thursday, 16 August 2007

Xceed DataGrid for WPF v1.2

 We've used the WPF DataGrid successfully on the National Express project, and the guys at Xceed are very prompt to answer questions and very quick to fix bugs we encountered with the first version of their products.

I'm being told it's now top quality and probably the best DataGrid available. And it's just been updated! Check their News Headlines page for the new features.

Technorati Tags: , , , ,

Wednesday, 15 August 2007

Some TFS links

Not the freshest of links but useful if you use TFS.

TFS Bug Snapper v1.0 Released

and

www.scrumforteamsystem.com that provides similar functionality to the eScrum tool I talked about before.

Tuesday, 14 August 2007

Quick note for testers

A quick link to Anutthara's blog because it's an invaluable resource for any tester. I'll probably enforce reading it to any tester I have to work with.

Install windows components on a locked-down machine

More and more companies set their users as non admin, even with XP. The so-called locking down tries to protect the user and the network against anything only an administrator should do.

But there's also group policy that directs what gets shown in windows, which software gets activated, etc. In my case, the policy doesn't let you access the Add/Remove Windows Components section.

Being an administrator on the machine, I could go and change the registry to deny read permission to whichever account is being used for policies. That's a bit drastic and I wouldn't recommend it.

But thanks to the complexity and myriad of options available to group policy, sometimes you can get away with easier things.

To add or remove windows components, open PowerShell and type the following.

PS C:\WINDOWS> sysocmgr /i:$env:windir\inf\sysoc.inf

Or for people still using cmd

C:\WINDOWS> sysocmgr /i:%WINDIR%\inf\sysoc.inf

I'd rather we didn't have to play catch and seek with network administrators, but you have to do what you have to do to get the job done sometimes.

Technorati Tags: , ,

Thursday, 9 August 2007

Mix:UK 07 - I'll be there!

Well, it's now official, I'll be at Mix:Uk 07!

Hope to get chatting with many of you about all things WPF / Silverlight. So much cross-over and so many differences!

DirectShow filters from MediaElement

I previously pointed to Jeremiah blog about his and Leslie's amazing win32 integration work.

Little did I realize that the trick I read a while ago to build your own DirectShow filter for a MediaElement control was also his!

Respect.

Wednesday, 8 August 2007

On why you shouldn't really subclass through XAML

As I am reviewing some code at the moment, I have been looking for this blog entry from Rob for a while, and just found it again: Building a control which holds content: CustomControl vs. MarkupSubclassing vs. UserControl. Included in my specification references, but posting it so I can reuse it as a reference.

And the ever so useful Neil (when are you getting a blog back?) points me to an article by Kevin on the same subject: Don't subclass a Panel, unless you're making a Panel.

It always amazes me that people, after x years of OOD, still don't see a problem in using inheritance instead of combination / encapsulation.

Then again these guidelines postdate most of the uses I've seen so far so you can't really blame anyone.

Technorati Tags: , , ,

Tuesday, 7 August 2007

Documentation != Help, or why visual studio sucks

Visual Studio 2005 has the terrible habit of opening the full msdn library whenever you press F1, which in my case is mostly accidental. Not that I don't need help, but the F1 is a reflex I use when I don't understand the meaning of an option on the UI. I couldn't care less for msdn at that point.

Visual Studio 2008 seems to have a faster <cough> <cough> documentation explorer, but goes into what I'd consider to be pure vice: The little question mark box next to the close button is for bloody contextual help. Guess what, opening your big document explorer in my face when I'm already trying to understand what in the name of god you meant by allow checked-in items to be edited is not contextual. I loose my patience, and definitely loose my respect for whichever manager decided that after all, contextual help could be in the big documentation.

Can I have my tooltips back? Please?

Thursday, 2 August 2007

WPF Tips'n'Tricks #5: Receive notifications for dependency properties

Receiving notifications for dependency property changes on an existing object is a very common scenario. The way to do it properly is not very obvious. So much so that while reviewing some code, I found the following snippet.

// Believe it or not, this seems to be the only way to get change
// notifications for DPs unless you derive from the relevant
// class and override OnPropertyChanged.

PropertyDescriptor prop = TypeDescriptor.GetProperties(obj)["Prop"];
prop.AddValueChanged(obj, delegate { viewModel.RaisePropertyChanged("Prop"); });

There's a few issues with this code. The first one is that you reflect on the CLR property anchoring the dependency property, and not the dependency property itself. For example, the following code wouldn't work.

public Dock Dock { get { return DockPanel.GetDock(this); } }
public void TestDockProperty()
{
    PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this)["Dock"];
    descriptor.AddValueChanged(this, delegate(object sender, EventArgs args) { MessageBox.Show("ValueChanged!"); });

    DockPanel.SetDock(this, Dock.Top);
}

The reason is that the PropertyDescriptor points to the CLR property, not to the dependency property.

The second issue is a problem of performance. TypeDescriptor.GetProperties reflects on every call and doesn't cache the result, so its cost is O(n). Here's the result of iterating several times on the code using TypeDescriptor.

  • 1,000 iterations : 00:00:00.2811402
  • 10,000 iterations : 00:00:01.4369388
  • 100,000 iterations : 00:00:14.1194856

So what is the correct way to do it? Say hi to DependencyTypeDescriptor. Here's the code rewritten to use DependencyProperties.

DependencyPropertyDescriptor prop = DependencyPropertyDescriptor.FromProperty(ParentObject.PropProperty, obj.GetType());
            prop.AddValueChanged(obj, delegate { viewModel.RaisePropertyChanged("Prop"); });

If you execute the code in the small benchmark application we used previously, the results are completely different.

  • 1,000 iterations : 00:00:00.00
  • 10,000 iterations : 00:00:00.00
  • 100,000 iterations : 00:00:00.0312378

As you can see in the source code, I simply use a DateTime before and after the call, and everything runs on the UI thread.

And the source is stored on box.net for those that want a peek. Be aware it's a visual Studio 2008 solution and project.

Download the source.