Esempio n. 1
0
        private void ShowDepartures(string from, string to, bool actSilently)
        {
            var allStations           = Stations.GetAll();
            var fromStationCandidates = allStations.Where(x => MainAndFilterPage.Filter(from, null, null, x)).ToArray();
            var fromStation           = fromStationCandidates.Length == 1 ? fromStationCandidates[0] : null;

            ShowDepartures(allStations, fromStation, from, to, actSilently);
        }
Esempio n. 2
0
        private void ShowDepartures(string to, bool actSilently)
        {
            var currentPosition = LocationService.CurrentPosition;

            if (currentPosition != null && !currentPosition.IsUnknown)
            {
                var from = Stations.GetNearest(LatLong.Create(currentPosition.Latitude, currentPosition.Longitude), 1)[0];
                ShowDepartures(Stations.GetAll(), from.Item2, null, to, actSilently);
            }
            else
            {
                OnError();
            }
        }
Esempio n. 3
0
        public MainAndFilterPage()
        {
            InitializeComponent();
            var allStationsView = new CollectionViewSource {
                Source = Stations.GetAll()
            }.View;

            allStationsView.Filter  = x => Filter(filter.Text, fromStation, excludeStation, (Station)x);
            allStations.ItemsSource = allStationsView;
            Observable.FromEvent <TextChangedEventArgs>(filter, "TextChanged")
            .Throttle(TimeSpan.FromMilliseconds(300))
            .Subscribe(_ => Dispatcher.BeginInvoke(() => allStationsView.Refresh()));
            Observable.FromEvent <KeyEventArgs>(filter, "KeyDown")
            .Where(x => x.EventArgs.Key == Key.Enter)
            .Subscribe(_ => Dispatcher.BeginInvoke(() =>
            {
                var stations = allStationsView.Cast <Station>().ToArray();
                if (stations.Length == 1)
                {
                    GoToStation(stations[0]);
                }
            }));
            CommonApplicationBarItems.Init(this);
        }