private void newToolStripButton_Click(object sender, EventArgs e) { using (NewGraphDialog ngd = new NewGraphDialog()) { if (ngd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { EditorForm rf = new EditorForm(ngd.isVertical, ngd.isAutomaticWeights); rf.MdiParent = this; rf.Show(); } } }
private void openToolStripButton_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { ofd.Filter = "XML files|*.xml;"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(ofd.FileName); XmlNodeList options = xmlDoc.GetElementsByTagName("O"); XmlNode option = options[0]; Boolean isVertical = Convert.ToBoolean(option.Attributes["vertical"].InnerText); Boolean isRandom = Convert.ToBoolean(option.Attributes["randomEdges"].InnerText); XmlNodeList Vertexes = xmlDoc.GetElementsByTagName("V"); XmlNodeList Edges = xmlDoc.GetElementsByTagName("E"); EditorForm ef = new EditorForm(isVertical, isRandom); foreach (XmlNode v in Vertexes) { ef.graph.AddVertex(new PointF(Convert.ToSingle(v.Attributes["X"].InnerText), Convert.ToSingle(v.Attributes["Y"].InnerText))); } foreach (XmlNode ed in Edges) { ef.graph.AddEdge(ef.graph.VertexCollection[Convert.ToInt32(ed.Attributes["S"].InnerText)], ef.graph.VertexCollection[Convert.ToInt32(ed.Attributes["T"].InnerText)], Convert.ToInt32(ed.Attributes["W"].InnerText)); } ef.MdiParent = this; ef.Show(); } catch (Exception) { KryptonMessageBox.Show("Couldnt open file", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }