I seek to @override
the DrawLine
method of the Graphics
class, but I am unsure if this is possible?
I seek to put a validation in
It is not possible for normal code to replace method that is not designed to be replaced/overriden.
You can
You just need a separate method. Put it wherever you want:
void CheckedDrawLine(Graphics g, int x1, int y1, int x2, int y2, int stopY) {
// Do the validation, draw the line
}
And you could make it into an extension method by sticking it in a static class
:
void CheckedDrawLine(this Graphics g, int x1, int y1, int x2, int y2, int stopY) {
// Do the validation, draw the line
}
to do a g.CheckedDrawLine(...)
instead of a CheckedDrawLine(g, ...)
.