コード例 #1
0
        //Rating gesture
        public void RatingChanged(TapGestureRecognizer tapGestureRecognizer)
        {
            tapGestureRecognizer.Tapped += (sender, e) =>
            {
                //Check which button is pressed
                Image pressedImage = (Image)sender;
                beer.rating = (pressedImage.ClassId.Equals("plus")) ? beer.rating += 1 : beer.rating -= 1;

                //Bounds
                if (beer.rating > 10)
                    beer.rating = 10;
                if (beer.rating < 1)
                    beer.rating = 0;

                //Change textcolor/image depending on rating
                    beerColor = (beer.rating > 5) ? Color.Green : Color.Red;

                lblRating.TextColor = beerColor;
                    beer.approval = (beerColor.Equals(Color.Green)) ? true : false;
                imgApprove.Source = (beer.approval) ? ImageSource.FromFile("like.png") : ImageSource.FromFile("nlike.png");
                lblRating.Text = "Rating: " + beer.rating.ToString() + "/10";
            };
        }