Ejemplo n.º 1
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(false, new string[] {
                "JSON Orbital Parameters",
            },
                     outputext: new string[] { "JSON|*.json|All|*.*" },
                     showflags: new Forms.ExportForm.ShowFlags[] { Forms.ExportForm.ShowFlags.DTCVSOI },
                     suggestedfilenames: new string[] { last_he?.System.Name ?? "" }

                     );

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                try
                {
                    var sysnode = discoveryform.history.StarScan.FindSystemSynchronous(showing_system, false);
                    var nodes   = sysnode.OrderedSystemTree();
                    if (nodes != null)
                    {
                        StarScan.ScanNode.DumpTree(nodes, "Top", 0);
                        QuickJSON.JObject jobj = StarScan.ScanNode.DumpOrbitElements(nodes);
                        File.WriteAllText(frm.Path, jobj.ToString(true)); // failure will be picked up below
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Scan excel " + ex);
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View" }, allowRawJournalExport: true);

            if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);
                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < dataGridViewJournal.Rows.Count)
                        {
                            HistoryEntry he = dataGridViewJournal.Rows[r].Cells[JournalHistoryColumns.HistoryTag].Tag as HistoryEntry;
                            return((dataGridViewJournal.Rows[r].Visible &&
                                    he.EventTimeLocal.CompareTo(frm.StartTime) >= 0 &&
                                    he.EventTimeLocal.CompareTo(frm.EndTime) <= 0) ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.Skip);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    grd.GetLine += delegate(int r)
                    {
                        HistoryEntry    he = dataGridViewJournal.Rows[r].Cells[JournalHistoryColumns.HistoryTag].Tag as HistoryEntry;
                        DataGridViewRow rw = dataGridViewJournal.Rows[r];
                        if (frm.ExportAsJournals)
                        {
                            return(new Object[] { he.journalEntry.GetJson()?.ToString() });
                        }
                        else
                        {
                            return new Object[] { rw.Cells[0].Value, rw.Cells[2].Value, rw.Cells[3].Value }
                        };
                    };

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < 3 && frm.IncludeHeader) ? dataGridViewJournal.Columns[c + ((c > 0) ? 1 : 0)].HeaderText : null);
                    };

                    if (grd.WriteCSV(frm.Path))
                    {
                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(frm.Path);
                        }
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            if (dataGridViewRoute.Rows.Count == 0)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(), "No Route Plotted", "Route", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "All" }, disablestartendtime: true);

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                grd.SetCSVDelimiter(frm.Comma);

                grd.GetLineStatus += delegate(int r)
                {
                    if (r < dataGridViewRoute.Rows.Count)
                    {
                        return(BaseUtils.CSVWriteGrid.LineStatus.OK);
                    }
                    else
                    {
                        return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                    }
                };

                grd.GetLine += delegate(int r)
                {
                    DataGridViewRow rw = dataGridViewRoute.Rows[r];

                    return(new Object[] { rw.Cells[0].Value, rw.Cells[1].Value,
                                          rw.Cells[2].Value, rw.Cells[3].Value, rw.Cells[4].Value,
                                          rw.Cells[5].Value, rw.Cells[6].Value });
                };

                grd.GetHeader += delegate(int c)
                {
                    return((c < dataGridViewRoute.Columns.Count) ? dataGridViewRoute.Columns[c].HeaderText : null);
                };


                if (grd.WriteCSV(frm.Path))
                {
                    if (frm.AutoOpen)
                    {
                        System.Diagnostics.Process.Start(frm.Path);
                    }
                }
                else
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Ejemplo n.º 4
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            var current_mc = discoveryform.history.CashLedger;

            if (current_mc != null)
            {
                Forms.ExportForm frm = new Forms.ExportForm();

                frm.Init(false, new string[] { "Export Current View" }, showflags: new Forms.ExportForm.ShowFlags[] { Forms.ExportForm.ShowFlags.DisableDateTime });

                if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);

                    grd.GetHeader += delegate(int c)
                    {
                        return((frm.IncludeHeader && c < dataGridViewLedger.ColumnCount) ? dataGridViewLedger.Columns[c].HeaderText : null);
                    };

                    grd.GetLine += delegate(int r)
                    {
                        if (r < dataGridViewLedger.RowCount)
                        {
                            DataGridViewRow rw = dataGridViewLedger.Rows[r];
                            return(new Object[] { rw.Cells[0].Value, rw.Cells[1].Value, rw.Cells[2].Value, rw.Cells[3].Value, rw.Cells[4].Value, rw.Cells[5].Value, rw.Cells[6].Value });
                        }
                        else
                        {
                            return(null);
                        }
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
            }
            else
            {
                ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "No Ledger available".T(EDTx.UserControlLedger_NOLG), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            if (dataGridViewEDSM.Rows.Count == 0)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(), "No data to export", "Export EDSM", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View" }, disablestartendtime: true);

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);

                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < dataGridViewEDSM.Rows.Count)
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.OK);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    string[] colh = new string[] { "Star", "Distance", "X", "Y", "Z", "ID" };

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < colh.Length && frm.IncludeHeader) ? colh[c] : null);
                    };

                    grd.GetLine += delegate(int r)
                    {
                        DataGridViewRow rw  = dataGridViewEDSM.Rows[r];
                        ISystem         sys = rw.Tag as ISystem;
                        return(new Object[]
                        {
                            rw.Cells[0].Value, rw.Cells[1].Value, sys.X.ToString("0.#"), sys.Y.ToString("0.#"), sys.Z.ToString("0.#"), rw.Cells[3].Value
                        });
                    };

                    if (grd.WriteCSV(frm.Path))
                    {
                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(frm.Path);
                        }
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "All" }, disablestartendtime: true);

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                grd.SetCSVDelimiter(frm.Comma);

                var found = ReadHistory(out int prospectorsused, out int collectorsused, out int asteroidscracked, out int prospected, out int[] content);

                grd.GetPreHeader += delegate(int r)
                {
                    if (r == 0)
                    {
                        return new Object[] { "Limpets left ", limpetsleftdisplay, "Prospectors Fired", prospectorsused, "Collectors Deployed", collectorsused }
                    }
                    ;
                    else if (r == 1)
                    {
                        return(new object[0]);
                    }
                    else
                    {
                        return(null);
                    }
                };

                grd.GetSetsPad = delegate(int s, int r)
                {
                    return(r < 2 ? new object[0] : null);
                };

                {
                    grd.GetSetsHeader.Add(delegate(int s, int r)
                    {
                        if (r == 0)
                        {
                            return new object[] { "", "Ref.", "Coll.", "Pros", "Ratio%", "Avg%", "Min%", "Max%", "M.Load", "High Ct", "Med Ct", "Low Ct", "Discv" }
                        }
                        ;
                        else
                        {
                            return(null);
                        }
                    });

                    grd.GetSetsData.Add(delegate(int s, int r)
                    {
                        if (r == 0)
                        {
                            return(new object[] { "", "", "", prospected.ToString("N0"), "", "", "", "", "",
                                                  content[0].ToString("N0"),
                                                  content[1].ToString("N0"),
                                                  content[2].ToString("N0") });
                        }
                        else if (r <= found.Count)
                        {
                            MaterialsFound f = found[r - 1];
                            return(new object[] { f.friendlyname, f.amountrefined, f.amountcollected - f.amountdiscarded,
                                                  f.prospectednoasteroids > 0 ? f.prospectednoasteroids.ToString("N0") : "",
                                                  f.prospectednoasteroids > 0 ? (100.0 * (double)f.prospectednoasteroids / prospected).ToString("N1") : "",
                                                  f.prospectednoasteroids > 0 ? f.prospectedamounts.Average().ToString("N1") : "",
                                                  f.prospectednoasteroids > 0 ? f.prospectedamounts.Min().ToString("N1") : "",
                                                  f.prospectednoasteroids > 0 ? f.prospectedamounts.Max().ToString("N1") : "",
                                                  f.motherloadasteroids > 0 ? f.motherloadasteroids.ToString("N0") : "",
                                                  f.prospectednoasteroids > 0 ? f.content[0].ToString("N0") :"",
                                                  f.prospectednoasteroids > 0 ? f.content[1].ToString("N0") : "",
                                                  f.prospectednoasteroids > 0 ? f.content[2].ToString("N0") : "",
                                                  f.discovered ? "*" : "" });
                        }
                        else
                        {
                            return(null);
                        }
                    });
                }

                var prosmat = found.Where(x => x.prospectednoasteroids > 0).ToList();

                {
                    grd.GetSetsHeader.Add(delegate(int s, int r)
                    {
                        if (r == 0)
                        {
                            Object[] ret = new object[prosmat.Count + 1];
                            ret[0]       = "CDFb";

                            for (int i = 0; i < prosmat.Count; i++)
                            {
                                ret[i + 1] = prosmat[i].friendlyname;
                            }

                            return(ret);
                        }
                        else
                        {
                            return(null);
                        }
                    });

                    grd.GetSetsData.Add(delegate(int s, int r)
                    {
                        if (r < CFDbMax)
                        {
                            Object[] ret = new object[prosmat.Count + 1];
                            int percent  = r;
                            ret[0]       = percent.ToString("N0") + "%";
                            for (int m = 0; m < prosmat.Count; m++)
                            {
                                if (prosmat[m].prospectednoasteroids > 0)
                                {
                                    ret[m + 1] = ((double)prosmat[m].prospectedamounts.Count(x => x >= percent) / prosmat[m].prospectednoasteroids * 100.0).ToString("N1");
                                }
                                else
                                {
                                    ret[m + 1] = "";
                                }
                            }

                            return(ret);
                        }
                        else
                        {
                            return(null);
                        }
                    });
                }

                {
                    const int precol = 4;

                    grd.GetSetsHeader.Add(delegate(int s, int r)
                    {
                        if (r == 0)
                        {
                            Object[] ret = new object[found.Count + precol];
                            ret[0]       = "Event";
                            ret[1]       = "Time";
                            ret[2]       = "Content";
                            ret[3]       = "Motherload";

                            for (int i = 0; i < prosmat.Count; i++)
                            {
                                ret[i + precol] = prosmat[i].friendlyname;
                            }

                            return(ret);
                        }
                        else
                        {
                            return(null);
                        }
                    });

                    var proslist = curlist.Where(x => x.EntryType == JournalTypeEnum.ProspectedAsteroid).ToList();

                    grd.GetSetsData.Add(delegate(int s, int r)
                    {
                        if (r < proslist.Count)
                        {
                            var jp = proslist[r].journalEntry as JournalProspectedAsteroid;

                            Object[] ret = new object[prosmat.Count + precol];
                            ret[0]       = (r + 1).ToString("N0");
                            ret[1]       = jp.EventTimeUTC.ToStringZulu();
                            ret[2]       = jp.Content.ToString();
                            ret[3]       = MaterialCommodityData.GetByFDName(jp.MotherlodeMaterial)?.Name ?? jp.MotherlodeMaterial;

                            for (int m = 0; m < prosmat.Count; m++)
                            {
                                int mi = Array.FindIndex(jp.Materials, x => x.Name == prosmat[m].matnamefd2);
                                if (mi >= 0)
                                {
                                    ret[m + precol] = jp.Materials[mi].Proportion.ToString("N2");
                                }
                                else
                                {
                                    ret[m + precol] = "";
                                }
                            }
                            return(ret);
                        }
                        else
                        {
                            return(null);
                        }
                    });
                }

                grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
            }
        }
