예제 #1
0
        private void Nazad1_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Вернуться без сохранения изменений?",
                                                  "Сообщение",
                                                  MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Information,
                                                  MessageBoxDefaultButton.Button1,
                                                  MessageBoxOptions.DefaultDesktopOnly
                                                  );

            if (result == DialogResult.Yes)
            {
                ChooseAction form = new ChooseAction();
                form.LabelTheme.Text = label1.Text;
                form.Show();
                form.TopMost = true;
                this.Close();
            }
            else
            {
                this.TopMost = true;
            }
        }
예제 #2
0
        private void labelTheme2_Click(object sender, EventArgs e)
        {
            if (File.Exists("theme.xml"))
            {
                List <Nazvanie_Theme> listThemes = new List <Nazvanie_Theme>();
                XmlSerializer         formater   = new XmlSerializer(typeof(List <Nazvanie_Theme>));
                using (FileStream fs = new FileStream("theme.xml", FileMode.OpenOrCreate))
                {
                    listThemes = (List <Nazvanie_Theme>)formater.Deserialize(fs);
                }


                Nazvanie_Theme nazvanie2 = new Nazvanie_Theme(labelTheme2.Text);

                if (listThemes.Contains(nazvanie2))
                {
                    ChooseAction form = new ChooseAction();
                    form.LabelTheme.Text = nazvanie2.Name;
                    form.Show();
                    this.Close();
                }
                else
                {
                    Tasks1 t = new Tasks1();
                    t.ThemeZagolovok.Text = "Введите название темы";
                    t.Show();
                    this.Close();
                }
            }
            else
            {
                Tasks1 t = new Tasks1();
                t.ThemeZagolovok.Text = "Введите название темы";
                t.Show();
                this.Close();
            }
        }
예제 #3
0
        private void Delete1_Click(object sender, EventArgs e)
        {
            if (Delete1.BackColor == Color.Red && Delete1.BackColor2 == Color.Red && localLIST != null)
            {
                List <Mission> any   = new List <Mission>();
                XmlSerializer  diser = new XmlSerializer(typeof(List <Mission>));
                using (FileStream fs = new FileStream("bank.xml", FileMode.OpenOrCreate))
                {
                    any = (List <Mission>)diser.Deserialize(fs);
                }
                string TemaEbat = localLIST[0].Theme;
                for (int i = 0; i < checks.Length; i++)
                {
                    if (checks[i].Checked)
                    {
                        foreach (var item in localLIST)
                        {
                            if (item.Theme == TemaEbat && item.question == checks[i].Text)
                            {
                                localLIST.Remove(item);
                                break;
                            }
                        }
                        foreach (var item in any)
                        {
                            if (item.Theme == TemaEbat && item.question == checks[i].Text)
                            {
                                any.Remove(item);
                                break;
                            }
                        }
                        // Если этот checkBox помечен, то мы удаляем этот вопрос из localLIST
                        // Затем эти изменения должны быть применены к общему хранилищу, т. е. bank.xml
                        //
                    }
                }
                XmlSerializer ser = new XmlSerializer(typeof(List <Mission>));
                if (File.Exists("bank.xml"))
                {
                    File.Delete("bank.xml");
                }
                using (FileStream fs = new FileStream("bank.xml", FileMode.OpenOrCreate))
                {
                    ser.Serialize(fs, any);
                }

                if (localLIST.Count != 0)
                {
                    ChooseAction form = new ChooseAction();
                    form.LabelTheme.Text = label1.Text;
                    form.Show();
                    this.Close();
                }
                else
                {
                    // Нужно удалить тему, если удалены все вопросы по этой теме

                    Nazvanie_Theme        theme      = new Nazvanie_Theme(label1.Text);
                    List <Nazvanie_Theme> themes     = new List <Nazvanie_Theme>();
                    XmlSerializer         deformater = new XmlSerializer(typeof(List <Nazvanie_Theme>));
                    if (File.Exists("theme.xml"))
                    {
                        using (FileStream fs = new FileStream("theme.xml", FileMode.OpenOrCreate))
                        {
                            themes = (List <Nazvanie_Theme>)deformater.Deserialize(fs);
                        }
                        File.Delete("theme.xml");
                    }
                    themes.Remove(theme);
                    XmlSerializer formater = new XmlSerializer(typeof(List <Nazvanie_Theme>));
                    using (FileStream fs = new FileStream("theme.xml", FileMode.OpenOrCreate))
                    {
                        formater.Serialize(fs, themes);
                    }
                    MenuWithThemes menu = new MenuWithThemes();


                    for (int j = 0; j < themes.Count; j++)
                    {
                        switch (j)
                        {
                        case 0:
                        {
                            menu.labelTheme1.Text = themes[0].Name;
                            break;
                        }

                        case 1:
                        {
                            menu.labelTheme2.Text = themes[1].Name;
                            break;
                        }

                        case 2:
                        {
                            menu.labelTheme3.Text = themes[2].Name;
                            break;
                        }

                        case 3:
                        {
                            menu.labelTheme4.Text = themes[3].Name;
                            break;
                        }

                        case 4:
                        {
                            menu.labelTheme5.Text = themes[4].Name;
                            break;
                        }

                        case 5:
                        {
                            menu.labelTheme6.Text = themes[5].Name;
                            break;
                        }

                        case 6:
                        {
                            menu.labelTheme7.Text = themes[6].Name;
                            break;
                        }

                        case 7:
                        {
                            menu.labelTheme8.Text = themes[7].Name;
                            break;
                        }

                        case 8:
                        {
                            menu.labelTheme9.Text = themes[8].Name;
                            break;
                        }

                        case 9:
                        {
                            menu.labelTheme10.Text = themes[9].Name;
                            break;
                        }
                        }
                    }
                    menu.Show();
                    this.Close();
                }
            }
        }
