日期:2009-03-01  浏览次数:20583 次

前几天没事,写了一个小程序,可以用于学习C#。
程序使用了VS.NET环境编译,你的机器只要安装了.NET Framework SDK就可以运行。

源码和执行文件可以下载
你不想下载也可读一下源码(图片资源等需要下载)。
namespace Leimom.FiveChess
{
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.WinForms;
    using System.Data;
    /// <summary>
    ///    Summary description for Form1.
    /// </summary>
    public class FiveForm : System.WinForms.Form
    {
        /// <summary>
        ///    Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components;
  private System.WinForms.ImageList imageListbw;
  //define the hot Rectangle
  private Rectangle[] pointSquares;
  //chess information
  private int[] chessTable;
  private int nextTurn;
  private const int bTurn = 1;
  private const int wTurn = 2;
  private Stack chessIndex;
  public FiveForm()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
   chessIndex = new Stack();
   nextTurn = bTurn;
   chessTable = new int[225];
   pointSquares = new Rectangle[225];
   Size size = new Size(18,18);
   int x = 0;
   int y = 0;
   for(int i = 0;i < 225;i++)
   {
    x = i%15;
    y = i/15;
    pointSquares[i].Size = size;
    pointSquares[i].Offset(9+x*20,6+y*20);
    chessTable[i] = 0;
   }
  }

  protected override void OnPaint(PaintEventArgs e)
  {
   //you may paint
            Graphics g = e.Graphics;
  }
  protected override void OnMouseDown(System.WinForms.MouseEventArgs e)
  {
   switch( e.Button )
   {
    //take left button down
    case MouseButtons.Left:
     OnLButtonDown(new Point(e.X,e.Y));
     break;
    //take right button down
    case MouseButtons.Right:
     OnRButtonDown(new Point(e.X,e.Y));
    &n