Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        /// <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();
        }
Beispiel #3
0
        /// <summary>
        /// Удалить выбранную озвучку из списка текущего м/ф
        /// </summary>
        private void RemoveVoiceOverFromCartoonList()
        {
            var cartoonVoiceOver = CartoonVoiceOvers
                                   .First(cvo => cvo.CartoonVoiceOverId == SelectedVoiceOverId);

            CartoonVoiceOvers.Remove(cartoonVoiceOver);
            NotifyOfPropertyChange(() => EpisodeVoiceOvers);
        }
Beispiel #4
0
        /// <summary>
        /// Копировать выбранную глобальную озвучку в текущий м/ф
        /// </summary>
        public void MoveToCartoonVoiceOvers()
        {
            if (CanMoveToCartoonVoiceOvers is false)
            {
                return;
            }

            if (SelectedVoiceOverId == 0)
            {
                throw new Exception("Id выбраной озвучки м/ф равен 0");
            }

            if (CartoonVoiceOvers.Any(cvo => cvo.CartoonVoiceOverId == SelectedVoiceOverId))
            {
                SelectedCartoonVoiceOver = CartoonVoiceOvers
                                           .First(cvo => cvo.CartoonVoiceOverId == SelectedVoiceOverId);
                return;
            }

            using (var ctx = new CVDbContext(AppDataPath))
            {
                var cartoon = ctx.Cartoons
                              .Include(c => c.CartoonVoiceOvers)
                              .Single(c => c.CartoonId == IdList.CartoonId);

                ctx.VoiceOvers
                .Include(vo => vo.Cartoons)
                .Single(vo => vo.CartoonVoiceOverId == SelectedVoiceOverId)
                .Cartoons.Add(cartoon);
                ctx.SaveChanges();
            }

            var voiceOver = GlobalVoiceOvers.First(vo => vo.CartoonVoiceOverId == SelectedVoiceOverId);

            CartoonVoiceOvers.Add(voiceOver);
            NotifyOfPropertyChange(() => EpisodeVoiceOvers);

            SelectedCartoonVoiceOver = voiceOver;
            NotifyOfPropertyChange(() => SelectedCartoonVoiceOver);
        }