private void ChannelsContextMenu_Opening(object sender, CancelEventArgs e) { Items.Clear(); // SPLIT BUTTON if (_channels != null) { _channels.ForEach(channel => // cached channelCollection { int i = 0; Items.Add(channel.ChannelName, channel.SiteIcon.ToBitmap()); Items[i].Name = channel.Name; // KEY EACH ITEM OFF OF NAME ++i; }); } }
protected virtual void LoadFavoritesLists() { ChannelCollection <TChannel> channels = _channelView.GetView(true, StationType.All); ChannelCountLabel.Text = string.Format(P.Resources.ChannelsAvailableNumber, channels.Count.ToString()); channels.ForEach(channel => { switch (channel.PlaylistType) { case StationType.DI: { PlaylistLabel1.Text = string.Format("{0} {1}", channel.PlaylistType.ToString(), "Channels"); DIPlaylistCheckedList.Items.Add(channel.ChannelName, Settings.Default.PlaylistFavorites.Contains( channel.ChannelName)); break; } case StationType.Sky: { PlaylistLabel2.Text = string.Format("{0} {1}", channel.PlaylistType.ToString(), "Channels"); SkyPlaylistCheckedList.Items.Add(channel.ChannelName, Settings.Default.PlaylistFavorites.Contains( channel.ChannelName)); break; } //case PlaylistTypes.External: default: { PlaylistLabel3.Text = string.Format("{0} {1}", channel.PlaylistType.ToString(), "Channels"); ExternalPlaylistCheckBox.Items.Add(channel.ChannelName, Settings.Default.PlaylistFavorites.Contains( channel.ChannelName)); break; } } }); }
/// <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); }