예제 #1
0
        protected override async void OnInitialActivate()
        {
            var leagues = await _exileEngine.TradeLeaguesAsync();

            var tradeStatic = await _exileEngine.TradeStaticAsync();

            if (leagues == null || tradeStatic == null)
            {
                MessageBox.Show("Loading error. Please try again later.");
                RequestClose();
                return;
            }

            _eventAggregator.Publish(new LeaguesLoadedEvent(leagues.Result));

            ImageCacheService.CreateDirectories();
            foreach (var currency in tradeStatic.Result.SelectMany(s => s.Entries).Where(w => !string.IsNullOrWhiteSpace(w.Image)))
            {
                if (ImageCacheService.Exist(currency.Id))
                {
                    continue;
                }
                InitText = $"[Image] {currency.Text}";
                await _exileEngine.DownloadImageAsync(currency.Image, ImageCacheService.Get(currency.Id));
            }

            IsInitDone = true;

            _eventAggregator.Publish(new AppLoadedEvent());

            base.OnInitialActivate();
        }
예제 #2
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value is string currency)
     {
         return(ImageCacheService.Exist(currency) ? new Uri(ImageCacheService.Get(currency)) : Binding.DoNothing);
     }
     else
     {
         return(Binding.DoNothing);
     }
 }