c# .net question

yhlee

Senior member
Jun 15, 2000
342
0
0
Ok.. I've been working on this and google just isn't finding the stuff i need.

Basically, i have a "picture" of a "chip" (like a poker chip).

There is a central location where the chips are initially held. By pushing G, i add chips to the left side. By pushing H, i add chips to the right side. Once all the chips in the central location are exhausted, I can still push G or H to move chips from the left to right and vice versa.

Now, it's really easy to do this with just a "numeric" representation of the chips, and i'm hoping it is also easy with the pic. I know that i can create new instances of PictureBox objects and easily add chips to either side, but it isn't clear to me how to remove these objects in a "stack" sort of way.. Meaning, if i add chip1 to chip5 to left, then move one chip from left to right, it removes chip5's pic.

What I don't want, is to have to redraw the whole form every time a chip is moved.

anyone with an idea how to do this?

edit: one stupid way i've thought about doing this is to put a picture on top of the picture i want to delete. this picture would be a simple image with the color the same as the background... i would then lock my code so nobody could read it though.....
 

HJB417

Senior member
Dec 31, 2000
763
0
0
You need to do something along the lines of listening for a KeyDown/KeyPressDown event, and in the method that handles the event, if it's the 'g' or 'h' key. Also, keep a System.Collections.Stack of the added picture boxes.
do

PictureBox pokerImg = new PictureBox();
pokerImg.Size = ????
pokerImg.Location = ???? left? right?
pokerImg.Image = ????
pokerImg.Push(pokerImg);
Form.Controls.Add(pokerImg);
return;


and when you want to put poker chips back in the center, do

PictureBox pokerImg = (PictureBox) pokerImg.Pop;
pokerImg.Location = ??? center?
return;



that's the basic idea, there's more that can be done to make it more efficient as I already see a potential problem with my code.