/// <summary> /// Load the requested file/match /// </summary> /// <returns></returns> public async Task Load(String Filename) { try { //Load the data String XML = await Helpers.LocalStorage.Load(Filename); //CompressedXML = ""; //Deserialize TennisMatch StoredMatch = (TennisMatch)Helpers.Serializer.XMLDeserialize(XML, typeof(TennisMatch)); //Restore references //Set it as the current match Match = StoredMatch; StatisticsCollection.SetSource(_Match); } catch (Exception) { ExtendedEventArgs eea = new ExtendedEventArgs(); eea.Error = "An error occured while loading the stored match"; OnFatalError(eea); //throw new Exception(); } }
/// <summary> /// Start the match /// </summary> public void Start(vmNewMatch newMatch) { if (Match == null) { Match = new TennisMatch(); } //Set the properties of the new match Match.Type = newMatch.GetType(); Match.NumberGamesPerSet = newMatch.GamesPerSet; Match.BestOutOf = newMatch.GetBestOutOf(); Match.TieBreakFinalSet = newMatch.TiebreakFinalSet; Match.LogLevel = newMatch.GetLogLevel(); Match.Location = newMatch.Location; Match.MatchSurface = newMatch.GetSurface(); TennisMatchVariant _variant = newMatch.MatchVariants[newMatch.SelectedMatchIndex]; Match.DeuceSuddenDeath = _variant.DeuceSuddenDeath; Match.FinalSetIsTiebreak = _variant.FinalSetIsTiebreak; Match.FinalSetTieBreakLength = _variant.FinalSetTieBreakLength; Match.NumberGamesPerSet = _variant.NumberGamesPerSet; Match.TieBreakAtSameScoreOf = _variant.TieBreakAtSameScoreOf; Match.TieBreakFinalSet = _variant.TieBreakFinalSet; Match.TieBreakLength = _variant.TieBreakLength; StatisticsCollection.SetSource(Match); //Add the players Tennis_Statistics.Game_Logic.TennisPlayer Player1 = new Game_Logic.TennisPlayer(); Player1.Name = newMatch.Player1.Name; Player1.ID = newMatch.Player1.ID; Player1.LocalPlayer = newMatch.Player1.LocalPlayer; Tennis_Statistics.Game_Logic.TennisPlayer Player2 = new Game_Logic.TennisPlayer(); Player2.Name = newMatch.Player2.Name; Player2.ID = newMatch.Player2.ID; Player2.LocalPlayer = newMatch.Player2.LocalPlayer; Match.Contestant1.Players.Add(Player1); Match.Contestant2.Players.Add(Player2); //Add partners if (Match.Type == TennisMatch.MatchType.Doubles) { Tennis_Statistics.Game_Logic.TennisPlayer Partner1 = new Game_Logic.TennisPlayer(); Partner1.Name = newMatch.Player1Partner.Name; Partner1.ID = newMatch.Player2Partner.ID; Partner1.LocalPlayer = newMatch.Player1Partner.LocalPlayer; Tennis_Statistics.Game_Logic.TennisPlayer Partner2 = new Game_Logic.TennisPlayer(); Partner2.Name = newMatch.Player2Partner.Name; Partner2.ID = newMatch.Player2Partner.ID; Partner2.LocalPlayer = newMatch.Player2Partner.LocalPlayer; Match.Contestant1.Players.Add(Partner1); Match.Contestant2.Players.Add(Partner2); } CurrentPoint.LogLevel = Match.LogLevel; //Start the new set Match.StartNewSet(); NewPoint(); }