예제 #1
0
        private void StartGame(object sender, EventArgs e)
        {
            try
            {
                c.Load();
                if (c.Count() < 15)
                {
                    _view.StartGameQ = false;
                    _view.Error("Ошибка", "У вас меньше 15 вопросов, добавьте вопросы.");
                    return;
                }
                _view.StartGameQ = true;

                c1 = new Сontainer();
                Random j = new Random();
                int    k = j.Next(0, c.Count());
                for (int i = 0; i < 15; i++)
                {
                    for (int i1 = 0; i1 < c1.Count(); i1++)
                    {
                        if (c1.Element(i1).Questio == c.Element(k).Questio)
                        {
                            i1 = -1;
                            int temp = k;
                            while (temp == k)
                            {
                                k = j.Next(0, c.Count());
                            }
                        }
                    }
                    c1.Add(c.Element(k));
                }
                RandomAnsver();

                _view.Question = c1.Element(numberQuestion).Questio;
            }
            catch (Exception ex)
            {
                c.Save();
            }
        }
예제 #2
0
파일: P_Edit.cs 프로젝트: Drift2020/ADO.NET
        public P_Edit(I_Add_Edit view, Сontainer c)
        {
            _c = c;


            _view = view;
            // Презентер подписывается на уведомления о событиях Представления
            _view.Quest       += new EventHandler <EventArgs>(OnOkey);
            _view.NumderQuest += new EventHandler <EventArgs>(UpdateNumberQuest);

            _model    = c.Element(0).Clone() as Question;
            _view.Max = c.Count();
            UpdateView();
        }
예제 #3
0
파일: P_Edit.cs 프로젝트: Drift2020/ADO.NET
        public P_Edit(I_Add_Edit view)
        {
            _c.SetSerializer(new XMLSerializer());
            _c.Load();

            _view = view;
            // Презентер подписывается на уведомления о событиях Представления
            _view.Quest       += new EventHandler <EventArgs>(OnOkey);
            _view.NumderQuest += new EventHandler <EventArgs>(UpdateNumberQuest);

            if (_c.Count() > 0)
            {
                _model    = _c.Element(0).Clone() as Question;
                _view.Max = _c.Count();
                UpdateView();
            }
            else
            {
                _view.QuestionEmty_Edit();
            }
        }
예제 #4
0
 private void UpdateQuestion(object sender, EventArgs e)
 {
     _view.Tex_Question = c.Element(_view.Value - 1).Questio;
 }
예제 #5
0
        private string SetAnsver(string vs, int n)
        {
            switch (n)
            {
            case 0:
                vs = c1.Element(numberQuestion).Answer_1;
                break;

            case 1:
                vs = c1.Element(numberQuestion).Answer_2;
                break;

            case 2:
                vs = c1.Element(numberQuestion).Answer_3;
                break;

            case 3:
                vs = c1.Element(numberQuestion).Answer_4;
                break;
            }
            return(vs);
        }