private void PageLoaded(object sender, EventArgs e) { // get the needed objects from application properties model = Application.Current.Properties["Model"] as Game; desc = Application.Current.Properties["GameDescriptionProxy"] as GameStringDescriptionProxy; oppInfo = Application.Current.Properties["OpponentsInfo"] as OpponentsInfo; gameLoadSaveManager = Application.Current.Properties["GameLoadSaveOperationsManager"] as GameLoadSaveOperationsManager; speechRecognitionManager = Application.Current.Properties["SpeechRecognitionManager"] as SpeechRecognitionManager; // load the last game gameLoadSaveManager.LoadLastGame(); gameBoard.Model = model; // set the promotion handler model.Promote = new PromotionHandler(GetPromotionPiece); // set the target of the speech commands speechRecognitionManager.Target = this; speechRecognitionManager.Enabled = false; // set the data contexts gameStatusItem.DataContext = desc; sideToMoveItem.DataContext = desc; oppInfoItem.DataContext = oppInfo; speechRecoItem.DataContext = speechRecognitionManager; moveHistory.DataContext = desc.MoveHistoryStringDescriptionList; }
private ValilGame InitValilGame() { GameStringDescriptionProxy gameLoader = new GameStringDescriptionProxy(); gameLoader.Model = new ValilGame(); gameLoader.LoadNewGame(); return(gameLoader.Model); }
private void AppStartup(object sender, StartupEventArgs args) { // put all the necessary objects in application properties // so they could be available in all windows // set the model Game model = new Game(); Properties["Model"] = model; // set the opponent info OpponentsInfo oppInfo = new OpponentsInfo(); oppInfo.Model = model; Properties["OpponentsInfo"] = oppInfo; // set the game description proxy GameStringDescriptionProxy desc = new GameStringDescriptionProxy(); desc.Model = model; Properties["GameDescriptionProxy"] = desc; // set the autosave manager GameLoadSaveOperationsManager gameLoadSaveManager = new GameLoadSaveOperationsManager(); gameLoadSaveManager.Proxy = desc; Properties["GameLoadSaveOperationsManager"] = gameLoadSaveManager; // set the speech recognizer manager SpeechRecognitionManager speechRecognitionManager = new SpeechRecognitionManager(); Properties["SpeechRecognitionManager"] = speechRecognitionManager; // set the text-to-speech manager TTSManager ttsManager = new TTSManager(); ttsManager.Model = model; ttsManager.OppInfo = oppInfo; Properties["TTSManager"] = ttsManager; }