示例#1
0
        /// <summary>
        /// Save Playername and Highscore
        /// </summary>
        /// <param name="_score">Highscore</param>
        private void SaveScore(Decimal _score)
        {
            string           player = "";
            PlayerNameDialog pnd    = new PlayerNameDialog();                                  //Open "PlayerNameDialog" for Userinput

            if (pnd.ShowDialog() == DialogResult.OK && pnd.Playername != "Type your Nickname") //Check the Dialog Result and the entered Playername
            {
                player = pnd.Playername;
            }
            else
            {
                player = "Anonymous";
            }
            Highscore hs = new Highscore(player, score);    // Create new Highscore from Class "Highscore"

            Highscore.scoreList.Add(hs);                    // Add Highscore to Highscorelist
            listBox1.Items.Add(hs);                         // Add Highscore to Listbox
            listBox1.Items.Clear();                         //Clear Listbox
            Highscore.scoreList.Sort();                     //Sort Listbox
            foreach (Highscore item in Highscore.scoreList) //Add Scores ti Listbox after Playername :(
            {
                listBox1.Items.Add(item);
            }
            listBox1.Refresh(); // Refresh Listbox
        }
示例#2
0
 /// <summary>
 /// Save Playername and Highscore
 /// </summary>
 /// <param name="_score">Highscore</param>
 private void SaveScore(Decimal _score)
 {
     string player = "";
     PlayerNameDialog pnd = new PlayerNameDialog(); //Open "PlayerNameDialog" for Userinput
     if (pnd.ShowDialog() == DialogResult.OK && pnd.Playername != "Type your Nickname") //Check the Dialog Result and the entered Playername
     {
         player = pnd.Playername;
     }
     else
     {
         player = "Anonymous";
     }
     Highscore hs = new Highscore(player, score); // Create new Highscore from Class "Highscore"
     Highscore.scoreList.Add(hs); // Add Highscore to Highscorelist
     listBox1.Items.Add(hs); // Add Highscore to Listbox
     listBox1.Items.Clear(); //Clear Listbox
     Highscore.scoreList.Sort(); //Sort Listbox
     foreach (Highscore item in Highscore.scoreList)//Add Scores ti Listbox after Playername :(
     {
         listBox1.Items.Add(item);
     }
     listBox1.Refresh(); // Refresh Listbox
 }