private void MergeBtn_Click(object sender, RoutedEventArgs e) { SaveFileDialog saveMergedDBC = new SaveFileDialog(); saveMergedDBC.FileName = "Merged_DBC_File"; saveMergedDBC.DefaultExt = ".dbc"; saveMergedDBC.Filter = "CAN db files (.dbc)|*.dbc"; if (saveMergedDBC.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (dbcParserA == null || dbcParserB == null) { return; } try { DBCWriter dbcWriter = new DBCWriter(saveMergedDBC.FileName); ObservableCollection <DbcMessage> mergedMsg = MergeDBC(dbcParserA, dbcParserB); dbcWriter.writeDBC(dbcParserA.DbVersion, dbcParserA.DbCustomer, dbcParserA.DbName + dbcParserB.DbName, String.IsNullOrEmpty(dbcParserA.DbBaudrate) ? "500000" : dbcParserA.DbBaudrate, mergedMsg); dbcWriter.close(); System.Windows.Forms.MessageBox.Show("DBC File Merged successfully!", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exp) { System.Windows.Forms.MessageBox.Show("Cannot merge dbc file\n" + exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnSaveDBC_Click(object sender, RoutedEventArgs e) { if (dbcParser == null) { System.Windows.Forms.MessageBox.Show("Please load DBC before save!\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SaveFileDialog saveDBC = new SaveFileDialog(); saveDBC.FileName = "DBC File"; saveDBC.DefaultExt = ".dbc"; saveDBC.Filter = "CAN db files (.dbc)|*.dbc"; if (saveDBC.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { DBCWriter dbcWriter = new DBCWriter(saveDBC.FileName); dbcWriter.writeDBC(dbcParser.DbVersion, dbcParser.DbCustomer, dbcParser.DbName, String.IsNullOrEmpty(dbcParser.DbBaudrate) ? "500000" : dbcParser.DbBaudrate, dbcParser.ExtGetAllMessages()); dbcWriter.close(); System.Windows.Forms.MessageBox.Show("DBC File Saved successfully!", "OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception exp) { System.Windows.Forms.MessageBox.Show("Cannot save dbc file\n" + exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }