2 // Moonlight List (moonlight-list@lists.ximian.com)
4 // Copyright 2007 Novell, Inc.
6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the
8 // "Software"), to deal in the Software without restriction, including
9 // without limitation the rights to use, copy, modify, merge, publish,
10 // distribute, sublicense, and/or sell copies of the Software, and to
11 // permit persons to whom the Software is furnished to do so, subject to
12 // the following conditions:
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 using System
.Windows
.Media
;
29 using System
.Windows
.Input
;
30 using System
.Runtime
.InteropServices
;
33 namespace System
.Windows
.Media
.Animation
{
34 public struct KeyTime
{
35 internal KeyTimeType type
;
37 internal double percent
;
38 internal TimeSpan time_span
;
40 internal KeyTime (KeyTimeType type
, double percent
, TimeSpan time_span
)
43 this.percent
= percent
;
44 this.time_span
= time_span
;
48 public static KeyTime
FromTimeSpan(TimeSpan timeSpan
)
50 return new KeyTime (KeyTimeType
.TimeSpan
, 0, timeSpan
);
53 public static bool Equals (KeyTime keyTime1
, KeyTime keyTime2
)
55 return keyTime1
== keyTime2
;
58 public static bool operator ==(KeyTime keyTime1
, KeyTime keyTime2
)
60 if (keyTime1
.type
!= keyTime2
.type
)
63 switch (keyTime1
.type
) {
64 case KeyTimeType
.TimeSpan
:
65 return keyTime1
.time_span
== keyTime2
.time_span
;
70 public static bool operator !=(KeyTime keyTime1
, KeyTime keyTime2
)
72 return !(keyTime1
== keyTime2
);
75 public bool Equals(KeyTime
value)
80 public override bool Equals(object value)
83 return this == (KeyTime
) value;
88 public override int GetHashCode()
91 case KeyTimeType
.TimeSpan
:
92 return time_span
.GetHashCode ();
94 return base.GetHashCode ();
98 public override string ToString ()
101 case KeyTimeType
.TimeSpan
:
102 return time_span
.ToString ();
103 case KeyTimeType
.Uniform
:
110 public static implicit operator KeyTime (TimeSpan timeSpan
)
112 return KeyTime
.FromTimeSpan (timeSpan
);
115 public TimeSpan TimeSpan
{
116 get { return time_span; }
119 public KeyTimeType Type
{
123 public static KeyTime Uniform
{
125 KeyTime result
= new KeyTime ();
126 result
.type
= KeyTimeType
.Uniform
;