-
-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathTimingFunction.cs
More file actions
70 lines (67 loc) · 2.02 KB
/
Copy pathTimingFunction.cs
File metadata and controls
70 lines (67 loc) · 2.02 KB
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;
namespace libmsstyle
{
//[Serializable]
public class TimingFunction
{
public TimingFunctionType Type { get; set; }
[TypeConverter(typeof(ExpandableObjectConverter))]
public CubicBezierTimingFunction CubicBezier { get; set; }
public PropertyHeader Header;
public TimingFunction(byte[] data, int start, PropertyHeader header)
{
this.Header = header;
Type = (TimingFunctionType)BitConverter.ToInt32(data, start + 0);
start += 4;
if (Type == TimingFunctionType.CubicBezier)
{
//Cubic Bezier function
CubicBezier = new CubicBezierTimingFunction(data, start);
}
else
{
throw new Exception("Unknown timing function type: " + Type);
}
}
public TimingFunction(PropertyHeader header, int partid)
{
CubicBezier = new CubicBezierTimingFunction();
Header = header;
Header.partID = partid;
}
public void Write(BinaryWriter bw)
{
if (Type == TimingFunctionType.Undefined)
Header.sizeInBytes = 4;
else if (Type == TimingFunctionType.CubicBezier)
Header.sizeInBytes = 4 + 16;
bw.Write(Header.Serialize());
WriteData(bw);
}
public void WriteData(BinaryWriter w)
{
w.Write((int)Type);
if (Type == TimingFunctionType.CubicBezier)
{
CubicBezier.Write(w);
}
w.Write(0); //Write padding
}
public override string ToString()
{
return "Timing function";
}
}
public enum TimingFunctionType : uint
{
Undefined = 0,
CubicBezier = 1,
}
}