root/plot/Pybrary.Plot/AnnotationCollection.cs

Revision 746, 1.8 kB (checked in by mfenniak, 2 years ago)

--

Line 
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Drawing;
5
6 namespace Pybrary.Plot
7 {
8     public class AnnotationCollection : EventObject, ICollection<Annotation>
9     {
10         private List<Annotation> annotations = new List<Annotation>();
11
12         public AnnotationCollection()
13         {
14         }
15
16         public void Draw(Graphics g, AdvancedRect dataArea)
17         {
18             foreach (Annotation ann in annotations)
19                 ann.Draw(g, dataArea);
20         }
21
22         public int Count
23         {
24             get
25             {
26                 return annotations.Count;
27             }
28         }
29
30         public bool IsReadOnly
31         {
32             get
33             {
34                 return false;
35             }
36         }
37
38         public void Add(Annotation item)
39         {
40             annotations.Add(item);
41             raiseEvent();
42         }
43
44         public void Clear()
45         {
46             annotations.Clear();
47             raiseEvent();
48         }
49
50         public bool Remove(Annotation item)
51         {
52             if (annotations.Remove(item))
53             {
54                 raiseEvent();
55                 return true;
56             }
57
58             return false;
59         }
60
61         public bool Contains(Annotation item)
62         {
63             return annotations.Contains(item);
64         }
65
66         public void CopyTo(Annotation[] arr, int arrIdx)
67         {
68             for (int i = 0; i < annotations.Count; i++)
69                 arr[i + arrIdx] = annotations[i];
70         }
71
72         public IEnumerator<Annotation> GetEnumerator()
73         {
74             return new ListEnumerator<Annotation>(annotations);
75         }
76
77         IEnumerator IEnumerable.GetEnumerator()
78         {
79             return GetEnumerator();
80         }
81     }
82 }
Note: See TracBrowser for help on using the browser.