public List <IData3DSet> AddNotedBookmarks(Bitmap map, Bitmap maptarget, float widthly, float heightly, Vector3 rotation, List <VisitedSystemsClass> VisitedSystems) { var datasetbks = Data3DSetClass <TexturedQuadData> .Create("bkmrs", Color.White, 1f); long bookmarknoted = TargetClass.GetTargetNotedSystem(); if (VisitedSystems != null) { foreach (VisitedSystemsClass vs in VisitedSystems) { SystemNoteClass notecs = SystemNoteClass.GetSystemNoteClass(vs.Name); if (notecs != null) // if we have a note.. { string note = notecs.Note.Trim(); if (note.Length > 0) { PointData pd = new PointData((vs.HasTravelCoordinates) ? vs.X : vs.curSystem.x, (vs.HasTravelCoordinates) ? vs.Y : vs.curSystem.y, (vs.HasTravelCoordinates) ? vs.Z : vs.curSystem.z); Bitmap touse = (notecs.id == bookmarknoted) ? maptarget : map; TexturedQuadData newtexture = TexturedQuadData.FromBitmap(touse, pd, rotation, widthly, heightly, 0, heightly / 2); newtexture.Tag = vs; newtexture.Tag2 = 1; // note mark datasetbks.Add(newtexture); } } } } _datasets.Add(datasetbks); return(_datasets); }
public void Bookmark(BookmarkClass bk) // from multiple places, update this bookmark, region or system.. { string note = ""; string name; long? edsmid = null; if (!bk.isRegion) { ISystem s = SystemCache.FindSystem(bk.StarName); if (s != null) // paranoia { InitialisePos(s); edsmid = s.EDSMID; } else { InitialisePos(bk.x, bk.y, bk.z); } SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(bk.StarName); note = (sn != null) ? sn.Note : ""; name = bk.StarName; } else { // region, set position, set name InitialisePos(bk.x, bk.y, bk.z); name = bk.Heading; } this.Text = "Update Bookmark".T(EDTx.BookmarkForm_UB); buttonOK.Text = "Update".T(EDTx.BookmarkForm_Update); textBoxName.Text = name; textBoxName.ReadOnly = !bk.isRegion; textBoxName.ReturnPressed += (ctrl) => { return(true); }; textBoxBookmarkNotes.Text = bk.Note; textBoxBookmarkNotes.CursorToEnd(); textBoxBookmarkNotes.ScrollToCaret(); textBoxTravelNote.Text = note; textBoxTime.Text = EDDConfig.Instance.ConvertTimeToSelectedFromUTC(bk.TimeUTC).ToString(); checkBoxTarget.Checked = bk.id == TargetClass.GetTargetBookmark(); // who is the target of a bookmark (0=none) //foreach (Control c in panelOuter.Controls) System.Diagnostics.Debug.WriteLine("All Control {0} at {1}", c.Name, c.Top); if (bk.isRegion) { HideEDSM(); HideTravelNote(); // in order note HideSurfaceBookmarks(); } else { var edsm = new EDSMClass(); edsmurl = edsm.GetUrlToEDSMSystem(name, edsmid); SurfaceBookmarks.Init(bk.StarName, bk.PlanetaryMarks); } buttonOK.Enabled = true; }
public bool Import(out string result) { if (!ReadFile()) { result = "The import file could not be read with specified settings."; return(false); } if (DateCol.HasValue) { foreach (ImportSystem sys in SystemsForImport) { if (!ImportJump(sys)) { result = string.Format("Travel History import failed at {0}.", sys.SysName); return(false); } } } if (SysNoteCol.HasValue) { foreach (ImportSystem sys in SystemsForImport) { if (!ImportNote(sys)) { result = string.Format("System Note import failed at {0}.", sys.SysName); return(false); } SystemNoteClass.GetAllSystemNotes(); } } result = "File imported successfully"; return(true); }
public int GetComments(DateTime starttime, out List <SystemNoteClass> notes) { notes = new List <SystemNoteClass>(); var json = GetComments(starttime); if (json == null) { return(0); } JObject msg = JObject.Parse(json); int msgnr = msg["msgnum"].Value <int>(); JArray comments = (JArray)msg["comments"]; if (comments != null) { foreach (JObject jo in comments) { SystemNoteClass note = new SystemNoteClass(); note.Name = jo["system"].Value <string>(); note.Note = jo["comment"].Value <string>(); note.Time = DateTime.ParseExact(jo["lastUpdate"].Value <string>(), "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime(); notes.Add(note); } } return(msgnr); }
private void textBoxName_Validated(object sender, EventArgs e) { if (!freeSystemEntry) { return; } string t = textBoxName.Text.Trim(); ISystem s = SystemClassDB.GetSystem(t); if (s != null) { var edsm = new EDSMClass(); edsmurl = edsm.GetUrlToEDSMSystem(t); userControlSurfaceBookmarks1.NewForSystem(t); SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(t); textBoxNotes.Text = (sn != null) ? sn.Note : ""; InitialisePos(s); buttonOK.Enabled = true; labelBadSystem.Text = ""; } else { buttonOK.Enabled = false; textBoxName.SelectAll(); labelBadSystem.Text = "System name not recognised"; } }
public List <IData3DCollection> AddNotedBookmarks(Bitmap map, Bitmap maptarget, float widthly, float heightly, Vector3 rotation, List <HistoryEntry> syslists) { var datasetbks = Data3DCollection <TexturedQuadData> .Create("bkmrs", Color.White, 1f); long bookmarknoted = TargetClass.GetTargetNotedSystem(); if (syslists != null) { foreach (HistoryEntry vs in syslists.Where(s => s.IsLocOrJump)) { SystemNoteClass notecs = SystemNoteClass.GetNoteOnSystem(vs.System.Name); if (notecs != null) // if we have a note.. { string note = notecs.Note.Trim(); if (note.Length > 0) { PointData pd = new PointData(vs.System.X, vs.System.Y, vs.System.Z); Bitmap touse = (notecs.id == bookmarknoted) ? maptarget : map; TexturedQuadData newtexture = TexturedQuadData.FromBitmap(touse, pd, rotation, widthly, heightly, 0, heightly / 2); newtexture.Tag = vs; newtexture.Tag2 = 1; // note mark datasetbks.Add(newtexture); } } } } _datasets.Add(datasetbks); return(_datasets); }
private void BackgroundInit() { StarScan.LoadBodyDesignationMap(); MaterialCommodityDB.SetUpInitialTable(); if (!EDDOptions.Instance.NoSystemsLoad) { downloadMapsTask = FGEImage.DownloadMaps(this, () => PendingClose, LogLine, LogLineHighlight); CheckSystems(() => PendingClose, (p, s) => ReportProgress(p, s)); } SystemNoteClass.GetAllSystemNotes(); // fill up memory with notes, bookmarks, galactic mapping BookmarkClass.GetAllBookmarks(); ReportProgress(-1, ""); InvokeAsyncOnUiThread(() => OnInitialSyncComplete?.Invoke()); if (PendingClose) { return; } if (EliteDangerousCore.EDDN.EDDNClass.CheckforEDMC()) // EDMC is running { if (EDCommander.Current.SyncToEddn) // Both EDD and EDMC should not sync to EDDN. { LogLineHighlight("EDDiscovery and EDMarketConnector should not both sync to EDDN. Stop EDMC or uncheck 'send to EDDN' in settings tab!"); } } if (PendingClose) { return; } LogLine("Reading travel history"); if (!EDDOptions.Instance.NoLoad) { DoRefreshHistory(new RefreshWorkerArgs { CurrentCommander = EDCommander.CurrentCmdrID }); } if (PendingClose) { return; } if (syncstate.performeddbsync || syncstate.performedsmsync) { string databases = (syncstate.performedsmsync && syncstate.performeddbsync) ? "EDSM and EDDB" : ((syncstate.performedsmsync) ? "EDSM" : "EDDB"); LogLine("ED Discovery will now synchronise to the " + databases + " databases to obtain star information." + Environment.NewLine + "This will take a while, up to 15 minutes, please be patient." + Environment.NewLine + "Please continue running ED Discovery until refresh is complete."); } InvokeAsyncOnUiThread(() => OnInitialisationComplete?.Invoke()); }
public string SetComment(SystemNoteClass sn) { string query; query = "set-comment?systemName=" + HttpUtility.UrlEncode(sn.Name) + "&commanderName=" + HttpUtility.UrlEncode(commanderName) + "&apiKey=" + apiKey + "&comment=" + HttpUtility.UrlEncode(sn.Note); var response = RequestGet("api-logs-v1/" + query); return(response.Body); }
private void AddNewHistoryRow(bool insert, HistoryEntry item) // second part of add history row, adds item to view. { SystemNoteClass snc = SystemNoteClass.GetNoteOnJournalEntry(item.Journalid); if (snc == null && item.IsFSDJump) { snc = SystemNoteClass.GetNoteOnSystem(item.System.name, item.System.id_edsm); } // Try to fill EDSM ID where a system note is set but journal item EDSM ID is not set if (snc != null && snc.Name != null && snc.EdsmId > 0 && item.System.id_edsm <= 0) { item.System.id_edsm = 0; discoveryform.history.FillEDSM(item); if (snc.Journalid != item.Journalid && item.System.id_edsm > 0 && snc.EdsmId != item.System.id_edsm) { snc = null; } } if (snc != null && snc.Name != null && snc.Journalid == item.Journalid && item.System.id_edsm > 0 && snc.EdsmId != item.System.id_edsm) { snc.EdsmId = item.System.id_edsm; snc.Update(); } //string debugt = item.Journalid + " " + item.System.id_edsm + " " + item.System.GetHashCode() + " "; // add on for debug purposes to a field below object[] rowobj = { EDDiscoveryForm.EDDConfig.DisplayUTC?item.EventTimeUTC : item.EventTimeLocal, "", item.EventSummary, item.EventDescription, (snc != null) ? snc.Note : "" }; int rownr; if (insert) { dataGridViewTravel.Rows.Insert(0, rowobj); rownr = 0; } else { dataGridViewTravel.Rows.Add(rowobj); rownr = dataGridViewTravel.Rows.Count - 1; } dataGridViewTravel.Rows[rownr].Cells[TravelHistoryColumns.HistoryTag].Tag = item; dataGridViewTravel.Rows[rownr].Cells[TravelHistoryColumns.NoteTag].Tag = snc; dataGridViewTravel.Rows[rownr].DefaultCellStyle.ForeColor = (item.System.HasCoordinate || item.EntryType != JournalTypeEnum.FSDJump) ? discoveryform.theme.VisitedSystemColor : discoveryform.theme.NonVisitedSystemColor; string tip = item.EventSummary + Environment.NewLine + item.EventDescription + Environment.NewLine + item.EventDetailedInfo; dataGridViewTravel.Rows[rownr].Cells[0].ToolTipText = tip; dataGridViewTravel.Rows[rownr].Cells[1].ToolTipText = tip; dataGridViewTravel.Rows[rownr].Cells[2].ToolTipText = tip; dataGridViewTravel.Rows[rownr].Cells[3].ToolTipText = tip; dataGridViewTravel.Rows[rownr].Cells[4].ToolTipText = tip; }
public void GetComments(Action <string> logout = null) // Protected against bad JSON { var json = GetComments(new DateTime(2011, 1, 1)); if (json != null) { try { JObject msg = JObject.Parse(json); // protect against bad json - seen in the wild int msgnr = msg["msgnum"].Value <int>(); JArray comments = (JArray)msg["comments"]; if (comments != null) { int commentsadded = 0; foreach (JObject jo in comments) { string name = jo["system"].Value <string>(); string note = jo["comment"].Value <string>(); string utctime = jo["lastUpdate"].Value <string>(); int edsmid = 0; if (!Int32.TryParse(jo["systemId"].Str("0"), out edsmid)) { edsmid = 0; } DateTime localtime = DateTime.ParseExact(utctime, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime(); SystemNoteClass curnote = SystemNoteClass.GetNoteOnSystem(name, edsmid); if (curnote != null) // curnote uses local time to store { if (localtime.Ticks > curnote.Time.Ticks) // if newer, add on (verified with EDSM 29/9/2016) { curnote.UpdateNote(curnote.Note + ". EDSM: " + note, true, localtime, edsmid, true); commentsadded++; } } else { SystemNoteClass.MakeSystemNote(note, localtime, name, 0, edsmid, true); // new one! its an FSD one as well commentsadded++; } } logout?.Invoke(string.Format("EDSM Comments downloaded/updated {0}", commentsadded)); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("Failed due to " + e.ToString()); } } }
public void Update(BookmarkClass bk) // from multiple places, update this bookmark, region or system.. { string note = ""; string name; long? edsmid = null; if (!bk.isRegion) { ISystem s = SystemCache.FindSystem(bk.StarName); if (s != null) // paranoia { InitialisePos(s); edsmid = s.EDSMID; } else { InitialisePos(bk.x, bk.y, bk.z); } SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(bk.StarName); note = (sn != null) ? sn.Note : ""; name = bk.StarName; } else { // region, set position, set name InitialisePos(bk.x, bk.y, bk.z); name = bk.Heading; } this.Text = "Update Bookmark".Tx(this, "UB"); buttonOK.Text = "Update".Tx(this); textBoxName.Text = name; textBoxName.ReadOnly = !bk.isRegion; textBoxName.ReturnPressed += (ctrl) => { return(true); }; textBoxBookmarkNotes.Text = bk.Note; textBoxBookmarkNotes.CursorToEnd(); textBoxBookmarkNotes.ScrollToCaret(); textBoxTravelNote.Text = note; textBoxTime.Text = bk.Time.ToString(); checkBoxTarget.Checked = bk.id == TargetClass.GetTargetBookmark(); // who is the target of a bookmark (0=none) if (bk.isRegion) { HideEDSM(); HideTravelNote(); HideSurfaceBookmarks(); } else { var edsm = new EDSMClass(); edsmurl = edsm.GetUrlToEDSMSystem(name, edsmid); SurfaceBookmarks.Init(bk.StarName, bk.PlanetaryMarks); } buttonOK.Enabled = true; }
// Called after HE removal/reorder, and after the UI's has had a chance to operate private void Controller_NewEntrySecond(HistoryEntry he, HistoryList hl) { BaseUtils.AppTicks.TickCountLapDelta("DFS", true); actioncontroller.ActionRunOnEntry(he, Actions.ActionEventEDList.NewEntry(he)); var t1 = BaseUtils.AppTicks.TickCountLapDelta("DFS"); if (t1.Item2 >= 80) { System.Diagnostics.Trace.WriteLine("NE Second Actions slow " + t1.Item1); } // all notes committed SystemNoteClass.CommitDirtyNotes((snc) => { if (EDCommander.Current.SyncToEdsm && snc.FSDEntry) { EDSMClass.SendComments(snc.SystemName, snc.Note, 0, he.Commander); } }); if (he.IsFSDCarrierJump) { int count = history.GetVisitsCount(he.System.Name); LogLine(string.Format("Arrived at system {0} Visit No. {1}".T(EDTx.EDDiscoveryForm_Arrived), he.System.Name, count)); System.Diagnostics.Trace.WriteLine("Arrived at system: " + he.System.Name + " " + count + ":th visit."); } if (EDCommander.Current.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EDCommander.Current.SyncToEDAstro) { EliteDangerousCore.EDAstro.EDAstroSync.SendEDAstroEvents(new List <HistoryEntry>() { he }); } if (EDDNClass.IsEDDNMessage(he.EntryType) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && EDCommander.Current.SyncToEddn == true) { EDDNSync.SendEDDNEvents(LogLine, new List <HistoryEntry> { he }); } if (DLLManager.Count > 0) { DLLManager.NewJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, he), false); } ScreenshotConverter.NewJournalEntry(he.journalEntry); // tell the screenshotter. CheckActionProfile(he); }
private void CheckSystems(Func <bool> cancelRequested, Action <int, string> reportProgress) // ASYNC process, done via start up, must not be too slow. { reportProgress(-1, ""); string rwsystime = SQLiteConnectionSystem.GetSettingString("EDSMLastSystems", "2000-01-01 00:00:00"); // Latest time from RW file. DateTime edsmdate; if (!DateTime.TryParse(rwsystime, CultureInfo.InvariantCulture, DateTimeStyles.None, out edsmdate)) { edsmdate = new DateTime(2000, 1, 1); } if (DateTime.Now.Subtract(edsmdate).TotalDays > 7) // Over 7 days do a sync from EDSM { // Also update galactic mapping from EDSM LogLine("Get galactic mapping from EDSM."); galacticMapping.DownloadFromEDSM(); // Skip EDSM full update if update has been performed in last 4 days bool outoforder = SQLiteConnectionSystem.GetSettingBool("EDSMSystemsOutOfOrder", true); DateTime lastmod = outoforder ? SystemClass.GetLastSystemModifiedTime() : SystemClass.GetLastSystemModifiedTimeFast(); if (DateTime.UtcNow.Subtract(lastmod).TotalDays > 4 || DateTime.UtcNow.Subtract(edsmdate).TotalDays > 28) { syncstate.performedsmsync = true; } else { SQLiteConnectionSystem.PutSettingString("EDSMLastSystems", DateTime.Now.ToString(CultureInfo.InvariantCulture)); } } if (!cancelRequested()) { SQLiteConnectionUser.TranferVisitedSystemstoJournalTableIfRequired(); SQLiteConnectionSystem.CreateSystemsTableIndexes(); SystemNoteClass.GetAllSystemNotes(); // fill up memory with notes, bookmarks, galactic mapping BookmarkClass.GetAllBookmarks(); galacticMapping.ParseData(); // at this point, EDSM data is loaded.. SystemClass.AddToAutoComplete(galacticMapping.GetGMONames()); EDDiscovery.EliteDangerous.MaterialCommodityDB.SetUpInitialTable(); LogLine("Loaded Notes, Bookmarks and Galactic mapping."); string timestr = SQLiteConnectionSystem.GetSettingString("EDDBSystemsTime", "0"); DateTime time = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc); if (DateTime.UtcNow.Subtract(time).TotalDays > 6.5) // Get EDDB data once every week. { syncstate.performeddbsync = true; } } }
private void clearEDSMIDAssignedToAllRecordsForCurrentCommanderToolStripMenuItem_Click(object sender, EventArgs e) { if (EDDiscovery.Forms.MessageBoxTheme.Show("Confirm you wish to reset the assigned EDSM IDs to all the current commander history entries," + " and clear all the assigned EDSM IDs in all your notes for all commanders\r\n\r\n" + "This will not change your history, but when you next refresh, it will try and reassign EDSM systems to " + "your history and notes. Use only if you think that the assignment of EDSM systems to entries is grossly wrong," + "or notes are going missing\r\n" + "\r\n" + "You can manually change one EDSM assigned system by right clicking on the travel history and selecting the option" , "WARNING", MessageBoxButtons.OKCancel) == DialogResult.OK) { EliteDangerous.JournalEntry.ClearEDSMID(EDCommander.CurrentCmdrID); SystemNoteClass.ClearEDSMID(); } }
public void SetJournalSystemNoteText(string text, bool commit, bool sendtoedsm) { if (snc == null || snc.Journalid == 0) // if no system note, or its one on a system, from now on we assign journal system notes only from this IF { snc = SystemNoteClass.MakeSystemNote("", DateTime.Now, System.Name, Journalid, System.EDSMID, IsFSDJump); } snc = snc.UpdateNote(text, commit, DateTime.Now, snc.EdsmId, IsFSDJump); // and update info, and update our ref in case it has changed or gone null // remember for EDSM send purposes if its an FSD entry if (snc != null && commit && sendtoedsm && snc.FSDEntry) // if still have a note, and commiting, and send to esdm, and FSD jump { EDSMClass.SendComments(snc.SystemName, snc.Note, snc.EdsmId); } }
private void StoreSystemNote() { string txt; try { //SystemPosition sp = (SystemPosition)dataGridView1.Rows[lastRowIndex].Cells[1].Tag; txt = richTextBoxNote.Text; if (currentSysPos != null && !txt.Equals(currentSysPos.curSystem.Note)) { SystemNoteClass sn; List <SystemClass> systems = new List <SystemClass>(); if (SQLiteDBClass.globalSystemNotes.ContainsKey(currentSysPos.curSystem.SearchName)) { sn = SQLiteDBClass.globalSystemNotes[currentSysPos.curSystem.SearchName]; sn.Note = txt; sn.Time = DateTime.Now; sn.Update(); } else { sn = new SystemNoteClass(); sn.Name = currentSysPos.curSystem.name; sn.Note = txt; sn.Time = DateTime.Now; sn.Add(); } currentSysPos.curSystem.Note = txt; dataGridView1.Rows[lastRowIndex].Cells[3].Value = txt; } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message); System.Diagnostics.Trace.WriteLine(ex.StackTrace); LogText("Exception : " + ex.Message, Color.Red); LogText(ex.StackTrace, Color.Red); } }
private void UpdateSystemRow(int rowindex) { if (rowindex < dataGridViewRouteSystems.Rows.Count && dataGridViewRouteSystems[0, rowindex].Value != null) { string sysname = dataGridViewRouteSystems[0, rowindex].Value.ToString(); var sys = GetSystem(sysname); dataGridViewRouteSystems[1, rowindex].Value = ""; if (rowindex > 0 && rowindex < dataGridViewRouteSystems.Rows.Count && dataGridViewRouteSystems[0, rowindex - 1].Value != null && dataGridViewRouteSystems[0, rowindex].Value != null) { string prevsysname = dataGridViewRouteSystems[0, rowindex - 1].Value.ToString(); var prevsys = GetSystem(prevsysname); if (sys != null && prevsys != null) { double dist = SystemClass.Distance(sys, prevsys); string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : ""; dataGridViewRouteSystems[1, rowindex].Value = strdist; } } dataGridViewRouteSystems[0, rowindex].Tag = sys; dataGridViewRouteSystems.Rows[rowindex].DefaultCellStyle.ForeColor = (sys != null && sys.HasCoordinate) ? _discoveryForm.theme.VisitedSystemColor : _discoveryForm.theme.NonVisitedSystemColor; if (sys != null) { SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(sys.name, sys.id_edsm); dataGridViewRouteSystems[2, rowindex].Value = sn != null ? sn.Note : ""; } if (sys == null && sysname != "") { dataGridViewRouteSystems.Rows[rowindex].ErrorText = "System not known to EDSM"; } else { dataGridViewRouteSystems.Rows[rowindex].ErrorText = ""; } } }
public void Update(BookmarkClass bk) { string note = ""; string name; if (!bk.isRegion) { SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(bk.StarName); ISystem s = SystemClassDB.GetSystem(bk.StarName); InitialisePos(s); note = (sn != null) ? sn.Note : ""; name = bk.StarName; } else { name = bk.Heading; } Update(name, note, bk.Note, bk.Time.ToString(), bk.isRegion, false, bk.PlanetaryMarks); userControlSurfaceBookmarks1.DisplayPlanetMarks(bk); buttonOK.Enabled = true; }
public override bool ToCSV(string filename) { try { using (StreamWriter writer = new StreamWriter(filename)) { if (IncludeHeader) { writer.Write("StarName" + delimiter); writer.Write("JournalEntry" + delimiter); writer.Write("EDSMID" + delimiter); writer.Write("Time" + delimiter); writer.Write("Note"); writer.WriteLine(); } SystemNoteClass.GetAllSystemNotes(); foreach (SystemNoteClass snc in SystemNoteClass.globalSystemNotes) { writer.Write(MakeValueCsvFriendly(snc.SystemName.Length > 0 ? snc.SystemName : "N/A")); writer.Write(MakeValueCsvFriendly(snc.Journalid > 0 ? snc.Journalid.ToString() : "N/A")); writer.Write(MakeValueCsvFriendly(snc.EdsmId > 0 ? snc.EdsmId.ToString() : "N/A")); writer.Write(MakeValueCsvFriendly(snc.Time)); writer.Write(MakeValueCsvFriendly(snc.Note, false)); writer.WriteLine(); } } return(true); } catch (IOException) { ExtendedControls.MessageBoxTheme.Show(String.Format("Is file {0} open?", filename), TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
// Called from Background Thread Worker at Init() private void BackgroundInit() { StarScan.LoadBodyDesignationMap(); SQLiteConnectionSystem.CreateSystemsTableIndexes(); // just make sure they are there.. Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Check systems"); ReportSyncProgress(-1, ""); bool checkGithub = EDDOptions.Instance.CheckGithubFiles; if (checkGithub) // not normall in debug, due to git hub chokeing { // Async load of maps in another thread DownloadMaps(() => PendingClose); // and Expedition data DownloadExpeditions(() => PendingClose); // and Exploration data DownloadExploration(() => PendingClose); } if (!EDDOptions.Instance.NoSystemsLoad) { // Former CheckSystems, reworked to accomodate new switches.. // Check to see what sync refreshes we need // New Galmap load - it was not doing a refresh if EDSM sync kept on happening. Now has its own timer string rwgalmaptime = SQLiteConnectionSystem.GetSettingString("EDSMGalMapLast", "2000-01-01 00:00:00"); // Latest time from RW file. DateTime galmaptime; if (!DateTime.TryParse(rwgalmaptime, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal, out galmaptime)) { galmaptime = new DateTime(2000, 1, 1); } if (DateTime.Now.Subtract(galmaptime).TotalDays > 14) // Over 14 days do a sync from EDSM for galmap { LogLine("Get galactic mapping from EDSM.".Tx(this, "EDSM")); galacticMapping.DownloadFromEDSM(); SQLiteConnectionSystem.PutSettingString("EDSMGalMapLast", DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss")); } Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Check systems complete"); } galacticMapping.ParseData(); // at this point, gal map data has been uploaded - get it into memory SystemClassDB.AddToAutoComplete(galacticMapping.GetGMONames()); SystemNoteClass.GetAllSystemNotes(); LogLine("Loaded Notes, Bookmarks and Galactic mapping.".Tx(this, "LN")); if (PendingClose) { return; } if (EliteDangerousCore.EDDN.EDDNClass.CheckforEDMC()) // EDMC is running { if (EDCommander.Current.SyncToEddn) // Both EDD and EDMC should not sync to EDDN. { LogLineHighlight("EDDiscovery and EDMarketConnector should not both sync to EDDN. Stop EDMC or uncheck 'send to EDDN' in settings tab!".Tx(this, "EDMC")); } } if (!EDDOptions.Instance.NoLoad) // here in this thread, we do a refresh of history. { LogLine("Reading travel history".Tx(this, "RTH")); DoRefreshHistory(new RefreshWorkerArgs { CurrentCommander = EDCommander.CurrentCmdrID }); // kick the background refresh worker thread into action } if (PendingClose) { return; } if (!EDDOptions.Instance.NoSystemsLoad && EDDConfig.Instance.EDSMEDDBDownload) // if enabled { SystemClassEDSM.DetermineIfFullEDSMSyncRequired(syncstate); // ask EDSM and EDDB if they want to do a Full sync.. EliteDangerousCore.EDDB.SystemClassEDDB.DetermineIfEDDBSyncRequired(syncstate); if (syncstate.perform_eddb_sync || syncstate.perform_edsm_fullsync) { string databases = (syncstate.perform_edsm_fullsync && syncstate.perform_eddb_sync) ? "EDSM and EDDB" : ((syncstate.perform_edsm_fullsync) ? "EDSM" : "EDDB"); LogLine(string.Format("Full synchronisation to the {0} databases required." + Environment.NewLine + "This will take a while, up to 15 minutes, please be patient." + Environment.NewLine + "Please continue running ED Discovery until refresh is complete.".Tx(this, "SyncEDSM"), databases)); } } else { LogLine("Synchronisation to EDSM and EDDB disabled. Use Settings panel to reenable".Tx(this, "SyncOff")); } }
private void UpdateSystemRow(int rowindex) { const int idxVisits = 5; const int idxScans = 6; const int idxBodies = 7; const int idxstars = 8; const int idxInfo = 9; const int idxNote = 10; ISystem currentSystem = discoveryform.history.CurrentSystem; // may be null if (rowindex < dataGridViewExplore.Rows.Count && dataGridViewExplore[0, rowindex].Value != null) { string sysname = dataGridViewExplore[0, rowindex].Value.ToString(); ISystem sys = (ISystem)dataGridViewExplore[0, rowindex].Tag; if (sys == null) { sys = discoveryform.history.FindSystem(sysname); } if (sys != null && currentSystem != null) { double dist = sys.Distance(currentSystem); string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : ""; dataGridViewExplore[1, rowindex].Value = strdist; } dataGridViewExplore[0, rowindex].Tag = sys; dataGridViewExplore.Rows[rowindex].DefaultCellStyle.ForeColor = (sys != null && sys.HasCoordinate) ? discoveryform.theme.VisitedSystemColor : discoveryform.theme.NonVisitedSystemColor; if (sys != null) { if (sys.HasCoordinate) { dataGridViewExplore[2, rowindex].Value = sys.X.ToString("0.00"); dataGridViewExplore[3, rowindex].Value = sys.Y.ToString("0.00"); dataGridViewExplore[4, rowindex].Value = sys.Z.ToString("0.00"); } dataGridViewExplore[idxVisits, rowindex].Value = discoveryform.history.GetVisitsCount(sysname).ToString(); StarScan.SystemNode sysnode = discoveryform.history.starscan.FindSystemSynchronous(sys, false); if (sysnode != null) { dataGridViewExplore[idxScans, rowindex].Value = sysnode.StarPlanetsScanned().ToString(); if (sysnode.FSSTotalBodies.HasValue) { dataGridViewExplore[idxBodies, rowindex].Value = sysnode.FSSTotalBodies.Value.ToString(); } dataGridViewExplore[idxstars, rowindex].Value = sysnode.StarTypesFound(false); string info = ""; foreach (var scan in sysnode.Bodies) { JournalScan sd = scan.ScanData; if (sd != null) { if (sd.IsStar) { if (sd.StarTypeID == EDStar.AeBe) { info = info + " " + "AeBe"; } if (sd.StarTypeID == EDStar.N) { info = info + " " + "NS"; } if (sd.StarTypeID == EDStar.H) { info = info + " " + "BH"; } } else { if (sd.PlanetTypeID == EDPlanet.Earthlike_body) { info = info + " " + (sd.Terraformable ? "T-ELW" : "ELW"); } else if (sd.PlanetTypeID == EDPlanet.Water_world) { info = info + " " + (sd.Terraformable ? "T-WW" : "WW"); } else if (sd.PlanetTypeID == EDPlanet.High_metal_content_body && sd.Terraformable) { info = info + " " + "T-HMC"; } } } } dataGridViewExplore[idxInfo, rowindex].Value = info.Trim(); } string note = ""; SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(sys.Name, sys.EDSMID); if (sn != null && !string.IsNullOrWhiteSpace(sn.Note)) { note = sn.Note; } else { BookmarkClass bkmark = GlobalBookMarkList.Instance.FindBookmarkOnSystem(sys.Name); if (bkmark != null && !string.IsNullOrWhiteSpace(bkmark.Note)) { note = bkmark.Note; } else { var gmo = discoveryform.galacticMapping.Find(sys.Name); if (gmo != null && !string.IsNullOrWhiteSpace(gmo.description)) { note = gmo.description; } } } dataGridViewExplore[idxNote, rowindex].Value = note.WordWrap(60); } if (sys == null && sysname != "") { dataGridViewExplore.Rows[rowindex].ErrorText = "System not known".T(EDTx.Systemnotknown); } else { dataGridViewExplore.Rows[rowindex].ErrorText = ""; } } }
private void Controller_NewEntrySecond(HistoryEntry he, HistoryList hl) // called after all UI's have had their chance { BaseUtils.AppTicks.TickCountLapDelta("DFS", true); actioncontroller.ActionRunOnEntry(he, Actions.ActionEventEDList.NewEntry(he)); var t1 = BaseUtils.AppTicks.TickCountLapDelta("DFS"); if (t1.Item2 >= 80) { System.Diagnostics.Trace.WriteLine("NE Second Actions slow " + t1.Item1); } // all notes committed SystemNoteClass.CommitDirtyNotes((snc) => { if (EDCommander.Current.SyncToEdsm && snc.FSDEntry) { EDSMClass.SendComments(snc.SystemName, snc.Note, 0, he.Commander); } }); var lastent = history.GetLast; if (!object.ReferenceEquals(he, lastent)) { LogLineHighlight(string.Format("Current history entry is not last in history - possible re-entrancy.\nAlert the EDDiscovery developers using either discord or Github (see help) and attach log file {0}", BaseUtils.TraceLog.LogFileName)); Trace.WriteLine($"Current history entry is not last in history"); Trace.WriteLine($"Current entry: {he.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Last entry: {lastent.journalEntry?.GetJsonString()}"); Trace.WriteLine($"Stack Trace:"); Trace.WriteLine(new StackTrace(true).ToString()); } if (he.IsFSDCarrierJump) { int count = history.GetVisitsCount(he.System.Name); LogLine(string.Format("Arrived at system {0} Visit No. {1}".T(EDTx.EDDiscoveryForm_Arrived), he.System.Name, count)); System.Diagnostics.Trace.WriteLine("Arrived at system: " + he.System.Name + " " + count + ":th visit."); } if (EDCommander.Current.SyncToEdsm && EDSMJournalSync.OkayToSend(he)) // send this one, if allowed. { EDSMJournalSync.SendEDSMEvents(LogLine, new List <HistoryEntry>() { he }); // send, if bad credentials, EDSM will moan alerting the user } if (EDCommander.Current.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, hl, he); } if (EDCommander.Current.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EDCommander.Current.SyncToEDAstro) { EliteDangerousCore.EDAstro.EDAstroSync.SendEDAstroEvents(new List <HistoryEntry>() { he }); } if (EDDNClass.IsEDDNMessage(he.EntryType) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && EDCommander.Current.SyncToEddn == true) { EDDNSync.SendEDDNEvents(LogLine, he); } DLLManager.NewJournalEntry(EliteDangerousCore.DLL.EDDDLLCallerHE.CreateFromHistoryEntry(history, he), false); screenshotconverter.NewJournalEntry(he.journalEntry); // tell the screenshotter. CheckActionProfile(he); }
public void ProcessWithUserDb(JournalEntry je, HistoryEntry prev, HistoryList hl, SQLiteConnectionUser conn) // called after above with a USER connection { materialscommodities = MaterialCommoditiesList.Process(je, prev?.materialscommodities, conn, EliteConfigInstance.InstanceConfig.ClearMaterials, EliteConfigInstance.InstanceConfig.ClearCommodities); snc = SystemNoteClass.GetSystemNote(Journalid, IsFSDJump, System); // may be null }
public static void setTargetSystem(Object sender, EDDiscoveryForm _discoveryForm, String sn, Boolean prompt) { Form senderForm = ((Control)sender)?.FindForm() ?? _discoveryForm; if (string.IsNullOrWhiteSpace(sn)) { if (prompt && TargetClass.IsTargetSet()) // if prompting, and target is set, ask for delete { if (ExtendedControls.MessageBoxTheme.Show(senderForm, "Confirm deletion of target", "Delete a target", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { TargetClass.ClearTarget(); _discoveryForm.NewTargetSet(sender); // tells everyone who cares a new target was set } } return; } ISystem sc = _discoveryForm.history.FindSystem(sn); string msgboxtext = null; if (sc != null && sc.HasCoordinate) { SystemNoteClass nc = SystemNoteClass.GetNoteOnSystem(sc.Name, sc.EDSMID); // has it got a note? if (nc != null) { TargetClass.SetTargetNotedSystem(sc.Name, nc.id, sc.X, sc.Y, sc.Z); msgboxtext = "Target set on system with note " + sc.Name; } else { BookmarkClass bk = GlobalBookMarkList.Instance.FindBookmarkOnSystem(sn); // has it been bookmarked? if (bk != null) { TargetClass.SetTargetBookmark(sc.Name, bk.id, bk.x, bk.y, bk.z); msgboxtext = "Target set on bookmarked system " + sc.Name; } else { bool createbookmark = false; if ((prompt && ExtendedControls.MessageBoxTheme.Show(senderForm, "Make a bookmark on " + sc.Name + " and set as target?", "Make Bookmark", MessageBoxButtons.OKCancel) == DialogResult.OK) || !prompt) { createbookmark = true; } if (createbookmark) { BookmarkClass newbk = GlobalBookMarkList.Instance.AddOrUpdateBookmark(null, true, sn, sc.X, sc.Y, sc.Z, DateTime.Now, ""); TargetClass.SetTargetBookmark(sc.Name, newbk.id, newbk.x, newbk.y, newbk.z); } } } } else { if (sn.Length > 2 && sn.Substring(0, 2).Equals("G:")) { sn = sn.Substring(2, sn.Length - 2); } GalacticMapObject gmo = _discoveryForm.galacticMapping.Find(sn, true, true); // ignore if its off, find any part of string, find if disabled if (gmo != null) { TargetClass.SetTargetGMO("G:" + gmo.name, gmo.id, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z); msgboxtext = "Target set on galaxy object " + gmo.name; } else { msgboxtext = "Unknown system, system is without co-ordinates or galaxy object not found"; } } _discoveryForm.NewTargetSet(sender); // tells everyone who cares a new target was set if (msgboxtext != null && prompt) { ExtendedControls.MessageBoxTheme.Show(senderForm, msgboxtext, "Create a target", MessageBoxButtons.OK); } }
// cursystem = null, curbookmark = null, new system free entry bookmark // cursystem != null, curbookmark = null, system bookmark found, update // cursystem != null, curbookmark = null, no system bookmark found, new bookmark on system // curbookmark != null, edit current bookmark public static void showBookmarkForm(Object sender, EDDiscoveryForm discoveryForm, ISystem cursystem, BookmarkClass curbookmark, bool notedsystem) { Form senderForm = ((Control)sender)?.FindForm() ?? discoveryForm; // try and find the associated bookmark.. BookmarkClass bkmark = (curbookmark != null) ? curbookmark : (cursystem != null ? GlobalBookMarkList.Instance.FindBookmarkOnSystem(cursystem.Name) : null); SystemNoteClass sn = (cursystem != null) ? SystemNoteClass.GetNoteOnSystem(cursystem.Name, cursystem.EDSMID) : null; string note = (sn != null) ? sn.Note : ""; BookmarkForm frm = new BookmarkForm(); if (notedsystem && bkmark == null) // note on a system { long targetid = TargetClass.GetTargetNotedSystem(); // who is the target of a noted system (0=none) long noteid = sn.id; frm.InitialisePos(cursystem); frm.NotedSystem(cursystem.Name, note, noteid == targetid); // note may be passed in null frm.ShowDialog(senderForm); if ((frm.IsTarget && targetid != noteid) || (!frm.IsTarget && targetid == noteid)) // changed.. { if (frm.IsTarget) { TargetClass.SetTargetNotedSystem(cursystem.Name, noteid, cursystem.X, cursystem.Y, cursystem.Z); } else { TargetClass.ClearTarget(); } } } else { bool regionmarker = false; DateTime tme; if (bkmark == null) // new bookmark { tme = DateTime.Now; if (cursystem == null) { frm.NewFreeEntrySystemBookmark(tme); } else { frm.NewSystemBookmark(cursystem, note, tme); } } else // update bookmark { regionmarker = bkmark.isRegion; tme = bkmark.Time; frm.Update(bkmark); } DialogResult res = frm.ShowDialog(senderForm); long curtargetid = TargetClass.GetTargetBookmark(); // who is the target of a bookmark (0=none) if (res == DialogResult.OK) { BookmarkClass newcls = GlobalBookMarkList.Instance.AddOrUpdateBookmark(bkmark, !regionmarker, frm.StarHeading, double.Parse(frm.x), double.Parse(frm.y), double.Parse(frm.z), tme, frm.Notes, frm.SurfaceLocations); if ((frm.IsTarget && curtargetid != newcls.id) || (!frm.IsTarget && curtargetid == newcls.id)) // changed.. { if (frm.IsTarget) { TargetClass.SetTargetBookmark(regionmarker ? ("RM:" + newcls.Heading) : newcls.StarName, newcls.id, newcls.x, newcls.y, newcls.z); } else { TargetClass.ClearTarget(); } } } else if (res == DialogResult.Abort && bkmark != null) { if (curtargetid == bkmark.id) { TargetClass.ClearTarget(); } GlobalBookMarkList.Instance.Delete(bkmark); } } discoveryForm.NewTargetSet(sender); }
private void Sync(EDSMClass edsm) { try { mainForm.LogLine("EDSM sync begin"); List <HistoryEntry> hlfsdunsyncedlist = mainForm.history.FilterByNotEDSMSyncedAndFSD; // first entry is oldest if (_syncTo && hlfsdunsyncedlist.Count > 0) // send systems to edsm (verified with dates, 29/9/2016, utc throughout) { DateTime logstarttime = DateTime.MinValue; DateTime logendtime = DateTime.MinValue; mainForm.LogLine("EDSM: Sending " + hlfsdunsyncedlist.Count.ToString() + " flightlog entries"); List <HistoryEntry> edsmsystemlog = null; int edsmsystemssent = 0; foreach (var he in hlfsdunsyncedlist) { if (Exit) { running = false; return; } if (edsmsystemlog == null || he.EventTimeUTC >= logendtime.AddDays(-1)) { edsm.GetLogs(he.EventTimeUTC.AddDays(-1), null, out edsmsystemlog, out logstarttime, out logendtime); // always returns a log, time is in UTC as per HistoryEntry and JournalEntry } if (logendtime < logstarttime) { running = false; return; } if (edsmsystemlog == null) { running = false; return; } HistoryEntry ps2 = (from c in edsmsystemlog where c.System.name == he.System.name && c.EventTimeUTC.Ticks == he.EventTimeUTC.Ticks select c).FirstOrDefault(); if (ps2 != null) // it did, just make sure EDSM sync flag is set.. { he.SetEdsmSync(); } else { string errmsg; // (verified with EDSM 29/9/2016) bool firstdiscover; int edsmid; if (edsm.SendTravelLog(he.System.name, he.EventTimeUTC, he.System.HasCoordinate && !he.IsStarPosFromEDSM, he.System.x, he.System.y, he.System.z, out errmsg, out firstdiscover, out edsmid)) { if (edsmid != 0 && he.System.id_edsm <= 0) { he.System.id_edsm = edsmid; EDDiscovery.EliteDangerous.JournalEntry.UpdateEDSMIDPosJump(he.Journalid, he.System, false, -1); } if (firstdiscover) { he.SetFirstDiscover(); } he.SetEdsmSync(); edsmsystemssent++; } if (errmsg.Length > 0) { mainForm.LogLine(errmsg); break; } } } mainForm.LogLine(string.Format("EDSM Systems sent {0}", edsmsystemssent)); } // TBD Comments to edsm? if (_syncFrom) // Verified ok with time 29/9/2016 { var json = edsm.GetComments(new DateTime(2011, 1, 1)); if (json != null) { JObject msg = JObject.Parse(json); int msgnr = msg["msgnum"].Value <int>(); JArray comments = (JArray)msg["comments"]; if (comments != null) { int commentsadded = 0; foreach (JObject jo in comments) { string name = jo["system"].Value <string>(); string note = jo["comment"].Value <string>(); string utctime = jo["lastUpdate"].Value <string>(); int edsmid = 0; if (!Int32.TryParse(JSONHelper.GetStringDef(jo["systemId"], "0"), out edsmid)) { edsmid = 0; } DateTime localtime = DateTime.ParseExact(utctime, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToLocalTime(); SystemNoteClass curnote = SystemNoteClass.GetNoteOnSystem(name, edsmid); if (curnote != null) { // curnote uses local time to store if (localtime.Ticks > curnote.Time.Ticks) // if newer, add on (verified with EDSM 29/9/2016) { curnote.Note += ". EDSM: " + note; curnote.Time = localtime; curnote.EdsmId = edsmid; curnote.Update(); commentsadded++; } } else { curnote = new SystemNoteClass(); curnote.Note = note; curnote.Time = localtime; curnote.Name = name; curnote.Journalid = 0; curnote.EdsmId = edsmid; curnote.Add(); commentsadded++; } } mainForm.LogLine(string.Format("EDSM Comments downloaded/updated {0}", commentsadded)); } } } mainForm.LogLine("EDSM sync Done"); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exception ex:" + ex.Message); mainForm.LogLineHighlight("EDSM sync Exception " + ex.Message); } }
private void UpdateSystemRow(int rowindex) { if (rowindex < dataGridViewRouteSystems.Rows.Count && dataGridViewRouteSystems[0, rowindex].Value != null) { string sysname = dataGridViewRouteSystems[0, rowindex].Value.ToString(); var sys = GetSystem(sysname); dataGridViewRouteSystems[1, rowindex].Value = ""; if (rowindex > 0 && rowindex < dataGridViewRouteSystems.Rows.Count && dataGridViewRouteSystems[0, rowindex - 1].Value != null && dataGridViewRouteSystems[0, rowindex].Value != null) { string prevsysname = dataGridViewRouteSystems[0, rowindex - 1].Value.ToString(); var prevsys = GetSystem(prevsysname); if (sys != null && prevsys != null) { double dist = sys.Distance(prevsys); string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : ""; dataGridViewRouteSystems[1, rowindex].Value = strdist; } } dataGridViewRouteSystems[0, rowindex].Tag = sys; dataGridViewRouteSystems.Rows[rowindex].DefaultCellStyle.ForeColor = (sys != null && sys.HasCoordinate) ? discoveryform.theme.VisitedSystemColor : discoveryform.theme.NonVisitedSystemColor; if (sys != null) { string note = ""; SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(sys.Name, sys.EDSMID); if (sn != null && !string.IsNullOrWhiteSpace(sn.Note)) { note = sn.Note; } else { BookmarkClass bkmark = GlobalBookMarkList.Instance.FindBookmarkOnSystem(sys.Name); if (bkmark != null && !string.IsNullOrWhiteSpace(bkmark.Note)) { note = bkmark.Note; } else { var gmo = discoveryform.galacticMapping.Find(sys.Name); if (gmo != null && !string.IsNullOrWhiteSpace(gmo.description)) { note = gmo.description; } } } dataGridViewRouteSystems[2, rowindex].Value = note.WordWrap(60); dataGridViewRouteSystems.Rows[rowindex].Cells[0].ToolTipText = string.Format("{0:0.#},{1:0.#},{2:0.#}", sys.X, sys.Y, sys.Z); } if (sys == null && sysname != "") { dataGridViewRouteSystems.Rows[rowindex].ErrorText = "System not known to EDSM".T(EDTx.UserControlExpedition_EDSMUnk); } else { dataGridViewRouteSystems.Rows[rowindex].ErrorText = ""; } } }
public void UpdateSystemNote() { snc = SystemNoteClass.GetSystemNote(Journalid, IsFSDCarrierJump ? System.Name : null); // may be null }
private void StoreSystemNote() { string txt; try { EDSMClass edsm = new EDSMClass(); SQLiteDBClass db = new SQLiteDBClass(); edsm.apiKey = EDDiscoveryForm.EDDConfig.CurrentCommander.APIKey; edsm.commanderName = EDDiscoveryForm.EDDConfig.CurrentCommander.Name; if (currentSysPos == null || currentSysPos.curSystem == null) { return; } txt = richTextBoxNote.Text; if (currentSysPos.curSystem.Note == null) { currentSysPos.curSystem.Note = ""; } if (currentSysPos != null && !txt.Equals(currentSysPos.curSystem.Note)) { SystemNoteClass sn; List <SystemClass> systems = new List <SystemClass>(); if (SQLiteDBClass.globalSystemNotes.ContainsKey(currentSysPos.curSystem.SearchName)) { sn = SQLiteDBClass.globalSystemNotes[currentSysPos.curSystem.SearchName]; sn.Note = txt; sn.Time = DateTime.Now; sn.Update(); } else { sn = new SystemNoteClass(); sn.Name = currentSysPos.curSystem.name; sn.Note = txt; sn.Time = DateTime.Now; sn.Add(); } currentSysPos.curSystem.Note = txt; if (dataGridViewTravel.SelectedCells.Count > 0) // if we have selected (we should!) { dataGridViewTravel.Rows[dataGridViewTravel.SelectedCells[0].OwningRow.Index].Cells[3].Value = txt; } if (edsm.commanderName == null || edsm.apiKey == null) { return; } if (edsm.commanderName.Length > 1 && edsm.apiKey.Length > 1) { edsm.SetComment(sn); } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exception : " + ex.Message); System.Diagnostics.Trace.WriteLine(ex.StackTrace); LogTextHighlight("Exception : " + ex.Message); LogTextHighlight(ex.StackTrace); } }
private void UpdateSystemRow(int rowindex) { if (rowindex < dataGridViewRouteSystems.Rows.Count && dataGridViewRouteSystems[0, rowindex].Value != null) { string sysname = dataGridViewRouteSystems[0, rowindex].Value.ToString(); var sys = GetSystem(sysname); dataGridViewRouteSystems[1, rowindex].Value = ""; if (rowindex > 0 && rowindex < dataGridViewRouteSystems.Rows.Count && dataGridViewRouteSystems[0, rowindex - 1].Value != null && dataGridViewRouteSystems[0, rowindex].Value != null) { string prevsysname = dataGridViewRouteSystems[0, rowindex - 1].Value.ToString(); var prevsys = GetSystem(prevsysname); if (sys != null && prevsys != null) { double dist = SystemClass.Distance(sys, prevsys); string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : ""; dataGridViewRouteSystems[1, rowindex].Value = strdist; } } dataGridViewRouteSystems[0, rowindex].Tag = sys; dataGridViewRouteSystems.Rows[rowindex].DefaultCellStyle.ForeColor = (sys != null && sys.HasCoordinate) ? _discoveryForm.theme.VisitedSystemColor : _discoveryForm.theme.NonVisitedSystemColor; if (sys != null) { string note = ""; SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(sys.name, sys.id_edsm); if (sn != null && !string.IsNullOrWhiteSpace(sn.Note)) { note = sn.Note; } else { BookmarkClass bkmark = BookmarkClass.bookmarks.Find(x => x.StarName != null && x.StarName.Equals(sys.name)); if (bkmark != null && !string.IsNullOrWhiteSpace(bkmark.Note)) { note = bkmark.Note; } else { var gmo = _discoveryForm.galacticMapping.Find(sys.name); if (gmo != null && !string.IsNullOrWhiteSpace(gmo.description)) { note = gmo.description; } } } dataGridViewRouteSystems[2, rowindex].Value = Tools.WordWrap(note, 60); } if (sys == null && sysname != "") { dataGridViewRouteSystems.Rows[rowindex].ErrorText = "System not known to EDSM"; } else { dataGridViewRouteSystems.Rows[rowindex].ErrorText = ""; } } }