Exemple #1
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);
        }