예제 #1
0
        }//end HardwareButtons_BackPressed()

        //When the page is navigated to
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //firstly make sure the page is in portrait orientation
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;

            List <HighScore> tasks;                          //Declare list of high score objects

            con = new SQLiteConnection("GameDatabase.db");   //Instantiate a new SQLite connection to the game database
            con.CreateTable <HighScore>();                   //Create a table for the connection using HighScore objects to represent
                                                             //table entities, each row is an object.

            dataHolder = e.Parameter as DataPasser;          //Get information from HighScoresMenu stating which highscores the user wants
            getListOfScores(dataHolder.data, out tasks);     //Execute the appropriate query to get list of high scores from table
                                                             //query is ordered by score desc

            //We want the ranks to be in order, currently they just have ids which arent ordered by score so....

            //Start looping over the list, first element will have the highest score, second will have the second highest and so on
            for (rank = 0; rank < tasks.Count(); ++rank)
            {
                HighScore currentInList = tasks.ElementAt(rank); //Retreive that element from the list (first iteration = highest score)
                currentInList.Id = (rank + 1);                   //Change its rank to one
                tasks.RemoveAt(rank);                            //Remove the element currently ranked in 1.
                tasks.Insert(rank, currentInList);               //Add new element with proper rank number
            }

            gameHighScoreList.ItemsSource = tasks;          //Once list is populated add it as the item source for the listbox
        }//end onNavigatedTo()
        }//end HardwareButtons_BackPressed()

        //When the page is navigated to
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //firstly make sure the page is in portrait orientation
            DisplayInformation.AutoRotationPreferences = DisplayOrientations.Portrait;

            List<HighScore> tasks;                           //Declare list of high score objects
            con = new SQLiteConnection("GameDatabase.db");   //Instantiate a new SQLite connection to the game database
            con.CreateTable<HighScore>();                    //Create a table for the connection using HighScore objects to represent
                                                             //table entities, each row is an object.

            dataHolder = e.Parameter as DataPasser;          //Get information from HighScoresMenu stating which highscores the user wants
            getListOfScores(dataHolder.data, out tasks);     //Execute the appropriate query to get list of high scores from table
                                                             //query is ordered by score desc
          
            //We want the ranks to be in order, currently they just have ids which arent ordered by score so....

            //Start looping over the list, first element will have the highest score, second will have the second highest and so on
            for (rank = 0; rank < tasks.Count(); ++rank)    
            {
                HighScore currentInList = tasks.ElementAt(rank); //Retreive that element from the list (first iteration = highest score)
                currentInList.Id = (rank + 1);                   //Change its rank to one
                tasks.RemoveAt(rank);                            //Remove the element currently ranked in 1.
                tasks.Insert(rank, currentInList);               //Add new element with proper rank number
            }

            gameHighScoreList.ItemsSource = tasks;          //Once list is populated add it as the item source for the listbox
        }//end onNavigatedTo()
예제 #3
0
        //When the game page has been navigated to.....
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            timer     = new DispatcherTimer();              //Instantiate a timer
            stopWatch = new Stopwatch();                    //Instantiate a stop watch

            secs = 60;                                      //seconds for timer is set to 59
            mins = 2;                                       //minutes for timer is set to 2
            con  = new SQLiteConnection("GameDatabase.db"); //Instantiate an SQLite connection object for the Games database
            con.CreateTable <Words>();

            txtScore.Text = score.ToString();                   //Output user score, zero to begin with
            dataHolder    = e.Parameter as DataPasser;          //Get data passed from MainPage.xaml specifying which game the user wants
            retreiveAndOutputWord(dataHolder.data);             //Use the data to retrieve word from certain table, jumble and output it

            timer.Interval = new TimeSpan(0, 0, 0, 1, 0);       //Set the timer interval to one second
            timer.Tick    += timerTick;                         //Add event to timers tick event
            timer.Start();                                      //Start the timer
            stopWatch.Start();                                  //Start the stopwatch
        }//end OnNavigatedTo()
예제 #4
0
        //When the game page has been navigated to.....
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            timer = new DispatcherTimer();              //Instantiate a timer
            stopWatch = new Stopwatch();                //Instantiate a stop watch

            secs = 60;                                              //seconds for timer is set to 59
            mins = 2;                                               //minutes for timer is set to 2
            con = new SQLiteConnection("GameDatabase.db");          //Instantiate an SQLite connection object for the Games database
            con.CreateTable<Words>();

           txtScore.Text = score.ToString();                     //Output user score, zero to begin with
           dataHolder = e.Parameter as DataPasser;               //Get data passed from MainPage.xaml specifying which game the user wants
           retreiveAndOutputWord(dataHolder.data);              //Use the data to retrieve word from certain table, jumble and output it

           timer.Interval = new TimeSpan(0, 0, 0, 1, 0);        //Set the timer interval to one second
           timer.Tick += timerTick;                             //Add event to timers tick event
           timer.Start();                                       //Start the timer
           stopWatch.Start();                                   //Start the stopwatch
        }//end OnNavigatedTo()