public void EpisodeIsEnricherReturnsFalseWhenNoSeasonEpisode() { var guideProgram = new GuideProgram(); guideProgram.SeriesNumber = 3; guideProgram.EpisodeNumber = 10; guideProgram.EpisodeNumberDisplay = "Test"; var program = new GuideEnricherProgram(guideProgram); program.EpisodeIsEnriched().ShouldBeFalse(); }
public void EpisodeIsEnricherReturnsTrueWhenEpisodeNumberAndSeasonEpisode() { var guideProgram = new GuideProgram(); guideProgram.SeriesNumber = 3; guideProgram.EpisodeNumber = 10; guideProgram.EpisodeNumberDisplay = "S03E10"; var program = new GuideEnricherProgram(guideProgram); program.EpisodeIsEnriched().ShouldBeTrue(); }
/// <summary> /// Create a combined description containing the episode title (optional), the actual description and the recording's director and actors. /// </summary> /// <param name="includeEpisodeTitle">Set to true to include the episode title.</param> /// <returns>The combined description.</returns> public string CreateCombinedDescription(bool includeEpisodeTitle) { string[] directors = new string[0]; string[] actors = new string[0]; if (!String.IsNullOrEmpty(this.Director)) { directors = this.Director.Split(';'); } if (!String.IsNullOrEmpty(this.Actors)) { actors = this.Actors.Split(';'); } return(GuideProgram.CreateCombinedDescription(includeEpisodeTitle ? CreateEpisodeTitle() : null, this.Description, directors, actors)); }
public static GuideProgram makeGuideProgram( SchedulesResponse sr, SchedulesResponse.Program srp, ProgramResponseInstance pri) { try { var gp = new GuideProgram(); gp.Title = makeTitle(pri); gp.SubTitle = pri.episodeTitle150; gp.Description = makeDescription(pri); DateTime startTime = DateTime.Parse(srp.airDateTime); gp.StartTime = startTime; gp.StopTime = startTime.AddSeconds(srp.duration); gp.EpisodeNumber = makeEpisodeNumber(pri); gp.SeriesNumber = makeSeriesNumber(pri); gp.EpisodeNumberDisplay = makeEpisodeNumberDisplay(pri); gp.Rating = makeRatings(srp); // srp.Premiere is for miniseries or movies if (srp.premiere.HasValue) { gp.IsPremiere = (true == srp.premiere.Value); } // so use srp.new to determine if it's a repeat... srp.repeat is only for sporting events gp.IsRepeat = true; // default to a repeat if ([email protected]) { gp.IsRepeat = [email protected]; } gp.PreviouslyAiredTime = DateTime.Parse(srp.airDateTime); gp.Actors = makeActors(pri); gp.Category = makeCategory(pri); gp.Directors = makeDirectors(pri); return gp; } catch (Exception ex) { Logger.Error("Error while creating guide program instances: {0}\n{1}",ex.Message, ex.StackTrace); throw; } }
// For shows beginning with EP, the next 8 digits represent the series ID, with the last 4 digits representing the episode id. private bool ParseEpisodeAndSeriesIds(string programId, GuideProgram guideProgram) { guideProgram.SeriesNumber = null; guideProgram.EpisodeNumber = null; bool hasEpisodeAndSeriesInfo = false; if(programId.StartsWith("EP") && programId.Length >= 12 ) { string seriesIdString = programId.Substring(2, 8); string episodeIdString = programId.Substring(programId.Length - 4); int tmp; if(int.TryParse(seriesIdString, out tmp)) { guideProgram.SeriesNumber = tmp; } if(int.TryParse(episodeIdString, out tmp)) { guideProgram.EpisodeNumber = tmp; } hasEpisodeAndSeriesInfo = true; } return hasEpisodeAndSeriesInfo; }
public void SaveGuideDataInArgusTV(ImportGuideChannel channel, ChannelType channelType, GuideProgram[] guideProgramData, bool updateChannelName ) { if (guideProgramData.Length > 0) { Guid guideChannelId = EnsureDefaultChannel(channel, channelType, updateChannelName); foreach (GuideProgram guideProgram in guideProgramData) { guideProgram.GuideChannelId = guideChannelId; try { Proxies.GuideService.ImportProgram(guideProgram, GuideSource.XmlTv).Wait(); } catch { } } } }
private GuideProgram FillGuideProgram(schedulesSchedule schedule, Program program) { GuideProgram guideProgram = new GuideProgram(); try { guideProgram.StartTime = schedule.time; guideProgram.StartTimeUtc = schedule.time.ToUniversalTime(); TimeSpan duration = ParseDuration(schedule.duration); guideProgram.StopTime = guideProgram.StartTime.Add(duration); guideProgram.StopTimeUtc = guideProgram.StartTimeUtc.Add(duration); if (guideProgram.StartTimeUtc >= guideProgram.StopTimeUtc) { return null; } AdaptGuideProgramTimeToLocalTimeZone(guideProgram); guideProgram.Title = program.Title; guideProgram.SubTitle = program.SubTitle; guideProgram.Description = TrimAndCutString(program.Description, 3999); guideProgram.Actors = program.Actors; guideProgram.Directors = program.Directors; if (schedule.tvRatingSpecified) { guideProgram.Rating = schedule.tvRating.ToString(); } guideProgram.StarRating = program.StarRating; guideProgram.IsRepeat = false; guideProgram.IsPremiere = false; if(schedule.hdtv ) guideProgram.Flags |= GuideProgramFlags.HighDefinition; // If the tvScheduleItem says it is a repeat or new, we believe them // MV = movies, EP = episode, SH = show, SP = sports if (schedule.repeat || schedule.@new ) { guideProgram.IsPremiere = schedule.@new; guideProgram.IsRepeat = !guideProgram.IsPremiere; } else if(program.Id.StartsWith("EP") && program.OriginalAirDate.HasValue && guideProgram.StartTime.Subtract(program.OriginalAirDate.Value).TotalDays > 60 ) { guideProgram.IsRepeat = true; } else if(program.Id.StartsWith("SH") && program.OriginalAirDate.HasValue && guideProgram.StartTime.Subtract(program.OriginalAirDate.Value).TotalDays > 60 && program.ShowType != null && (program.ShowType.Equals("Short Film") || program.ShowType.Equals("Special"))) { guideProgram.IsRepeat = true; } else if (program.Id.StartsWith("SP")) // Sports -> always new. { guideProgram.IsPremiere = true; } if (!ParseEpisodeAndSeriesIds(program.Id, guideProgram)) { guideProgram.EpisodeNumber = program.EpisodeNumber; } if (guideProgram.EpisodeNumber.HasValue) { guideProgram.EpisodeNumberDisplay = guideProgram.EpisodeNumber.ToString(); } guideProgram.Category = TrimAndCutString(program.Genre, 49); guideProgram.PreviouslyAiredTime = program.OriginalAirDate; } catch(Exception ex) { Logger.Write(TraceEventType.Error, "FillGuideProgram exception : " + ex.Message); } return guideProgram; }
private void SetFocus() { if (_cursorX < 0) { return; } if (_cursorY == 0 || _cursorY == MinYIndex) // either channel or group button { int controlid; GUIControl.UnfocusControl(GetID, (int)Controls.SPINCONTROL_DAY); GUIControl.UnfocusControl(GetID, (int)Controls.SPINCONTROL_TIME_INTERVAL); if (_cursorY == -1) controlid = (int)Controls.CHANNEL_GROUP_BUTTON; else controlid = (int)Controls.IMG_CHAN1 + _cursorX; GUIControl.FocusControl(GetID, controlid); } else { Correct(); int iControlId = GUIDE_COMPONENTID_START + _cursorX * RowID + (_cursorY - 1) * ColID; GUIButton3PartControl img = GetControl(iControlId) as GUIButton3PartControl; if (null != img && img.IsVisible) { img.ColourDiffuse = 0xffffffff; _currentProgram = Proxies.GuideService.GetProgramById(((GuideProgramSummary)img.Data).GuideProgramId).Result; SetProperties(); } GUIControl.FocusControl(GetID, iControlId); } }
private string GetDurationAsMinutes(GuideProgram program) { if (program.Title == "No TVGuide data available") { return ""; } DateTime progStart = program.StartTime; DateTime progEnd = program.StopTime; TimeSpan progDuration = progEnd.Subtract(progStart); return progDuration.TotalMinutes + " " + GUILocalizeStrings.Get(2998); }
public void SaveGuideDataInArgusTV(ImportGuideChannel channel, ChannelType channelType, GuideProgram[] guideProgramData, bool updateChannelName ) { if (guideProgramData.Length > 0) { using (GuideServiceAgent guideServiceAgent = new GuideServiceAgent()) { using (SchedulerServiceAgent schedulerServiceAgent = new SchedulerServiceAgent()) { Guid guideChannelId = EnsureDefaultChannel(channel, channelType, updateChannelName); foreach (GuideProgram guideProgram in guideProgramData) { guideProgram.GuideChannelId = guideChannelId; try { guideServiceAgent.ImportProgram(guideProgram, GuideSource.XmlTv); } catch { } } } } } }
private void RenderChannel(int iChannel, GuideBaseChannel tvGuideChannel, long iStart, long iEnd, bool selectCurrentShow) { Channel channel = tvGuideChannel.channel; int channelNum = 0; if (!_byIndex) { if (channel.LogicalChannelNumber.HasValue) { channelNum = channel.LogicalChannelNumber.Value; } } else { channelNum = _channelList.IndexOf(tvGuideChannel) + 1; } GUIButton3PartControl img = GetControl(iChannel + (int)Controls.IMG_CHAN1) as GUIButton3PartControl; if (img != null) { if (_showChannelLogos) { img.TexutureIcon = tvGuideChannel.strLogo; } if (channelNum > 0 && _showChannelNumber) { img.Label1 = channelNum + " " + channel.DisplayName; } else { img.Label1 = channel.DisplayName; } img.Data = channel; img.IsVisible = true; } IList<GuideProgramSummary> programs = new List<GuideProgramSummary>(); if (_model.ProgramsByChannel.ContainsKey(channel.ChannelId)) { programs = _model.ProgramsByChannel[channel.ChannelId].Programs; } bool noEPG = (programs == null || programs.Count == 0); if (noEPG) { DateTime dt = Utils.longtodate(iEnd); long iProgEnd = Utils.datetolong(dt); GuideProgramSummary prog = new GuideProgramSummary() { GuideChannelId = channel.GuideChannelId.HasValue ? channel.GuideChannelId.Value : Guid.Empty, StartTime = Utils.longtodate(iStart), StopTime = Utils.longtodate(iProgEnd), Title = Utility.GetLocalizedText(TextId.NoDataAvailable), SubTitle = String.Empty, Category = String.Empty }; programs = new List<GuideProgramSummary>(); programs.Add(prog); } int iProgram = 0; int iPreviousEndXPos = 0; int width = GetControl((int)Controls.LABEL_TIME1 + 1).XPosition; width -= GetControl((int)Controls.LABEL_TIME1).XPosition; int height = GetControl((int)Controls.IMG_CHAN1 + 1).YPosition; height -= GetControl((int)Controls.IMG_CHAN1).YPosition; foreach (GuideProgramSummary program in programs) { if (Utils.datetolong(program.StopTime) <= iStart || Utils.datetolong(program.StartTime) >= iEnd) continue; string strTitle = program.Title; bool bStartsBefore = false; bool bEndsAfter = false; if (Utils.datetolong(program.StartTime) < iStart) bStartsBefore = true; if (Utils.datetolong(program.StopTime) > iEnd) bEndsAfter = true; DateTime dtBlokStart = new DateTime(); dtBlokStart = _viewingTime; dtBlokStart = dtBlokStart.AddMilliseconds(-dtBlokStart.Millisecond); dtBlokStart = dtBlokStart.AddSeconds(-dtBlokStart.Second); bool isAlert; bool isRecording; string recordIconImage = GetChannelProgramIcon(channel, program.GuideProgramId, out isRecording,out isAlert); if (noEPG && !isRecording) { ActiveRecording rec; isRecording = PluginMain.IsChannelRecording(channel.ChannelId, out rec); } bool bProgramIsHD = (program.Flags & GuideProgramFlags.HighDefinition) != 0; int iStartXPos = 0; int iEndXPos = 0; for (int iBlok = 0; iBlok < _numberOfBlocks; iBlok++) { float fWidthEnd = (float)width; DateTime dtBlokEnd = dtBlokStart.AddMinutes(_timePerBlock - 1); if (IsRunningAt(program, dtBlokStart, dtBlokEnd)) { //dtBlokEnd = dtBlokStart.AddSeconds(_timePerBlock * 60); if (program.StopTime <= dtBlokEnd) { TimeSpan dtSpan = dtBlokEnd - program.StopTime; int iEndMin = _timePerBlock - (dtSpan.Minutes); fWidthEnd = (((float)iEndMin) / ((float)_timePerBlock)) * ((float)(width)); if (bEndsAfter) { fWidthEnd = (float)width; } } if (iStartXPos == 0) { TimeSpan ts = program.StartTime - dtBlokStart; int iStartMin = ts.Hours * 60; iStartMin += ts.Minutes; if (ts.Seconds == 59) { iStartMin += 1; } float fWidth = (((float)iStartMin) / ((float)_timePerBlock)) * ((float)(width)); if (bStartsBefore) { fWidth = 0; } iStartXPos = GetControl(iBlok + (int)Controls.LABEL_TIME1).XPosition; iStartXPos += (int)fWidth; iEndXPos = GetControl(iBlok + (int)Controls.LABEL_TIME1).XPosition + (int)fWidthEnd; } else { iEndXPos = GetControl(iBlok + (int)Controls.LABEL_TIME1).XPosition + (int)fWidthEnd; } } dtBlokStart = dtBlokStart.AddMinutes(_timePerBlock); } if (iStartXPos >= 0) { if (iPreviousEndXPos > iStartXPos) { iStartXPos = iPreviousEndXPos; } if (iEndXPos <= iStartXPos + 5) { iEndXPos = iStartXPos + 6; // at least 1 pixel width } int ypos = GetControl(iChannel + (int)Controls.IMG_CHAN1).YPosition; int iControlId = GUIDE_COMPONENTID_START + iChannel * RowID + iProgram * ColID; int iWidth = iEndXPos - iStartXPos; if (iWidth > 3) { iWidth -= 3; } else { iWidth = 1; } string TexutureFocusLeftName = "tvguide_button_selected_left.png"; string TexutureFocusMidName = "tvguide_button_selected_middle.png"; string TexutureFocusRightName = "tvguide_button_selected_right.png"; string TexutureNoFocusLeftName = "tvguide_button_light_left.png"; string TexutureNoFocusMidName = "tvguide_button_light_middle.png"; string TexutureNoFocusRightName = "tvguide_button_light_right.png"; bool TileFillTFL = false; bool TileFillTNFL = false; bool TileFillTFM = false; bool TileFillTNFM = false; bool TileFillTFR = false; bool TileFillTNFR = false; if (_programNotRunningTemplate != null) { _programNotRunningTemplate.IsVisible = false; TexutureFocusLeftName = _programNotRunningTemplate.TexutureFocusLeftName; TexutureFocusMidName = _programNotRunningTemplate.TexutureFocusMidName; TexutureFocusRightName = _programNotRunningTemplate.TexutureFocusRightName; TexutureNoFocusLeftName = _programNotRunningTemplate.TexutureNoFocusLeftName; TexutureNoFocusMidName = _programNotRunningTemplate.TexutureNoFocusMidName; TexutureNoFocusRightName = _programNotRunningTemplate.TexutureNoFocusRightName; TileFillTFL = _programNotRunningTemplate.TileFillTFL; TileFillTNFL = _programNotRunningTemplate.TileFillTNFL; TileFillTFM = _programNotRunningTemplate.TileFillTFM; TileFillTNFM = _programNotRunningTemplate.TileFillTNFM; TileFillTFR = _programNotRunningTemplate.TileFillTFR; TileFillTNFR = _programNotRunningTemplate.TileFillTNFR; } img = GetControl(iControlId) as GUIButton3PartControl; if (img == null) { img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iWidth, height - 2, TexutureFocusLeftName, TexutureFocusMidName, TexutureFocusRightName, TexutureNoFocusLeftName, TexutureNoFocusMidName, TexutureNoFocusRightName, String.Empty); img.AllocResources(); GUIControl cntl = (GUIControl)img; Add(ref cntl); } else { img.Focus = false; img.SetPosition(iStartXPos, ypos); img.Width = iWidth; img.IsVisible = true; img.DoUpdate(); } img.RenderLeft = false; img.RenderRight = false; img.TexutureIcon = String.Empty; if (recordIconImage != null && isAlert) { if (_programNotifyTemplate != null) { _programNotifyTemplate.IsVisible = false; TexutureFocusLeftName = _programNotifyTemplate.TexutureFocusLeftName; TexutureFocusMidName = _programNotifyTemplate.TexutureFocusMidName; TexutureFocusRightName = _programNotifyTemplate.TexutureFocusRightName; TexutureNoFocusLeftName = _programNotifyTemplate.TexutureNoFocusLeftName; TexutureNoFocusMidName = _programNotifyTemplate.TexutureNoFocusMidName; TexutureNoFocusRightName = _programNotifyTemplate.TexutureNoFocusRightName; TileFillTFL = _programNotifyTemplate.TileFillTFL; TileFillTNFL = _programNotifyTemplate.TileFillTNFL; TileFillTFM = _programNotifyTemplate.TileFillTFM; TileFillTNFM = _programNotifyTemplate.TileFillTNFM; TileFillTFR = _programNotifyTemplate.TileFillTFR; TileFillTNFR = _programNotifyTemplate.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 = _programNotifyTemplate.IconOffsetX; img.IconOffsetY = _programNotifyTemplate.IconOffsetY; img.IconAlign = _programNotifyTemplate.IconAlign; img.IconVAlign = _programNotifyTemplate.IconVAlign; img.IconInlineLabel1 = _programNotifyTemplate.IconInlineLabel1; } else { if (_useNewNotifyButtonColor) { TexutureFocusLeftName = "tvguide_notifyButton_Focus_left.png"; TexutureFocusMidName = "tvguide_notifyButton_Focus_middle.png"; TexutureFocusRightName = "tvguide_notifyButton_Focus_right.png"; TexutureNoFocusLeftName = "tvguide_notifyButton_noFocus_left.png"; TexutureNoFocusMidName = "tvguide_notifyButton_noFocus_middle.png"; TexutureNoFocusRightName = "tvguide_notifyButton_noFocus_right.png"; } else { img.TexutureIcon = Thumbs.TvNotifyIcon; } } } if (recordIconImage != null) { // Select the partial recording template if needed. //if (bPartialRecording) //{ // buttonRecordTemplate = _programPartialRecordTemplate; //} if (isRecording) { GUIButton3PartControl buttonRecordTemplate = _programRecordTemplate; if (buttonRecordTemplate != null) { buttonRecordTemplate.IsVisible = false; TexutureFocusLeftName = buttonRecordTemplate.TexutureFocusLeftName; TexutureFocusMidName = buttonRecordTemplate.TexutureFocusMidName; TexutureFocusRightName = buttonRecordTemplate.TexutureFocusRightName; TexutureNoFocusLeftName = buttonRecordTemplate.TexutureNoFocusLeftName; TexutureNoFocusMidName = buttonRecordTemplate.TexutureNoFocusMidName; TexutureNoFocusRightName = buttonRecordTemplate.TexutureNoFocusRightName; TileFillTFL = buttonRecordTemplate.TileFillTFL; TileFillTNFL = buttonRecordTemplate.TileFillTNFL; TileFillTFM = buttonRecordTemplate.TileFillTFM; TileFillTNFM = buttonRecordTemplate.TileFillTNFM; TileFillTFR = buttonRecordTemplate.TileFillTFR; 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) //{ // TexutureFocusLeftName = "tvguide_recButton_Focus_left.png"; // TexutureFocusMidName = "tvguide_recButton_Focus_middle.png"; // TexutureFocusRightName = "tvguide_recButton_Focus_right.png"; // TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png"; // TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png"; // TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png"; //} img.IconOffsetX = buttonRecordTemplate.IconOffsetX; img.IconOffsetY = buttonRecordTemplate.IconOffsetY; img.IconAlign = buttonRecordTemplate.IconAlign; img.IconVAlign = buttonRecordTemplate.IconVAlign; img.IconInlineLabel1 = buttonRecordTemplate.IconInlineLabel1; } else { //if (bPartialRecording && _useNewPartialRecordingButtonColor) //{ // TexutureFocusLeftName = "tvguide_partRecButton_Focus_left.png"; // TexutureFocusMidName = "tvguide_partRecButton_Focus_middle.png"; // TexutureFocusRightName = "tvguide_partRecButton_Focus_right.png"; // TexutureNoFocusLeftName = "tvguide_partRecButton_noFocus_left.png"; // TexutureNoFocusMidName = "tvguide_partRecButton_noFocus_middle.png"; // TexutureNoFocusRightName = "tvguide_partRecButton_noFocus_right.png"; //} //else { if (_useNewRecordingButtonColor) { TexutureFocusLeftName = "tvguide_recButton_Focus_left.png"; TexutureFocusMidName = "tvguide_recButton_Focus_middle.png"; TexutureFocusRightName = "tvguide_recButton_Focus_right.png"; TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png"; TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png"; TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png"; } } } } img.TexutureIcon = recordIconImage; } img.TexutureIcon2 = String.Empty; if (bProgramIsHD) { if (_programNotRunningTemplate != null) { img.TexutureIcon2 = _programNotRunningTemplate.TexutureIcon2; } else { if (_useHdProgramIcon) { img.TexutureIcon2 = "tvguide_hd_program.png"; } } img.Icon2InlineLabel1 = true; img.Icon2VAlign = GUIControl.VAlignment.ALIGN_MIDDLE; img.Icon2OffsetX = 5; } img.Data = program; img.ColourDiffuse = GetColorForGenre(program.Category); iWidth = iEndXPos - iStartXPos; 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 = strTitle; GUILabelControl labelTemplate; if (IsRunningAt(program, dt)) { labelTemplate = _titleDarkTemplate; } else { labelTemplate = _titleTemplate; } if (labelTemplate != null) { img.FontName1 = labelTemplate.FontName; img.TextColor1 = labelTemplate.TextColor; img.TextColor2 = labelTemplate.TextColor; img.TextOffsetX1 = labelTemplate.XPosition; img.TextOffsetY1 = labelTemplate.YPosition; img.SetShadow1(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor); // This is a legacy behavior check. Adding labelTemplate.XPosition and labelTemplate.YPosition requires // skinners to add these values to the skin xml unless this check exists. Perform a sanity check on the // x,y position to ensure it falls into the bounds of the button. If it does not then fall back to use the // legacy values. This check is necessary because the x,y position (without skin file changes) will be taken // from either the references.xml control template or the controls coded defaults. if (img.TextOffsetY1 > img.Height) { // Set legacy values. img.TextOffsetX1 = 5; img.TextOffsetY1 = 5; } } img.TextOffsetX2 = 5; img.TextOffsetY2 = img.Height / 2; img.FontName2 = "font13"; img.TextColor2 = 0xffffffff; if (IsRunningAt(program, dt)) { labelTemplate = _genreDarkTemplate; } else { labelTemplate = _genreTemplate; } if (labelTemplate != null) { img.FontName2 = labelTemplate.FontName; img.TextColor2 = labelTemplate.TextColor; img.Label2 = program.Category; img.TextOffsetX2 = labelTemplate.XPosition; img.TextOffsetY2 = labelTemplate.YPosition; img.SetShadow2(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor); // This is a legacy behavior check. Adding labelTemplate.XPosition and labelTemplate.YPosition requires // skinners to add these values to the skin xml unless this check exists. Perform a sanity check on the // x,y position to ensure it falls into the bounds of the button. If it does not then fall back to use the // legacy values. This check is necessary because the x,y position (without skin file changes) will be taken // from either the references.xml control template or the controls coded defaults. if (img.TextOffsetY2 > img.Height) { // Set legacy values. img.TextOffsetX2 = 5; img.TextOffsetY2 = 5; } } if (IsRunningAt(program, dt)) { GUIButton3PartControl buttonRunningTemplate = _programRunningTemplate; if (!isRecording && !isAlert && buttonRunningTemplate != null) { buttonRunningTemplate.IsVisible = false; TexutureFocusLeftName = buttonRunningTemplate.TexutureFocusLeftName; TexutureFocusMidName = buttonRunningTemplate.TexutureFocusMidName; TexutureFocusRightName = buttonRunningTemplate.TexutureFocusRightName; TexutureNoFocusLeftName = buttonRunningTemplate.TexutureNoFocusLeftName; TexutureNoFocusMidName = buttonRunningTemplate.TexutureNoFocusMidName; TexutureNoFocusRightName = buttonRunningTemplate.TexutureNoFocusRightName; TileFillTFL = buttonRunningTemplate.TileFillTFL; TileFillTNFL = buttonRunningTemplate.TileFillTNFL; TileFillTFM = buttonRunningTemplate.TileFillTFM; TileFillTNFM = buttonRunningTemplate.TileFillTNFM; TileFillTFR = buttonRunningTemplate.TileFillTFR; TileFillTNFR = buttonRunningTemplate.TileFillTNFR; } else if (isRecording && _useNewRecordingButtonColor) { TexutureFocusLeftName = "tvguide_recButton_Focus_left.png"; TexutureFocusMidName = "tvguide_recButton_Focus_middle.png"; TexutureFocusRightName = "tvguide_recButton_Focus_right.png"; TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png"; TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png"; TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png"; } else if (isAlert && _useNewRecordingButtonColor) { TexutureFocusLeftName = "tvguide_notifyButton_Focus_left.png"; TexutureFocusMidName = "tvguide_notifyButton_Focus_middle.png"; TexutureFocusRightName = "tvguide_notifyButton_Focus_right.png"; TexutureNoFocusLeftName = "tvguide_notifyButton_noFocus_left.png"; TexutureNoFocusMidName = "tvguide_notifyButton_noFocus_middle.png"; TexutureNoFocusRightName = "tvguide_notifyButton_noFocus_right.png"; } else { TexutureFocusLeftName = "tvguide_button_selected_left.png"; TexutureFocusMidName = "tvguide_button_selected_middle.png"; TexutureFocusRightName = "tvguide_button_selected_right.png"; TexutureNoFocusLeftName = "tvguide_button_left.png"; TexutureNoFocusMidName = "tvguide_button_middle.png"; TexutureNoFocusRightName = "tvguide_button_right.png"; } if (selectCurrentShow && iChannel == _cursorX) { _cursorY = iProgram + 1; _currentProgram = Proxies.GuideService.GetProgramById(program.GuideProgramId).Result; m_dtStartTime = program.StartTime; SetProperties(); } } if (bEndsAfter) { img.RenderRight = true; TexutureFocusRightName = "tvguide_arrow_selected_right.png"; TexutureNoFocusRightName = "tvguide_arrow_light_right.png"; if (IsRunningAt(program, dt)) { TexutureNoFocusRightName = "tvguide_arrow_right.png"; } } if (bStartsBefore) { img.RenderLeft = true; TexutureFocusLeftName = "tvguide_arrow_selected_left.png"; TexutureNoFocusLeftName = "tvguide_arrow_light_left.png"; if (IsRunningAt(program, dt)) { TexutureNoFocusLeftName = "tvguide_arrow_left.png"; } } img.TexutureFocusLeftName = TexutureFocusLeftName; img.TexutureFocusMidName = TexutureFocusMidName; img.TexutureFocusRightName = TexutureFocusRightName; img.TexutureNoFocusLeftName = TexutureNoFocusLeftName; img.TexutureNoFocusMidName = TexutureNoFocusMidName; img.TexutureNoFocusRightName = TexutureNoFocusRightName; img.TileFillTFL = TileFillTFL; img.TileFillTNFL = TileFillTNFL; img.TileFillTFM = TileFillTFM; img.TileFillTNFM = TileFillTNFM; img.TileFillTFR = TileFillTFR; img.TileFillTNFR = TileFillTNFR; iProgram++; } iPreviousEndXPos = iEndXPos; } }
internal static bool HasUpcomingProgram(Guid channelId, GuideProgram program, out UpcomingProgram upcomingProgram, ScheduleType scheduleType) { upcomingProgram = null; Guid upcomingProgramId = program.GetUniqueUpcomingProgramId(channelId); List<UpcomingProgram> upcomingPrograms = Proxies.SchedulerService.GetAllUpcomingPrograms(scheduleType, true).Result; foreach (UpcomingProgram upcoming in upcomingPrograms) { if (upcoming.UpcomingProgramId == upcomingProgramId) { upcomingProgram = upcoming; return true; } } return false; }
internal static bool GetUpcomingProgramAndSchedule(Guid channelId, GuideProgram program, out UpcomingProgram upcomingProgram, out Schedule schedule, ScheduleType scheduleType) { schedule = null; if (HasUpcomingProgram(channelId, program, out upcomingProgram, scheduleType)) { schedule = Proxies.SchedulerService.GetScheduleById(upcomingProgram.ScheduleId).Result; return (schedule != null); } return false; }
internal static bool HasUpcomingRecording(Guid channelId, GuideProgram program, out UpcomingRecording upcomingRecording) { upcomingRecording = null; Guid upcomingProgramId = program.GetUniqueUpcomingProgramId(channelId); var upcomingRecordings = Proxies.ControlService.GetAllUpcomingRecordings(UpcomingRecordingsFilter.All, true).Result; foreach (UpcomingRecording recording in upcomingRecordings) { if (recording.Program.UpcomingProgramId == upcomingProgramId) { upcomingRecording = recording; return true; } } return false; }
internal static bool GetUpcomingRecordingAndSchedule(Guid channelId, GuideProgram program, out UpcomingRecording upcomingRecording, out Schedule schedule) { schedule = null; if (HasUpcomingRecording(channelId, program, out upcomingRecording)) { schedule = Proxies.SchedulerService.GetScheduleById(upcomingRecording.Program.ScheduleId).Result; return (schedule != null); } return false; }
public GuideEnricherProgram(GuideProgram guideProgram) { this.guideProgram = guideProgram; this.Matched = this.EpisodeIsEnriched(); this.OriginalSubTitle = this.SubTitle; }
/// <summary> /// Import a new program into the guide. /// </summary> /// <param name="guideProgram">The program to import.</param> /// <param name="source">The source of the program.</param> /// <returns>The ID of the imported program.</returns> public async Task<Guid> ImportProgram(GuideProgram guideProgram, GuideSource source) { var request = NewRequest(HttpMethod.Post, "ImportNewProgram"); request.AddBody(new { Program = guideProgram, Source = source }); var result = await ExecuteAsync<GuideProgramIdResult>(request).ConfigureAwait(false); return result.GuideProgramId; }
public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: // fired when OSD is hidden { Dispose(); GUIPropertyManager.SetProperty("#currentmodule", GUILocalizeStrings.Get(100000 + message.Param1)); return true; } case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: // fired when OSD is shown { GUIPropertyManager.SetProperty("#currentmodule", GUILocalizeStrings.Get(100000 + GetID)); previousProgram = null; AllocResources(); ResetAllControls(); // make sure the controls are positioned relevant to the OSD Y offset isSubMenuVisible = false; m_iActiveMenuButtonID = 0; m_iActiveMenu = 0; m_bNeedRefresh = false; m_dateTime = DateTime.Now; Reset(); FocusControl(GetID, (int)Controls.OSD_PLAY, 0); // set focus to play button by default when window is shown ShowPrograms(); QueueAnimation(AnimationType.WindowOpen); for (int i = (int)Controls.Panel1; i < (int)Controls.Panel2; ++i) { ShowControl(GetID, i); } m_delayInterval = global::MediaPortal.Player.Subtitles.SubEngine.GetInstance().DelayInterval; if (m_delayInterval > 0) m_subtitleDelay = global::MediaPortal.Player.Subtitles.SubEngine.GetInstance().Delay / m_delayInterval; return true; } case GUIMessage.MessageType.GUI_MSG_SETFOCUS: goto case GUIMessage.MessageType.GUI_MSG_LOSTFOCUS; case GUIMessage.MessageType.GUI_MSG_LOSTFOCUS: { if (message.SenderControlId == 13) { return true; } } break; case GUIMessage.MessageType.GUI_MSG_CLICKED: { int iControl = message.SenderControlId; // get the ID of the control sending us a message if (iControl == btnChannelUp.GetID) { OnNextChannel(); } if (iControl == btnChannelDown.GetID) { OnPreviousChannel(); } if (!g_Player.IsTVRecording) { if (iControl == btnPreviousProgram.GetID) { GuideProgram prog = PluginMain.GetProgramAt(m_dateTime); if (prog != null) { prog = PluginMain.GetProgramAt(prog.StartTime.Subtract(new TimeSpan(0, 1, 0))); if (prog != null) { m_dateTime = prog.StartTime.AddMinutes(1); } } ShowPrograms(); } if (iControl == btnNextProgram.GetID) { GuideProgram prog = PluginMain.GetProgramAt(m_dateTime); if (prog != null) { prog = PluginMain.GetProgramAt(prog.StopTime.AddMinutes(+1)); if (prog != null) { m_dateTime = prog.StartTime.AddMinutes(1); } } ShowPrograms(); } } if (iControl >= (int)Controls.OSD_VOLUMESLIDER) // one of the settings (sub menu) controls is sending us a message { Handle_ControlSetting(iControl, message.Param1); } if (iControl == (int)Controls.OSD_PAUSE) { if (g_Player.Paused) { ToggleButton((int)Controls.OSD_PLAY, true); // make sure play button is down (so it shows the pause symbol) ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state } else { ToggleButton((int)Controls.OSD_PLAY, false); // make sure play button is up (so it shows the play symbol) if (g_Player.Speed < 1) // are we not playing back at normal speed { ToggleButton((int)Controls.OSD_REWIND, true); // make sure out button is in the down position ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state } else { ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state if (g_Player.Speed == 1) { ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state } } } } if (iControl == (int)Controls.OSD_PLAY) { int iSpeed = g_Player.Speed; if (iSpeed != 1) // we're in ffwd or rewind mode { g_Player.Speed = 1; // drop back to single speed ToggleButton((int)Controls.OSD_REWIND, false); // pop all the relevant ToggleButton((int)Controls.OSD_FFWD, false); // buttons back to ToggleButton((int)Controls.OSD_PLAY, false); // their up state } else { g_Player.Pause(); //Pause/Un-Pause playback if (g_Player.Paused) { ToggleButton((int)Controls.OSD_PLAY, true); // make sure play button is down (so it shows the pause symbol) } else { ToggleButton((int)Controls.OSD_PLAY, false); // make sure play button is up (so it shows the play symbol) } } } if (iControl == (int)Controls.OSD_STOP) { if (isSubMenuVisible) // sub menu currently active ? { FocusControl(GetID, m_iActiveMenuButtonID, 0); // set focus to last menu button ToggleSubMenu(0, m_iActiveMenu); // hide the currently active sub-menu } Log.Debug("TVOSD:stop"); } if (iControl == (int)Controls.OSD_REWIND) { if (g_Player.Paused) { g_Player.Pause(); // Unpause playback } if (g_Player.Speed < 1) // are we not playing back at normal speed { ToggleButton((int)Controls.OSD_REWIND, true); // make sure out button is in the down position ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state } else { ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state if (g_Player.Speed == 1) { ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state } } } if (iControl == (int)Controls.OSD_FFWD) { if (g_Player.Paused) { g_Player.Pause(); // Unpause playback } if (g_Player.Speed > 1) // are we not playing back at normal speed { ToggleButton((int)Controls.OSD_FFWD, true); // make sure out button is in the down position ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state } else { ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state if (g_Player.Speed == 1) { ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state } } } if (iControl == (int)Controls.OSD_SKIPBWD) { if (_immediateSeekIsRelative) { g_Player.SeekRelativePercentage(-_immediateSeekValue); } else { g_Player.SeekRelative(-_immediateSeekValue); } ToggleButton((int)Controls.OSD_SKIPBWD, false); // pop the button back to it's up state } if (iControl == (int)Controls.OSD_SKIPFWD) { if (_immediateSeekIsRelative) { g_Player.SeekRelativePercentage(_immediateSeekValue); } else { g_Player.SeekRelative(_immediateSeekValue); } ToggleButton((int)Controls.OSD_SKIPFWD, false); // pop the button back to it's up state } if (iControl == (int)Controls.OSD_MUTE) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_VOL); // hide or show the sub-menu if (isSubMenuVisible) // is sub menu on? { ShowControl(GetID, (int)Controls.OSD_VOLUMESLIDER); // show the volume control FocusControl(GetID, (int)Controls.OSD_VOLUMESLIDER, 0); // set focus to it } else // sub menu is off { FocusControl(GetID, (int)Controls.OSD_MUTE, 0); // set focus to the mute button } } if (iControl == (int)Controls.OSD_SUBTITLES) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_SUBTITLES); // hide or show the sub-menu if (isSubMenuVisible) { // set the controls values GUISliderControl pControl = (GUISliderControl)GetControl((int)Controls.OSD_SUBTITLE_DELAY); pControl.SpinType = GUISpinControl.SpinType.SPIN_CONTROL_TYPE_FLOAT; pControl.FloatInterval = 1; pControl.SetRange(-10, 10); SetSliderValue(-10, 10, m_subtitleDelay, (int)Controls.OSD_SUBTITLE_DELAY); SetCheckmarkValue(g_Player.EnableSubtitle, (int)Controls.OSD_SUBTITLE_ONOFF); // show the controls on this sub menu ShowControl(GetID, (int)Controls.OSD_SUBTITLE_DELAY); ShowControl(GetID, (int)Controls.OSD_SUBTITLE_DELAY_LABEL); ShowControl(GetID, (int)Controls.OSD_SUBTITLE_ONOFF); ShowControl(GetID, (int)Controls.OSD_SUBTITLE_LIST); FocusControl(GetID, (int)Controls.OSD_SUBTITLE_DELAY, 0); // set focus to the first control in our group PopulateSubTitles(); // populate the list control with subtitles for this video } } if (iControl == (int)Controls.OSD_BOOKMARKS) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_BOOKMARKS); // hide or show the sub-menu if (isSubMenuVisible) { // show the controls on this sub menu ShowControl(GetID, (int)Controls.OSD_CREATEBOOKMARK); ShowControl(GetID, (int)Controls.OSD_BOOKMARKS_LIST); ShowControl(GetID, (int)Controls.OSD_BOOKMARKS_LIST_LABEL); ShowControl(GetID, (int)Controls.OSD_CLEARBOOKMARKS); FocusControl(GetID, (int)Controls.OSD_CREATEBOOKMARK, 0); // set focus to the first control in our group } } if (iControl == (int)Controls.OSD_VIDEO) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_VIDEO); // hide or show the sub-menu if (isSubMenuVisible) // is sub menu on? { // set the controls values float fPercent = (float)(100 * (g_Player.CurrentPosition / g_Player.Duration)); SetSliderValue(0.0f, 100.0f, (float)fPercent, (int)Controls.OSD_VIDEOPOS); UpdateGammaContrastBrightness(); // show the controls on this sub menu ShowControl(GetID, (int)Controls.OSD_VIDEOPOS); ShowControl(GetID, (int)Controls.OSD_SATURATIONLABEL); ShowControl(GetID, (int)Controls.OSD_SATURATION); ShowControl(GetID, (int)Controls.OSD_SHARPNESSLABEL); ShowControl(GetID, (int)Controls.OSD_SHARPNESS); ShowControl(GetID, (int)Controls.OSD_VIDEOPOS_LABEL); ShowControl(GetID, (int)Controls.OSD_BRIGHTNESS); ShowControl(GetID, (int)Controls.OSD_BRIGHTNESSLABEL); ShowControl(GetID, (int)Controls.OSD_CONTRAST); ShowControl(GetID, (int)Controls.OSD_CONTRASTLABEL); ShowControl(GetID, (int)Controls.OSD_GAMMA); ShowControl(GetID, (int)Controls.OSD_GAMMALABEL); FocusControl(GetID, (int)Controls.OSD_VIDEOPOS, 0); // set focus to the first control in our group } } if (iControl == (int)Controls.OSD_AUDIO) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_AUDIO); // hide or show the sub-menu if (isSubMenuVisible) // is sub menu on? { // show the controls on this sub menu ShowControl(GetID, (int)Controls.OSD_AVDELAY); ShowControl(GetID, (int)Controls.OSD_AVDELAY_LABEL); lstAudioStreamList.Visible = true; FocusControl(GetID, (int)Controls.OSD_AVDELAY, 0); // set focus to the first control in our group PopulateAudioStreams(); // populate the list control with audio streams for this video } } return true; } } return base.OnMessage(message); }
private void UpdateProgressBar() { if (!g_Player.IsTVRecording) { double fPercent; GuideProgram prog = PluginMain.GetCurrentProgram(ChannelType.Television); if (prog == null) { GUIPropertyManager.SetProperty("#TV.View.Percentage", "0"); return; } string strTime = String.Format("{0}-{1}", prog.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), prog.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); TimeSpan ts = prog.StopTime - prog.StartTime; double iTotalSecs = ts.TotalSeconds; ts = DateTime.Now - prog.StartTime; double iCurSecs = ts.TotalSeconds; fPercent = ((double)iCurSecs) / ((double)iTotalSecs); fPercent *= 100.0d; GUIPropertyManager.SetProperty("#TV.View.Percentage", fPercent.ToString()); Get_TimeInfo(); bool updateProperties = false; if (previousProgram == null) { m_dateTime = DateTime.Now; previousProgram = prog; ShowPrograms(); updateProperties = true; } else if (previousProgram.StartTime != prog.StartTime || previousProgram.GuideChannelId != prog.GuideChannelId) { m_dateTime = DateTime.Now; previousProgram = prog; ShowPrograms(); updateProperties = true; } if (updateProperties) { GUIPropertyManager.SetProperty("#TV.View.channel", GetChannelName()); GUIPropertyManager.SetProperty("#TV.View.start", prog.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); GUIPropertyManager.SetProperty("#TV.View.stop", prog.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); GUIPropertyManager.SetProperty("#TV.View.remaining", Utils.SecondsToHMSString(prog.StopTime - prog.StartTime)); GUIPropertyManager.SetProperty("#TV.View.genre", prog.Category); GUIPropertyManager.SetProperty("#TV.View.title", prog.Title); GUIPropertyManager.SetProperty("#TV.View.compositetitle", prog.CreateProgramTitle()); GUIPropertyManager.SetProperty("#TV.View.subtitle", prog.SubTitle); GUIPropertyManager.SetProperty("#TV.View.description", prog.CreateCombinedDescription(false)); GUIPropertyManager.SetProperty("#TV.View.episode", prog.EpisodeNumberDisplay); } } else { Recording rec = null; string startTime = ""; string endTime = ""; string channelDisplayName = ""; rec = TvRecorded.GetPlayingRecording(); if (rec != null && rec.ChannelType == ChannelType.Television) { long currentPosition = (long)(g_Player.CurrentPosition); startTime = Utils.SecondsToHMSString((int)currentPosition); long duration = (long)(g_Player.Duration); endTime = Utils.SecondsToHMSString((int)duration); channelDisplayName = rec.ChannelDisplayName + " " + Utility.GetLocalizedText(TextId.RecordedSuffix); double fPercent; if (rec == null) { GUIPropertyManager.SetProperty("#TV.View.Percentage", "0"); return; } fPercent = ((double)currentPosition) / ((double)duration); fPercent *= 100.0d; GUIPropertyManager.SetProperty("#TV.View.Percentage", fPercent.ToString()); Get_TimeInfo(); GUIPropertyManager.SetProperty("#TV.View.channel", channelDisplayName); GUIPropertyManager.SetProperty("#TV.View.start", startTime); GUIPropertyManager.SetProperty("#TV.View.stop", endTime); GUIPropertyManager.SetProperty("#TV.View.genre", rec.Category); GUIPropertyManager.SetProperty("#TV.View.title", rec.Title); GUIPropertyManager.SetProperty("#TV.View.compositetitle", rec.CreateCombinedDescription(false)); GUIPropertyManager.SetProperty("#TV.View.description", rec.Description); GUIPropertyManager.SetProperty("#TV.View.subtitle", rec.SubTitle); GUIPropertyManager.SetProperty("#TV.View.episode", rec.EpisodeNumberDisplay); } } }
private void SetLabels(UpcomingProgram program) { //set program description if (_currentProgram == null) return; Channel _channel = Channel; if (program != null && program.GuideProgramId.HasValue) { if (_ProgramToShow != null && _ProgramToShow.GuideProgramId == program.GuideProgramId.Value) { return; } _ProgramToShow = Proxies.GuideService.GetProgramById(program.GuideProgramId.Value).Result; _channel = program.Channel; } else { _ProgramToShow = _currentProgram; } string strTime = String.Format("{0} {1} - {2}", Utility.GetShortDayDateString(_ProgramToShow.StartTime), _ProgramToShow.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), _ProgramToShow.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); if (_ProgramToShow.Category != null) _categoryLabel.Label = _ProgramToShow.Category; else _categoryLabel.Label = string.Empty; _programChannelFadeLabel.Label = _channel.DisplayName; _programTimeLabel.Label = strTime; _descriptionScrollUp.Label = _ProgramToShow.CreateCombinedDescription(true); _programTitleFadeLabel.Label = _ProgramToShow.Title; }
public override bool OnMessage(GUIMessage message) { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: // fired when OSD is hidden { //if (g_application.m_pPlayer) g_application.m_pPlayer.ShowOSD(true); // following line should stay. Problems with OSD not // appearing are already fixed elsewhere //for (int i = (int)Controls.Panel1; i < (int)Controls.Panel2; i++) //{ // HideControl(GetID, i); //} Dispose(); GUIPropertyManager.SetProperty("#currentmodule", GUIWindowManager.GetWindow(message.Param1).GetModuleName()); return true; } case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: // fired when OSD is shown { GUIPropertyManager.SetProperty("#currentmodule", GetModuleName()); previousProgram = null; AllocResources(); // if (g_application.m_pPlayer) g_application.m_pPlayer.ShowOSD(false); ResetAllControls(); // make sure the controls are positioned relevant to the OSD Y offset isSubMenuVisible = false; m_iActiveMenuButtonID = 0; m_iActiveMenu = 0; m_bNeedRefresh = false; m_dateTime = DateTime.Now; Reset(); FocusControl(GetID, (int)Controls.OSD_PLAY, 0); // set focus to play button by default when window is shown ShowPrograms(); QueueAnimation(AnimationType.WindowOpen); for (int i = (int)Controls.Panel1; i < (int)Controls.Panel2; i++) { ShowControl(GetID, i); } if (g_Player.Paused) { ToggleButton((int)Controls.OSD_PLAY, true); // make sure play button is down (so it shows the pause symbol) } else { ToggleButton((int)Controls.OSD_PLAY, false); // make sure play button is up (so it shows the play symbol) } m_delayInterval = global::MediaPortal.Player.Subtitles.SubEngine.GetInstance().DelayInterval; if (m_delayInterval > 0) m_subtitleDelay = global::MediaPortal.Player.Subtitles.SubEngine.GetInstance().Delay / m_delayInterval; m_delayIntervalAudio = PostProcessingEngine.GetInstance().AudioDelayInterval; if (m_delayIntervalAudio > 0) m_audioDelay = PostProcessingEngine.GetInstance().AudioDelay / m_delayIntervalAudio; return true; } case GUIMessage.MessageType.GUI_MSG_SETFOCUS: goto case GUIMessage.MessageType.GUI_MSG_LOSTFOCUS; case GUIMessage.MessageType.GUI_MSG_LOSTFOCUS: { if (message.SenderControlId == 13) { return true; } } break; case GUIMessage.MessageType.GUI_MSG_CLICKED: { int iControl = message.SenderControlId; // get the ID of the control sending us a message if (iControl == btnChannelUp.GetID) { OnNextChannel(); } if (iControl == btnChannelDown.GetID) { OnPreviousChannel(); } if (!g_Player.IsTVRecording) { if (iControl == btnPreviousProgram.GetID) { GuideProgram prog = PluginMain.GetProgramAt(m_dateTime); if (prog != null) { prog = PluginMain.GetProgramAt(prog.StartTime.Subtract(new TimeSpan(0, 1, 0))); if (prog != null) { m_dateTime = prog.StartTime.AddMinutes(1); } } ShowPrograms(); } if (iControl == btnNextProgram.GetID) { GuideProgram prog = PluginMain.GetProgramAt(m_dateTime); if (prog != null) { prog = PluginMain.GetProgramAt(prog.StopTime.AddMinutes(+1)); if (prog != null) { m_dateTime = prog.StartTime.AddMinutes(1); } } ShowPrograms(); } } if (iControl >= (int)Controls.OSD_VOLUMESLIDER) // one of the settings (sub menu) controls is sending us a message { Handle_ControlSetting(iControl, message.Param1); } if (iControl == (int)Controls.OSD_PAUSE) { if (g_Player.Paused) { ToggleButton((int)Controls.OSD_PLAY, true); // make sure play button is down (so it shows the pause symbol) ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state } else { ToggleButton((int)Controls.OSD_PLAY, false); // make sure play button is up (so it shows the play symbol) if (g_Player.Speed < 1) // are we not playing back at normal speed { ToggleButton((int)Controls.OSD_REWIND, true); // make sure out button is in the down position ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state } else { ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state if (g_Player.Speed == 1) { ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state } } } } if (iControl == (int)Controls.OSD_PLAY) { //TODO int iSpeed = g_Player.Speed; if (iSpeed != 1) // we're in ffwd or rewind mode { g_Player.Speed = 1; // drop back to single speed ToggleButton((int)Controls.OSD_REWIND, false); // pop all the relevant ToggleButton((int)Controls.OSD_FFWD, false); // buttons back to ToggleButton((int)Controls.OSD_PLAY, false); // their up state } else { g_Player.Pause(); // Pause/Un-Pause playback if (g_Player.Paused) { ToggleButton((int)Controls.OSD_PLAY, true); // make sure play button is down (so it shows the pause symbol) } else { ToggleButton((int)Controls.OSD_PLAY, false); // make sure play button is up (so it shows the play symbol) } } } if (iControl == (int)Controls.OSD_STOP) { if (isSubMenuVisible) // sub menu currently active ? { FocusControl(GetID, m_iActiveMenuButtonID, 0); // set focus to last menu button ToggleSubMenu(0, m_iActiveMenu); // hide the currently active sub-menu } //g_application.m_guiWindowFullScreen.m_bOSDVisible = false; // toggle the OSD off so parent window can de-init Log.Debug("TVOSD:stop"); //GUIWindowManager.ShowPreviousWindow(); // go back to the previous window } if (iControl == (int)Controls.OSD_REWIND) { if (g_Player.Paused) { g_Player.Pause(); // Unpause playback } if (g_Player.Speed < 1) // are we not playing back at normal speed { ToggleButton((int)Controls.OSD_REWIND, true); // make sure out button is in the down position ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state } else { ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state if (g_Player.Speed == 1) { ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state } } } if (iControl == (int)Controls.OSD_FFWD) { if (g_Player.Paused) { g_Player.Pause(); // Unpause playback } if (g_Player.Speed > 1) // are we not playing back at normal speed { ToggleButton((int)Controls.OSD_FFWD, true); // make sure out button is in the down position ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state } else { ToggleButton((int)Controls.OSD_FFWD, false); // pop the button back to it's up state if (g_Player.Speed == 1) { ToggleButton((int)Controls.OSD_REWIND, false); // pop the button back to it's up state } } } if (iControl == (int)Controls.OSD_SKIPBWD) { if (_immediateSeekIsRelative) { g_Player.SeekRelativePercentage(-_immediateSeekValue); } else { g_Player.SeekRelative(-_immediateSeekValue); } ToggleButton((int)Controls.OSD_SKIPBWD, false); // pop the button back to it's up state } if (iControl == (int)Controls.OSD_SKIPFWD) { if (_immediateSeekIsRelative) { g_Player.SeekRelativePercentage(_immediateSeekValue); } else { g_Player.SeekRelative(_immediateSeekValue); } ToggleButton((int)Controls.OSD_SKIPFWD, false); // pop the button back to it's up state } if (iControl == (int)Controls.OSD_MUTE) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_VOL); // hide or show the sub-menu if (isSubMenuVisible) // is sub menu on? { int iValue = g_Player.Volume; GUISliderControl pSlider = GetControl((int)Controls.OSD_VOLUMESLIDER) as GUISliderControl; if (null != pSlider) { pSlider.Percentage = iValue; // Update our volume slider accordingly ... } ShowControl(GetID, (int)Controls.OSD_VOLUMESLIDER); // show the volume control ShowControl(GetID, (int)Controls.OSD_VOLUMESLIDER_LABEL); FocusControl(GetID, (int)Controls.OSD_VOLUMESLIDER, 0); // set focus to it } else // sub menu is off { FocusControl(GetID, (int)Controls.OSD_MUTE, 0); // set focus to the mute button } } if (iControl == (int)Controls.OSD_SUBTITLES) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_SUBTITLES); // hide or show the sub-menu if (isSubMenuVisible) { // set the controls values GUISliderControl pControl = (GUISliderControl)GetControl((int)Controls.OSD_SUBTITLE_DELAY); pControl.SpinType = GUISpinControl.SpinType.SPIN_CONTROL_TYPE_FLOAT; pControl.FloatInterval = 1; pControl.SetRange(-10, 10); SetSliderValue(-10, 10, m_subtitleDelay, (int)Controls.OSD_SUBTITLE_DELAY); SetCheckmarkValue(g_Player.EnableSubtitle, (int)Controls.OSD_SUBTITLE_ONOFF); // show the controls on this sub menu ShowControl(GetID, (int)Controls.OSD_SUBTITLE_DELAY); ShowControl(GetID, (int)Controls.OSD_SUBTITLE_DELAY_LABEL); ShowControl(GetID, (int)Controls.OSD_SUBTITLE_ONOFF); ShowControl(GetID, (int)Controls.OSD_SUBTITLE_LIST); FocusControl(GetID, (int)Controls.OSD_SUBTITLE_DELAY, 0); // set focus to the first control in our group PopulateSubTitles(); // populate the list control with subtitles for this video } } if (iControl == (int)Controls.OSD_BOOKMARKS) { //not used } if (iControl == (int)Controls.OSD_VIDEO) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_VIDEO); // hide or show the sub-menu if (isSubMenuVisible) // is sub menu on? { // set the controls values float fPercent = (float)(100 * (g_Player.CurrentPosition / g_Player.Duration)); SetSliderValue(0.0f, 100.0f, (float)fPercent, (int)Controls.OSD_VIDEOPOS); bool hasPostProc = g_Player.HasPostprocessing; if (hasPostProc) { IPostProcessingEngine engine = PostProcessingEngine.GetInstance(); SetCheckmarkValue(engine.EnablePostProcess, (int)Controls.OSD_VIDEO_POSTPROC_DEBLOCK_ONOFF); SetCheckmarkValue(engine.EnableResize, (int)Controls.OSD_VIDEO_POSTPROC_RESIZE_ONOFF); SetCheckmarkValue(engine.EnableCrop, (int)Controls.OSD_VIDEO_POSTPROC_CROP_ONOFF); SetCheckmarkValue(engine.EnableDeinterlace, (int)Controls.OSD_VIDEO_POSTPROC_DEINTERLACE_ONOFF); UpdatePostProcessing(); ShowControl(GetID, (int)Controls.OSD_VIDEO_POSTPROC_DEBLOCK_ONOFF); ShowControl(GetID, (int)Controls.OSD_VIDEO_POSTPROC_RESIZE_ONOFF); ShowControl(GetID, (int)Controls.OSD_VIDEO_POSTPROC_CROP_ONOFF); ShowControl(GetID, (int)Controls.OSD_VIDEO_POSTPROC_DEINTERLACE_ONOFF); ShowControl(GetID, (int)Controls.OSD_VIDEO_POSTPROC_CROP_VERTICAL); ShowControl(GetID, (int)Controls.OSD_VIDEO_POSTPROC_CROP_HORIZONTAL); ShowControl(GetID, (int)Controls.OSD_VIDEO_POSTPROC_CROP_VERTICAL_LABEL); ShowControl(GetID, (int)Controls.OSD_VIDEO_POSTPROC_CROP_HORIZONTAL_LABEL); } //SetCheckmarkValue(g_stSettings.m_bNonInterleaved, Controls.OSD_NONINTERLEAVED); //SetCheckmarkValue(g_stSettings.m_bNoCache, Controls.OSD_NOCACHE); //SetCheckmarkValue(g_stSettings.m_bFrameRateConversions, Controls.OSD_ADJFRAMERATE); UpdateGammaContrastBrightness(); // show the controls on this sub menu ShowControl(GetID, (int)Controls.OSD_VIDEOPOS); ShowControl(GetID, (int)Controls.OSD_VIDEOPOS_LABEL); ShowControl(GetID, (int)Controls.OSD_NONINTERLEAVED); ShowControl(GetID, (int)Controls.OSD_NOCACHE); ShowControl(GetID, (int)Controls.OSD_ADJFRAMERATE); ShowControl(GetID, (int)Controls.OSD_SATURATIONLABEL); ShowControl(GetID, (int)Controls.OSD_SATURATION); ShowControl(GetID, (int)Controls.OSD_SHARPNESSLABEL); ShowControl(GetID, (int)Controls.OSD_SHARPNESS); ShowControl(GetID, (int)Controls.OSD_BRIGHTNESS); ShowControl(GetID, (int)Controls.OSD_BRIGHTNESSLABEL); ShowControl(GetID, (int)Controls.OSD_CONTRAST); ShowControl(GetID, (int)Controls.OSD_CONTRASTLABEL); ShowControl(GetID, (int)Controls.OSD_GAMMA); ShowControl(GetID, (int)Controls.OSD_GAMMALABEL); FocusControl(GetID, (int)Controls.OSD_VIDEOPOS, 0); // set focus to the first control in our group } } if (iControl == (int)Controls.OSD_AUDIO) { ToggleSubMenu(iControl, (int)Controls.OSD_SUBMENU_BG_AUDIO); // hide or show the sub-menu if (isSubMenuVisible) // is sub menu on? { int iValue = g_Player.Volume; GUISliderControl pSlider = GetControl((int)Controls.OSD_AUDIOVOLUMESLIDER) as GUISliderControl; if (null != pSlider) { pSlider.Percentage = iValue; // Update our volume slider accordingly ... } // set the controls values GUISliderControl pControl = (GUISliderControl)GetControl((int)Controls.OSD_AVDELAY); pControl.SpinType = GUISpinControl.SpinType.SPIN_CONTROL_TYPE_FLOAT; pControl.SetRange(-20, 20); SetSliderValue(-20, 20, m_audioDelay, (int)Controls.OSD_AVDELAY); bool hasPostProc = g_Player.HasPostprocessing; if (hasPostProc) { GUIPropertyManager.SetProperty("#TvOSD.AudioVideoDelayPossible", "true"); pControl.FloatInterval = 1; } else { GUIPropertyManager.SetProperty("#TvOSD.AudioVideoDelayPossible", "false"); pControl.FloatValue = 0; m_audioDelay = 0; pControl.FloatInterval = 0; } // show the controls on this sub menu ShowControl(GetID, (int)Controls.OSD_AVDELAY); ShowControl(GetID, (int)Controls.OSD_AVDELAY_LABEL); ShowControl(GetID, (int)Controls.OSD_AUDIOSTREAM_LIST); ShowControl(GetID, (int)Controls.OSD_AUDIOVOLUMESLIDER); ShowControl(GetID, (int)Controls.OSD_AUDIOVOLUMESLIDER_LABEL); FocusControl(GetID, (int)Controls.OSD_AVDELAY, 0); // set focus to the first control in our group PopulateAudioStreams(); // populate the list control with audio streams for this video } } return true; } } return base.OnMessage(message); }
internal static bool RecordProgram(Channel channel, GuideProgram guideProgram, ScheduleType scheduleType, bool NeedConfirm) { Log.Debug("TVProgammInfo.RecordProgram - channel = {0}, program = {1}", channel.DisplayName, guideProgram.CreateProgramTitle()); bool hasUpcomingRecording = false; bool hasUpcomingAlert = false; if (scheduleType == ScheduleType.Recording) { UpcomingRecording upcomingRecording; if (HasUpcomingRecording(channel.ChannelId, guideProgram, out upcomingRecording)) { hasUpcomingRecording = true; if (upcomingRecording.Program.IsCancelled) { switch (upcomingRecording.Program.CancellationReason) { case UpcomingCancellationReason.Manual: Proxies.SchedulerService.UncancelUpcomingProgram(upcomingRecording.Program.ScheduleId, guideProgram.GuideProgramId, channel.ChannelId, guideProgram.StartTime).Wait(); return true; case UpcomingCancellationReason.AlreadyQueued: { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.Record)); dlg.SetLine(1, Utility.GetLocalizedText(TextId.ThisProgramIsAlreadyQueued)); dlg.SetLine(2, Utility.GetLocalizedText(TextId.ForRecordingAtAnEarlierTime)); dlg.DoModal(GUIWindowManager.ActiveWindow); } break; case UpcomingCancellationReason.PreviouslyRecorded: { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.Record)); dlg.SetLine(1, Utility.GetLocalizedText(TextId.ThisProgramWasPreviouslyRecorded)); dlg.DoModal(GUIWindowManager.ActiveWindow); } break; } } else { if (upcomingRecording.Program.IsPartOfSeries) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.DeleteProgram)); dlg.Add(Utility.GetLocalizedText(TextId.CancelThisShow)); dlg.Add(Utility.GetLocalizedText(TextId.DeleteEntireSchedule)); dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId > 0) { switch (dlg.SelectedLabel) { case 0: // Cancel Proxies.SchedulerService.CancelUpcomingProgram(upcomingRecording.Program.ScheduleId, guideProgram.GuideProgramId, channel.ChannelId, guideProgram.StartTime).Wait(); return true; case 1: // Delete Schedule schedule = Proxies.SchedulerService.GetScheduleById(upcomingRecording.Program.ScheduleId).Result; if (schedule != null) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.DeleteEntireSchedule)); dlgYesNo.SetLine(1, "\"" + schedule.Name + "\""); dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure)); dlgYesNo.SetLine(3, String.Empty); dlgYesNo.SetDefaultToYes(false); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (dlgYesNo.IsConfirmed) { Proxies.SchedulerService.DeleteSchedule(upcomingRecording.Program.ScheduleId).Wait(); return true; } } } break; } } } } else { if (PluginMain.IsActiveRecording(channel.ChannelId, guideProgram)) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.StopRecording)); dlgYesNo.SetLine(1, channel.DisplayName); dlgYesNo.SetLine(2, guideProgram.Title); dlgYesNo.SetLine(3, string.Empty); dlgYesNo.SetDefaultToYes(false); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (!dlgYesNo.IsConfirmed) { return false; } } } else if (PluginMain.IsActiveRecording(channel.ChannelId, guideProgram) == false && NeedConfirm) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.DontRecord)); dlgYesNo.SetLine(1, channel.DisplayName); dlgYesNo.SetLine(2, guideProgram.Title); dlgYesNo.SetLine(3, string.Empty); dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (!dlgYesNo.IsConfirmed) { return false; } } } Proxies.SchedulerService.DeleteSchedule(upcomingRecording.Program.ScheduleId).Wait(); return true; } } } } else if (scheduleType == ScheduleType.Alert) { UpcomingProgram upcomingProgram; if (HasUpcomingProgram(channel.ChannelId, guideProgram, out upcomingProgram, scheduleType)) { hasUpcomingAlert = true; if (upcomingProgram.IsCancelled) { switch (upcomingProgram.CancellationReason) { case UpcomingCancellationReason.Manual: Proxies.SchedulerService.UncancelUpcomingProgram(upcomingProgram.ScheduleId, guideProgram.GuideProgramId, channel.ChannelId, guideProgram.StartTime).Wait(); return true; case UpcomingCancellationReason.AlreadyQueued: { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.Record)); dlg.SetLine(1, Utility.GetLocalizedText(TextId.ThisProgramIsAlreadyQueued)); dlg.SetLine(2, Utility.GetLocalizedText(TextId.ForRecordingAtAnEarlierTime)); dlg.DoModal(GUIWindowManager.ActiveWindow); } break; case UpcomingCancellationReason.PreviouslyRecorded: { GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.Record)); dlg.SetLine(1, Utility.GetLocalizedText(TextId.ThisProgramWasPreviouslyRecorded)); dlg.DoModal(GUIWindowManager.ActiveWindow); } break; } } else { if (upcomingProgram.IsPartOfSeries) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.DeleteProgram)); dlg.Add(Utility.GetLocalizedText(TextId.CancelThisShow)); dlg.Add(Utility.GetLocalizedText(TextId.DeleteEntireSchedule)); dlg.DoModal(GUIWindowManager.ActiveWindow); if (dlg.SelectedId > 0) { switch (dlg.SelectedLabel) { case 0: // Cancel Proxies.SchedulerService.CancelUpcomingProgram(upcomingProgram.ScheduleId, guideProgram.GuideProgramId, channel.ChannelId, guideProgram.StartTime).Wait(); return true; case 1: // Delete Schedule schedule = Proxies.SchedulerService.GetScheduleById(upcomingProgram.ScheduleId).Result; if (schedule != null) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.DeleteEntireSchedule)); dlgYesNo.SetLine(1, "\"" + schedule.Name + "\""); dlgYesNo.SetLine(2, Utility.GetLocalizedText(TextId.AreYouSure)); dlgYesNo.SetLine(3, String.Empty); dlgYesNo.SetDefaultToYes(false); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (dlgYesNo.IsConfirmed) { Proxies.SchedulerService.DeleteSchedule(upcomingProgram.ScheduleId).Wait(); return true; } } } break; } } } } else { if (NeedConfirm) { GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (dlgYesNo != null) { dlgYesNo.SetHeading(Utility.GetLocalizedText(TextId.DontRecord)); dlgYesNo.SetLine(1, channel.DisplayName); dlgYesNo.SetLine(2, guideProgram.Title); dlgYesNo.SetLine(3, string.Empty); dlgYesNo.SetDefaultToYes(true); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); if (!dlgYesNo.IsConfirmed) { return false; } } } Proxies.SchedulerService.DeleteSchedule(upcomingProgram.ScheduleId).Wait(); return true; } } } } if (!hasUpcomingRecording && !hasUpcomingAlert) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU); if (dlg != null) { Schedule newSchedule = null; GuideController.RepeatingType dayRepeatingType; dlg.Reset(); dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectScheduleType)); dlg.Add(Utility.GetLocalizedText(TextId.Once)); dlg.Add(Utility.GetLocalizedText(TextId.EverytimeOnThisChannel)); dlg.Add(Utility.GetLocalizedText(TextId.EverytimeOnEveryChannel)); dlg.Add(Utility.GetLocalizedText(TextId.EveryWeekAtThisTime)); dlg.Add(Utility.GetLocalizedText(TextId.EveryDayAtThisTime)); if (guideProgram.StartTime.DayOfWeek == DayOfWeek.Saturday || guideProgram.StartTime.DayOfWeek == DayOfWeek.Sunday) { dayRepeatingType = GuideController.RepeatingType.SatSun; dlg.Add(Utility.GetLocalizedText(TextId.SatSun)); } else { dayRepeatingType = GuideController.RepeatingType.MonFri; dlg.Add(Utility.GetLocalizedText(TextId.MonFri)); } dlg.DoModal(GUIWindowManager.ActiveWindow); switch (dlg.SelectedLabel) { case 0: //once newSchedule = GuideController.CreateRecordOnceSchedule(channel.ChannelType, channel.ChannelId, guideProgram.Title, guideProgram.SubTitle, guideProgram.EpisodeNumberDisplay, guideProgram.StartTime); break; case 1: //everytime, this channel newSchedule = GuideController.CreateRecordRepeatingSchedule(GuideController.RepeatingType.AnyTimeThisChannel, channel.ChannelType, channel.ChannelId, guideProgram.Title, guideProgram.StartTime, "(" + Utility.GetLocalizedText(TextId.AlwaysThisChannel) + ")"); ScheduleRule newEpisodesRule = FindNewEpisodesOnlyRule(newSchedule); if (newEpisodesRule != null) { newEpisodesRule.Arguments[0] = false; } break; case 2: //everytime, any channel newSchedule = GuideController.CreateRecordRepeatingSchedule(GuideController.RepeatingType.AnyTime, channel.ChannelType, null, guideProgram.Title, guideProgram.StartTime, "(" + Utility.GetLocalizedText(TextId.AlwaysEveryChannel) + ")"); ScheduleRule newEpisodesRule2 = FindNewEpisodesOnlyRule(newSchedule); if (newEpisodesRule2 != null) { newEpisodesRule2.Arguments[0] = false; } break; case 3: //weekly newSchedule = GuideController.CreateRecordRepeatingSchedule(GuideController.RepeatingType.Weekly, channel.ChannelType, channel.ChannelId, guideProgram.Title, guideProgram.StartTime, "(" + Utility.GetLocalizedText(TextId.Weekly) + ")"); break; case 4: //daily newSchedule = GuideController.CreateRecordRepeatingSchedule(GuideController.RepeatingType.Daily, channel.ChannelType, channel.ChannelId, guideProgram.Title, guideProgram.StartTime, "(" + Utility.GetLocalizedText(TextId.Daily) + ")"); break; case 5: //Mon-Fri or Sat-Sun string repeatingTime = string.Empty; if (dayRepeatingType == GuideController.RepeatingType.MonFri) { repeatingTime = "(" + Utility.GetLocalizedText(TextId.MonFri) + ")"; } else if (dayRepeatingType == GuideController.RepeatingType.SatSun) { repeatingTime = "(" + Utility.GetLocalizedText(TextId.SatSun) + ")"; } newSchedule = GuideController.CreateRecordRepeatingSchedule(dayRepeatingType, channel.ChannelType, channel.ChannelId, guideProgram.Title, guideProgram.StartTime, repeatingTime); break; } if (newSchedule != null) { newSchedule.ScheduleType = scheduleType; Proxies.SchedulerService.SaveSchedule(newSchedule).Wait(); return true; } } } return false; }
private GuideProgram FillGuideProgram(OleDbDataReader dataReader) { GuideProgram guideProgram = new GuideProgram(); //try //{ guideProgram.StartTime = DateTime.Parse(dataReader["StartTime"].ToString()); guideProgram.StartTimeUtc = guideProgram.StartTime.ToUniversalTime(); guideProgram.StopTime = DateTime.Parse(dataReader["EndTime"].ToString()); guideProgram.StopTimeUtc = guideProgram.StopTime.ToUniversalTime(); if (guideProgram.StartTimeUtc >= guideProgram.StopTimeUtc) { return null; } guideProgram.Title = dataReader["Title"].ToString(); string subTitle = dataReader["SubTitle"].ToString(); if (!String.IsNullOrEmpty(subTitle) && !subTitle.Equals(guideProgram.Title)) { guideProgram.SubTitle = subTitle; } if (_useShortDesc) { string shortDescription = dataReader["ShortDescription"].ToString().Replace("<br>", " "); guideProgram.Description = TrimAndCutString(shortDescription, 3999); } else { string description = dataReader["Description"].ToString().Replace("<br>", " "); guideProgram.Description = TrimAndCutString(description, 4000); } guideProgram.Actors = BuildCredits(dataReader["Actors"].ToString()); guideProgram.Directors = BuildCredits(dataReader["Director"].ToString()); if (!String.IsNullOrEmpty(dataReader["Rating"].ToString())) { guideProgram.Rating = BuildRating(dataReader["Rating"].ToString()); } if (_addShortCritic && !String.IsNullOrEmpty(dataReader["ShortCritic"].ToString())) { guideProgram.Rating = guideProgram.Rating + ", " + dataReader["ShortCritic"].ToString(); } if (!String.IsNullOrEmpty(guideProgram.Rating)) { guideProgram.Rating = TrimAndCutString(guideProgram.Rating, 49); } guideProgram.StarRating = 0; try { guideProgram.StarRating = Convert.ToSingle(dataReader["StarRating"].ToString()) / 6; } catch { } if (dataReader["ImageFormat16to9"] != null && (bool)dataReader["ImageFormat16to9"]) { guideProgram.Flags |= GuideProgramFlags.WidescreenAspectRatio; } guideProgram.IsRepeat = false; if (dataReader["IsRepeat"] != null && (bool)dataReader["IsRepeat"] ) { guideProgram.IsRepeat = true; } guideProgram.Category = TrimAndCutString(dataReader["Category"].ToString(), 49); //} //catch { } return guideProgram; }
public override bool OnMessage(GUIMessage message) { try { switch (message.Message) { case GUIMessage.MessageType.GUI_MSG_PERCENTAGE_CHANGED: if (message.SenderControlId == (int)Controls.HORZ_SCROLLBAR) { _needUpdate = true; float fPercentage = (float)message.Param1; fPercentage /= 100.0f; fPercentage *= 24.0f; fPercentage *= 60.0f; _viewingTime = new DateTime(_viewingTime.Year, _viewingTime.Month, _viewingTime.Day, 0, 0, 0, 0); _viewingTime = _viewingTime.AddMinutes((int)fPercentage); } if (message.SenderControlId == (int)Controls.VERT_SCROLLBAR) { _needUpdate = true; float fPercentage = (float)message.Param1; fPercentage /= 100.0f; if (_singleChannelView) { fPercentage *= (float)_totalProgramCount; int iChan = (int)fPercentage; _channelOffset = 0; _cursorX = 0; while (iChan >= _channelCount) { iChan -= _channelCount; _channelOffset += _channelCount; } _cursorX = iChan; } else { fPercentage *= (float)_channelList.Count; int iChan = (int)fPercentage; _channelOffset = 0; _cursorX = 0; while (iChan >= _channelCount) { iChan -= _channelCount; _channelOffset += _channelCount; } _cursorX = iChan; } } break; case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT: { base.OnMessage(message); SaveSettings(); //_recordingList.Clear(); //_controls = new Dictionary<int, GUIButton3PartControl>(); _channelList = null; _recordingList = null; _currentProgram = null; return true; } case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT: { GUIPropertyManager.SetProperty("#itemcount", string.Empty); GUIPropertyManager.SetProperty("#selecteditem", string.Empty); GUIPropertyManager.SetProperty("#selecteditem2", string.Empty); GUIPropertyManager.SetProperty("#selectedthumb", string.Empty); if (_shouldRestore) { DoRestoreSkin(); } else { LoadSkin(); AllocResources(); } InitControls(); base.OnMessage(message); string currentChannelName; LoadSettings(out currentChannelName); UpdateOverlayAllowed(); GUIGraphicsContext.Overlay = _isOverlayAllowed; // set topbar autohide switch (_autoHideTopbarType) { case AutoHideTopBar.No: _autoHideTopbar = false; break; case AutoHideTopBar.Yes: _autoHideTopbar = true; break; default: _autoHideTopbar = GUIGraphicsContext.DefaultTopBarHide; break; } GUIGraphicsContext.AutoHideTopBar = _autoHideTopbar; GUIGraphicsContext.TopBarHidden = _autoHideTopbar; GUIGraphicsContext.DisableTopBar = _disableTopBar; LoadSettings(); GUIControl cntlPanel = GetControl((int)Controls.PANEL_BACKGROUND); GUIImage cntlChannelTemplate = (GUIImage)GetControl((int)Controls.CHANNEL_TEMPLATE); int iHeight = cntlPanel.Height + cntlPanel.YPosition - cntlChannelTemplate.YPosition; int iItemHeight = cntlChannelTemplate.Height; _channelCount = (int)(((float)iHeight) / ((float)iItemHeight)); bool isPreviousWindowTvGuideRelated = (message.Param1 == (int)Window.WINDOW_TV_PROGRAM_INFO || message.Param1 == (int)Window.WINDOW_VIDEO_INFO); if (!isPreviousWindowTvGuideRelated) { UnFocus(); } GetChannels(true); LoadSchedules(true); _currentProgram = null; if (!isPreviousWindowTvGuideRelated) { _viewingTime = DateTime.Now; _cursorY = 0; _cursorX = 0; _channelOffset = 0; _singleChannelView = false; _showChannelLogos = false; _currentChannel = null; int index = 0; foreach (GuideBaseChannel channel in _channelList) { if (channel.channel.DisplayName == currentChannelName) { _currentChannel = channel.channel; _cursorX = index; break; } index++; } } while (_cursorX >= _channelCount) { _cursorX -= _channelCount; _channelOffset += _channelCount; } // Mantis 3579: the above lines can lead to too large channeloffset. // Now we check if the offset is too large, and if it is, we reduce it and increase the cursor position accordingly if (!_guideContinuousScroll && (_channelOffset > _channelList.Count - _channelCount) && (_channelList.Count - _channelCount > 0)) { _cursorX += _channelOffset - (_channelList.Count - _channelCount); _channelOffset = _channelList.Count - _channelCount; } GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl; if (cntlDay != null) { DateTime dtNow = DateTime.Now; cntlDay.Reset(); cntlDay.SetRange(0, MaxDaysInGuide - 1); for (int iDay = 0; iDay < MaxDaysInGuide; iDay++) { DateTime dtTemp = dtNow.AddDays(iDay); string day; switch (dtTemp.DayOfWeek) { case DayOfWeek.Monday: day = GUILocalizeStrings.Get(657); break; case DayOfWeek.Tuesday: day = GUILocalizeStrings.Get(658); break; case DayOfWeek.Wednesday: day = GUILocalizeStrings.Get(659); break; case DayOfWeek.Thursday: day = GUILocalizeStrings.Get(660); break; case DayOfWeek.Friday: day = GUILocalizeStrings.Get(661); break; case DayOfWeek.Saturday: day = GUILocalizeStrings.Get(662); break; default: day = GUILocalizeStrings.Get(663); break; } day = GetLocalDate(day, dtTemp.Day, dtTemp.Month); cntlDay.AddLabel(day, iDay); } } else { Log.Debug("TvGuideBase: SpinControl cntlDay is null!"); } GUISpinControl cntlTimeInterval = GetControl((int)Controls.SPINCONTROL_TIME_INTERVAL) as GUISpinControl; if (cntlTimeInterval != null) { cntlTimeInterval.Reset(); for (int i = 1; i <= 4; i++) { cntlTimeInterval.AddLabel(String.Empty, i); } cntlTimeInterval.Value = (_timePerBlock / 15) - 1; } else { Log.Debug("TvGuideBase: SpinControl cntlTimeInterval is null!"); } if (!isPreviousWindowTvGuideRelated) { Update(true); } else { Update(false); } SetFocus(); if (_currentProgram != null) { m_dtStartTime = _currentProgram.StartTime; } UpdateCurrentProgram(false); return true; } //break; case GUIMessage.MessageType.GUI_MSG_CLICKED: int iControl = message.SenderControlId; if (iControl == (int)Controls.SPINCONTROL_DAY) { GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl; int iDay = cntlDay.Value; _viewingTime = DateTime.Now; _viewingTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, _viewingTime.Hour, _viewingTime.Minute, 0, 0); _viewingTime = _viewingTime.AddDays(iDay); _recalculateProgramOffset = true; Update(false); SetFocus(); return true; } if (iControl == (int)Controls.SPINCONTROL_TIME_INTERVAL) { GUISpinControl cntlTimeInt = GetControl((int)Controls.SPINCONTROL_TIME_INTERVAL) as GUISpinControl; int iInterval = (cntlTimeInt.Value) + 1; if (iInterval > 4) { iInterval = 4; } _timePerBlock = iInterval * 15; Update(false); SetFocus(); return true; } if (iControl == (int)Controls.CHANNEL_GROUP_BUTTON) { OnSelectChannelGroup(); return true; } if (iControl >= GUIDE_COMPONENTID_START) { if (OnSelectItem(true)) { Update(false); SetFocus(); } } else if (_cursorY == 0) { OnSwitchMode(); } break; } } catch (Exception ex) { Log.Debug("TvGuideBase: {0}", ex); } return base.OnMessage(message); }
private void UpdateCurrentProgram(bool updateIcon) { if (_cursorX < 0) { return; } if (_cursorY < 0) { return; } if (_cursorY == 0) { SetProperties(); SetFocus(); return; } int iControlId = GUIDE_COMPONENTID_START + _cursorX * RowID + (_cursorY - 1) * ColID; GUIButton3PartControl img = GetControl(iControlId) as GUIButton3PartControl; if (null != img) { SetFocus(); _currentProgram = Proxies.GuideService.GetProgramById(((GuideProgramSummary)img.Data).GuideProgramId).Result; if (updateIcon) { bool isRecording; bool isAlert; string recordIconImage = GetChannelProgramIcon(_currentChannel, _currentProgram.GuideProgramId, out isRecording, out isAlert); img.TexutureIcon = recordIconImage == null ? String.Empty : recordIconImage; } SetProperties(); } }
internal static bool HasUpcomingRecording(Guid channelId, GuideProgram program, out UpcomingRecording upcomingRecording) { using (ControlServiceAgent tvControlAgent = new ControlServiceAgent()) { upcomingRecording = null; Guid upcomingProgramId = program.GetUniqueUpcomingProgramId(channelId); UpcomingRecording[] upcomingRecordings = tvControlAgent.GetAllUpcomingRecordings(UpcomingRecordingsFilter.All, true); foreach (UpcomingRecording recording in upcomingRecordings) { if (recording.Program.UpcomingProgramId == upcomingProgramId) { upcomingRecording = recording; return true; } } return false; } }
/// <summary> /// Calculates the duration of a program and sets the Duration property /// </summary> private string GetDuration(GuideProgram program) { if (program.GuideProgramId == Guid.Empty) { return ""; } string space = " "; DateTime progStart = program.StartTime; DateTime progEnd = program.StopTime; TimeSpan progDuration = progEnd.Subtract(progStart); string duration = ""; switch (progDuration.Hours) { case 0: duration = progDuration.Minutes + space + GUILocalizeStrings.Get(3004); break; case 1: if (progDuration.Minutes == 1) { duration = progDuration.Hours + space + GUILocalizeStrings.Get(3001) + ", " + progDuration.Minutes + space + GUILocalizeStrings.Get(3003); } else if (progDuration.Minutes > 1) { duration = progDuration.Hours + space + GUILocalizeStrings.Get(3001) + ", " + progDuration.Minutes + space + GUILocalizeStrings.Get(3004); } else { duration = progDuration.Hours + space + GUILocalizeStrings.Get(3001); } break; default: if (progDuration.Minutes == 1) { duration = progDuration.Hours + " Hours" + ", " + progDuration.Minutes + space + GUILocalizeStrings.Get(3003); } else if (progDuration.Minutes > 0) { duration = progDuration.Hours + " Hours" + ", " + progDuration.Minutes + space + GUILocalizeStrings.Get(3004); } else { duration = progDuration.Hours + space + GUILocalizeStrings.Get(3002); } break; } return duration; }
private void AdaptGuideProgramTimeToLocalTimeZone(GuideProgram guideProgram) { guideProgram.StartTime = AdjustGmtToLocal(guideProgram.StartTime); guideProgram.StopTime = AdjustGmtToLocal(guideProgram.StopTime); }
/// <summary> /// Calculates how long from current time a program starts or started, set the TimeFromNow property /// </summary> private string GetStartTimeFromNow(GuideProgram program) { string timeFromNow = String.Empty; if (program.GuideProgramId == Guid.Empty) { return timeFromNow; } string space = " "; string strRemaining = String.Empty; DateTime progStart = program.StartTime; TimeSpan timeRelative = progStart.Subtract(DateTime.Now); if (timeRelative.Days == 0) { if (timeRelative.Hours >= 0 && timeRelative.Minutes >= 0) { switch (timeRelative.Hours) { case 0: if (timeRelative.Minutes == 1) { timeFromNow = GUILocalizeStrings.Get(3009) + " " + timeRelative.Minutes + space + GUILocalizeStrings.Get(3003); // starts in 1 minute } else if (timeRelative.Minutes > 1) { timeFromNow = GUILocalizeStrings.Get(3009) + " " + timeRelative.Minutes + space + GUILocalizeStrings.Get(3004); //starts in x minutes } else { timeFromNow = GUILocalizeStrings.Get(3013); } break; case 1: if (timeRelative.Minutes == 1) { timeFromNow = GUILocalizeStrings.Get(3009) + " " + timeRelative.Hours + space + GUILocalizeStrings.Get(3001) + ", " + timeRelative.Minutes + space + GUILocalizeStrings.Get(3003); //starts in 1 hour, 1 minute } else if (timeRelative.Minutes > 1) { timeFromNow = GUILocalizeStrings.Get(3009) + " " + timeRelative.Hours + space + GUILocalizeStrings.Get(3001) + ", " + timeRelative.Minutes + space + GUILocalizeStrings.Get(3004); //starts in 1 hour, x minutes } else { timeFromNow = GUILocalizeStrings.Get(3009) + " " + timeRelative.Hours + GUILocalizeStrings.Get(3001); //starts in 1 hour } break; default: if (timeRelative.Minutes == 1) { timeFromNow = GUILocalizeStrings.Get(3009) + " " + timeRelative.Hours + space + GUILocalizeStrings.Get(3002) + ", " + timeRelative.Minutes + space + GUILocalizeStrings.Get(3003); //starts in x hours, 1 minute } else if (timeRelative.Minutes > 1) { timeFromNow = GUILocalizeStrings.Get(3009) + " " + timeRelative.Hours + space + GUILocalizeStrings.Get(3002) + ", " + timeRelative.Minutes + space + GUILocalizeStrings.Get(3004); //starts in x hours, x minutes } else { timeFromNow = GUILocalizeStrings.Get(3009) + " " + timeRelative.Hours + space + GUILocalizeStrings.Get(3002); //starts in x hours } break; } } else //already started { DateTime progEnd = program.StopTime; TimeSpan tsRemaining = DateTime.Now.Subtract(progEnd); if (tsRemaining.Minutes > 0) { timeFromNow = GUILocalizeStrings.Get(3016); return timeFromNow; } switch (tsRemaining.Hours) { case 0: if (timeRelative.Minutes == 1) { strRemaining = "(" + -tsRemaining.Minutes + space + GUILocalizeStrings.Get(3018) + ")"; //(1 Minute Remaining) } else { strRemaining = "(" + -tsRemaining.Minutes + space + GUILocalizeStrings.Get(3010) + ")"; //(x Minutes Remaining) } break; case -1: if (timeRelative.Minutes == 1) { strRemaining = "(" + -tsRemaining.Hours + space + GUILocalizeStrings.Get(3001) + ", " + -tsRemaining.Minutes + space + GUILocalizeStrings.Get(3018) + ")"; //(1 Hour,1 Minute Remaining) } else if (timeRelative.Minutes > 1) { strRemaining = "(" + -tsRemaining.Hours + space + GUILocalizeStrings.Get(3001) + ", " + -tsRemaining.Minutes + space + GUILocalizeStrings.Get(3010) + ")"; //(1 Hour,x Minutes Remaining) } else { strRemaining = "(" + -tsRemaining.Hours + space + GUILocalizeStrings.Get(3012) + ")"; //(1 Hour Remaining) } break; default: if (timeRelative.Minutes == 1) { strRemaining = "(" + -tsRemaining.Hours + space + GUILocalizeStrings.Get(3002) + ", " + -tsRemaining.Minutes + space + GUILocalizeStrings.Get(3018) + ")"; //(x Hours,1 Minute Remaining) } else if (timeRelative.Minutes > 1) { strRemaining = "(" + -tsRemaining.Hours + space + GUILocalizeStrings.Get(3002) + ", " + -tsRemaining.Minutes + space + GUILocalizeStrings.Get(3010) + ")"; //(x Hours,x Minutes Remaining) } else { strRemaining = "(" + -tsRemaining.Hours + space + GUILocalizeStrings.Get(3012) + ")"; //(x Hours Remaining) } break; } switch (timeRelative.Hours) { case 0: if (timeRelative.Minutes == -1) { timeFromNow = GUILocalizeStrings.Get(3017) + -timeRelative.Minutes + space + GUILocalizeStrings.Get(3007) + space + strRemaining; //Started 1 Minute ago } else if (timeRelative.Minutes < -1) { timeFromNow = GUILocalizeStrings.Get(3017) + -timeRelative.Minutes + space + GUILocalizeStrings.Get(3008) + space + strRemaining; //Started x Minutes ago } else { timeFromNow = GUILocalizeStrings.Get(3013); //Starting Now } break; case -1: if (timeRelative.Minutes == -1) { timeFromNow = GUILocalizeStrings.Get(3017) + -timeRelative.Hours + space + GUILocalizeStrings.Get(3001) + ", " + -timeRelative.Minutes + space + GUILocalizeStrings.Get(3007) + " " + strRemaining; //Started 1 Hour,1 Minute ago } else if (timeRelative.Minutes < -1) { timeFromNow = GUILocalizeStrings.Get(3017) + -timeRelative.Hours + space + GUILocalizeStrings.Get(3001) + ", " + -timeRelative.Minutes + space + GUILocalizeStrings.Get(3008) + " " + strRemaining; //Started 1 Hour,x Minutes ago } else { timeFromNow = GUILocalizeStrings.Get(3017) + -timeRelative.Hours + space + GUILocalizeStrings.Get(3005) + space + strRemaining; //Started 1 Hour ago } break; default: if (timeRelative.Minutes == -1) { timeFromNow = GUILocalizeStrings.Get(3017) + -timeRelative.Hours + space + GUILocalizeStrings.Get(3006) + ", " + -timeRelative.Minutes + space + GUILocalizeStrings.Get(3008) + " " + strRemaining; //Started x Hours,1 Minute ago } else if (timeRelative.Minutes < -1) { timeFromNow = GUILocalizeStrings.Get(3017) + -timeRelative.Hours + space + GUILocalizeStrings.Get(3006) + ", " + -timeRelative.Minutes + space + GUILocalizeStrings.Get(3008) + " " + strRemaining; //Started x Hours,x Minutes ago } else { timeFromNow = GUILocalizeStrings.Get(3017) + -timeRelative.Hours + space + GUILocalizeStrings.Get(3006) + space + strRemaining; //Started x Hours ago } break; } } } else { if (timeRelative.Days == 1) { timeFromNow = GUILocalizeStrings.Get(3009) + space + timeRelative.Days + space + GUILocalizeStrings.Get(3014); //Starts in 1 Day } else { timeFromNow = GUILocalizeStrings.Get(3009) + space + timeRelative.Days + space + GUILocalizeStrings.Get(3015); //Starts in x Days } } return timeFromNow; }
public void EpisodeIsEnricherReturnsFalseWhenNoEpisodeNumber() { var guideProgram = new GuideProgram(); var program = new GuideEnricherProgram(guideProgram); program.EpisodeIsEnriched().ShouldBeFalse(); }
private void ImportEpgPrograms(EpgChannel epgChannel) { if (!this.IsArgusTVConnectionInitialized) { InitializeArgusTVConnection(null); } if (this.IsArgusTVConnectionInitialized) { TvDatabase.TvBusinessLayer layer = new TvDatabase.TvBusinessLayer(); bool epgSyncOn = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncOn, false.ToString()).Value); if (epgSyncOn) { DVBBaseChannel dvbChannel = epgChannel.Channel as DVBBaseChannel; if (dvbChannel != null) { TvDatabase.Channel mpChannel = layer.GetChannelByTuningDetail(dvbChannel.NetworkId, dvbChannel.TransportId, dvbChannel.ServiceId); if (mpChannel != null) { Log.Debug("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms(): received {0} programs on {1}", epgChannel.Programs.Count, mpChannel.DisplayName); using (CoreServiceAgent coreAgent = new CoreServiceAgent()) using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent()) using (GuideServiceAgent tvGuideAgent = new GuideServiceAgent()) { bool epgSyncAutoCreateChannels = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannels, false.ToString()).Value); bool epgSyncAutoCreateChannelsWithGroup = Convert.ToBoolean(layer.GetSetting(SettingName.EpgSyncAutoCreateChannelsWithGroup, false.ToString()).Value); string epgLanguages = layer.GetSetting("epgLanguages").Value; Channel channel = EnsureChannelForDvbEpg(tvSchedulerAgent, mpChannel, epgSyncAutoCreateChannels, epgSyncAutoCreateChannelsWithGroup); if (channel != null) { EnsureGuideChannelForDvbEpg(tvSchedulerAgent, tvGuideAgent, channel, mpChannel); List<GuideProgram> guidePrograms = new List<GuideProgram>(); foreach (EpgProgram epgProgram in epgChannel.Programs) { string title; string description; string genre; int starRating; string classification; int parentalRating; GetProgramInfoForLanguage(epgProgram.Text, epgLanguages, out title, out description, out genre, out starRating, out classification, out parentalRating); if (!String.IsNullOrEmpty(title)) { GuideProgram guideProgram = new GuideProgram(); guideProgram.GuideChannelId = channel.GuideChannelId.Value; guideProgram.StartTime = epgProgram.StartTime; guideProgram.StopTime = epgProgram.EndTime; guideProgram.StartTimeUtc = epgProgram.StartTime.ToUniversalTime(); guideProgram.StopTime = epgProgram.EndTime; guideProgram.StopTimeUtc = epgProgram.EndTime.ToUniversalTime(); guideProgram.Title = title; guideProgram.Description = description; guideProgram.Category = genre; guideProgram.Rating = classification; guideProgram.StarRating = starRating / 7.0; guidePrograms.Add(guideProgram); } } _dvbEpgThread.ImportProgramsAsync(guidePrograms); } else { Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to ensure channel."); } } } else { Log.Info("ArgusTV.Recorder.MediaPortalTvServer: ImportEpgPrograms() failed to find MP channel."); } } } } }
/// <summary> /// Create a single string with episode information (episode title and/or number). /// </summary> /// <returns>A string with all episode information.</returns> public string CreateEpisodeTitle() { return(GuideProgram.CreateEpisodeTitle(this.SubTitle, this.EpisodeNumberDisplay)); }