public async Task <FullSnookerPlayerData> LoadForPlayer(int athleteID)
        {
            FullSnookerPlayerData data = new FullSnookerPlayerData();

            data.AthleteID = athleteID;

            var webResults = await App.WebService.GetResults(data.AthleteID);

            if (webResults != null)
            {
                var results = (from r in webResults
                               select r.ToResult()).ToList();
                data.Breaks = (from i in results
                               select SnookerBreak.FromResult(i)).ToList();
            }
            else
            {
                data.InternetIssues = true;
            }

            var scores = await App.WebService.GetScores(data.AthleteID);

            if (scores != null)
            {
                data.Matches = (from i in scores
                                select SnookerMatchScore.FromScore(data.AthleteID, i)).ToList();
            }
            else
            {
                data.InternetIssues = true;
            }

            await loadOpponents(data);
            await loadVenues(data);

            data.Person = await App.WebService.GetPersonByID(data.AthleteID);

            if (data.Person == null)
            {
                data.InternetIssues = true;
            }

            this.putPlaceholdersIfInternetIssues(data);
            return(data);
        }
        public async Task <FullSnookerPlayerData> LoadForMe()
        {
            DateTime timeBegin = DateTime.Now;

            FullSnookerPlayerData data = new FullSnookerPlayerData();

            data.AthleteID = App.Repository.GetMyAthleteID();

            var results = App.Repository.GetResults(data.AthleteID, false);

            data.Breaks = (from i in results
                           select SnookerBreak.FromResult(i)).ToList();

            var scores = App.Repository.GetScores(false);

            data.Matches = (from i in scores
                            select SnookerMatchScore.FromScore(data.AthleteID, i)).ToList();

            await loadOpponents(data);
            await loadVenues(data);

            data.Person = await App.WebService.GetPersonByID(data.AthleteID);

            if (data.Person == null)
            {
                data.InternetIssues = true;

                var athlete = App.Repository.GetAthlete(data.AthleteID);
                data.Person = new PersonFullWebModel();
                data.Person.CopyFrom(athlete);
            }

            this.putPlaceholdersIfInternetIssues(data);

            if (data.InternetIssues == false && data.Person != null)
            {
                await App.Cache.LoadFromWebserviceIfNecessary_Metro(data.Person.MetroID);
            }

            TraceHelper.TraceTimeSpan(timeBegin, DateTime.Now, "FullSnookerPlayerDataHelper.LoadForMe");
            return(data);
        }
Пример #3
0
        async void ctrl_UserWantsToDeleteScore(object sender, SnookerEventArgs e)
        {
            if (this.IsMyAthlete == false)
            {
                return;
            }

            SnookerMatchScore match = e.MatchScore;

            bool ok = await App.Navigator.NavPage.DisplayAlert("Byb", "Delete match " + match.ToString() + " ?", "Yes, delete", "Cancel");

            if (ok == false)
            {
                return;
            }

            App.Repository.SetIsDeletedOnScore(match.ID, true);
            App.Navigator.StartSyncAndCheckForNotifications();

            this.loadDataAsyncAndFill(false);
        }
Пример #4
0
        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();
        }
Пример #5
0
        public SnookerMatchMetadata FromScoreForYou(SnookerMatchScore score)
        {
            var me = App.Repository.GetMyAthlete();

            SnookerMatchMetadata metadata = new SnookerMatchMetadata()
            {
                Date                  = score.Date,
                PrimaryAthleteID      = me.AthleteID,
                PrimaryAthleteName    = me.Name ?? "",
                PrimaryAthletePicture = me.Picture,
                OpponentAthleteID     = score.OpponentAthleteID,
                OpponentAthleteName   = score.OpponentName ?? "",
                OpponentPicture       = score.OpponentPicture,
                TableSize             = score.TableSize,
                VenueID               = score.VenueID,
                VenueName             = score.VenueName,
            };

            if (metadata.OpponentAthleteID > 0)
            {
                var person = App.Cache.People.Get(metadata.OpponentAthleteID);
                if (person != null)
                {
                    metadata.OpponentAthleteName = person.Name;
                    metadata.OpponentPicture     = person.Picture;
                }
            }

            if (metadata.VenueID > 0)
            {
                var venue = App.Cache.Venues.Get(metadata.VenueID);
                if (venue != null)
                {
                    metadata.VenueName = venue.Name;
                }
            }

            return(metadata);
        }