Ejemplo n.º 7
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            if (dataGridViewBookMarks.Rows.Count == 0)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(), "No data to export", "Export EDSM", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View" }, disablestartendtime: true);

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)
                {
                    string path = frm.Path;               //string path = "C:\\code\\f.csv"; // debug

                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);

                    List <string> colh = new List <string>();
                    colh.AddRange(new string[] { "Type", "Time", "System/Region", "Note", "X", "Y", "Z", "Planet", "Name", "Comment", "Lat", "Long" });

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < colh.Count && frm.IncludeHeader) ? colh[c] : null);
                    };

                    int bkrowno = 0;
                    IEnumerator <Tuple <PlanetMarks.Planet, PlanetMarks.Location> > planetloc = null;

                    System.Diagnostics.Debug.WriteLine("Rows " + dataGridViewBookMarks.Rows.Count);

                    grd.GetLineStatus += delegate(int r)
                    {
                        return(bkrowno < dataGridViewBookMarks.Rows.Count ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.EOF);
                    };

                    grd.GetLine += delegate(int r)
                    {
                        DataGridViewRow rw             = dataGridViewBookMarks.Rows[bkrowno];
                        BookmarkClass   bk             = rw.Tag as BookmarkClass;
                        bool            firstplanetrow = false;

                        if (planetloc == null && bk.hasPlanetaryMarks)          // if not iterating planets, but it has one, iterate
                        {
                            planetloc = bk.PlanetaryMarks.GetEnumerator();
                            planetloc.MoveNext();       // move to first
                            firstplanetrow = true;
                        }

                        List <Object> retrow = new List <Object>
                        {
                            bk.isRegion ? "Region" : "System",
                                      bk.Time.ToStringYearFirst(),
                                      bk.isRegion ? bk.Heading : bk.StarName,
                                      bk.Note,
                                      bk.x.ToString("0.##"),
                            bk.y.ToString("0.##"),
                            bk.z.ToString("0.##"),
                        };

                        System.Diagnostics.Debug.WriteLine("Export system " + bkrowno + " " + bk.StarName);

                        if (planetloc != null)
                        {
                            var           plloc     = planetloc.Current;
                            List <Object> planetrow = new List <Object>
                            {
                                plloc.Item1.Name,
                                plloc.Item2.Name,
                                plloc.Item2.Comment,
                                plloc.Item2.IsWholePlanetBookmark ? "" : plloc.Item2.Latitude.ToString("0.##"),
                                plloc.Item2.IsWholePlanetBookmark ? "" : plloc.Item2.Longitude.ToString("0.##"),
                            };

                            if (!firstplanetrow)
                            {
                                retrow = new List <object>()
                                {
                                    "", "", "", "", "", "", ""
                                };
                            }

                            retrow.AddRange(planetrow);
                        }

                        if (planetloc == null || planetloc.MoveNext() == false)
                        {
                            planetloc = null;
                            bkrowno++;
                        }

                        return(retrow.ToArray());
                    };

                    if (grd.WriteCSV(path))
                    {
                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(path);
                        }
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        private void toolStripButtonExport_Click(object sender, EventArgs e)
        {
            if (dataGridViewExplore.Rows.Count == 0 ||
                (dataGridViewExplore.Rows.Count == 1 && ((string)dataGridViewExplore[0, 0].Value).IsEmpty()))
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(),
                                                      "There is no route to export".T(EDTx.UserControlExploration_NoRoute), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Route", "Grid" }, disablestartendtime: true, outputext: new string[] { "Text File|*.txt", "CSV export| *.csv" });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)     // old route export
                {
                    try
                    {
                        using (StreamWriter writer = new StreamWriter(frm.Path, false))
                        {
                            for (int i = 0; i < dataGridViewExplore.Rows.Count; i++)
                            {
                                String sysname = (String)dataGridViewExplore[0, i].Value;
                                if (!String.IsNullOrWhiteSpace(sysname))
                                {
                                    writer.WriteLine(sysname);
                                }
                            }
                        }

                        if (frm.AutoOpen)
                        {
                            try
                            {
                                System.Diagnostics.Process.Start(frm.Path);
                            }
                            catch
                            {
                                ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to open " + frm.Path, "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }
                    catch (IOException)
                    {
                        ExtendedControls.MessageBoxTheme.Show(FindForm(), string.Format("Error exporting route. Is file {0} open?".T(EDTx.UserControlExploration_ErrorW), frm.Path), "Warning".T(EDTx.Warning),
                                                              MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);
                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < dataGridViewExplore.Rows.Count)
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.OK);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    grd.GetLine += delegate(int r)
                    {
                        DataGridViewRow rw = dataGridViewExplore.Rows[r];
                        return(new Object[] { rw.Cells[0].Value, rw.Cells[1].Value, rw.Cells[2].Value, rw.Cells[3].Value,
                                              rw.Cells[4].Value, rw.Cells[5].Value, rw.Cells[6].Value, rw.Cells[7].Value,
                                              rw.Cells[8].Value, rw.Cells[9].Value, rw.Cells[10].Value });
                    };

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < 3 && frm.IncludeHeader) ? dataGridViewExplore.Columns[c].HeaderText : null);
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
            }
        }
Ejemplo n.º 9
0
        private void extButtonExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View", "All" }, disablestartendtime: true);

            if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
            {
                BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                grd.SetCSVDelimiter(frm.Comma);

                grd.GetLineHeader += delegate(int c)
                {
                    if (c == 0)
                    {
                        return new string[] { "Time", "System", "Body", "Note", "Tags" }
                    }
                    ;
                    else
                    {
                        return(null);
                    }
                };

                if (frm.SelectedIndex == 1)
                {
                    List <CaptainsLogClass> logs = GlobalCaptainsLogList.Instance.LogEntries;
                    int i = 0;

                    grd.GetLine += delegate(int r)
                    {
                        while (i < logs.Count)
                        {
                            CaptainsLogClass ent = logs[i++];
                            if (ent.Commander == EDCommander.CurrentCmdrID)
                            {
                                return(new object[] { EDDConfig.Instance.ConvertTimeToSelectedFromUTC(ent.TimeUTC),
                                                      ent.SystemName, ent.BodyName, ent.Note, ent.Tags });
                            }
                        }

                        return(null);
                    };
                }
                else
                {
                    grd.GetLine += delegate(int r)
                    {
                        if (r < dataGridView.RowCount)
                        {
                            DataGridViewRow  rw  = dataGridView.Rows[r];
                            CaptainsLogClass ent = rw.Tag as CaptainsLogClass;
                            return(new Object[] { rw.Cells[0].Value, rw.Cells[1].Value, rw.Cells[2].Value, rw.Cells[3].Value, ent.Tags });
                        }

                        return(null);
                    };
                }

                grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
            }
        }
Ejemplo n.º 10
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View", "Export as Journals" }, outputext: new string[] { "CSV export| *.csv", "Journal Export|*.log" });

            if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 1)
                {
                    try
                    {
                        using (StreamWriter writer = new StreamWriter(frm.Path))
                        {
                            foreach (DataGridViewRow dgvr in dataGridViewJournal.Rows)
                            {
                                HistoryEntry he = dgvr.Tag as HistoryEntry;
                                if (dgvr.Visible && he.EventTimeUTC.CompareTo(frm.StartTimeUTC) >= 0 && he.EventTimeUTC.CompareTo(frm.EndTimeUTC) <= 0)
                                {
                                    string forExport = he.journalEntry.GetJsonString().Replace("\r\n", "");
                                    if (forExport != null)
                                    {
                                        forExport = System.Text.RegularExpressions.Regex.Replace(forExport, "(\"(?:[^\"\\\\]|\\\\.)*\")|\\s+", "$1");
                                        writer.Write(forExport);
                                        writer.WriteLine();
                                    }
                                }
                            }
                        }

                        if (frm.AutoOpen)
                        {
                            try
                            {
                                System.Diagnostics.Process.Start(frm.Path);
                            }
                            catch
                            {
                                ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to open " + frm.Path, "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }
                    catch
                    {
                        ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);
                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < dataGridViewJournal.Rows.Count)
                        {
                            HistoryEntry he = dataGridViewJournal.Rows[r].Tag as HistoryEntry;
                            return((dataGridViewJournal.Rows[r].Visible &&
                                    he.EventTimeUTC.CompareTo(frm.StartTimeUTC) >= 0 &&
                                    he.EventTimeUTC.CompareTo(frm.EndTimeUTC) <= 0) ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.Skip);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    grd.GetLine += delegate(int r)
                    {
                        DataGridViewRow rw = dataGridViewJournal.Rows[r];
                        return(new Object[] { rw.Cells[0].Value, rw.Cells[2].Value, rw.Cells[3].Value });
                    };

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < 3 && frm.IncludeHeader) ? dataGridViewJournal.Columns[c + ((c > 0) ? 1 : 0)].HeaderText : null);
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
            }
        }
