/**
         * Counting the total amount of Matches that have been played and
         * displaying it on the totalGames text field
         * */
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            Games          game       = (Games)this.BindingContext;
            List <Matches> allMatches = database.GetAllMatches();

            foreach (Matches match in allMatches)
            {
                if (match.mGameID == game.gID)
                {
                    counter++;
                }
            }
            totalGames.Text = Convert.ToString(counter);
        }
Esempio n. 2
0
        /**
         * Display option for the match cell and how it will be displayed on page
         * */
        public matchCell()
        {
            database = App.Database;

            lblFullName = new Label {
                FontAttributes = FontAttributes.Bold
            };

            Label lblDate = new Label {
                FontSize = 12
            };

            lblDate.SetBinding(Label.TextProperty, "mDate", stringFormat: "{0:D}");

            lblGameName = new Label {
                FontSize = 12
            };
            // Menu item to be able to delete a match
            MenuItem menuItem = new MenuItem
            {
                Text          = "Delete Match?",
                IsDestructive = true
            };

            menuItem.Clicked += (sender, e) =>
            {
                // Get parent's list to remove item
                ListView parent = (ListView)this.Parent;
                // Remove item from database
                database.DeleteMatch(this.BindingContext as Matches);
                // Update list
                parent.ItemsSource = database.GetAllMatches();
            };

            ContextActions.Add(menuItem);

            View = new StackLayout
            {
                Spacing  = 2,
                Padding  = 5,
                Children = { lblFullName, lblDate, lblGameName }
            };
        }