My previous post on a .NET custom forms designer was a basic listing of the samples that are out there and some of their merits. It was not an exceptionally enlightened piece, so I intend to correct a few things and add some additional detail over the next couple of weeks. I included a listing of interfaces and made an unfulfilled hint at completing a full-featured design surface. I’ll get to the point eventually, so bear with me on this. We are off on a voyage of discovery....
I listed five examples of design surfaces in that first post. I will be throwing out two of them from consideration, but for different reasons. The first to be tossed is the MSDN GDI+ sample. This does not interact with the core .NET designer and is actually a poor substitute at trying to emulate it. It is OK for what it tries to do, but it does not fit my ultimate goal, which I’ll get to shortly.
The second example to be tossed is SharpDevelop. I am not trying to recreate Visual Studio as they are. SharpDevelop also has what can only be called an intricate extensible structure of "codons". Their extensibility structure seems to have created lots of additional work with little perceivable benefit. Perhaps I’m wrong. Anyway, you are welcome to look at their work, but the GPL restrictions were enough to turn me off.
That leaves us with three samples. For ease of reference, I’ll shorten their names as follows:
From these three samples, I intend to work towards a Windows Forms design surface that I will be able to then customize for my specific application. Therefore my goal is a rich design environment that will permit my users to create custom forms. Eventually, I'll create some custom controls and restrict them to only using those, but that is far in the future. In the meantime, I need to create a designer.
I need to make a few corrections to my earlier comments.
The Dawson sample consists of code and a brief accompanying article. There is some depth to parts of the discussion, but it does not cover things in detail. Overall, it is great and was the first published effort I found. The presented sample is very rough, but it works. The toolbox is actually a Listbox with the names of the controls. There is simple functionality.
The MSDN sample is far ahead of the Dawson version. Interestingly, I wondered if they came from the same code base, since there were some amazing similarities I saw. The MSDN toolbox is a Treeview with drag-and-drop functionality. Tools and icons are loaded from those installed on the user’s machine with the framework. Functionality is much better.
The MSKB sample is actually the best of the three. There is no real accompanying article, but the code is well-commented. In fact, the code appears to have been excised from a larger, more-finished program. There are several stubs present for additional interface implementations. These may well be the remains of routines left after custom code was removed, but their retention is appreciated. Many of the comments look suspiciously like the remains of XML comments that have had their XML wrappers deleted. This sample has by far the best functionality. Keyboard and menu commands are included. Code display in both VB and C# is supported. The toolbox looks much like Visual Studio’s and supports both mouse and keyboard. Overall, it wins as the most complete example.