c# - Add bitmap resources to list -


I am working on CardGam and my resources (all cards) have 52 bitmaps as it is of 2 cards Now works when dealing with:

  Public Zero GiveTwoRandomCardsFromCardsList () {Random random = new random (); System.Threading.Thread.Sleep (100); Int slumptal = random.Next (0, 52); Card 1 = card [slums]; Bull flag = false; While (! Flag) {System.Threading.Thread.Sleep (100); Int slumptal2 = random.Next (0, 52); If (unclear! = Slumptal2) {card2 = card [slumptal2]; Flag = true; }}}  

This two strings have to give value to the list of strings. The list contains 52 strings h2, h3, h4, h5, etc. Now if I want to display the image of a certain card, I have a long switch from:

  switch (whatIsTheFirstCard) {// hearts case "H2": Card 1 picture. Image = resource1h2; break; Case "H3": Card 1 Picture. Image = resource 1 H3; break; Case "H4": Card 1 Picture. Image = resource1h4; break;  

etc etc for all cards Is there any way to add images directly to the list and then call that list instead? The way now is that I should copy and paste the switch for each card, which I want to display. Needless to say, I have only one list which can keep all my bitmap cards.

  Private Zero FlopButton_Click (Object Sender, EventArgs e) {theCards.DealTheFlop (); Flopcard 1 Image = thibitmapgoser; }  

I do not know the syntax for adding a bitmap to the list and then call them from that list.

If you use the exact same identifier for the card in the code in the resources, You can get proper resources through the manager, i.e.

  flopkard 1 Image = (bitmap) resource. Resource Manager. GetObject ("h4", resource farming);  

Internally, this is the same as the generated code.

In this way, you do not need a separate list and you can easily specify different card sets for different cultures.


Comments