Пример #1
0
        private void OnShowContextMenu(int iItem, bool clicked)
        {
            m_iSelectedItem = iItem;
            GUIListItem item = GetItem(iItem);

            if (item == null)
            {
                return;
            }

            if (item.IsFolder && clicked)
            {
                bool noitems = false;
                if (item.Label == "..")
                {
                    if (selectedItem != null)
                    {
                        selectedItem = null;
                    }
                    LoadDirectory();
                    return;
                }
                if (selectedItem == null)
                {
                    IList <Schedule> seriesList = TVHome.Util.GetRecordingTimes(item.TVTag as Schedule);
                    if (seriesList.Count < 1)
                    {
                        noitems = true; // no items existing
                    }
                    else
                    {
                        selectedItem = item.TVTag as Schedule;
                    }
                }
                if (noitems == false)
                {
                    LoadDirectory();
                    return;
                }
            }

            bool showSeries = btnSeries.Selected;

            Schedule rec = item.TVTag as Schedule;

            if (rec == null)
            {
                return;
            }

            Log.Info("OnShowContextMenu: Rec = {0}", rec.ToString());
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(rec.ProgramName);

            if (showSeries && item.IsFolder)
            {
                dlg.AddLocalizedString(982); //Cancel this show (618=delete)
                dlg.AddLocalizedString(888); //Episodes management
            }
            else if (rec.Series == false)
            {
                dlg.AddLocalizedString(618); //delete
            }
            else
            {
                dlg.AddLocalizedString(981); //Cancel this show
                dlg.AddLocalizedString(982); //Delete this entire recording
                dlg.AddLocalizedString(888); //Episodes management
            }
            VirtualCard card;
            TvServer    server = new TvServer();

            bool isRec = Schedule.IsScheduleRecording(rec.IdSchedule); //TVHome.IsRecordingSchedule(rec, null, out card);

            if (isRec)
            {
                dlg.AddLocalizedString(979); //Play recording from beginning
                dlg.AddLocalizedString(980); //Play recording from live point
            }

            //Schedule schedDB = Schedule.Retrieve(rec.IdSchedule);
            //if (schedDB.ScheduleType != (int)ScheduleRecordingType.Once)
            //{
            dlg.AddLocalizedString(1048); // settings
            //}

            dlg.DoModal(GetID);
            if (dlg.SelectedLabel == -1)
            {
                return;
            }

            bool isSchedRec = TvDatabase.Schedule.IsScheduleRecording(rec.IdSchedule);
            //TVHome.IsRecordingSchedule(rec, null, out card);

            string fileName = "";

            if (isSchedRec)
            {
                bool isCardRec = server.IsRecording(rec.ReferencedChannel().IdChannel, out card);
                if (isCardRec && card != null)
                {
                    fileName = card.RecordingFileName;
                }
            }
            Log.Info("recording fname:{0}", fileName);
            switch (dlg.SelectedId)
            {
            case 888: ////Episodes management
                TvPriorities.OnSetEpisodesToKeep(rec);
                break;

            case 1048: ////settings
                Schedule schedule = item.MusicTag as Schedule;
                if (schedule == null)
                {
                    schedule = item.TVTag as Schedule;
                }
                if (schedule != null)
                {
                    TVProgramInfo.CurrentRecording = schedule;
                    GUIWindowManager.ActivateWindow((int)Window.WINDOW_TV_PROGRAM_INFO);
                }
                return;

            case 882: ////Quality settings
                TvPriorities.OnSetQuality(rec);
                break;

            case 981: //Cancel this show
            {
                var layer = new TvBusinessLayer();
                // get the program that this episode is for
                var progs = layer.GetPrograms(rec.ReferencedChannel(), rec.StartTime, rec.EndTime);
                // pick up the schedule that is actually used for recording
                // see TVUtil.GetRecordingTimes where schedules are all spawend as one off types
                // and this is what rec is (ie. it does not actually exist in the database)
                var  realSchedule = Schedule.Retrieve(rec.IdParentSchedule) ?? rec;
                bool res          = TVUtil.DeleteRecAndSchedWithPrompt(realSchedule, progs[0]);
                if (res)
                {
                    LoadDirectory();
                }
            }
            break;

            case 982: //Delete series recording
                goto case 618;

            case 618: // delete entire recording
            {
                bool res = TVUtil.DeleteRecAndEntireSchedWithPrompt(rec, rec.StartTime);
                if (res)
                {
                    if (showSeries && !item.IsFolder)
                    {
                        OnShowContextMenu(0, true);
                        return;
                    }
                    else
                    {
                        LoadDirectory();
                    }
                }
            }
            break;

            case 979: // Play recording from beginning
            {
                Recording recDB = Recording.Retrieve(fileName);
                if (recDB != null)
                {
                    TVUtil.PlayRecording(recDB);
                }
            }
                return;

            case 980: // Play recording from live point
            {
                TVHome.ViewChannelAndCheck(rec.ReferencedChannel());
                if (g_Player.Playing)
                {
                    g_Player.ShowFullScreenWindow();
                }

                /*
                 * g_Player.Stop();
                 * if (System.IO.File.Exists(fileName))
                 * {
                 * g_Player.Play(fileName, g_Player.MediaType.Recording);
                 * g_Player.SeekAbsolute(g_Player.Duration);
                 * g_Player.ShowFullScreenWindow();
                 * return;
                 * }
                 * else
                 * {
                 * string url = server.GetRtspUrlForFile(fileName);
                 * Log.Info("recording url:{0}", url);
                 * if (url.Length > 0)
                 * {
                 *  g_Player.Play(url, g_Player.MediaType.Recording);
                 *
                 *  if (g_Player.Playing)
                 *  {
                 *    g_Player.SeekAbsolute(g_Player.Duration);
                 *    g_Player.SeekAbsolute(g_Player.Duration);
                 *    g_Player.ShowFullScreenWindow();
                 *    return;
                 *  }
                 * }
                 * }*/
            }
            break;
            }
            while (m_iSelectedItem >= GetItemCount() && m_iSelectedItem > 0)
            {
                m_iSelectedItem--;
            }
            GUIControl.SelectItemControl(GetID, listSchedules.GetID, m_iSelectedItem);
        }
