示例#1
0
        /// <summary>
        /// Подсчет длительности эпизода
        /// </summary>
        /// <returns></returns>
        private TimeSpan CalculatingDuration(EpisodeOption episodeOption = null)
        {
            int totalSkipCount;

            if (episodeOption != null)
            {
                totalSkipCount = episodeOption.Jumpers.Sum(j => j?.SkipCount ?? 0);

                return(episodeOption.CreditsStart - new TimeSpan(0, 0, totalSkipCount * 5));
            }


            if (SelectedEpisodeOption == null)
            {
                return(new TimeSpan());
            }

            totalSkipCount = Jumpers.Sum(j => j.SkipCount);

            var duration = SelectedEpisodeOption.CreditsStart - new TimeSpan(0, 0, totalSkipCount * 5);

            //SelectedEpisodeOption.Duration = duration;

            return(duration);
        }
示例#2
0
        /// <summary>
        /// Создание новой опции эпизода с джампером
        /// </summary>
        /// <param name="ctx">база данных</param>
        /// <param name="episode">созданный эпизод</param>
        /// <param name="voiceOver">активная озвучка</param>
        private void CreateNewEpisodeOption(CVDbContext ctx, CartoonEpisode episode, CartoonVoiceOver voiceOver)
        {
            // создание новой опции
            var episodeOption = new EpisodeOption
            {
                CartoonEpisodeId   = episode.CartoonEpisodeId,
                CartoonVoiceOverId = voiceOver.CartoonVoiceOverId,
                Name = $"{voiceOver.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.ToList().Last();

            episodeOption.Duration = CalculatingDuration(episodeOption);
            ctx.SaveChanges();
        }
示例#3
0
 /// <summary>
 /// Конвертировать значения Эпизода в значения класса EpisodeTime
 /// </summary>
 /// <param name="episodeOption">редактируемая опция</param>
 /// <param name="jumper">редактируемый джампер</param>
 /// <returns></returns>
 private EpisodeTime ConvertToEpisodeTime(EpisodeOption episodeOption, Jumper jumper) => new EpisodeTime
 {
     JumperTimeHours    = jumper?.StartTime.Hours,
     JumperTimeMinutes  = jumper?.StartTime.Minutes,
     JumperTimeSeconds  = jumper?.StartTime.Seconds,
     SkipCount          = jumper?.SkipCount,
     CreditsTimeHours   = episodeOption?.CreditsStart.Hours,
     CreditsTimeMinutes = episodeOption?.CreditsStart.Minutes,
     CreditsTimeSeconds = episodeOption?.CreditsStart.Seconds
 };
示例#4
0
        /// <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;
        }