TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gary Fritz
NA
5
0
Graphics - conceptual question
May 20 2009 7:09 PM
I have some basic confusions on how to do graphics in C# (and presumably other .Net languages). I'm still fairly new to the .Net event-driven model so I'm a little unclear how I should make everything work together.
I understand that the Paint method draws your form. I believe that the Paint object is invoked anytime the form needs to be refreshed -- like if you just uncovered the window, or something like that.
But what if I've got a happily displayed form, and now I need to change the content dynamically? I'm writing a simple game with a board and pieces, and I want to do some animation on the board when the user makes a move. I've got the board displaying just fine, but I'm not sure how to do the animation.
The Paint method gets called with an object and a PaintEventArgs as params. You use the PaintEventArgs to create a Graphics object and draw using that. (That's what I've figured out so far, anyway. Please feel free to correct any misunderstandings, and if you know of a good source to learn the architecture, I'd love a pointer!!)
So that works for the Paint method. But what about other code that doesn't get passed the PaintEventArgs param? How do I create a Graphics object that can talk to the form to do the animation?
The animation operation will happen when the user clicks on the screen, so maybe I should trigger a graphics operation from the Click event handler?
Thanks,
Gary
Reply
Answers (
3
)
Code Conversion
this.hide();