Example #1
0
        /// <summary>
        /// </summary>
        private void PickRandomBackground()
        {
            var featuredMix =
                this.Latest.Mixes.Where(mix => !mix.IsExplicit)
                .Skip(this.random.Next(this.Latest.Mixes.Count - 2))
                .FirstOrDefault();
            Uri url = this.Recent.Mixes.Where(p => p.IsNowPlaying).Select(p => p.ImageUrl).FirstOrDefault()
                      ?? this.BackgroundImageUrl
                      ?? (featuredMix != null ? featuredMix.ImageUrl : null)
                      ?? DefaultBackground;

            if (this.BackgroundImageUrl != url || this.BackgroundImage == null)
            {
                if (!this.Recent.Mixes.Any(p => p.IsNowPlaying) && featuredMix != null)
                {
                    // No now playing so use the background mix
                    BackgroundPinService.UpdateFlipTile("Flat Beats", featuredMix.MixName, featuredMix.Description, featuredMix.Description, 0, new Uri("/", UriKind.Relative), featuredMix.ThumbnailUrl, featuredMix.ThumbnailUrl, null, featuredMix.ImageUrl, null);
                }

                this.BackgroundImageUrl = url;
                this.BackgroundImage    = new ImageBrush
                {
                    ImageSource = new BitmapImage(url)
                    {
                        CreateOptions = BitmapCreateOptions.DelayCreation
                    },
                    Opacity = 0.3,
                    Stretch = Stretch.UniformToFill
                };
            }
        }
 /// <summary>
 /// The update pinned state.
 /// </summary>
 private void UpdatePinnedState()
 {
     if (BackgroundPinService.IsPinned(this.mixData))
     {
         this.PinToStartCommand.Text = StringResources.Command_UnpinStart;
     }
     else
     {
         this.PinToStartCommand.Text = StringResources.Command_PinToStart;
     }
 }
Example #3
0
        public static void PinToStart(MixContract mix)
        {
            if (!BackgroundPinService.IsPinned(mix))
            {
                var tileUrl = GetPlayPageUrl(mix);
                if (tileUrl == null)
                {
                    return;
                }

                if (PlatformHelper.IsWindowsPhone78OrLater)
                {
                    // Get the new FlipTileData type.
                    Type flipTileDataType = Type.GetType("Microsoft.Phone.Shell.FlipTileData, Microsoft.Phone");

                    // Get the ShellTile type so we can call the new version of "Update" that takes the new Tile templates.
                    Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");
                    if (flipTileDataType == null || shellTileType == null)
                    {
                        return;
                    }

                    // Get the constructor for the new FlipTileData class and assign it to our variable to hold the Tile properties.
                    var c = flipTileDataType.GetConstructor(new Type[] { });
                    if (c == null)
                    {
                        return;
                    }

                    var updateTileData = c.Invoke(null);
                    // UpdateFlipTile(mix.Name, mix.Name, mix.Description, mix.Description, mix.TrackCount, tileUrl, mix.Cover.ThumbnailUrl, mix.Cover.ThumbnailUrl, null, mix.Cover.OriginalUrl, null, false);


                    // Set the properties.
                    SetProperty(updateTileData, "Title", mix.Name ?? string.Empty);
                    SetProperty(updateTileData, "Count", mix.TrackCount);
                    SetProperty(updateTileData, "BackTitle", mix.Name ?? string.Empty);
                    SetProperty(updateTileData, "BackContent", mix.Description ?? string.Empty);
                    SetProperty(updateTileData, "SmallBackgroundImage", mix.Cover.ThumbnailUrl ?? ResetUrl);
                    SetProperty(updateTileData, "BackgroundImage", mix.Cover.ThumbnailUrl ?? ResetUrl);
                    SetProperty(updateTileData, "BackBackgroundImage", ResetUrl);
                    SetProperty(updateTileData, "WideBackgroundImage", mix.Cover.OriginalUrl ?? ResetUrl);
                    SetProperty(updateTileData, "WideBackBackgroundImage", ResetUrl);
                    SetProperty(updateTileData, "WideBackContent", mix.Description ?? string.Empty);

                    // Invoke the new version of ShellTile.Update.
                    var createMethod = shellTileType.GetMethods().FirstOrDefault(m => m.Name == "Create" && m.GetParameters().Length == 3);
                    if (createMethod != null)
                    {
                        createMethod.Invoke(null, new[] { tileUrl, updateTileData, true });
                        return;
                    }
                }

                // Fallback to the WinPhone 7.0 way
                ShellTile.Create(
                    tileUrl,
                    new StandardTileData
                {
                    Title               = mix.Name ?? string.Empty,
                    BackContent         = mix.Description ?? string.Empty,
                    BackgroundImage     = mix.Cover.ThumbnailUrl ?? ResetUrl,
                    BackTitle           = mix.Name ?? string.Empty,
                    BackBackgroundImage = ResetUrl,
                    Count               = mix.TrackCount
                });
            }
        }