private void SelectVoiceOver() { if (CartoonVoiceOvers.Count == 0 && EpisodeVoiceOvers.Count == 0) { SelectedGlobalVoiceOver = GlobalVoiceOvers.Count > 0 ? GlobalVoiceOvers.Last() : null; return; } if (EpisodeVoiceOvers.Count > 0) { SelectedEpisodeVoiceOver = EpisodeVoiceOvers.Last(); return; } if (CartoonVoiceOvers.Count > 0) { SelectedCartoonVoiceOver = CartoonVoiceOvers.Last(); return; } if (SelectedVoiceOverId > 0) { SelectedGlobalVoiceOver = GlobalVoiceOvers .FirstOrDefault(gvo => gvo.CartoonVoiceOverId == SelectedVoiceOverId); } }
/// <summary> /// Задать новое значение выбранной озвучке /// </summary> private void SetVoiceOverValue() { _selectedGlobalVoiceOver = GlobalVoiceOvers .FirstOrDefault(gvo => gvo.CartoonVoiceOverId == SelectedVoiceOverId); NotifyOfPropertyChange(() => SelectedGlobalVoiceOver); NotifyGlobalVoiceOversButtons(); if (SelectedCartoon != null) { if (SelectedEpisode != null) { _selectedEpisodeVoiceOver = EpisodeVoiceOvers .FirstOrDefault(evo => evo.CartoonVoiceOverId == SelectedVoiceOverId); NotifyOfPropertyChange(() => SelectedEpisodeVoiceOver); NotifyEpisodeVoiceOversButtons(); } _selectedCartoonVoiceOver = CartoonVoiceOvers .FirstOrDefault(evo => evo.CartoonVoiceOverId == SelectedVoiceOverId); NotifyOfPropertyChange(() => SelectedCartoonVoiceOver); NotifyCartoonVoiceOversButtons(); } NotifySharedVoiceOversButtons(); }
/// <summary> /// Удалить выбранную озвучку из списка текущего эпизода /// </summary> private void RemoveVoiceOverFromEpisodeList() { var episodeVoiceOver = EpisodeVoiceOvers .First(cvo => cvo.CartoonVoiceOverId == SelectedVoiceOverId); EpisodeVoiceOvers.Remove(episodeVoiceOver); NotifyOfPropertyChange(() => EpisodeVoiceOvers); }
/// <summary> /// Копировать выбранную озвучку м/ф в текущий эпизод /// </summary> public void MoveToEpisodeVoiceOvers() { if (CanMoveToEpisodeVoiceOvers is false) { return; } if (SelectedVoiceOverId == 0) { throw new Exception("Id выбраной озвучки м/ф равен 0"); } using (var ctx = new CVDbContext(AppDataPath)) { var episode = ctx.CartoonEpisodes .Include(ce => ce.EpisodeVoiceOvers) .Single(ce => ce.CartoonEpisodeId == IdList.EpisodeId); var episodeOption = new EpisodeOption { CartoonEpisodeId = episode.CartoonEpisodeId, CartoonVoiceOverId = SelectedVoiceOverId, Name = $"{SelectedGlobalVoiceOver.Name}_Option" }; ctx.EpisodeOptions.Add(episodeOption); ctx.SaveChanges(); episodeOption = ctx.EpisodeOptions.ToList().Last(); // создание нового джампера var jumper = new Jumper { EpisodeOptionId = episodeOption.EpisodeOptionId, Number = 1 }; ctx.Jumpers.Add(jumper); ctx.SaveChanges(); episodeOption = ctx.EpisodeOptions .Include(eo => eo.Jumpers) .ToList().Last(); var totalSkipCount = episodeOption.Jumpers.Sum(j => j.SkipCount); var duration = episodeOption.CreditsStart - new TimeSpan(0, 0, totalSkipCount * 5); episodeOption.Duration = duration; ctx.SaveChanges(); if (episode.EpisodeVoiceOvers.Count == 0) { ctx.VoiceOvers .Include(vo => vo.CheckedEpisodes) .Single(vo => vo.CartoonVoiceOverId == SelectedVoiceOverId) .CheckedEpisodes.Add(episode); } ctx.VoiceOvers .Include(vo => vo.CartoonEpisodes) .Single(vo => vo.CartoonVoiceOverId == SelectedVoiceOverId) .CartoonEpisodes.Add(episode); ctx.SaveChanges(); } var voiceOver = GlobalVoiceOvers.First(vo => vo.CartoonVoiceOverId == SelectedVoiceOverId); EpisodeVoiceOvers.Add(voiceOver); NotifyOfPropertyChange(() => EpisodeVoiceOvers); SelectedEpisodeVoiceOver = voiceOver; }