public SubsceneService(FileEntry selected) { this.selected = selected; }
/// <summary> /// Called everytime the window is displayed. /// </summary> public void OnPresented() { FileEntry selectedEntry = listSearchViewModel.SelectedEntry; if (selectedEntry != null) { this.customEntry = new FileEntry(selectedEntry.GetFullPath(), selectedEntry.title, selectedEntry.release, selectedEntry.episode); } else { this.customEntry = new FileEntry(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "", "", ""); } }
private void AddDirectoryContent(ObservableCollection<FileEntry> parent, string directory) { var ignoredFiles = new List<String> { "desktop", "thumbs", "movies", "series", "sample" }; foreach (var entry in Directory.GetFileSystemEntries(directory)) { try { var fileName = Path.GetFileName(entry); if (fileName == null) continue; var isDirectory = Directory.Exists(entry); var isDirectoryAndContainsSeveralCorrectFileTypes = false; var isCorrectFileType = ExpectedNames.FileTypeNames.Contains(fileName.Substring(fileName.Length - 4)); var subtitleExist = false; if (isDirectory) { if (Settings.IgnoreAlreadySubbedFolders) { subtitleExist = LookForSubtitle(entry); } //Check if correct file type is present in first level of dir: var dirEntries = Directory.GetFiles(entry); foreach (var dirEntry in dirEntries) { if (ExpectedNames.FileTypeNames.Contains(Path.GetExtension(dirEntry)) == false) { continue; } if (isCorrectFileType) { isDirectoryAndContainsSeveralCorrectFileTypes = true; } isCorrectFileType = true; } } if ((Settings.IgnoreAlreadySubbedFolders && subtitleExist) || ignoredFiles.Contains(fileName.ToLower().Split('.')[0]) || !isCorrectFileType) { continue; } FileEntry fileEntry = new FileEntry(entry); fileEntry.DefineEntriesFromPath(); parent.Add(fileEntry); if (isDirectoryAndContainsSeveralCorrectFileTypes) { this.AddDirectoryContent(fileEntry.AllEntries, fileEntry.path); } else { if (AllEntries != parent) { var parentEntry = AllEntries.Count > 0 ? AllEntries.Last() : fileEntry; fileEntry.DefineEntriesWithDefault("", parentEntry.release ?? "", ""); } } } catch(Exception) { //ignored and continue with next (meaning that this entry will not be shown.) } } }
public void OpenFileDialogBrowser() { var dialog = new System.Windows.Forms.FolderBrowserDialog(); if (dialog.ShowDialog() == DialogResult.OK) { CustomEntry = new FileEntry(dialog.SelectedPath, customEntry.title, customEntry.release, customEntry.episode); } }