예제 #4
0
        private void DopolniteTheme1_Click(object sender, EventArgs e)
        {
            bool fal1            = false;
            bool fal2            = false;
            bool fal3            = false;
            bool fal4            = false;
            int  countRadioCheck = 0;

            if (PanelConstanta == 0)
            {
                fal3 = true;
            }
            for (int j = 0; j < currentIndexRadio; j++)
            {
                if (radio[j].Checked)
                {
                    countRadioCheck++;
                }
            }
            if (countRadioCheck != CountNans.Count)
            {
                fal4 = true;
            }
            for (int j = 0; j < currentIndexRadio; j++)
            {
                if (radio[j].Text == "")
                {
                    fal1 = true;
                    break;
                }
            }
            for (int j = 0; j < currentIndexTextTask; j++)
            {
                if (textTask[j].Text == "")
                {
                    fal2 = true;
                    break;
                }
            }
            if (fal1 || fal2 || fal3 || fal4)
            {
                MessageBox.Show("Некорректные введенные данные");
            }
            else
            {
                int           ind   = 0;
                int           i     = 0;
                XmlSerializer diser = new XmlSerializer(typeof(List <Mission>));
                if (File.Exists("bank.xml"))
                {
                    using (FileStream fs = new FileStream("bank.xml", FileMode.OpenOrCreate))
                    {
                        any = (List <Mission>)diser.Deserialize(fs);
                    }
                }
                while (i < radio.Length && ind < CountNans.Count)
                {
                    Mission mr = new Mission();

                    int n = CountNans[ind];
                    for (int j = 0; j < n; j++)
                    {
                        Pair <string, bool> v = new Pair <string, bool>();
                        v.First  = radio[i].Text;
                        v.Second = radio[i].Checked;
                        mr.answers.Add(v);
                        i++;
                    }
                    mr.Theme    = label1.Text;
                    mr.question = textTask[ind].Text;
                    any.Add(mr);
                    ind++;
                }
                XmlSerializer ser = new XmlSerializer(typeof(List <Mission>));
                if (File.Exists("bank.xml"))
                {
                    File.Delete("bank.xml");
                }
                using (FileStream fs = new FileStream("bank.xml", FileMode.OpenOrCreate))
                {
                    ser.Serialize(fs, any);
                }
                ChooseAction menu = new ChooseAction();
                menu.LabelTheme.Text = label1.Text;
                menu.Show();
                this.Close();
            }
        }