public string GetLibelleHourMinutLeftBeforeStart() { if (m_lsarret == null || m_lsarret.Count == 0) { return(""); } Arret starting = m_lsarret[m_lsarret.Count - 1]; string[] tHoursMinuts = starting.m_sTime?.Split('.'); if (tHoursMinuts == null || tHoursMinuts.Length < 2) { return(""); } DateTime dateStart = new DateTime(m_datetrajet.Year, m_datetrajet.Month, m_datetrajet.Day, int.Parse(tHoursMinuts[0]), int.Parse(tHoursMinuts[1]), 0); if (dateStart < DateTime.Now) { return(""); } TimeSpan diff = dateStart - DateTime.Now; string sRes = ""; if (diff.TotalDays > 1) { sRes += (int)diff.TotalDays + " jour "; } if (diff.TotalHours > 1) { sRes += (int)diff.Hours + " h "; } if (diff.TotalMinutes > 0) { sRes += (int)diff.Minutes + " min "; } return(sRes); }
public void GetArretFromLatLon(double latitude, double longitude, out Arret m_currentArret, out Arret m_nextArret) { //if (m_lsarret.Count > 0) m_currentArret = m_lsarret[m_lsarret.Count - 1]; //if (m_lsarret.Count > 1) m_nextArret = m_lsarret[m_lsarret.Count - 2]; int iIndexCurrentArret = m_lsarret.Count - 1; foreach (Arret pointPassage in m_lsarret) { //If p is X Xmeters around position (depending on Settings) if (pointPassage.IsAroundPosition(latitude, longitude)) { iIndexCurrentArret = m_lsarret.FindIndex(p => p == pointPassage); m_currentArret = pointPassage; if (iIndexCurrentArret > 0) { m_nextArret = m_lsarret[iIndexCurrentArret - 1]; } else { m_nextArret = null; } break; } } //Remove past stops if needed.... Don't do it here, it's done in the adapter int iRemoveFromIndex = iIndexCurrentArret + 1; int iRemoveCount = m_lsarret.Count - iRemoveFromIndex; if (iRemoveFromIndex < m_lsarret.Count) { m_lsarret.RemoveRange(iRemoveFromIndex, iRemoveCount); } }