コード例 #1
0
 public void UpdateAvailableFileFilters(IEnumerable <string> availableFileFilters)
 {
     if (availableFileFilters != null)
     {
         AvailableFileFilters = new ReadOnlyCollection <string>(availableFileFilters.ToList());
         if (!ActiveFileFilters.Any())
         {
             ActiveFileFilters = new ObservableCollection <string>(availableFileFilters);
         }
     }
 }
コード例 #2
0
        private bool ItemFilter(object item)
        {
            var searchResult = (SearchResultViewModel)item;

            try
            {
                string regexFileFriendlyFilter      = RegexHelper.WildcardToRegex(FileFilterExpression);
                string regexDirectoryFriendlyFilter = RegexHelper.WildcardToRegex(DirectoryFilterExpression);

                bool isFileFilterValid      = string.IsNullOrEmpty(FileFilterExpression) || RegexHelper.IsValidRegex(RegexHelper.WildcardToRegex(FileFilterExpression));
                bool isDirectoryFilterValid = string.IsNullOrEmpty(DirectoryFilterExpression) || RegexHelper.IsValidRegex(RegexHelper.WildcardToRegex(DirectoryFilterExpression));

                bool hasValidExtension = !ActiveFileFilters.Any() || ActiveFileFilters.Any(cur => cur.TrimStart('*') == searchResult.Extension);
                return(hasValidExtension &&
                       (!isFileFilterValid || Regex.IsMatch(searchResult.Filename, regexFileFriendlyFilter, RegexOptions.IgnoreCase)) &&
                       (!isDirectoryFilterValid || Regex.IsMatch(searchResult.Directory, regexDirectoryFriendlyFilter, RegexOptions.IgnoreCase)));
            }
            catch
            {
                return(true);
            }
        }