public void ReadJournals(HistoryEntry currenthe) { dataGridViewCommanders.AutoGenerateColumns = false; // BEFORE assigned to list.. dataGridViewCommanders.DataSource = EDCommander.GetListCommanders(); if (currenthe != null) { DLLManager.Refresh(EDCommander.Current.Name, EDDDLLCallerHE.CreateFromHistoryEntry(currenthe)); if (currenthe.Commander.SyncToInara) { EliteDangerousCore.Inara.InaraSync.Refresh(LogLine, currenthe, currenthe.Commander); } } }
HistoryEntry lastuihe = null; // last he that the ui was updated on.. used during store to try and prevent too much thrash public void HistoryEvent(HistoryEntry he, bool stored, bool recent) // recent is true on stored for last few entries.. { bool dontupdateui = (lasthe != null && stored && !recent); if (!dontupdateui) // so, if we have displayed one, and we are in stored reply, and not a recent entry.. don't update UI { bool reposbut = false; if (lastuihe == null || !he.Commander.Name.Equals(lastuihe.Commander.Name)) { labelCmdr.Text = he.Commander.Name; if (EDCommander.Current.Name != he.Commander.Name) { labelCmdr.Text += " Report clash " + EDCommander.Current.Name; } } if (lastuihe == null || he.Credits != lastuihe.Credits) { labelCredits.Text = he.Credits.ToString("N0"); } if (!labelSystem.Text.Equals(he.System.Name)) // because of StartJump rewriting the previous entry, we can't detect system names changes using UI { // which ends up we never seeing lastui.system.name being different to he.system.name extButtonEDSMSystem.Enabled = extButtonInaraSystem.Enabled = extButtonEDDBSystem.Enabled = true; labelSystem.Text = he.System.Name; reposbut = true; } if (lastuihe == null || !he.WhereAmI.Equals(lastuihe.WhereAmI)) { labelLocation.Text = he.WhereAmI; reposbut = true; } bool hasmarketid = he?.MarketID.HasValue ?? false; bool hasbodyormarketid = hasmarketid || he.FullBodyID.HasValue; if (lastuihe == null || extButtonInaraStation.Enabled != hasmarketid) { extButtonInaraStation.Enabled = extButtonEDDBStation.Enabled = hasmarketid; } if (lastuihe == null || extButtonSpanshStation.Enabled != hasbodyormarketid) { extButtonSpanshStation.Enabled = hasbodyormarketid; } if ((he.ShipInformation != null) != extButtonEDSY.Enabled) // enabled/visible causes effort, only do it if different { extButtonEDSY.Enabled = extButtonCoriolis.Enabled = he.ShipInformation != null; } if (he.ShipInformation != null && (lastuihe == null || lastuihe.ShipInformation == null || he.ShipInformation.ShipNameIdentType != lastuihe.ShipInformation.ShipNameIdentType)) { labelShip.Text = he.ShipInformation.ShipNameIdentType ?? "Unknown"; reposbut = true; } if (reposbut) { int maxx = Math.Max(labelSystem.Right, labelLocation.Right) + 2; extButtonEDSMSystem.Left = maxx; extButtonInaraSystem.Left = extButtonEDSMSystem.Right + 2; extButtonEDDBSystem.Left = extButtonInaraSystem.Right + 2; extButtonSpanshSystem.Left = extButtonEDDBSystem.Right + 2; extButtonInaraStation.Left = maxx; extButtonEDDBStation.Left = extButtonInaraStation.Right + 2; extButtonSpanshStation.Left = extButtonEDDBStation.Right + 2; extButtonCoriolis.Left = labelShip.Right + 2; extButtonEDSY.Left = extButtonCoriolis.Right + 2; } if (lastuihe == null || he.MaterialCommodity.DataCount != lastuihe.MaterialCommodity.DataCount || he.MaterialCommodity.CargoCount != lastuihe.MaterialCommodity.CargoCount || he.MaterialCommodity.MaterialsCount != lastuihe.MaterialCommodity.MaterialsCount) { labelData.Text = he.MaterialCommodity.DataCount.ToString(); labelCargo.Text = he.MaterialCommodity.CargoCount.ToString(); labelMaterials.Text = he.MaterialCommodity.MaterialsCount.ToString(); } he.journalEntry.FillInformation(out string info, out string detailed); LogLine(EDDConfig.Instance.ConvertTimeToSelectedFromUTC(he.EventTimeUTC) + " " + he.journalEntry.SummaryName(he.System) + ": " + info); if (he.MissionList != null) { labelMissionCount.Text = he.MissionList.Missions.Count.ToString(); string mtext = ""; if (he.MissionList.Missions.Count > 0) { var list = he.MissionList.GetAllCurrentMissions(DateTime.Now); if (list.Count > 0) { var last = list[0]; mtext = BaseUtils.FieldBuilder.Build("", last.Mission.LocalisedName, "", last.Mission.Expiry, "", last.Mission.DestinationSystem, "", last.Mission.DestinationStation); } } labelLatestMission.Text = mtext; } lastuihe = he; System.Diagnostics.Debug.WriteLine("Set lastuihe to " + lastuihe.System.Name); } if (!stored) { if (he.Commander.SyncToEdsm) { EDSMJournalSync.SendEDSMEvents(LogLine, he); } if (he.Commander.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EliteDangerousCore.EDDN.EDDNClass.IsEDDNMessage(he.EntryType, he.EventTimeUTC) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && he.Commander.SyncToEddn == true) { EliteDangerousCore.EDDN.EDDNSync.SendEDDNEvents(LogLine, he); } if (he.Commander.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, he); } screenshot.NewJournalEntry(he.journalEntry); } if (DLLManager.Count > 0) // if worth calling.. { DLLManager.NewJournalEntry(EDDDLLCallerHE.CreateFromHistoryEntry(he, stored), stored); } lasthe = he; }
public void HistoryEvent(HistoryEntry he, bool stored) { if (lasthe == null || he.Commander.Name != lasthe.Commander.Name) { labelCmdr.Text = he.Commander.Name; if (EDCommander.Current.Name != he.Commander.Name) { labelCmdr.Text += " Report clash " + EDCommander.Current.Name; } } if (lasthe == null || he.System.Name != lasthe.System.Name) { extButtonEDSM.Enabled = true; extButtonInaraSystem.Enabled = true; labelSystem.Text = he.System.Name; } if (lasthe == null || he.WhereAmI != lasthe.WhereAmI) { labelLocation.Text = he.WhereAmI; } extButtonEDSY.Enabled = extButtonCoriolis.Enabled = he.ShipInformation != null; if (he.ShipInformation != null && (lasthe == null || lasthe.ShipInformation == null || he.ShipInformation.ShipNameIdentType != lasthe.ShipInformation.ShipNameIdentType)) { labelShip.Text = he.ShipInformation.ShipNameIdentType ?? "Unknown"; } if (lasthe == null || he.MaterialCommodity.DataCount != lasthe.MaterialCommodity.DataCount || he.MaterialCommodity.CargoCount != lasthe.MaterialCommodity.CargoCount || he.MaterialCommodity.MaterialsCount != lasthe.MaterialCommodity.MaterialsCount) { labelData.Text = he.MaterialCommodity.DataCount.ToString(); labelCargo.Text = he.MaterialCommodity.CargoCount.ToString(); labelMaterials.Text = he.MaterialCommodity.MaterialsCount.ToString(); } if (lasthe == null || he.Credits != lasthe.Credits) { labelCredits.Text = he.Credits.ToString("N0"); } he.journalEntry.FillInformation(out string info, out string detailed); LogLine(he.EventTimeUTC + " " + he.journalEntry.EventTypeStr + " " + info); extButtonInaraStation.Enabled = he.IsDocked; if (he.MissionList != null) { labelMissionCount.Text = he.MissionList.Missions.Count.ToString(); string mtext = ""; if (he.MissionList.Missions.Count > 0) { var list = he.MissionList.GetAllCurrentMissions(DateTime.Now); if (list.Count > 0) { var last = list[0]; mtext = BaseUtils.FieldBuilder.Build("", last.Mission.LocalisedName, "", last.Mission.Expiry, "", last.Mission.DestinationSystem, "", last.Mission.DestinationStation); } } labelLatestMission.Text = mtext; } lasthe = he; if (!stored) { if (he.Commander.SyncToEdsm) { EDSMJournalSync.SendEDSMEvents(LogLine, he); } if (he.Commander.SyncToIGAU) { EliteDangerousCore.IGAU.IGAUSync.NewEvent(LogLine, he); } if (EliteDangerousCore.EDDN.EDDNClass.IsEDDNMessage(he.EntryType, he.EventTimeUTC) && he.AgeOfEntry() < TimeSpan.FromDays(1.0) && he.Commander.SyncToEddn == true) { EliteDangerousCore.EDDN.EDDNSync.SendEDDNEvents(LogLine, he); } if (he.Commander.SyncToInara) { EliteDangerousCore.Inara.InaraSync.NewEvent(LogLine, he); } if (DLLManager.Count > 0) // if worth calling.. { DLLManager.NewJournalEntry(EDDDLLCallerHE.CreateFromHistoryEntry(he)); } screenshot.NewJournalEntry(he.journalEntry); } }