Virtual Developer Workshop: Containerized Development with Docker
When developing control elements for .NET, our company KBSoft faced a task of providing the design of complex compound control elements in the designtime. Our goal was to provide convenience of designing of a control element, containing plentiful compound parts (signatures, diagrams, images, and so forth) that will be displayed on its surface. And, for the user's comfort, these elements should be chosen by a mouse in the designtime. So, the convenience of such a compound control element adjustment should be the same as of adjustment of control elements on a form, when a user can choose different control elements, move them and resize with the help of a mouse, and adjust features of the chosen control element with the help of VisualStudio property grid.
A standard decision comes first to mind for such a problem statement—mplement all parts of a custom control element with the help of other controls. But, this approach is difficult. It is well known how difficult it sometimes is to get a demanded behavior from a window. For example, if you need to make a text mark that would have oval borders, on a control element, or to obtain non-transparent text display on a semi-transparent background, difficulties will occur; these difficulties were mentioned in the article Non-transparent controls on a semi-transparent window. Besides, each window takes certain resources, receives messages, and so on, that often are not needed at all.
This article contains a ready designer SmartControlDesigner, that we created in KBSoft for internal needs. This designer is able to support the adjustment of the position of some rectangular areas on the surface of your control element. For such areas, the frame is drawn in the style of a standard, drawn when you choose a control element on a form in WindowForms application. This frame allows you to adjust the position and area sizes. Such an area can be chosen by a mouse and its properties will be displayed in a property grid. Thus, a user, adjusting your control, has an impression that he is working with usual control elements on a form. In fact, this area will never be a window and can be a simple object in the memory, drawn by several GDI-functions. On the following image, you will see an appearance of an area designed in the VisualStudio IDE.
SmartControlDesigner is totally ready to use, and having implemented several interfaces in your element, you receive a perfectly adjustable designtime control element. An example of the current designer implementation can be a base for developing a more flexible and comfortable system of component adjustment in the designtime. The SmartControlDesigner source code contains detailed comments and explanations for that.