Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pokemonList"></param>
        /// <remarks>
        /// advancedrei: The LiveTileUpdater is on teh App class, so this has to stay here for now. Might refactor later.
        /// </remarks>
        internal static void UpdateLiveTile(IList <PokemonData> pokemonList)
        {
            // Let's run this on a separate thread.
            Task.Run(() => {
                try
                {
                    TileContent tile = null;
                    var images       = new List <string>();
                    var mode         = SettingsService.Instance.LiveTileMode;

                    // Generate the images list for multi-image modes.
                    if (mode == LiveTileModes.People && mode == LiveTileModes.Photo)
                    {
                        images.AddRange(pokemonList.Select(c => new PokemonDataWrapper(c).ImageFileName));
                    }

                    if (mode != LiveTileModes.Peek)
                    {
                        App.LiveTileUpdater.EnableNotificationQueue(true);
                    }
                    else
                    {
                        App.LiveTileUpdater.EnableNotificationQueue(false);
                        LiveTileUpdater.Clear();
                    }

                    switch (mode)
                    {
                    case LiveTileModes.Off:
                        break;

                    case LiveTileModes.Peek:
                        foreach (PokemonData pokemonData in pokemonList)
                        {
                            if (LiveTileUpdater.GetScheduledTileNotifications().Count >= 300)
                            {
                                return;
                            }
                            var peekTile  = LiveTileHelper.GetPeekTile(new PokemonDataWrapper(pokemonData));
                            var scheduled = new ScheduledTileNotification(peekTile.GetXml(),
                                                                          DateTimeOffset.Now.AddSeconds((pokemonList.IndexOf(pokemonData) * 30) + 1));
                            LiveTileUpdater.AddToSchedule(scheduled);
                        }
                        break;

                    case LiveTileModes.People:
                        tile = LiveTileHelper.GetPeopleTile(images);
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Photo:
                        tile = LiveTileHelper.GetPhotosTile(images);
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Transparent:
                        tile = LiveTileHelper.GetImageTile("LiveTiles/Transparent/Square44x44Logo.scale-400.png");
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;
                    }
                    if (tile != null)
                    {
                        //Logger.Write(tile.GetXml().GetXml());
                    }
                }
                catch (Exception ex)
                {
                    Logger.Write(ex.Message);
                    if (!string.IsNullOrEmpty(ApplicationKeys.HockeyAppToken))
                    {
                        HockeyClient.Current.TrackException(ex);
                    }
                }
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pokemonList"></param>
        /// <remarks>
        /// advancedrei: The LiveTileUpdater is on teh App class, so this has to stay here for now. Might refactor later.
        /// </remarks>
        internal static void UpdateLiveTile(IList <PokemonData> pokemonList)
        {
            // Let's run this on a separate thread.
            Task.Run(() => {
                try
                {
                    TileContent tile = null;
                    var images       = new List <string>();
                    var mode         = SettingsService.Instance.LiveTileMode;

                    // Generate the images list for multi-image modes.
                    if (mode == LiveTileModes.People || mode == LiveTileModes.Photo)
                    {
                        images.AddRange(pokemonList.Select(c => new PokemonDataWrapper(c).ImageFileName));
                    }

                    foreach (ScheduledTileNotification scheduled in LiveTileUpdater.GetScheduledTileNotifications())
                    {
                        LiveTileUpdater.RemoveFromSchedule(scheduled);
                    }

                    if (mode != LiveTileModes.Peek)
                    {
                        LiveTileUpdater.EnableNotificationQueue(true);
                    }
                    else
                    {
                        LiveTileUpdater.EnableNotificationQueue(false);
                        LiveTileUpdater.Clear();
                    }

                    switch (mode)
                    {
                    case LiveTileModes.Off:
                        tile = LiveTileHelper.GetImageTile("Normal");
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Official:
                        tile = LiveTileHelper.GetImageTile("Official");
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Transparent:
                        tile = LiveTileHelper.GetImageTile("Transparent");
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Peek:
                        foreach (PokemonData pokemonData in pokemonList)
                        {
                            if (LiveTileUpdater.GetScheduledTileNotifications().Count >= 300)
                            {
                                return;
                            }
                            var peekTile  = LiveTileHelper.GetPeekTile(new PokemonDataWrapper(pokemonData));
                            var scheduled = new ScheduledTileNotification(peekTile.GetXml(),
                                                                          DateTimeOffset.Now.AddSeconds((pokemonList.IndexOf(pokemonData) * 30) + 1));
                            LiveTileUpdater.AddToSchedule(scheduled);
                        }
                        break;

                    case LiveTileModes.People:
                        tile = LiveTileHelper.GetPeopleTile(images);
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;

                    case LiveTileModes.Photo:
                        tile = LiveTileHelper.GetPhotosTile(images);
                        LiveTileUpdater.Update(new TileNotification(tile.GetXml()));
                        break;
                    }
                    if (tile != null)
                    {
                        GameClient.CurrentSession.Logger.Debug(tile.GetContent());
                    }
                }
                catch (Exception ex)
                {
                    GameClient.CurrentSession.Logger.Debug(ex.Message);
                    HockeyClient.Current.TrackException(ex);
                }
            });
        }