aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing.Net/ImageHelpers.cs
blob: 1afc47cd035fbc28153523b6ce6f7665a1d788a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;

namespace Emby.Drawing.Net
{
    internal static class ImageHelpers
    {
        internal static List<string> ProjectPaths(List<string> paths, int count)
        {
            if (count <= 0)
            {
                throw new ArgumentOutOfRangeException("count");
            }
            if (paths.Count == 0)
            {
                throw new ArgumentOutOfRangeException("paths");
            }

            var list = new List<string>();

            AddToList(list, paths, count);

            return list.Take(count).ToList();
        }

        private static void AddToList(List<string> list, List<string> paths, int count)
        {
            while (list.Count < count)
            {
                foreach (var path in paths)
                {
                    list.Add(path);

                    if (list.Count >= count)
                    {
                        return;
                    }
                }
            }
        }
    }
}