private void Load_Options() { int_CellSize.Value = obj.CellSize; int_ChessPieceSize.Value = obj.PieceSize; cboBoardStyle.SelectedIndex = ((int)obj.BoardStyle) - 1; cboChessPieceStyle.SelectedIndex = ((int)obj.PieceStyle) - 1; ckb_Sound.Checked = obj.PlaySound; try { Uc_ChessBoard board = new Uc_ChessBoard(obj.BoardStyle, obj.PieceStyle, eChessSide.White, eGameMode.VsNetWorkPlayer, 48, 48, false, new CultureInfo("vi")); pictureBox1.Image = board.TakePicture(pictureBox1.Width, pictureBox1.Height); board.Dispose(); } catch { } }
private void cboBoardStyle_SelectedIndexChanged(object sender, EventArgs e) { if (cboBoardStyle.SelectedIndex == -1 || cboChessPieceStyle.SelectedIndex == -1) { return; } try { eChessBoardStyle BoardStyle = (eChessBoardStyle)(cboBoardStyle.SelectedIndex + 1); eChessPieceStyle PieceStyle = (eChessPieceStyle)(cboChessPieceStyle.SelectedIndex + 1); Uc_ChessBoard board = new Uc_ChessBoard(BoardStyle, PieceStyle, eChessSide.White, eGameMode.VsNetWorkPlayer, 48, 48, false, new CultureInfo("vi")); pictureBox1.Image = board.TakePicture(pictureBox1.Width, pictureBox1.Height); board.Dispose(); } catch { } }
/// <summary> /// Play with computer given State /// </summary> /// <param name="ownside"></param> /// <param name="gamemode"></param> /// <param name="gamedifficulty"></param> /// <param name="arrState"></param> private void CreateChessBoard(eChessSide ownside, eGameMode gamemode, eGameDifficulty gamedifficulty, ChessState[,] arrState) { if (board != null) { board.CancelThinking(); board.Dispose(); ucCountDownTimer1.StopTimer(); ucCountDownTimer2.StopTimer(); ucCountDownTimer1.Min = _timeLimit; ucCountDownTimer2.Min = _timeLimit; ucCountDownTimer1.Sec = 0; ucCountDownTimer2.Sec = 0; } else { ucChessPieceEated1 = new Uc_ChessPieceEated(ownside); ucChessPieceEated2 = new Uc_ChessPieceEated(ownside); ucCountDownTimer1 = new Uc_CountDownTimer(); ucCountDownTimer2 = new Uc_CountDownTimer(); ucCountDownTimer1.StopTimer(); ucCountDownTimer2.StopTimer(); ucCountDownTimer1.Min = _timeLimit; ucCountDownTimer2.Min = _timeLimit; ucCountDownTimer1.Sec = 1; ucCountDownTimer2.Sec = 1; ucCountDownTimer1.TimeOut += new Uc_CountDownTimer.TimeOutHandler(UcCountDownTimer_TimeOut); ucCountDownTimer2.TimeOut += new Uc_CountDownTimer.TimeOutHandler(UcCountDownTimer_TimeOut); } this.SuspendLayout(); btn_Undo.Enabled = true; btn_Redo.Enabled = true; btn_Savegame.Enabled = true; btn_Savemoved.Enabled = true; panel1.Visible = true; panel1.Controls.Clear(); pnlTimerLeft.Controls.Clear(); pnlTimerRight.Controls.Clear(); pnlTimerRight.Visible = true; pnlTimerLeft.Visible = true; pnlTimerLeft.Controls.Add(this.ucCountDownTimer1); pnlTimerRight.Controls.Add(this.ucCountDownTimer2); ucCountDownTimer1.Size = new Size(110, 35); ucCountDownTimer2.Size = new Size(110, 35); ucCountDownTimer1.Location = new Point(8, 8); ucCountDownTimer2.Location = new Point(8, 8); pnlTimerLeft.Size = new Size(ucCountDownTimer1.Width + 16, ucCountDownTimer1.Height + 16); pnlTimerRight.Size = pnlTimerLeft.Size; Options obj = new Options(); board = new Uc_ChessBoard(obj.BoardStyle, obj.PieceStyle, ownside, gamemode, gamedifficulty, obj.CellSize, obj.PieceSize, obj.PlaySound, _language, arrState); board.MoveMaked += new Uc_ChessBoard.MoveMakedHandler(MoveMaked); if (board.GameMode == eGameMode.VsComputer) { btn_Hint.Enabled = true; } else { btn_Hint.Enabled = false; } Bitmap bmpBackImage = new Bitmap(board.Width, board.Height); board.DrawToBitmap(bmpBackImage, board.Bounds); board.BackgroundImage = bmpBackImage; board.BoardBitmap = bmpBackImage; _notationSize = (int)((obj.CellSize * 38) / 100); this._gameMode = gamemode; this._ownSide = ownside; AddNotation(obj.CellSize, ownside); board.Location = new Point(_notationSize, _notationSize); this.panel1.ClientSize = new Size(obj.CellSize * 8 + _notationSize * 2, obj.CellSize * 8 + _notationSize * 2); this.panel1.Controls.Add(board); this.MinimumSize = new Size(1000, 230 + obj.CellSize * 8); pnlTimerLeft.Location = new Point(8, 161); panel1.Location = new Point(pnlTimerLeft.Location.X + 2 + pnlTimerLeft.Width, 161); pnlTimerRight.Location = new Point(panel1.Location.X + 2 + panel1.Width, panel1.Location.Y + panel1.Height - pnlTimerRight.Height); //ChessPieceEated pnlChessPieceEated1.Controls.Clear(); pnlChessPieceEated2.Controls.Clear(); pnlChessPieceEated1.Visible = true; pnlChessPieceEated2.Visible = true; if (board.OwnSide == eChessSide.White) { ucChessPieceEated1.Side = eChessSide.White; pnlChessPieceEated1.BackColor = Color.White; ucChessPieceEated2.Side = eChessSide.Black; pnlChessPieceEated2.BackColor = Color.DimGray; } else { ucChessPieceEated1.Side = eChessSide.Black; pnlChessPieceEated1.BackColor = Color.DimGray; ucChessPieceEated2.Side = eChessSide.White; pnlChessPieceEated2.BackColor = Color.White; } pnlChessPieceEated1.Size = new Size(pnlTimerLeft.Size.Width - 45, (pnlTimerLeft.Width - 30) * 4); pnlChessPieceEated2.Size = new Size(pnlTimerRight.Size.Width - 45, (pnlTimerRight.Width - 30) * 4); pnlChessPieceEated1.Location = new Point(pnlTimerLeft.Location.X + pnlTimerLeft.Width - pnlChessPieceEated1.Width, pnlTimerLeft.Location.Y + pnlTimerLeft.Height + 10); pnlChessPieceEated2.Location = new Point(pnlTimerRight.Location.X, pnlTimerRight.Location.Y - pnlChessPieceEated2.Height - 10); ucChessPieceEated1.Size = new Size(pnlChessPieceEated1.Size.Width, pnlChessPieceEated1.Size.Height); ucChessPieceEated2.Size = new Size(pnlChessPieceEated2.Size.Width, pnlChessPieceEated2.Size.Height); pnlChessPieceEated1.Controls.Add(ucChessPieceEated1); pnlChessPieceEated2.Controls.Add(ucChessPieceEated2); ucChessPieceEated1.LoadChessPieces(board.stkChessPieceEated); ucChessPieceEated2.LoadChessPieces(board.stkChessPieceEated); if (board.OwnSide == eChessSide.White) { ucCountDownTimer2.StartTimer(); } else { ucCountDownTimer1.StartTimer(); } this.ResumeLayout(); }