ReportComponentCollection.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using FastReport.Utils;
  6. namespace FastReport
  7. {
  8. /// <summary>
  9. /// Holds the list of objects of <see cref="ReportComponentBase"/> type.
  10. /// </summary>
  11. public class ReportComponentCollection : FRCollectionBase
  12. {
  13. /// <summary>
  14. /// Gets or sets the element at the specified index.
  15. /// </summary>
  16. /// <param name="index">Index of an element.</param>
  17. /// <returns>The element at the specified index.</returns>
  18. public ReportComponentBase this[int index]
  19. {
  20. get { return List[index] as ReportComponentBase; }
  21. set { List[index] = value; }
  22. }
  23. internal ReportComponentCollection SortByTop()
  24. {
  25. ReportComponentCollection result = new ReportComponentCollection();
  26. CopyTo(result);
  27. result.InnerList.Sort(new TopComparer());
  28. return result;
  29. }
  30. /// <summary>
  31. /// Initializes a new instance of the <see cref="ReportComponentCollection"/> class with default settings.
  32. /// </summary>
  33. public ReportComponentCollection() : this(null)
  34. {
  35. }
  36. /// <summary>
  37. /// Initializes a new instance of the <see cref="ReportComponentCollection"/> class with specified owner.
  38. /// </summary>
  39. public ReportComponentCollection(Base owner) : base(owner)
  40. {
  41. }
  42. private class TopComparer : IComparer
  43. {
  44. public int Compare(object x, object y)
  45. {
  46. return (x as ReportComponentBase).Top.CompareTo((y as ReportComponentBase).Top);
  47. }
  48. }
  49. }
  50. }