public RecordFramePage(SnookerMatchScore matchScore, SnookerFrameScore frameScore, bool isMatchEditMode)
        {
            this.MatchScore        = matchScore;
            this.CurrentFrameScore = frameScore;
            this.isMatchEditMode   = isMatchEditMode;

            init();
            updateImages();

            if (frameScore.IsEmpty == false)
            {
                this.listOfBreaksInMatchControl.Fill(this.MatchScore, this.MatchScore.FrameScores.IndexOf(this.CurrentFrameScore) + 1);
            }
            else
            {
                this.CurrentFrameScore.A = 0;
                this.CurrentFrameScore.B = 0;
            }

            updateFrameScoreInSnookerBreakControl();
        }
Exemple #2
0
        //
        // Fill the list of breaks in a frame
        //
        public void Fill(SnookerMatchScore match, int frameNumber)
        {
            string debugString = String.Format("ListOfBreaksInMatchControl::Fill(): frame {0}, Enter", frameNumber);

            TraceHelper.TraceInfoForResponsiveness(debugString);

            this.Children.Clear();

            if (match == null || match.YourBreaks == null || match.OpponentBreaks == null)
            {
                this.Breaks = new List <SnookerBreak> ();
                return;
            }

            // list of all breaks
            this.Breaks = new List <SnookerBreak>();
            this.Breaks.AddRange(match.YourBreaks.Where(i => i.FrameNumber == frameNumber).ToList());
            this.Breaks.AddRange(match.OpponentBreaks.Where(i => i.FrameNumber == frameNumber).ToList());
            this.Breaks = this.Breaks.OrderByDescending(i => i.Date).ToList();

            // Check that the Frame score corresponds to the list of breaks
            // and we can display the running frame score with each break
            frameScoreYou      = 0;
            frameScoreOpponent = 0;
            foreach (var snookerBreak in this.Breaks)
            {
                if (match.YourAthleteID == snookerBreak.AthleteID)
                {
                    frameScoreYou += snookerBreak.Points;
                }
                else
                {
                    frameScoreOpponent += snookerBreak.Points;
                }
            }

            SnookerFrameScore frameScore = match.FrameScores.ElementAt(frameNumber - 1);

            if ((frameScore.A == frameScoreYou) && (frameScore.B == frameScoreOpponent))
            {
                // Frame score corresponds to all the breaks entered,
                // display the running frame score after each break
                frameScoreValid = true;
            }
            else
            {
                frameScoreValid = false;                 // don't display running frame score
            }
            // add elements
            foreach (var snookerBreak in this.Breaks)
            {
                //TraceHelper.TraceInfoForResponsiveness(String.Format("break {0}", snookerBreak.Balls.Count));

                this.Children.Add(new BoxView()
                {
                    BackgroundColor = Config.ColorBackground,
                    HeightRequest   = 1,
                });

                bool isOpponentsBreak = match.OpponentBreaks.Contains(snookerBreak);
                addSnookerBreakControls(snookerBreak, isOpponentsBreak);

                // if displaying running frame score, update it
                if (frameScoreValid)
                {
                    if (isOpponentsBreak)
                    {
                        frameScoreOpponent -= snookerBreak.Balls.Sum();
                    }
                    else
                    {
                        frameScoreYou -= snookerBreak.Balls.Sum();
                    }
                }
            }

            debugString = String.Format("ListOfBreaksInMatchControl::Fill(): frame {0}, Exit", frameNumber);
            TraceHelper.TraceInfoForResponsiveness(debugString);
        }