예제 #1
0
        /**
         * This method is called when an item is tapped in the list view of games
         */
        private async void listPartie_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            ScorePartie sp = (ScorePartie)listPartie.SelectedItem;

            if (state == 0)//if in games panel in profil page
            {
                await Navigation.PushModalAsync(new DetailsPartiePage((ScorePartie)listPartie.SelectedItem));
            }
            else if (state == 1)  //if in stats panel in profil page
            {
                if (this.partieStatPage == null)
                {
                    this.partieStatPage = new PartieStatPage(sp, sp.GolfName);
                }
                else
                {
                    this.partieStatPage.changePartie(sp, sp.GolfName);
                }
                await Navigation.PushModalAsync(this.partieStatPage);
            }
            else if (state == 2)  //when loading an existing and not finished game
            {
                partie.ScoreOfThisPartie = sp;
                foreach (ScoreHole sh in sp.scoreHoles)
                {
                    partie.nextHole();//skip holes that was already done
                }
                //partie.holeFinishedCount++;//needs to increment one last time because this attibute is initialized to -1 to start at 0 after first main game page appearing
                await Navigation.PushAsync(new Play.Game.MainGamePage(partie), false);
            }
        }
        public PartieStatPage(ScorePartie sp, string golfCourseName)
        {
            InitializeComponent();
            changePartie(sp, golfCourseName);
            this.legendButton.BorderColor = Color.FromHex("0C5E11");
            this.legendButton.BorderWidth = 2;

            this.allShots = null;
        }
예제 #3
0
        public DetailsPartiePage(ScorePartie sp)
        {
            InitializeComponent();
            List <DisplayScoreCard> list = new List <DisplayScoreCard>();
            int i        = 1;
            int totPar   = 0;
            int totPutt  = 0;
            int totPen   = 0;
            var totScore = 0;

            //computes the total number of pars, putts, penality shots and shots of this game and creates a list of DisplayScoreCard (one by hole)
            foreach (ScoreHole sh in sp.scoreHoles)
            {
                list.Add(new DisplayScoreCard(i, sh));
                i++;
                totPar   += sh.Hole.Par;
                totPutt  += sh.NombrePutt;
                totPen   += sh.Penality;
                totScore += (sh.Score + sh.Hole.Par);
            }
            listScore.ItemsSource = list;

            //manages the number of shots that the user did over the par of the golf course (top right hand corner of the view)
            var scoreDelta = totScore - totPar;
            var sdAbs      = Math.Abs(scoreDelta);

            if (scoreDelta < 0)
            {
                score.Text = "-" + sdAbs;
            }
            else
            {
                score.Text = "+" + scoreDelta;
            }
            if (sdAbs >= 100)
            {
                score.FontSize = 25;
                score.Margin   = new Thickness(MainPage.responsiveDesign(32), MainPage.responsiveDesign(33), 0, 0);
            }
            else if (sdAbs >= 10)
            {
                score.FontSize = 30;
                score.Margin   = new Thickness(MainPage.responsiveDesign(35), MainPage.responsiveDesign(29), 0, 0);
            }
            else
            {
                score.Margin = new Thickness(MainPage.responsiveDesign(39), MainPage.responsiveDesign(27), 0, 0);
            }
            title.Margin    = new Thickness(MainPage.responsiveDesign(65), MainPage.responsiveDesign(20), 0, 0);
            totalPar.Text   = totPar + "";
            totalPutt.Text  = totPutt + "";
            totalPen.Text   = totPen + "";
            totalScore.Text = totScore + "";

            partie.Text = sp.GolfName + " :";
            date.Text   = sp.DateString;
        }
 /**
  * Changes the game and some concerned labels
  */
 public void changePartie(ScorePartie sp, string golfCourseName)
 {
     this.scorePartie         = sp;
     this.partieDate.Text     = "Partie du " + sp.DateString + " sur le";
     this.golfCourseName.Text = golfCourseName;
 }