Afaik gibt's die nicht, lässt sich aber quick and dirty mit einem
UserControl lösen...
In der Projektmappe ein UserControl hinzufügen und den Rest hier
einfügen, die Events entsprechend "verdrahten", ...
1 | public enum ShapeKind { Circle, Rect ... };
|
2 | public partial class Shape : UserControl {
|
3 | ShapeKind _kind = ShapeKind.Circle;
|
4 | SolidBrush _brush;
|
5 | public Shape() {
|
6 | InitializeComponent();
|
7 | _brush = new SolidBrush(ForeColor);
|
8 | }
|
9 | // Alles was public ist, taucht auf der
|
10 | // Eigenschaftenseite des Controls auf
|
11 | //
|
12 | public ShapeKind Kind {
|
13 | get { return _kind; }
|
14 | set { _kind = value; Invalidate(); }
|
15 | }
|
16 |
|
17 | private void Shape_Paint(object sender, PaintEventArgs e) {
|
18 | switch (_kind) {
|
19 | case ShapeKind.Circle:
|
20 | e.Graphics.FillEllipse(_brush, ClientRectangle);
|
21 | break;
|
22 | ...
|
23 | }
|
24 | }
|
25 |
|
26 | private void Shape_ForeColorChanged(object sender, EventArgs e) {
|
27 | _brush = new SolidBrush(ForeColor);
|
28 | }
|
29 | }
|
Das ganze taucht dann wie ein "normales" Control in der ToolBox auf