private void UpdateChannelPrograms(ChannelProgramListItem channel) { int programCount = channel.Programs.Count; if (programCount > 0) { ProgramListItem firstItem = (ProgramListItem) channel.Programs[0]; ProgramListItem lastItem = (ProgramListItem) channel.Programs[programCount - 1]; DateTime timeFrom = firstItem.Program.StartTime; DateTime timeTo = lastItem.Program.EndTime; if (timeFrom > GuideStartTime) ReloadStart(channel, timeFrom); else TrimStart(channel.Programs); if (timeTo < GuideEndTime) ReloadEnd(channel, timeTo); else TrimEnd(channel.Programs); foreach (ProgramListItem program in channel.Programs) program.Program.UpdateDuration(GuideStartTime, GuideEndTime); RemoveZeroDurations(channel.Programs); } channel.Programs.FireChange(); }
private void ReloadStart(ChannelProgramListItem channel, DateTime firstFromTime) { ItemsList newItems = GetProgramsList(channel.Channel, GuideStartTime, firstFromTime.AddSeconds(-1)); int idx = 0; foreach (ListItem listItem in newItems) channel.Programs.Insert(idx++, listItem); }
/// <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 ReloadEnd(ChannelProgramListItem channel, DateTime lastEndTime) { ItemsList newItems = GetProgramsList(channel.Channel, lastEndTime.AddSeconds(1), GuideEndTime); foreach (ListItem listItem in newItems) channel.Programs.Add(listItem); }
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, GetNowAndNextProgramsList(currentChannel)) { Command = new MethodDelegateCommand(() => Tune(currentChannel)) }; item.AdditionalProperties["CHANNEL"] = channel; _channelList.Add(item); } CurrentGroupChannels.FireChange(); }