/// <summary> /// Find the existing show or add the show if not yet present. /// </summary> /// <param name="title">Show title to find or add</param> /// <returns>Found or added show</returns> public Show GetShow(string title) { foreach(Show show in Shows) if(show.Title == title) return show; Show s = new Show(this, title); Shows.Add(s); return s; }
/// <summary> /// Check whether the specified show has any recordings. /// </summary> /// <param name="s">Show to find</param> /// <returns>True if there are recordings for the specified show</returns> public bool Contains(Show s) { return Shows.Contains(s); }
/// <summary> /// Create a new Season. /// </summary> /// <param name="parent">Show this season belongs to</param> /// <param name="number">Season number, or 0 for shows without proper seasons</param> /// <param name="cover">URL to cover art for this season</param> public Season(Show parent, string number, string cover) { _show = parent; int.TryParse(number, out _number); _coverUrl = cover; }
/// <summary> /// Compares this Show with another and indicates whether this Show /// precedes, follows, or appears in the same position in the sort order /// as the specified Show. /// </summary> /// <param name="show">Show to compare</param> /// <returns>Sort relation between this Show and show</returns> public int CompareTo(Show show) { switch(Recordings.SortOption) { case RecordingSortOption.OldestRecorded: return OldestEpisode.FirstAired.CompareTo(show.OldestEpisode.FirstAired); case RecordingSortOption.Title: default: return SortTitle.CompareTo(show.SortTitle); } }
/// <summary> /// Show the info panel with information for the specified Show. /// </summary> /// <param name="s">Show to display</param> private void ShowShowInfo(Show s) { _pnlInfo.Controls.Clear(); _pnlInfo.Tag = s; _pnlInfo.Controls.Add(MakeInfoTitleLabel(s.Title)); _pnlInfo.Controls.Add(MakeInfoLabel(string.Format(Properties.Resources.InfoNumEpisodes, s.NumEpisodes))); if(s.Seasons.Count > 1) _pnlInfo.Controls.Add(MakeInfoLabel(string.Format(Properties.Resources.InfoNumSeasons, s.Seasons.Count))); _pnlInfo.Controls.Add(MakeInfoLabel(string.Format(Properties.Resources.InfoRecordedRange, s.OldestEpisode.Recorded, s.NewestEpisode.Recorded))); _pnlInfo.Controls.Add(MakeInfoLabel(s.Duration.ToStringUnit())); _pnlInfo.Controls.Add(MakeInfoAction(Properties.Resources.Play18, Properties.Resources.ActionPlayOldest, Properties.Resources.TipPlayOldestShow, btnShowPlay_Click)); _pnlInfo.Controls.Add(MakeInfoAction(Properties.Resources.Export18, Properties.Resources.ActionExport, Properties.Resources.TipExportShow, btnShowExport_Click)); _pnlInfo.Controls.Add(MakeInfoAction(Properties.Resources.Delete18, Properties.Resources.ActionDeleteOldest, Properties.Resources.TipDeleteOldestShow, btnShowDelete_Click)); }
/// <summary> /// List all recorded seasons for the specified show. Shows with only one /// recorded season will jump right into that season, otherwise the season /// matching selectNumber is selected. /// </summary> /// <param name="show">Show to list seasons for</param> /// <param name="selectNumber">Select the season with this number</param> private void ListSeasons(Show show, int selectNumber) { if(show.Seasons.Count == 1) ListEpisodes(show.Seasons[0]); else { _pnlMain.Controls.Clear(); _pnlMain.Tag = show; _tip.SetToolTip(_pbBack, string.Format(Properties.Resources.BackTo, Properties.Resources.RecordedShows)); _pbBack.Enabled = true; _lblTitle.Text = string.Format(Properties.Resources.RecordedSeasons, show.Title); bool selectedSomething = false; foreach(Season s in show.Seasons) { PictureBox pb = new PictureBox(); pb.Tag = s; pb.Image = s.Cover != null ? s.Cover : Properties.Resources.Static1080p; pb.Width = 212; pb.Height = 301; pb.SizeMode = PictureBoxSizeMode.StretchImage; pb.Padding = new Padding(6); pb.Margin = new Padding(5); pb.Click += mainItem_Click; pb.DoubleClick += pbSeason_DoubleClick; pb.ContextMenuStrip = _cmnuSeason; _pnlMain.Controls.Add(pb); if(s.Number == selectNumber) { Select(pb); selectedSomething = true; } } if(!selectedSomething && _pnlMain.Controls.Count > 0) Select(_pnlMain.Controls[0]); } }
/// <summary> /// List all recorded seasons for the specified show. Shows with only one /// recorded season will jump right into that season, otherwise the first /// season is selected. /// </summary> /// <param name="show">Show to list seasons for</param> private void ListSeasons(Show show) { ListSeasons(show, -1); }
/// <summary> /// Export all Episodes of the specified Show with readable filenames to /// the specified path with the specified filename format. /// </summary> /// <param name="s">Show containing the Episodes to export</param> /// <param name="exportPath">Path to save exported episodes</param> /// <param name="nameFormat">Name format for exported episodes</param> private void ExportShowEpisodes(Show s, string exportPath, string nameFormat) { using(FileOperation fo = new FileOperation()) foreach(Season season in s.Seasons) foreach(Episode e in season.Episodes) ExportEpisodeTo(e, exportPath, nameFormat, fo); }
/// <summary> /// Export all Episodes of the specified Show with readable filenames. /// </summary> /// <param name="s">Show containing the Episodes to export</param> private void ExportShowEpisodes(Show s) { string nameFormat, exportPath; if(AskExportDetails(s.OldestEpisode, true, out nameFormat, out exportPath)) { Thread exportThread = new Thread(() => ExportShowEpisodes(s, exportPath, nameFormat)); exportThread.TrySetApartmentState(ApartmentState.MTA); exportThread.Name = "ExportShowEpisodes"; exportThread.Start(); } }