-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathStrip.cs
147 lines (123 loc) · 3.08 KB
/
Strip.cs
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using System;
using System.Collections;
using System.Runtime.Serialization;
namespace SpiffCode
{
/// <summary>
/// Summary description for Strip.
/// </summary>
[Serializable]
public class Strip : CollectionBase, ISerializable, IComparable, ICloneable
{
private string m_strName = null;
private int m_ifrActive = 0;
private int m_cfrActive = 1;
private int m_cHold = 0;
public Strip(string strName)
{
m_strName = strName;
}
public object Clone()
{
Strip stpNew = new Strip(m_strName);
for (int i = 0; i < this.Count; i++) {
stpNew.Add((Frame)this[i].Clone());
}
stpNew.m_ifrActive = m_ifrActive;
stpNew.m_cfrActive = m_cfrActive;
stpNew.m_cHold = m_cHold;
return stpNew;
}
// IComparable implementation
public int CompareTo(object ob) {
return m_strName.CompareTo(((Strip)ob).m_strName);
}
// Public properties
public Frame this[int i] {
get {
return (Frame)InnerList[i];
}
set {
// We allow Frames to be added out-of-range in which case
// we expand the range to include the new Frame.
while (i >= InnerList.Count)
InnerList.Add(null);
InnerList[i] = value;
}
}
public string Name {
get {
return m_strName;
}
set {
m_strName = value;
}
}
// Exposed for anyone who wants to keep track of this Strip's ActiveFrame
public event EventHandler ActiveFrameChanged;
public int ActiveFrame {
get {
return m_ifrActive;
}
set {
m_ifrActive = value;
ActiveFrameCount = 1;
if (ActiveFrameChanged != null)
ActiveFrameChanged(this, EventArgs.Empty);
}
}
public event EventHandler ActiveFrameCountChanged;
public int ActiveFrameCount {
get {
return m_cfrActive;
}
set {
m_cfrActive = value;
if (m_ifrActive + m_cfrActive > Count) {
m_cfrActive = Count - m_ifrActive;
}
if (ActiveFrameCountChanged != null)
ActiveFrameCountChanged(this, EventArgs.Empty);
}
}
public int DefHoldCount {
get {
return m_cHold;
}
set {
m_cHold = value;
}
}
public int Add(Frame fr) {
return ((IList)this).Add(fr);
}
public int IndexOf(Frame fr) {
return ((IList)this).IndexOf(fr);
}
public void Insert(int ifr, Frame fr) {
((IList)this).Insert(ifr, fr);
}
// ISerializable interface implementation
private Strip(SerializationInfo seri, StreamingContext stmc) {
m_strName = seri.GetString("Name");
try {
m_cHold = seri.GetInt32("DefHoldCount");
} catch {}
int cfr = seri.GetInt32("FrameCount");
for (int i = 0; i < cfr; i++) {
Frame fr = (Frame)seri.GetValue(i.ToString(), typeof(Frame));
Add(fr);
}
}
void ISerializable.GetObjectData(SerializationInfo seri, StreamingContext stmc) {
seri.AddValue("Name", m_strName);
seri.AddValue("DefHoldCount", m_cHold);
seri.AddValue("FrameCount", InnerList.Count);
int i = 0;
foreach (Frame fr in InnerList) {
seri.AddValue(i.ToString(), fr);
i++;
}
}
}
}