Click here to Skip to main content
15,884,986 members
Articles / Multimedia / GDI+

HiLow Card Game

Rate me:
Please Sign up or sign in to vote.
2.67/5 (8 votes)
14 May 20073 min read 94.3K   2.7K   22  
An article on creating a simple card game with C#, using updated card.dll wrapper class
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Publicjoe.Windows.Cards;

namespace HiLow
{
  public partial class ChangeForm : Form
  {
    private Card cardDrawing;

    public int theSelection
    {
      get { return comboBox1.SelectedIndex; }
    }

    public ChangeForm()
    {
      InitializeComponent();

      cardDrawing = new Card();
    }

    protected override void OnPaint(PaintEventArgs e)
    {
      cardDrawing.Begin(e.Graphics);
         
      CardBack TheBack = CardBack.Crosshatch;

      switch (theSelection)
      {
        case 0: TheBack = CardBack.Crosshatch; break;
        case 1: TheBack = CardBack.Sky; break;
        case 2: TheBack = CardBack.Mineral; break;
        case 3: TheBack = CardBack.Fish; break;
        case 4: TheBack = CardBack.Frog; break;
        case 5: TheBack = CardBack.Moonflower; break;
        case 6: TheBack = CardBack.Island; break;
        case 7: TheBack = CardBack.Squares; break;
        case 8: TheBack = CardBack.Magenta; break;
        case 9: TheBack = CardBack.Sanddunes; break;
        case 10: TheBack = CardBack.Space; break;
        case 11: TheBack = CardBack.Lines; break;
        case 12: TheBack = CardBack.Toycars; break;
        case 13: TheBack = CardBack.The_X; break;
        case 14: TheBack = CardBack.The_O; break;
        default: break;
      }

      cardDrawing.DrawCardBack(new Point(200, 10), TheBack);

      cardDrawing.End();

      base.OnPaint(e);
    }

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
      Invalidate();
    }
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


Written By
Software Developer (Senior)
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions