/// <summary> /// Load the settings from local storage /// </summary> /// <returns></returns> public static async Task <vmNewMatch> Load() { vmNewMatch _vmNewMatch = new vmNewMatch(); try { //Load the last settings from local storage and deserialize String StoredSettingsNewMatch = await Helpers.LocalStorage.Load("newmatchsettings.gz"); if (StoredSettingsNewMatch.Length > 0) { _vmNewMatch = (vmNewMatch)Helpers.Serializer.DecompressAndDeserialize(StoredSettingsNewMatch, typeof(vmNewMatch)); if (_vmNewMatch == null) { _vmNewMatch = new vmNewMatch(); } } } catch (Exception e) { //An error occurred, create a brand new one _vmNewMatch = new vmNewMatch(); } //await _vmNewMatch.GetPositionAsync(); //_vmNewMatch.PreviousPlayers.AddOrUpdateLocalPlayer(); return(_vmNewMatch); }
/// <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(); }