Ejemplo n.º 1
0
        private void Next_Click(object sender, RoutedEventArgs e)
        {
            foreach (var element in lstckbBatchModes.Items)
            {
                if (((ListBoxItemQuestion)element).IsChecked)
                {
                    foreach (var el in Questions[index].questions)
                    {
                        if (((ListBoxItemQuestion)element).Text == el.Text && el.IsAnswer)
                        {
                            mark++;
                        }
                        if (((ListBoxItemQuestion)element).Text == el.Text && !el.IsAnswer)
                        {
                            mark--;
                        }
                    }
                }
            }
            if (index == Questions.Count - 1)
            {
                if (mark < 0)
                {
                    mark = 0;
                }
                MessageBox.Show("Mark " + mark.ToString());
                myuser.Mark = mark;
                XmlSerializer xml = new XmlSerializer(typeof(List <QuestionUser>));
                using (TextWriter t = new StreamWriter("Users.xml"))
                {
                    xml.Serialize(t, CreateAcc.users);
                }
                this.Close();

                return;
            }


            index++;
            lstckbBatchModes.Items.Clear();



            if (index <= Questions.Count - 1)
            {
                label1.Content = Questions[index]?.Ask;
                for (int i = 0; i < Questions[index].questions.Count; i++)
                {
                    ListBoxItemQuestion item = new ListBoxItemQuestion()
                    {
                        Text = Questions[index].questions[i].Text
                    };
                    lstckbBatchModes.Items.Add(item);
                }
            }
        }
Ejemplo n.º 2
0
        public void Load()
        {
            lstckbBatchModes.Items.Clear();

            XmlSerializer xml = new XmlSerializer(typeof(List <Question>));

            using (TextReader t = new StreamReader("Test.xml"))
            {
                Questions      = (List <Question>)xml.Deserialize(t);
                label1.Content = Questions[0].Ask;
                for (int i = 0; i < Questions[0].questions.Count; i++)
                {
                    ListBoxItemQuestion item = new ListBoxItemQuestion()
                    {
                        Text = Questions[0].questions[i].Text
                    };
                    lstckbBatchModes.Items.Add(item);
                }
            }
        }