I'm building a couple of designers and I would like to use the same drawing
that winforms classes use.
I managed to do this:
class ButtonComponent
{
}
class ButtonComponentDesigner
{
Button b = new Button();
// b is synced with the ButtonComponent that we should design
}
When painting in the designer I want to draw using the logic from b. OnPaint
is protected so I had to inherit Button in my own class to access it. So
what I did was:
class FakeButton : Button
{
public void DoFakePaint(PaintEventArgs e)
{
base.OnPaint(e);
}
}
So now the designer becomes:
class ButtonComponentDesigner
{
FakeButton b = new FakeButton();
// sync b like above with ButtonComponent
// when drawing just call b.DoFakePaint() and it works
}
This is all very good and it works but I have problems with the other
winforms controls: CheckedListBox, ComboBox, ListBox, PictureBox, TextBox -
they don't draw using this method.
Button, CheckBox, GroupBox, Label, LinkLabel all work perfectly.
Is it possible to steal the drawing form the more complicated controls?...
That's all I need, just for them to look the same, and doing it by hand
doesn't appeal to me.
Thanks.
Adrin - 20 Nov 2004 23:05 GMT
One more thing... xxxComponent already has a base class so i can't inherit
from Button directly. Also it is not a Control that can be placed on a form.
It's more like a bussines object. Still, I want to be able to make a
designer for these components as fast as possible, without changing anything
inside them (xxxComponents represent the model in a MVC architecture).
> I'm building a couple of designers and I would like to use the same
> drawing that winforms classes use.
[quoted text clipped - 43 lines]
>
> Thanks.