private void CreatePlaylists_Click(object sender, RoutedEventArgs e) { if (PlaylistWindow.Show(this)) { StartActionType = StartActionType.CreatePlaylist; this.DialogResult = true; } }
private void UpdateMoviesheets_Click(object sender, RoutedEventArgs e) { if (SelectTemplateBox.Show(this)) { StartActionType = StartActionType.UpdateMoviesheetsTemplate; this.DialogResult = true; } }
private void Button_Click_2(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are you sure you want to rename all *.jpg_tg files to *.jpg\r\n and remove the zzz.mp4 files (for the checked folders)?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { GC.Collect(); StartActionType = StartActionType.UnfixNetworkShares; this.DialogResult = true; } }
private void Automatic_Click(object sender, RoutedEventArgs e) { //if (MessageBox.Show("Are you sure you want to let me find thumbnails for the selected movies?\n\nI recommend you to use .nfo files and collectors supporting IMDb search.", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { GC.Collect(); StartActionType = StartActionType.ProcessAutomatic; this.DialogResult = true; } }
private void GenerateDummyFile_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are you sure you want to generate the dummy file for all checked movies?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { GC.Collect(); StartActionType = StartActionType.GenerateDummyFile; this.DialogResult = true; } }
private void GetRandomSnapshotsMix_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are you sure you want to let me generate automatically thumbnails for the selected movies?\n\n" + "Thumbnails will be built from several snapshots taken from the movie.", "Question", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.Yes) { GC.Collect(); StartActionType = StartActionType.GenerateRandomThumbs; this.DialogResult = true; } }
public static void ProcessMovies(ObservableCollection <CollectorNode> selectedCollectors, ThumbGenMainWindow mainWindow, IList <string> rootPaths, StartActionType actionType) { CurrentSeriesHelper.Reset(); FolderToSkip = null; FolderCompleteSkipped = false; if (actionType == StartActionType.Unknown) { return; } m_OverwriteExisting = Configuration.Options.OverwriteExistingThumbs; m_Progress = mainWindow.progressBar1; m_ProgressText = mainWindow.textBlock1; Movies.Clear(); mainWindow.progressListBox.DataContext = Movies; //(mainWindow.FindResource("MoviesCollectionView") as CollectionViewSource).Source = Movies; bool _aborted = false; m_ProgressText.Text = "Collecting movies..."; try { ShowAdorner("Collecting movies...", false); Helpers.DoEvents(); List <FileInfo> _files = null; if (rootPaths.Count != 0) { mainWindow.Dispatcher.Invoke((Action) delegate { FilesCollector _fc = new FilesCollector(); _files = new List <FileInfo>(); // new approach, scan the given folders fully foreach (string _item in rootPaths) { if (Directory.Exists(_item)) { // collect all movies List <FileInfo> _tmp = _fc.CollectFiles(_item, true, false).ToList <FileInfo>(); if (_tmp.Count != 0) { _files.AddRange(_tmp); } } else { if (File.Exists(_item)) { _files.Add(new FileInfo(_item)); } } } }, DispatcherPriority.Background); } else { return; } switch (actionType) { case StartActionType.Process: case StartActionType.ProcessAutomatic: case StartActionType.ProcessSemiautomatic: case StartActionType.ProcessFeelingLucky: case StartActionType.GenerateRandomThumbs: foreach (FileInfo _file in _files) { Movies.Add(new MovieItem(_file.FullName)); Thread.Sleep(0); } break; case StartActionType.FixNetworkShares: MP4Tagger.MP4Manager.ApplyBatchFix(_files); break; case StartActionType.UnfixNetworkShares: MP4Tagger.MP4Manager.ApplyBatchUnFix(_files); break; case StartActionType.GenerateDummyFile: FileManager.GenerateDummyFiles(_files); break; case StartActionType.UpdateMoviesheetsTemplate: foreach (FileInfo _file in _files) { Movies.Add(new MovieItem(_file.FullName)); Thread.Sleep(0); } MoviesheetsUpdateManager.ApplyNewTemplate(_files, MoviesheetsUpdateManager.SelectedTemplates); break; case StartActionType.CreatePlaylist: foreach (FileInfo _file in _files) { Movies.Add(new MovieItem(_file.FullName)); Thread.Sleep(0); } ShowAdorner("Generating playlists... Please wait...", false); using (Playlists.PlaylistManager _manager = new Playlists.PlaylistManager()) { _manager.CreatePlaylists(_files, FileManager.Configuration.Options.PlaylistsJobs); } break; } } finally { HideAdorners(); } if (Movies != null && Movies.Count != 0 && (actionType == StartActionType.Process || actionType == StartActionType.ProcessAutomatic || actionType == StartActionType.ProcessSemiautomatic || actionType == StartActionType.ProcessFeelingLucky || actionType == StartActionType.GenerateRandomThumbs)) { m_Progress.Minimum = 0; m_Progress.Maximum = Movies.Count; m_Progress.Value = 0; List <BaseCollector> _collectors = new List <BaseCollector>(); if (actionType != StartActionType.GenerateRandomThumbs) { foreach (CollectorNode _node in selectedCollectors) { if (_node.Collector != null) { // if it is a XMLImportCollectorBase derived collector then call Load XMLImportCollectorBase _xmlCol = _node.Collector as XMLImportCollectorBase; if (_xmlCol != null) { _xmlCol.Load(); } // check if online try { IPHostEntry _inetServer = Dns.GetHostEntry(_node.Collector.Host.Replace("http://", String.Empty)); // add it if online _collectors.Add(_node.Collector); } catch { MessageBox.Show(String.Format("Unable to connect to {0}.\n\nThe {1} collector will be disabled for this session.", _node.Collector.Host, _node.Collector.CollectorName), "Connection error", MessageBoxButton.OK, MessageBoxImage.Warning); _node.IsSelected = false; // disable the collector } } } } else { //_collectors.Add(new RandomSnapshotsCollector()); } CurrentCollector = new AllProvidersCollector(_collectors); CurrentCollector.MainWindow = mainWindow; if (CurrentCollector != null) { CurrentCollector.Processing += new EventHandler(_collector_Processing); CurrentCollector.Processed += new EventHandler(_collector_Processed); CurrentCollector.ThumbnailCreated += new EventHandler(_collector_ThumbnailCreated); } _aborted = DoProcessMovies(Movies, mainWindow, actionType); } CurrentSeriesHelper.Reset(); m_Progress.Value = 0; if (!_aborted && (actionType == StartActionType.ProcessAutomatic || actionType == StartActionType.ProcessFeelingLucky)) { // chkeck if there are "Not found" movies and ask user maybe he wants to reprocess them manually var _notFoundMovies = from c in Movies where c.MovieItemStatus == MovieItemStatus.NotFound || c.MovieItemStatus == MovieItemStatus.Exception select c; if (_notFoundMovies != null && _notFoundMovies.Count() != 0) { if (MessageBox.Show(string.Format("Not found: {0} movie(s)\r\n\r\nWould you like to manually process them?", _notFoundMovies.Count()), "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes) == MessageBoxResult.Yes) { ObservableCollection <MovieItem> _movies = new ObservableCollection <MovieItem>(_notFoundMovies); FileManager.Mode = ProcessingMode.Manual; _aborted = DoProcessMovies(_movies, mainWindow, StartActionType.Process); } } } if (!_aborted) { m_ProgressText.Text = "Done."; } CurrentSeriesHelper.Reset(); m_Progress.Value = 0; }
private static bool ProcessMovie(MovieItem movie, StartActionType actionType) { if (movie != null && File.Exists(movie.FilePath)) { movie.MovieItemStatus = MovieItemStatus.Querying; //string _sourceFile = Path.GetFileName(movie.FilePath); string _imageFile = Helpers.GetCorrectThumbnailPath(movie.FilePath, false); m_ProgressText.Text = "Processing " + movie.FilePath; m_Progress.Value++; if (File.Exists(_imageFile) && !m_OverwriteExisting && FileManager.Configuration.Options.AutogenerateThumbnail) { //m_LogBox.Items.Insert(0, string.Format("* {0} - Skipped (thumbnail exists).", movie.Filename)); movie.MovieItemStatus = MovieItemStatus.SkippedExistingThumbnail; return(true); } string _msg = string.Empty; QueryResult _done = QueryResult.Abort; if (CurrentCollector != null) { ShowAdorner(string.Format("Analyzing {0}...", movie.Filename), false); Helpers.DoEvents(); try { if (actionType == StartActionType.GenerateRandomThumbs) { _done = VideoScreenShot.MakeThumbnail(movie.FilePath) ? QueryResult.Done : QueryResult.Skip; } else { _done = CurrentCollector.ProcessMovie(movie); } } finally { HideAdorners(); } } if (_done == QueryResult.Abort) { //abort return(false); } //_msg = string.Format("* {0}{1}", movie.Filename, (bool)_done ? " - Done." : " - Skipped."); switch (_done) { case QueryResult.Done: movie.MovieItemStatus = MovieItemStatus.Done; break; case QueryResult.NotFound: movie.MovieItemStatus = MovieItemStatus.NotFound; break; case QueryResult.SkipFolder: // TODO: Handle the folder skip here somehow...currently it is not skipping anything FolderToSkip = movie.DirectoryName; FolderCompleteSkipped = true; movie.MovieItemStatus = MovieItemStatus.Skipped; break; default: movie.MovieItemStatus = MovieItemStatus.Skipped; break; } Helpers.DoEvents(); } return(true); }
private static bool DoProcessMovies(ObservableCollection <MovieItem> movies, ThumbGenMainWindow mainWindow, StartActionType actionType) { bool _aborted = false; foreach (MovieItem _item in movies) { if (FolderToSkip != null) { if (string.Compare(FolderToSkip, Path.GetDirectoryName(_item.FilePath), true) != 0) { FolderToSkip = null; FolderCompleteSkipped = false; } else { if (FolderCompleteSkipped) { continue; } } } if (!ProcessMovie(_item, actionType)) { m_ProgressText.Text = "Aborted by the user."; _item.MovieItemStatus = MovieItemStatus.Unknown; _aborted = true; break; } //generate the dummy file for HUB (if required) FileManager.GenerateDummyFile(_item.FilePath); mainWindow.progressListBox.ScrollIntoViewCentered(_item); Thread.Sleep(0); } return(_aborted); }
private void startbutton_Click(object sender, RoutedEventArgs e) { IEnumerable <CollectorNode> _selectedCollectors = FileManager.GetSelectedCollectors(Collectors); if (!_selectedCollectors.Any() && !FileManager.Configuration.Options.DisableSearch) { MessageBox.Show("Please select at least one provider for images.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } GC.Collect(); //GC.WaitForPendingFinalizers(); ExplorerWindow _fileExplorer = new ExplorerWindow(this); ExplorerWindowViewModel _fileExplorerVM = new ExplorerWindowViewModel(); _fileExplorer.DataContext = _fileExplorerVM; _fileExplorerVM.SelectPath(FileManager.Configuration.Options.LastSelectedFolder); bool?_res = _fileExplorer.ShowDialog(); StartActionType _actionType = _fileExplorer.StartActionType; if (_res.HasValue && _res.Value) { switch (_actionType) { case StartActionType.Process: case StartActionType.ProcessAutomatic: case StartActionType.ProcessSemiautomatic: case StartActionType.ProcessFeelingLucky: case StartActionType.GenerateRandomThumbs: switch (_actionType) { case StartActionType.Process: FileManager.Mode = ProcessingMode.Manual; break; case StartActionType.ProcessSemiautomatic: FileManager.Mode = ProcessingMode.SemiAutomatic; break; case StartActionType.ProcessAutomatic: FileManager.Mode = ProcessingMode.Automatic; break; case StartActionType.ProcessFeelingLucky: FileManager.Mode = ProcessingMode.FeelingLucky; break; } dcMovies.IsEnabled = false; TheRibbon.IsEnabled = false; try { IList <string> list = _fileExplorerVM.CollectSelectedFolders(); UpdateConfigurationData(); _fileExplorerVM.Dispose(); _fileExplorer.Close(); _fileExplorer = null; GC.Collect(); if (list.Count != 0) { FileManager.ProcessMovies(_selectedCollectors as ObservableCollection <CollectorNode>, this, list, _actionType); } else { System.Windows.MessageBox.Show("Nothing selected, nothing to do...", "Information", MessageBoxButton.OK, MessageBoxImage.Information); return; } } finally { dcMovies.IsEnabled = true; TheRibbon.IsEnabled = true; } break; case StartActionType.FixNetworkShares: case StartActionType.UnfixNetworkShares: case StartActionType.UpdateMoviesheetsTemplate: case StartActionType.CreatePlaylist: case StartActionType.GenerateDummyFile: _fileExplorer.Close(); _fileExplorer = null; GC.Collect(); IList <string> list2 = _fileExplorerVM.CollectSelectedFolders(); if (list2.Count != 0) { FileManager.ProcessMovies(_selectedCollectors as ObservableCollection <CollectorNode>, this, list2, _actionType); } else { System.Windows.MessageBox.Show("Nothing selected, nothing to do...", "Information", MessageBoxButton.OK, MessageBoxImage.Information); return; } break; } } }