示例#1
0
        private bool OnAbortActiveRecording(ActiveRecording rec)
        {
            using (ControlServiceAgent tvControlAgent = new ControlServiceAgent())
            {
                if (rec == null) return false;
                bool aborted = false;
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg == null) return false;
                dlg.Reset();
                dlg.SetHeading(rec.Program.Title);
                dlg.AddLocalizedString(1449); //Stop recording
                dlg.AddLocalizedString(979);  //Play recorded from beginning
                dlg.AddLocalizedString(980);  //Play recorded from live point

                Recording recording = tvControlAgent.GetRecordingById(rec.RecordingId);
                if (recording != null && recording.LastWatchedPosition.HasValue)
                {
                    dlg.AddLocalizedString(900);//play from last point
                }

                dlg.DoModal(GetID);
                switch (dlg.SelectedId)
                {
                    case 979:
                        if (recording != null)
                        {
                            RecordedBase.PlayFromPreRecPoint(recording);
                        }
                        break;

                    case 980:
                        RecordedBase.PlayFromLivePoint(rec);
                        break;

                    case 900:
                        if (recording != null)
                        {
                            RecordedBase.PlayRecording(recording, recording.LastWatchedPosition.Value);
                        }
                        break;

                    case 1449: // Abort
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo != null)
                        {
                            dlgYesNo.Reset();
                            dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.StopRecording));
                            dlgYesNo.SetLine(1, rec.Program.Channel.DisplayName);
                            dlgYesNo.SetLine(2, rec.Program.Title);
                            dlgYesNo.SetLine(3, string.Empty);
                            dlgYesNo.SetDefaultToYes(false);
                            dlgYesNo.DoModal(GetID);

                            if (dlgYesNo.IsConfirmed)
                            {
                                tvControlAgent.AbortActiveRecording(rec);
                                aborted = true;
                            }
                        }
                        break;
                }
                return aborted;
            }
        }
示例#2
0
        private void ShowContextMenu()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);
            if (dlg != null)
            {
                dlg.Reset();
                dlg.SetHeading(GUILocalizeStrings.Get(924)); //Menu

                bool isRecording = false;
                bool isAlert = false;
                ActiveRecording activeRecording = null;

                if (_currentChannel != null)
                {
                    dlg.AddLocalizedString(938); // View this channel

                    if (_currentProgram != null)
                    {
                        dlg.AddLocalizedString(1020); // Information
                        string recordIconImage = GetChannelProgramIcon(_currentChannel, _currentProgram.GuideProgramId, out isRecording, out isAlert);
                    }
                }

                if (_currentProgram != null && _currentProgram.StartTime > DateTime.Now)
                {
                    if (isAlert)
                    {
                        dlg.AddLocalizedString(1212); // cancel reminder
                    }
                    else if (!isRecording)
                    {
                        dlg.AddLocalizedString(1040); // set reminder
                    }
                }

                if (_currentProgram != null && _currentChannel != null)
                {
                    if (PluginMain.IsActiveRecording(_currentChannel.ChannelId, _currentProgram, out activeRecording))
                    {
                        dlg.AddLocalizedString(1449); // Abort active recording
                    }
                    else if (isRecording)
                    {
                        dlg.AddLocalizedString(610); // don't record
                    }
                    else
                    {
                        dlg.AddLocalizedString(264); // Record
                    }
                }

                if (PluginMain.Navigator.GetGroups(_channelType).Count > 1)
                {
                    dlg.AddLocalizedString(971); // Group
                }

                dlg.AddLocalizedString(939); // Switch mode
                dlg.AddLocalizedString(368); // IMDB

                dlg.DoModal(GetID);
                if (dlg.SelectedLabel == -1)
                {
                    return;
                }
                switch (dlg.SelectedId)
                {
                    case 368: // IMDB
                        OnGetIMDBInfo();
                        break;

                    case 971: //group
                        OnSelectChannelGroup();
                        //dlg.Reset();
                        //dlg.SetHeading(GUILocalizeStrings.Get(971));//Group
                        //foreach (ChannelGroup group in TVHome.Navigator.Groups)
                        //{
                        //  dlg.Add(group.GroupName);
                        //}
                        //dlg.DoModal(GetID);
                        //if (dlg.SelectedLabel == -1) return;
                        //TVHome.Navigator.SetCurrentGroup(dlg.SelectedLabelText);

                        GetChannels(true);
                        Update(false);
                        SetFocus();
                        break;

                    case 938: // view channel
                        PluginMain.Navigator.ZapToChannel(_currentChannel, false);
                        break;

                    case 939: // switch mode
                        OnSwitchMode();
                        break;

                    case 1020: // information
                        ShowProgramInfo();
                        break;

                    case 610: // don't record
                    case 264: // record
                        OnRecordOrAlert(ScheduleType.Recording);
                        break;

                    case 1212: // don't notify
                    case 1040: // notify
                        OnRecordOrAlert(ScheduleType.Alert);
                        break;

                    case 1449:
                        //TODO: put this somewhere else
                        GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO);
                        if (dlgYesNo != null)
                        {
                            dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.StopRecording));
                            dlgYesNo.SetLine(1, _currentProgram.Title);
                            dlgYesNo.SetLine(2, string.Empty);
                            dlgYesNo.SetLine(3, string.Empty);
                            dlgYesNo.SetDefaultToYes(false);
                            dlgYesNo.DoModal(GetID);

                            if (dlgYesNo.IsConfirmed && activeRecording != null)
                            {
                                using (ControlServiceAgent tvControlAgent = new ControlServiceAgent())
                                {
                                    tvControlAgent.AbortActiveRecording(activeRecording);
                                }
                            }
                        }
                        break;
                }
            }
        }