Exemplo n.º 1
0
        /// <summary>
        /// Initialize an instance with the contents of a tennisset
        /// </summary>
        /// <param name="instance"></param>
        /// <param name="set"></param>
        public static void Initialize(vmSetScore instance, TennisSet set)
        {
            instance.Score1 = set.ScoreContestant1.ToString();
            instance.Score2 = set.ScoreContestant2.ToString();

            instance.Index      = set.PartOf.Sets.IndexOf(set) + 1;
            instance.InProgress = (set.Winner == 0);

            if (set.Games.Count > 1)
            {
                TennisGame LastGame = set.Games[set.Games.Count - 1];
                if (LastGame.GetType() == typeof(TennisTiebreak))
                {
                    instance.IsTiebreak = true;

                    if (!instance.InProgress)
                    {
                        instance.Score1Tiebreak = LastGame.getScoreContestant(1);
                        instance.Score2Tiebreak = LastGame.getScoreContestant(2);
                    }
                }
            }
        }