i have 2 classes. one is a partial class belonging to winform, and the other is a code class of chess.
problem , is that my enums arent being triggered , or they reset themselves..
okay, so in the code class i have got this:
class PiecePromotion
{
PromotionPieces pieceP;
public Pieces[,] promotionPresentation(Pieces[,] pieces, bool black, bool white, int rowEnd, int columnEnd)
{
pieceP = chess.PromotedPiece ;// this property should be retrieved after i click on the radio box. pieceP should be assigned to be an enum of ROOK, QUEEN, KNIGHT, BISHOP.
if (black)
{
switch (pieceP)
{
case PromotionPieces.ROOK:
pieces[rowEnd, columnEnd] = new Rook("BR3");
break;
case PromotionPieces.BISHOP:
pieces[rowEnd, columnEnd] = new Knight("BN3");
break;
case PromotionPieces.KNIGHT:
pieces[rowEnd, columnEnd] = new Bishop("BB3");
break;
case PromotionPieces.QUEEN:
pieces[rowEnd, columnEnd] = new Queen("BQueen2");
break;
default:
ChessBoard.moveValidity = "Invalid Choice";
break;
}
}
if (white)
{
switch (pieceP)
{
case PromotionPieces.ROOK:
pieces[rowEnd, columnEnd] = new Rook("WR3");
break;
case PromotionPieces.BISHOP:
pieces[rowEnd, columnEnd] = new Knight("WN3");
break;
case PromotionPieces.KNIGHT:
pieces[rowEnd, columnEnd] = new Bishop("WB3");
break;
case PromotionPieces.QUEEN:
pieces[rowEnd, columnEnd] = new Queen("WQueen2");
break;
default:
ChessBoard.moveValidity = "Invalid Choice"; break;// all i get an invalid choice, as if pieceP wasnt assigned. why is that?
}
}
return pieces;
}
}
and in the winform class i have got his:
public STATE Gamestate { set; get; }
public PromotionPieces PromotedPiece { set; get; }// when i click on the radiobox this property should be assigned
public void update()
{
move1.Text = moveValidity;
PromotionTable.Visible = true;// in this table there are radioboxes. each radiobox triggers an event that assigned PromotedPiece....
}
private void radioButtonQueen_CheckedChanged(object sender, EventArgs e)
{
PromotedPiece = PromotionPieces.QUEEN;
}
private void radioButtonRook_CheckedChanged(object sender, EventArgs e)
{
PromotedPiece = PromotionPieces.ROOK;
}
private void radioButtonBishop_CheckedChanged(object sender, EventArgs e)
{
PromotedPiece = PromotionPieces.BISHOP;
}
private void radioButtonKnight_CheckedChanged(object sender, EventArgs e)
{
PromotedPiece = PromotionPieces.KNIGHT;
}
}