Truly Customizable User Interfaces

My most recent project is working on a small IDE (integrated development environment) for generating micro-C Linux kernels.  It’s an updated version of Fusion.  One thing in particular that it does is present a UI of choices for configuring the kernel to your hardware.  Specifically, we want the end user to be able to add their own hardware without us needing to do the work and releasing an updated version of the software or a patch to it.  This called for some truly customizable UI.

Since the original software was written in VB, I thought C# would be a good platform for the application.  It would allow me to reuse some of the components, like ScintillaNET, and have equivalent operating system calls and components to the original application.  Also, having a built-in MDI (multiple document interface) framework was an added bonus.

The interesting part has really been the customizable UI.  How can we let the user add their hardware to our configuration dialog?  The answer was simple: use WPF (Windows Presentation Foundation).  If you’re not familiar with WPF, it’s Microsoft’s XML-like, declarative UI language (XAML).  It turns out that this is really easy to load at runtime.  By the way, for help in generating the XAML code, I found Kaxaml very helpful.  Then came the other end of the problem.  How does this same end user modify the C header file that this UI generates to add his own hardware needs?

Well, of course, you’d think about putting information into a user-accessible file that you could load at runtime.  You could parse it for “commands” that would retrieve information from the UI and log the information for output to the header files.  This would generally work fine, but some operations can be a little complicated and I had no desire to build a true lexical parser to handle operations that C# or some other scripting language already had built in.  After a quick search, I found out that C# can compile code at runtime.  Another search took me to Westwind, where I found a nice package built around the numerous commands that C# makes you execute to accomplish the task.  The Westwind code builds a class and takes constructor arguments.  I added a callback class to the arguments, so my end-users can add C# code and calls to my specific class to generate the header files.

I hope this gives you some ideas on how to increase the level of customization in your application or how to add some user-level customization.