-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmQueryPawnPromotionType.cs
91 lines (85 loc) · 4.3 KB
/
frmQueryPawnPromotionType.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace SrcChess {
/// <summary>Query the promotion type of a pawn</summary>
public partial class frmQueryPawnPromotionType : Form {
private ChessBoard.ValidPawnPromotionE m_eValidPawnPromotion;
//*********************************************************
//
/// <summary>
/// Class constructor
/// </summary>
//
//*********************************************************
public frmQueryPawnPromotionType() {
InitializeComponent();
}
//*********************************************************
//
/// <summary>
/// Class constructor
/// </summary>
/// <param name="eValidPawnPromotion"> The valid pawn promotion type</param>
//
//*********************************************************
public frmQueryPawnPromotionType(ChessBoard.ValidPawnPromotionE eValidPawnPromotion) : this() {
m_eValidPawnPromotion = eValidPawnPromotion;
}
//*********************************************************
//
/// <summary>
/// Get the pawn promotion type
/// </summary>
/// <param name="sender"> Sender object</param>
/// <param name="e"> Event argument</param>
//
//*********************************************************
private void frmQueryPawnPromotionType_Load(object sender, EventArgs e) {
radioButtonQueen.Enabled = ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Queen) != ChessBoard.ValidPawnPromotionE.None);
radioButtonRook.Enabled = ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Rook) != ChessBoard.ValidPawnPromotionE.None);
radioButtonBishop.Enabled = ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Bishop) != ChessBoard.ValidPawnPromotionE.None);
radioButtonKnight.Enabled = ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Knight) != ChessBoard.ValidPawnPromotionE.None);
radioButtonPawn.Enabled = ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Pawn) != ChessBoard.ValidPawnPromotionE.None);
if ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Queen) != ChessBoard.ValidPawnPromotionE.None) {
radioButtonQueen.Checked = true;
} else if ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Rook) != ChessBoard.ValidPawnPromotionE.None) {
radioButtonRook.Checked = true;
} else if ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Bishop) != ChessBoard.ValidPawnPromotionE.None) {
radioButtonBishop.Checked = true;
} else if ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Knight) != ChessBoard.ValidPawnPromotionE.None) {
radioButtonKnight.Checked = true;
} else if ((m_eValidPawnPromotion & ChessBoard.ValidPawnPromotionE.Pawn) != ChessBoard.ValidPawnPromotionE.None) {
radioButtonPawn.Checked = true;
}
}
//*********************************************************
//
/// <summary>
/// Get the pawn promotion type
/// </summary>
//
//*********************************************************
public ChessBoard.MoveTypeE PromotionType {
get {
ChessBoard.MoveTypeE eRetVal;
if (radioButtonRook.Checked) {
eRetVal = ChessBoard.MoveTypeE.PawnPromotionToRook;
} else if (radioButtonBishop.Checked) {
eRetVal = ChessBoard.MoveTypeE.PawnPromotionToBishop;
} else if (radioButtonKnight.Checked) {
eRetVal = ChessBoard.MoveTypeE.PawnPromotionToKnight;
} else if (radioButtonPawn.Checked) {
eRetVal = ChessBoard.MoveTypeE.PawnPromotionToPawn;
} else {
eRetVal = ChessBoard.MoveTypeE.PawnPromotionToQueen;
}
return(eRetVal);
}
}
}
}