Пример #1
0
        private async void RefreshNewsFeed()
        {
            if (_isUpdaterRunning == false)
            {
                _isUpdaterRunning = true;
                var uapi = new UserApi("5940771a096a5bf6e36f530769a6ba2f");
                try
                {
                    _newsFeed = await uapi.ApiNews(TempAppData.CurrentTown.id);

                    foreach (var town in _newsFeed)
                    {
                        town.bodyClean      = Regex.Replace(town.body, "<[^<]+?>", String.Empty);
                        town.bodyCleanShort = (town.bodyClean.Substring(1, 200) + " ...");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error accessing LocalD services, we can not fetch news at this time", ":(",
                                    MessageBoxButton.OK);
                }
                _isUpdaterRunning = false;

                NewsFeedBox.ItemsSource = _newsFeed;
            }
        }