SvgPathSegmentList.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.ComponentModel;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. #pragma warning disable
  6. namespace Svg.Pathing
  7. {
  8. [TypeConverter(typeof(SvgPathBuilder))]
  9. public sealed class SvgPathSegmentList : IList<SvgPathSegment>
  10. {
  11. internal SvgPath _owner;
  12. private List<SvgPathSegment> _segments;
  13. public SvgPathSegmentList()
  14. {
  15. this._segments = new List<SvgPathSegment>();
  16. }
  17. public SvgPathSegment Last
  18. {
  19. get { return this._segments[this._segments.Count - 1]; }
  20. }
  21. public int IndexOf(SvgPathSegment item)
  22. {
  23. return this._segments.IndexOf(item);
  24. }
  25. public void Insert(int index, SvgPathSegment item)
  26. {
  27. this._segments.Insert(index, item);
  28. if (this._owner != null)
  29. {
  30. this._owner.OnPathUpdated();
  31. }
  32. }
  33. public void RemoveAt(int index)
  34. {
  35. this._segments.RemoveAt(index);
  36. if (this._owner != null)
  37. {
  38. this._owner.OnPathUpdated();
  39. }
  40. }
  41. public SvgPathSegment this[int index]
  42. {
  43. get { return this._segments[index]; }
  44. set { this._segments[index] = value; this._owner.OnPathUpdated(); }
  45. }
  46. public void Add(SvgPathSegment item)
  47. {
  48. this._segments.Add(item);
  49. if (this._owner != null)
  50. {
  51. this._owner.OnPathUpdated();
  52. }
  53. }
  54. public void Clear()
  55. {
  56. this._segments.Clear();
  57. }
  58. public bool Contains(SvgPathSegment item)
  59. {
  60. return this._segments.Contains(item);
  61. }
  62. public void CopyTo(SvgPathSegment[] array, int arrayIndex)
  63. {
  64. this._segments.CopyTo(array, arrayIndex);
  65. }
  66. public int Count
  67. {
  68. get { return this._segments.Count; }
  69. }
  70. public bool IsReadOnly
  71. {
  72. get { return false; }
  73. }
  74. public bool Remove(SvgPathSegment item)
  75. {
  76. bool removed = this._segments.Remove(item);
  77. if (removed)
  78. {
  79. if (this._owner != null)
  80. {
  81. this._owner.OnPathUpdated();
  82. }
  83. }
  84. return removed;
  85. }
  86. public IEnumerator<SvgPathSegment> GetEnumerator()
  87. {
  88. return this._segments.GetEnumerator();
  89. }
  90. System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
  91. {
  92. return this._segments.GetEnumerator();
  93. }
  94. }
  95. }
  96. #pragma warning restore