public ResolutionViewModel(Resolution r) {
     _resolution = r;
 }
Пример #2
0
        // this resolution handling is a little strange since wallhaven actually seems to support searching for any resolution (in the url)
        // but their UI only allows for selecting from a specific set.
        // this code also conforms to that specific set.
        // an alternative would be to just search using no specific resolutions every time and scrape the entire results set to find the resolutions we want
        // this would allow us to find resolutions that aren't in the supported list, but would be more of a pain and is less likely to return desirable results quickly
        // (e.g. if there are no images on the first page with the resolution you want, you have to load the next page and check that, etc.
        // if there are no images at all with the resolution you want, you have to scrape the entire results set before you find out)
        string ResolutionToSearchString(Resolution resolution) {
            if (resolution.ResolutionType == ResolutionType.Exactly) {
                return string.Join(",", resolution.Resolutions.Where(r => SupportedResolutions.Contains(r)).Select(r => r.ToString()));
            }

            return string.Join(",", SupportedResolutions.Where(r => {
                return (resolution.ResolutionType == ResolutionType.AtLeast && r.X >= resolution.Width && r.Y >= resolution.Height) ||
                       (resolution.ResolutionType == ResolutionType.AtMost && r.X <= resolution.Width && r.Y <= resolution.Height);
            }).Select(r => r.ToString()));
        }