private void openToolStripMenuItem_database_Click(object sender, EventArgs e) { // Open file dialog using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "dbc files (*.dbc)|*.dbc"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { // Check if duplicate if (chart_gui.database_set.databases.Exists(x => !Convert.ToBoolean(string.Compare(x.path, openFileDialog.FileName)))) { MessageBox.Show("Database already included!"); } else { // Create new database and add to database_set Database new_database = new Database(); new_database.path = openFileDialog.FileName; new_database.parse(new_database.path); chart_gui.database_set.databases.Add(new_database); // Add new database to treeview TreeNode new_database_node = new TreeNode(Path.GetFileName(new_database.path)); treeView_tree.Nodes[1].Nodes.Add(new_database_node); treeView_tree.Nodes[1].Expand(); // If logfile already exists, reparse logfile if (chart_gui.logfile.path != null) { // Parse logfile //chart_gui.logfile.parse(chart_gui.database_set); // Experimental loading bar parser Loading_Bar_Parser parser = new Loading_Bar_Parser(chart_gui, checkedListBox_signals); parser.ShowDialog(); chart_gui = parser.chart_gui; // Update logfile in chart chart_gui.update_logfile(chart_gui.checked_list_box); // Set initial chart to show timeslice of entire logfile chart_gui.set_initial_timeslice_data(); } } } } }
private void openToolStripMenuItem_logfile_Click(object sender, EventArgs e) { // Open file dialog using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "txt files (*.txt)|*.txt"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { // Check if same as currently existing if (!Convert.ToBoolean(string.Compare(chart_gui.logfile.path, openFileDialog.FileName))) { MessageBox.Show("Same logfile already loaded!"); } else { // Set logfile path, will be parsed in Logfile_Parser chart_gui.logfile.path = openFileDialog.FileName; // Parse logfile //chart_gui.logfile.parse(chart_gui.database_set); // Experimental loading bar parser, if cancels, overwrites log file with new instantiation Loading_Bar_Parser parser = new Loading_Bar_Parser(chart_gui, checkedListBox_signals); parser.ShowDialog(); chart_gui = parser.chart_gui; // Check if cancelled if (chart_gui.logfile.path == null) { return; } // Update logfile in chart //chart_gui.update_logfile(chart_gui.checked_list_box); // Update status bar text status_text.Text = Path.GetFileName(chart_gui.logfile.path); // Add to treeview TreeNode new_logfile_node = new TreeNode(Path.GetFileName(chart_gui.logfile.path)); treeView_tree.Nodes[0].Nodes.Add(new_logfile_node); treeView_tree.Nodes[0].Expand(); // Populate checkedListBox with all logfile signals chart_gui.logfile.update_CheckedListBox(checkedListBox_signals); //// Update now updated logfile in chart_gui //if (chart_gui.update_logfile(logfile, database_set, checkedListBox_signals) == 0) // throw new ArgumentException("chart_gui cannot be updated with null logfile argument"); //Logfile_Parser parser = new Logfile_Parser(chart_gui, database_set, checkedListBox_signals); //parser.Show(); // Set initial chart to show timeslice of entire logfile chart_gui.set_initial_timeslice_data(); } } } /* * // Set initial gui window to entire logfile timeslice, with some padding * if (logfile.num_points != 0) * { * gui.time_start = logfile.point_list[0].timestamp - 0.1 * (logfile.point_list[logfile.num_points - 1].timestamp - logfile.point_list[0].timestamp); * gui.time_end = logfile.point_list[logfile.num_points - 1].timestamp + 0.1 * (logfile.point_list[logfile.num_points - 1].timestamp - logfile.point_list[0].timestamp); * } * else * MessageBox.Show("Logfile empty"); */ }