private void lstResearches_SelectedIndexChanged(object sender, EventArgs e) { if (lstResearches.SelectedIndex != -1) { currentResearch = (Research)lstResearches.SelectedItem; researchUpdated(); } }
private void MainForm_Load(object sender, EventArgs e) { XmlDocument doc = new XmlDocument(); try { doc.Load(XML_FILENAME); } catch (System.IO.FileNotFoundException ex) { Console.WriteLine(ex); } catch (Exception ex) { Console.WriteLine(ex); } XmlNodeList list = doc.SelectNodes("/saved_data/research"); foreach (XmlNode node in list) { Research research = new Research(node.SelectSingleNode("name").FirstChild.Value); try { research.FrontViewPath = node.SelectSingleNode("front_view").FirstChild.Value; research.SideViewPath = node.SelectSingleNode("side_view").FirstChild.Value; } catch (NullReferenceException) { Console.WriteLine("Изображения не были сохранены"); } XmlNodeList cp_nodes = node.SelectNodes("KT/*"); if (cp_nodes != null) { foreach (XmlNode cp in cp_nodes) { try { switch (cp.Name) { case "outside": research.CheckPoints.Add(loadOutside(cp)); break; case "vent": research.CheckPoints.Add(loadVent(cp)); break; case "neighbor": research.CheckPoints.Add(loadNeighbor(cp)); break; case "vibro": research.CheckPoints.Add(loadVibro(cp)); break; } } catch (Exception ex) { Console.WriteLine(ex); } } } lstResearches.Items.Add(research); } researchUpdated(); }
private void btnDeleteResearch_Click(object sender, EventArgs e) { lstResearches.Items.RemoveAt(lstResearches.SelectedIndex); currentResearch = null; researchUpdated(); }