Example #1
0
        private void exportCanOpenNodeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab != null)
            {
                DeviceView dv = (DeviceView)tabControl1.SelectedTab.Controls[0];

                SaveFileDialog sfd = new SaveFileDialog();
                sfd.CheckFileExists = false;

                sfd.FileName         = "CO_OD.c";
                sfd.InitialDirectory = dv.eds.fi.exportFolder;
                sfd.RestoreDirectory = true;

                DialogResult result = sfd.ShowDialog();

                if (result == DialogResult.OK)
                {
                    string savePath = Path.GetDirectoryName(sfd.FileName);
                    dv.eds.fi.exportFolder = savePath;

                    Warnings.warning_list.Clear();

                    CanOpenNodeExporter cone = new CanOpenNodeExporter();
                    cone.export(savePath, dv.eds);

                    if (Warnings.warning_list.Count != 0)
                    {
                        WarningsFrm frm = new WarningsFrm();
                        frm.ShowDialog();
                    }
                }
            }
        }
Example #2
0
        private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Warnings.warning_list.Clear();

                if (tabControl1.SelectedTab != null)
                {
                    DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                    SaveFileDialog sfd = new SaveFileDialog();

                    string temp = Path.GetTempFileName();

                    this.UseWaitCursor = true;

                    DocumentationGen docgen = new DocumentationGen();
                    docgen.genhtmldoc(temp, dv.eds);
                    ReportView rv = new ReportView(temp);
                    rv.Show();

                    this.UseWaitCursor = false;
                }
            }
            catch (Exception ex)
            {
                Warnings.warning_list.Add(ex.ToString());
            }

            if (Warnings.warning_list.Count != 0)
            {
                WarningsFrm frm = new WarningsFrm();
                frm.ShowDialog();
            }
        }
Example #3
0
        private void documentationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Warnings.warning_list.Clear();

                if (tabControl1.SelectedTab != null)
                {
                    DeviceView     dv  = (DeviceView)tabControl1.SelectedTab.Controls[0];
                    SaveFileDialog sfd = new SaveFileDialog();

                    string dir = GetTemporaryDirectory();


                    string csspath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".edseditor");
                    csspath = Path.Combine(csspath, "style.css");

                    if (!System.IO.File.Exists(csspath))
                    {
                        csspath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "style.css");
                    }

                    if (System.IO.File.Exists(csspath))
                    {
                        System.IO.File.Copy(csspath, dir + Path.DirectorySeparatorChar + "style.css");
                    }

                    string temp  = dir + Path.DirectorySeparatorChar + "documentation.html";
                    string temp2 = dir + Path.DirectorySeparatorChar + "documentation.md";

                    this.UseWaitCursor = true;

                    DocumentationGen docgen = new DocumentationGen();
                    docgen.genhtmldoc(temp, dv.eds);
                    docgen.genmddoc(temp2, dv.eds);
                    System.Diagnostics.Process.Start("file://" + temp2);
                    if (IsRunningOnMono())
                    {
                        System.Diagnostics.Process.Start("file://" + temp);
                    }
                    else
                    {
                        ReportView rv = new ReportView(temp);
                        rv.Show();
                    }

                    this.UseWaitCursor = false;
                }
            }
            catch (Exception ex)
            {
                Warnings.warning_list.Add(ex.ToString());
            }

            if (Warnings.warning_list.Count != 0)
            {
                WarningsFrm frm = new WarningsFrm();
                frm.ShowDialog();
            }
        }
Example #4
0
        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();
                }
            }
        }
Example #5
0
        private void openXDDfile(string path)
        {
            try
            {
                EDSsharp eds;

                //fixme
                //ISO15745ProfileContainer devs; //one day this will be multiple devices

                CanOpenXDD coxml = new CanOpenXDD();
                eds = coxml.readXML(path);

                if (eds == null)
                {
                    return;
                }

                eds.xddfilename = path;

                tabControl1.TabPages.Add(eds.di.ProductName);

                DeviceView device = new DeviceView();

                eds.OnDataDirty += Eds_onDataDirty;

                device.eds = eds;
                tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);
                device.Dock = DockStyle.Fill;

                device.dispatch_updateOD();

                network.Add(eds);
            }
            catch (Exception ex)
            {
                Warnings.warning_list.Add(ex.ToString());
            }

            if (Warnings.warning_list.Count != 0)
            {
                WarningsFrm frm = new WarningsFrm();
                frm.ShowDialog();
            }
        }
Example #6
0
        private void openXMLfile(string path)
        {
            try
            {
                EDSsharp eds;
                Device   dev; //one day this will be multiple devices

                CanOpenXML coxml = new CanOpenXML();
                coxml.readXML(path);

                Bridge b = new Bridge();

                eds             = b.convert(coxml.dev);
                eds.xmlfilename = path;

                dev = coxml.dev;

                tabControl1.TabPages.Add(eds.di.ProductName);

                DeviceView device = new DeviceView();

                eds.onDataDirty += Eds_onDataDirty;

                device.eds = eds;
                tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);
                device.Dock = DockStyle.Fill;

                device.dispatch_updateOD();

                network.Add(eds);
            }
            catch (Exception ex)
            {
                Warnings.warning_list.Add(ex.ToString());
            }

            if (Warnings.warning_list.Count != 0)
            {
                WarningsFrm frm = new WarningsFrm();
                frm.ShowDialog();
            }
        }
Example #7
0
        private void openEDSfile(string path)
        {
            Warnings.warning_list.Clear();

            try
            {
                EDSsharp eds = new EDSsharp();
                Device   dev;

                eds.loadfile(path);
                Bridge bridge = new Bridge(); //tell me again why bridge is not static?
                dev = bridge.convert(eds);

                DeviceView device = new DeviceView();

                eds.onDataDirty += Eds_onDataDirty;

                device.eds = eds;
                tabControl1.TabPages.Add(eds.di.ProductName);
                tabControl1.TabPages[tabControl1.TabPages.Count - 1].Controls.Add(device);
                device.Dock = DockStyle.Fill;

                device.dispatch_updateOD();

                network.Add(eds);
            }
            catch (Exception ex)
            {
                Warnings.warning_list.Add(ex.ToString());
            }

            if (Warnings.warning_list.Count != 0)
            {
                WarningsFrm frm = new WarningsFrm();
                frm.ShowDialog();
            }
        }
Example #8
0
        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();
                }
            }
        }