示例#1
0
        /// <summary>
        /// Pokazuje rezultate koji su napravljeni na engleskom jeziku.
        /// </summary>
        private void btnEnglish_Click(object sender, EventArgs e)
        {
            LoadingHighscore();

            List <Highscore> englishHighscore = new List <Highscore>();

            foreach (Highscore score in SortedList)
            {
                if (score.language == false)
                {
                    englishHighscore.Add(score);
                }
            }
            if (englishHighscore.Count > 10)
            {
                using (dbTypingGameEntities baza = new dbTypingGameEntities())
                {
                    baza.Highscore.Attach(englishHighscore[englishHighscore.Count - 1]);
                    baza.Highscore.Remove(englishHighscore[englishHighscore.Count - 1]);
                    baza.SaveChanges();
                }
                englishHighscore.Remove(englishHighscore[englishHighscore.Count - 1]);
            }
            highscoreBindingSource.DataSource = englishHighscore;
        }
示例#2
0
        /// <summary>
        /// Pokazuje rezultate koji su napravljeni na hrvatskom jeziku.
        /// </summary>
        private void btnCroatian_Click(object sender, EventArgs e)
        {
            LoadingHighscore();

            List <Highscore> croatianHighscore = new List <Highscore>();

            foreach (Highscore score in SortedList)
            {
                if (score.language == true)
                {
                    croatianHighscore.Add(score);
                }
            }
            if (croatianHighscore.Count > 10)
            {
                using (dbTypingGameEntities baza = new dbTypingGameEntities())
                {
                    baza.Highscore.Attach(croatianHighscore[croatianHighscore.Count - 1]);
                    baza.Highscore.Remove(croatianHighscore[croatianHighscore.Count - 1]);
                    baza.SaveChanges();
                }
                croatianHighscore.Remove(croatianHighscore[croatianHighscore.Count - 1]);
            }
            highscoreBindingSource.DataSource = croatianHighscore;
        }
示例#3
0
        /// <summary>
        /// Provjerava je li rezultat dovoljan za ući na listu.
        /// </summary>
        private void CheckForHighscore(int iCPM, int iWPM)
        {
            List <Highscore>        sortedList = null;
            BindingList <Highscore> list       = null;

            using (dbTypingGameEntities baza = new dbTypingGameEntities())
            {
                list = new BindingList <Highscore>(baza.Highscore.ToList());
            }
            sortedList = list.OrderByDescending(o => o.CPM).ToList();

            List <Highscore> listEnglish  = new List <Highscore>();
            List <Highscore> listCroatian = new List <Highscore>();

            foreach (Highscore item in sortedList)
            {
                if (item.language == hrvat)
                {
                    listCroatian.Add(item);
                }
                else
                {
                    listEnglish.Add(item);
                }
            }
            if (hrvat)
            {
                if (listCroatian.Count < 10 || listCroatian[listCroatian.Count - 1].CPM < iCPM)
                {
                    ScoreInput scoreInput = new ScoreInput(iCPM, iWPM, hrvat);
                    scoreInput.ShowDialog();

                    ShowHighscore();
                }
                else
                {
                    ShowHighscore();
                }
            }
            else
            {
                if (listEnglish.Count < 10 || listEnglish[listEnglish.Count - 1].CPM < iCPM)
                {
                    ScoreInput scoreInput = new ScoreInput(iCPM, iWPM, hrvat);
                    scoreInput.ShowDialog();

                    ShowHighscore();
                }
                else
                {
                    ShowHighscore();
                }
            }
        }
示例#4
0
        /// <summary>
        /// Učitava Highscore tablicu
        /// </summary>
        private void LoadingHighscore()
        {
            BindingList <Highscore> lista = null;

            using (dbTypingGameEntities baza = new dbTypingGameEntities())
            {
                lista = new BindingList <Highscore>(baza.Highscore.ToList());
            }
            SortedList = lista.OrderByDescending(o => o.CPM).ToList();

            FirstTenHighscores = SortedList.Take(10).ToList();
        }
示例#5
0
 /// <summary>
 /// Gumb prilikom kojeg se usnimava rezultat.
 /// </summary>
 private void btnSave_Click(object sender, EventArgs e)
 {
     using (dbTypingGameEntities baza = new dbTypingGameEntities())
     {
         Highscore highscore = new Highscore
         {
             nickname = txtName.Text,
             CPM      = CPM,
             WPM      = WPM,
             language = Hrv,
         };
         baza.Highscore.Add(highscore);
         baza.SaveChanges();
     }
     Close();
 }