void dosave(DeviceView dv, string FileName) { switch (Path.GetExtension(FileName)) { case ".eds": dv.eds.Savefile(FileName, InfoSection.Filetype.File_EDS); dv.eds.edsfilename = FileName; break; case ".dcf": dv.eds.Savefile(FileName, InfoSection.Filetype.File_DCF); dv.eds.dcffilename = FileName; break; case ".xml": Bridge b = new Bridge(); Device d = b.convert(dv.eds); CanOpenXML coxml = new CanOpenXML(); coxml.dev = d; coxml.writeXML(FileName); dv.eds.xmlfilename = FileName; break; case ".xdd": CanOpenXDD coxdd = new CanOpenXDD(); coxdd.writeXML(FileName, dv.eds); dv.eds.xddfilename = FileName; dv.eds.Dirty = false; break; } dv.dispatch_updateOD(); }
private void saveExportAllToolStripMenuItem_Click(object sender, EventArgs e) { string temp; //Attempt to save EDS,XML and export the CANopen dictionary if (tabControl1.SelectedTab != null) { DeviceView dv = (DeviceView)tabControl1.SelectedTab.Controls[0]; SaveFileDialog sfd = new SaveFileDialog(); //save eds xml and export CO_OD.c and CO_OD.h if (dv.eds.edsfilename == null || dv.eds.edsfilename == "") { MessageBox.Show("Please manually save as EDS at least once"); return; } temp = Path.GetDirectoryName(dv.eds.edsfilename); if (Directory.Exists(temp) != true) { MessageBox.Show("File path was removed. Please manually save as EDS once"); return; } if (dv.eds.xmlfilename == null || dv.eds.xmlfilename == "") { MessageBox.Show("Please manually save as XML at least once"); return; } temp = Path.GetDirectoryName(dv.eds.xmlfilename); if (Directory.Exists(temp) != true) { MessageBox.Show("File path was removed. Please manually save as XML once"); return; } if (dv.eds.fi.exportFolder == null || dv.eds.fi.exportFolder == "") { MessageBox.Show("Please export CO_OD.c/h at least once"); return; } if (Directory.Exists(dv.eds.fi.exportFolder) != true) { MessageBox.Show("File path was removed. Please export CO_OD.c/h once"); return; } //export XML Bridge b = new Bridge(); Device d = b.convert(dv.eds); CanOpenXML coxml = new CanOpenXML(); coxml.dev = d; coxml.writeXML(dv.eds.xmlfilename); if (dv.eds.xddfilename != null) { CanOpenXDD coxdd = new CanOpenXDD(); coxdd.writeXML(dv.eds.xddfilename, dv.eds); } //export EDS dv.eds.Savefile(dv.eds.edsfilename, InfoSection.Filetype.File_EDS); //export CO_OD.c and CO_OD.h CanOpenNodeExporter cone = new CanOpenNodeExporter(); try { cone.export(dv.eds.fi.exportFolder, "", this.gitVersion, dv.eds); } catch (Exception ex) { MessageBox.Show("Export failed, error message:\n" + ex.ToString()); return; } dv.eds.Dirty = false; if (Warnings.warning_list.Count != 0) { WarningsFrm frm = new WarningsFrm(); frm.ShowDialog(); } } }