コード例 #1
0
        override public bool ToCSV(string filename)
        {
            try {
                using (StreamWriter writer = new StreamWriter(filename))
                {
                    // Write header
                    writer.Write("Time" + delimiter);
                    writer.Write("Name" + delimiter);
                    writer.Write("X" + delimiter);
                    writer.Write("Y" + delimiter);
                    writer.Write("Z" + delimiter);
                    writer.Write("Distance" + delimiter);
                    writer.Write("Fuel used" + delimiter);
                    writer.Write("Fuel left" + delimiter);
                    writer.Write("Boost" + delimiter);
                    writer.Write("Note" + delimiter);

                    writer.WriteLine();

                    foreach (var je in scans)
                    {
                        if (je.EventTypeID == JournalTypeEnum.FSDJump)
                        {
                            EliteDangerousCore.JournalEvents.JournalFSDJump ev = je as EliteDangerousCore.JournalEvents.JournalFSDJump;

                            writer.Write(MakeValueCsvFriendly(ev.EventTimeLocal));
                            writer.Write(MakeValueCsvFriendly(ev.StarSystem));
                            writer.Write(MakeValueCsvFriendly(ev.StarPos.X));
                            writer.Write(MakeValueCsvFriendly(ev.StarPos.Y));
                            writer.Write(MakeValueCsvFriendly(ev.StarPos.Z));
                            writer.Write(MakeValueCsvFriendly(ev.JumpDist));
                            writer.Write(MakeValueCsvFriendly(ev.FuelUsed));
                            writer.Write(MakeValueCsvFriendly(ev.FuelLevel));
                            writer.Write(MakeValueCsvFriendly(ev.BoostUsed, false));
//                        writer.Write(MakeValueCsvFriendly(je.System.SystemNote));

                            writer.WriteLine();
                        }
                    }
                }

                return(true);
            }
            catch (IOException)
            {
                ExtendedControls.MessageBoxTheme.Show(String.Format("Is file {0} open?", filename), "Export Scan",
                                                      MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
コード例 #2
0
        private void buttonExt1_Click(object sender, EventArgs e)
        {
            System.IO.StreamReader filejr = new System.IO.StreamReader(textBoxFile.Text);
            string   line;
            string   system = "";
            StarScan ss     = new StarScan();

            Dictionary <string, string> items = new Dictionary <string, string>();

            while ((line = filejr.ReadLine()) != null)
            {
                if (line.Equals("END"))
                {
                    break;
                }
                //System.Diagnostics.Trace.WriteLine(line);

                if (line.Length > 0)
                {
                    JObject jo = (JObject)JObject.Parse(line);

                    //JSONPrettyPrint jpp = new JSONPrettyPrint(EliteDangerous.JournalFieldNaming.StandardConverters(), "event;timestamp", "_Localised", (string)jo["event"]);
                    //string s = jpp.PrettyPrintStr(line, 80);
                    //System.Diagnostics.Trace.WriteLine(s);

                    EliteDangerousCore.JournalEntry je = EliteDangerousCore.JournalEntry.CreateJournalEntry(line);
                    //System.Diagnostics.Trace.WriteLine(je.EventTypeStr);

                    if (je.EventTypeID == EliteDangerousCore.JournalTypeEnum.Location)
                    {
                        EliteDangerousCore.JournalEvents.JournalLocOrJump jl = je as EliteDangerousCore.JournalEvents.JournalLocOrJump;
                        system = jl.StarSystem;
                    }
                    else if (je.EventTypeID == EliteDangerousCore.JournalTypeEnum.FSDJump)
                    {
                        EliteDangerousCore.JournalEvents.JournalFSDJump jfsd = je as EliteDangerousCore.JournalEvents.JournalFSDJump;
                        system = jfsd.StarSystem;
                    }
                    else if (je.EventTypeID == EliteDangerousCore.JournalTypeEnum.Scan)
                    {
                        //ss.Process(je as EliteDangerousCore.JournalEvents.JournalScan, new EliteDangerousCore.SystemClass(system));
                    }
                }
            }
        }
コード例 #3
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);
                }
            }
        }