protected override void UpdateChannels()
    {
      base.UpdateChannels();
      if (CurrentChannelGroup != null)
      {
        CurrentGroupName = CurrentChannelGroup.Name;
      }
      _channelList.Clear();

      bool isOneSelected = false;
      foreach (IChannel channel in ChannelContext.Channels)
      {
        // Use local variable, otherwise delegate argument is not fixed
        IChannel currentChannel = channel;

        bool isCurrentSelected = IsSameChannel(currentChannel, _lastTunedChannel);
        isOneSelected |= isCurrentSelected;
        ChannelProgramListItem item = new ChannelProgramListItem(currentChannel, null)
        {
          Programs = new ItemsList { GetNoProgramPlaceholder(), GetNoProgramPlaceholder() },
          Command = new MethodDelegateCommand(() => Tune(currentChannel)),
          Selected = isCurrentSelected
        };
        item.AdditionalProperties["CHANNEL"] = channel;
        _channelList.Add(item);
      }
      // Adjust channel list position
      ChannelContext.Channels.MoveTo(c => IsSameChannel(c, _lastTunedChannel));

      // If the current watched channel is not part of the channel group, set the "selected" property to first list item to make sure focus will be set to the list view
      if (!isOneSelected && _channelList.Count > 0)
        _channelList.First().Selected = true;

      // Load programs asynchronously, this increases performance of list building
      GetNowAndNextProgramsList_Async();
      CurrentGroupChannels.FireChange();
    }
 private void UpdateChannelPrograms(ChannelProgramListItem channel)
 {
   lock (channel.Programs.SyncRoot)
   {
     channel.Programs.Clear();
     if (_groupPrograms != null)
       _groupPrograms.Where(p => p.ChannelId == channel.Channel.ChannelId && p.StartTime < GuideEndTime).ToList().ForEach(p => channel.Programs.Add(BuildProgramListItem(p)));
     FillNoPrograms(channel, GuideStartTime, GuideEndTime);
   }
   // Don't notify about every channel programs list changes, only for channel list
   // channel.Programs.FireChange();
 }
    private void FillNoPrograms(ChannelProgramListItem channel, DateTime viewPortStart, DateTime viewPortEnd)
    {
      var programs = channel.Programs;
      if (programs.Count == 0)
      {
        programs.Add(NoProgramPlaceholder(channel.Channel, null, null));
        return;
      }
      ProgramListItem firstItem = programs.Cast<ProgramListItem>().First();
      ProgramListItem lastItem = programs.Cast<ProgramListItem>().Last();
      if (firstItem.Program.StartTime > viewPortStart)
        programs.Insert(0, NoProgramPlaceholder(channel.Channel, null, firstItem.Program.StartTime));

      if (lastItem.Program.EndTime < viewPortEnd)
        programs.Add(NoProgramPlaceholder(channel.Channel, lastItem.Program.EndTime, null));
    }
 private void BackgroundUpdateChannels()
 {
   //base.UpdateChannels();
   _channelList.Clear();
   foreach (IChannel channel in ChannelContext.Instance.Channels)
   {
     IChannel localChannel = channel;
     var channelProgramsItem = new ChannelProgramListItem(channel, new ItemsList())
       {
         Command = new MethodDelegateCommand(() => ShowSingleChannelGuide(localChannel))
       };
     UpdateChannelPrograms(channelProgramsItem);
     _channelList.Add(channelProgramsItem);
   }
   _channelList.FireChange();
 }
 /// <summary>
 /// Sets the "IsRunning" state of all programs.
 /// </summary>
 /// <param name="channel"></param>
 private static void UpdateChannelProgramsState(ChannelProgramListItem channel)
 {
   lock (channel.Programs.SyncRoot)
     foreach (ProgramListItem program in channel.Programs)
       program.Update();
 }
 private void UpdateChannelPrograms(ChannelProgramListItem channel)
 {
   channel.Programs.Clear();
   if (_groupPrograms != null)
     _groupPrograms.Where(p => p.ChannelId == channel.Channel.ChannelId && p.StartTime < GuideEndTime).ToList().ForEach(p => channel.Programs.Add(BuildProgramListItem(p)));
   FillNoPrograms(channel, GuideStartTime, GuideEndTime);
   channel.Programs.FireChange();
 }
 /// <summary>
 /// Sets the "IsRunning" state of all programs.
 /// </summary>
 /// <param name="channel"></param>
 private static void UpdateChannelProgramsState(ChannelProgramListItem channel)
 {
   foreach (ProgramListItem program in channel.Programs)
     program.Update();
 }
 private void BackgroundUpdateChannels(object threadArgument)
 {
   base.UpdateChannels();
   _channelList.Clear();
   if (_channels != null)
     foreach (IChannel channel in _channels)
     {
       var channelProgramsItem = new ChannelProgramListItem(channel, new ItemsList());
       UpdateChannelPrograms(channelProgramsItem);
       _channelList.Add(channelProgramsItem);
     }
   _channelList.FireChange();
 }
 protected void GetNowAndNextProgramsList(ChannelProgramListItem channelItem, IChannel channel)
 {
   IThreadPool threadPool = ServiceRegistration.Get<IThreadPool>();
   threadPool.Add(() =>
                    {
                      IProgram currentProgram;
                      IProgram nextProgram;
                      // We do not check return code here. Results for currentProgram or nextProgram can be null, this is ok here, as Program will be filled with placeholder.
                      if (_tvHandler.ProgramInfo == null)
                        return;
                      _tvHandler.ProgramInfo.GetNowNextProgram(channel, out currentProgram, out nextProgram);
                      CreateProgramListItem(currentProgram, channelItem.Programs[0]);
                      CreateProgramListItem(nextProgram, channelItem.Programs[1], currentProgram);
                    },
                    QueuePriority.Low
                  );
 }
    protected override void UpdateChannels()
    {
      base.UpdateChannels();
      if (_webChannelGroupIndex < _channelGroups.Count)
      {
        IChannelGroup currentGroup = _channelGroups[_webChannelGroupIndex];
        CurrentGroupName = currentGroup.Name;
      }
      _channelList.Clear();
      if (_channels == null)
        return;

      foreach (IChannel channel in _channels)
      {
        // Use local variable, otherwise delegate argument is not fixed
        IChannel currentChannel = channel;

        ChannelProgramListItem item = new ChannelProgramListItem(currentChannel, null)
        {
          Programs = new ItemsList { GetNoProgramPlaceholder(), GetNoProgramPlaceholder() },
          Command = new MethodDelegateCommand(() => Tune(currentChannel)),
          Selected = IsSameChannel(currentChannel, _lastTunedChannel)
        };
        item.AdditionalProperties["CHANNEL"] = channel;
        // Load programs asynchronously, this increases performance of list building
        GetNowAndNextProgramsList(item, currentChannel);
        _channelList.Add(item);
      }
      CurrentGroupChannels.FireChange();
    }