Beispiel #1
0
        // Reading its matrix representation stored in a .csv file.
        private void toolStripRightCSV_Click(object sender, EventArgs e)
        {
            try
            {
                // File Dialog properties setup.
                OpenFileGraph.FileName = "undirectedConnected";
                OpenFileGraph.Filter   = "csv files (*.csv)|*.csv";

                if (OpenFileGraph.ShowDialog() == DialogResult.OK)
                {
                    graphAlObj.ReadGraphFromCSVFile(OpenFileGraph.FileName);
                    ListBoxImport.Items.Add(OpenFileGraph.FileName);
                }
                else
                {
                    // Cancel Button.
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("File Format Not Accepted");
                toolStripStatusLabelReady.Text = "Ready!";
                ListBoxImport.Items.Clear();
            }
        }
Beispiel #2
0
        // Reading its matrix representation stored in a .txt or .csv files.
        private void toolStripRightUnknown_Click(object sender, EventArgs e)
        {
            try
            {
                // File Dialog properties setup.
                OpenFileGraph.FileName    = "undirectedConnected";
                OpenFileGraph.Multiselect = true;
                OpenFileGraph.Filter      = "all supported(*.csv,*.txt)|*.csv;*.txt|csv files (*.csv)|*.csv|txt files (*.txt)|*.txt";

                if (OpenFileGraph.ShowDialog() == DialogResult.OK)
                {
                    string[] files = OpenFileGraph.FileNames;

                    foreach (string filename in files)
                    {
                        // Filetype Validation.
                        if (filename.Contains(".txt"))
                        {
                            graphAlObj.ReadGraphFromTXTFile(filename);
                            ListBoxImport.Items.Add(filename);
                        }
                        else if (filename.Contains(".csv"))
                        {
                            graphAlObj.ReadGraphFromCSVFile(filename);
                            ListBoxImport.Items.Add(filename);
                        }
                    }
                }
                else
                {
                    // Cancel Button.
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("File Format Not Accepted");
                toolStripStatusLabelReady.Text = "Ready!";
                ListBoxImport.Items.Clear();
            }
        }