CPF/CPF.ReoGrid/Outline/OutlineCollectionProperty.cs

59 lines
1.2 KiB
C#
Raw Permalink Normal View History

2024-06-24 10:15:59 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
namespace CPF.ReoGrid.Outline
{
public class OutlineCollectionProperty<T> : IEnumerable<T>, IEnumerable where T : ReoGridOutline
{
internal OutlineCollectionProperty(Worksheet worksheet, RowOrColumn rowOrColumn)
{
this.worksheet = worksheet;
this.rowOrColumn = rowOrColumn;
}
public T AddOutline(int start, int count)
{
return (T)((object)this.worksheet.AddOutline(this.rowOrColumn, start, count));
}
public T RemoveOutline(int start, int count)
{
return (T)((object)this.worksheet.RemoveOutline(this.rowOrColumn, start, count));
}
public T this[int start, int count]
{
get
{
return (T)((object)this.worksheet.GetOutline(this.rowOrColumn, start, count));
}
}
private IEnumerator<T> GetEnum()
{
foreach (OutlineGroup<ReoGridOutline> og in this.worksheet.GetOutlines(this.rowOrColumn))
{
foreach (ReoGridOutline o in og)
{
yield return (T)((object)o);
}
}
}
public IEnumerator<T> GetEnumerator()
{
return this.GetEnum();
}
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnum();
}
private Worksheet worksheet;
private RowOrColumn rowOrColumn;
}
}