/// <summary> /// Add series recording options for program /// </summary> protected void AddRecordingOptions(ItemsList items, IProgram program, RecordingStatus status) { bool isRecording = status.HasFlag(RecordingStatus.Recording); if (program != null) { bool isRunning = DateTime.Now >= program.StartTime && DateTime.Now <= program.EndTime; ILocalization localization = ServiceRegistration.Get <ILocalization>(); if (status.HasFlag(RecordingStatus.SeriesScheduled)) { if (isRecording || program.EndTime > DateTime.Now) { items.Add(new ListItem(Consts.KEY_NAME, localization.ToString(isRecording ? "[SlimTvClient.StopCurrentRecording]" : "[SlimTvClient.DeleteSingle]", program.Title)) { Command = new AsyncMethodDelegateCommand(() => CreateOrDeleteSchedule(program, ScheduleRecordingType.Once)) }); } items.Add(new ListItem(Consts.KEY_NAME, "[SlimTvClient.DeleteFullSchedule]") { Command = new AsyncMethodDelegateCommand(() => CreateOrDeleteSchedule(program, ScheduleRecordingType.EveryTimeOnEveryChannel)) }); } else { string prompt = null; if (isRecording) { prompt = "[SlimTvClient.StopCurrentRecording]"; } else if (isRunning) { prompt = "[SlimTvClient.RecordCurrentProgram]"; } else if (status.HasFlag(RecordingStatus.Scheduled)) { prompt = "[SlimTvClient.DeleteSchedule]"; } else if (program.EndTime > DateTime.Now) { prompt = "[SlimTvClient.CreateSchedule]"; } if (prompt != null) { items.Add(new ListItem(Consts.KEY_NAME, localization.ToString(prompt, program.Title)) { Command = new AsyncMethodDelegateCommand(() => CreateOrDeleteSchedule(program)) }); } items.Add( new ListItem(Consts.KEY_NAME, "[SlimTvClient.RecordSeries]") { Command = new MethodDelegateCommand(() => SlimTvExtScheduleModel.RecordSeries(program)) }); } } if (_programExtensions == null) { BuildExtensions(); } ILocalization loc = ServiceRegistration.Get <ILocalization>(); foreach (KeyValuePair <Guid, TvExtension> programExtension in _programExtensions) { TvExtension extension = programExtension.Value; // First check if this extension applies for the selected program if (!extension.Extension.IsAvailable(program)) { continue; } items.Add( new ListItem(Consts.KEY_NAME, loc.ToString(extension.Caption)) { Command = new MethodDelegateCommand(() => extension.Extension.ProgramAction(program)) }); } }
protected virtual void ShowProgramActions(IProgram program) { if (program == null) { return; } ILocalization loc = ServiceRegistration.Get <ILocalization>(); _programActions = new ItemsList(); // if program is over already, there is nothing to do. if (program.EndTime < DateTime.Now) { _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.ProgramOver]"))); } else { // Check if program is currently running. bool isRunning = DateTime.Now >= program.StartTime && DateTime.Now <= program.EndTime; if (isRunning) { _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchNow]")) { Command = new AsyncMethodDelegateCommand(() => TuneChannelByProgram(program)) }); } if (_tvHandler.ScheduleControl != null) { var result = _tvHandler.ScheduleControl.GetRecordingStatusAsync(program).Result; if (result.Success && result.Result != RecordingStatus.None) { if (isRunning) { _programActions.Add( new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchFromBeginning]")) { Command = new AsyncMethodDelegateCommand(() => _tvHandler.WatchRecordingFromBeginningAsync(program)) }); } _programActions.Add( new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.StopCurrentRecording]" : "[SlimTvClient.DeleteSchedule]", program.Title)) { Command = new AsyncMethodDelegateCommand(async() => { if (await _tvHandler.ScheduleControl.RemoveScheduleForProgramAsync(program, ScheduleRecordingType.Once)) { UpdateRecordingStatus(program, RecordingStatus.None); } } ) }); } else { _programActions.Add( new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.RecordNow]" : "[SlimTvClient.CreateSchedule]")) { Command = new AsyncMethodDelegateCommand(async() => { AsyncResult <ISchedule> recResult; // "No Program" placeholder if (program.ProgramId == -1) { recResult = await _tvHandler.ScheduleControl.CreateScheduleByTimeAsync(new Channel { ChannelId = program.ChannelId }, program.StartTime, program.EndTime, ScheduleRecordingType.Once); } else { recResult = await _tvHandler.ScheduleControl.CreateScheduleAsync(program, ScheduleRecordingType.Once); } if (recResult.Success) { UpdateRecordingStatus(program, RecordingStatus.Scheduled); } } ) }); } } } // Add list entries for extensions foreach (KeyValuePair <Guid, TvExtension> programExtension in _programExtensions) { TvExtension extension = programExtension.Value; // First check if this extension applies for the selected program if (!extension.Extension.IsAvailable(program)) { continue; } _programActions.Add( new ListItem(Consts.KEY_NAME, loc.ToString(extension.Caption)) { Command = new MethodDelegateCommand(() => extension.Extension.ProgramAction(program)) }); } IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>(); screenManager.ShowDialog(_programActionsDialogName); }
protected void ShowProgramActions(IProgram program) { if (program == null) { return; } ILocalization loc = ServiceRegistration.Get <ILocalization>(); _programActions = new ItemsList(); // if program is over already, there is nothing to do. if (program.EndTime < DateTime.Now) { _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.ProgramOver]"))); } else { // Check if program is currently running. bool isRunning = DateTime.Now >= program.StartTime && DateTime.Now <= program.EndTime; if (isRunning) { _programActions.Add(new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchNow]")) { Command = new MethodDelegateCommand(() => { IChannel channel; if (_tvHandler.ProgramInfo.GetChannel(program, out channel)) { IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>(); SlimTvClientModel model = workflowManager.GetModel(SlimTvClientModel.MODEL_ID) as SlimTvClientModel; if (model != null) { model.Tune(channel); } } }) }); } if (_tvHandler.ScheduleControl != null) { RecordingStatus recordingStatus; if (_tvHandler.ScheduleControl.GetRecordingStatus(program, out recordingStatus) && recordingStatus != RecordingStatus.None) { if (isRunning) { _programActions.Add( new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.WatchFromBeginning]")) { Command = new MethodDelegateCommand(() => _tvHandler.WatchRecordingFromBeginning(program)) }); } _programActions.Add( new ListItem(Consts.KEY_NAME, loc.ToString("[SlimTvClient.DeleteSchedule]")) { Command = new MethodDelegateCommand(() => { if (_tvHandler.ScheduleControl.RemoveScheduleForProgram(program, ScheduleRecordingType.Once)) { UpdateRecordingStatus(program, RecordingStatus.None); } } ) }); } else { _programActions.Add( new ListItem(Consts.KEY_NAME, loc.ToString(isRunning ? "[SlimTvClient.RecordNow]" : "[SlimTvClient.CreateSchedule]")) { Command = new MethodDelegateCommand(() => { ISchedule schedule; if (_tvHandler.ScheduleControl.CreateSchedule(program, ScheduleRecordingType.Once, out schedule)) { UpdateRecordingStatus(program, RecordingStatus.Scheduled); } } ) }); } } } // Add list entries for extensions foreach (KeyValuePair <Guid, TvExtension> programExtension in _programExtensions) { TvExtension extension = programExtension.Value; // First check if this extension applies for the selected program if (!extension.Extension.IsAvailable(program)) { continue; } _programActions.Add( new ListItem(Consts.KEY_NAME, loc.ToString(extension.Caption)) { Command = new MethodDelegateCommand(() => extension.Extension.ProgramAction(program)) }); } IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>(); screenManager.ShowDialog(_programActionsDialogName); }