C# Class TicTacToeAppWarp.MainPage

Inheritance: BasePage
显示文件 Open project: shephertz/Tutorials_WP_7_8

Private Properties

Property Type Description
ClearStatusText void
DidSomeoneWin string
GameOver void
InitializeBoard void
LockGameboard void
NewGame void
PiecesAvailable bool
Play void
ShowWinningLine void
UnLockGameboard void
UpdateStatus void
UpdateUiFromMove void
_initBoard void
_updateStatus void
appbarEndGame_Click void
appbarHideDiag_Click void
appbarNewGame_Click void
tb_Tap void

Public Methods

Method Description
MainPage ( ) : System
showResult ( String result ) : void

Protected Methods

Method Description
OnNavigatedFrom ( System e ) : void
OnNavigatingFrom ( System e ) : void

Private Methods

Method Description
ClearStatusText ( ) : void
DidSomeoneWin ( ) : string

Hard-coded game logic to keep things simple. There are 8 possible ways someone can get a winning line. I check for each one here.

GameOver ( ) : void

Lock the gameboard when the game is over

InitializeBoard ( ) : void

Clear all board pieces and reset their text color. Also resets the mapping of gamepiece to value

LockGameboard ( ) : void
NewGame ( ) : void

Refreshes the game board and informs the user what gamepiece they are playing

PiecesAvailable ( ) : bool

Check to see if there are any squares on the board still in play

Play ( TextBlock tbTapped, TicTacToeAppWarp.MoveMessage msg ) : void

Play the selected piece.

ShowWinningLine ( TextBlock w1, TextBlock w2, TextBlock w3 ) : void

Add a little bling to the gameboard by showing the winning line in a different color

UnLockGameboard ( ) : void
UpdateStatus ( string status ) : void

Helper method to write a simple status update to a TextBlock on the page. Uses the Dispatcher object if currently not on UI Thread.

UpdateUiFromMove ( TicTacToeAppWarp.MoveMessage msg ) : void
_initBoard ( ) : void

Clear all text on the board, reset font color and clear out internal gamepiece map

_updateStatus ( string status ) : void
appbarEndGame_Click ( object sender, EventArgs e ) : void
appbarHideDiag_Click ( object sender, EventArgs e ) : void
appbarNewGame_Click ( object sender, EventArgs e ) : void
tb_Tap ( object sender, GestureEventArgs e ) : void

Event handler for the Tap event on each gamepiece

Method Details

MainPage() public method

public MainPage ( ) : System
return System

OnNavigatedFrom() protected method

protected OnNavigatedFrom ( System e ) : void
e System
return void

OnNavigatingFrom() protected method

protected OnNavigatingFrom ( System e ) : void
e System
return void

showResult() public method

public showResult ( String result ) : void
result String
return void