Exemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DateTimeOffset dto = DateTimeOffset.Now;

            if (dto.DayOfYear < 107 || dto.DayOfYear > 108)
            {
                MessageBox.Show("err");
                Close();
            }

            SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint, true);

            Location = new Point(x / 2 - Width / 2, y / 2 - Height / 2);

            login log = new login(this);

            log.Show();

            form_stats = new stats();
            form_stats.Show(); form_stats.Hide();

            //functions.show_stat(form_stats);

            rct.res_cur_test.ForeColor = Color.FromArgb(255, 200, 255, 255);
            rct.Show(); rct.Hide();
            rct.Location = new Point(x / 2 - rct.Width / 2, y / 2 - rct.Height / 2);

            Location = new Point(x / 2 - Width / 2, y / 2 - Height / 2);

            if (!Directory.Exists("data\\tests"))
            {
                MessageBox.Show("Создаите тесты для тестирования в папке data\\tests");

                Close();
            }
            //user usr = new user();
            //usr.last_name = "Исмагилов"; usr.first_name = "Кирилл"; usr.par = "Флуньевич"; usr.login = "******";
            //functions.load_tests(this, usr);
        }
Exemplo n.º 2
0
        public static void show_stat(stats form_stat)
        {
            form_stat.fLP.Controls.Clear();


            List <stat> stat = load_stat("data\\results\\results.csv");

            if (stat == null)
            {
                MessageBox.Show("Проидите хотя бы один тест");

                return;
            }


            string[] users = new string[stat.Count];
            for (int i = 0; i < stat.Count; i++)
            {
                users[i] = stat[i].login;
            }
            users = users.Distinct().ToArray();

            List <usr> struct_users = new List <usr>();
            usr        tmp_user     = new usr();

            foreach (string user in users)
            {
                List <stat> s = stat.FindAll(a => a.login == user);
                int         sum = 0, percent = 0;
                foreach (var test in s)
                {
                    sum += Convert.ToInt32(test.percent);
                }

                percent       = sum / s.Count;
                tmp_user.user = user; tmp_user.percent = percent; tmp_user.fio = s[0].fio;
                struct_users.Add(tmp_user);
            }

            //	соритровка по кол-ву баллов
            struct_users.Sort((a, b) => (b.percent.CompareTo(a.percent)));

            foreach (usr user in struct_users)
            {
                Label lb = new Label();
                lb.AutoSize = true;
                lb.Anchor   = AnchorStyles.None;
                lb.Dock     = DockStyle.Fill;
                //lb.TextAlign = ContentAlignment.MiddleCenter;
                lb.TextAlign = ContentAlignment.MiddleLeft;
                lb.ForeColor = Color.FromArgb(255, 200, 255, 255);
                lb.Font      = new Font("Times New Roman", 15, FontStyle.Bold);

                lb.Text = "\r\n" + user.fio + ": " + user.percent + "%\r\n";
                form_stat.fLP.WrapContents = false;
                form_stat.fLP.Controls.Add(lb);
            }
            // Sort((a, b) => (a.ToString()[0].CompareTo(b.ToString()[0])));

            form_stat.Show();
        }