Example #1
0
        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 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 CreateScheduleItem(ISchedule schedule, ProgramProperties program)
        {
            ListItem item  = null;
            DateTime start = schedule.StartTime;
            DateTime end   = schedule.EndTime;

            if (program != null)
            {
                item = new ProgramListItem(program)
                {
                    Command = new MethodDelegateCommand(() => ShowSchedules()),
                };
                item.SetLabel("Name", schedule.Name);
                start = program.StartTime;
                end   = program.EndTime;
            }
            if (item == null)
            {
                item = new ListItem("Name", schedule.Name)
                {
                    Command = new MethodDelegateCommand(() => ShowSchedules()),
                };
            }
            item.SetLabel("ChannelName", program?.ChannelName ?? "");
            item.SetLabel("StartTime", start.FormatProgramStartTime());
            item.SetLabel("EndTime", end.FormatProgramEndTime());
            item.SetLabel("ScheduleType", string.Format("[SlimTvClient.ScheduleRecordingType_{0}]", schedule.RecordingType));
            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);
        }
        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);
        }