C
Charles Law
I have a base class - ComponentBase - that inherits from UserControl. My
class implements IComponentBase, which defines a minimal set of core
properties and methods. All my other components inherit from ComponentBase.
I have defined IComponentBase in a common assembly so that my other projects
reference this rather than the (large) library that contains the component
implementation.
[Stop me when I start to go off the rails]
Now, because UserControl is actually at the heart (base) of all my
components, I automatically get properties like Width, Height, Left, Top,
etc. I also get events like LocationChanged, MouseEnter, and so on.
So that I can attach to the MouseEnter event, and others, I find that I have
to define a MouseEnter event in my interface, implement it in my base class,
and override OnMouseEnter in by base class to call MyBase.OnMouseEnter and
raise my event, which shadows the one in UserControl. It seems that I have
to do this for every event I want to attach to.
I also find that if I want to refer to the Width property of UserControl, I
have to define it in my interface and override it in my base class.
This seems like a lot of code that, basically, just passes things on to the
UserControl base class, and it is very tedious and, of course, error prone.
Am I going about this the right way, or is there an easier solution?
TIA
Charles
class implements IComponentBase, which defines a minimal set of core
properties and methods. All my other components inherit from ComponentBase.
I have defined IComponentBase in a common assembly so that my other projects
reference this rather than the (large) library that contains the component
implementation.
[Stop me when I start to go off the rails]
Now, because UserControl is actually at the heart (base) of all my
components, I automatically get properties like Width, Height, Left, Top,
etc. I also get events like LocationChanged, MouseEnter, and so on.
So that I can attach to the MouseEnter event, and others, I find that I have
to define a MouseEnter event in my interface, implement it in my base class,
and override OnMouseEnter in by base class to call MyBase.OnMouseEnter and
raise my event, which shadows the one in UserControl. It seems that I have
to do this for every event I want to attach to.
I also find that if I want to refer to the Width property of UserControl, I
have to define it in my interface and override it in my base class.
This seems like a lot of code that, basically, just passes things on to the
UserControl base class, and it is very tedious and, of course, error prone.
Am I going about this the right way, or is there an easier solution?
TIA
Charles