protected void UpdateForChannel(IChannel channel, ProgramProperties current, ProgramProperties next, AbstractProperty channelNameProperty, AbstractProperty progressProperty)
 {
   channelNameProperty.SetValue(channel.Name);
   IProgram currentProgram;
   IProgram nextProgram;
   if (_tvHandler.ProgramInfo.GetNowNextProgram(channel, out currentProgram, out nextProgram))
   {
     current.SetProgram(currentProgram);
     next.SetProgram(nextProgram);
     double progress = (DateTime.Now - currentProgram.StartTime).TotalSeconds / (currentProgram.EndTime - currentProgram.StartTime).TotalSeconds * 100;
     progressProperty.SetValue(progress);
   }
   else
   {
     current.SetProgram(null);
     next.SetProgram(null);
     progressProperty.SetValue(100d);
   }
 }
    private ProgramListItem BuildProgramListItem(IProgram program)
    {
      ProgramProperties programProperties = new ProgramProperties();
      IProgram currentProgram = program;
      programProperties.SetProgram(currentProgram);

      ProgramListItem item = new ProgramListItem(programProperties)
        {
          Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram))
        };
      item.AdditionalProperties["PROGRAM"] = currentProgram;
      return item;
    }
    private PlaceholderListItem NoProgramPlaceholder(IChannel channel, DateTime? startTime, DateTime? endTime)
    {
      ILocalization loc = ServiceRegistration.Get<ILocalization>();
      DateTime today = GuideStartTime.GetDay();
      ProgramProperties programProperties = new ProgramProperties();
      Program placeholderProgram = new Program
                              {
                                ProgramId = -1,
                                ChannelId = channel.ChannelId,
                                Title = loc.ToString("[SlimTvClient.NoProgram]"),
                                StartTime = startTime ?? today,
                                EndTime = endTime ?? today.AddDays(1)
                              };
      programProperties.SetProgram(placeholderProgram);

      var item = new PlaceholderListItem(programProperties)
      {
        Command = new MethodDelegateCommand(() => ShowProgramActions(placeholderProgram))
      };
      item.AdditionalProperties["PROGRAM"] = placeholderProgram;

      return item;
    }
    private PlaceholderListItem NoProgramPlaceholder(IChannel channel, DateTime? startTime, DateTime? endTime)
    {
      ILocalization loc = ServiceRegistration.Get<ILocalization>();
      DateTime today = FormatHelper.GetDay(DateTime.Now);
      ProgramProperties programProperties = new ProgramProperties(GuideStartTime, GuideEndTime);
      Program placeholderProgram = new Program
                              {
                                ChannelId = channel.ChannelId,
                                Title = loc.ToString("[SlimTvClient.NoProgram]"),
                                StartTime = startTime.HasValue ? startTime.Value : today,
                                EndTime = endTime.HasValue? endTime.Value : today.AddDays(1)
                              };
      programProperties.SetProgram(placeholderProgram);
      
      var item = new PlaceholderListItem(programProperties);
      item.AdditionalProperties["PROGRAM"] = placeholderProgram;

      return item;
    }
    protected override void UpdatePrograms()
    {
      _programsList.Clear();
      if (_channel != null)
      {
        if (_tvHandler.ProgramInfo.GetPrograms(_channel, DateTime.Now.AddHours(-2), DateTime.Now.AddHours(24), out _programs))
        {
          foreach (IProgram program in _programs)
          {
            // Use local variable, otherwise delegate argument is not fixed
            ProgramProperties programProperties = new ProgramProperties();
            IProgram currentProgram = program;
            programProperties.SetProgram(currentProgram);

            ProgramListItem item = new ProgramListItem(programProperties)
                              {
                                Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram))
                              };
            item.AdditionalProperties["PROGRAM"] = currentProgram;

            _programsList.Add(item);
          }
        }
        ProgramsList.FireChange();
      }
      else
        _programs = null;
    }
    private void FillProgramsList()
    {
      _programsList.Clear();

      foreach (IProgram program in _programs)
      {
        // Use local variable, otherwise delegate argument is not fixed
        ProgramProperties programProperties = new ProgramProperties();
        IProgram currentProgram = program;
        programProperties.SetProgram(currentProgram);

        if (ProgramComparer.Instance.Equals(currentProgram, program))
        {
        }

        ProgramListItem item = new ProgramListItem(programProperties)
        {
          Command = new MethodDelegateCommand(() =>
          {
            var isSingle = programProperties.IsScheduled;
            var isSeries = programProperties.IsSeriesScheduled;
            if (isSingle || isSeries)
              CancelSchedule(currentProgram);
            else
              RecordSeries(currentProgram);
          })
        };
        item.AdditionalProperties["PROGRAM"] = currentProgram;
        item.Selected = _lastProgramId == program.ProgramId; // Restore focus

        _programsList.Add(item);
      }

      _programsList.FireChange();
    }
    private ListItem CreateProgramItem(IProgram program, ISchedule schedule)
    {
      ProgramProperties programProperties = new ProgramProperties();
      IProgram currentProgram = program;
      programProperties.SetProgram(currentProgram);

      ListItem item = new ProgramListItem(programProperties)
      {
        Command = new MethodDelegateCommand(() => ShowActions(schedule, program))
      };
      IChannel channel;
      if (_tvHandler.ChannelAndGroupInfo.GetChannel(currentProgram.ChannelId, out channel))
        item.SetLabel("ChannelName", channel.Name);
      item.SetLabel("ScheduleType", string.Format("[SlimTvClient.ScheduleRecordingType_{0}]", schedule.RecordingType));
      item.AdditionalProperties["PROGRAM"] = currentProgram;
      item.AdditionalProperties["SCHEDULE"] = schedule;
      return item;
    }
    private void FillProgramsList()
    {
      _programsList.Clear();

      bool isSingle = false;
      bool isSeries = false;
      foreach (IProgram program in _programs)
      {
        // Use local variable, otherwise delegate argument is not fixed
        ProgramProperties programProperties = new ProgramProperties();
        IProgram currentProgram = program;
        programProperties.SetProgram(currentProgram);

        if (ProgramComparer.Instance.Equals(_selectedProgram, program))
        {
          isSingle = programProperties.IsScheduled;
          isSeries = programProperties.IsSeriesScheduled;
        }

        ProgramListItem item = new ProgramListItem(programProperties)
        {
          Command = new MethodDelegateCommand(() => CreateOrDeleteSchedule(currentProgram))
        };
        item.AdditionalProperties["PROGRAM"] = currentProgram;
        item.Selected = _lastProgramId == program.ProgramId; // Restore focus

        _programsList.Add(item);
      }

      // "Record" buttons are related to properties, for schedules we need to keep them to "Cancel record" state.
      if (_isScheduleMode)
        isSingle = isSeries = _selectedSchedule != null;

      IsSingleRecordingScheduled = isSingle;
      IsSeriesRecordingScheduled = isSeries;

      _programsList.FireChange();
    }