Пример #6
0
        void fillPausedMatches()
        {
            // incompleted matches in the db
            var scoreObjs = (from i in App.Repository.GetScores(false)
                             where i.IsUnfinished == true
                             orderby i.TimeModified descending
                             select i).ToList();

            this.panelNewMatch.IsVisible = scoreObjs.Count() == 0;
            this.panelPausedMatches.Children.Clear();

            foreach (var scoreObj in scoreObjs)
            {
                var match         = SnookerMatchScore.FromScore(scoreObj.AthleteAID, scoreObj);
                var matchMetadata = new MetadataHelper().FromScoreForYou(match);

                var metadataControl = new SnookerMatchMetadataControl(matchMetadata, true)
                {
                    Padding = new Thickness(0, 0, 0, 0)
                };
                this.panelPausedMatches.Children.Add(metadataControl);

                var buttonDelete = new BybButton()
                {
                    Text              = "Cancel the match",
                    Style             = (Style)App.Current.Resources["BlackButtonStyle"],
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                };
                buttonDelete.Clicked += async(s1, e1) =>
                {
                    if (await App.Navigator.NavPage.DisplayAlert("Byb", "Delete this match?", "Yes, delete", "Cancel") == true)
                    {
                        App.Repository.SetIsDeletedOnScore(scoreObj.ScoreID, true);
                        this.DoOnOpen();
                    }
                };

                var buttonContinue = new BybButton()
                {
                    Text              = "Continue the match",
                    Style             = (Style)App.Current.Resources["LargeButtonStyle"],
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                };
                buttonContinue.Clicked += async(s1, e1) =>
                {
                    new MetadataHelper().ToScore(matchMetadata, match);

                    var page = new RecordMatchPage(match, false);
                    await App.Navigator.NavPage.Navigation.PushModalAsync(page);
                };

                this.panelPausedMatches.Children.Add(new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Padding           = new Thickness(0, 12, 0, 0),
                    Spacing           = 1,
                    Children          =
                    {
                        buttonDelete,
                        buttonContinue
                    }
                });
                this.panelPausedMatches.Children.Add(new BoxView()
                {
                    HeightRequest = 25
                });

                // load opponent names from web if it's not loaded yet
                if (matchMetadata.OpponentAthleteID > 0 && string.IsNullOrEmpty(matchMetadata.OpponentAthleteName) == true)
                {
                    Task.Run(async() =>
                    {
                        await App.Cache.LoadFromWebserviceIfNecessary_People(new List <int> ()
                        {
                            matchMetadata.OpponentAthleteID
                        });
                        var person = App.Cache.People.Get(matchMetadata.OpponentAthleteID);
                        if (person != null)
                        {
                            Device.BeginInvokeOnMainThread(() =>
                            {
                                match.OpponentName                = person.Name;
                                match.OpponentPicture             = person.Picture;
                                matchMetadata.OpponentAthleteName = person.Name;
                                matchMetadata.OpponentPicture     = person.Picture;
                                metadataControl.Refill();
                            });
                        }
                    });
                }
                ;
            }
        }
