Ejemplo n.º 1
0
        public Uc_ChessPiece(eChessSide side, eChessPieceType type, eChessPieceStyle style, int cellSize, int piecesize)
        {
            InitializeComponent();

            this._side  = side;
            this._type  = type;
            this._style = style;
            _cellSize   = cellSize;
            _pieceSize  = piecesize;
            _image      = Read_Image_From_Resources.GetChessPieceBitMap(_side, _type, _style);

            //UserControl Size
            this.Size = new Size(this._pieceSize, this._pieceSize);
        }
Ejemplo n.º 2
0
        /*
         * Hàm này trả về tên của hình ảnh quân cờ chứa trong resource
         * VD: Muon lay quan Mã màu Đen Style Classic
         * Bitmap img=GetChessPieceBitMap(ChessPieceSide.Black,eChessPieceType.Knight,eChessPieceStyle.Classic);
         * Hàm này lấy hình ảnh trong Resource có tên là "Black_K_1";
         */
        public static Bitmap GetChessPieceBitMap(eChessSide Side, eChessPieceType Type, eChessPieceStyle Style)
        {
            string strImg = "";

            switch (Side)
            {
            case eChessSide.Black:
                strImg += "Black_";
                break;

            case eChessSide.White:
                strImg += "White_";
                break;
            }

            switch (Type)
            {
            case eChessPieceType.Pawn:
                strImg += "P_";
                break;

            case eChessPieceType.Bishop:
                strImg += "B_";
                break;

            case eChessPieceType.Knight:
                strImg += "N_";
                break;

            case eChessPieceType.Rook:
                strImg += "R_";
                break;

            case eChessPieceType.Queen:
                strImg += "Q_";
                break;

            case eChessPieceType.King:
                strImg += "K_";
                break;
            }

            strImg += (int)Style;

            Bitmap img = (Bitmap)Properties.Resources.ResourceManager.GetObject(strImg);

            return(img);
        }
Ejemplo n.º 3
0
        public ChessMove(Point x1, Point x2, eMove m, Point eated, eChessPieceType pieceType, int moves, int fromMoves)
        {
            this._moveFrom.X = x1.X;
            this._moveFrom.Y = x1.Y;

            this._moveTo.X = x2.X;
            this._moveTo.Y = x2.Y;

            this._moveEated.X = eated.X;
            this._moveEated.Y = eated.Y;

            this._howMove        = m;
            this.ChessPieceEated = pieceType;
            this._moves          = moves;
            this._fromMoves      = fromMoves;
        }
Ejemplo n.º 4
0
        public static void Promotion(Uc_ChessPiece UcPawn, eChessPieceType PromoteTo, System.Globalization.CultureInfo Language)
        {
            if (PromoteTo == eChessPieceType.Null)
            {
                Form_Promotion f = new Form_Promotion(UcPawn.Side, UcPawn.Style, Language);
                if (f.ShowDialog() == DialogResult.OK)
                {
                }
                f.Dispose();

                UcPawn.Type = Form_Promotion.Type;
            }
            else
            {
                UcPawn.Type = PromoteTo;
            }
            UcPawn.Image = Read_Image_From_Resources.GetChessPieceBitMap(UcPawn.Side, UcPawn.Type, UcPawn.Style);
        }
Ejemplo n.º 5
0
 private void pictureBox4_Click(object sender, EventArgs e)
 {
     Type = eChessPieceType.Bishop;
     this.Close();
 }
Ejemplo n.º 6
0
 private void pictureBox3_Click(object sender, EventArgs e)
 {
     Type = eChessPieceType.Knight;
     this.Close();
 }
Ejemplo n.º 7
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     Type = eChessPieceType.Queen;
     this.Close();
 }
Ejemplo n.º 8
0
 private void Form_Promotion_Load(object sender, EventArgs e)
 {
     Type = eChessPieceType.Queen;
 }
Ejemplo n.º 9
0
 public ChessState(eChessPieceType Type, eChessSide side, int moves)
 {
     this._type = Type;
     this._side = side;
     this.moves = moves;
 }
Ejemplo n.º 10
0
 public ChessState(eChessPieceType Type, eChessSide side)
 {
     this._type = Type;
     this._side = side;
     this.moves = 0;
 }