Пример #2
0
        private void OnAdvancedRecord()
        {
            GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUILocalizeStrings.Get(891)); //Select TV Channel
            IList <GroupMap> channels = TVHome.Navigator.CurrentGroup.ReferringGroupMap();

            foreach (GroupMap chan in channels)
            {
                GUIListItem item    = new GUIListItem(chan.ReferencedChannel().DisplayName);
                string      strLogo = Utils.GetCoverArt(Thumbs.TVChannel, chan.ReferencedChannel().DisplayName);
                if (string.IsNullOrEmpty(strLogo))
                {
                    strLogo = "defaultVideoBig.png";
                }
                item.ThumbnailImage = strLogo;
                item.IconImageBig   = strLogo;
                item.IconImage      = strLogo;
                dlg.Add(item);
            }
            dlg.DoModal(GetID);
            if (dlg.SelectedLabel < 0)
            {
                return;
            }

            Channel selectedChannel = (channels[dlg.SelectedLabel]).ReferencedChannel();

            dlg.Reset();
            dlg.SetHeading(616); //select recording type
            for (int i = 611; i <= 615; ++i)
            {
                dlg.Add(GUILocalizeStrings.Get(i));
            }
            dlg.Add(GUILocalizeStrings.Get(WeekEndTool.GetText(DayType.Record_WorkingDays)));
            dlg.Add(GUILocalizeStrings.Get(WeekEndTool.GetText(DayType.Record_WeekendDays)));

            Schedule rec = new Schedule(selectedChannel.IdChannel, "", Schedule.MinSchedule, Schedule.MinSchedule);

            TvBusinessLayer layer = new TvBusinessLayer();

            rec.PreRecordInterval  = Int32.Parse(layer.GetSetting("preRecordInterval", "5").Value);
            rec.PostRecordInterval = Int32.Parse(layer.GetSetting("postRecordInterval", "5").Value);

            dlg.DoModal(GetID);
            if (dlg.SelectedLabel == -1)
            {
                return;
            }

            switch (dlg.SelectedLabel)
            {
            case 0: //once
                rec.ScheduleType = (int)ScheduleRecordingType.Once;
                break;

            case 1: //everytime, this channel
                rec.ScheduleType = (int)ScheduleRecordingType.EveryTimeOnThisChannel;
                break;

            case 2: //everytime, all channels
                rec.ScheduleType = (int)ScheduleRecordingType.EveryTimeOnEveryChannel;
                break;

            case 3: //weekly
                rec.ScheduleType = (int)ScheduleRecordingType.Weekly;
                break;

            case 4: //daily
                rec.ScheduleType = (int)ScheduleRecordingType.Daily;
                break;

            case 5: //WorkingDays
                rec.ScheduleType = (int)ScheduleRecordingType.WorkingDays;
                break;

            case 6: //Weekend
                rec.ScheduleType = (int)ScheduleRecordingType.Weekends;
                break;

            case 7://everytime weekly, this channel
                rec.ScheduleType = (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel;
                break;
            }


            DateTime dtNow = DateTime.Now;
            int      day;

            dlg.Reset();
            dlg.SetHeading(636); //select day
            dlg.ShowQuickNumbers = false;

            for (day = 0; day < 30; day++)
            {
                if (day > 0)
                {
                    dtNow = DateTime.Now.AddDays(day);
                }
                dlg.Add(dtNow.ToLongDateString());
            }
            dlg.DoModal(GetID);
            if (dlg.SelectedLabel == -1)
            {
                return;
            }
            day = dlg.SelectedLabel;


            dlg.Reset();
            dlg.SetHeading(142); //select time
            dlg.ShowQuickNumbers = false;
            //time
            //int no = 0;
            int hour, minute, steps;

            steps = 5;
            dlg.Add("00:00");
            for (hour = 0; hour <= 23; hour++)
            {
                for (minute = 0; minute < 60; minute += steps)
                {
                    if (hour == 0 && minute == 0)
                    {
                        continue;
                    }
                    string time;
                    if (hour < 10)
                    {
                        time = "0" + hour;
                    }
                    else
                    {
                        time = hour.ToString();
                    }
                    time += ":";
                    if (minute < 10)
                    {
                        time = time + "0" + minute;
                    }
                    else
                    {
                        time += minute.ToString();
                    }

                    //if (hour < 1) time = String.Format("{0} {1}", minute, GUILocalizeStrings.Get(3004));
                    dlg.Add(time);
                }
            }
            // pre-select the current time
            dlg.SelectedLabel = (DateTime.Now.Hour * (60 / steps)) + (Convert.ToInt16(DateTime.Now.Minute / steps));
            dlg.DoModal(GetID);
            if (dlg.SelectedLabel == -1)
            {
                return;
            }

            int mins = (dlg.SelectedLabel) * steps;

            hour   = (mins) / 60;
            minute = ((mins) % 60);


            dlg.Reset();
            dlg.SetHeading(180); //select time
            dlg.ShowQuickNumbers = false;
            //duration
            for (float hours = 0.5f; hours <= 24f; hours += 0.5f)
            {
                dlg.Add(String.Format("{0} {1}", hours.ToString("f2"), GUILocalizeStrings.Get(3002)));
            }
            dlg.DoModal(GetID);
            if (dlg.SelectedLabel == -1)
            {
                return;
            }
            int duration = (dlg.SelectedLabel + 1) * 30;

            IList <TuningDetail> details = Channel.Retrieve(rec.IdChannel).ReferringTuningDetail();

            foreach (TuningDetail detail in details)
            {
                if (detail.ChannelType == 0)
                {
                    TvPriorities.OnSetQuality(rec);
                    break;
                }
            }


            dtNow           = DateTime.Now.AddDays(day);
            rec.StartTime   = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, hour, minute, 0, 0);
            rec.EndTime     = rec.StartTime.AddMinutes(duration);
            rec.ProgramName = GUILocalizeStrings.Get(413) + " (" + rec.ReferencedChannel().DisplayName + ")";
            rec.Persist();
            TvServer server = new TvServer();

            server.OnNewSchedule();
            GUIWindowManager.ShowPreviousWindow();
        }