public bool FilterAction(ImageComponent component) { if (string.IsNullOrWhiteSpace(Term) || IsInvalid) { return(false); } if (Favorite) { if (!component.IsFavorite.Value) { return(false); } } if (ExcludedTags.Count != 0) { if (ExcludedTags.Any(t => component.MetaData.Tags.Contains(t))) { return(false); } } if (Tags.Count != 0) { if (!Tags.Any(t => component.MetaData.Tags.Contains(t))) { return(false); } } if (!string.IsNullOrWhiteSpace(SearchName)) { if (!component.Name.Contains(SearchName)) { return(false); } } if (!string.IsNullOrWhiteSpace(User.Value)) { if (!component.MetaData.User.Contains(User.Value)) { return(false); } } if (CompareInt(component.MetaData.Rating, Rating) && CompareInt(component.MetaData.Height, Height) && CompareInt(component.MetaData.Width, Width) && CompareInt(component.MetaData.Mpixels, Mpixels)) { return(Date.Expression switch { Expression.None => true, Expression.Larger => (component.MetaData.CreationTime > Date.Value), Expression.Smaller => (component.MetaData.CreationTime < Date.Value), Expression.Equal => (component.MetaData.CreationTime == Date.Value), Expression.Between => (component.MetaData.CreationTime >= Date.Value && component.MetaData.CreationTime <= Date.Next), _ => throw new ArgumentOutOfRangeException() });
public MainPageViewModel() { _appSettings = ApplicationData.Current.RoamingSettings.Values; var savedUn = _appSettings["Username"] as string; var savedApiKey = _appSettings["APIKey"] as string; if (_appSettings["PerPage"] != null) { _perPage = (int)_appSettings["PerPage"]; } if (_appSettings["SafeChecked"] != null) { _safeChecked = (bool)_appSettings["SafeChecked"]; } if (_appSettings["QuestionableChecked"] != null) { _questionableChecked = (bool)_appSettings["QuestionableChecked"]; } if (_appSettings["ExplicitChecked"] != null) { _explicitChecked = (bool)_appSettings["ExplicitChecked"]; } if (_appSettings["UseLargerImagesForThumbnails"] != null) { _useLargerImagesForThumbnails = (bool)_appSettings["UseLargerImagesForThumbnails"]; } GlobalInfo.ContentCheck[0] = _safeChecked; GlobalInfo.ContentCheck[1] = _questionableChecked; GlobalInfo.ContentCheck[2] = _explicitChecked; if (!string.IsNullOrEmpty(savedUn)) { Debug.WriteLine("username not empty it's " + _appSettings["Username"] + ". APIKey is " + _appSettings["APIKey"]); _username = savedUn; if (!string.IsNullOrEmpty(savedApiKey)) { ApiKey = savedApiKey; BooruApi.SetLogin(savedUn, savedApiKey); } else { ApiKey = ""; BooruApi.SetLogin(savedUn, ""); } } Debug.WriteLine("Count for saved Searches is " + SavedSearches.Count); BooruApi.TagSearchCompletedHandler += (sender, tuple) => { if (tuple.Item1 && _currentTag.Length > 0) { foreach (var tag in tuple.Item2) { _suggestedTags.Add(tag.Name); } RaisePropertyChanged("SuggestedTags"); } }; GlobalInfo.SavedSearchesLoaded += (sender, e) => { if (GlobalInfo.SavedSearches.Count > 0) { foreach (var search in GlobalInfo.SavedSearches) { _savedSearches.Add(new SavedSearchViewModel(search, this)); } RaisePropertyChanged("SavedSearches"); RaisePropertyChanged("DontHaveSavedSearches"); } }; GlobalInfo.FavouriteTagsLoaded += (sender, args) => { if (GlobalInfo.FavouriteTags.Count > 0) { foreach (var tag in GlobalInfo.FavouriteTags) { _favouriteTags.First(x => x.Key == tag.category).Add(new TagViewModel(tag, this)); } foreach (GroupInfoList t1 in _favouriteTags) { var tagList = t1; var result = from t in tagList orderby t.Name select t; tagList = new GroupInfoList(result.ToList()); } RaisePropertyChanged("FavouriteTags"); RaisePropertyChanged("DontHaveSavedSearches"); } }; GlobalInfo.FavouriteImagesLoadedEventHandler += (sender, args) => { RaisePropertyChanged("FavouritePostCount"); }; GlobalInfo.LoadSavedForLaterImages(); _savedForLater = new ObservableCollection <FullImageViewModel>(); GlobalInfo.ImagesSavedForLaterLoaded += (sender, args) => { _savedForLater = new ObservableCollection <FullImageViewModel>(); foreach (var image in GlobalInfo.ImagesSavedForLater) { _savedForLater.Add(new FullImageViewModel(image, image.id, image.Preview_File_Url, image.Large_File_Url, "https://danbooru.donmai.us/posts/" + image.id, null, null)); } RaisePropertyChanged("SavedForLater"); }; _thumbnails = new IncrementalLoadingCollection <PostSource, FullImageViewModel>(_perPage); //BooruApi.Page = 1; foreach (var model in GlobalInfo.ImageViewModels) { _thumbnails.Add(model); } Thumbnails.OnStartLoading = () => { IsLoading = true; NoImagesText = "Loading"; }; Thumbnails.OnEndLoading = ImageOnLoadFinish; Thumbnails.OnError = ImageLoadOnError; BooruApi.UserLookupEvent += (sender, args) => { var tags = BooruApi.UserModel?.blacklisted_tags.Split('\r'); if (tags != null && tags.Length > 0) { foreach (var tag in tags) { if (tag.Trim() != "") { var name = tag.Replace("\n", ""); ExcludedTags.Add(new TagViewModel(new Tag(name.Trim()))); RaisePropertyChanged("ExcludedTags"); } } } }; ImageSaver.ImageFolderLoadedEventHandler += delegate { RaisePropertyChanged("SaveFolder"); }; BooruApi.GetUser(); }