private bool TestFile(string file) { if (_shouldCancelSearch.WaitOne(0)) { return(false); } if (file == null || File.Exists(file) == false) { return(false); } if (SearchBookmarksActive()) { BookmarkFileInfo bfi = new BookmarkFileInfo(file, false); if (bfi == null || !bfi.IsValid || (theTask.Option1 && bfi.IsOrphan) || /* for BMK files: option 1 = non-orphan bookmarks */ (theTask.Option2 && !bfi.IsOrphan)) /* for BMK files: option 2 = orphan bookmarks */ { return(false); // skip this file } } else if (SearchMediaFilesActive()) { if (!MediaRenderer.IsSupportedMedia(file)) { return(false); // not a media file } MediaFileInfo mfi = MediaFileInfo.FromPath(file); if (mfi == null || !mfi.IsValid || (theTask.Option1 && mfi.Bookmarks.Count < 1) || /* for media files: option 1 = files with bookmarks */ (theTask.Option2 && mfi.Bookmarks.Count > 0)) /* for media files: option 2 = files w/o bookmarks */ { return(false); // skip this file } } if (!theTask.UseAttributes || AttributesMatch(File.GetAttributes(file), true)) { bool match = (theTask.SearchText.Length == 0) || (theTask.SearchProperties && ContainsProperty(file)) || (!theTask.SearchProperties && ContainsText(file)); if (match && !_matchingItems.Contains(file.ToLowerInvariant())) { _matchingItems.Add(file.ToLowerInvariant()); _displayItems.Add(file); return(true); } } return(false); }
private void DoShowProperties() { lbfi = new List <object>(); foreach (string item in strItems) { BookmarkFileInfo bfi = new BookmarkFileInfo(item, false); if (bfi.IsValid) { lbfi.Add(bfi); } } FileAttributesBrowser.ProcessObjectAttributes(lbfi); pgProperties.SelectedObjects = lbfi.ToArray(); base.Modified = false; }
private void BuildFields(string path) { if (this.IsServerURI) { mediaType = "URL"; } else if (!string.IsNullOrEmpty(path)) { try { string mediaName = base.Name; mediaType = PathUtils.GetExtension(path); MediaRenderer renderer = MediaRenderer.DefaultInstance; if (!MediaRenderer.AllMediaTypes.Contains(mediaType)) { throw new FileLoadException("Unexpected file type: " + mediaType, base.Path); } // Check for bookmark file string bookmarkPath = string.Format("{0}.bmk", path); _bookmarkInfo = new BookmarkFileInfo(bookmarkPath, false); _bookmarkInfo.BookmarkCollectionChanged += new EventHandler(_bookmarkInfo_BookmarkCollectionChanged); } catch (FileLoadException) { throw; } catch (FileNotFoundException) { throw; } catch { } } }