/// <summary> /// Loads the board configuration and the moves from PGN into the model. /// Throws ArgumentException if the board configuration or one of the moves is not valid. /// Does nothing if the model is null. /// </summary> /// <param name="tr"></param> public void LoadGame(TextReader tr) { if (model == null) { return; } // build the event args CancelEventArgs emptyArgs = new CancelEventArgs(); // raise the Loading event on the model model.OnLoading(emptyArgs); // if the operation was cancelled if (emptyArgs.Cancel) { return; } try { // initialize the game form the PGN tag pairs try { InitializeGameFromPGNTagPairs(tr); } catch { throw; } finally { // raise the GameBoardConfigurationLoaded event on the model model.OnGameBoardConfigurationLoaded(EventArgs.Empty); } // traverse the PGN movetext section TraversePGNMovetext(tr); } catch { throw; } finally { // raise the GameMoveSectionLoaded event on the model model.OnGameMoveSectionLoaded(EventArgs.Empty); } }