Esempio n. 1
0
 private void exportAsPNGToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (ActiveMdiChild != null)
     {
         using (SaveFileDialog sfd = new SaveFileDialog())
         {
             sfd.Filter = "PNG file|*.png;";
             if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 if (ActiveMdiChild is EditorForm)
                 {
                     EditorForm f = (EditorForm)ActiveMdiChild;
                     f.SaveImate(sfd.FileName);
                 }
                 else if (ActiveMdiChild is DijkstraForm)
                 {
                     DijkstraForm f = (DijkstraForm)ActiveMdiChild;
                     f.SaveImate(sfd.FileName);
                 }
                 else if (ActiveMdiChild is BellmanFordForm)
                 {
                     BellmanFordForm f = (BellmanFordForm)ActiveMdiChild;
                     f.SaveImate(sfd.FileName);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        private void openBellmanFordToolStripMenuItem_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");

                        BellmanFordForm ef = new BellmanFordForm(isVertical);

                        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); }
                }
            }
        }