public FindStationInfoPage()
        {
            InitializeComponent();

            BindingContext = new FindStationInfoPageViewModel();

            foreach (var cached in StationInfoCached.FetchStationInfoData())
            {
                favoritesStackLayout.Children.Add(new FavoriteItemContentView(favoritesStackLayout, scrollView, cached, stopEntry));
            }
        }
        private void removeButton_Click(object sender, EventArgs e)
        {
            foreach (StationInfoCached item in favoritesListBox.CheckedItems)
            {
                item.Remove();
            }

            favorites = StationInfoCached.FetchStationInfoData().ToList();

            favoritesListBox.Items.Clear();
            foreach (var item in favorites)
            {
                favoritesListBox.Items.Add(item);
            }

            removeButton.Enabled = favoritesListBox.CheckedItems.Count > 0;
            findButton.Enabled   = favoritesListBox.CheckedItems.Count > 0;
        }
        public FavoriteStationsWindow()
        {
            InitializeComponent();

            Settings.Theme.Apply(this);

            stationTextBox.Text = Settings.Localization.Station;
            addButton.Text      = Settings.Localization.Add;
            removeButton.Text   = Settings.Localization.Remove;
            findButton.Text     = Settings.Localization.Find;

            favorites = StationInfoCached.FetchStationInfoData().ToList();

            foreach (var item in favorites)
            {
                favoritesListBox.Items.Add(item);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updates all the cached results.
        /// </summary>
        public static async Task UpdateCachedResultsAsync(bool forceUpdate = false)
        {
            Task ForEachFetchedResult <Res, Req>(IEnumerable <CachedData <Res, Req> > collection, Func <Req, bool, Task> processAsync) where Res : ResponseBase where Req : RequestBase
            {
                return(Task.Run(() =>
                {
                    foreach (var fetched in collection)
                    {
                        if (forceUpdate || fetched.ShouldBeUpdated)
                        {
                            processAsync(fetched.ConstructNewRequest(), forceUpdate);
                        }
                    }
                }));
            }

            await Task.WhenAll(
                ForEachFetchedResult(StationInfoCached.FetchStationInfoData(), CacheDepartureBoardAsync),
                ForEachFetchedResult(LineInfoCached.FetchLineInfoData(), CacheDepartureBoardAsync),
                ForEachFetchedResult(JourneyCached.FetchJourneyData(), CacheJourneyAsync)
                );
        }