Krzysztof Mossakowski
Windows Programming
Windows Forms: resources, custom controls
Custom control
Custom controls displaying a bitmap clipped by curves or a polygon:
the clipping is always set using 4 points
points define a polygon or curves (Splines)
all points are situated inside the control
Implementation details:
Custom Control (inherited from System.Windows.Forms.Control)
the control has an icon visible on the toolbox (pic.1)
the control has 3 properties: ClipRegionType, Points, SourceImage (pic. 2 and 3)
ClipRegionType - the way of joining points: Spline (default), Polygon
Points - Point[4] type (see below)
SourceImage - Image type, the image to draw
all properties must be placed in Image section, description must be provided (see pic. 3)
change of any property should refresh the control (during editing in Visual Studio)
use Color.Pink color as a background in edit mode
use AntiAlias and double buffering
Points property editor:
use Editor attribute
the class of the editor must be inherited from
UITypeEditor
override the following methods:
EditValue
GetEditStyle (use UITypeEditorEditStyle.DropDown style)
control used for edition of this property is of the same type as the control being edited
user's actions (pic. 4) :
moving of points
double click - toogle Spline/Polygon mode
the content of the control need not to be refreshed after changing any point's coordinations in property grid
Hints:
classes, methods, properties:
ToolboxBitmapAttribute
BrowsableAttribute
CategoryAttribute
DefaultValueAttribute
DescriptionAttribute
EditorAttribute
Component.DesignMode
UITypeEditor class