51 lines
1.2 KiB
C#
51 lines
1.2 KiB
C#
![]() |
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace CPF.ReoGrid
|
|||
|
{
|
|||
|
public class AutoFillSequence
|
|||
|
{
|
|||
|
public AutoFillSequence(IList<object> values)
|
|||
|
{
|
|||
|
bool flag = values == null || values.Count == 0;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
throw new ArgumentException("AutoFillSequence requires at least one value.");
|
|||
|
}
|
|||
|
int i = 0;
|
|||
|
IAutoFillSectionEntry entry = AutoFillSectionEntryFactory.Create(values[i++]);
|
|||
|
AutoFillSection autoFillSection = new AutoFillSection(entry);
|
|||
|
this.sections.Add(autoFillSection);
|
|||
|
while (i < values.Count)
|
|||
|
{
|
|||
|
entry = AutoFillSectionEntryFactory.Create(values[i++]);
|
|||
|
bool flag2 = !autoFillSection.TryAdd(entry);
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
autoFillSection = new AutoFillSection(entry);
|
|||
|
this.sections.Add(autoFillSection);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public object[] Extrapolate(int count)
|
|||
|
{
|
|||
|
List<object> list = new List<object>(count);
|
|||
|
int num = 0;
|
|||
|
while (list.Count < count)
|
|||
|
{
|
|||
|
num++;
|
|||
|
foreach (AutoFillSection autoFillSection in this.sections)
|
|||
|
{
|
|||
|
object[] values = autoFillSection.GetValues(num);
|
|||
|
list.AddRange(values.Take(count - list.Count));
|
|||
|
}
|
|||
|
}
|
|||
|
return list.ToArray();
|
|||
|
}
|
|||
|
|
|||
|
private readonly List<AutoFillSection> sections = new List<AutoFillSection>();
|
|||
|
}
|
|||
|
}
|