コード例 #1
0
        public ImageValidationResults ValidateDiscCoverImage(ImageInfo imageInfo)
        {
            ImageValidationResults validationResults = ImageValidationResults.None;

            if (imageInfo.Width < MinWidthAndHeight || imageInfo.Height < MinWidthAndHeight)
            {
                validationResults |= ImageValidationResults.ImageIsTooSmall;
            }

            if (imageInfo.Width > MaxWidthAndHeight || imageInfo.Height > MaxWidthAndHeight)
            {
                validationResults |= ImageValidationResults.ImageIsTooBig;
            }

            if (imageInfo.FileSize > MaxFileSize)
            {
                validationResults |= ImageValidationResults.FileSizeIsTooBig;
            }

            if (SupportedDiscCoverImageFormats.All(supportedFormat => !supportedFormat.ImageFormat.Equals(imageInfo.Format)))
            {
                validationResults |= ImageValidationResults.UnsupportedFormat;
            }

            return(validationResults == ImageValidationResults.None ? ImageValidationResults.ImageIsOk : validationResults);
        }
コード例 #2
0
 public IEnumerable <string> GetValidationResultsHints(ImageValidationResults results)
 {
     foreach (var enumValue in Enum.GetValues(typeof(ImageValidationResults)).Cast <ImageValidationResults>())
     {
         if ((results & enumValue) != 0)
         {
             yield return(enumValue.GetDescription());
         }
     }
 }