示例#1
0
        /// <param name="eBoardStyle">Kiểu bàn cờ</param>
        /// <param name="ePieceStyle">Kiểu quân cờ</param>
        /// <param name="eOwnSide">Quân Mà Người Chơi Chọn</param>
        /// <param name="eGameMode">Chế Độ Chơi</param>
        /// <param name="CellSize">Kích thước ô cờ</param>
        /// <param name="PieceSize">Kích thước quân cờ (Mặc định nếu =0)</param>
        /// <param name="bPlaySound">Âm Thanh</param>
        /// <param name="strFEN">Forsyth-Edwards Notation</param>
        /// Chơi Với Người
        public UcChessBoard(ChessBoardStyle eBoardStyle, ChessPieceStyle ePieceStyle, ChessSide eOwnSide, GameMode eGameMode, int CellSize, int PieceSize, bool bPlaySound, string strFEN)
        {
            InitializeComponent();
            this.Size             = new Size(CellSize * 8, CellSize * 8);
            this._BlackCellBitmap = clsImageProcess.GetChessBoardBitMap(ChessSide.Black, eBoardStyle);
            this._WhiteCellBitmap = clsImageProcess.GetChessBoardBitMap(ChessSide.White, eBoardStyle);

            this._CellSize   = CellSize;
            this._PieceSize  = PieceSize;
            this._PieceStyle = ePieceStyle;
            this._BoardStyle = eBoardStyle;
            this._PlaySound  = bPlaySound;
            this._OwnSide    = eOwnSide;
            this._GameMode   = eGameMode;


            CreateChessBoard();       //Tạo các ô cờ
            kingsideCastling  = true; //Nhập thành gần, quân đen
            queensideCastling = true; //Nhập thành xa, quân đen

            KINGsideCastling  = true; //Nhập thành gần, quân trắng
            QUEENsideCastling = true; //Nhập thành xa, quân trắng
            _EnPassantPoint   = new Point();
            clsFEN.SetFEN(this, strFEN);
            AddChessPiece(ePieceStyle, this._BoardState);
        }
示例#2
0
 public UcChessCell(int PositionX, int PositionY, Bitmap BackImage, ChessSide Side, ChessBoardStyle Style)
 {
     InitializeComponent();
     this._PositionX  = PositionX;
     this._PositionY  = PositionY;
     this._Side       = Side;
     this._BoardStyle = Style;
     this._BackImage  = BackImage;
 }
示例#3
0
        public clsOptions()
        {
            this._CellSize   = 80;
            this._PieceSize  = 64;
            this._PieceStyle = ChessPieceStyle.Classic;
            this._BoardStyle = ChessBoardStyle.Metal;
            this.PlaySound   = true;

            LoadOptions();
        }
示例#4
0
        public UcChessCell(int PositionX, int PositionY, ChessSide Side, ChessBoardStyle Style)
        {
            InitializeComponent();

            this._PositionX  = PositionX;
            this._PositionY  = PositionY;
            this._Side       = Side;
            this._BoardStyle = Style;
            this._BackImage  = clsImageProcess.GetChessBoardBitMap(Side, Style);
            this.BackImage   = _BackImage;
        }
示例#5
0
 public void LoadOptions()
 {
     if (File.Exists(path) == false)
     {
         clsXMLProcess.CreateNewOptions(path);
         SaveOptions();
     }
     else
     {
         DataTable tbl = clsXMLProcess.GetTable(path);
         DataRow   r   = tbl.Rows[0];
         this._CellSize   = Convert.ToInt32(r["CELLSIZE"]);
         this._PieceSize  = Convert.ToInt32(r["PIECESIZE"]);
         this._BoardStyle = (ChessBoardStyle )Convert.ToInt32(r["BOARDSTYLE"]);
         this._PieceStyle = (ChessPieceStyle )Convert.ToInt32(r["PIECESTYLE"]);
         this._PlaySound  = Convert.ToBoolean(r["PLAYSOUND"]);
     }
 }
示例#6
0
        public static Bitmap GetChessBoardBitMap(ChessSide Side, ChessBoardStyle Style)
        {
            string strImg = "";

            switch (Side)
            {
            case ChessSide.Black: strImg += "Black_C_";
                break;

            case ChessSide.White: strImg += "White_C_";
                break;
            }

            strImg += (int)Style;

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

            return(img);
        }
示例#7
0
        private void cboBoardStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboBoardStyle.SelectedIndex == -1 || cboPieceStyle.SelectedIndex == -1)
            {
                return;
            }
            try
            {
                ChessBoardStyle BoardStyle = (ChessBoardStyle)(cboBoardStyle.SelectedIndex + 1);

                ChessPieceStyle PieceStyle = (ChessPieceStyle)(cboPieceStyle.SelectedIndex + 1);

                UcChessBoard Board = new UcChessBoard(BoardStyle, PieceStyle, ChessSide.White, GameMode.VsNetWorkPlayer, 48, 48, false, "KQRBNP2/kqrbnp2/8/8/8/8/8/8");
                pictureBox1.Image = Board.TakePicture(pictureBox1.Width, pictureBox1.Height);
                Board.Dispose();
            }
            catch
            {
            }
        }