private void saveProjectXMLToolStripMenuItem_Click(object sender, EventArgs e) { if (tabControl1.SelectedTab != null) { DeviceView dv = (DeviceView)tabControl1.SelectedTab.Controls[0]; SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Canopen Node XML (*.xml)|*.xml"; sfd.InitialDirectory = Path.GetDirectoryName(dv.eds.xmlfilename); sfd.RestoreDirectory = true; sfd.FileName = Path.GetFileNameWithoutExtension(dv.eds.xmlfilename); if (sfd.ShowDialog() == DialogResult.OK) { //dv.eds.savefile(sfd.FileName); Bridge b = new Bridge(); Device d = b.convert(dv.eds); CanOpenXML coxml = new CanOpenXML(); coxml.dev = d; coxml.writeXML(sfd.FileName); dv.eds.xmlfilename = sfd.FileName; dv.eds.dirty = false; } } }
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) { //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; } if (dv.eds.xmlfilename == null || dv.eds.xmlfilename == "") { MessageBox.Show("Please manually save as XML at least once"); return; } if (dv.eds.fi.exportFolder == null || dv.eds.fi.exportFolder == "") { MessageBox.Show("Please expot CO_OD.c/h at least 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); //export EDS dv.eds.savefile(dv.eds.edsfilename); //export CO_OD.c and CO_OD.h CanOpenNodeExporter cone = new CanOpenNodeExporter(); cone.export(dv.eds.fi.exportFolder, dv.eds); if (Warnings.warning_list.Count != 0) { WarningsFrm frm = new WarningsFrm(); frm.ShowDialog(); } } }
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); //export EDS dv.eds.savefile(dv.eds.edsfilename); //export CO_OD.c and CO_OD.h CanOpenNodeExporter cone = new CanOpenNodeExporter(); try { cone.export(dv.eds.fi.exportFolder, 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(); } } }