SvgPathSegmentList.cs 2.74 KB
Newer Older
davescriven's avatar
davescriven committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;

namespace Svg.Pathing
{
    [TypeConverter(typeof(SvgPathBuilder))]
    public sealed class SvgPathSegmentList : IList<SvgPathSegment>
    {
        internal SvgPath _owner;
        private List<SvgPathSegment> _segments;

        internal SvgPathSegmentList()
        {
            this._segments = new List<SvgPathSegment>();
        }

        public SvgPathSegment Last
        {
            get { return this._segments[this._segments.Count-1]; }
        }

        public int IndexOf(SvgPathSegment item)
        {
            return this._segments.IndexOf(item);
        }

        public void Insert(int index, SvgPathSegment item)
        {
            this._segments.Insert(index, item);
            if (this._owner != null)
            {
                this._owner.OnPathUpdated();
            }
        }

        public void RemoveAt(int index)
        {
            this._segments.RemoveAt(index);
            if (this._owner != null)
            {
                this._owner.OnPathUpdated();
            }
        }

        public SvgPathSegment this[int index]
        {
            get { return this._segments[index]; }
            set { this._segments[index] = value; this._owner.OnPathUpdated(); }
        }

        public void Add(SvgPathSegment item)
        {
            this._segments.Add(item);
            if (this._owner != null)
            {
                this._owner.OnPathUpdated();
            }
        }

        public void Clear()
        {
            this._segments.Clear();
        }

        public bool Contains(SvgPathSegment item)
        {
            return this._segments.Contains(item);
        }

        public void CopyTo(SvgPathSegment[] array, int arrayIndex)
        {
            this._segments.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return this._segments.Count; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool Remove(SvgPathSegment item)
        {
            bool removed = this._segments.Remove(item);

            if (removed)
            {
                if (this._owner != null)
                {
                    this._owner.OnPathUpdated();
                }
            }

            return removed;
        }

        public IEnumerator<SvgPathSegment> GetEnumerator()
        {
            return this._segments.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this._segments.GetEnumerator();
        }
    }
}