Ejemplo n.º 11
0
        private void toolStripButtonExport_Click(object sender, EventArgs e)
        {
            var rt = new SavedRouteClass();

            UpdateRouteInfo(rt);

            if (rt.Systems.Count < 1)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(), "There is no route to export ".T(EDTx.UserControlExpedition_NoRouteExport),
                                                      "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Route", "Grid" }, disablestartendtime: true, outputext: new string[] { "Text File|*.txt", "CSV export| *.csv" });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)     // old route export
                {
                    try
                    {
                        using (StreamWriter writer = new StreamWriter(frm.Path, false))
                        {
                            foreach (var sysname in rt.Systems)
                            {
                                if (!string.IsNullOrWhiteSpace(sysname))
                                {
                                    writer.WriteLine(sysname);
                                }
                            }
                        }

                        if (frm.AutoOpen)
                        {
                            try
                            {
                                System.Diagnostics.Process.Start(frm.Path);
                            }
                            catch
                            {
                                ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to open " + frm.Path, "Warning".Tx(), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                    }
                    catch
                    {
                        ExtendedControls.MessageBoxTheme.Show(FindForm(), $"Problem exporting route. Is file {frm.Path} already open?",
                                                              "Export route", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);
                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < dataGridViewRouteSystems.Rows.Count)
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.OK);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    grd.GetLine += delegate(int r)
                    {
                        DataGridViewRow rw = dataGridViewRouteSystems.Rows[r];
                        return(new Object[] { rw.Cells[0].Value, rw.Cells[1].Value, rw.Cells[2].Value });
                    };

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < 3 && frm.IncludeHeader) ? dataGridViewRouteSystems.Columns[c].HeaderText : null);
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
            }
        }
Ejemplo n.º 12
0
        private void buttonExtImport_Click(object sender, EventArgs e)
        {
            var frm = new Forms.ExportForm();

            frm.Init(true, new string[] { "CSV" },
                     new string[] { "CSV|*.csv" },
                     new Forms.ExportForm.ShowFlags[] { Forms.ExportForm.ShowFlags.DTOI });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                string path = frm.Path;

                BaseUtils.CSVFile csv = new BaseUtils.CSVFile();

                if (csv.Read(path, System.IO.FileShare.ReadWrite, frm.Comma))
                {
                    List <BaseUtils.CSVFile.Row> rows = csv.RowsExcludingHeaderRow;

                    BookmarkClass currentbk = null;

                    var Regexyyyyddmm = new System.Text.RegularExpressions.Regex(@"\d\d\d\d-\d\d-\d\d", System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.Singleline);

                    foreach (var r in rows)
                    {
                        string type = r[0];
                        string date = r[1];

                        if (type.HasChars() && date.HasChars())
                        {
                            bool region = type?.Equals("Region", StringComparison.InvariantCultureIgnoreCase) ?? false;

                            DateTime timeutc = DateTime.MinValue;

                            bool isyyyy = Regexyyyyddmm.IsMatch(date);      // excel, after getting our output in, converts the damn thing to local dates.. this distinguishes it.

                            bool success = isyyyy ? DateTime.TryParse(date, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal, out timeutc) :
                                           DateTime.TryParse(date, System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.AssumeUniversal, out timeutc);

                            if (success)
                            {
                                timeutc = EDDConfig.Instance.ConvertTimeToUTCFromSelected(timeutc);     // assume import is in selected time base, convert

                                string name = r[2];
                                string note = r[3];
                                double?x    = r[4].InvariantParseDoubleNull();
                                double?y    = r[5].InvariantParseDoubleNull();
                                double?z    = r[6].InvariantParseDoubleNull();

                                if (x != null && y != null && z != null)
                                {
                                    System.Diagnostics.Debug.WriteLine("Bookmark {0} {1} {2} {3} ({4},{5},{6}", type, timeutc.ToStringZulu(), name, note, x, y, z);

                                    currentbk = GlobalBookMarkList.Instance.FindBookmark(name, region);

                                    if (currentbk != null)
                                    {
                                        GlobalBookMarkList.Instance.AddOrUpdateBookmark(currentbk, !region, name, x.Value, y.Value, z.Value, timeutc, note, currentbk.PlanetaryMarks);
                                    }
                                    else
                                    {
                                        currentbk = GlobalBookMarkList.Instance.AddOrUpdateBookmark(null, !region, name, x.Value, y.Value, z.Value, timeutc, note, null);
                                    }
                                }
                                else
                                {
                                    System.Diagnostics.Debug.WriteLine("Not a system with valid coords {0} {1}", r[0], r[1]);
                                }
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine("Rejected due to date {0} {1}", r[0], r[1]);
                            }
                        }

                        string planet = r[7];

                        if (planet.HasChars() && currentbk != null)
                        {
                            string locname   = r[8];
                            string comment   = r[9];
                            double?latitude  = r[10].InvariantParseDoubleNull();
                            double?longitude = r[11].InvariantParseDoubleNull();

                            if (!locname.HasChars() && latitude == null && longitude == null) // whole planet bookmark
                            {
                                currentbk.AddOrUpdatePlanetBookmark(planet, comment);
                            }
                            else if (locname.HasChars() && latitude.HasValue && longitude.HasValue)
                            {
                                currentbk.AddOrUpdateLocation(planet, locname, comment, latitude.Value, longitude.Value);
                            }
                        }
                    }

                    PutSetting("ImportExcelFolder", System.IO.Path.GetDirectoryName(path));
                }
                else
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to read " + path, "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
        public void Excel(int columnsout)
        {
            if (Rows.Count == 0)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(), "No data to export", "Export EDSM", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View" }, disablestartendtime: true);

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);

                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < Rows.Count)
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.OK);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    List <string> colh = new List <string>();
                    for (int i = 0; i < columnsout; i++)
                    {
                        colh.Add(Columns[i].HeaderText);
                    }
                    colh.AddRange(new string[] { "X", "Y", "Z", "ID" });

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < colh.Count && frm.IncludeHeader) ? colh[c] : null);
                    };

                    grd.GetLine += delegate(int r)
                    {
                        DataGridViewRow rw   = Rows[r];
                        ISystem         sys  = SysFrom(rw.Tag);
                        List <Object>   data = new List <object>();
                        for (int i = 0; i < columnsout; i++)
                        {
                            data.Add(rw.Cells[i].Value);
                        }

                        data.Add(sys.X.ToString("0.#"));
                        data.Add(sys.Y.ToString("0.#"));
                        data.Add(sys.Z.ToString("0.#"));
                        data.Add(sys.EDSMID);

                        return(data.ToArray());
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
            }
        }
