示例#1
0
        private void exerciseNumbercomboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int exerciseNum = Convert.ToInt32(convertToExersiceId(exerciseNumbercomboBox1.SelectedItem.ToString()));
            ExerciseResultInfo currentResultInfo = getResultInfoByNum(exerciseNum);

            errorCounttextBox3.Text    = currentResultInfo.errorsCount.ToString();
            exerciseSpeedtextBox4.Text = currentResultInfo.speed.ToString();
            assessmentTextBox5.Text    = currentResultInfo.assesment.ToString();
        }
示例#2
0
        public ExeciseResult()
        {
            InitializeComponent();
            ExerciseResultInfo exerciseInfo = Session.CurrentResultInfo;

            wrongNumber.Text = "Количество ошибок: " + exerciseInfo.errorsCount.ToString();
            markLabel.Text   = exerciseInfo.assesment.ToString();
            time.Text        = "Время выполнения: " + exerciseInfo.speed + " сек.";
        }
示例#3
0
        private ExerciseResultInfo getResultInfoByNum(int exerciseNum)
        {
            ExerciseResultInfo exercise = null;

            foreach (ExerciseResultInfo result in resultsInfo)
            {
                if (result.exerciseId == exerciseNum)
                {
                    exercise = result;
                }
            }
            return(exercise);
        }
示例#4
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (isShuting)
            {
                double errorsCount = stats.Missed;
                double maxErrorsCount = exercise.maxErrors;
                int assigment;

                if (maxErrorsCount == 0)
                {
                    assigment = (int)Math.Round(5 * (1 - errorsCount));
                }
                else
                {
                    assigment = (int)Math.Round(5 * (1 - errorsCount / maxErrorsCount));

                }



                double speedDouble = (double)stats.Total / watch.Elapsed.Seconds;

                if (stats.Missed >= exercise.maxErrors && stats.Missed != 0)
                {

                    //listBox1.Items.Add("Game over");
                    isRuning = false;
                    timer2.Stop();
                    watch.Stop();

                    Session.CurrentResultInfo = new ExerciseResultInfo(exercise, DateTime.Today, stats.Missed, assigment, Math.Round(speedDouble, 1), watch.Elapsed.Seconds);
                    ExeciseResultForm execiseResult = new ExeciseResultForm();
                    execiseResult.ShowDialog();
                    int command = execiseResult.getCommand();
                    execiseResult.Close();
                    if (command == 1)
                    {
                        clearAll();
                        initBoxList();
                    }

                    if (command == 2)
                    {
                        this.Close();
                    }
                }

                if (stats.Correct == list.Count)
                {
                    //listBox1.Items.Clear();
                    //listBox1.Items.Add("Win!!!!");
                    timer2.Stop();
                    watch.Stop();
                    isRuning = false;

                    ExerciseResultInfo result = new ExerciseResultInfo(exercise, DateTime.Today, stats.Missed, assigment, Math.Round(speedDouble, 1), watch.Elapsed.Seconds);

                    Statistic stat = new Statistic(Session.user.userId);
                    stat.addResult(result);


                    Session.CurrentResultInfo = result;


                    ExeciseResultForm execiseResult = new ExeciseResultForm();
                    execiseResult.ShowDialog();
                    int command = execiseResult.getCommand();
                    execiseResult.Close();
                    if (command == 1)
                    {
                        clearAll();
                        initBoxList();
                    }

                    if (command == 2)
                    {
                        DBUtils.saveUserStatictis(stat);
                        this.Close();
                    }

                }
            }
        }