using System;
using System.Collections.Generic;
using System.IO;
using System.Drawing;


namespace FunctionalSubstructure
{
    
    /// <summary>
    /// Class representing a folder that contains images.
    /// </summary>
    public class ImageFolder
    {
        
        private List<ImageFile> imageFiles;
        private int imageCount;


        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="folder">The folder containing images.</param>
        public ImageFolder(string folder)
        {
            imageFiles = new List<ImageFile>();
            CreateImagesList(folder);
            imageCount = imageFiles.Count;
        }


        /// <summary>
        /// Creates the list of image files.
        /// </summary>
        /// <param name="folder">The folder where the images reside</param>
        private void CreateImagesList(string folder)
        {
            DirectoryInfo di = new DirectoryInfo(folder);
            FileInfo[] filesInformation = di.GetFiles("*", SearchOption.TopDirectoryOnly);

            foreach (FileInfo fi in filesInformation)
                switch (fi.Extension.ToLower())
                {
                    case ".bmp":
                    case ".jpg":
                    case ".jpe":
                    case ".jpeg":
                    case ".gif":
                    case ".tif":
                    case ".tiff":
                    case ".png":
                        imageFiles.Add(new ImageFile(fi.FullName));
                        break;
                }
        }


        /// <summary>
        /// Returns the number of images in the folder.
        /// </summary>
        public int ImagesCount
        {
            get { return imageCount; }
        }


        /// <summary>
        /// Returns the images list of the folder.
        /// </summary>
        public List<ImageFile> ImagesList
        {
            get
            {
                return imageFiles;
            }
        }

    }

}