Ejemplo n.º 14
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "All",
                                    "Stars only",
                                    "Planets only",             //2
                                    "Exploration List Stars",   //3
                                    "Exploration List Planets", //4
                                    "Ring Scans",               //5
                     });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                BaseUtils.CSVWrite csv = new BaseUtils.CSVWrite();
                csv.SetCSVDelimiter(frm.Comma);

                try
                {
                    if (frm.SelectedIndex == 5)
                    {
                        var saaentries  = JournalEntry.GetByEventType(JournalTypeEnum.SAASignalsFound, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalSAASignalsFound)x);
                        var scanentries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalScan)x);

                        BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                        grd.SetCSVDelimiter(frm.Comma);

                        string[] headers1 = { "",           "", "", "", "", "",
                                              "Icy Ring",   "", "", "", "", "","",  "", "", "",
                                              "Rocky",      "", "", "", "", "","",  "",
                                              "Metal Rich", "", "", "", "",
                                              "Metalic",    "", "", "", "",
                                              "Other" };

                        string[] headers2 = { "Time",         "BodyName",      "Ring Types",    "Mass MT",  "Inner Rad (ls)", "Outer Rad (ls)",

                                              // icy ring
                                              "Water",        "Liquid Oxygen", "Methanol Mono", "Methane",  "Bromellite",     "Grandidierite", "Low Temp Diamonds","Void Opals",   "Alexandrite", "Tritium",
                                              // rocky
                                              "Bauxite",      "Indite",        "Alexandrite",   "Monazite", "Musgravite",     "Benitoite",     "Serendibite",   "Rhodplumsite",
                                              // metal rich
                                              "Rhodplumsite", "Serendibite",   "Platinum",      "Monazite", "Painite",
                                              // metalic
                                              "Rhodplumsite", "Serendibite",   "Platinum",      "Monazite", "Painite",
                                              // others
                                              "Geological",   "Biological",    "Thargoid",      "Human",    "Guardian",       };

                        string[] fdname = { "Water",                       "LiquidOxygen",                "methanolmonohydratecrystals", "MethaneClathrate",      // icy
                                            "Bromellite",                  "Grandidierite",               "lowtemperaturediamond",       "Opal",
                                            "Alexandrite",                 "Tritium",
                                            "Bauxite",                     "Indite",                      "Alexandrite",                 "Monazite",              "Musgravite","Benitoite", "Serendibite", "Rhodplumsite", // rocky
                                            "Rhodplumsite",                "Serendibite",                 "Platinum",                    "Monazite",              "Painite",                      // metal rich
                                            "Rhodplumsite",                "Serendibite",                 "Platinum",                    "Monazite",              "Painite",                      // metalic
                                            "$SAA_SignalType_Geological;", "$SAA_SignalType_Biological;", "$SAA_SignalType_Thargoid;",   "$SAA_SignalType_Human;","$SAA_SignalType_Guardian;" };

                        grd.GetLineHeader = (row) => { return(row == 1 ? headers2 : row == 0 ? headers1 : null); };
                        grd.GetLineStatus = (row) =>
                        {
                            if (row < saaentries.Count)
                            {
                                for (int rp = row + 1; rp < saaentries.Count; rp++)
                                {
                                    if (saaentries[rp].BodyName == saaentries[row].BodyName && (saaentries[rp].EventTimeUTC - saaentries[row].EventTimeUTC) < new TimeSpan(30, 0, 0, 0))
                                    {
                                        return(CSVWriteGrid.LineStatus.Skip); // if matches one in front, and its less than 30 days from it, ignore
                                    }
                                }

                                return(CSVWriteGrid.LineStatus.OK);
                            }
                            else
                            {
                                return(CSVWriteGrid.LineStatus.EOF);
                            }
                        };

                        grd.GetLine = (r) =>
                        {
                            var    entry   = saaentries[r];
                            string signals = string.Join(",", entry.Signals.Select(x => x.Type_Localised));

                            JournalScan scanof = scanentries.Find(x => x.FindRing(entry.BodyName) != null);

                            bool showrocky = true, showmr = true, showmetalic = true, showicy = true;       // only used if item appears more than once below

                            string ringtype = "", mass = "", innerrad = "", outerrad = "";
                            if (scanof != null)
                            {
                                var ri = scanof.FindRing(entry.BodyName);
                                ringtype = ri.RingClassNormalised();
                                if (ringtype.Contains("metalic", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    showicy = showrocky = showmr = false;
                                }
                                else if (ringtype.Contains("Metal", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    showicy = showrocky = showmetalic = false;
                                }
                                else if (ringtype.Contains("rocky", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    showicy = showmetalic = showmr = false;
                                }
                                else if (ringtype.Contains("icy", StringComparison.InvariantCultureIgnoreCase))
                                {
                                    showrocky = showmetalic = showmr = false;
                                }

                                mass     = ri.MassMT.ToStringInvariant();
                                innerrad = (ri.InnerRad / JournalScan.oneLS_m).ToStringInvariant("N3");
                                outerrad = (ri.OuterRad / JournalScan.oneLS_m).ToStringInvariant("N3");
                            }

                            //string sig = string.Join(",", entry.Signals.Select(x=>x.Type)); // debug

                            return(new object[] { EDDConfig.Instance.ConvertTimeToSelectedFromUTC(entry.EventTimeUTC), entry.BodyName, ringtype,
                                                  mass, innerrad, outerrad,
                                                  entry.ContainsStr(fdname[0]), entry.ContainsStr(fdname[1]), entry.ContainsStr(fdname[2]), entry.ContainsStr(fdname[3]),
                                                  entry.ContainsStr(fdname[4]), entry.ContainsStr(fdname[5]), entry.ContainsStr(fdname[6]), entry.ContainsStr(fdname[7]),
                                                  entry.ContainsStr(fdname[8], showicy), entry.ContainsStr(fdname[9]),

                                                  // "Bauxite","Indite","Alexandrite","Monazite", // rocky
                                                  entry.ContainsStr(fdname[10]), entry.ContainsStr(fdname[11]), entry.ContainsStr(fdname[12], showrocky), entry.ContainsStr(fdname[13], showrocky),
                                                  // "Musgravite","Benitoite","Serendibite","Rhodplumsite",          // rocky
                                                  entry.ContainsStr(fdname[14]), entry.ContainsStr(fdname[15]), entry.ContainsStr(fdname[16], showrocky), entry.ContainsStr(fdname[17], showrocky),

                                                  // "Rhodplumsite","Serendibite","Platinum","Monazite","Painite",   // metal rich
                                                  entry.ContainsStr(fdname[18], showmr), entry.ContainsStr(fdname[19], showmr), entry.ContainsStr(fdname[20], showmr), entry.ContainsStr(fdname[21], showmr), entry.ContainsStr(fdname[22], showmr),

                                                  // "Rhodplumsite","Serendibite","Platinum","Monazite","Painite", // metalic
                                                  entry.ContainsStr(fdname[23], showmetalic), entry.ContainsStr(fdname[24], showmetalic), entry.ContainsStr(fdname[25], showmetalic), entry.ContainsStr(fdname[26], showmetalic), entry.ContainsStr(fdname[27], showmetalic),

                                                  entry.ContainsStr(fdname[28]), entry.ContainsStr(fdname[29]), entry.ContainsStr(fdname[30]), entry.ContainsStr(fdname[31]), entry.ContainsStr(fdname[32]), });
                        };

                        grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                    }
                    else
                    {
                        using (System.IO.StreamWriter writer = new System.IO.StreamWriter(frm.Path))
                        {
                            List <JournalScan> scans = null;

                            if (frm.SelectedIndex < 3)
                            {
                                var entries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC);
                                scans = entries.ConvertAll(x => (JournalScan)x);
                            }
                            else
                            {
                                ExplorationSetClass currentExplorationSet = new ExplorationSetClass();

                                string file = currentExplorationSet.DialogLoad(FindForm());

                                if (file != null)
                                {
                                    scans = new List <JournalScan>();

                                    foreach (string system in currentExplorationSet.Systems)
                                    {
                                        ISystem sys = SystemCache.FindSystem(system);
                                        if (sys != null)
                                        {
                                            var jl = EDSMClass.GetBodiesList(sys);
                                            List <JournalScan> sysscans = jl.Item1;
                                            if (sysscans != null)
                                            {
                                                scans.AddRange(sysscans);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }

                            bool ShowStars        = frm.SelectedIndex < 2 || frm.SelectedIndex == 3;
                            bool ShowPlanets      = frm.SelectedIndex == 0 || frm.SelectedIndex == 2 || frm.SelectedIndex == 4;
                            bool ShowBeltClusters = frm.SelectedIndex == 0;

                            List <JournalSAAScanComplete> mappings = ShowPlanets ?
                                                                     JournalEntry.GetByEventType(JournalTypeEnum.SAAScanComplete, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalSAAScanComplete)x)
                                                        : null;

                            if (frm.IncludeHeader)
                            {
                                // Write header

                                writer.Write(csv.Format("Time"));
                                writer.Write(csv.Format("BodyName"));
                                writer.Write(csv.Format("Estimated Value"));
                                writer.Write(csv.Format("DistanceFromArrivalLS"));
                                writer.Write(csv.Format("WasMapped"));
                                writer.Write(csv.Format("WasDiscovered"));
                                if (ShowStars)
                                {
                                    writer.Write(csv.Format("StarType"));
                                    writer.Write(csv.Format("StellarMass"));
                                    writer.Write(csv.Format("AbsoluteMagnitude"));
                                    writer.Write(csv.Format("Age MY"));
                                    writer.Write(csv.Format("Luminosity"));
                                }
                                writer.Write(csv.Format("Radius"));
                                writer.Write(csv.Format("RotationPeriod"));
                                writer.Write(csv.Format("SurfaceTemperature"));

                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format("TidalLock"));
                                    writer.Write(csv.Format("TerraformState"));
                                    writer.Write(csv.Format("PlanetClass"));
                                    writer.Write(csv.Format("Atmosphere"));
                                    writer.Write(csv.Format("Iron"));
                                    writer.Write(csv.Format("Silicates"));
                                    writer.Write(csv.Format("SulphurDioxide"));
                                    writer.Write(csv.Format("CarbonDioxide"));
                                    writer.Write(csv.Format("Nitrogen"));
                                    writer.Write(csv.Format("Oxygen"));
                                    writer.Write(csv.Format("Water"));
                                    writer.Write(csv.Format("Argon"));
                                    writer.Write(csv.Format("Ammonia"));
                                    writer.Write(csv.Format("Methane"));
                                    writer.Write(csv.Format("Hydrogen"));
                                    writer.Write(csv.Format("Helium"));
                                    writer.Write(csv.Format("Volcanism"));
                                    writer.Write(csv.Format("SurfaceGravity"));
                                    writer.Write(csv.Format("SurfacePressure"));
                                    writer.Write(csv.Format("Landable"));
                                    writer.Write(csv.Format("EarthMasses"));
                                    writer.Write(csv.Format("IcePercent"));
                                    writer.Write(csv.Format("RockPercent"));
                                    writer.Write(csv.Format("MetalPercent"));
                                }
                                // Common orbital param
                                writer.Write(csv.Format("SemiMajorAxis"));
                                writer.Write(csv.Format("Eccentricity"));
                                writer.Write(csv.Format("OrbitalInclination"));
                                writer.Write(csv.Format("Periapsis"));
                                writer.Write(csv.Format("OrbitalPeriod"));
                                writer.Write(csv.Format("AxialTilt"));


                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format("Carbon"));
                                    writer.Write(csv.Format("Iron"));
                                    writer.Write(csv.Format("Nickel"));
                                    writer.Write(csv.Format("Phosphorus"));
                                    writer.Write(csv.Format("Sulphur"));
                                    writer.Write(csv.Format("Arsenic"));
                                    writer.Write(csv.Format("Chromium"));
                                    writer.Write(csv.Format("Germanium"));
                                    writer.Write(csv.Format("Manganese"));
                                    writer.Write(csv.Format("Selenium"));
                                    writer.Write(csv.Format("Vanadium"));
                                    writer.Write(csv.Format("Zinc"));
                                    writer.Write(csv.Format("Zirconium"));
                                    writer.Write(csv.Format("Cadmium"));
                                    writer.Write(csv.Format("Mercury"));
                                    writer.Write(csv.Format("Molybdenum"));
                                    writer.Write(csv.Format("Niobium"));
                                    writer.Write(csv.Format("Tin"));
                                    writer.Write(csv.Format("Tungsten"));
                                    writer.Write(csv.Format("Antimony"));
                                    writer.Write(csv.Format("Polonium"));
                                    writer.Write(csv.Format("Ruthenium"));
                                    writer.Write(csv.Format("Technetium"));
                                    writer.Write(csv.Format("Tellurium"));
                                    writer.Write(csv.Format("Yttrium"));
                                }

                                writer.WriteLine();
                            }

                            foreach (JournalScan je in scans)
                            {
                                JournalScan scan = je as JournalScan;

                                if ((je.IsPlanet && ShowPlanets) || (je.IsStar && ShowStars) || (je.IsBeltCluster && ShowBeltClusters))
                                {
                                    if (je.IsPlanet)
                                    {
                                        var mapping = mappings?.FirstOrDefault(m => m.BodyID == scan.BodyID && m.BodyName == scan.BodyName);

                                        if (mapping != null)
                                        {
                                            scan.SetMapped(true, mapping.ProbesUsed <= mapping.EfficiencyTarget);
                                        }
                                    }

                                    writer.Write(csv.Format(EDDConfig.Instance.ConvertTimeToSelectedFromUTC(scan.EventTimeUTC)));
                                    writer.Write(csv.Format(scan.BodyName));
                                    writer.Write(csv.Format(scan.EstimatedValue));
                                    writer.Write(csv.Format(scan.DistanceFromArrivalLS));
                                    writer.Write(csv.Format(scan.WasMapped));
                                    writer.Write(csv.Format(scan.WasDiscovered));

                                    if (ShowStars)
                                    {
                                        writer.Write(csv.Format(scan.StarType));
                                        writer.Write(csv.Format((scan.nStellarMass.HasValue) ? scan.nStellarMass.Value : 0));
                                        writer.Write(csv.Format((scan.nAbsoluteMagnitude.HasValue) ? scan.nAbsoluteMagnitude.Value : 0));
                                        writer.Write(csv.Format((scan.nAge.HasValue) ? scan.nAge.Value : 0));
                                        writer.Write(csv.Format(scan.Luminosity));
                                    }


                                    writer.Write(csv.Format(scan.nRadius.HasValue ? scan.nRadius.Value : 0));
                                    writer.Write(csv.Format(scan.nRotationPeriod.HasValue ? scan.nRotationPeriod.Value : 0));
                                    writer.Write(csv.Format(scan.nSurfaceTemperature.HasValue ? scan.nSurfaceTemperature.Value : 0));

                                    if (ShowPlanets)
                                    {
                                        writer.Write(csv.Format(scan.nTidalLock.HasValue ? scan.nTidalLock.Value : false));
                                        writer.Write(csv.Format((scan.TerraformState != null) ? scan.TerraformState : ""));
                                        writer.Write(csv.Format((scan.PlanetClass != null) ? scan.PlanetClass : ""));
                                        writer.Write(csv.Format((scan.Atmosphere != null) ? scan.Atmosphere : ""));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Iron")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Silicates")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("SulphurDioxide")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("CarbonDioxide")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Nitrogen")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Oxygen")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Water")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Argon")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Ammonia")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Methane")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Hydrogen")));
                                        writer.Write(csv.Format(scan.GetAtmosphereComponent("Helium")));
                                        writer.Write(csv.Format((scan.Volcanism != null) ? scan.Volcanism : ""));
                                        writer.Write(csv.Format(scan.nSurfaceGravity.HasValue ? scan.nSurfaceGravity.Value : 0));
                                        writer.Write(csv.Format(scan.nSurfacePressure.HasValue ? scan.nSurfacePressure.Value : 0));
                                        writer.Write(csv.Format(scan.nLandable.HasValue ? scan.nLandable.Value : false));
                                        writer.Write(csv.Format((scan.nMassEM.HasValue) ? scan.nMassEM.Value : 0));
                                        writer.Write(csv.Format(scan.GetCompositionPercent("Ice")));
                                        writer.Write(csv.Format(scan.GetCompositionPercent("Rock")));
                                        writer.Write(csv.Format(scan.GetCompositionPercent("Metal")));
                                    }
                                    // Common orbital param
                                    writer.Write(csv.Format(scan.nSemiMajorAxis.HasValue ? scan.nSemiMajorAxis.Value : 0));
                                    writer.Write(csv.Format(scan.nEccentricity.HasValue ? scan.nEccentricity.Value : 0));
                                    writer.Write(csv.Format(scan.nOrbitalInclination.HasValue ? scan.nOrbitalInclination.Value : 0));
                                    writer.Write(csv.Format(scan.nPeriapsis.HasValue ? scan.nPeriapsis.Value : 0));
                                    writer.Write(csv.Format(scan.nOrbitalPeriod.HasValue ? scan.nOrbitalPeriod.Value : 0));
                                    writer.Write(csv.Format(scan.nAxialTilt.HasValue ? scan.nAxialTilt : null));

                                    if (ShowPlanets)
                                    {
                                        writer.Write(csv.Format(scan.GetMaterial("Carbon")));
                                        writer.Write(csv.Format(scan.GetMaterial("Iron")));
                                        writer.Write(csv.Format(scan.GetMaterial("Nickel")));
                                        writer.Write(csv.Format(scan.GetMaterial("Phosphorus")));
                                        writer.Write(csv.Format(scan.GetMaterial("Sulphur")));
                                        writer.Write(csv.Format(scan.GetMaterial("Arsenic")));
                                        writer.Write(csv.Format(scan.GetMaterial("Chromium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Germanium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Manganese")));
                                        writer.Write(csv.Format(scan.GetMaterial("Selenium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Vanadium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Zinc")));
                                        writer.Write(csv.Format(scan.GetMaterial("Zirconium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Cadmium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Mercury")));
                                        writer.Write(csv.Format(scan.GetMaterial("Molybdenum")));
                                        writer.Write(csv.Format(scan.GetMaterial("Niobium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Tin")));
                                        writer.Write(csv.Format(scan.GetMaterial("Tungsten")));
                                        writer.Write(csv.Format(scan.GetMaterial("Antimony")));
                                        writer.Write(csv.Format(scan.GetMaterial("Polonium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Ruthenium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Technetium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Tellurium")));
                                        writer.Write(csv.Format(scan.GetMaterial("Yttrium")));
                                    }
                                    writer.WriteLine();
                                }
                            }

                            writer.Close();
                        }

                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(frm.Path);
                        }
                    }
                }
                catch
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Ejemplo n.º 15
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            if (last_si != null)
            {
                Forms.ExportForm frm = new Forms.ExportForm();
                frm.Init(new string[] { "Export Current View" }, disablestartendtime: true, allowRawJournalExport: false);

                if (frm.ShowDialog(this.FindForm()) == DialogResult.OK)
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);

                    grd.GetPreHeader += delegate(int r)
                    {
                        if (r == 0)
                        {
                            return new Object[] { last_si.ShipUserName ?? "", last_si.ShipUserIdent ?? "", last_si.ShipType ?? "", last_si.ID }
                        }
                        ;
                        else if (r == 1)
                        {
                            return new Object[] { }
                        }
                        ;
                        else
                        {
                            return(null);
                        }
                    };

                    grd.GetHeader += delegate(int c)
                    {
                        return((frm.IncludeHeader && c < dataGridViewModules.ColumnCount) ? dataGridViewModules.Columns[c].HeaderText : null);
                    };

                    grd.GetLine += delegate(int r)
                    {
                        if (r < dataGridViewModules.RowCount)
                        {
                            DataGridViewRow rw = dataGridViewModules.Rows[r];
                            return(new Object[] { rw.Cells[0].Value, rw.Cells[1].Value, rw.Cells[2].Value, rw.Cells[3].Value, rw.Cells[4].Value, rw.Cells[5].Value, rw.Cells[6].Value, rw.Cells[7].Value });
                        }
                        else
                        {
                            return(null);
                        }
                    };

                    var x = discoveryform.history.shipinformationlist.Ships.GetEnumerator();
                    x.MoveNext();

                    grd.GetPostHeader += delegate(int r)
                    {
                        if (r == 0)
                        {
                            return new Object[] { }
                        }
                        ;
                        else if (r == 1)
                        {
                            return new Object[] { "Ships:" }
                        }
                        ;

                        while (x.MoveNext())
                        {
                            if (x.Current.Value.State == ShipInformation.ShipState.Owned)
                            {
                                return new Object[] { x.Current.Value.ShipFullInfo() }
                            }
                            ;
                        }

                        return(null);
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
            }
            else
            {
                ExtendedControls.MessageBoxTheme.Show(this.FindForm(), "No Ship Information available".T(EDTx.UserControlModules_NOSI), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
Ejemplo n.º 16
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "All", "Stars only",
                                    "Planets only",             //2
                                    "Exploration List Stars",   //3
                                    "Exploration List Planets", //4
                                    "Sold Exploration Data",    // 5
                     });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                BaseUtils.CSVWrite csv = new BaseUtils.CSVWrite();
                csv.SetCSVDelimiter(frm.Comma);

                try
                {
                    using (System.IO.StreamWriter writer = new System.IO.StreamWriter(frm.Path))
                    {
                        if (frm.SelectedIndex == 5)
                        {
                            int count;
                            List <HistoryEntry> data = HistoryList.FilterByJournalEvent(discoveryform.history.ToList(), "Sell Exploration Data", out count);
                            data = (from he in data where he.EventTimeLocal >= frm.StartTime && he.EventTimeLocal <= frm.EndTime orderby he.EventTimeUTC descending select he).ToList();

                            List <HistoryEntry> scans = HistoryList.FilterByJournalEvent(discoveryform.history.ToList(), "Scan", out count);

                            if (frm.IncludeHeader)
                            {
                                writer.Write(csv.Format("Time"));
                                writer.Write(csv.Format("System"));
                                writer.Write(csv.Format("Star type"));
                                writer.Write(csv.Format("Planet type", false));
                                writer.WriteLine();
                            }

                            foreach (HistoryEntry he in data)
                            {
                                JournalSellExplorationData jsed = he.journalEntry as JournalSellExplorationData;
                                if (jsed == null || jsed.Discovered == null)
                                {
                                    continue;
                                }
                                foreach (String system in jsed.Discovered)
                                {
                                    writer.Write(csv.Format(jsed.EventTimeLocal));
                                    writer.Write(csv.Format(system));

                                    EDStar   star   = EDStar.Unknown;
                                    EDPlanet planet = EDPlanet.Unknown_Body_Type;

                                    foreach (HistoryEntry scanhe in scans)
                                    {
                                        JournalScan scan = scanhe.journalEntry as JournalScan;
                                        if (scan.BodyName.Equals(system, StringComparison.OrdinalIgnoreCase))
                                        {
                                            star   = scan.StarTypeID;
                                            planet = scan.PlanetTypeID;
                                            break;
                                        }
                                    }
                                    writer.Write(csv.Format((star != EDStar.Unknown) ? Enum.GetName(typeof(EDStar), star) : ""));
                                    writer.Write(csv.Format((planet != EDPlanet.Unknown_Body_Type) ? Enum.GetName(typeof(EDPlanet), planet) : "", false));
                                    writer.WriteLine();
                                }
                            }
                        }
                        else
                        {
                            List <JournalScan> scans = null;

                            if (frm.SelectedIndex < 3)
                            {
                                var entries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTime, frm.EndTime);
                                scans = entries.ConvertAll(x => (JournalScan)x);
                            }
                            else
                            {
                                ExplorationSetClass currentExplorationSet = new ExplorationSetClass();

                                string file = currentExplorationSet.DialogLoad(FindForm());

                                if (file != null)
                                {
                                    scans = new List <JournalScan>();

                                    foreach (string system in currentExplorationSet.Systems)
                                    {
                                        ISystem sys = SystemCache.FindSystem(system);
                                        if (sys != null)
                                        {
                                            List <JournalScan> sysscans = EDSMClass.GetBodiesList(sys.EDSMID);
                                            if (sysscans != null)
                                            {
                                                scans.AddRange(sysscans);
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    return;
                                }
                            }

                            bool ShowStars   = frm.SelectedIndex < 2 || frm.SelectedIndex == 3;
                            bool ShowPlanets = frm.SelectedIndex == 0 || frm.SelectedIndex == 2 || frm.SelectedIndex == 4;

                            List <JournalSAAScanComplete> mappings = ShowPlanets ?
                                                                     JournalEntry.GetByEventType(JournalTypeEnum.SAAScanComplete, EDCommander.CurrentCmdrID, frm.StartTime, frm.EndTime)
                                                                     .ConvertAll(x => (JournalSAAScanComplete)x)
                                : null;

                            if (frm.IncludeHeader)
                            {
                                // Write header

                                writer.Write(csv.Format("Time"));
                                writer.Write(csv.Format("BodyName"));
                                writer.Write(csv.Format("Estimated Value"));
                                writer.Write(csv.Format("DistanceFromArrivalLS"));
                                writer.Write(csv.Format("WasMapped"));
                                writer.Write(csv.Format("WasDiscovered"));
                                if (ShowStars)
                                {
                                    writer.Write(csv.Format("StarType"));
                                    writer.Write(csv.Format("StellarMass"));
                                    writer.Write(csv.Format("AbsoluteMagnitude"));
                                    writer.Write(csv.Format("Age MY"));
                                    writer.Write(csv.Format("Luminosity"));
                                }
                                writer.Write(csv.Format("Radius"));
                                writer.Write(csv.Format("RotationPeriod"));
                                writer.Write(csv.Format("SurfaceTemperature"));

                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format("TidalLock"));
                                    writer.Write(csv.Format("TerraformState"));
                                    writer.Write(csv.Format("PlanetClass"));
                                    writer.Write(csv.Format("Atmosphere"));
                                    writer.Write(csv.Format("Iron"));
                                    writer.Write(csv.Format("Silicates"));
                                    writer.Write(csv.Format("SulphurDioxide"));
                                    writer.Write(csv.Format("CarbonDioxide"));
                                    writer.Write(csv.Format("Nitrogen"));
                                    writer.Write(csv.Format("Oxygen"));
                                    writer.Write(csv.Format("Water"));
                                    writer.Write(csv.Format("Argon"));
                                    writer.Write(csv.Format("Ammonia"));
                                    writer.Write(csv.Format("Methane"));
                                    writer.Write(csv.Format("Hydrogen"));
                                    writer.Write(csv.Format("Helium"));
                                    writer.Write(csv.Format("Volcanism"));
                                    writer.Write(csv.Format("SurfaceGravity"));
                                    writer.Write(csv.Format("SurfacePressure"));
                                    writer.Write(csv.Format("Landable"));
                                    writer.Write(csv.Format("EarthMasses"));
                                    writer.Write(csv.Format("IcePercent"));
                                    writer.Write(csv.Format("RockPercent"));
                                    writer.Write(csv.Format("MetalPercent"));
                                }
                                // Common orbital param
                                writer.Write(csv.Format("SemiMajorAxis"));
                                writer.Write(csv.Format("Eccentricity"));
                                writer.Write(csv.Format("OrbitalInclination"));
                                writer.Write(csv.Format("Periapsis"));
                                writer.Write(csv.Format("OrbitalPeriod"));
                                writer.Write(csv.Format("AxialTilt"));


                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format("Carbon"));
                                    writer.Write(csv.Format("Iron"));
                                    writer.Write(csv.Format("Nickel"));
                                    writer.Write(csv.Format("Phosphorus"));
                                    writer.Write(csv.Format("Sulphur"));
                                    writer.Write(csv.Format("Arsenic"));
                                    writer.Write(csv.Format("Chromium"));
                                    writer.Write(csv.Format("Germanium"));
                                    writer.Write(csv.Format("Manganese"));
                                    writer.Write(csv.Format("Selenium"));
                                    writer.Write(csv.Format("Vanadium"));
                                    writer.Write(csv.Format("Zinc"));
                                    writer.Write(csv.Format("Zirconium"));
                                    writer.Write(csv.Format("Cadmium"));
                                    writer.Write(csv.Format("Mercury"));
                                    writer.Write(csv.Format("Molybdenum"));
                                    writer.Write(csv.Format("Niobium"));
                                    writer.Write(csv.Format("Tin"));
                                    writer.Write(csv.Format("Tungsten"));
                                    writer.Write(csv.Format("Antimony"));
                                    writer.Write(csv.Format("Polonium"));
                                    writer.Write(csv.Format("Ruthenium"));
                                    writer.Write(csv.Format("Technetium"));
                                    writer.Write(csv.Format("Tellurium"));
                                    writer.Write(csv.Format("Yttrium"));
                                }

                                writer.WriteLine();
                            }

                            foreach (JournalScan je in scans)
                            {
                                JournalScan scan = je as JournalScan;

                                if (ShowPlanets == true && !string.IsNullOrEmpty(scan.PlanetClass))
                                {
                                    var mapping = mappings?.FirstOrDefault(m => m.BodyID == scan.BodyID);

                                    if (mapping != null)
                                    {
                                        scan.SetMapped(true, mapping.ProbesUsed <= mapping.EfficiencyTarget);
                                    }
                                }

                                if (ShowPlanets == false)  // Then only show stars.
                                {
                                    if (String.IsNullOrEmpty(scan.StarType))
                                    {
                                        continue;
                                    }
                                }

                                if (ShowStars == false)   // Then only show planets
                                {
                                    if (String.IsNullOrEmpty(scan.PlanetClass))
                                    {
                                        continue;
                                    }
                                }

                                writer.Write(csv.Format(scan.EventTimeUTC));
                                writer.Write(csv.Format(scan.BodyName));
                                writer.Write(csv.Format(scan.EstimatedValue));
                                writer.Write(csv.Format(scan.DistanceFromArrivalLS));
                                writer.Write(csv.Format(scan.WasMapped));
                                writer.Write(csv.Format(scan.WasDiscovered));

                                if (ShowStars)
                                {
                                    writer.Write(csv.Format(scan.StarType));
                                    writer.Write(csv.Format((scan.nStellarMass.HasValue) ? scan.nStellarMass.Value : 0));
                                    writer.Write(csv.Format((scan.nAbsoluteMagnitude.HasValue) ? scan.nAbsoluteMagnitude.Value : 0));
                                    writer.Write(csv.Format((scan.nAge.HasValue) ? scan.nAge.Value : 0));
                                    writer.Write(csv.Format(scan.Luminosity));
                                }


                                writer.Write(csv.Format(scan.nRadius.HasValue ? scan.nRadius.Value : 0));
                                writer.Write(csv.Format(scan.nRotationPeriod.HasValue ? scan.nRotationPeriod.Value : 0));
                                writer.Write(csv.Format(scan.nSurfaceTemperature.HasValue ? scan.nSurfaceTemperature.Value : 0));

                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format(scan.nTidalLock.HasValue ? scan.nTidalLock.Value : false));
                                    writer.Write(csv.Format((scan.TerraformState != null) ? scan.TerraformState : ""));
                                    writer.Write(csv.Format((scan.PlanetClass != null) ? scan.PlanetClass : ""));
                                    writer.Write(csv.Format((scan.Atmosphere != null) ? scan.Atmosphere : ""));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Iron")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Silicates")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("SulphurDioxide")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("CarbonDioxide")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Nitrogen")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Oxygen")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Water")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Argon")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Ammonia")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Methane")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Hydrogen")));
                                    writer.Write(csv.Format(scan.GetAtmosphereComponent("Helium")));
                                    writer.Write(csv.Format((scan.Volcanism != null) ? scan.Volcanism : ""));
                                    writer.Write(csv.Format(scan.nSurfaceGravity.HasValue ? scan.nSurfaceGravity.Value : 0));
                                    writer.Write(csv.Format(scan.nSurfacePressure.HasValue ? scan.nSurfacePressure.Value : 0));
                                    writer.Write(csv.Format(scan.nLandable.HasValue ? scan.nLandable.Value : false));
                                    writer.Write(csv.Format((scan.nMassEM.HasValue) ? scan.nMassEM.Value : 0));
                                    writer.Write(csv.Format(scan.GetCompositionPercent("Ice")));
                                    writer.Write(csv.Format(scan.GetCompositionPercent("Rock")));
                                    writer.Write(csv.Format(scan.GetCompositionPercent("Metal")));
                                }
                                // Common orbital param
                                writer.Write(csv.Format(scan.nSemiMajorAxis.HasValue ? scan.nSemiMajorAxis.Value : 0));
                                writer.Write(csv.Format(scan.nEccentricity.HasValue ? scan.nEccentricity.Value : 0));
                                writer.Write(csv.Format(scan.nOrbitalInclination.HasValue ? scan.nOrbitalInclination.Value : 0));
                                writer.Write(csv.Format(scan.nPeriapsis.HasValue ? scan.nPeriapsis.Value : 0));
                                writer.Write(csv.Format(scan.nOrbitalPeriod.HasValue ? scan.nOrbitalPeriod.Value : 0));
                                writer.Write(csv.Format(scan.nAxialTilt.HasValue ? scan.nAxialTilt : null));

                                if (ShowPlanets)
                                {
                                    writer.Write(csv.Format(scan.GetMaterial("Carbon")));
                                    writer.Write(csv.Format(scan.GetMaterial("Iron")));
                                    writer.Write(csv.Format(scan.GetMaterial("Nickel")));
                                    writer.Write(csv.Format(scan.GetMaterial("Phosphorus")));
                                    writer.Write(csv.Format(scan.GetMaterial("Sulphur")));
                                    writer.Write(csv.Format(scan.GetMaterial("Arsenic")));
                                    writer.Write(csv.Format(scan.GetMaterial("Chromium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Germanium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Manganese")));
                                    writer.Write(csv.Format(scan.GetMaterial("Selenium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Vanadium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Zinc")));
                                    writer.Write(csv.Format(scan.GetMaterial("Zirconium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Cadmium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Mercury")));
                                    writer.Write(csv.Format(scan.GetMaterial("Molybdenum")));
                                    writer.Write(csv.Format(scan.GetMaterial("Niobium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Tin")));
                                    writer.Write(csv.Format(scan.GetMaterial("Tungsten")));
                                    writer.Write(csv.Format(scan.GetMaterial("Antimony")));
                                    writer.Write(csv.Format(scan.GetMaterial("Polonium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Ruthenium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Technetium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Tellurium")));
                                    writer.Write(csv.Format(scan.GetMaterial("Yttrium")));
                                }
                                writer.WriteLine();
                            }
                        }

                        writer.Close();

                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(frm.Path);
                        }
                    }
                }
                catch
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Ejemplo n.º 17
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View" });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)
                {
                    // 0        1       2           3            4               5           6           7             8              9              10              11              12
                    string[] colh = { "Time", "System", "Visits", "Other Info", "Scan Value", "Unused", "Body", "Ship", "Description", "Detailed Info", "Travel Dist", "Travel Time", "Travel Jumps", "Travelled MisJumps" };

                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);
                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < dataGridViewStarList.Rows.Count)
                        {
                            HistoryEntry he = dataGridViewStarList.Rows[r].Tag as HistoryEntry;

                            return((dataGridViewStarList.Rows[r].Visible &&
                                    he.EventTimeUTC.CompareTo(frm.StartTimeUTC) >= 0 &&
                                    he.EventTimeUTC.CompareTo(frm.EndTimeUTC) <= 0) ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.Skip);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    grd.GetLine += delegate(int r)
                    {
                        HistoryEntry    he = dataGridViewStarList.Rows[r].Tag as HistoryEntry;
                        DataGridViewRow rw = dataGridViewStarList.Rows[r];

                        he.journalEntry.FillInformation(out string EventDescription, out string EventDetailedInfo);

                        return(new Object[] {
                            rw.Cells[0].Value,
                            rw.Cells[1].Value,
                            rw.Cells[2].Value,
                            rw.Cells[3].Value,
                            rw.Cells[4].Value,
                            "",
                            he.WhereAmI,
                            he.ShipInformation != null ? he.ShipInformation.Name : "Unknown",
                            EventDescription,
                            EventDetailedInfo,
                            he.isTravelling ? he.TravelledDistance.ToString("0.0") : "",
                            he.isTravelling ? he.TravelledSeconds.ToString() : "",
                            he.isTravelling ? he.Travelledjumps.ToString() : "",
                            he.isTravelling ? he.TravelledMissingjump.ToString() : "",
                        });
                    };

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < colh.Length && frm.IncludeHeader) ? colh[c] : null);
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
            }
        }
