private IEnumerable <IInputFile> FilesAlreadyScanned() { // return the intersection of _fileNames and inputFiles if (_project == null) { return(Enumerable.Empty <IInputFile>()); } return(_project.GetInputFiles().Where(f => SelectedInputFiles.Contains(f.Name))); }
/// <summary> /// Runs the file scanner after closing this dialog. /// Start a scan on the selected file(s) /// </summary> private void Run() { if (ContainerDetectorSelection.Count == 0 && CodecDetectorSelection.Count == 0) { MessageBox.Show("There is no container and no codec detector selected to scan the files. Please select one or more container and codec detectors.", "Select a detector", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.None; // Keep the dialog open return; } if ((SelectedInputFiles == null) || (SelectedInputFiles.Count() == 0)) { MessageBox.Show("There are no files selected. Please select one ore more files to scan.", "Select a file", MessageBoxButtons.OK, MessageBoxIcon.Error); this.DialogResult = DialogResult.None; // Keep the dialog open return; } // Check for files that are already scanned IEnumerable <IInputFile> filesAlreadyScanned = FilesAlreadyScanned(); if (filesAlreadyScanned.Count() > 0) { string message = "These files are already scanned by some of the selected plug-ins:" + Environment.NewLine + Environment.NewLine; foreach (IInputFile inputFile in filesAlreadyScanned) { message += inputFile.Name + Environment.NewLine; } message += Environment.NewLine + "When you press OK, they will be deleted and rescanned."; message += Environment.NewLine + "Note that all open Workpads will be closed."; DialogResult dialogResult = MessageBox.Show(message, "Delete and rescan files", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (dialogResult == DialogResult.Cancel) { this.DialogResult = DialogResult.None; // Keep the dialog open return; } CloseAllWorkpads(); DeleteFiles(filesAlreadyScanned); } DialogResult = DialogResult.OK; }