1) Change the definition of ValidMoves from
private
to
protected
- this allows it to be visible to derived classes.
See here for details[
^]
2) You will have to derive ChessPiece from a control, and handle the paint event to display the image, or modify your form code to display the appropriate pieces.
I would go with the first option, since the chess piece is something that will be interacted with by the user.
"how can i handle the paint event to display image?thanks - arashmobileboy 4 mins ago"
Add an event handler for your Form (or panel - what ever you want to display the piece on) and then use Graphics.DrawImage on the PaintEventArgs Graphics parameter:
private void panel1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(myChessPeiceImage, myChessPeiceLocation);
}
"sorry that it took long time to comment on your answer. should i put siaysah1(the name of kingimage) instead of myChessPeiceImage in your code?because i put the siayhsah1 but it says siaysah1 doesnt exist in the current context(i added the siyahsah1 pic to resources):
private void ChessForm_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(siyahsah1,chess6.Properties.Resources.siyahsah1);
}
- arashmobileboy 5 mins ago"
Assuming you have set an image file as an embedded resource called "myPicture", use:
Image myImage = Properties.Resources.myPicture;
e.Graphics.DrawImage(myImage, new Point(0, 0));