private void HotTileJobExecution(Job<TileData> job, TileData tile) { try { var imageBackground = _random.NextDouble(); if (imageBackground > 0.2) { using (var session = new EchoNestSession(EchoNestModule.ApiKey)) { var response = session.Query<TopHottt>().Execute(bucket: ArtistBucket.Images); if (response != null && response.Status.Code == ResponseCode.Success) { var index = _random.Next(0, response.Artists.Count - 1); var artist = response.Artists[index]; if (artist.Images.Count > 0) { tile.Effect = _tileEffect; index = _random.Next(0, artist.Images.Count - 1); tile.BackgroundImage = new Uri(artist.Images[index].Url, UriKind.RelativeOrAbsolute); _dispatcher.BeginInvoke(new Action(() => { tile.Content = new TextBlock { Text = artist.Name, TextTrimming = TextTrimming.CharacterEllipsis, Margin = new Thickness(4), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; })); } } } } else { tile.Effect = null; tile.BackgroundImage = _tileIcon; tile.Content = null; } } catch (Exception e) { _logger.Log(e.ToString(), Category.Exception, Priority.Low); } }
public void Start() { _tileData = new TileData { Title = "Hot artists", BackgroundImage = _tileIcon }; _tileEffect = new ColorToneShaderEffect { DarkColor = Colors.Black, LightColor = Colors.DarkOrange, Desaturation = 0.5, Toned = 0.5 }; _tileEffect.Freeze(); _dispatcher.BeginInvoke(new Action(() => _tileService.Add<Views.Hot.HotArtistsView>(_tileData)), DispatcherPriority.ContextIdle); Job<TileData> job = new Job<TileData>("HotTile"); job.Data = _tileData; job.Run.From(DateTime.Now).Every.Seconds(60); _scheduler.SubmitJob(job, HotTileJobExecution); }
public Tile(Uri navigationUri, TileData data, string targetRegionName) { NavigationUri = navigationUri; Data = data; TargetRegionName = targetRegionName; }