Пример #7
0
        private PersonFullWebModel getFull(int myAthleteID, int athleteID)
        {
            var _person = this.getBasic(myAthleteID, db.Athletes.Where(a => a.AthleteID == athleteID)).FirstOrDefault();

            if (_person == null)
            {
                return(null);
            }

            var person = new PersonFullWebModel();

            _person.CopyTo(person);

            var athlete = (from a in db.Athletes.Include("Friendships1").Include("Friendships2").Include("ScoreAs").Include("ScoreBs").Include("Results")
                           where a.AthleteID == athleteID
                           select a).Single();

            // added in 01/25/2016:
            person.IsFriendRequestSentByThisPerson = false;
            if (person.IsFriend == false)
            {
                if (athlete.Friendships1.Where(i => i.Athlete1ID == athleteID && i.FriendshipStatus == (int)FriendshipStatusEnum.Initiated).Count() == 1)
                {
                    person.IsFriendRequestSentByThisPerson = true;
                }
            }

            // basic stats
            person.SnookerStats = new SnookerStatsModel();
            person.SnookerStats.CountContributions = (from i in athlete.VenueEdits
                                                      select i.VenueID).Distinct().Count();
            person.SnookerStats.CountBests = (from r in athlete.Results
                                              where r.OpponentConfirmation != (int)OpponentConfirmationEnum.Declined
                                              where r.IsDeleted == false
                                              select r).Count();
            person.SnookerStats.CountMatches = (from s in athlete.ScoreAs
                                                where s.AthleteBConfirmation != (int)OpponentConfirmationEnum.Declined
                                                where s.IsDeleted == false
                                                select s).Count()
                                               +
                                               (from s in athlete.ScoreBs
                                                where s.AthleteBConfirmation == (int)OpponentConfirmationEnum.Confirmed
                                                where s.IsDeleted == false
                                                select s).Count();
            person.SnookerStats.BestBallCount = (from r in athlete.Results
                                                 where r.OpponentConfirmation != (int)OpponentConfirmationEnum.Declined
                                                 where r.IsDeleted == false
                                                 select r).Max(i => i.Count2) ?? 0;
            person.SnookerStats.BestPoints = (from r in athlete.Results
                                              where r.OpponentConfirmation != (int)OpponentConfirmationEnum.Declined
                                              where r.IsDeleted == false
                                              select r).Max(i => i.Count) ?? 0;

            // best frame score
            //var matchesA = (from i in athlete.ScoreAs
            //                select SnookerMatchScore.FromScore(myAthleteID, i));
            //var matchesB = (from i in athlete.ScoreBs
            //                where i.AthleteBConfirmation == (int)OpponentConfirmationEnum.Confirmed
            //                select SnookerMatchScore.FromScore(myAthleteID, i));
            List <SnookerMatchScore> matches = new List <SnookerMatchScore>();

            matches.AddRange(from i in athlete.ScoreAs
                             where i.IsDeleted == false
                             select SnookerMatchScore.FromScore(myAthleteID, i));
            matches.AddRange(from i in athlete.ScoreBs
                             where i.AthleteBConfirmation == (int)OpponentConfirmationEnum.Confirmed
                             where i.IsDeleted == false
                             select SnookerMatchScore.FromScore(myAthleteID, i));
            person.SnookerStats.BestFrameScore = (from m in matches
                                                  from f in m.FrameScores
                                                  select(int?) f.A).Max() ?? 0;
            //int maxA = (from m in matchesA
            //            from f in m.FrameScores
            //            select (int?)f.A).Max() ?? 0;
            //int maxB = (from m in matchesB
            //            from f in m.FrameScores
            //            select (int?)f.B).Max() ?? 0;
            //person.SnookerStats.BestFrameScore = System.Math.Max(maxA, maxB);

            // number of venues
            var venues1 = (from r in athlete.Results
                           where r.OpponentConfirmation != (int)OpponentConfirmationEnum.Declined
                           where r.IsDeleted == false
                           where r.VenueID != null
                           select r.VenueID.Value).Distinct().ToList();
            var venues2 = (from s in athlete.ScoreAs
                           where s.AthleteBConfirmation != (int)OpponentConfirmationEnum.Declined
                           where s.IsDeleted == false
                           where s.VenueID != null
                           select s.VenueID.Value).Distinct().ToList();
            var venues3 = (from s in athlete.ScoreBs
                           where s.AthleteBConfirmation != (int)OpponentConfirmationEnum.Declined
                           where s.IsDeleted == false
                           where s.VenueID != null
                           select s.VenueID.Value).Distinct().ToList();
            List <int> venues = venues1.ToList();

            foreach (var i in venues2)
            {
                if (venues.Contains(i) == false)
                {
                    venues.Add(i);
                }
            }
            foreach (var i in venues3)
            {
                if (venues.Contains(i) == false)
                {
                    venues.Add(i);
                }
            }
            person.SnookerStats.CountVenuesPlayed = venues.Count();

            // number of opponents
            var opponents1 = (from r in athlete.Results
                              where r.OpponentAthleteID != null && r.OpponentAthleteID != 0
                              where r.OpponentConfirmation != (int)OpponentConfirmationEnum.Declined
                              where r.IsDeleted == false
                              select r.OpponentAthleteID.Value).Distinct().ToList();
            var opponents2 = (from s in athlete.ScoreAs
                              where s.AthleteBID != 0
                              where s.AthleteBConfirmation != (int)OpponentConfirmationEnum.Declined
                              where s.IsDeleted == false
                              select s.AthleteBID).Distinct().ToList();
            var opponents3 = (from s in athlete.ScoreBs
                              where s.AthleteAID != 0
                              where s.AthleteBConfirmation != (int)OpponentConfirmationEnum.Declined
                              where s.IsDeleted == false
                              select s.AthleteAID).Distinct().ToList();
            List <int> opponents = opponents1.ToList();

            foreach (var i in opponents2)
            {
                if (opponents.Contains(i) == false)
                {
                    opponents.Add(i);
                }
            }
            foreach (var i in opponents3)
            {
                if (opponents.Contains(i) == false)
                {
                    opponents.Add(i);
                }
            }
            person.SnookerStats.CountOpponentsPlayed = opponents.Count;

            return(person);
        }
