Groups | Blog | Home
all groups > c# > february 2008 >

c# : Perform painting


Marc Gravell
2/13/2008 1:03:03 PM
[quoted text, click to view]
Looks about right; maybe call the base method first...

[quoted text, click to view]
"Graphics " is part of System.Drawing, so this is a mute question

[quoted text, click to view]
If you want something funky, you might also look at WPF, then whole
new GUI framework in .NET 3.0

Peter Duniho
2/13/2008 9:49:50 PM
On Wed, 13 Feb 2008 21:47:47 -0800, K Viltersten <tmp1@viltersten.com>
[quoted text, click to view]

For the most part, your Java techniques will apply in .NET. They aren't
exactly the same, but the general idea of always drawing in a specific
method designed for the purpose and that method being called by the system
to have you draw when needed applies in both cases. Since that's a
central part of understanding how drawing works in both environments,
you're way ahead of the game.

You had a number of questions, so I don't think Marc's reply could have a
simple "yes" or "no". If you're only asking specifically about the last
question ("is there a better one?"), then that's difficult to answer
without knowing what you're trying to do. WPF is supposed to provide in
some respects a simpler, more broadly featured drawing API, but the
pre-WPF drawing paradigm works just fine.

Overriding OnPaint() is not only acceptable, it's a good way to do drawing
assuming you don't have a specific desire to use WPF. Other than
providing a handler for the Paint event, it's the only "right way" to do
it (and in Control-inheriting classes, IMHO overriding the OnPaint()
method is generally better).

K Viltersten
2/13/2008 10:15:47 PM
I'm going to design some custom painting on a component
and the way i'm going to start off is to inherit a Form and
then override the following method.

private void onPaint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.doCoolStuffToMe();
}

Is this a recommended way to go? Is there a better one?


I've also seen that there's
System.Drawing.*
and i wonder if it's more suitable for designing my own
graphics or if extending a Forms.Form to a class called
e.g. Canvas is a smart solution.

--

Regards
Konrad Viltersten
--------------------------------
IT-Consultant
Mandator, Fujitsu Services
0730 - 700 418

K Viltersten
2/14/2008 6:47:47 AM
[quoted text, click to view]


Yes, i do and yes, i will.

However, was your reply a "yes", a "no" or a "boy,
can't explain it in short..."?

In Java i'm used to override a components
paintComponent (Graphics g)
but that doesn't imply it's the way to solve it in C#.
That's what i'm curious about.

--

Regards
Konrad Viltersten
--------------------------------
IT-Consultant
Mandator, Fujitsu Services
0730 - 700 418

K Viltersten
2/14/2008 8:24:53 AM
"Peter Duniho" <NpOeStPeAdM@nnowslpianmk.com> skrev i meddelandet
news:op.t6h2hcve8jd0ej@petes-computer.local...
[quoted text, click to view]


Thanks!

I guess i underestimated the complexity of my
question. I should have explain that i'll be
drawing some graphs.

--

Regards
Konrad Viltersten
--------------------------------
sleep - a substitute for coffee for the poor

amibition - lack of sense to be lazy

- "What's the difference between training and educating?"
- "Would you like your 14-years old dotter to be sexually educated or
trained?"
AddThis Social Bookmark Button