Example #1
0
        private void OnEpisodeCompleted(Episode episode)
        {
            this.activeEpisode.Completed -= OnEpisodeCompleted;

            if (Episodes.All(item => item.IsCompleted) && this.characterManager.Character.Entity.IsAlive())
            {
                OnCompleted();
                AnyScenarioCompleted?.Invoke(this);
            }
        }
        public MainWindowViewModel(List <Episode> episodes)
        {
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            var fileNames = new HashSet <string>(Directory.GetFiles(folder));

            foreach (var episode in episodes)
            {
                episode.OnSelectionChanged += (s, e) =>
                {
                    if (allSelected && !e.Value)
                    {
                        allSelected = false;

                        RaisePropertyChanged(() => AllSelected);
                    }
                    else if (!allSelected && Episodes.All(c => c.Selected))
                    {
                        allSelected = true;

                        RaisePropertyChanged(() => AllSelected);
                    }

                    UpdateUI();
                };

                if (fileNames.Contains(episode.GetFullPath(folder, MediaKind.Audio)))
                {
                    episode.HasAudio = true;
                }

                if (fileNames.Contains(episode.GetFullPath(folder, MediaKind.Video)))
                {
                    episode.HasVideo = true;
                }
            }

            Episodes = episodes;

            EpisodeFilterView        = (CollectionView)CollectionViewSource.GetDefaultView(Episodes);
            EpisodeFilterView.Filter = OnFilterTriggered;

            UpdateUI();

            FetchVideos = true;
            FetchAudios = false;

            cts = new CancellationTokenSource();

            ShowStandardStatusPrompt();
        }