Esempio n. 1
0
        // Saving Graph.
        private void toolStripRightSave_Click(object sender, EventArgs e)
        {
            if (ListBoxResults.SelectedIndex != -1)
            {
                SaveFileGraph.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";

                if (SaveFileGraph.ShowDialog() == DialogResult.OK)
                {
                    if (ListBoxResults.SelectedItem.ToString().Contains("MST:"))
                    {
                        graphAlObj.WriteMSTSolutionTo(SaveFileGraph.FileName, ListBoxResults.SelectedItem.ToString().Substring(5));
                        ListBoxResults.Items.Remove(ListBoxResults.SelectedItem);
                    }
                    else if (ListBoxResults.SelectedItem.ToString().Contains("Shortest Paths:"))
                    {
                        graphAlObj.WriteSSSPSolutionTo(SaveFileGraph.FileName, ListBoxResults.SelectedItem.ToString().Substring(16));
                        ListBoxResults.Items.Remove(ListBoxResults.SelectedItem);
                    }
                }
                else
                {
                    // Cancel Button.
                }
            }
            else
            {
                MessageBox.Show("You have not selected a value from the list.", "Caution", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }