protected ItemsList GetProgramsList(IChannel channel, DateTime referenceStart, DateTime referenceEnd) { ItemsList channelPrograms = new ItemsList(); if (_tvHandler.ProgramInfo.GetPrograms(channel, referenceStart, referenceEnd, out _programs)) { foreach (IProgram program in _programs) { // Use local variable, otherwise delegate argument is not fixed ProgramProperties programProperties = new ProgramProperties(GuideStartTime, GuideEndTime); IProgram currentProgram = program; programProperties.SetProgram(currentProgram); ProgramListItem item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram)) }; item.AdditionalProperties["PROGRAM"] = currentProgram; channelPrograms.Add(item); } } else { channelPrograms.Add(NoProgramPlaceholder()); } return(channelPrograms); }
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, channel); var item = new PlaceholderListItem(programProperties) { Command = new MethodDelegateCommand(() => ShowProgramActions(placeholderProgram)) }; item.AdditionalProperties["PROGRAM"] = placeholderProgram; return(item); }
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); 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(); }
protected void UpdatePrograms() { UpdateGuiProperties(); _programsList.Clear(); IChannel channel = CurrentChannel; 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, channel); ProgramListItem item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram)) }; item.AdditionalProperties["PROGRAM"] = currentProgram; _programsList.Add(item); } } ProgramsList.FireChange(); } else { _programs = null; } }
private ListItem CreateProgramItem(IProgram program, ISchedule schedule) { ProgramProperties programProperties = new ProgramProperties(); IProgram currentProgram = program; IChannel channel; if (!_tvHandler.ChannelAndGroupInfo.GetChannel(currentProgram.ChannelId, out channel)) { channel = null; } programProperties.SetProgram(currentProgram, channel); ListItem item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => ShowActions(schedule, program)) }; if (channel != null) { 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 async Task <ListItem> CreateScheduleItem(ISchedule schedule, IChannel channel) { ListItem item = null; if (channel != null) { var programResult = await _tvHandler.ProgramInfo.GetProgramsAsync(channel, schedule.StartTime, schedule.EndTime); if (programResult.Success) { ProgramProperties programProperties = new ProgramProperties(); programProperties.SetProgram(programResult.Result.First(), channel); item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => ShowSchedules()), }; item.SetLabel("Name", schedule.Name); } } if (item == null) { item = new ListItem("Name", schedule.Name) { Command = new MethodDelegateCommand(() => ShowSchedules()), }; } item.SetLabel("ChannelName", channel?.Name ?? ""); item.SetLabel("StartTime", schedule.StartTime.FormatProgramStartTime()); item.SetLabel("EndTime", schedule.EndTime.FormatProgramEndTime()); item.SetLabel("ScheduleType", string.Format("[SlimTvClient.ScheduleRecordingType_{0}]", schedule.RecordingType)); item.AdditionalProperties["SCHEDULE"] = schedule; return(item); }
protected async void UpdatePrograms() { UpdateGuiProperties(); _programsList.Clear(); IChannel channel = CurrentChannel; if (channel == null) { _programs = null; return; } var result = await _tvHandler.ProgramInfo.GetProgramsAsync(channel, DateTime.Now.AddHours(-2), DateTime.Now.AddDays(_settings.Settings.SingleChannelGuideDays)); if (result.Success) { _programs = result.Result; foreach (IProgram program in _programs) { // Use local variable, otherwise delegate argument is not fixed ProgramProperties programProperties = new ProgramProperties(); IProgram currentProgram = program; programProperties.SetProgram(currentProgram, channel); ProgramListItem item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram)) }; item.AdditionalProperties["PROGRAM"] = currentProgram; _programsList.Add(item); } } ProgramsList.FireChange(); }
public override async Task <bool> UpdateItemsAsync(int maxItems, UpdateReason updateReason) { if (!TryInitTvHandler()) { return(false); } var tvHandlerScheduleControl = _tvHandler.ScheduleControl; if (tvHandlerScheduleControl == null) { return(false); } if (!updateReason.HasFlag(UpdateReason.Forced) && !updateReason.HasFlag(UpdateReason.PeriodicMinute)) { return(true); } var scheduleResult = await tvHandlerScheduleControl.GetSchedulesAsync(); if (!scheduleResult.Success) { return(false); } var schedules = scheduleResult.Result; var scheduleSortList = new List <Tuple <ISchedule, ProgramProperties> >(); foreach (ISchedule schedule in schedules) { var programResult = await tvHandlerScheduleControl.GetProgramsForScheduleAsync(schedule); if (!programResult.Success || programResult.Result.Count == 0) { continue; } ProgramProperties programProperties = new ProgramProperties(); programProperties.SetProgram(programResult.Result.OrderBy(p => p.StartTime).First()); scheduleSortList.Add(new Tuple <ISchedule, ProgramProperties>(schedule, programProperties)); } scheduleSortList.Sort(ChannelAndProgramStartTimeComparison); var scheduleList = new List <Tuple <ISchedule, ProgramProperties> >(scheduleSortList.Take(maxItems)); if (_currentSchedules.Select(s => s.Item1.ScheduleId).SequenceEqual(scheduleList.Select(s => s.Item1.ScheduleId))) { return(true); } ListItem[] items = scheduleList.Select(s => CreateScheduleItem(s.Item1, s.Item2)).ToArray(); lock (_allItems.SyncRoot) { _currentSchedules = scheduleList; _allItems.Clear(); CollectionUtils.AddAll(_allItems, items); } _allItems.FireChange(); return(true); }
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, channel); next.SetProgram(nextProgram, channel); 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 void FillProgramsList() { _programsList.Clear(); bool isSingle = false; bool isSeries = false; foreach (IProgram program in _programs) { IChannel channel; if (!_tvHandler.ChannelAndGroupInfo.GetChannel(program.ChannelId, out channel)) { channel = null; } // Use local variable, otherwise delegate argument is not fixed ProgramProperties programProperties = new ProgramProperties(); IProgram currentProgram = program; programProperties.SetProgram(currentProgram, channel); 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 if (channel != null) { item.SetLabel("ChannelName", channel.Name); item.SetLabel("ChannelLogoType", channel.GetFanArtMediaType()); } _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(); }
private ListItem CreateProgramItem(IProgram program, IChannel channel) { ProgramProperties programProperties = new ProgramProperties(); programProperties.SetProgram(program, channel); ProgramListItem item = new ProgramListItem(programProperties) { Command = new AsyncMethodDelegateCommand(() => SlimTvModelBase.TuneChannel(channel)), }; item.SetLabel("ChannelName", channel.Name); item.AdditionalProperties["PROGRAM"] = program; return(item); }
private ProgramListItem BuildProgramListItem(IProgram program, IChannel channel) { ProgramProperties programProperties = new ProgramProperties(); IProgram currentProgram = program; programProperties.SetProgram(currentProgram, channel); ProgramListItem item = new ProgramListItem(programProperties) { Command = new MethodDelegateCommand(() => ShowProgramActions(currentProgram)) }; item.AdditionalProperties["PROGRAM"] = currentProgram; return(item); }
private static void CreateProgramListItem(IProgram program, ItemsList channelPrograms) { ProgramListItem item; if (program == null) { item = GetNoProgramPlaceholder(); } else { ProgramProperties programProperties = new ProgramProperties(); programProperties.SetProgram(program); item = new ProgramListItem(programProperties); } item.AdditionalProperties["PROGRAM"] = program; channelPrograms.Add(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(); }
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); }