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 { } }
private void btn_Capture_Click(object sender, EventArgs e) { if (board != null) { try { Bitmap bmp = board.TakePicture(board.Width, board.Height); SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "JPeg Image|*.jpg"; dialog.InitialDirectory = Environment.SpecialFolder.Desktop.ToString(); if (dialog.ShowDialog() == DialogResult.OK) { bmp.Save(dialog.FileName, ImageFormat.Jpeg); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }