Пример #1
0
        /// <summary>
        /// Load the collection of train trips
        /// </summary>
        private static void LoadTrips()
        {
            // Load the trips
            int numberOfTrips = PersistentStorage.GetIntItem(TrainTripsSizeName, 0);

            trips = new List <TrainTrip>();

            for (int tripIndex = 0; tripIndex < numberOfTrips; ++tripIndex)
            {
                TrainTrip tripToAdd = new TrainTrip {
                    From     = PersistentStorage.GetStringItem(TrainTripFromName + tripIndex, ""),
                    To       = PersistentStorage.GetStringItem(TrainTripToName + tripIndex, ""),
                    FromCode = PersistentStorage.GetStringItem(TrainTripFromCodeName + tripIndex, ""),
                    ToCode   = PersistentStorage.GetStringItem(TrainTripToCodeName + tripIndex, "")
                };
                trips.Add(tripToAdd);
            }

            // Get the current trip
            selectedTrip = PersistentStorage.GetIntItem(TrainTripSelectedName, 0);

            // Make sure that the selected trip is valid
            if (selectedTrip >= trips.Count)
            {
                selectedTrip = trips.Count - 1;
                PersistentStorage.SetIntItem(TrainTripSelectedName, selectedTrip);
            }
        }
Пример #2
0
        /// <summary>
        /// Load upto MaxStations station names from the persistent storage
        /// </summary>
        private static void LoadStations()
        {
            // Load the stations
            int numberOfRecentStations = Math.Min(PersistentStorage.GetIntItem(RecentStationsSizeName, 0), MaxStations);

            stations = new List <string>();

            for (int stationIndex = 0; stationIndex < numberOfRecentStations; ++stationIndex)
            {
                stations.Add(PersistentStorage.GetStringItem(RecentStationName + stationIndex, ""));
            }
        }