Exemplo n.º 1
0
        /// <summary>
        /// For the channels in the specified channel collection, if any of them are CurrentFavorites, we will assume that
        /// the argument has more current information, and we'll copy that info.
        /// </summary>
        /// <param name="knownChannels">the most up to date channel information</param>
        public void UpdateFavorites(ChannelCollection knownChannels)
        {
            for (int i = 0; i < CurrentFavorites.Items.Count; i++)
            {
                int index = knownChannels.IndexOf(CurrentFavorites.Items[i]);
                if (index > -1)
                {
                    CurrentFavorites.Items[i] = knownChannels.Items[index];
                }
            }

            RecreateThumbnails();
        }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="bypassCache"> </param>
        /// <param name="playlistTypes"> </param>
        /// <returns> </returns>
        public virtual ChannelCollection <TChannel> GetView(bool bypassCache, StationType playlistTypes)
        {
            // assume view is set
            IsViewSet = true;

            _channels = GetItem(_channels);

            if ((bypassCache) || (_channels == null))
            {
                _loader = new ChannelLoader <TChannel, TTrack>(Settings.Default.DIPlaylistXml);
                // this should not be hardcoded
                //_channels = ChannelLoaderService<TChannel>.LoadChannels(bypassCache);
                _channels = _loader.LoadChannels(bypassCache);

                //if (!IsViewSet)
                //{
                // ParseSortSettings();
                IsViewSet = false;
                //}

                // assign siteIcons
                _channels.ForEach(t =>
                {
                    if (t.SiteName.Contains(Resources.Properties.Resources.DIHomePage))
                    {
                        t.PlaylistType = StationType.DI;
                        t.SiteIcon     = Resources.Properties.Resources.DIIconNew;
                    }
                    else if (t.SiteName.Contains(Resources.Properties.Resources.SkyHomePage))
                    {
                        t.PlaylistType = StationType.Sky;
                        t.SiteIcon     = Resources.Properties.Resources.SkyIcon;
                    }
                    else
                    {
                        t.PlaylistType = StationType.External;
                        // t.SiteIcon = Resources.Properties.Resources.
                    }
                });

                // now remove channels that aren't favorites specified in settings
                if (playlistTypes == StationType.Custom)
                {
                    _channels.RemoveAll(t => !Settings.Default.PlaylistFavorites.Contains(t.ChannelName));
                }
                else
                {
                    _channels.RemoveAll(t => (t.PlaylistType & playlistTypes) == 0);
                }

                Sort(_channels);
                _channels.ForEach(t => { t.IsAlternating = (_channels.IndexOf(t) % 2 == 0); });

                InsertItem(_channels);

                // only fire the event if the view changed, cache was bypassed on purpose
                // OnChannelViewChanged(this, new ChannelViewChangedEventArgs<ChannelCollection<IChannel>>(_channels as ChannelCollection<IChannel>));
            }

            return(_channels);
        }