public GetPrograms ( TvDatabase.Channel channel, System.DateTime startTime ) : IList |
||
channel | TvDatabase.Channel | |
startTime | System.DateTime | |
Résultat | IList |
//void SetProperties() protected override void RenderSingleChannel(Channel channel) { string strLogo; int chan = ChannelOffset; for (int iChannel = 0; iChannel < _channelCount; iChannel++) { if (chan < _channelList.Count) { Channel tvChan = _channelList[chan].channel; strLogo = GetChannelLogo(tvChan.DisplayName); GUIButton3PartControl img = GetControl(iChannel + (int)Controls.IMG_CHAN1) as GUIButton3PartControl; if (img != null) { if (_showChannelLogos) { img.TexutureIcon = strLogo; } img.Label1 = tvChan.DisplayName; img.Data = tvChan; img.IsVisible = true; } } chan++; } GUILabelControl channelLabel = GetControl((int)Controls.SINGLE_CHANNEL_LABEL) as GUILabelControl; GUIImage channelImage = GetControl((int)Controls.SINGLE_CHANNEL_IMAGE) as GUIImage; strLogo = GetChannelLogo(channel.DisplayName); if (channelImage == null) { if (strLogo.Length > 0) { channelImage = new GUIImage(GetID, (int)Controls.SINGLE_CHANNEL_IMAGE, GetControl((int)Controls.LABEL_TIME1).XPosition, GetControl((int)Controls.LABEL_TIME1).YPosition - 15, 40, 40, strLogo, Color.White); channelImage.AllocResources(); GUIControl temp = (GUIControl)channelImage; Add(ref temp); } } else { channelImage.SetFileName(strLogo); } if (channelLabel == null) { channelLabel = new GUILabelControl(GetID, (int)Controls.SINGLE_CHANNEL_LABEL, channelImage.XPosition + 44, channelImage.YPosition + 10, 300, 40, "font16", channel.DisplayName, 4294967295, GUIControl.Alignment.Left, GUIControl.VAlignment.Top, true, 0, 0, 0xFF000000); channelLabel.AllocResources(); GUIControl temp = channelLabel; Add(ref temp); } setSingleChannelLabelVisibility(true); channelLabel.Label = channel.DisplayName; if (strLogo.Length > 0) { channelImage.SetFileName(strLogo); } if (channelLabel != null) { channelLabel.Label = channel.DisplayName; } if (_recalculateProgramOffset) { _programs = new List<Program>(); DateTime dtStart = DateTime.Now; dtStart = dtStart.AddDays(-1); DateTime dtEnd = dtStart.AddDays(30); TvBusinessLayer layer = new TvBusinessLayer(); _programs = layer.GetPrograms(channel, dtStart, dtEnd); _totalProgramCount = _programs.Count; if (_totalProgramCount == 0) { _totalProgramCount = _channelCount; } _recalculateProgramOffset = false; bool found = false; for (int i = 0; i < _programs.Count; i++) { Program program = (Program)_programs[i]; if (program.StartTime <= _viewingTime && program.EndTime >= _viewingTime) { _programOffset = i; found = true; break; } } if (!found) { _programOffset = 0; } } else if (_programOffset < _programs.Count) { int day = ((Program)_programs[_programOffset]).StartTime.DayOfYear; bool changed = false; while (day > _viewingTime.DayOfYear) { _viewingTime = _viewingTime.AddDays(1.0); changed = true; } while (day < _viewingTime.DayOfYear) { _viewingTime = _viewingTime.AddDays(-1.0); changed = true; } if (changed) { GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl; // Find first day in TVGuide and set spincontrol position int iDay = CalcDays(); for (; iDay < 0; ++iDay) { _viewingTime = _viewingTime.AddDays(1.0); } for (; iDay >= MaxDaysInGuide; --iDay) { _viewingTime = _viewingTime.AddDays(-1.0); } cntlDay.Value = iDay; } } // ichan = number of rows for (int ichan = 0; ichan < _channelCount; ++ichan) { GUIButton3PartControl imgCh = GetControl(ichan + (int)Controls.IMG_CHAN1) as GUIButton3PartControl; imgCh.TexutureIcon = ""; int iStartXPos = GetControl(0 + (int)Controls.LABEL_TIME1).XPosition; int height = GetControl((int)Controls.IMG_CHAN1 + 1).YPosition; height -= GetControl((int)Controls.IMG_CHAN1).YPosition; int width = GetControl((int)Controls.LABEL_TIME1 + 1).XPosition; width -= GetControl((int)Controls.LABEL_TIME1).XPosition; int iTotalWidth = width * _numberOfBlocks; Program program; int offset = _programOffset; if (offset + ichan < _programs.Count) { program = (Program)_programs[offset + ichan]; } else { // bugfix for 0 items if (_programs.Count == 0) { program = new Program(channel.IdChannel, _viewingTime, _viewingTime, "-", string.Empty, string.Empty, Program.ProgramState.None, DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1, string.Empty, -1); } else { program = (Program)_programs[_programs.Count - 1]; if (program.EndTime.DayOfYear == _viewingTime.DayOfYear) { program = new Program(channel.IdChannel, program.EndTime, program.EndTime, "-", "-", "-", Program.ProgramState.None, DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1, string.Empty, -1); } else { program = new Program(channel.IdChannel, _viewingTime, _viewingTime, "-", "-", "-", Program.ProgramState.None, DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1, string.Empty, -1); } } } int ypos = GetControl(ichan + (int)Controls.IMG_CHAN1).YPosition; int iControlId = GUIDE_COMPONENTID_START + ichan * RowID + 0 * ColID; GUIButton3PartControl img = GetControl(iControlId) as GUIButton3PartControl; GUIButton3PartControl buttonTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl; if (img == null) { if (buttonTemplate != null) { buttonTemplate.IsVisible = false; img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iTotalWidth, height - 2, buttonTemplate.TexutureFocusLeftName, buttonTemplate.TexutureFocusMidName, buttonTemplate.TexutureFocusRightName, buttonTemplate.TexutureNoFocusLeftName, buttonTemplate.TexutureNoFocusMidName, buttonTemplate.TexutureNoFocusRightName, String.Empty); img.TileFillTFL = buttonTemplate.TileFillTFL; img.TileFillTNFL = buttonTemplate.TileFillTNFL; img.TileFillTFM = buttonTemplate.TileFillTFM; img.TileFillTNFM = buttonTemplate.TileFillTNFM; img.TileFillTFR = buttonTemplate.TileFillTFR; img.TileFillTNFR = buttonTemplate.TileFillTNFR; } else { img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iTotalWidth, height - 2, "tvguide_button_selected_left.png", "tvguide_button_selected_middle.png", "tvguide_button_selected_right.png", "tvguide_button_light_left.png", "tvguide_button_light_middle.png", "tvguide_button_light_right.png", String.Empty); } img.AllocResources(); img.ColourDiffuse = GetColorForGenre(program.Genre); GUIControl cntl = (GUIControl)img; Add(ref cntl); } else { if (buttonTemplate != null) { buttonTemplate.IsVisible = false; img.TexutureFocusLeftName = buttonTemplate.TexutureFocusLeftName; img.TexutureFocusMidName = buttonTemplate.TexutureFocusMidName; img.TexutureFocusRightName = buttonTemplate.TexutureFocusRightName; img.TexutureNoFocusLeftName = buttonTemplate.TexutureNoFocusLeftName; img.TexutureNoFocusMidName = buttonTemplate.TexutureNoFocusMidName; img.TexutureNoFocusRightName = buttonTemplate.TexutureNoFocusRightName; img.TileFillTFL = buttonTemplate.TileFillTFL; img.TileFillTNFL = buttonTemplate.TileFillTNFL; img.TileFillTFM = buttonTemplate.TileFillTFM; img.TileFillTNFM = buttonTemplate.TileFillTNFM; img.TileFillTFR = buttonTemplate.TileFillTFR; img.TileFillTNFR = buttonTemplate.TileFillTNFR; } else { img.TexutureFocusLeftName = "tvguide_button_selected_left.png"; img.TexutureFocusMidName = "tvguide_button_selected_middle.png"; img.TexutureFocusRightName = "tvguide_button_selected_right.png"; img.TexutureNoFocusLeftName = "tvguide_button_light_left.png"; img.TexutureNoFocusMidName = "tvguide_button_light_middle.png"; img.TexutureNoFocusRightName = "tvguide_button_light_right.png"; } img.Focus = false; img.SetPosition(iStartXPos, ypos); img.Width = iTotalWidth; img.ColourDiffuse = GetColorForGenre(program.Genre); img.IsVisible = true; img.DoUpdate(); } img.RenderLeft = false; img.RenderRight = false; img.StretchIfNotRendered = true; bool bSeries = (program.IsRecordingSeries || program.IsRecordingSeriesPending || program.IsPartialRecordingSeriesPending); bool bConflict = program.HasConflict; bool bRecording = bSeries || (program.IsRecording || program.IsRecordingOncePending); img.Data = program; img.ColourDiffuse = GetColorForGenre(program.Genre); height = height - 10; height /= 2; int iWidth = iTotalWidth; if (iWidth > 10) { iWidth -= 10; } else { iWidth = 1; } DateTime dt = DateTime.Now; img.TextOffsetX1 = 5; img.TextOffsetY1 = 5; img.FontName1 = "font13"; img.TextColor1 = 0xffffffff; img.Label1 = TVUtil.GetDisplayTitle(program); string strTimeSingle = String.Format("{0}", program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); if (program.StartTime.DayOfYear != _viewingTime.DayOfYear) { img.Label1 = String.Format("{0} {1}", Utils.GetShortDayString(program.StartTime), TVUtil.GetDisplayTitle(program)); } GUILabelControl labelTemplate; if (program.IsRunningAt(dt)) { labelTemplate = _titleDarkTemplate; } else { labelTemplate = _titleTemplate; } if (labelTemplate != null) { img.FontName1 = labelTemplate.FontName; img.TextColor1 = labelTemplate.TextColor; img.TextOffsetX1 = labelTemplate.XPosition; img.TextOffsetY1 = labelTemplate.YPosition; img.SetShadow1(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor); } img.TextOffsetX2 = 5; img.TextOffsetY2 = img.Height / 2; img.FontName2 = "font13"; img.TextColor2 = 0xffffffff; img.Label2 = ""; if (program.IsRunningAt(dt)) { img.TextColor2 = 0xff101010; labelTemplate = _genreDarkTemplate; } else { labelTemplate = _genreTemplate; } if (labelTemplate != null) { img.FontName2 = labelTemplate.FontName; img.TextColor2 = labelTemplate.TextColor; img.Label2 = program.Genre; img.TextOffsetX2 = labelTemplate.XPosition; img.TextOffsetY2 = labelTemplate.YPosition; img.SetShadow2(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor); } imgCh.Label1 = strTimeSingle; imgCh.TexutureIcon = ""; if (program.IsRunningAt(dt)) { GUIButton3PartControl buttonRunningTemplate = _programRunningTemplate; if (buttonRunningTemplate != null) { buttonRunningTemplate.IsVisible = false; img.TexutureFocusLeftName = buttonRunningTemplate.TexutureFocusLeftName; img.TexutureFocusMidName = buttonRunningTemplate.TexutureFocusMidName; img.TexutureFocusRightName = buttonRunningTemplate.TexutureFocusRightName; img.TexutureNoFocusLeftName = buttonRunningTemplate.TexutureNoFocusLeftName; img.TexutureNoFocusMidName = buttonRunningTemplate.TexutureNoFocusMidName; img.TexutureNoFocusRightName = buttonRunningTemplate.TexutureNoFocusRightName; img.TileFillTFL = buttonRunningTemplate.TileFillTFL; img.TileFillTNFL = buttonRunningTemplate.TileFillTNFL; img.TileFillTFM = buttonRunningTemplate.TileFillTFM; img.TileFillTNFM = buttonRunningTemplate.TileFillTNFM; img.TileFillTFR = buttonRunningTemplate.TileFillTFR; img.TileFillTNFR = buttonRunningTemplate.TileFillTNFR; } else { img.TexutureFocusLeftName = "tvguide_button_selected_left.png"; img.TexutureFocusMidName = "tvguide_button_selected_middle.png"; img.TexutureFocusRightName = "tvguide_button_selected_right.png"; img.TexutureNoFocusLeftName = "tvguide_button_left.png"; img.TexutureNoFocusMidName = "tvguide_button_middle.png"; img.TexutureNoFocusRightName = "tvguide_button_right.png"; } } img.SetPosition(img.XPosition, img.YPosition); img.TexutureIcon = String.Empty; if (program.Notify) { GUIButton3PartControl buttonNotifyTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOTIFY) as GUIButton3PartControl; if (buttonNotifyTemplate != null) { buttonNotifyTemplate.IsVisible = false; img.TexutureFocusLeftName = buttonNotifyTemplate.TexutureFocusLeftName; img.TexutureFocusMidName = buttonNotifyTemplate.TexutureFocusMidName; img.TexutureFocusRightName = buttonNotifyTemplate.TexutureFocusRightName; img.TexutureNoFocusLeftName = buttonNotifyTemplate.TexutureNoFocusLeftName; img.TexutureNoFocusMidName = buttonNotifyTemplate.TexutureNoFocusMidName; img.TexutureNoFocusRightName = buttonNotifyTemplate.TexutureNoFocusRightName; img.TileFillTFL = buttonNotifyTemplate.TileFillTFL; img.TileFillTNFL = buttonNotifyTemplate.TileFillTNFL; img.TileFillTFM = buttonNotifyTemplate.TileFillTFM; img.TileFillTNFM = buttonNotifyTemplate.TileFillTNFM; img.TileFillTFR = buttonNotifyTemplate.TileFillTFR; img.TileFillTNFR = buttonNotifyTemplate.TileFillTNFR; // Use of the button template control implies use of the icon. Use a blank image if the icon is not desired. img.TexutureIcon = Thumbs.TvNotifyIcon; img.IconOffsetX = buttonNotifyTemplate.IconOffsetX; img.IconOffsetY = buttonNotifyTemplate.IconOffsetY; img.IconAlign = buttonNotifyTemplate.IconAlign; img.IconVAlign = buttonNotifyTemplate.IconVAlign; img.IconInlineLabel1 = buttonNotifyTemplate.IconInlineLabel1; } else { if (_useNewNotifyButtonColor) { img.TexutureFocusLeftName = "tvguide_notifyButton_Focus_left.png"; img.TexutureFocusMidName = "tvguide_notifyButton_Focus_middle.png"; img.TexutureFocusRightName = "tvguide_notifyButton_Focus_right.png"; img.TexutureNoFocusLeftName = "tvguide_notifyButton_noFocus_left.png"; img.TexutureNoFocusMidName = "tvguide_notifyButton_noFocus_middle.png"; img.TexutureNoFocusRightName = "tvguide_notifyButton_noFocus_right.png"; } else { img.TexutureIcon = Thumbs.TvNotifyIcon; } } } if (bRecording) { bool bPartialRecording = program.IsPartialRecordingSeriesPending; GUIButton3PartControl buttonRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RECORD) as GUIButton3PartControl; // Select the partial recording template if needed. if (bPartialRecording) { buttonRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_PARTIAL_RECORD) as GUIButton3PartControl; } if (buttonRecordTemplate != null) { buttonRecordTemplate.IsVisible = false; img.TexutureFocusLeftName = buttonRecordTemplate.TexutureFocusLeftName; img.TexutureFocusMidName = buttonRecordTemplate.TexutureFocusMidName; img.TexutureFocusRightName = buttonRecordTemplate.TexutureFocusRightName; img.TexutureNoFocusLeftName = buttonRecordTemplate.TexutureNoFocusLeftName; img.TexutureNoFocusMidName = buttonRecordTemplate.TexutureNoFocusMidName; img.TexutureNoFocusRightName = buttonRecordTemplate.TexutureNoFocusRightName; img.TileFillTFL = buttonRecordTemplate.TileFillTFL; img.TileFillTNFL = buttonRecordTemplate.TileFillTNFL; img.TileFillTFM = buttonRecordTemplate.TileFillTFM; img.TileFillTNFM = buttonRecordTemplate.TileFillTNFM; img.TileFillTFR = buttonRecordTemplate.TileFillTFR; img.TileFillTNFR = buttonRecordTemplate.TileFillTNFR; // Use of the button template control implies use of the icon. Use a blank image if the icon is not desired. if (bConflict) { img.TexutureIcon = Thumbs.TvConflictRecordingIcon; } else if (bSeries) { img.TexutureIcon = Thumbs.TvRecordingSeriesIcon; } else { img.TexutureIcon = Thumbs.TvRecordingIcon; } img.IconOffsetX = buttonRecordTemplate.IconOffsetX; img.IconOffsetY = buttonRecordTemplate.IconOffsetY; img.IconAlign = buttonRecordTemplate.IconAlign; img.IconVAlign = buttonRecordTemplate.IconVAlign; img.IconInlineLabel1 = buttonRecordTemplate.IconInlineLabel1; } else { if (bPartialRecording && _useNewPartialRecordingButtonColor) { img.TexutureFocusLeftName = "tvguide_partRecButton_Focus_left.png"; img.TexutureFocusMidName = "tvguide_partRecButton_Focus_middle.png"; img.TexutureFocusRightName = "tvguide_partRecButton_Focus_right.png"; img.TexutureNoFocusLeftName = "tvguide_partRecButton_noFocus_left.png"; img.TexutureNoFocusMidName = "tvguide_partRecButton_noFocus_middle.png"; img.TexutureNoFocusRightName = "tvguide_partRecButton_noFocus_right.png"; } else { if (_useNewRecordingButtonColor) { img.TexutureFocusLeftName = "tvguide_recButton_Focus_left.png"; img.TexutureFocusMidName = "tvguide_recButton_Focus_middle.png"; img.TexutureFocusRightName = "tvguide_recButton_Focus_right.png"; img.TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png"; img.TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png"; img.TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png"; } else { if (bConflict) { img.TexutureIcon = Thumbs.TvConflictRecordingIcon; } else if (bSeries) { img.TexutureIcon = Thumbs.TvRecordingSeriesIcon; } else { img.TexutureIcon = Thumbs.TvRecordingIcon; } } } } } } }
private void OnAdvancedRecord() { if (CurrentProgram == null) { return; } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(GUILocalizeStrings.Get(616)); //616=Select Schedule type //610=None //611=Record once //612=Record everytime on this channel //613=Record everytime on every channel //614=Record every week at this time //615=Record every day at this time for (int i = 611; i <= 615; ++i) { dlg.AddLocalizedString(i); } dlg.Add(GUILocalizeStrings.Get(WeekEndTool.GetText(DayType.Record_WorkingDays))); dlg.Add(GUILocalizeStrings.Get(WeekEndTool.GetText(DayType.Record_WeekendDays))); dlg.AddLocalizedString(990000); // 990000=Weekly everytime on this channel dlg.DoModal(GetID); if (dlg.SelectedLabel == -1) { return; } int scheduleType = (int)ScheduleRecordingType.Once; switch (dlg.SelectedLabel) { case 0: //once scheduleType = (int)ScheduleRecordingType.Once; break; case 1: //everytime, this channel scheduleType = (int)ScheduleRecordingType.EveryTimeOnThisChannel; break; case 2: //everytime, all channels scheduleType = (int)ScheduleRecordingType.EveryTimeOnEveryChannel; break; case 3: //weekly scheduleType = (int)ScheduleRecordingType.Weekly; break; case 4: //daily scheduleType = (int)ScheduleRecordingType.Daily; break; case 5: //WorkingDays scheduleType = (int)ScheduleRecordingType.WorkingDays; break; case 6: //Weekends scheduleType = (int)ScheduleRecordingType.Weekends; break; case 7://Weekly everytime, this channel scheduleType = (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel; break; } CreateProgram(CurrentProgram, scheduleType, GetID); if (scheduleType == (int)ScheduleRecordingType.Once) { //check if this program is interrupted (for example by a news bulletin) //ifso ask the user if he wants to record the 2nd part also DateTime dtStart = CurrentProgram.EndTime.AddMinutes(1); DateTime dtEnd = dtStart.AddHours(3); TvBusinessLayer layer = new TvBusinessLayer(); IList<Program> programs = layer.GetPrograms(CurrentProgram.ReferencedChannel(), dtStart, dtEnd); if (programs.Count >= 2) { Program next = programs[0]; Program nextNext = programs[1]; if (nextNext.Title == CurrentProgram.Title) { TimeSpan ts = next.EndTime - nextNext.StartTime; if (ts.TotalMinutes <= 40) { // GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_YES_NO); dlgYesNo.SetHeading(1012); //This program will be interrupted by dlgYesNo.SetLine(1, next.Title); dlgYesNo.SetLine(2, 1013); //Would you like to record the second part also? dlgYesNo.DoModal(GetID); if (dlgYesNo.IsConfirmed) { CreateProgram(nextNext, scheduleType, GetID); Update(); } } } } } } Update(); }
private static void UpdateCurrentProgramTitle(ref Schedule recNew) { TvBusinessLayer layer = new TvBusinessLayer(); IList<Program> programs = layer.GetPrograms(recNew.ReferencedChannel(), recNew.StartTime, recNew.EndTime); if (programs != null && programs.Count > 0) { recNew.ProgramName = programs[0].Title; } }