Saturday, 12 July 2008


Isn’t inspiration brilliant? You estimate how long tasks will take on your todo list. You put down "1 hour" for one of your tasks, because it "could be easy, but there could be some little nuances that make it a little tricky." One minute into the task, you think "hang on, what if I do this" and bang, the task is complete :)

Where do you get inspiration from? Well, that comes from practice…

Saturday, 5 July 2008

Dynamic PropertyGrid

People seem to be stumbling across my blog after searching for how to create a dynamic property grid with attributes in c#.

Presumably, people want to be able to hide some fields, and make others read only, which can be done easily at design time by adding "Browsable" and "ReadOnly" attributes. But try to find any information on the Internet about changing those attributes at runtime and you'll find yourself crashing straight into a brick wall.

From what I gather, attributes are compiled into the executable, so being allowed to change them dynamically at runtime would mean making changes to the executable - which is probably a Bad Thing(TM). Which means it can't be done.

What you end up having to do, is creating a dynamic class, on-the-fly, containing the fields that you want to appear in the property grid, then creating property descriptors per property. Then when the property grid is dismissed, copying the data out of the temporary class back into your original class.

There's a sample over at CodeProject.

Good luck!


Whenever I have to work on a new computer for any length of time, I'll start to customize it. Naturally, I have the most customizations on my home computer; my work machine comes a close second, and any other machine I work on will have some of my customization footprint left behind.

I won't refuse to work on a machine until it suits me - I don't have the time to put all my tweaks on every box I touch, but I will add my personal touches as and when I need them.

Looking at other peoples must-have utilities, registry hacks, and firefox plugins, I will often look down the list and not see a single thing that interests me. Because I don't install something that "could be useful", but rather go hunting when and where I find a niche. I'll think "wouldn't it be good if there was a program or tweak or plugin that did xyz?" And if I can't find the add-on that I'm looking for, I'll write it for myself.

The majority of my customizations are to help me get to what I want as quickly as possible.

My first customization is switching the start menu to classic mode. The "favourites" list is too ephemeral for my liking. I like my shortcuts to stay where I put them!

Once I've tried searching for a file a few times with windows explorer, I'll install TweakUI, one of Microsoft's PowerToys, because I'll quickly get fed up of having to specify that I want to search through "All files and folders" every time I search. There are lots of things that can be tweaked with TweakUI, but "Use classic search in explorer" is the main tweak that I use.

Winkey is a must have. I can set up any keyboard shortcut I want using the windows key and other modifiers in conjunction.

In winkey I'll have Windows + i = firefox (the "i" stands for "Internet"). Windows + n = notepad (indispensable to a programmer - none of this wysiwyg milarky!). Windows + s = command prompt ("s" stands for "shell"). Windows + C = Calculator. Out of the box you get Windows + F12 = regedit, and windows + 1, windows + 2, windows + 3 etc corresponding with your drives c:\ d:\, etc.

If I have some network drives mapped in My Computer and I'm disconnected from the network (and sometimes even when I am connected to the network) the My Computer window becomes slow to start up. Once I have winkey access to my drives, I have very little need for the My Computer icon. In fact, if the icon is available on my desktop, I can accidentally double-click it, and instantly regret it when I have to wait 30 seconds before my computer becomes responsive again. So I'll go back into tweakUI and remove the My Computer icon from my desktop.

In firefox, I will always install the Adblock extension (I hate ads!). I will always install the google toolbar for firefox. I will always tell the tabs bar to be visible all the time. (If the tab bar only pops up when a second tab is opened, the contents of the entire page shifts downwards and breaks my concentration).

Baregrep is a lovely gui grep tool which I can use to find files containing certain strings.

Certain apps "forget" that they were maximized, and when they are run again, they start up "almost" maximized. So when I click the hotspot at the top right of a maximized window (the X) to close the window, I end up closing the window behind the one I intended to! Extremely annoying! So I install AutoSizer to make sure that those apps which exhibit this behaviour always open maximized.

That's about all of my customizations that I can remember. If I remember any more I'll add to this list.

Friday, 4 July 2008

Many Ways to Skin a Cat

Today's operating systems offer many different ways of achieving the same thing. To open a recent Word document, you could find it in the recent documents menu, open Word and find it on the recent files list, open Word and use the open file menu option and navigate to the file, you could find the file in Explorer and open it from there, or you could open the file from any other shortcut that you have set up.

A few years ago, I found that the "many ways to skin a cat" approach made it difficult to teach people to use a computer (particularly when I was teaching my parents). They were keen to learn, and though I tried to be consistent when trying to teach them, I would often accidentally use an alternative method to open a file and end up confusing them.

Now, however, I have come to the conclusion that the different ways of achieving your goal enable you to be more efficient at what you are doing.

If I have accessed a file recently, then chances are good that I will want to use it again. So I have a recent documents menu on the start menu. Now the recent documents menu might keep the file long enough to serve its purpose, but other, more recently used files will inevitably demote the file until it no longer appears on the recent documents menu. If I still need a file after it has been bumped off the recent documents menu, it might still be in the recent files menu of the application that it's accessed in. If it gets bumped off of that menu, then I'll set up a shortcut to it.

Now I try to keep a tidy computer, because it keeps my computer use efficient. I try to keep my desktop as clear as possible. I'll use the desktop as a temporary storage bin - an inbox, but I'll try to clear it out as soon as possible.

The reason is, items tend to gather on a desktop in no particular order. Even if the desktop is arranged in such a way that you remember what went where, an accidental sorting of the icons, or a resolution change moves the icons out of place, your spatial memory is no longer accurate, and the shortcuts are no longer as efficient as they were.

So, as you may have gathered I won't keep my shortcut on the desktop. If I have the screen real-estate, I will have up to two toolbars on the taskbar to contain my shortcuts - the quick launch toolbar for shortcuts to programs and individual files, and, if I have the space, a "folders" toolbar which contains shortcuts to the folders that I access most frequently. (If I don't have the space for two toolbars, I'll keep everything in the quick launch toolbar). Each of these toolbars will contain a hierarchy, so as not to have massive, sprawling lists to wade through.

These toolbars usually end up containing the files and folders I access 99% of the time. I'll occasionally have a quick spring clean and delete anything that has become obsolete, but usually the hierarchy keeps things getting too messy.

Next post I'll talk about customization in general.