Ejemplo n.º 18
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View" });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)
                {
                    // 0        1       2           3            4               5           6           7             8              9              10              11              12
                    string[] colh = { "Time", "System", "Visits", "Other Info", "Visit List", "Body", "Ship", "Description", "Detailed Info", "Travel Dist", "Travel Time", "Travel Jumps", "Travelled MisJumps" };

                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);
                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < dataGridViewStarList.Rows.Count)
                        {
                            List <HistoryEntry> syslist = dataGridViewStarList.Rows[r].Tag as List <HistoryEntry>;
                            HistoryEntry        he      = syslist[0];

                            return((dataGridViewStarList.Rows[r].Visible &&
                                    he.EventTimeLocal.CompareTo(frm.StartTime) >= 0 &&
                                    he.EventTimeLocal.CompareTo(frm.EndTime) <= 0) ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.Skip);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };
                    grd.GetLine += delegate(int r)
                    {
                        List <HistoryEntry> syslist = dataGridViewStarList.Rows[r].Tag as List <HistoryEntry>;
                        HistoryEntry        he      = syslist[0];
                        DataGridViewRow     rw      = dataGridViewStarList.Rows[r];

                        string tlist = "";
                        if (syslist.Count > 1)
                        {
                            for (int i = 1; i < syslist.Count; i++)
                            {
                                tlist = tlist.AppendPrePad(syslist[i].EventTimeLocal.ToShortDateString() + " " + syslist[i].EventTimeLocal.ToShortTimeString(), ", ");
                            }
                        }

                        he.journalEntry.FillInformation(out string EventDescription, out string EventDetailedInfo);

                        return(new Object[] {
                            rw.Cells[0].Value,
                            rw.Cells[1].Value,
                            rw.Cells[2].Value,
                            rw.Cells[3].Value,
                            tlist,
                            he.WhereAmI,
                            he.ShipInformation != null ? he.ShipInformation.Name : "Unknown",
                            EventDescription,
                            EventDetailedInfo,
                            he.isTravelling ? he.TravelledDistance.ToString("0.0") : "",
                            he.isTravelling ? he.TravelledSeconds.ToString() : "",
                            he.isTravelling ? he.Travelledjumps.ToStringInvariant() : "",
                            he.isTravelling ? he.TravelledMissingjump.ToStringInvariant() : "",
                        });
                    };

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < colh.Length && frm.IncludeHeader) ? colh[c] : null);
                    };

                    if (grd.WriteCSV(frm.Path))
                    {
                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(frm.Path);
                        }
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "View", "FSD Jumps only", "With Notes only", "With Notes, no repeat" });

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                grd.SetCSVDelimiter(frm.Comma);

                List <SystemNoteClass> sysnotecache = new List <SystemNoteClass>();
                string[] colh = null;

                grd.GetLineStatus += delegate(int r)
                {
                    if (r < dataGridViewTravel.Rows.Count)
                    {
                        HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Cells[TravelHistoryColumns.HistoryTag].Tag;
                        return((dataGridViewTravel.Rows[r].Visible &&
                                he.EventTimeLocal.CompareTo(frm.StartTime) >= 0 &&
                                he.EventTimeLocal.CompareTo(frm.EndTime) <= 0) ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.Skip);
                    }
                    else
                    {
                        return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                    }
                };

                if (frm.SelectedIndex == 1)     // export fsd jumps
                {
                    colh = new string[] { "Time", "Name", "X", "Y", "Z", "Distance", "Fuel Used", "Fuel Left", "Boost", "Note" };

                    grd.VerifyLine += delegate(int r)       // addition qualifier for FSD jump
                    {
                        HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Cells[TravelHistoryColumns.HistoryTag].Tag;
                        return(he.EntryType == JournalTypeEnum.FSDJump);
                    };

                    grd.GetLine += delegate(int r)
                    {
                        HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Cells[TravelHistoryColumns.HistoryTag].Tag;
                        EliteDangerousCore.JournalEvents.JournalFSDJump fsd = he.journalEntry as EliteDangerousCore.JournalEvents.JournalFSDJump;

                        return(new Object[] {
                            fsd.EventTimeLocal,
                            fsd.StarSystem,
                            fsd.StarPos.X,
                            fsd.StarPos.Y,
                            fsd.StarPos.Z,
                            fsd.JumpDist,
                            fsd.FuelUsed,
                            fsd.FuelLevel,
                            fsd.BoostUsed,
                            he.snc != null ? he.snc.Note : "",
                        });
                    };
                }
                else
                {
                    colh = new string[] { "Time", "Event", "System", "Body",                    //0
                                          "Ship", "Summary", "Description", "Detailed Info",    //4
                                          "Note", "Travel Dist", "Travel Time", "Travel Jumps", //8
                                          "Travelled MisJumps", "X", "Y", "Z",                  //12
                                          "JID", "EDSMID", "EDDBID" };                          //16

                    grd.GetLine += delegate(int r)
                    {
                        HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Cells[TravelHistoryColumns.HistoryTag].Tag;
                        return(new Object[] {
                            dataGridViewTravel.Rows[r].Cells[0].Value,
                            he.journalEntry.EventTypeStr,
                            (he.System != null) ? he.System.name : "Unknown",    // paranoia
                            he.WhereAmI,
                            he.ShipInformation != null ? he.ShipInformation.Name : "Unknown",
                            he.EventSummary,
                            he.EventDescription,
                            he.EventDetailedInfo,
                            dataGridViewTravel.Rows[r].Cells[4].Value,
                            he.isTravelling ? he.TravelledDistance.ToString("0.0") : "",
                            he.isTravelling ? he.TravelledSeconds.ToString() : "",
                            he.isTravelling ? he.Travelledjumps.ToStringInvariant() : "",
                            he.isTravelling ? he.TravelledMissingjump.ToStringInvariant() : "",
                            he.System.x,
                            he.System.y,
                            he.System.z,
                            he.Journalid,
                            he.System.id_edsm,
                            he.System.id_eddb,
                        });
                    };

                    if (frm.SelectedIndex == 2 || frm.SelectedIndex == 3) // export notes
                    {
                        grd.VerifyLine += delegate(int r)                 // second hook to reject line
                        {
                            HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Cells[TravelHistoryColumns.HistoryTag].Tag;
                            if (he.snc != null)
                            {
                                if (sysnotecache.Contains(he.snc))
                                {
                                    return(false);
                                }
                                else
                                {
                                    if (frm.SelectedIndex == 3)
                                    {
                                        sysnotecache.Add(he.snc);
                                    }
                                    return(true);
                                }
                            }
                            else
                            {
                                return(false);
                            }
                        };
                    }
                }

                grd.GetHeader += delegate(int c)
                {
                    return((c < colh.Length && frm.IncludeHeader) ? colh[c] : null);
                };

                if (grd.WriteCSV(frm.Path))
                {
                    if (frm.AutoOpen)
                    {
                        System.Diagnostics.Process.Start(frm.Path);
                    }
                }
                else
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Ejemplo n.º 20
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(false, new string[] { "View", "FSD Jumps only", "With Notes only", "With Notes, no repeat",       //0-3
                                           "Scans All Bodies", "Scans Planets", "Scans Stars", "Scans Rings" },        //4-7
                     suggestedfilenames: new string[] { "TravelGrid", "FSDJumps", "TravelGrid", "TravelGrid", "Scans", "ScanPlanet", "ScanStars", "ScanRings" }
                     );

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 7)
                {
                    var saaentries  = JournalEntry.GetByEventType(JournalTypeEnum.SAASignalsFound, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalSAASignalsFound)x);
                    var scanentries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalScan)x);

                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);

                    string[] headers1 = { "",           "", "", "", "", "",
                                          "Icy Ring",   "", "", "", "", "","",  "", "", "",
                                          "Rocky",      "", "", "", "", "","",  "",
                                          "Metal Rich", "", "", "", "",
                                          "Metalic",    "", "", "", "",
                                          "Other" };

                    string[] headers2 = { "Time",         "BodyName",      "Ring Types",    "Mass MT",  "Inner Rad (ls)", "Outer Rad (ls)",

                                          // icy ring
                                          "Water",        "Liquid Oxygen", "Methanol Mono", "Methane",  "Bromellite",     "Grandidierite", "Low Temp Diamonds","Void Opals",   "Alexandrite", "Tritium",
                                          // rocky
                                          "Bauxite",      "Indite",        "Alexandrite",   "Monazite", "Musgravite",     "Benitoite",     "Serendibite",   "Rhodplumsite",
                                          // metal rich
                                          "Rhodplumsite", "Serendibite",   "Platinum",      "Monazite", "Painite",
                                          // metalic
                                          "Rhodplumsite", "Serendibite",   "Platinum",      "Monazite", "Painite",
                                          // others
                                          "Geological",   "Biological",    "Thargoid",      "Human",    "Guardian",       };

                    string[] fdname = { "Water",                       "LiquidOxygen",                "methanolmonohydratecrystals", "MethaneClathrate",      // icy
                                        "Bromellite",                  "Grandidierite",               "lowtemperaturediamond",       "Opal",
                                        "Alexandrite",                 "Tritium",
                                        "Bauxite",                     "Indite",                      "Alexandrite",                 "Monazite",              "Musgravite","Benitoite", "Serendibite", "Rhodplumsite", // rocky
                                        "Rhodplumsite",                "Serendibite",                 "Platinum",                    "Monazite",              "Painite",                      // metal rich
                                        "Rhodplumsite",                "Serendibite",                 "Platinum",                    "Monazite",              "Painite",                      // metalic
                                        "$SAA_SignalType_Geological;", "$SAA_SignalType_Biological;", "$SAA_SignalType_Thargoid;",   "$SAA_SignalType_Human;","$SAA_SignalType_Guardian;" };

                    grd.GetLineHeader = (row) => { return(row == 1 ? headers2 : row == 0 ? headers1 : null); };
                    grd.GetLineStatus = (row) =>
                    {
                        if (row < saaentries.Count)
                        {
                            for (int rp = row + 1; rp < saaentries.Count; rp++)
                            {
                                if (saaentries[rp].BodyName == saaentries[row].BodyName && (saaentries[rp].EventTimeUTC - saaentries[row].EventTimeUTC) < new TimeSpan(30, 0, 0, 0))
                                {
                                    return(BaseUtils.CSVWriteGrid.LineStatus.Skip); // if matches one in front, and its less than 30 days from it, ignore
                                }
                            }

                            return(BaseUtils.CSVWriteGrid.LineStatus.OK);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    grd.GetLine = (r) =>
                    {
                        var    entry   = saaentries[r];
                        string signals = string.Join(",", entry.Signals.Select(x => x.Type_Localised));

                        JournalScan scanof = scanentries.Find(x => x.FindRing(entry.BodyName) != null);

                        bool showrocky = true, showmr = true, showmetalic = true, showicy = true;       // only used if item appears more than once below

                        string ringtype = "", mass = "", innerrad = "", outerrad = "";
                        if (scanof != null)
                        {
                            var ri = scanof.FindRing(entry.BodyName);
                            ringtype = ri.RingClassNormalised();
                            if (ringtype.Contains("metalic", StringComparison.InvariantCultureIgnoreCase))
                            {
                                showicy = showrocky = showmr = false;
                            }
                            else if (ringtype.Contains("Metal", StringComparison.InvariantCultureIgnoreCase))
                            {
                                showicy = showrocky = showmetalic = false;
                            }
                            else if (ringtype.Contains("rocky", StringComparison.InvariantCultureIgnoreCase))
                            {
                                showicy = showmetalic = showmr = false;
                            }
                            else if (ringtype.Contains("icy", StringComparison.InvariantCultureIgnoreCase))
                            {
                                showrocky = showmetalic = showmr = false;
                            }

                            mass     = ri.MassMT.ToStringInvariant();
                            innerrad = (ri.InnerRad / JournalScan.oneLS_m).ToStringInvariant("N3");
                            outerrad = (ri.OuterRad / JournalScan.oneLS_m).ToStringInvariant("N3");
                        }

                        //string sig = string.Join(",", entry.Signals.Select(x=>x.Type)); // debug

                        return(new object[] { EDDConfig.Instance.ConvertTimeToSelectedFromUTC(entry.EventTimeUTC), entry.BodyName, ringtype,
                                              mass, innerrad, outerrad,
                                              entry.ContainsStr(fdname[0]), entry.ContainsStr(fdname[1]), entry.ContainsStr(fdname[2]), entry.ContainsStr(fdname[3]),
                                              entry.ContainsStr(fdname[4]), entry.ContainsStr(fdname[5]), entry.ContainsStr(fdname[6]), entry.ContainsStr(fdname[7]),
                                              entry.ContainsStr(fdname[8], showicy), entry.ContainsStr(fdname[9]),

                                              // "Bauxite","Indite","Alexandrite","Monazite", // rocky
                                              entry.ContainsStr(fdname[10]), entry.ContainsStr(fdname[11]), entry.ContainsStr(fdname[12], showrocky), entry.ContainsStr(fdname[13], showrocky),
                                              // "Musgravite","Benitoite","Serendibite","Rhodplumsite",          // rocky
                                              entry.ContainsStr(fdname[14]), entry.ContainsStr(fdname[15]), entry.ContainsStr(fdname[16], showrocky), entry.ContainsStr(fdname[17], showrocky),

                                              // "Rhodplumsite","Serendibite","Platinum","Monazite","Painite",   // metal rich
                                              entry.ContainsStr(fdname[18], showmr), entry.ContainsStr(fdname[19], showmr), entry.ContainsStr(fdname[20], showmr), entry.ContainsStr(fdname[21], showmr), entry.ContainsStr(fdname[22], showmr),

                                              // "Rhodplumsite","Serendibite","Platinum","Monazite","Painite", // metalic
                                              entry.ContainsStr(fdname[23], showmetalic), entry.ContainsStr(fdname[24], showmetalic), entry.ContainsStr(fdname[25], showmetalic), entry.ContainsStr(fdname[26], showmetalic), entry.ContainsStr(fdname[27], showmetalic),

                                              entry.ContainsStr(fdname[28]), entry.ContainsStr(fdname[29]), entry.ContainsStr(fdname[30]), entry.ContainsStr(fdname[31]), entry.ContainsStr(fdname[32]), });
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
                else if (frm.SelectedIndex >= 4)
                {
                    var entries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC);
                    var scans   = entries.ConvertAll(x => (JournalScan)x);

                    bool ShowStars        = frm.SelectedIndex == 4 || frm.SelectedIndex == 6;
                    bool ShowPlanets      = frm.SelectedIndex == 4 || frm.SelectedIndex == 5;
                    bool ShowBeltClusters = frm.SelectedIndex == 4;

                    if (ShowPlanets)
                    {
                        // because they come from the DB, they don't have the mapped/efficient mapped flags set. So we need to set them
                        List <JournalSAAScanComplete> mappings = JournalEntry.GetByEventType(JournalTypeEnum.SAAScanComplete, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalSAAScanComplete)x);

                        foreach (var m in mappings)
                        {
                            var scan = scans.Find(x => x.BodyID == m.BodyID && x.BodyName == m.BodyName);
                            if (scan != null)
                            {
                                //System.Diagnostics.Debug.WriteLine($"Set mapping {scan.BodyName}");
                                scan.SetMapped(true, m.ProbesUsed <= m.EfficiencyTarget);
                            }
                        }
                    }

                    if (!CSVHelpers.OutputScanCSV(scans, frm.Path, frm.Comma, frm.IncludeHeader, ShowStars, ShowPlanets, ShowPlanets, ShowBeltClusters))
                    {
                        throw new Exception();      // throw to get to scan excel error
                    }
                    if (frm.AutoOpen)
                    {
                        System.Diagnostics.Process.Start(frm.Path);
                    }
                }
                else
                {
                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);

                    List <SystemNoteClass> sysnotecache = new List <SystemNoteClass>();
                    string[] colh = null;

                    grd.GetLineStatus += delegate(int r)
                    {
                        if (r < dataGridViewTravel.Rows.Count)
                        {
                            HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Tag;
                            return((dataGridViewTravel.Rows[r].Visible &&
                                    he.EventTimeUTC.CompareTo(frm.StartTimeUTC) >= 0 &&
                                    he.EventTimeUTC.CompareTo(frm.EndTimeUTC) <= 0) ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.Skip);
                        }
                        else
                        {
                            return(BaseUtils.CSVWriteGrid.LineStatus.EOF);
                        }
                    };

                    if (frm.SelectedIndex == 1)     // export fsd jumps
                    {
                        colh = new string[] { "Time", "Name", "X", "Y", "Z", "Distance", "Fuel Used", "Fuel Left", "Boost", "Note" };

                        grd.VerifyLine += delegate(int r)       // addition qualifier for FSD jump
                        {
                            HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Tag;
                            return(he.EntryType == JournalTypeEnum.FSDJump);
                        };

                        grd.GetLine += delegate(int r)
                        {
                            HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Tag;
                            EliteDangerousCore.JournalEvents.JournalFSDJump fsd = he.journalEntry as EliteDangerousCore.JournalEvents.JournalFSDJump;

                            return(new Object[] {
                                EDDConfig.Instance.ConvertTimeToSelectedFromUTC(fsd.EventTimeUTC),
                                fsd.StarSystem,
                                fsd.StarPos.X,
                                fsd.StarPos.Y,
                                fsd.StarPos.Z,
                                fsd.JumpDist,
                                fsd.FuelUsed,
                                fsd.FuelLevel,
                                fsd.BoostUsed,
                                he.SNC != null ? he.SNC.Note : "",
                            });
                        };
                    }
                    else
                    {
                        colh = new string[] { "Time", "Event", "System", "Body",                    //0
                                              "Ship", "Summary", "Description", "Detailed Info",    //4
                                              "Note", "Travel Dist", "Travel Time", "Travel Jumps", //8
                                              "Travelled MisJumps", "X", "Y", "Z",                  //12
                                              "JID", "EDSMID" };                                    //16

                        grd.GetLine += delegate(int r)
                        {
                            HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Tag;
                            he.FillInformation(out string EventDescription, out string EventDetailedInfo);
                            return(new Object[] {
                                EDDConfig.Instance.ConvertTimeToSelectedFromUTC(he.EventTimeUTC),
                                he.EventSummary,
                                (he.System != null) ? he.System.Name : "Unknown",    // paranoia
                                he.WhereAmI,
                                he.ShipInformation != null ? he.ShipInformation.Name : "Unknown",
                                he.EventSummary,
                                EventDescription,
                                EventDetailedInfo,
                                dataGridViewTravel.Rows[r].Cells[4].Value,
                                he.isTravelling ? he.TravelledDistance.ToString("0.0") : "",
                                he.isTravelling ? he.TravelledSeconds.ToString() : "",
                                he.isTravelling ? he.Travelledjumps.ToString() : "",
                                he.isTravelling ? he.TravelledMissingjump.ToString() : "",
                                he.System.X,
                                he.System.Y,
                                he.System.Z,
                                he.Journalid,
                                he.System.EDSMID,
                            });
                        };

                        if (frm.SelectedIndex == 2 || frm.SelectedIndex == 3) // export notes
                        {
                            grd.VerifyLine += delegate(int r)                 // second hook to reject line
                            {
                                HistoryEntry he = (HistoryEntry)dataGridViewTravel.Rows[r].Tag;
                                if (he.SNC != null)
                                {
                                    if (sysnotecache.Contains(he.SNC))
                                    {
                                        return(false);
                                    }
                                    else
                                    {
                                        if (frm.SelectedIndex == 3)
                                        {
                                            sysnotecache.Add(he.SNC);
                                        }
                                        return(true);
                                    }
                                }
                                else
                                {
                                    return(false);
                                }
                            };
                        }
                    }

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < colh.Length && frm.IncludeHeader) ? colh[c] : null);
                    };

                    grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm());
                }
            }
        }