Esempio n. 1
0
        /// <summary>
        /// Gets a link to the image, as the specified thumbnail size.
        /// </summary>
        /// <param name="imageThumbnailSize">The tnumbnail size you want. Size guide here: (https://api.imgur.com/models/image#thumbs)</param>
        /// <returns>A link to the image, with the specified thumbnail indictorator embedded.</returns>
        public string GetThumbnailLink(ImageThumbnailSize imageThumbnailSize)
        {
            var lastDecimalIndex = Link.LastIndexOf('.');

            if (lastDecimalIndex < 0)
            {
                throw new IndexOutOfRangeException("there was no decimal point in the url. There should be.");
            }

            char thumbnailSize;

            switch (imageThumbnailSize)
            {
            default:
            case ImageThumbnailSize.SmallSquare:
                thumbnailSize = 's';
                break;

            case ImageThumbnailSize.BigSquare:
                thumbnailSize = 'b';
                break;

            case ImageThumbnailSize.SmallThumbnail:
                thumbnailSize = 't';
                break;

            case ImageThumbnailSize.MediumThumbnail:
                thumbnailSize = 'm';
                break;

            case ImageThumbnailSize.LargeThumbnail:
                thumbnailSize = 'l';
                break;

            case ImageThumbnailSize.HugeThumbnail:
                thumbnailSize = 'h';
                break;
            }

            return(Link.Insert(lastDecimalIndex, thumbnailSize.ToString()));
        }
Esempio n. 2
0
        /// <summary>
        /// Gets a link to the image, as the specified thumbnail size.
        /// </summary>
        /// <param name="imageThumbnailSize">The tnumbnail size you want. Size guide here: (https://api.imgur.com/models/image#thumbs)</param>
        /// <returns>A link to the image, with the specified thumbnail indictorator embedded.</returns>
        public string GetThumbnailLink(ImageThumbnailSize imageThumbnailSize)
        {
            var lastDecimalIndex = Link.LastIndexOf('.');
            if (lastDecimalIndex < 0)
                throw new IndexOutOfRangeException("there was no decimal point in the url. There should be.");

            char thumbnailSize;
            switch (imageThumbnailSize)
            {
                default:
                case ImageThumbnailSize.SmallSquare:
                    thumbnailSize = 's';
                    break;
                case ImageThumbnailSize.BigSquare:
                    thumbnailSize = 'b';
                    break;
                case ImageThumbnailSize.SmallThumbnail:
                    thumbnailSize = 't';
                    break;
                case ImageThumbnailSize.MediumThumbnail:
                    thumbnailSize = 'm';
                    break;
                case ImageThumbnailSize.LargeThumbnail:
                    thumbnailSize = 'l';
                    break;
                case ImageThumbnailSize.HugeThumbnail:
                    thumbnailSize = 'h';
                    break;
            }

            return Link.Insert(lastDecimalIndex, thumbnailSize.ToString());
        }