diff --git a/TvEngine3/Mediaportal/TV/TvPlugin/Helper/TVUtil.cs b/TvEngine3/Mediaportal/TV/TvPlugin/Helper/TVUtil.cs index 7e72cd7d335..ec9c6da47a7 100644 --- a/TvEngine3/Mediaportal/TV/TvPlugin/Helper/TVUtil.cs +++ b/TvEngine3/Mediaportal/TV/TvPlugin/Helper/TVUtil.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Configuration; +using System.Globalization; using System.IO; using System.Linq; using System.Text; @@ -98,7 +99,7 @@ public static void SetGentleConfigFile() throw; } } - + public IList GetRecordingTimes(ScheduleBLL rec) { IList programs = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsForSchedule(rec.Entity).ToList(); @@ -113,7 +114,7 @@ private IList AddProgramsToSchedulesList(ScheduleBLL rec, IList AddProgramsToSchedulesList(ScheduleBLL rec, IList @@ -244,7 +292,7 @@ public static void TitleDisplay(StringBuilder strBuilder, string title, string e string episodePart) { strBuilder.Append(title); - GetEpisodeInfo(strBuilder, episodeName, seriesNum, episodeNum, episodePart); + GetEpisodeInfo(strBuilder, episodeName, seriesNum, episodeNum, episodePart); } @@ -262,7 +310,7 @@ public static string GetFileNameForTimeshifting() { bool fileExists = File.Exists(TVHome.Card.TimeShiftFileName); if (!fileExists) - // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. + // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. { if (TVHome.TimeshiftingPath().Length > 0) { @@ -303,7 +351,7 @@ public static string GetFileNameForRecording(Recording rec) { bool fileExists = File.Exists(rec.FileName); if (!fileExists) - // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. + // fileName does not exist b/c it points to the local folder on the tvserver, which is ofcourse invalid on the tv client. { if (TVHome.RecordingPath().Length > 0) { @@ -314,7 +362,7 @@ public static string GetFileNameForRecording(Recording rec) fileExists = File.Exists(fileNameSimple); if (!fileExists) - //maybe file exist in folder, schedules recs often appear in folders, no way to intelligently determine this. + //maybe file exist in folder, schedules recs often appear in folders, no way to intelligently determine this. { DirectoryInfo dirInfo = Directory.GetParent(rec.FileName); @@ -348,7 +396,7 @@ public static string GetFileNameForRecording(Recording rec) return fileName; } - + public static bool PlayRecording(Recording rec) { return PlayRecording(rec, 0); @@ -358,7 +406,7 @@ public static bool PlayRecording(Recording rec, double startOffset) { return PlayRecording(rec, startOffset, g_Player.MediaType.Recording); } - + public static bool PlayRecording(Recording rec, double startOffset, g_Player.MediaType mediaType) { string fileName = GetFileNameForRecording(rec); @@ -383,7 +431,7 @@ public static bool PlayRecording(Recording rec, double startOffset, g_Player.Med double dTime = g_Player.Duration - 5; g_Player.SeekAbsolute(dTime); } - + TvRecorded.SetActiveRecording(rec); //populates recording metadata to g_player; @@ -392,13 +440,13 @@ public static bool PlayRecording(Recording rec, double startOffset, g_Player.Med g_Player.currentDescription = rec.Description; rec.TimesWatched++; - ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(rec); + ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(rec); return true; } return false; } - public static string GetChannelLogo (Channel channel) + public static string GetChannelLogo(Channel channel) { string logo = String.Empty; if (null != channel && channel.MediaType == (int)MediaTypeEnum.TV) @@ -438,15 +486,15 @@ public static bool DeleteRecAndSchedQuietly(Schedule schedule, DateTime canceled { bool wasDeleted = false; if (IsValidSchedule(schedule)) - { + { Schedule parentSchedule = null; GetParentAndSpawnSchedule(ref schedule, out parentSchedule); - wasDeleted = StopRecAndDeleteSchedule(schedule, parentSchedule, idChannel, canceledStartTime); + wasDeleted = StopRecAndDeleteSchedule(schedule, parentSchedule, idChannel, canceledStartTime); } return wasDeleted; } - + /// /// Deletes a single or a complete schedule. /// If the schedule is currently recording, then this is stopped also. @@ -457,7 +505,7 @@ public static bool DeleteRecAndSchedQuietly(Schedule schedule, DateTime canceled public static bool DeleteRecAndEntireSchedQuietly(Schedule schedule) { DateTime canceledStartTime = schedule.StartTime; - return (DeleteRecAndEntireSchedQuietly(schedule, canceledStartTime)); + return (DeleteRecAndEntireSchedQuietly(schedule, canceledStartTime)); } /// @@ -474,7 +522,7 @@ public static bool DeleteRecAndEntireSchedQuietly(Schedule schedule, DateTime ca if (IsValidSchedule(schedule)) { Schedule parentSchedule = null; - wasDeleted = StopRecAndDeleteEntireSchedule(schedule, parentSchedule, canceledStartTime); + wasDeleted = StopRecAndDeleteEntireSchedule(schedule, parentSchedule, canceledStartTime); } return wasDeleted; } @@ -492,7 +540,7 @@ public static bool StopRecAndSchedWithPrompt(Schedule schedule, int idChannel) { DateTime canceledStartTime = schedule.StartTime; return (StopRecAndSchedWithPrompt(schedule, canceledStartTime, idChannel)); - } + } /// /// Deletes a single or a complete schedule. @@ -529,10 +577,10 @@ public static bool StopRecAndSchedWithPrompt(Schedule schedule, DateTime cancele /// start time of the schedule to cancel /// true if the schedule was deleted, otherwise false public static bool DeleteRecAndSchedWithPrompt(Schedule schedule, Program prg) - { + { bool wasDeleted = false; if (IsValidSchedule(schedule)) - { + { Schedule parentSchedule = null; bool confirmed = true; GetParentAndSpawnSchedule(ref schedule, out parentSchedule); @@ -541,10 +589,10 @@ public static bool DeleteRecAndSchedWithPrompt(Schedule schedule, Program prg) if (confirmed) { if (prg != null) - { + { DateTime canceledStartTime = new ScheduleBLL(schedule).GetSchedStartTimeForProg(prg); int idChannel = prg.IdChannel; - wasDeleted = StopRecAndDeleteSchedule(schedule, parentSchedule, idChannel, canceledStartTime); + wasDeleted = StopRecAndDeleteSchedule(schedule, parentSchedule, idChannel, canceledStartTime); } else { @@ -571,11 +619,11 @@ public static bool DeleteRecAndSchedWithPrompt(Schedule schedule) schedule.EndTime); wasDeleted = DeleteRecAndSchedWithPrompt(schedule, prg); } - - return wasDeleted; - } - /// + return wasDeleted; + } + + /// /// Deletes a single or a complete schedule. /// The user is being prompted if the schedule is currently recording. /// If the schedule is currently recording, then this is stopped also. @@ -586,7 +634,7 @@ public static bool DeleteRecAndSchedWithPrompt(Schedule schedule) public static bool DeleteRecAndEntireSchedWithPrompt(Schedule schedule) { DateTime canceledStartTime = schedule.StartTime; - return (DeleteRecAndEntireSchedWithPrompt(schedule, canceledStartTime)); + return (DeleteRecAndEntireSchedWithPrompt(schedule, canceledStartTime)); } /// @@ -602,16 +650,16 @@ public static bool DeleteRecAndEntireSchedWithPrompt(Schedule schedule, DateTime { bool wasDeleted = false; if (IsValidSchedule(schedule)) - { - Schedule parentSchedule = null; + { + Schedule parentSchedule = null; bool confirmed = true; GetParentAndSpawnSchedule(ref schedule, out parentSchedule); - - confirmed = PromptDeleteRecording(schedule.IdSchedule); + + confirmed = PromptDeleteRecording(schedule.IdSchedule); if (confirmed) { wasDeleted = StopRecAndDeleteEntireSchedule(schedule, parentSchedule, canceledStartTime); - } + } } return wasDeleted; } @@ -628,26 +676,26 @@ private static bool StopRecAndDeleteSchedule(Schedule schedule, Schedule parentS if (isScheduleTypeOnce && !wasDeleted) { wasDeleted = DeleteSchedule(schedule.IdSchedule); - } + } } - - + + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); return wasDeleted || wasCanceled; } private static bool StopRecAndDeleteEntireSchedule(Schedule schedule, Schedule parentSchedule, DateTime canceledStartTime) { - int idChannel = schedule.IdChannel; - - bool wasRecStopped = StopRecording(schedule); - bool wasDeleted = DeleteEntireOrOnceSchedule(schedule, parentSchedule); - + int idChannel = schedule.IdChannel; + + bool wasRecStopped = StopRecording(schedule); + bool wasDeleted = DeleteEntireOrOnceSchedule(schedule, parentSchedule); + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); return wasRecStopped || wasDeleted; } - private static bool IsScheduleTypeOnce (int IdSchedule) + private static bool IsScheduleTypeOnce(int IdSchedule) { Schedule schedule = ServiceAgents.Instance.ScheduleServiceAgent.GetSchedule(IdSchedule); bool isOnce = (schedule.ScheduleType == (int)ScheduleRecordingType.Once); @@ -659,32 +707,32 @@ private static bool DeleteEntireOrOnceSchedule(Schedule schedule, Schedule paren //is the schedule recording, then stop it now. bool wasDeleted = false; try - { + { if (parentSchedule != null) { - wasDeleted = DeleteSchedule(parentSchedule.IdSchedule); + wasDeleted = DeleteSchedule(parentSchedule.IdSchedule); } if (schedule != null) { - wasDeleted = DeleteSchedule(schedule.IdSchedule); - } + wasDeleted = DeleteSchedule(schedule.IdSchedule); + } } catch (Exception) { //consume ex - } + } return wasDeleted; } - private static bool DeleteSchedule (int idSchedule) + private static bool DeleteSchedule(int idSchedule) { bool scheduleDeleted = false; if (idSchedule > 0) { Schedule sched2del = ServiceAgents.Instance.ScheduleServiceAgent.GetSchedule(idSchedule); if (sched2del != null) - { + { ServiceAgents.Instance.ScheduleServiceAgent.DeleteSchedule(sched2del.IdSchedule); } scheduleDeleted = true; @@ -711,13 +759,13 @@ private static bool CancelEpisode(DateTime cancelStartTime, Schedule scheduleToC { DateTime cancel = cancelStartTime; int IdForScheduleToCancel = scheduleToCancel.IdSchedule; - CanceledSchedule canceledSchedule = CanceledScheduleFactory.CreateCanceledSchedule(IdForScheduleToCancel, idChannel, cancel); + CanceledSchedule canceledSchedule = CanceledScheduleFactory.CreateCanceledSchedule(IdForScheduleToCancel, idChannel, cancel); ServiceAgents.Instance.CanceledScheduleServiceAgent.SaveCanceledSchedule(canceledSchedule); episodeCanceled = true; } } return episodeCanceled; - } + } private static bool PromptStopRecording(int IdSchedule) { @@ -726,7 +774,7 @@ private static bool PromptStopRecording(int IdSchedule) if (isRec) { - GUIDialogYesNo dlgYesNo = (GUIDialogYesNo) GUIWindowManager.GetWindow((int) GUIWindow.Window.WINDOW_DIALOG_YES_NO); + GUIDialogYesNo dlgYesNo = (GUIDialogYesNo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_YES_NO); if (null == dlgYesNo) { Log.Error("TVProgramInfo.DeleteRecordingPrompt: ERROR no GUIDialogYesNo found !!!!!!!!!!"); @@ -737,7 +785,7 @@ private static bool PromptStopRecording(int IdSchedule) dlgYesNo.SetLine(1, 1450); // are you sure to stop recording? string recordingTitle = GetRecordingTitle(IdSchedule); - dlgYesNo.SetLine(2, recordingTitle); + dlgYesNo.SetLine(2, recordingTitle); dlgYesNo.DoModal(GUIWindowManager.ActiveWindow); confirmed = dlgYesNo.IsConfirmed; @@ -750,13 +798,14 @@ private static bool PromptStopRecording(int IdSchedule) return confirmed; } - private static string GetRecordingTitle(int IdSchedule) { - string recordingTitle = ""; + private static string GetRecordingTitle(int IdSchedule) + { + string recordingTitle = ""; Schedule schedule = ServiceAgents.Instance.ScheduleServiceAgent.GetSchedule(IdSchedule); if (schedule != null) { - Schedule spawnedSchedule = ServiceAgents.Instance.ScheduleServiceAgent.RetrieveSpawnedSchedule(IdSchedule, schedule.StartTime); + Schedule spawnedSchedule = ServiceAgents.Instance.ScheduleServiceAgent.RetrieveSpawnedSchedule(IdSchedule, schedule.StartTime); if (spawnedSchedule != null) { recordingTitle = GetDisplayTitle(ServiceAgents.Instance.RecordingServiceAgent.GetActiveRecording(spawnedSchedule.IdSchedule)); @@ -812,17 +861,17 @@ private static bool PromptDeleteRecording(int idSchedule, Program prg) bool isRec = false; if (prg != null) { - isRec = ServiceAgents.Instance.ScheduleServiceAgent.IsScheduleRecordingProgram(idSchedule, prg.IdProgram); + isRec = ServiceAgents.Instance.ScheduleServiceAgent.IsScheduleRecordingProgram(idSchedule, prg.IdProgram); } else { IVirtualCard vCard; isRec = ServiceAgents.Instance.ControllerServiceAgent.IsRecordingSchedule(idSchedule, out vCard); - } + } if (isRec) { - confirmed = SetupConfirmDelRecDialogue(); + confirmed = SetupConfirmDelRecDialogue(); } else { @@ -862,11 +911,11 @@ private static bool IsValidSchedule(Schedule schedule) private static bool StopRecording(Schedule schedule) { - bool stoppedRec = false; + bool stoppedRec = false; bool isRec = ServiceAgents.Instance.ScheduleServiceAgent.IsScheduleRecording(schedule.IdSchedule); if (isRec) { - + ServiceAgents.Instance.ControllerServiceAgent.StopRecordingSchedule(schedule.IdSchedule); stoppedRec = true; } diff --git a/TvEngine3/Mediaportal/TV/TvPlugin/Radio/RadioRecorded.cs b/TvEngine3/Mediaportal/TV/TvPlugin/Radio/RadioRecorded.cs index c831b24ab08..364d9be4f95 100644 --- a/TvEngine3/Mediaportal/TV/TvPlugin/Radio/RadioRecorded.cs +++ b/TvEngine3/Mediaportal/TV/TvPlugin/Radio/RadioRecorded.cs @@ -20,7 +20,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using System.Threading; @@ -29,7 +28,7 @@ using MediaPortal.GUI.Library; using MediaPortal.Player; using MediaPortal.Profile; -using MediaPortal.Util; +using MediaPortal.Util; using Mediaportal.TV.Server.TVControl.ServiceAgents; using Mediaportal.TV.Server.TVDatabase.Entities; using Mediaportal.TV.Server.TVDatabase.Entities.Enums; @@ -38,7 +37,7 @@ using Mediaportal.TV.TvPlugin.Helper; using Action = MediaPortal.GUI.Library.Action; using Log = Mediaportal.TV.Server.TVLibrary.Interfaces.Logging.Log; - + namespace Mediaportal.TV.TvPlugin.Radio { @@ -113,7 +112,7 @@ protected override void LoadSettings() { currentLayout = (GUIFacadeControl.Layout)xmlreader.GetValueAsInt(SerializeName, "layout", (int)GUIFacadeControl.Layout.List); m_bSortAscending = xmlreader.GetValueAsBool(SerializeName, "sortasc", true); - + string strTmp = xmlreader.GetValueAsString("radiorecorded", "sort", "channel"); if (strTmp == "channel") @@ -152,7 +151,7 @@ protected override void SaveSettings() { xmlwriter.SetValue(SerializeName, "layout", (int)currentLayout); xmlwriter.SetValueAsBool(SerializeName, "sortasc", m_bSortAscending); - + switch (_currentSortMethod) { case SortMethod.Channel: @@ -532,7 +531,7 @@ protected override void UpdateButtonStates() this.LogError(ex, "RadioRecorded: Error updating button states"); } } - + #endregion #region Public methods @@ -612,7 +611,7 @@ private void LoadDirectory() { // catch exceptions here so MP will go on and list further recs try - { + { bool add = true; // combine recordings with the same name to a folder located on top @@ -819,7 +818,7 @@ private GUIListItem BuildItemFromRecording(Recording aRecording) if (refCh != null) { strChannelName = refCh.DisplayName; - } + } // this.LogDebug("RadioRecorded: BuildItemFromRecording [{0}]: {1} ({2}) on channel {3}", _currentDbView.ToString(), aRecording.title, aRecording.ProgramCategory.category, strChannelName); item = new GUIListItem(); @@ -849,18 +848,18 @@ private GUIListItem BuildItemFromRecording(Recording aRecording) // Get the channel logo for the small icons string StationLogo = Utils.GetCoverArt(Thumbs.Radio, strChannelName); - if (!string.IsNullOrEmpty(StationLogo)) + if (!string.IsNullOrEmpty(StationLogo)) { SmallThumb = StationLogo; } item.IconImage = item.ThumbnailImage = item.IconImageBig = SmallThumb; // Display previews only if the option to create them is active - if (string.IsNullOrEmpty(PreviewThumb)) + if (string.IsNullOrEmpty(PreviewThumb)) { item.ThumbnailImage = String.Empty; } - + //Mark the recording with a "rec. symbol" if it is an active recording. if (IsRecordingActual(aRecording)) { @@ -891,16 +890,11 @@ private void SetLabels() continue; } Recording rec = (Recording)item1.TVTag; - TimeSpan ts = rec.EndTime - rec.StartTime; - - string strTime = String.Format("{0} ({1})", - Utils.GetNamedDate(rec.StartTime), - Utils.SecondsToHMString((int)ts.TotalSeconds)); // Do not display a duration in top level of History view if (_currentDbView != DBView.History || _currentLabel != String.Empty) { - item1.Label2 = strTime; + item1.Label2 = TVUtil.GetRecordingDateString(rec); } if (currentLayout != GUIFacadeControl.Layout.List) { @@ -973,7 +967,7 @@ private bool OnSelectedRecording(int iItem) GUIPropertyManager.SetProperty("#Play.Current.ArtistThumb", pItem.Label); GUIPropertyManager.SetProperty("#Play.Current.Album", pItem.Label); GUIPropertyManager.SetProperty("#Play.Current.Thumb", pItem.ThumbnailImage); - + Recording rec = (Recording)pItem.TVTag; IEnumerable itemlist = ServiceAgents.Instance.RecordingServiceAgent.ListAllRecordingsByMediaType(MediaTypeEnum.Radio); @@ -1049,7 +1043,7 @@ private void OnDeleteRecording(int iItem) } dlgYesNo.SetDefaultToYes(false); - bool isRec = IsRecordingActual(rec); + bool isRec = IsRecordingActual(rec); bool remove = false; if (isRec) { @@ -1111,7 +1105,7 @@ private void DeleteRecordingAndUpdateGUI(Recording rec) private void TryDeleteRecordingAndNotifyUser(Recording rec) - { + { int timeout = 0; bool deleteRecording = false; @@ -1263,14 +1257,10 @@ private void SetProperties(Recording rec) GUIPropertyManager.SetProperty("#Radio.Recorded.thumb", ""); return; } - string strTime = string.Format("{0} {1} - {2}", - Utils.GetShortDayString(rec.StartTime), - rec.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - rec.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); GUIPropertyManager.SetProperty("#Radio.Recorded.Title", rec.Title); GUIPropertyManager.SetProperty("#Radio.Recorded.Genre", TVUtil.GetCategory(rec.ProgramCategory)); - GUIPropertyManager.SetProperty("#Radio.Recorded.Time", strTime); + GUIPropertyManager.SetProperty("#Radio.Recorded.Time", TVUtil.GetRecordingDateStringFull(rec)); GUIPropertyManager.SetProperty("#Radio.Recorded.Description", rec.Description); string strLogo = ""; @@ -1278,7 +1268,7 @@ private void SetProperties(Recording rec) GUIPropertyManager.SetProperty("#Radio.Recorded.Channel", GetRecordingDisplayName(rec)); strLogo = Utils.GetCoverArt(Thumbs.Radio, GetRecordingDisplayName(rec)); - if (!string.IsNullOrEmpty(strLogo)) + if (!string.IsNullOrEmpty(strLogo)) { GUIPropertyManager.SetProperty("#Radio.Recorded.thumb", strLogo); } @@ -1585,7 +1575,7 @@ private void doOnPlayBackStoppedOrChanged(g_Player.MediaType type, int stoptime, { return; } - + Recording rec = ServiceAgents.Instance.RecordingServiceAgent.GetRecordingByFileName(filename); if (rec != null) { @@ -1595,7 +1585,7 @@ private void doOnPlayBackStoppedOrChanged(g_Player.MediaType type, int stoptime, } ; //temporary workaround before end of stream get's properly implemented rec = ServiceAgents.Instance.RecordingServiceAgent.GetRecording(rec.IdRecording); - rec.StopTime = stoptime; + rec.StopTime = stoptime; ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(rec); } else @@ -1631,22 +1621,22 @@ private void OnPlayRecordingBackEnded(g_Player.MediaType type, string filename) } g_Player.Stop(); - + Recording rec = ServiceAgents.Instance.RecordingServiceAgent.GetRecordingByFileName(filename); if (rec != null) { if (_deleteWatchedShows || rec.KeepUntil == (int)KeepMethodType.UntilWatched) { - + ServiceAgents.Instance.ControllerServiceAgent.DeleteRecording(rec.IdRecording); } else { rec = ServiceAgents.Instance.RecordingServiceAgent.GetRecording(rec.IdRecording); - rec.StopTime = 0; + rec.StopTime = 0; ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(rec); } - } + } } private void OnPlayRecordingBackStarted(g_Player.MediaType type, string filename) @@ -1673,10 +1663,10 @@ private void OnPlayRecordingBackStarted(g_Player.MediaType type, string filename private void ResetWatchedStatus(Recording aRecording) { aRecording.TimesWatched = 0; - aRecording.StopTime = 0; + aRecording.StopTime = 0; ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(aRecording); } #endregion } -} +} diff --git a/TvEngine3/Mediaportal/TV/TvPlugin/Radio/RadioSearch.cs b/TvEngine3/Mediaportal/TV/TvPlugin/Radio/RadioSearch.cs index e5064df8c85..0993f240394 100644 --- a/TvEngine3/Mediaportal/TV/TvPlugin/Radio/RadioSearch.cs +++ b/TvEngine3/Mediaportal/TV/TvPlugin/Radio/RadioSearch.cs @@ -109,9 +109,9 @@ private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { - currentSortMethod = (SortMethod)Enum.Parse(typeof(SortMethod), xmlreader.GetValueAsString("radiosearch", "cursortmethod", "Name"), true); - chosenSortMethod = (SortMethod)Enum.Parse(typeof(SortMethod), xmlreader.GetValueAsString("radiosearch", "chosortmethod", "Auto"), true); - currentSearchMode = (SearchMode)Enum.Parse(typeof(SearchMode), xmlreader.GetValueAsString("radiosearch", "searchmode", "Title"), true); + currentSortMethod = (SortMethod)Enum.Parse(typeof(SortMethod), xmlreader.GetValueAsString("radiosearch", "cursortmethod", "Name"), true); + chosenSortMethod = (SortMethod)Enum.Parse(typeof(SortMethod), xmlreader.GetValueAsString("radiosearch", "chosortmethod", "Auto"), true); + currentSearchMode = (SearchMode)Enum.Parse(typeof(SearchMode), xmlreader.GetValueAsString("radiosearch", "searchmode", "Title"), true); } } @@ -121,7 +121,7 @@ private void SaveSettings() { xmlwriter.SetValue("radiosearch", "cursortmethod", currentSortMethod.ToString()); xmlwriter.SetValue("radiosearch", "chosortmethod", chosenSortMethod.ToString()); - xmlwriter.SetValue("radiosearch", "searchmode", currentSearchMode.ToString()); + xmlwriter.SetValue("radiosearch", "searchmode", currentSearchMode.ToString()); } } @@ -131,7 +131,7 @@ public RadioSearch() { GetID = (int)Window.WINDOW_SEARCH_RADIO; } - + public override bool IsTv { get { return false; } @@ -147,7 +147,7 @@ public override void DeInit() { SaveSettings(); } - + public override void OnAction(Action action) { if (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU) @@ -174,13 +174,13 @@ protected override void OnPageDestroy(int newWindowId) base.OnPageDestroy(newWindowId); listRecordings.Clear(); listRecordings = null; - if (!GUIGraphicsContext.IsTvWindow(newWindowId)) {} + if (!GUIGraphicsContext.IsTvWindow(newWindowId)) { } } protected override void OnPageLoad() { TVHome.ShowTvEngineSettingsUIIfConnectionDown(); - + base.OnPageLoad(); LoadSchedules(); @@ -325,7 +325,7 @@ protected override void OnClicked(int controlId, GUIControl control, Action.Acti dlg.AddLocalizedString(622); //name dlg.AddLocalizedString(620); //channel dlg.AddLocalizedString(621); //date - + // set the focus to currently used sort method dlg.SelectedLabel = (int)chosenSortMethod; @@ -434,7 +434,7 @@ private void Update() } else { - currentSortMethod = chosenSortMethod; + currentSortMethod = chosenSortMethod; } if (currentLevel == 0 && currentSearchMode == SearchMode.Genre) @@ -557,7 +557,7 @@ private void Update() { case SearchMode.Genre: if (currentLevel == 0) - { + { IEnumerable genres = ServiceAgents.Instance.ProgramCategoryServiceAgent.ListAllProgramCategories(); foreach (ProgramCategory genre in genres) { @@ -586,12 +586,12 @@ private void Update() Utils.SetDefaultIcons(item); listView.Add(item); titleView.Add(item); - + StringComparisonEnum stringComparisonCategory = StringComparisonEnum.StartsWith; stringComparisonCategory |= StringComparisonEnum.EndsWith; IEnumerable titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndCategoryAndMediaType(currentGenre, filterShow, - MediaTypeEnum.Radio, stringComparisonCategory, StringComparisonEnum.StartsWith); + MediaTypeEnum.Radio, stringComparisonCategory, StringComparisonEnum.StartsWith); //titles = new List(); foreach (Program program in titles) { @@ -638,27 +638,22 @@ private void Update() continue; } - strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(program.StartTime), - program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - program.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - item = new GUIListItem(); - + //check if we are filtering for specific show or just letter if (filterShow == String.Empty) { - //not searching for episode data so show just title - item.Label = program.Title; - item.Label2 = String.Empty; - item.IsFolder = true; + //not searching for episode data so show just title + item.Label = program.Title; + item.Label2 = String.Empty; + item.IsFolder = true; } else { - //searching for specific show so add episode data to display - item.Label = TVUtil.GetDisplayTitle(program); - item.Label2 = strTime; - item.IsFolder = false; + //searching for specific show so add episode data to display + item.Label = TVUtil.GetDisplayTitle(program); + item.Label2 = TVUtil.GetRecordingDateStringFull(program); + item.IsFolder = false; } item.Path = program.Title; item.TVTag = program; @@ -699,15 +694,15 @@ private void Update() listView.Add(item); titleView.Add(item); } - IEnumerable titles = new List(); + IEnumerable titles = new List(); StringComparisonEnum stringComparison = StringComparisonEnum.StartsWith; stringComparison |= StringComparisonEnum.EndsWith; if (filterLetter == "#") - { + { if (filterShow == String.Empty) - { + { titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType("[^a-z]", MediaTypeEnum.Radio, - stringComparison); + stringComparison); } else { @@ -720,12 +715,12 @@ private void Update() if (filterShow == String.Empty) { titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType(filterLetter, MediaTypeEnum.Radio, - StringComparisonEnum.StartsWith); + StringComparisonEnum.StartsWith); } else { titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType(filterShow, MediaTypeEnum.Radio, - stringComparison); + stringComparison); } } foreach (Program program in titles) @@ -789,32 +784,27 @@ private void Update() continue; } - string strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(program.StartTime), - program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - program.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - GUIListItem item = new GUIListItem(); - + //check if we are filtering for specific show or just letter if (filterShow == String.Empty) { - //not searching for episode data so show just title - item.Label = program.Title; - item.Label2 = String.Empty; - item.IsFolder = true; + //not searching for episode data so show just title + item.Label = program.Title; + item.Label2 = String.Empty; + item.IsFolder = true; } else { - //searching for specific show so add episode data to display - item.Label = TVUtil.GetDisplayTitle(program); - item.IsFolder = false; - //moved this if statement but can not see it is doing anything? - //if (program.startTime > DateTime.MinValue) - //{ - item.Label2 = strTime; - //} + //searching for specific show so add episode data to display + item.Label = TVUtil.GetDisplayTitle(program); + item.IsFolder = false; + //moved this if statement but can not see it is doing anything? + //if (program.startTime > DateTime.MinValue) + //{ + item.Label2 = TVUtil.GetRecordingDateStringFull(program); + //} } item.Path = program.Title; @@ -843,7 +833,7 @@ private void Update() break; case SearchMode.Description: { - IEnumerable titles = new List(); + IEnumerable titles = new List(); if (filterLetter == "#") { if (filterShow == String.Empty) @@ -875,7 +865,7 @@ private void Update() if (filterLetter != "#") { programs.Add(program); - + if (filterShow != String.Empty) { if (program.Title == filterShow) @@ -898,16 +888,11 @@ private void Update() continue; } - strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(program.StartTime), - program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - program.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - GUIListItem item = new GUIListItem(); item.IsFolder = false; item.Label = TVUtil.GetDisplayTitle(program); - item.Label2 = strTime; - + item.Label2 = TVUtil.GetRecordingDateStringFull(program); + item.Path = program.Title; item.TVTag = program; @@ -943,7 +928,7 @@ private void Update() { programs.Sort(); } - catch (Exception) {} + catch (Exception) { } int selItem = 0; int count = 0; if (btnShow != null) @@ -1134,7 +1119,7 @@ private void OnClick(int iItem) { OnRecord(program); } - + } } break; @@ -1198,7 +1183,7 @@ private void SetChannelLogo(Program prog, ref GUIListItem item, Dictionary itemlist = new List(); foreach (var schedule in ServiceAgents.Instance.ScheduleServiceAgent.ListAllSchedules().OrderBy(s => s.Priority)) { var scheduleBll = new ScheduleBLL(schedule); itemlist.Add(scheduleBll); - } + } int total = 0; foreach (ScheduleBLL rec in itemlist) @@ -231,11 +231,11 @@ private void LoadDirectory() item.Label = String.Format("{0}.{1}", total, rec.Entity.ProgramName); item.TVTag = rec; string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, rec.Entity.Channel.DisplayName); - if (string.IsNullOrEmpty(strLogo)) + if (string.IsNullOrEmpty(strLogo)) { strLogo = "defaultVideoBig.png"; } - + IVirtualCard card; if (ServiceAgents.Instance.ControllerServiceAgent.IsRecordingSchedule(rec.Entity.IdSchedule, out card)) { @@ -295,7 +295,7 @@ private void OnClick(int iItem) dlg.AddLocalizedString(888); //Episodes management } IVirtualCard card; - + if (ServiceAgents.Instance.ControllerServiceAgent.IsRecordingSchedule(rec.IdSchedule, out card)) { dlg.AddLocalizedString(979); //Play recording from beginning @@ -343,8 +343,8 @@ private void OnClick(int iItem) if (dlgYesNo.IsConfirmed) { - ServiceAgents.Instance.ControllerServiceAgent.StopRecordingSchedule(rec.IdSchedule); - ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); + ServiceAgents.Instance.ControllerServiceAgent.StopRecordingSchedule(rec.IdSchedule); + ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); } } @@ -385,7 +385,7 @@ private void OnClick(int iItem) } else { - ServiceAgents.Instance.ScheduleServiceAgent.DeleteSchedule(rec.IdSchedule); + ServiceAgents.Instance.ScheduleServiceAgent.DeleteSchedule(rec.IdSchedule); ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); } LoadDirectory(); @@ -513,9 +513,9 @@ private void ChangeType(Schedule rec) rec.ScheduleType = (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel; rec.Canceled = ScheduleFactory.MinSchedule; break; - } + } ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); - + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); LoadDirectory(); } @@ -588,7 +588,7 @@ private void OnMoveDown(int item) tempPriority = tmprec.Priority; tmprec.Priority = Schedule.HighestPriority - i; if (tempPriority != tmprec.Priority) - { + { ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(tmprec); } } @@ -597,7 +597,7 @@ private void OnMoveDown(int item) tempPriority = tmprec.Priority; tmprec.Priority = Schedule.HighestPriority - item; if (tempPriority != tmprec.Priority) - { + { ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(tmprec); } @@ -608,14 +608,14 @@ private void OnMoveDown(int item) tempPriority = tmprec.Priority; tmprec.Priority = Schedule.HighestPriority - i; if (tempPriority != tmprec.Priority) - { + { ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(tmprec); } } rec.Priority = Schedule.HighestPriority - item - 1; ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); - + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); LoadDirectory(); } @@ -658,26 +658,21 @@ private void OnMoveUp(int item) } rec.Priority = Schedule.HighestPriority - item + 1; - + ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); - + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); LoadDirectory(); } private void SetProperties(Schedule rec) { - string strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(rec.StartTime), - rec.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - rec.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - GUIPropertyManager.SetProperty("#TV.RecordedTV.Title", rec.ProgramName); GUIPropertyManager.SetProperty("#TV.RecordedTV.Genre", ""); - GUIPropertyManager.SetProperty("#TV.RecordedTV.Time", strTime); + GUIPropertyManager.SetProperty("#TV.RecordedTV.Time", TVUtil.GetRecordingDateStringFull(rec)); GUIPropertyManager.SetProperty("#TV.RecordedTV.Description", ""); string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, rec.Channel.DisplayName); - if (string.IsNullOrEmpty(strLogo)) + if (string.IsNullOrEmpty(strLogo)) { GUIPropertyManager.SetProperty("#TV.RecordedTV.thumb", "defaultVideoBig.png"); } @@ -696,13 +691,8 @@ public void SetProperties(Schedule schedule, Program prog) GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", String.Empty); GUIPropertyManager.SetProperty("#TV.Scheduled.Channel", String.Empty); - string strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(schedule.StartTime), - schedule.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - schedule.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - GUIPropertyManager.SetProperty("#TV.Scheduled.Title", prog.Title); - GUIPropertyManager.SetProperty("#TV.Scheduled.Time", strTime); + GUIPropertyManager.SetProperty("#TV.Scheduled.Time", TVUtil.GetRecordingDateStringFull(schedule)); if (prog != null) { GUIPropertyManager.SetProperty("#TV.Scheduled.Channel", prog.Channel.DisplayName); @@ -717,13 +707,13 @@ public void SetProperties(Schedule schedule, Program prog) string logo = Utils.GetCoverArt(Thumbs.TVChannel, schedule.Channel.DisplayName); - if (string.IsNullOrEmpty(logo)) + if (string.IsNullOrEmpty(logo)) { GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", "defaultVideoBig.png"); } else { - GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", logo); + GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", logo); } } @@ -745,7 +735,7 @@ private void UpdateDescription() { return; } - Program prog = ServiceAgents.Instance.ProgramServiceAgent.GetProgramAt(rec.StartTime.AddMinutes(1), rec.IdChannel); + Program prog = ServiceAgents.Instance.ProgramServiceAgent.GetProgramAt(rec.StartTime.AddMinutes(1), rec.IdChannel); SetProperties(rec, prog); } @@ -787,9 +777,9 @@ public static void OnSetEpisodesToKeep(Schedule rec) else { schedule.MaxAirings = dlg.SelectedLabel; - } + } ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(schedule); - + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); } @@ -850,7 +840,7 @@ public static void OnSetQuality(Schedule rec) break; } - recBLL.BitRateMode = _newBitRate; + recBLL.BitRateMode = _newBitRate; ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(recBLL.Entity); dlg.Reset(); @@ -927,10 +917,10 @@ public static void OnSetQuality(Schedule rec) break; } - recBLL.QualityType = _newQuality; + recBLL.QualityType = _newQuality; ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(recBLL.Entity); } - + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); } diff --git a/TvEngine3/Mediaportal/TV/TvPlugin/TVProgramInfo.cs b/TvEngine3/Mediaportal/TV/TvPlugin/TVProgramInfo.cs index b1fce936109..a90c87c8d98 100644 --- a/TvEngine3/Mediaportal/TV/TvPlugin/TVProgramInfo.cs +++ b/TvEngine3/Mediaportal/TV/TvPlugin/TVProgramInfo.cs @@ -20,7 +20,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.Linq; using System.Runtime.CompilerServices; using MediaPortal.Dialogs; @@ -108,7 +107,7 @@ public DateTime EndTime /// public class TVProgramInfo : GUIInternalWindow { - + #region Invoke delegates protected delegate void UpdateCurrentItem(ScheduleInfo aInfo); @@ -303,8 +302,8 @@ public static Program CurrentProgram initialProgram = currentProgram; if (currentProgram != null) { - currentSchedule= ServiceAgents.Instance.ScheduleServiceAgent.RetrieveSeries(currentProgram.IdChannel, - currentProgram.StartTime, currentProgram.EndTime); + currentSchedule = ServiceAgents.Instance.ScheduleServiceAgent.RetrieveSeries(currentProgram.IdChannel, + currentProgram.StartTime, currentProgram.EndTime); } } } @@ -318,7 +317,7 @@ public static ScheduleBLL CurrentRecording currentSchedule = value.Entity; currentProgram = null; // comment: this is not performant, i.e. query 15.000 programs and then start comparing each of them - IEnumerable programs = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTimesInterval(DateTime.Now, DateTime.Now.AddDays(10)); + IEnumerable programs = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTimesInterval(DateTime.Now, DateTime.Now.AddDays(10)); foreach (Program prog in programs.Where(prog => value.IsRecordingProgram(prog, false))) { CurrentProgram = prog; @@ -329,8 +328,8 @@ public static ScheduleBLL CurrentRecording if (CurrentProgram == null) { ProgramFactory.CreateProgram(currentSchedule.IdChannel, currentSchedule.StartTime, currentSchedule.EndTime, currentSchedule.ProgramName, "", - null, ProgramState.None, DateTime.MinValue, "", "", "", "", 0, "", 0); - } + null, ProgramState.None, DateTime.MinValue, "", "", "", "", 0, "", 0); + } } } @@ -338,14 +337,6 @@ public static ScheduleBLL CurrentRecording #region Static methods - private static string GetRecordingDateTime(Schedule rec) - { - return String.Format("{0} {1} - {2}", - Utils.GetShortDayString(rec.StartTime), - rec.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - rec.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - } - public static bool IsRecordingProgram(Program program, out Schedule recordingSchedule, bool filterCanceledRecordings) { @@ -354,7 +345,7 @@ public static bool IsRecordingProgram(Program program, out Schedule recordingSch IList schedules = ServiceAgents.Instance.ScheduleServiceAgent.ListAllSchedules().ToList(); foreach (Schedule sched in schedules) { - ScheduleBLL schedule = new ScheduleBLL (sched); + ScheduleBLL schedule = new ScheduleBLL(sched); if (schedule.Entity.Canceled != ScheduleFactory.MinSchedule || (filterCanceledRecordings && schedule.IsSerieIsCanceled(schedule.GetSchedStartTimeForProg(program), program.IdChannel))) { continue; @@ -389,7 +380,7 @@ private void item_OnItemSelected(GUIListItem item, GUIControl parent) lock (updateLock) { if (item != null && item.MusicTag != null) - { + { Program lstProg = item.MusicTag as Program; if (lstProg != null) { @@ -401,7 +392,7 @@ private void item_OnItemSelected(GUIListItem item, GUIControl parent) lstProg.StartTime, lstProg.EndTime ); - GUIGraphicsContext.form.Invoke(new UpdateCurrentItem(UpdateProgramDescription), new object[] {refEpisode}); + GUIGraphicsContext.form.Invoke(new UpdateCurrentItem(UpdateProgramDescription), new object[] { refEpisode }); } } else @@ -429,13 +420,8 @@ private void UpdateProgramDescription(ScheduleInfo episode) //this.LogDebug("TVProgrammInfo.UpdateProgramDescription: {0} - {1}", episode.title, episode.description); lblProgramChannel.Label = ServiceAgents.Instance.ChannelServiceAgent.GetChannel(episode.IdChannel).DisplayName; - string strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(episode.StartTime), - episode.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - episode.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - lblProgramGenre.Label = episode.Genre; - lblProgramTime.Label = strTime; + lblProgramTime.Label = TVUtil.GetRecordingDateStringFull(episode); lblProgramDescription.Label = episode.Description; lblProgramTitle.Label = episode.Title; } @@ -493,10 +479,10 @@ private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram) List episodes = episodesList.Select(program => new ProgramBLL(program)).ToList(); // now if schedule is time based then build a second list for that schedule based on start time (see below) - IList actualUpcomingEps = new List(); + IList actualUpcomingEps = new List(); if (currentSchedule != null) { - int scheduletype = currentSchedule.ScheduleType; + int scheduletype = currentSchedule.ScheduleType; switch (scheduletype) { @@ -514,9 +500,9 @@ private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram) case (int)ScheduleRecordingType.Daily: actualUpcomingEps = ServiceAgents.Instance.ProgramServiceAgent.RetrieveDaily(initialProgram.StartTime, initialProgram.EndTime, initialProgram.IdChannel).ToList(); - break; + break; } - + // now if we have a time based schedule then loop through that and if entry does not exist // in the original list then add it // an entry will exist in the second list but not first if the program name is different @@ -533,13 +519,13 @@ private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram) bool contains = episodes.Any(e => e.Entity == ep); if (!contains) - { + { episodes.Add(new ProgramBLL(ep)); } } episodes.Sort((x, y) => (x.Entity.StartTime.CompareTo(y.Entity.StartTime))); //resort list locally on starttime } - } + } ScheduleBLL recordingSchedule = new ScheduleBLL(currentSchedule); bool updateCurrentProgram = true; @@ -551,14 +537,14 @@ private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram) item.Label = TVUtil.GetDisplayTitle(episode.Entity); item.OnItemSelected += item_OnItemSelected; string logo = Utils.GetCoverArt(Thumbs.TVChannel, episode.Entity.Channel.DisplayName); - if (string.IsNullOrEmpty(logo)) + if (string.IsNullOrEmpty(logo)) { item.Label = String.Format("{0} {1}", episode.Entity.Channel.DisplayName, TVUtil.GetDisplayTitle(episode.Entity)); logo = "defaultVideoBig.png"; } - bool isActualUpcomingEps = actualUpcomingEps.Contains(episode.Entity) ; - bool isRecPrg = isActualUpcomingEps; + bool isActualUpcomingEps = actualUpcomingEps.Contains(episode.Entity); + bool isRecPrg = isActualUpcomingEps; // appears a little odd but seems to work // if episode is not in second (time based) list then override isRecPrg by actually // checking if episode is due to be recorded (if it is in second (time based) list then @@ -566,7 +552,7 @@ private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram) if (!isActualUpcomingEps) { Schedule recSchedule = null; - isRecPrg = (episode.IsRecording || episode.IsRecordingOncePending || episode.IsRecordingSeriesPending || + isRecPrg = (episode.IsRecording || episode.IsRecordingOncePending || episode.IsRecordingSeriesPending || episode.IsPartialRecordingSeriesPending) && IsRecordingProgram(episode.Entity, out recSchedule, true); recordingSchedule.Entity = recSchedule; } @@ -586,15 +572,15 @@ private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram) } if (isPartialRecording) { - item.PinImage = hasConflict ? - (isSeries? Thumbs.TvConflictPartialRecordingSeriesIcon : Thumbs.TvConflictPartialRecordingIcon) : - (isSeries? Thumbs.TvPartialRecordingSeriesIcon : Thumbs.TvPartialRecordingIcon); + item.PinImage = hasConflict ? + (isSeries ? Thumbs.TvConflictPartialRecordingSeriesIcon : Thumbs.TvConflictPartialRecordingIcon) : + (isSeries ? Thumbs.TvPartialRecordingSeriesIcon : Thumbs.TvPartialRecordingIcon); } else { - item.PinImage = hasConflict ? - (isSeries? Thumbs.TvConflictRecordingSeriesIcon : Thumbs.TvConflictRecordingIcon) : - (isSeries? Thumbs.TvRecordingSeriesIcon : Thumbs.TvRecordingIcon); + item.PinImage = hasConflict ? + (isSeries ? Thumbs.TvConflictRecordingSeriesIcon : Thumbs.TvConflictRecordingIcon) : + (isSeries ? Thumbs.TvRecordingSeriesIcon : Thumbs.TvRecordingIcon); } if (updateCurrentProgram) @@ -604,7 +590,7 @@ private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram) activeRecordings++; anyUpcomingEpisodesRecording = true; updateCurrentProgram = false; - } + } item.TVTag = recordingSchedule; } else @@ -618,10 +604,7 @@ private void PopulateListviewWithUpcomingEpisodes(Program lastSelectedProgram) item.MusicTag = episode.Entity; item.ThumbnailImage = item.IconImageBig = item.IconImage = logo; - item.Label2 = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(episode.Entity.StartTime), - episode.Entity.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - episode.Entity.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); + item.Label2 = TVUtil.GetRecordingDateStringFull(episode.Entity); if (lastSelectedProgram != null) { @@ -668,9 +651,9 @@ private void CheckRecordingStatus() } else { - // Mantis 2927 - // Removed loop over all schedules as this was not actually - // needed and was causing performance issues + // Mantis 2927 + // Removed loop over all schedules as this was not actually + // needed and was causing performance issues Schedule recSched; isRecording = IsRecordingProgram(CurrentProgram, out recSched, true); @@ -771,18 +754,18 @@ private void OnPreRecordInterval() } rec.PreRecordInterval = RecordingIntervalValues[dlg.SelectedLabel]; - ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); + ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); currentSchedule = rec; Schedule assocSchedule = ServiceAgents.Instance.ScheduleServiceAgent.RetrieveSpawnedSchedule(rec.IdSchedule, rec.StartTime); if (assocSchedule != null) { - assocSchedule.PreRecordInterval = rec.PreRecordInterval; + assocSchedule.PreRecordInterval = rec.PreRecordInterval; ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(assocSchedule); } - + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); } Update(); @@ -851,15 +834,15 @@ private void OnPostRecordInterval() return; } - rec.PostRecordInterval = RecordingIntervalValues[dlg.SelectedLabel]; + rec.PostRecordInterval = RecordingIntervalValues[dlg.SelectedLabel]; ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); currentSchedule = rec; Schedule assocSchedule = ServiceAgents.Instance.ScheduleServiceAgent.RetrieveSpawnedSchedule(rec.IdSchedule, rec.StartTime); - + if (assocSchedule != null) { - assocSchedule.PostRecordInterval = rec.PostRecordInterval; + assocSchedule.PostRecordInterval = rec.PostRecordInterval; ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(assocSchedule); } } @@ -930,7 +913,7 @@ private void OnSetQuality() break; } - rec.BitRateMode = _newBitRate; + rec.BitRateMode = _newBitRate; ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec.Entity); currentSchedule = rec.Entity; @@ -1004,7 +987,7 @@ private void OnSetQuality() break; } - rec.QualityType = _newQuality; + rec.QualityType = _newQuality; ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec.Entity); currentSchedule = rec.Entity; } @@ -1041,7 +1024,7 @@ private void OnRecordProgram(Program program) } else { - + IVirtualCard card; if (TVHome.Navigator.Channel.Entity.IdChannel == program.IdChannel && ServiceAgents.Instance.ControllerServiceAgent.IsRecording(TVHome.Navigator.Channel.Entity.IdChannel, out card)) @@ -1075,7 +1058,7 @@ private static void CancelProgram(Program program, Schedule schedule, int dialog if (schedule.ScheduleType == (int)ScheduleRecordingType.Once) { - TVUtil.DeleteRecAndSchedWithPrompt(schedule); + TVUtil.DeleteRecAndSchedWithPrompt(schedule); ResetCurrentScheduleAndProgram(schedule); return; } @@ -1086,7 +1069,7 @@ private static void CancelProgram(Program program, Schedule schedule, int dialog || (schedule.ScheduleType == (int)ScheduleRecordingType.WorkingDays) || (schedule.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnEveryChannel) || (schedule.ScheduleType == (int)ScheduleRecordingType.EveryTimeOnThisChannel) - || (schedule.ScheduleType == (int) ScheduleRecordingType.WeeklyEveryTimeOnThisChannel)) + || (schedule.ScheduleType == (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel)) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) @@ -1117,7 +1100,7 @@ private static void CancelProgram(Program program, Schedule schedule, int dialog deleteEntireSched = true; break; } - + if (deleteEntireSched) { TVUtil.DeleteRecAndEntireSchedWithPrompt(schedule, program.StartTime); @@ -1126,7 +1109,7 @@ private static void CancelProgram(Program program, Schedule schedule, int dialog else { TVUtil.DeleteRecAndSchedWithPrompt(schedule, program); - } + } } } @@ -1152,7 +1135,7 @@ private static void ResetCurrentScheduleAndProgram(Schedule schedule) public static void CreateProgram(Program program, int scheduleType, int dialogId) { Log.Debug("TVProgramInfo.CreateProgram: program = {0}", program.ToString()); - Schedule saveSchedule = null; + Schedule saveSchedule = null; Schedule scheduleOut; var isRecordingProgram = IsRecordingProgram(program, out scheduleOut, false); @@ -1188,9 +1171,9 @@ public static void CreateProgram(Program program, int scheduleType, int dialogId // check if this program is conflicting with any other already scheduled recording or not viewable cause isn't assigned to a card List notViewables; // check if this program is conflicting with any other already scheduled recording - IList conflicts = ServiceAgents.Instance.ScheduleServiceAgent.GetConflictingSchedules(schedule.Entity, out notViewables).ToList(); - - Log.Debug("TVProgramInfo.CreateProgram - conflicts.Count = {0} - notViewable.Count = {1}", conflicts.Count, notViewables.Count); + IList conflicts = ServiceAgents.Instance.ScheduleServiceAgent.GetConflictingSchedules(schedule.Entity, out notViewables).ToList(); + + Log.Debug("TVProgramInfo.CreateProgram - conflicts.Count = {0} - notViewable.Count = {1}", conflicts.Count, notViewables.Count); //conflicts management bool skipConflictingEpisodes = false; @@ -1207,7 +1190,7 @@ public static void CreateProgram(Program program, int scheduleType, int dialogId Log.Debug("TVProgramInfo.CreateProgram: Conflicts = " + conflict); GUIListItem item = new GUIListItem(conflict.ProgramName); - item.Label2 = GetRecordingDateTime(conflict); + item.Label2 = TVUtil.GetRecordingDateStringFull(conflict); Channel channel = ServiceAgents.Instance.ChannelServiceAgent.GetChannel(conflict.IdChannel); if (channel != null && !string.IsNullOrEmpty(channel.DisplayName)) { @@ -1279,7 +1262,7 @@ public static void CreateProgram(Program program, int scheduleType, int dialogId Log.Debug("TVProgramInfo.CreateProgram: NotViewable = " + notViewable); GUIListItem item = new GUIListItem(notViewable.ProgramName); - item.Label2 = GetRecordingDateTime(notViewable); + item.Label2 = TVUtil.GetRecordingDateStringFull(notViewable); Channel channel = ServiceAgents.Instance.ChannelServiceAgent.GetChannel(notViewable.IdChannel); if (channel != null && !string.IsNullOrEmpty(channel.DisplayName)) { @@ -1325,7 +1308,7 @@ public static void CreateProgram(Program program, int scheduleType, int dialogId if (saveSchedule != null) { Log.Debug("TVProgramInfo.CreateProgram - UnCancleSerie at {0}", program.StartTime); - ServiceAgents.Instance.ScheduleServiceAgent.UnCancelSerie(saveSchedule, program.StartTime, program.IdChannel); + ServiceAgents.Instance.ScheduleServiceAgent.UnCancelSerie(saveSchedule, program.StartTime, program.IdChannel); ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(saveSchedule); currentSchedule = saveSchedule; } @@ -1341,7 +1324,7 @@ public static void CreateProgram(Program program, int scheduleType, int dialogId } if (skipConflictingEpisodes) { - + IEnumerable episodes = ServiceAgents.Instance.ScheduleServiceAgent.GetRecordingTimes(schedule.Entity, 10); List episodesBLL = episodes.Select(s => new ScheduleBLL(s)).ToList(); @@ -1368,12 +1351,12 @@ public static void CreateProgram(Program program, int scheduleType, int dialogId } if (skipNotViewableEpisodes) { - IList episodes = ServiceAgents.Instance.ScheduleServiceAgent.GetRecordingTimes(schedule.Entity, 10); + IList episodes = ServiceAgents.Instance.ScheduleServiceAgent.GetRecordingTimes(schedule.Entity, 10); foreach (Schedule notViewable in notViewables) { if (DateTime.Now > notViewable.EndTime) { - continue; + continue; } var notViewableBLL = new ScheduleBLL(notViewable); @@ -1381,9 +1364,9 @@ public static void CreateProgram(Program program, int scheduleType, int dialogId { continue; } - Log.Debug("TVProgramInfo.CreateProgram - skip episode not viewable = {0}", notViewable.ToString()); + Log.Debug("TVProgramInfo.CreateProgram - skip episode not viewable = {0}", notViewable.ToString()); CanceledSchedule canceledSchedule = CanceledScheduleFactory.CreateCanceledSchedule(schedule.Entity.IdSchedule, notViewable.IdChannel, notViewable.StartTime); - ServiceAgents.Instance.CanceledScheduleServiceAgent.SaveCanceledSchedule(canceledSchedule); + ServiceAgents.Instance.CanceledScheduleServiceAgent.SaveCanceledSchedule(canceledSchedule); } } ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); @@ -1456,7 +1439,7 @@ private void OnAdvancedRecord() //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); + DateTime dtEnd = dtStart.AddHours(3); IList programs = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByChannelAndStartEndTimes(CurrentProgram.IdChannel, dtStart, dtEnd).ToList(); if (programs.Count >= 2) { @@ -1561,10 +1544,10 @@ private void OnKeep() case 1046: rec.KeepMethod = (int)KeepMethodType.Always; break; - } + } ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); currentSchedule = rec; - + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); } diff --git a/TvEngine3/Mediaportal/TV/TvPlugin/TVRecordedInfo.cs b/TvEngine3/Mediaportal/TV/TvPlugin/TVRecordedInfo.cs index 34131f297d8..ae2a3d6de17 100644 --- a/TvEngine3/Mediaportal/TV/TvPlugin/TVRecordedInfo.cs +++ b/TvEngine3/Mediaportal/TV/TvPlugin/TVRecordedInfo.cs @@ -19,7 +19,6 @@ #endregion using System; -using System.Globalization; using MediaPortal.Dialogs; using MediaPortal.GUI.Library; using MediaPortal.Util; @@ -79,12 +78,8 @@ private void Update() return; } - string strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(currentProgram.StartTime), - currentProgram.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - currentProgram.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); lblProgramGenre.Label = TVUtil.GetCategory(currentProgram.ProgramCategory); - lblProgramTime.Label = strTime; + lblProgramTime.Label = TVUtil.GetRecordingDateStringFull(currentProgram); lblProgramDescription.Label = currentProgram.Description; lblProgramTitle.Label = currentProgram.Title; } @@ -183,7 +178,7 @@ private void OnKeep() case 1046: currentProgram.KeepUntil = (int)KeepMethodType.Always; break; - } + } ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(currentProgram); } diff --git a/TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs b/TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs index 66e8ffe34e7..5679619b1d2 100644 --- a/TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs +++ b/TvEngine3/Mediaportal/TV/TvPlugin/TVScheduler.cs @@ -46,7 +46,7 @@ namespace Mediaportal.TV.TvPlugin /// public class TvScheduler : GUIInternalWindow, IComparer { - + #region variables, ctor/dtor @@ -77,7 +77,7 @@ public TvScheduler() GetID = (int)Window.WINDOW_SCHEDULER; } - ~TvScheduler() {} + ~TvScheduler() { } public override bool IsTv { @@ -490,8 +490,8 @@ private GUIListItem Schedule2ListItem(Schedule schedule) item.TVTag = schedule; string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, schedule.Channel.DisplayName); - - if (string.IsNullOrEmpty(strLogo)) + + if (string.IsNullOrEmpty(strLogo)) { strLogo = "defaultVideoBig.png"; } @@ -536,7 +536,7 @@ private void LoadDirectory() btnConflicts.Visible = conflictsList.Count > 0; GUIControl.ClearControl(GetID, listSchedules.GetID); IList schedulesList = new List(); - + foreach (var schedule in ServiceAgents.Instance.ScheduleServiceAgent.ListAllSchedules()) { var scheduleBll = new ScheduleBLL(schedule); @@ -680,7 +680,7 @@ private void SetLabels() { continue; } - Schedule rec = (Schedule)item.TVTag; + Schedule rec = (Schedule)item.TVTag; item.Label = TVUtil.GetDisplayTitle(rec); @@ -759,39 +759,39 @@ private void SetLabels() item.Label2 = String.Format("{0} {1} {2}", strType, day, strTime); break; case (int)ScheduleRecordingType.EveryTimeOnThisChannel: - item.Label2 = GUILocalizeStrings.Get(650, new object[] {rec.Channel.DisplayName}); + item.Label2 = GUILocalizeStrings.Get(650, new object[] { rec.Channel.DisplayName }); break; case (int)ScheduleRecordingType.EveryTimeOnEveryChannel: item.Label2 = GUILocalizeStrings.Get(651); break; - case (int) ScheduleRecordingType.WeeklyEveryTimeOnThisChannel: - switch (rec.StartTime.DayOfWeek) - { - case DayOfWeek.Monday: - day = GUILocalizeStrings.Get(11); - break; - case DayOfWeek.Tuesday: - day = GUILocalizeStrings.Get(12); - break; - case DayOfWeek.Wednesday: - day = GUILocalizeStrings.Get(13); - break; - case DayOfWeek.Thursday: - day = GUILocalizeStrings.Get(14); - break; - case DayOfWeek.Friday: - day = GUILocalizeStrings.Get(15); - break; - case DayOfWeek.Saturday: - day = GUILocalizeStrings.Get(16); - break; - default: - day = GUILocalizeStrings.Get(17); - break; + case (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel: + switch (rec.StartTime.DayOfWeek) + { + case DayOfWeek.Monday: + day = GUILocalizeStrings.Get(11); + break; + case DayOfWeek.Tuesday: + day = GUILocalizeStrings.Get(12); + break; + case DayOfWeek.Wednesday: + day = GUILocalizeStrings.Get(13); + break; + case DayOfWeek.Thursday: + day = GUILocalizeStrings.Get(14); + break; + case DayOfWeek.Friday: + day = GUILocalizeStrings.Get(15); + break; + case DayOfWeek.Saturday: + day = GUILocalizeStrings.Get(16); + break; + default: + day = GUILocalizeStrings.Get(17); + break; + } + item.Label2 = GUILocalizeStrings.Get(990001, new object[] { day, rec.Channel.DisplayName }); + break; } - item.Label2 = GUILocalizeStrings.Get(990001, new object[] { day, rec.Channel.DisplayName }); - break; - } } else { @@ -803,7 +803,7 @@ private void SetLabels() } else { - item.Label2 = String.Empty; + item.Label2 = String.Empty; } } } @@ -938,7 +938,7 @@ private void OnShowContextMenu(int iItem, bool clicked) } if (schedule != null) { - TVProgramInfo.CurrentRecording = new ScheduleBLL(schedule); + TVProgramInfo.CurrentRecording = new ScheduleBLL(schedule); GUIWindowManager.ActivateWindow((int)Window.WINDOW_TV_PROGRAM_INFO); } return; @@ -1009,7 +1009,7 @@ private void OnShowContextMenu(int iItem, bool clicked) } GUIControl.SelectItemControl(GetID, listSchedules.GetID, m_iSelectedItem); } - + private void ChangeType(Schedule rec) { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); @@ -1089,9 +1089,9 @@ private void ChangeType(Schedule rec) rec.ScheduleType = (int)ScheduleRecordingType.WeeklyEveryTimeOnThisChannel; rec.Canceled = ScheduleFactory.MinSchedule; break; - } + } ServiceAgents.Instance.ScheduleServiceAgent.SaveSchedule(rec); - + ServiceAgents.Instance.ControllerServiceAgent.OnNewSchedule(); LoadDirectory(); } @@ -1129,14 +1129,9 @@ private void OnCleanup() private void SetProperties(Schedule rec) { - string strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(rec.StartTime), - rec.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - rec.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - GUIPropertyManager.SetProperty("#TV.RecordedTV.Title", rec.ProgramName); GUIPropertyManager.SetProperty("#TV.RecordedTV.Genre", ""); - GUIPropertyManager.SetProperty("#TV.RecordedTV.Time", strTime); + GUIPropertyManager.SetProperty("#TV.RecordedTV.Time", TVUtil.GetRecordingDateStringFull(rec)); GUIPropertyManager.SetProperty("#TV.RecordedTV.Description", ""); if (rec.IdChannel < 0) @@ -1146,9 +1141,9 @@ private void SetProperties(Schedule rec) else { string strLogo = Utils.GetCoverArt(Thumbs.TVChannel, rec.Channel.DisplayName); - if (string.IsNullOrEmpty(strLogo)) + if (string.IsNullOrEmpty(strLogo)) { - GUIPropertyManager.SetProperty("#TV.RecordedTV.thumb", "defaultVideoBig.png"); + GUIPropertyManager.SetProperty("#TV.RecordedTV.thumb", "defaultVideoBig.png"); } else { @@ -1175,12 +1170,7 @@ public void SetProperties(Schedule schedule, Program prog) if (schedule != null) { - string strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(schedule.StartTime), - schedule.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - schedule.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - - GUIPropertyManager.SetProperty("#TV.Scheduled.Time", strTime); + GUIPropertyManager.SetProperty("#TV.Scheduled.Time", TVUtil.GetRecordingDateStringFull(schedule)); if (schedule.IdChannel < 0) { @@ -1190,13 +1180,13 @@ public void SetProperties(Schedule schedule, Program prog) { GUIPropertyManager.SetProperty("#TV.Scheduled.Channel", schedule.Channel.DisplayName); string logo = Utils.GetCoverArt(Thumbs.TVChannel, schedule.Channel.DisplayName); - if (string.IsNullOrEmpty(logo)) + if (string.IsNullOrEmpty(logo)) { GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", "defaultVideoBig.png"); } else { - GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", logo); + GUIPropertyManager.SetProperty("#TV.Scheduled.thumb", logo); } } } @@ -1204,7 +1194,7 @@ public void SetProperties(Schedule schedule, Program prog) private void UpdateDescription() { - Schedule rec = ScheduleFactory.CreateSchedule(-1, "", ScheduleFactory.MinSchedule, ScheduleFactory.MinSchedule); + Schedule rec = ScheduleFactory.CreateSchedule(-1, "", ScheduleFactory.MinSchedule, ScheduleFactory.MinSchedule); rec.PreRecordInterval = Int32.Parse(ServiceAgents.Instance.SettingServiceAgent.GetSettingWithDefaultValue("preRecordInterval", "5").Value); rec.PostRecordInterval = Int32.Parse(ServiceAgents.Instance.SettingServiceAgent.GetSettingWithDefaultValue("postRecordInterval", "5").Value); SetProperties(rec); @@ -1219,7 +1209,7 @@ private void UpdateDescription() return; } - Program prog = ServiceAgents.Instance.ProgramServiceAgent.GetProgramAt(rec.StartTime.AddMinutes(1), rec.IdChannel); + Program prog = ServiceAgents.Instance.ProgramServiceAgent.GetProgramAt(rec.StartTime.AddMinutes(1), rec.IdChannel); SetProperties(rec, prog); } diff --git a/TvEngine3/Mediaportal/TV/TvPlugin/TVSearch.cs b/TvEngine3/Mediaportal/TV/TvPlugin/TVSearch.cs index bb42a2718ee..214f473af33 100644 --- a/TvEngine3/Mediaportal/TV/TvPlugin/TVSearch.cs +++ b/TvEngine3/Mediaportal/TV/TvPlugin/TVSearch.cs @@ -109,9 +109,9 @@ private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { - currentSortMethod = (SortMethod)Enum.Parse(typeof(SortMethod), xmlreader.GetValueAsString("tvsearch", "cursortmethod", "Name"), true); - chosenSortMethod = (SortMethod)Enum.Parse(typeof(SortMethod), xmlreader.GetValueAsString("tvsearch", "chosortmethod", "Auto"), true); - currentSearchMode = (SearchMode)Enum.Parse(typeof(SearchMode), xmlreader.GetValueAsString("tvsearch", "searchmode", "Title"), true); + currentSortMethod = (SortMethod)Enum.Parse(typeof(SortMethod), xmlreader.GetValueAsString("tvsearch", "cursortmethod", "Name"), true); + chosenSortMethod = (SortMethod)Enum.Parse(typeof(SortMethod), xmlreader.GetValueAsString("tvsearch", "chosortmethod", "Auto"), true); + currentSearchMode = (SearchMode)Enum.Parse(typeof(SearchMode), xmlreader.GetValueAsString("tvsearch", "searchmode", "Title"), true); } } @@ -121,7 +121,7 @@ private void SaveSettings() { xmlwriter.SetValue("tvsearch", "cursortmethod", currentSortMethod.ToString()); xmlwriter.SetValue("tvsearch", "chosortmethod", chosenSortMethod.ToString()); - xmlwriter.SetValue("tvsearch", "searchmode", currentSearchMode.ToString()); + xmlwriter.SetValue("tvsearch", "searchmode", currentSearchMode.ToString()); } } @@ -173,7 +173,7 @@ protected override void OnPageDestroy(int newWindowId) base.OnPageDestroy(newWindowId); listRecordings.Clear(); listRecordings = null; - if (!GUIGraphicsContext.IsTvWindow(newWindowId)) {} + if (!GUIGraphicsContext.IsTvWindow(newWindowId)) { } } protected override void OnPageLoad() @@ -323,7 +323,7 @@ protected override void OnClicked(int controlId, GUIControl control, Action.Acti dlg.AddLocalizedString(622); //name dlg.AddLocalizedString(620); //channel dlg.AddLocalizedString(621); //date - + // set the focus to currently used sort method dlg.SelectedLabel = (int)chosenSortMethod; @@ -432,7 +432,7 @@ private void Update() } else { - currentSortMethod = chosenSortMethod; + currentSortMethod = chosenSortMethod; } if (currentLevel == 0 && currentSearchMode == SearchMode.Genre) @@ -555,7 +555,7 @@ private void Update() { case SearchMode.Genre: if (currentLevel == 0) - { + { IEnumerable genres = ServiceAgents.Instance.ProgramCategoryServiceAgent.ListAllProgramCategories(); foreach (ProgramCategory genre in genres) { @@ -586,7 +586,7 @@ private void Update() IEnumerable titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndCategoryAndMediaType(currentGenre, filterShow, MediaTypeEnum.TV, StringComparisonEnum.StartsWith, - StringComparisonEnum.StartsWith); + StringComparisonEnum.StartsWith); foreach (Program program in titles) { @@ -633,27 +633,22 @@ private void Update() continue; } - strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(program.StartTime), - program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - program.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - item = new GUIListItem(); - + //check if we are filtering for specific show or just letter if (filterShow == String.Empty) { - //not searching for episode data so show just title - item.Label = program.Title; - item.Label2 = String.Empty; - item.IsFolder = true; + //not searching for episode data so show just title + item.Label = program.Title; + item.Label2 = String.Empty; + item.IsFolder = true; } else { - //searching for specific show so add episode data to display - item.Label = TVUtil.GetDisplayTitle(program); - item.Label2 = strTime; - item.IsFolder = false; + //searching for specific show so add episode data to display + item.Label = TVUtil.GetDisplayTitle(program); + item.Label2 = TVUtil.GetRecordingDateStringFull(program); + item.IsFolder = false; } item.Path = program.Title; item.TVTag = program; @@ -701,22 +696,22 @@ private void Update() { if (filterShow == String.Empty) { - titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType("[^a-z]", MediaTypeEnum.TV, stringComparison); + titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType("[^a-z]", MediaTypeEnum.TV, stringComparison); } else { - titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType(filterShow, MediaTypeEnum.TV, stringComparison); + titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType(filterShow, MediaTypeEnum.TV, stringComparison); } } else { if (filterShow == String.Empty) { - titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType(filterLetter, MediaTypeEnum.TV, StringComparisonEnum.StartsWith); + titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType(filterLetter, MediaTypeEnum.TV, StringComparisonEnum.StartsWith); } else { - titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType(filterShow, MediaTypeEnum.TV, stringComparison); + titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByTitleAndMediaType(filterShow, MediaTypeEnum.TV, stringComparison); } } foreach (Program program in titles) @@ -780,32 +775,27 @@ private void Update() continue; } - string strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(program.StartTime), - program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - program.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); - GUIListItem item = new GUIListItem(); - + //check if we are filtering for specific show or just letter if (filterShow == String.Empty) { - //not searching for episode data so show just title - item.Label = program.Title; - item.Label2 = String.Empty; - item.IsFolder = true; + //not searching for episode data so show just title + item.Label = program.Title; + item.Label2 = String.Empty; + item.IsFolder = true; } else { - //searching for specific show so add episode data to display - item.Label = TVUtil.GetDisplayTitle(program); - item.IsFolder = false; - //moved this if statement but can not see it is doing anything? - //if (program.startTime > DateTime.MinValue) - //{ - item.Label2 = strTime; - //} + //searching for specific show so add episode data to display + item.Label = TVUtil.GetDisplayTitle(program); + item.IsFolder = false; + //moved this if statement but can not see it is doing anything? + //if (program.startTime > DateTime.MinValue) + //{ + item.Label2 = TVUtil.GetRecordingDateStringFull(program); + //} } item.Path = program.Title; @@ -834,7 +824,7 @@ private void Update() break; case SearchMode.Description: { - IEnumerable titles = new List(); + IEnumerable titles = new List(); if (filterLetter == "#") { if (filterShow == String.Empty) @@ -843,7 +833,7 @@ private void Update() } else { - titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByDescriptionAndMediaType(filterShow, MediaTypeEnum.TV, StringComparisonEnum.StartsWith); + titles = ServiceAgents.Instance.ProgramServiceAgent.GetProgramsByDescriptionAndMediaType(filterShow, MediaTypeEnum.TV, StringComparisonEnum.StartsWith); } } else @@ -866,7 +856,7 @@ private void Update() if (filterLetter != "#") { programs.Add(program); - + if (filterShow != String.Empty) { if (program.Title == filterShow) @@ -889,16 +879,12 @@ private void Update() continue; } - strTime = String.Format("{0} {1} - {2}", - Utils.GetShortDayString(program.StartTime), - program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - program.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); GUIListItem item = new GUIListItem(); item.IsFolder = false; item.Label = TVUtil.GetDisplayTitle(program); - item.Label2 = strTime; - + item.Label2 = TVUtil.GetRecordingDateStringFull(program); + item.Path = program.Title; item.TVTag = program; @@ -934,7 +920,7 @@ private void Update() { programs.Sort(); } - catch (Exception) {} + catch (Exception) { } int selItem = 0; int count = 0; if (btnShow != null) @@ -1125,7 +1111,7 @@ private void OnClick(int iItem) { OnRecord(program); } - + } } break; @@ -1171,13 +1157,13 @@ private void SetChannelLogo(Program prog, ref GUIListItem item, Dictionary { - + #region ThumbCacher public class RecordingThumbCacher { - + private Work work; @@ -90,10 +89,10 @@ private void PerformRequest() Utils.GetThumbExtension()); if ((!TVHome.UseRTSP()) && !Utils.FileExistsInCache(thumbNail)) - { + { try { - Thread.Sleep(250); + Thread.Sleep(250); if (VideoThumbCreator.CreateVideoThumb(recFileName, thumbNail, true, true)) { this.LogInfo("RecordedTV: Thumbnail successfully created for - {0}", Utils.SplitFilename(recFileName)); @@ -163,12 +162,12 @@ private enum DBView private DateTime _resetSMSsearchDelay; private RecordingThumbCacher thumbworker = null; - + [SkinControl(6)] protected GUIButtonControl btnCleanup = null; [SkinControl(7)] protected GUIButtonControl btnCompress = null; - + #endregion @@ -191,7 +190,7 @@ protected override void LoadSettings() { currentLayout = (GUIFacadeControl.Layout)xmlreader.GetValueAsInt(SerializeName, "layout", (int)GUIFacadeControl.Layout.List); m_bSortAscending = xmlreader.GetValueAsBool(SerializeName, "sortasc", true); - + string strTmp = xmlreader.GetValueAsString("tvrecorded", "sort", "channel"); if (strTmp == "channel") @@ -233,7 +232,7 @@ protected override void SaveSettings() { xmlwriter.SetValue(SerializeName, "layout", (int)currentLayout); xmlwriter.SetValueAsBool(SerializeName, "sortasc", m_bSortAscending); - + switch (_currentSortMethod) { case SortMethod.Channel: @@ -430,7 +429,7 @@ protected override void OnShowSort() dlg.AddLocalizedString(669); // genre dlg.AddLocalizedString(671); // watched dlg.AddLocalizedString(1017); // duration - + // set the focus to currently used sort method dlg.SelectedLabel = (int)_currentSortMethod; @@ -457,7 +456,7 @@ public override bool OnMessage(GUIMessage message) } return base.OnMessage(message); } - + protected override void OnShowContextMenu() { int iItem = GetSelectedItemNo(); @@ -737,7 +736,7 @@ private string GetSpokenViewDate(DateTime aStartTime) else if (DateTime.Now.Year.Equals(compareDate.AddYears(1).Year)) return GUILocalizeStrings.Get(6080); // "Last year"; else return GUILocalizeStrings.Get(6090); // "Older"; - } + } private void LoadDirectory() { @@ -748,7 +747,7 @@ private void LoadDirectory() IEnumerable recordings = ServiceAgents.Instance.RecordingServiceAgent.ListAllRecordingsByMediaType(MediaTypeEnum.TV); if (_currentLabel == string.Empty) - { + { Func keySelector = (rec => rec.Title); switch (_currentDbView) { @@ -766,7 +765,7 @@ private void LoadDirectory() break; } - ILookup recItems = recordings.ToLookup(keySelector); + ILookup recItems = recordings.ToLookup(keySelector); itemlist = recItems.Select(recs => { @@ -785,7 +784,7 @@ private void LoadDirectory() } return item; }).ToList(); - } + } else { // Showing a merged folders content @@ -886,7 +885,7 @@ public static string GetRecordingDisplayName(Recording rec) private static bool IsRecordingActual(Recording aRecording) { - return aRecording.IsRecording; + return aRecording.IsRecording; } private GUIListItem BuildItemFromRecording(Recording aRecording) @@ -908,7 +907,7 @@ private GUIListItem BuildItemFromRecording(Recording aRecording) if (refCh != null) { strChannelName = refCh.DisplayName; - } + } // this.LogDebug("TVRecorded: BuildItemFromRecording [{0}]: {1} ({2}) on channel {3}", _currentDbView.ToString(), aRecording.title, aRecording.ProgramCategory.category, strChannelName); item = new GUIListItem(); @@ -947,7 +946,7 @@ private GUIListItem BuildItemFromRecording(Recording aRecording) if (Utils.FileExistsInCache(previewThumb)) { // Search a larger one - string PreviewThumbLarge = Utils.ConvertToLargeCoverArt(previewThumb); + string PreviewThumbLarge = Utils.ConvertToLargeCoverArt(previewThumb); if (Utils.FileExistsInCache(PreviewThumbLarge)) { previewThumb = PreviewThumbLarge; @@ -992,16 +991,11 @@ private void SetLabels() continue; } Recording rec = (Recording)item1.TVTag; - TimeSpan ts = rec.EndTime - rec.StartTime; - - string strTime = String.Format("{0} ({1})", - Utils.GetNamedDate(rec.StartTime), - Utils.SecondsToHMString((int)ts.TotalSeconds)); // Do not display a duration in top level of History view if (_currentDbView != DBView.History || _currentLabel != String.Empty) { - item1.Label2 = strTime; + item1.Label2 = TVUtil.GetRecordingDateString(rec); } if (currentLayout != GUIFacadeControl.Layout.List) { @@ -1073,7 +1067,7 @@ private bool OnSelectedRecording(int iItem) IEnumerable itemlist = ServiceAgents.Instance.RecordingServiceAgent.ListAllRecordingsByMediaType(MediaTypeEnum.TV); _activeRecording = rec; - _bIsLiveRecording = false; + _bIsLiveRecording = false; foreach (Recording recItem in itemlist) { if (rec.IdRecording == recItem.IdRecording && IsRecordingActual(recItem)) @@ -1189,9 +1183,9 @@ private void DeleteRecordingAndUpdateGUI(Recording rec) { _oldStateSMSsearch = facadeLayout.EnableSMSsearch; facadeLayout.EnableSMSsearch = false; - + TryDeleteRecordingAndNotifyUser(rec); - + LoadDirectory(); while (_iSelectedItem >= GetItemCount() && _iSelectedItem > 0) @@ -1207,7 +1201,7 @@ private void DeleteRecordingAndUpdateGUI(Recording rec) private void TryDeleteRecordingAndNotifyUser(Recording rec) { - + int timeout = 0; bool deleteRecording = false; @@ -1350,14 +1344,10 @@ private void SetProperties(Recording rec) GUIPropertyManager.SetProperty("#TV.RecordedTV.thumb", ""); return; } - string strTime = string.Format("{0} {1} - {2}", - Utils.GetShortDayString(rec.StartTime), - rec.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat), - rec.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat)); GUIPropertyManager.SetProperty("#TV.RecordedTV.Title", TVUtil.GetDisplayTitle(rec)); GUIPropertyManager.SetProperty("#TV.RecordedTV.Genre", TVUtil.GetCategory(rec.ProgramCategory)); - GUIPropertyManager.SetProperty("#TV.RecordedTV.Time", strTime); + GUIPropertyManager.SetProperty("#TV.RecordedTV.Time", TVUtil.GetRecordingDateStringFull(rec)); GUIPropertyManager.SetProperty("#TV.RecordedTV.Description", rec.Description); string strLogo = ""; @@ -1371,7 +1361,7 @@ private void SetProperties(Recording rec) } else { - GUIPropertyManager.SetProperty("#TV.RecordedTV.thumb", "defaultVideoBig.png"); + GUIPropertyManager.SetProperty("#TV.RecordedTV.thumb", "defaultVideoBig.png"); } } catch (Exception ex) @@ -1477,7 +1467,7 @@ public int Compare(GUIListItem item1, GUIListItem item2) if (rec1.Channel != null) { rec1DisplayName = rec1.Channel.DisplayName; - } + } if (rec2.Channel != null) { rec2DisplayName = rec2.Channel.DisplayName; @@ -1609,7 +1599,7 @@ public int Compare(GUIListItem item1, GUIListItem item2) case SortMethod.Genre: var categoryRec1 = TVUtil.GetCategory(rec1.ProgramCategory); var categoryRec2 = TVUtil.GetCategory(rec2.ProgramCategory); - item1.Label2 = categoryRec1; + item1.Label2 = categoryRec1; item2.Label2 = categoryRec2; if (categoryRec1 != categoryRec2) { @@ -1685,23 +1675,23 @@ private void doOnPlayBackStoppedOrChanged(g_Player.MediaType type, int stoptime, { return; } - + Recording rec = ServiceAgents.Instance.RecordingServiceAgent.GetRecordingByFileName(filename); if (rec != null) { if (stoptime >= g_Player.Duration) { stoptime = 0; - } + } ; //temporary workaround before end of stream get's properly implemented rec = ServiceAgents.Instance.RecordingServiceAgent.GetRecording(rec.IdRecording); - rec.StopTime = stoptime; + rec.StopTime = stoptime; ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(rec); } else { this.LogInfo("TvRecorded:{0} no recording found with filename {1}", caller, filename); - } + } } private void OnPlayRecordingBackChanged(MediaPortal.Player.g_Player.MediaType type, int stoptime, string filename) @@ -1722,18 +1712,18 @@ private void OnPlayRecordingBackEnded(g_Player.MediaType type, string filename) } g_Player.Stop(); - + Recording rec = ServiceAgents.Instance.RecordingServiceAgent.GetRecordingByFileName(filename); if (rec != null) { if (_deleteWatchedShows || rec.KeepUntil == (int)KeepMethodType.UntilWatched) { - + ServiceAgents.Instance.ControllerServiceAgent.DeleteRecording(rec.IdRecording); } else - { - rec.StopTime = 0; + { + rec.StopTime = 0; ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(rec); } } @@ -1773,7 +1763,7 @@ private void OnPlayRecordingBackStarted(g_Player.MediaType type, string filename private void ResetWatchedStatus(Recording aRecording) { aRecording.TimesWatched = 0; - aRecording.StopTime = 0; + aRecording.StopTime = 0; ServiceAgents.Instance.RecordingServiceAgent.SaveRecording(aRecording); }