using System; using System.Collections; using System.Collections.Generic; using System.Linq; using CPF.ReoGrid.Main; namespace CPF.ReoGrid { public class WorksheetCollection : IList, ICollection, IEnumerable, IEnumerable { internal WorksheetCollection(Workbook workbook) { this.adapter = workbook.controlAdapter; this.workbook = workbook; } public Worksheet Create(string name = null) { return this.workbook.CreateWorksheet(name); } public void Add(Worksheet sheet) { this.workbook.InsertWorksheet(this.workbook.worksheets.Count, sheet); } public void Insert(int index, Worksheet sheet) { this.workbook.InsertWorksheet(index, sheet); } public void Clear() { this.workbook.ClearWorksheets(); } public bool Contains(Worksheet sheet) { return this.workbook.worksheets.Contains(sheet); } public int Count { get { return this.workbook.worksheets.Count; } } public bool IsReadOnly { get { return this.workbook.Readonly; } } public bool Remove(Worksheet sheet) { return this.workbook.RemoveWorksheet(sheet); } public IEnumerator GetEnumerator() { return this.workbook.worksheets.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return this.workbook.worksheets.GetEnumerator(); } public Worksheet this[int index] { get { bool flag = index < 0 || index >= this.workbook.worksheets.Count; if (flag) { throw new ArgumentOutOfRangeException("index"); } return this.workbook.worksheets[index]; } set { bool flag = index < 0 || index >= this.workbook.worksheets.Count; if (flag) { throw new ArgumentOutOfRangeException("index"); } this.workbook.worksheets[index] = value; } } public Worksheet this[string name] { get { return this.workbook.worksheets.FirstOrDefault((Worksheet s) => string.Compare(s.Name, name, true) == 0); } } public int IndexOf(Worksheet sheet) { return this.workbook.GetWorksheetIndex(sheet); } public void RemoveAt(int index) { this.workbook.RemoveWorksheet(index); } public void CopyTo(Worksheet[] array, int arrayIndex) { this.workbook.worksheets.CopyTo(array, arrayIndex); } private IControlAdapter adapter; private Workbook workbook; } }