CPF/CPF.ReoGrid/Print/PrintSessionWorksheetCollection.cs

79 lines
1.5 KiB
C#
Raw Normal View History

2024-06-24 10:15:59 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
namespace CPF.ReoGrid.Print
{
internal class PrintSessionWorksheetCollection : ICollection<Worksheet>, IEnumerable<Worksheet>, IEnumerable
{
internal PrintSessionWorksheetCollection(PrintSession session)
{
this.session = session;
}
public void Add(Worksheet worksheet)
{
this.CheckInPrinting();
this.session.worksheets.Add(worksheet);
}
public void Clear()
{
this.CheckInPrinting();
}
public bool Contains(Worksheet worksheet)
{
return this.session.worksheets.Contains(worksheet);
}
public void CopyTo(Worksheet[] array, int arrayIndex)
{
this.session.worksheets.CopyTo(array, arrayIndex);
}
public int Count
{
get
{
return this.session.worksheets.Count;
}
}
public bool IsReadOnly
{
get
{
return this.session.IsPrinting;
}
}
public bool Remove(Worksheet worksheet)
{
this.CheckInPrinting();
return this.session.worksheets.Remove(worksheet);
}
private void CheckInPrinting()
{
bool isPrinting = this.session.IsPrinting;
if (isPrinting)
{
throw new InvalidOperationException("Cannot modify worksheet collection during printing.");
}
}
public IEnumerator<Worksheet> GetEnumerator()
{
return this.session.worksheets.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return this.session.worksheets.GetEnumerator();
}
private PrintSession session;
}
}