public void updateStations(string routeName)//
        {
            StationList.Clear();
            Task.Run(async() =>
            {
                string routeID = Database.routeID_NameMap.FirstOrDefault(x => x.Value == routeName).Key;
                SelectedRoute  = routeID;
                ScheduleList   = await DataQuery.getSchedule(routeID, RouteDirection.direction_id);

                if (Database.routeAbrevMap.ContainsKey(routeName))
                {
                    LineCode  = Database.routeAbrevMap[routeName];
                    LineColor = Configs.lineColorMap[LineCode];
                }
                else
                {
                    LineCode  = routeName;
                    LineColor = "#AEA29F";
                }

                List <Station> stationList   = await DataQuery.getStations(routeID);
                Station start_st             = stationList[0], final_st = stationList[stationList.Count - 1];
                RouteDirection.start_station = start_st.attributes.name;
                RouteDirection.final_station = final_st.attributes.name;

                foreach (Station station in stationList)
                {
                    StationList.Add(station.attributes.name);
                }
            }).Wait();
        }
        internal void SeachStation(string p)
        {
            if (string.IsNullOrEmpty(p))
            {
                StationList.Clear();
            }
            else
            {
                p = p.ToLower();


                var stations = StationNameService.GetStations().Where(x => x.Name.ToLower().StartsWith(p)).OrderBy(x => x.Sort).Take(7);

                if (stations.Count() < 7)
                {
                    var extraStations = StationNameService.GetStations().Where(x => x.StartsWith(p)).OrderBy(x => x.Sort).Take(7 - stations.Count());

                    stations = stations.Union(extraStations);
                }

                StationList.Clear();

                foreach (var s in stations)
                {
                    StationList.Add(s);
                }
            }
        }
Пример #3
0
        internal void InitValues(string from, string to, string via, bool keepValues, DateTime?dateTime)
        {
            Settings = SettingService.GetSettings();

            if (!keepValues && !string.IsNullOrEmpty(from))
            {
                VanStation = StationNameService.GetStationByName(from);
                if (VanStation == null)
                {
                    VanStation = StationNameService.GetStationByCode(from);
                }
            }
            else if (!keepValues)
            {
                VanStation = null;
                GetGpsStation();
            }

            if (!keepValues && !string.IsNullOrEmpty(to))
            {
                NaarStation = StationNameService.GetStationByName(to);
            }
            else if (!keepValues)
            {
                NaarStation = null;
            }

            if (!keepValues && !string.IsNullOrEmpty(via))
            {
                ViaStation = StationNameService.GetStationByName(via);
            }
            else if (!keepValues)
            {
                ViaStation = null;
            }

            if (!keepValues)
            {
                if (dateTime.HasValue)
                {
                    Date = dateTime.Value.Date;
                    Time = dateTime.Value;
                }
                else
                {
                    Date = DateTime.Now;
                    Time = DateTime.Now;
                }

                IsYearCard     = Settings.HasYearCard;
                IsHogesnelheid = Settings.UseHsl;
                IsViaVisible   = false;
            }

            StationList.Clear();
        }
        /// <summary>
        /// Search a station
        /// </summary>
        /// <param name="p"></param>
        internal void SeachStation(string p)
        {
            if (string.IsNullOrEmpty(p))
            {
                StationList.Clear();

                ShowFavoriteStations();
            }
            else
            {
                p = p.ToLower();

                //Do a normal starts with
                var stations = StationNameService.GetStations().Where(x => x.Name.ToLower().StartsWith(p)).OrderBy(x => x.Sort).Take(8);

                if (stations.Count() < 8)
                {
                    //Search extra names codes etc
                    var extraStations = StationNameService.GetStations().Where(x => x.StartsWith(p)).OrderBy(x => x.Sort).Take(8 - stations.Count());

                    stations = stations.Union(extraStations);
                }

                //No results? Search international
                if (stations.Count() <= 2)
                {
                    //Search extra names codes etc
                    var extraStations = StationNameService.GetStations(true).Where(x => x.StartsWith(p)).OrderBy(x => x.Sort).Take(8);

                    //Remove stations already found from extraStations
                    var dubbel = extraStations.Where(x => stations.Select(s => s.Code).Contains(x.Code)).ToList();
                    extraStations = extraStations.Except(dubbel);

                    stations = stations.Union(extraStations);
                }

                StationList.Clear();

                foreach (var station in stations)
                {
                    StationList.Add(station);
                }
            }
        }
        ////public override void Cleanup()
        ////{
        ////    // Clean own resources if needed

        ////    base.Cleanup();
        ////}

        internal void Load()
        {
            Settings = SettingService.GetSettings();

            StationList.Clear();
        }
        /// <summary>
        /// Reset before a new pick
        /// </summary>
        internal void InitForNewPick()
        {
            StationList.Clear();

            ShowFavoriteStations();
        }