public void MergeEpisodes(IEnumerable <ITvShowEpisodeInfo> episodes, bool subtitlesNeeded) { episodes = episodes.OrderBy(e => e.Season, new SeasonComparer()).ThenBy(e => e.Episode); ITvShowEpisodeInfo lastEpisode = null; foreach (var episodeInfo in episodes) { var season = Seasons.FirstOrDefault(s => s.Season == episodeInfo.Season); if (season == null) { season = new TvShowSeason { TvShowId = Id, TvShow = this, Season = episodeInfo.Season }; Seasons.Add(season); } var episode = season.Episodes.FirstOrDefault(e => e.Episode == episodeInfo.Episode); if (episode == null) { episode = new TvShowEpisode { TvShowSeason = season }; season.Episodes.Add(episode); episode.Episode = episodeInfo.Episode; episode.BackgroundDownload = AutoDownload; episode.BackgroundSubtitleDownload = AutoDownload && subtitlesNeeded; } episode.AirDate = episodeInfo.AirDate; episode.Name = episodeInfo.Name; episode.Overview = episodeInfo.Overview; lastEpisode = episodeInfo; } if (lastEpisode != null) { for (var i = Seasons.Count - 1; i >= 0; i--) { var season = Seasons.ElementAt(i); if (season.Season > lastEpisode.Season) { Seasons.Remove(season); } else if (season.Season == lastEpisode.Season) { for (var j = season.Episodes.Count - 1; j >= 0; j--) { var episode = season.Episodes.ElementAt(j); if (episode.Episode > lastEpisode.Episode) { season.Episodes.Remove(episode); } } } } } }
private void PB_Del_Click(object sender, EventArgs e) { if (DialogResult.OK == MessageBox.Show("Are you sure you want to dismiss this Season and all its Episodes and Subtitles?", "Delete Season?", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)) { Seasons.Remove(Season); Dispose(); } }
void DeleteSeason() { if (SelectedSeason == null) { return; } Seasons.Remove(SelectedSeason); IsChanged = true; }
private void PB_Del_Click(object sender, EventArgs e) { if (DialogResult.OK == MessageBox.Show("Are you sure you want to dismiss this Episode and its Subtitles?", "Delete Episode?", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk)) { Episode.Season.Control.Height -= Height; Episode.Season.Control.EpControlList.Remove(this); if (Episode.Season.Control.EpControlList.Count == 0) { Episode.Season.Control.Dispose(); Seasons.Remove(Episode.Season); } else { Episode.Season.Episodes.Remove(Episode); Dispose(); } } }
protected override void CopyFrom(IEntity entity) { var external = Helper.ConvertTo <TvShow>(entity); CopyFrom(external); AutoDownload = external.AutoDownload; IsActive = external.IsActive; Status = external.Status; LastUpdateDate = external.LastUpdateDate; var c = Seasons.Count; var ec = external.Seasons.Count; while (c > ec) { Seasons.Remove(Seasons.ElementAt(--c)); } for (var i = 0; i < ec; i++) { TvShowSeason season; if (c < i + 1) { season = new TvShowSeason { TvShowId = Id, TvShow = this }; Seasons.Add(season); } else { season = Seasons.ElementAt(i); } season.CopyFrom(external.Seasons.ElementAt(i)); } }
/// <summary> /// Удалить выбранный сезон /// </summary> public void RemoveSeason() { if (CanRemoveSeason is false) { return; } using (var ctx = new CVDbContext(AppDataPath)) { var temp = ctx.CartoonSeasons.Find(SelectedSeason.CartoonSeasonId); ctx.Entry(temp).State = EntityState.Deleted; ctx.SaveChanges(); } var tempList = ((CartoonsEditorViewModel)Parent).Seasons; ((CartoonsEditorViewModel)Parent) .Seasons.Remove(tempList.First(s => s.CartoonSeasonId == SelectedSeason.CartoonSeasonId)); Seasons.Remove(SelectedSeason); NotifyOfPropertyChange(() => Seasons); SelectedSeason = Seasons.Count > 0 ? Seasons.Last() : null; }
public void RemoveSeason(Season season) { Seasons?.Remove(season); }