private void button2_Click(object sender, RoutedEventArgs e) { // index = 0 für sound if (lb_kato.SelectedIndex == 0 && listBox1.SelectedItem != null) { MainWindow begriffe_window = new MainWindow(txt_name.Text, listBox1.SelectedItem.ToString()); begriffe_window.Owner = this; begriffe_window.Show(); } // index = 1 für text if (lb_kato.SelectedIndex == 1 && listBox1.SelectedItem != null) { fragenquiz begriffe_window = new fragenquiz(txt_name.Text, listBox1.SelectedItem.ToString()); begriffe_window.Owner = this; begriffe_window.Show(); } }
private void button1_Click(object sender, RoutedEventArgs e) { int dauer = 10; try { dauer = Convert.ToInt32(txt_dauer.Text); } catch (Exception) { } if (!Directory.Exists(Directory.GetCurrentDirectory() + "/quizxml/")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/quizxml/"); } if (File.Exists(Directory.GetCurrentDirectory() + "/quizxml/" + txt_name.Text + ".xml")) { if (!bearbeiten) { MessageBox.Show("Ein Quiz mit diesem Namen existiert bereits! Bitte wählen Sie einen anderen Namen."); return; } } else { XmlTextWriter myXmlTextWriter = new XmlTextWriter(Directory.GetCurrentDirectory() + "/quizxml/" + txt_name.Text + ".xml", System.Text.Encoding.UTF8); myXmlTextWriter.Formatting = Formatting.Indented; myXmlTextWriter.WriteStartDocument(false); myXmlTextWriter.WriteStartElement("Quiz"); myXmlTextWriter.WriteElementString("quizname", txt_name.Text); myXmlTextWriter.WriteElementString("sounddatei", txt_name.Text + ".mp3"); myXmlTextWriter.WriteElementString("clipdauer", dauer.ToString()); myXmlTextWriter.WriteElementString("quiztyp", lb_kato.SelectedValue.ToString()); myXmlTextWriter.WriteStartElement("Items"); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.WriteEndElement(); myXmlTextWriter.Close(); bearbeiten = true; } // index = 0 für sound if (lb_kato.SelectedIndex == 0) { MainWindow begriffe_window = new MainWindow(txt_name.Text); begriffe_window.Owner = this; begriffe_window.Show(); } // index = 1 für text if (lb_kato.SelectedIndex == 1) { fragenquiz begriffe_window = new fragenquiz(txt_name.Text); begriffe_window.Owner = this; begriffe_window.Show(); } }
private void button3_Click(object sender, RoutedEventArgs e) { if (!(txt_anzeigename.Text == "")) { XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(Directory.GetCurrentDirectory() + "/quizxml/" + xml_name + ".xml"); XmlNode node, newnode, node_alternativ; newnode = myXmlDocument.CreateNode(XmlNodeType.Element, "Anzeigename", null); node = myXmlDocument.DocumentElement; if (bearbeiten) { foreach (XmlNode node1 in node.ChildNodes) { foreach (XmlNode node2 in node1.ChildNodes) { if (node2.Name == "Anzeigename") { if (node2.InnerText == anzeigename) { node2.InnerText = txt_anzeigename.Text; XmlNode node3; node3 = node2.NextSibling; while (node3 != null) { if (node3.Name == "Alternativ") { node1.RemoveChild(node3); node3 = node2.NextSibling; } else { break; } } for (int i = list_alternativ.Items.Count - 1; i > -1; i--) { node_alternativ = myXmlDocument.CreateNode(XmlNodeType.Element, "Alternativ", null); node_alternativ.InnerText = list_alternativ.Items[i].ToString(); node1.InsertAfter(node_alternativ, node2); } } } } } } else { foreach (XmlNode node1 in node.ChildNodes) { if (node1.Name == "Items") { newnode.InnerText = txt_anzeigename.Text; node1.AppendChild(newnode); for (int i = 1; i < list_alternativ.Items.Count + 1; i++) { node_alternativ = myXmlDocument.CreateNode(XmlNodeType.Element, "Alternativ", null); node_alternativ.InnerText = list_alternativ.Items[i - 1].ToString(); node1.AppendChild(node_alternativ); } } } } myXmlDocument.Save(Directory.GetCurrentDirectory() + "/quizxml/" + xml_name + ".xml"); MainWindow NeuesFenster = new MainWindow(xml_name); NeuesFenster.Show(); this.Close(); } }