private void OnLoadRecordings() { try { for (int i = 0; i < Recordings.Count; i++) { Recordings.RemoveAt(i); } RegionManager.Regions[RegionNames.RecordingRegion].RemoveAll(); foreach (var recording in TvHeadend.GetRecordings()) { Recordings.Add(recording); } foreach (var recording in Recordings.OrderBy(r => r.Start)) { var navigationParams = new NavigationParameters { { "DataContext", recording } }; RegionManager.RequestNavigate(RegionNames.RecordingRegion, new Uri("Recording", UriKind.Relative), NavigationCompleted, navigationParams); } EventAggregator.GetEvent <StatusChangedEvent>().Publish(new StatusInfo($"{Recordings.Count} Recordings.")); } catch (Exception ex) { EventAggregator.GetEvent <StatusChangedEvent>().Publish(new StatusInfo(ex.Message)); } }
public bool BuildFromDirectory(string Directory) { // Get list of raw files string[] Files = System.IO.Directory.GetFiles(Directory, "*.mp4").OrderBy(x => x).ToArray(); // Make sure there's at least one valid file if (Files.Length < 1) { return(false); } // Create a list of cam files List <TeslaCamFile> CurrentTeslaCams = new List <TeslaCamFile>(Files.Length); // Convert raw file to cam file foreach (var File in Files) { TeslaCamFile f = TeslaCamFile.TryParse(File); if (f != null) { CurrentTeslaCams.Add(f); } } if (CurrentTeslaCams.Count == 0) { return(false); } // Now get list of only distinct events List <string> DistinctEvents = CurrentTeslaCams.Select(e => e.Date.UTCDateString).Distinct().ToList(); // Find the files that match the distinct event foreach (var CurrentEvent in DistinctEvents) { List <TeslaCamFile> MatchedFiles = CurrentTeslaCams.Where(e => e.Date.UTCDateString == CurrentEvent).ToList(); TeslaCamFileSet CurrentFileSet = new TeslaCamFileSet(); CurrentFileSet.SetCollection(MatchedFiles); this.Recordings.Add(CurrentFileSet); } // Set metadata this.Recordings = Recordings.OrderBy(e => e.Date.UTCDateString).ToList(); this.StartDate = Recordings.First().Date; this.EndDate = Recordings.Last().Date; // Success return(true); }