private void EA_OnMissionEvent(object sender, missionEventArgs e) { try { this.Dispatcher.Invoke(delegate { lstElapsingMissions.Items.Clear(); foreach (double id in e.ElapsingMissions.Keys) { TimeSpan ts = e.ElapsingMissions[id].Expiry - DateTime.Now; bool negative = false; if (ts.TotalSeconds < 0) { negative = true; ts = ts.Negate(); } string formRemaining = (negative ? "-" : "") + (ts.Days > 0 ? ts.Days + ":" : "") + (ts.Hours > 0 || ts.Days > 0 ? ts.Hours.ToString().PadLeft(2, '0') + ":" : "") + ts.Minutes.ToString().PadLeft(2, '0') + ":" + ts.Seconds.ToString().PadLeft(2, '0'); lstElapsingMissions.Items.Add(formRemaining + " - " + e.ElapsingMissions[id].LocalisedName + " - " + e.ElapsingMissions[id].DestSys + " - " + e.ElapsingMissions[id].DestStat); } }); } catch { } }
public void MissionEvent(Dictionary <double, mission> em) { // Make sure someone is listening to event if (OnMissionEvent == null) { return; } missionEventArgs args = new missionEventArgs(em); OnMissionEvent(this, args); }
private void Pl_OnMissionEvent(object sender, missionEventArgs e) { MissionEvent(e.ElapsingMissions); }