Пример #8
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);
        }
Пример #9
0
        public void Fill(List <SnookerMatchScore> matches)
        {
            try
            {
                this.Matches = matches;

                var itemsToRemove = this.Children.ToList();
                itemsToRemove.Remove(panelTop);

                this.panelsToResize = new List <StackLayout>();

                if (this.Matches == null)
                {
                    this.SortedMatches = new List <SnookerMatchScore>();
                }
                else
                {
                    this.SortedMatches = SnookerMatchScore.Sort(matches, SortType);
                }

                if (Matches == null)
                {
                    string text = "Couldn't load data. Internet issues?";
                    this.Children.Add(new BoxView {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    });
                    this.Children.Add(new BybLabel
                    {
                        Text = text,
                        HorizontalOptions = LayoutOptions.Center
                    });
                    this.Children.Add(new BoxView {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    });
                }
                else if (this.SortedMatches.Count == 0)
                {
                    string text = "No matches have been recorded yet";
                    this.Children.Add(new BoxView {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    });
                    this.Children.Add(new BybLabel
                    {
                        Text = text,
                        HorizontalOptions       = LayoutOptions.Center,
                        HorizontalTextAlignment = TextAlignment.Center
                    });
                    this.Children.Add(new BoxView {
                        Style = (Style)App.Current.Resources["BoxViewPadding1Style"]
                    });
                }

                foreach (var match in this.SortedMatches)
                {
                    // opponent
                    FormattedString formattedString = new FormattedString();
                    formattedString.Spans.Add(new Span()
                    {
                        Text = string.IsNullOrEmpty(match.YourName) ? "-" : match.YourName, FontAttributes = FontAttributes.Bold, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize
                    });
                    formattedString.Spans.Add(new Span()
                    {
                        Text = " vs. ", ForegroundColor = Config.ColorGrayTextOnWhite
                    });
                    formattedString.Spans.Add(new Span()
                    {
                        Text = string.IsNullOrEmpty(match.OpponentName) ? "-" : match.OpponentName, FontAttributes = FontAttributes.Bold, FontFamily = Config.FontFamily, FontSize = Config.DefaultFontSize
                    });
                    //if (match.OpponentConfirmation == OpponentConfirmationEnum.Confirmed)
                    //{
                    //}
                    //else if (match.OpponentConfirmation == OpponentConfirmationEnum.Declined)
                    //    formattedString.Spans.Add(new Span() { Text = "  (declined)", ForegroundColor = Config.ColorTextOnBackgroundGrayed });
                    //else
                    //    formattedString.Spans.Add(new Span() { Text = "  (unconfirmed)", ForegroundColor = Config.ColorTextOnBackgroundGrayed });
                    Label labelOpponent = new BybLabel()
                    {
                        FormattedText = formattedString, VerticalTextAlignment = TextAlignment.Center
                    };
                    if (match.OpponentAthleteID > 0)
                    {
                        labelOpponent.GestureRecognizers.Add(new TapGestureRecognizer()
                        {
                            Command = new Command(async() =>
                            {
                                await App.Navigator.GoToPersonProfile(match.OpponentAthleteID);
                            }),
                            NumberOfTapsRequired = 1
                        });
                    }

                    // venue
                    string venueName = match.VenueName;
                    if (string.IsNullOrEmpty(venueName))
                    {
                        venueName = "-";
                    }
                    Label labelVenue = new BybLabel()
                    {
                        Text = venueName, VerticalTextAlignment = TextAlignment.Center, TextColor = Config.ColorGrayTextOnWhite
                    };
                    if (match.VenueID > 0)
                    {
                        labelVenue.GestureRecognizers.Add(new TapGestureRecognizer()
                        {
                            Command = new Command(async() =>
                            {
                                await App.Navigator.GoToVenueProfile(match.VenueID);
                            }),
                            NumberOfTapsRequired = 1
                        });
                    }

                    // frames
                    Label labelForFrames = new BybLabel()
                    {
                        LineBreakMode           = LineBreakMode.WordWrap,
                        HorizontalOptions       = LayoutOptions.Fill,
                        HorizontalTextAlignment = TextAlignment.Start,
                    };
                    if (match.HasFrameScores)
                    {
                        FormattedString formattedStringScores = new FormattedString();

                        foreach (var frame in match.FrameScores)
                        {
                            if (match.FrameScores.First() != frame)
                            {
                                formattedStringScores.Spans.Add(new Span()
                                {
                                    Text            = " , ",
                                    FontAttributes  = FontAttributes.None,
                                    FontSize        = Config.DefaultFontSize,
                                    FontFamily      = Config.FontFamily,
                                    ForegroundColor = Config.ColorGrayTextOnWhite,
                                });
                            }

                            Color color = Config.ColorGray;
                            if (frame.A > frame.B)
                            {
                                color = Config.ColorGreen;
                            }
                            else if (frame.A < frame.B)
                            {
                                color = Config.ColorRed;
                            }

                            formattedStringScores.Spans.Add(new Span()
                            {
                                Text            = frame.A + ":" + frame.B,
                                FontAttributes  = FontAttributes.Bold,
                                FontSize        = Config.DefaultFontSize,
                                FontFamily      = Config.FontFamily,
                                ForegroundColor = color,
                            });
                        }

                        labelForFrames.FormattedText = formattedStringScores;
                    }
                    //                    StackLayout stackForFrames = new StackLayout()
                    //                    {
                    //                        Orientation = StackOrientation.Horizontal,
                    //                        Spacing = 8,
                    //                        Padding = new Thickness(0,0,0,0)
                    //                    };
                    //                    ScrollView scrollViewForFrames = new ScrollView()
                    //                    {
                    //                        Orientation = ScrollOrientation.Horizontal,
                    //                        Padding = new Thickness(0),
                    //                        Content = stackForFrames
                    //                    };
                    //                    if (match.HasFrameScores)
                    //                    {
                    //                        foreach (var frame in match.FrameScores)
                    //                        {
                    //                            Color color = Config.ColorGray;
                    //                            if (frame.A > frame.B)
                    //                                color = Config.ColorGreen;
                    //                            else if (frame.A < frame.B)
                    //                                color = Config.ColorRed;
                    //
                    //                            Label label = new BybLabel()
                    //                            {
                    //                                Text = frame.A + ":" + frame.B,
                    //                                FontAttributes = FontAttributes.Bold,
                    //                                TextColor = color,
                    //                                VerticalOptions = LayoutOptions.Center
                    //                            };
                    //                            stackForFrames.Children.Add(label);
                    //                        }
                    //                    }

                    // match color
                    //Color matchColor = match.MatchScoreA > match.MatchScoreB ? Config.ColorGreen : (match.MatchScoreA < match.MatchScoreB ? Config.ColorRed : Config.ColorGray);
                    Color matchColor = Config.ColorGray;
                    if (match.IsUnfinished)
                    {
                        matchColor = Config.ColorGray;
                    }

                    var panel1_1 = new StackLayout
                    {
                        Orientation         = StackOrientation.Vertical,
                        Padding             = new Thickness(0, 8, 0, 0),
                        WidthRequest        = Config.IsTablet ? 120 : 80,
                        MinimumWidthRequest = Config.IsTablet ? 100 : 80,
                        HeightRequest       = Config.IsTablet ? 55 : 45,
                        HorizontalOptions   = LayoutOptions.Center,
                        VerticalOptions     = LayoutOptions.Start,
                        BackgroundColor     = matchColor,
                        Spacing             = 2,
                        Children            =
                        {
                            new BybLabel
                            {
                                Text              = match.IsUnfinished ? "PAUSED" : "Score",
                                FontAttributes    = match.IsUnfinished ? Xamarin.Forms.FontAttributes.Bold : FontAttributes.None,
                                TextColor         = match.IsUnfinished ? Config.ColorBlackBackground : Color.White,
                                HorizontalOptions = LayoutOptions.Center
                            },
                            new BybLabel
                            {
                                Text              = match.MatchScoreA.ToString() + " : " + match.MatchScoreB.ToString(),
                                FontSize          = Config.LargerFontSize,
                                FontAttributes    = Xamarin.Forms.FontAttributes.Bold,
                                TextColor         = Color.White,
                                HorizontalOptions = LayoutOptions.Center
                            },
                        }
                    };

                    var panel1_0 = new StackLayout
                    {
                        Padding           = new Thickness(10, 10, 0, 5),
                        Orientation       = StackOrientation.Vertical,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        WidthRequest      = widthOfLeftColumn,
                        VerticalOptions   = LayoutOptions.Start,
                        Children          =
                        {
                            labelOpponent,
                            labelForFrames,//scrollViewForFrames
                        }
                    };
                    this.panelsToResize.Add(panel1_0);

                    var panel1 = new StackLayout()
                    {
                        Orientation     = StackOrientation.Horizontal,
                        BackgroundColor = Color.White,
                        Padding         = new Thickness(0, 0, 0, 0),
                        Children        =
                        {
                            panel1_0,
                            panel1_1,
                        }
                    };
                    var panel2 = new StackLayout
                    {
                        Orientation     = StackOrientation.Horizontal,
                        BackgroundColor = Color.White,
                        Padding         = new Thickness(5, 0, 5, 0),
                        Children        =
                        {
                            new Frame
                            {
                                Padding           = new Thickness(5, 5, 0, 5),
                                HorizontalOptions = LayoutOptions.StartAndExpand,
                                Content           = new BybLabel()
                                {
                                    Text = DateTimeHelper.DateToString(match.Date),//match.Date.ToShortDateString(),
                                    VerticalTextAlignment = TextAlignment.Center,
                                    TextColor             = Config.ColorGrayTextOnWhite
                                }
                            },
                            new Frame
                            {
                                Padding           = new Thickness(0, 5, 5, 5),
                                HorizontalOptions = LayoutOptions.EndAndExpand,
                                Content           = labelVenue
                            },
                        }
                    };

                    panel1.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(() => { this.tapped(match); })
                    });
                    panel2.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(() => { this.tapped(match); })
                    });
                    panel1_1.GestureRecognizers.Add(new TapGestureRecognizer()
                    {
                        Command = new Command(() => { this.tapped(match); })
                    });
                    //scrollViewForFrames.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command(() => { this.tapped(match); }) });

                    this.Children.Add(new StackLayout()
                    {
                        Orientation = StackOrientation.Vertical,
                        Spacing     = 1,
                        Children    =
                        {
                            panel1,
                            panel2,
                        }
                    });
                }

                // remove previous items now, to avoid unnecessary scrolling
                foreach (var item in itemsToRemove)
                {
                    this.Children.Remove(item);
                }
            }
            catch (Exception exc)
            {
                this.Children.Add(new BybLabel()
                {
                    Text = "Error: " + TraceHelper.ExceptionToString(exc)
                });
            }
        }