| View previous topic :: View next topic |
| Author |
Message |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sat Jun 06, 2009 7:08 pm Post subject: [C#]Getting PictureBox.Image Name |
|
|
So recently I decided to make a BlackJack game program in C#.
However, the only thing I'm having a problem with is comparing a card image, with its represented value.
My first instinct is to compare the image name with resource names to see what card it is. However, I can't figure out how to get a PictureBox's current image name.
Thanks~
_________________
|
|
| Back to top |
|
 |
FullyAwesome I post too much
Reputation: 0
Joined: 05 Apr 2007 Posts: 4438 Location: Land Down Under
|
Posted: Sat Jun 06, 2009 8:45 pm Post subject: |
|
|
you could always load your images from an imagelist, and store the index value for that card in a variable, and then compare that to another variable (or array index) that has the value of a different card.
_________________
|
|
| Back to top |
|
 |
killersamurai Expert Cheater
Reputation: 0
Joined: 10 Sep 2007 Posts: 197 Location: Colorado
|
Posted: Sun Jun 07, 2009 1:54 am Post subject: |
|
|
| Since you're using a picturebox, you will eventually have the location of the image. When ever you have it, you can set the ImageLocation property of the picturebox. I believe it will not be set if it doesn't contain the full location. Since this is a card game, you'll most likely have 52 cards unique cards and it will be easier to store them. I would just create a card class that will store that information then create a deck class that will manage the cards. If you don't want to create classes, you can create a Dictionary and you can determine if it has the key with the key being either the image or value of the card. Either way, you'll have to store the information unless you are using a single image.
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Jun 07, 2009 8:58 am Post subject: Re: [C#]Getting PictureBox.Image Name |
|
|
| yoyonerd wrote: | So recently I decided to make a BlackJack game program in C#.
However, the only thing I'm having a problem with is comparing a card image, with its represented value.
My first instinct is to compare the image name with resource names to see what card it is. However, I can't figure out how to get a PictureBox's current image name.
Thanks~ |
Just declare an array of all the images and another variable for the current card. Then render the image based on the value of the current card.
|
|
| Back to top |
|
 |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Sun Jun 07, 2009 5:36 pm Post subject: |
|
|
ATM, I already have each image in an array, the problem is they are embedded resources, which means they have no readily available.
_________________
|
|
| Back to top |
|
 |
iostream How do I cheat?
Reputation: 0
Joined: 06 Apr 2009 Posts: 9 Location: georgia
|
Posted: Fri Jun 12, 2009 5:03 pm Post subject: |
|
|
Did you check in the properties?
Its probably a stupid suggestion considering you're already good with C#
_________________
Don't wait up. |
|
| Back to top |
|
 |
yoyonerd Grandmaster Cheater
Reputation: 0
Joined: 26 Apr 2008 Posts: 699 Location: -->formerly yoyonerd<--
|
Posted: Fri Jun 12, 2009 5:09 pm Post subject: |
|
|
| iostream wrote: | Did you check in the properties?
Its probably a stupid suggestion considering you're already good with C# |
Of course I tried, there is none, I had to resort to using a different method, which doesn't allow me to use the images as embedded resources.
_________________
|
|
| Back to top |
|
 |
iostream How do I cheat?
Reputation: 0
Joined: 06 Apr 2009 Posts: 9 Location: georgia
|
Posted: Fri Jun 12, 2009 5:56 pm Post subject: |
|
|
thats what i figured, glad you figured it out though :p
_________________
Don't wait up. |
|
| Back to top |
|
 |
|