|
Guys, just so you know, I sorted this out. Instead of using "return" i used " this.Show();. Not sure if this is the correct thing to do but it seems to be working fine.
Thanks so much of the assistance from both of you.
Cheers
B
|
|
|
|
|
Cool deal, glad it seems to be working
"Find it your bloody self - immediately!" - Dave Kreskowiak
|
|
|
|
|
Hi, I have a simple blackjack game I am toying with and I need to count the amount of times the player has pressed the "Deal" button. Any suggestions ?
Thanks
|
|
|
|
|
|
More specifically, it is an aspx application and I need a way to capture the callback in a variable or by using IsCallBack to keep track of postbacks. Any help ????
|
|
|
|
|
Okay, final thing (for now) on graphics. How do you move what you draw? Does it involve the right or top , etc? I tried
rectangle1.Location = new System.Drawing.Point(x, y);
, but it didn't work. (x/y being someplace not important)
And, this is in a swich event for the arrow keys, just to let anyone who's curious to know.
Thanks in advance
|
|
|
|
|
Hi, I have a standard answer to painting questions, here it is:
there are several steps to draw something so it becomes visible on the screen:
1.
decide on what object you want to draw; it normally is a Control (e.g. a Panel) or a
Form itself. I prefer to add a Panel to a Form, then draw on the Panel.
2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of
your drawing. For a rectangle that could be top and left coordinate, and width+height,
or just a Rectangle object. etc.
3.
create a Paint handler for that Panel, and do all your drawing in there, using the
Graphics class and your variables.
4.
when you want to move things, modify the variables and call Panel.Invalidate() or
one of its overloads (for selective invalidation).
5.
If you want to animate things, perform the move (step 4) inside the Tick handler
of a Windows.Forms.Timer
BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Please give me an example of Panel.Invalidate(). Thanks though, I honestly see what you are getting at.
|
|
|
|
|
MasterSharp wrote: Please give me an example of Panel.Invalidate().
They hide those in the documentation[^]
|
|
|
|
|
MasterSharp wrote: Please give me an example of Panel.Invalidate().
if you have a Panel myPanel on which you draw some shape myShape and
want to move the shape, then do something along these lines:
myShape.X=myShape.X+100;
myPanel.Invalidate();
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Can you do that with the form? I tried and 'it didn't work'.
|
|
|
|
|
MasterSharp wrote: Can you do that with the form?
Whatever "that" is, the answer is yes.
MasterSharp wrote: I tried and 'it didn't work'
Can you be more specific; "didn't work" doesn't tell me anything.
If it does not compile, show the exact code and the first (couple of) error message(s).
If it does not run properly, show the relevant code, and describe the outcome;
if an Exception occurs, show its entire ToString() value.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
MasterSharp wrote: How do you move what you draw?
You can't. Once you have drawn something somewhere, it's drawn. It's like a brush stroke on a canvas, you can't move that around once it's done.
MasterSharp wrote: I tried
rectangle1.Location = new System.Drawing.Point(x, y);
That would work if it was a windows control. They repaint themselves when needed. Graphics that has been drawn are just pixels on the screen, they doesn't exist as an entity that you can manipulate in any way.
MasterSharp wrote: but it didn't work.
I am amazed about how often people describe a result with "doesn't work". It doesn't say anything about what the problem is, and it can be anything from a slight difference from what was expected to a total failure.
What do you mean exctly when you say that "it didn't work"?
---
single minded; short sighted; long gone;
|
|
|
|
|
It did not make the graphics move, but you just told me the reason. SO to make it move, you'd have to (for animating), draw the graphic, then dispose, draw, dispose...?
|
|
|
|
|
Something like that, yes. Think of it like a cartoon: draw 1 frame on one piece of paper, drawn the next frame on another piece of paper, etc.
The drawing should be done in the OnPaint override of your window/control. When you want to draw a new frame, call this.Invalidate() in your window/control code.
|
|
|
|
|
I keep hearing Invalidate(). What's that mean??? I get most else.
|
|
|
|
|
The Invalidate method is used to tell a control that it needs to redraw itself.
It will create a windows message that is put in the message queue. When the message is processed, it will raise the Paint event for the control that is used to redraw the control.
---
single minded; short sighted; long gone;
|
|
|
|
|
MasterSharp wrote: to make it move, you'd have to (for animating), draw the graphic, then dispose, draw, dispose...?
Disposing anything that you used to draw graphics doesn't remove what you have drawn. You can't remove anything that you have drawn, you have to draw something else to replace it.
If you have for example drawn an image on the screen, you would have to remove it by drawing with the background color, the draw the image at the new location.
---
single minded; short sighted; long gone;
|
|
|
|
|
Could I please have some example code? How would you DO what you're saying. (Dummies book doesn't have graphics, so I'm sorry I'm questioning...)
|
|
|
|
|
Why don't you check out this link. It has references to several games written in C#. Games typically animate things on the screen. I used the links there to create a game I plan to publish later this year...
Hogan.
|
|
|
|
|
Cool. Can I see some source?
|
|
|
|
|
Sorry it took me so long, but I published the article last night. Your post inspired me to finish this madness (even though it took a long time).
http://www.codeproject.com/useritems/Henry_s_Game.asp
I hope you have made progress on your work in the mean time.
Hogan
|
|
|
|
|
Draw to a bitmap and then place it as the background of a lightweight control and then you can do the translation. The best method, however, is to actually do the translation in the draw routines.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I have a WebService that has an class, lets call it BaseObjectClass. There are other classes that implement the BaseOjbectClass. I want to find all the classes that implement this BaseObjectClass, thru code or thru IDE but pref by IDE.
This assembly has thousands of classes and its difficult for me to search through all these objects.
Thanks in advance.
|
|
|
|
|
Your code obviously is well documented, so extract an XML file with the documentation and
search it for whatever it is you want to find...
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|