: .NET Compact Framework

13.1.

13.1.

#Const PLAYFIELD_ON_BOTTOM = 0 '
'#Const PLAYFIELD_ON_BOTTOM = 1 '
'-------------------------------------------------
' :
'-------------------------------------------------
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'
SetStartControlPositionAndState()
' , ,
'
StateChangeForGameUI(GameUIState.startScreen)
End Sub
'---------------------------------------------------------------------------
' , ,
'---------------------------------------------------------------------------
Private Enum GameUIState
startScreen = 1
waitForNextQuestion = 2
waitForUserToStateKnowledge = 4
waitForUserToAnswerMultipleChoice = 8
End Enum
'
Private m_GameUIState As GameUIState
'==========================================================================
' ,
'==========================================================================
Private Sub StateChangeForGameUI(ByVal newGameUIState As _
GameUIState)
m_GameUIState = newGameUIState
Select Case (newGameUIState)
Case GameUIState.startScreen
buttonAskQuestion.Visible = True
buttonAskQuestion.Text = "Start"
'
textBoxAskQuestion.Visible = False
SetAnswerButtonVisibility(False)
SetDifficultyButtonVisibility(False)
Case GameUIState.waitForNextQuestion
setQuestionText("List answer details here... " + vbCrLf + _
"Lots of space to write..." + vbCrLf + _
"Waiting for user to select next question...")
textBoxAskQuestion.Visible = True
buttonAskQuestion.Text = "Next"
buttonAskQuestion.Visible = True
' ,
buttonAskQuestion.BringToFront()
SetAnswerButtonVisibility(False)
SetDifficultyButtonVisibility(False)
#If PLAYFIELD_ON_BOTTOM <> 0 Then '
textBoxAskQuestion.Height = pictureBoxGameBoard.Top - 2
#Else '
textBoxAskQuestion.Top = pictureBoxGameBoard.Top + _
pictureBoxGameBoard.Height + 2
textBoxAskQuestion.Height = Me.Height - _
textBoxAskQuestion.Top
#End If
Case GameUIState.waitForUserToStateKnowledge
SetTextForVocabularyQuestion()
textBoxAskQuestion.Visible = True
buttonAskQuestion.Visible = False
SetAnswerButtonVisibility(False)
SetDifficultyButtonVisibility(True)
#If PLAYFIELD_ON_BOTTOM <> 0 Then '
textBoxAskQuestion.Height = _
buttonShowAnswers_AdvancedVersion.Top - 2
#Else '
textBoxAskQuestion.Top = _
buttonShowAnswers_AdvancedVersion.Top + _
buttonShowAnswers_AdvancedVersion.Height + 2
textBoxAskQuestion.Height = Me.Height - _
textBoxAskQuestion.Top
#End If
Case GameUIState.waitForUserToAnswerMultipleChoice
buttonAskQuestion.Visible = False
SetDifficultyButtonVisibility(False)
' ,
SetAnswerButtonEnabled(True)
SetAnswerButtonVisibility(True)
#If PLAYFIELD_ON_BOTTOM <> 0 Then
'
textBoxAskQuestion.Height = buttonAnswer0.Top - 2
#Else '
' ,
'
textBoxAskQuestion.Top = buttonAnswer5.Top + _
buttonAnswer5.Height + 2
textBoxAskQuestion.Height = Me.Height - _
textBoxAskQuestion.Top
#End If
End Select
End Sub
'========================================================================
' .
' , .
'
'
'========================================================================
Private Sub SetStartControlPositionAndState()
pictureBoxGameBoard.Width = 240
pictureBoxGameBoard.Height = 176
'
Const answerButtons_dx As Integer = 117
Const answerButtons_dy As Integer = 18
buttonAnswer0.Width = answerButtons_dx
buttonAnswer0.Height = answerButtons_dy
buttonAnswer1.Size = buttonAnswer0.Size
buttonAnswer2.Size = buttonAnswer0.Size
buttonAnswer3.Size = buttonAnswer0.Size
buttonAnswer4.Size = buttonAnswer0.Size
buttonAnswer5.Size = buttonAnswer0.Size
buttonShowAnswers_AdvancedVersion.Width = answerButtons_dx
buttonShowAnswers_AdvancedVersion.Height = 24
buttonShowAnswers_SimpleVersion.Size = _
buttonShowAnswers_AdvancedVersion.Size
' ( )
Const dx_betweenButtons As Integer = 3
Const dy betweenButtons As Integer = 2
Const answerbuttons_beginX As Integer = 3
' ,
'
Dim gameBoard As System.Drawing.Bitmap
gameBoard = New System.Drawing.Bitmap( _
pictureBoxGameBoard.Width, pictureBoxGameBoard.Height)
Dim gameboard_gfx As System.Drawing.Graphics
gameboard_gfx = System.Drawing.Graphics.FromImage(gameBoard)
gameboard_gfx.Clear(System.Drawing.Color.Yellow)
Dim myPen As System.Drawing.Pen = New System.Drawing.Pen( _
System.Drawing.Color.Blue)
gameboard_gfx.DrawRectangle(myPen, 2, 2, _
gameBoard.Width - 4, gameBoard.Height - 6)
myPen.Dispose()
gameboard_gfx.Dispose()
pictureBoxGameBoard.Image = gameBoard
' , ,
'
textBoxAskQuestion.Left = 0
textBoxAskQuestion.Width = 240
buttonAskQuestion.Width = 64
buttonAskQuestion.Height = 20
#If PLAYFIELD_ON_BOTTOM <> 0 Then '
Const answerbuttons_beginY As Integer = 42
Const showanswers_beginY As Integer = 77
'------------------------------------------------------------
' "Easy" "Hard"
'------------------------------------------------------------
buttonShowAnswers_AdvancedVersion.Top = showanswers_beginY
buttonShowAnswers_SimpleVersion.Top = showanswers_beginY
'------------------------------
'
'------------------------------
' ,
'
buttonAnswer0.Top = answerbuttons_beginY
' PictureBox
pictureBoxGameBoard.Top = _
(answerButtons dy + dy betweenButtons) * 3 + _
answerbuttons_beginY
buttonAskQuestion.Top = 0
buttonAskQuestion.Left = 174
textBoxAskQuestion.Top = 0
#Else '
Const answerbuttons_beginY As Integer = 174
'------------------------------------------------------------
' "Easy" "Hard"
'------------------------------------------------------------
buttonShowAnswers_AdvancedVersion.Top = answerbuttons_beginY
buttonShowAnswers_SimpleVersion.Top = answerbuttons_beginY
'-----------------------------
'
'-----------------------------
' ,
'
buttonAnswer0.Top = answerbuttons_beginY
pictureBoxGameBoard.Top = 0
buttonAskQuestion.Top = answerbuttons_beginY
buttonAskQuestion.Left = 174
#End If
buttonShowAnswers AdvancedVersion.Left = answerbuttons_beginX
buttonShowAnswers_SimpleVersion.Left = _
buttonShowAnswers_AdvancedVersion.Left + _
answerButtons dx + dx_betweenButtons
pictureBoxGameBoard.Left = 0
pictureBoxGameBoard.Width = 240
pictureBoxGameBoard.Height = 172
buttonAnswer0.Left = answerbuttons_beginX
buttonAnswer1.Left = buttonAnswer0.Left + answerButtons_dx + _
dx_betweenButtons
buttonAnswer1.Top = buttonAnswer0.Top
'
buttonAnswer2.Left = buttonAnswer0.Left
buttonAnswer2.Top = buttonAnswer0.Top + answerButtons_dy + _
dy_betweenButtons
buttonAnswer3.Left = buttonAnswer2.Left + answerButtons_dx + _
dx_betweenButtons
buttonAnswer3.Top = buttonAnswer2.Top
'
buttonAnswer4.Left = buttonAnswer2.Left
buttonAnswer4.Top = buttonAnswer2.Top + answerButtons_dy + _
dy_betweenButtons
buttonAnswer5.Left = buttonAnswer4.Left + answerButtons_dx + _
dx_betweenButtons
buttonAnswer5.Top = buttonAnswer4.Top
End Sub
'-----------------------------------------------------------------------
' ,
',
'-----------------------------------------------------------------------
Private Sub SetAnswerButtonVisibility(ByVal visibleState _
As Boolean)
buttonAnswer0.Visible = visibleState
buttonAnswer1.Visible = visibleState
buttonAnswer2.Visible = visibleState
buttonAnswer3.Visible = visibleState
buttonAnswer4.Visible = visibleState
buttonAnswer5.Visible = visibleState
End Sub
'-----------------------------------------------------------------
' ,
'
'-----------------------------------------------------------------
Private Sub SetDifficultyButtonVisibility(ByVal visibleState _
As Boolean)
buttonShowAnswers_AdvancedVersion.Visible = visibleState
buttonShowAnswers_SimpleVersion.Visible = visibleState
End Sub
'-----------------------------------------------------------------------
' ,
',
'-----------------------------------------------------------------------
Private Sub SetAnswerButtonEnabled(ByVal enabledState _
As Boolean)
buttonAnswer0.Enabled = enabledState
buttonAnswer1.Enabled = enabledState
buttonAnswer2.Enabled = enabledState
buttonAnswer3.Enabled = enabledState
buttonAnswer4.Enabled = enabledState
buttonAnswer5.Enabled = enabledState
End Sub
'-----------------------------------------------------------------
' ,
' .
'
'
'
'-----------------------------------------------------------------
Private Sub SetTextForVocabularyQuestion()
setQuestionText("What is the English word for 'der Mensch'?")
buttonAnswer0.Text = "Four"
buttonAnswer1.Text = "Person"
buttonAnswer2.Text = "Three"
buttonAnswer3.Text = "To Jump"
buttonAnswer4.Text = "Newspaper"
buttonAnswer5.Text = "Brother"
End Sub
' ,
Private Sub evaluateMultipleChoiceAnswer(ByVal buttonClicked _
As Button, ByVal selection As Integer)
':
' " #1"
' ,
'
If (selection <> 1) Then
'
buttonClicked.Enabled = False
Else
' ,
StateChangeForGameUI(GameUIState.waitForNextQuestion)
End If
End Sub
',
Sub setQuestionText(ByVal textIn As String)
textBoxAskQuestion.Text = textIn
End Sub
'----------------------------------------------------------------
' :
'----------------------------------------------------------------
Private Sub buttonAskQuestion_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles buttonAskQuestion.Click
SetTextForVocabularyQuestion()
StateChangeForGameUI(GameUIState.waitForUserToStateKnowledge)
End Sub
'---------------------------------------------------------------------
' :
' ,
'
'---------------------------------------------------------------------
Private Sub buttonShowAnswers AdvancedVersion_Click( _
ByVal sender As Object, ByVal e As System.EventArgs) _
Handles buttonShowAnswers_AdvancedVersion.Click
'
StateChangeForGameUI( _
GameUIState.waitForUserToAnswerMultipleChoice)
End Sub
'---------------------------------------------------------------------
' :
' ,
'
'---------------------------------------------------------------------
Private Sub buttonShowAnswers_SimpleVersion_Click( _
ByVal sender As Object, ByVal e As System.EventArgs) _
Handles buttonShowAnswers_SimpleVersion.Click
'
StateChangeForGameUI( _
GameUIState.waitForUserToAnswerMultipleChoice)
End Sub
' :
Private Sub buttonAnswer0_Click(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles buttonAnswer0.Click
evaluateMultipleChoiceAnswer(buttonAnswer0, 0)
End Sub
' :
Private Sub buttonAnswer1_Click(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles buttonAnswer1.Click
evaluateMultipleChoiceAnswer(buttonAnswer1, 1)
End Sub
' :
Private Sub buttonAnswer2_Click(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles buttonAnswer2.Click
evaluateMultipleChoiceAnswer(buttonAnswer2, 2)
End Sub
' :
Private Sub buttonAnswer3_Click(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles buttonAnswer3.Click
evaluateMultipleChoiceAnswer(buttonAnswer3, 3)
End Sub
' :
Private Sub buttonAnswer4_Click(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles buttonAnswer4.Click
evaluateMultipleChoiceAnswer(buttonAnswer4, 4)
End Sub
' :
Private Sub buttonAnswer5_Click(ByVal sender As Object, ByVal _
e As System.EventArgs) Handles buttonAnswer5.Click
evaluateMultipleChoiceAnswer(buttonAnswer5, 5)
End Sub


: 1.224. /Cache: 3 / 1