Author: toshok
Date: 2007-12-09 17:43:18 -0500 (Sun, 09 Dec 2007)
New Revision: 91017

Added:
   trunk/olive/class/PresentationCore/tools/
   trunk/olive/class/PresentationCore/tools/gen-animation-types.cs
Removed:
   
trunk/olive/class/PresentationCore/System.Windows.Media.Animation/gen-animation-types.cs
Modified:
   trunk/olive/class/PresentationCore/System.Windows.Media.Animation/
Log:
move gen-animation-types.cs from System.Windows.Media.Animation/ to tools/.  
It's meant to be run from the olive/class/PresentationCore, and it now outputs 
both the classes and unit tests.


Property changes on: 
trunk/olive/class/PresentationCore/System.Windows.Media.Animation
___________________________________________________________________
Name: svn:ignore
   - gen-animation-types.exe

   + 


Deleted: 
trunk/olive/class/PresentationCore/System.Windows.Media.Animation/gen-animation-types.cs
===================================================================
--- 
trunk/olive/class/PresentationCore/System.Windows.Media.Animation/gen-animation-types.cs
    2007-12-09 22:42:01 UTC (rev 91016)
+++ 
trunk/olive/class/PresentationCore/System.Windows.Media.Animation/gen-animation-types.cs
    2007-12-09 22:43:18 UTC (rev 91017)
@@ -1,795 +0,0 @@
-using System;
-using System.IO;
-
-public class GenAnimationTypes {
-
-       enum AnimatableType {
-               Boolean,
-               Byte,
-               Char,
-               Color,
-               Decimal,
-               Double,
-               Int16,
-               Int32,
-               Int64,
-               Matrix,
-               Object,
-               //Point3D,
-               Point,
-               //Quaternion,
-               Rect,
-               //Rotation3D,
-               Single,
-               Size,
-               String,
-               //Vector3D,
-               Vector
-       };
-
-       enum AnimationClassType {
-               /*Int32*/Animation,
-               /*Int32*/AnimationBase,
-               /*Int32*/AnimationUsingKeyFrames,
-               /*Int32*/KeyFrame,
-               /*Int32*/KeyFrameCollection
-       };
-
-       enum KeyFrameType {
-               Discrete/*Int32KeyFrame*/,
-               Linear/*Int32KeyFrame*/,
-               Spline/*Int32KeyFrame*/
-       };
-
-       static bool istypecontinuous (AnimatableType t)
-       {
-               switch (t) {
-               case AnimatableType.Boolean:
-               case AnimatableType.Char:
-               case AnimatableType.Object:
-               case AnimatableType.String:
-               case AnimatableType.Matrix:
-                       return false;
-
-               case AnimatableType.Color:
-               //case AnimatableType.Point3D:
-               //case AnimatableType.Quaternion:
-               //case AnimatableType.Rotation3D:
-               //case AnimatableType.Vector3D:
-
-               default:
-                       return true;
-               }
-       }
-
-       static string gettype (AnimatableType t)
-       {
-               switch (t) {
-               case AnimatableType.Boolean: return "bool";
-               case AnimatableType.Byte: return "byte";
-               case AnimatableType.Char: return "char";
-               case AnimatableType.Object: return "object";
-               case AnimatableType.Single: return "float";
-               case AnimatableType.Double: return "double";
-               case AnimatableType.Int16: return "short";
-               case AnimatableType.Int32: return "int";
-               case AnimatableType.Int64: return "long";
-               case AnimatableType.Decimal:
-               case AnimatableType.Color:
-               case AnimatableType.Matrix:
-                       //case AnimatableType.Point3D:
-               case AnimatableType.Point:
-                       //case AnimatableType.Quaternion:
-               case AnimatableType.Rect:
-                       //case AnimatableType.Rotation3D:
-               case AnimatableType.Size:
-               case AnimatableType.String:
-                       //case AnimatableType.Vector3D:
-               case AnimatableType.Vector:
-                       return t.ToString();
-               }
-
-               return null;
-       }
-
-       string generateLerp (string from, string to, string progress)
-       {
-               switch (type) {
-               case AnimatableType.Byte:
-               case AnimatableType.Int16:
-               case AnimatableType.Int32:
-               case AnimatableType.Int64:
-               case AnimatableType.Single:
-               case AnimatableType.Double:
-                       return String.Format ("return ({0})({1} + ({2} - {1}) * 
{3})", gettype(type), from, to, progress);
-
-               case AnimatableType.Decimal:
-                       return String.Format ("return ({0})((double){1} + 
((double){2} - (double){1}) * {3})", gettype(type), from, to, progress);
-
-               case AnimatableType.Point:
-               case AnimatableType.Vector:
-                       return String.Format ("return new {3} ({0}.X + ({1}.X - 
{0}.X) * {2}, {0}.Y + ({1}.Y - {0}.Y) * {2});", from, to, progress, type);
-               case AnimatableType.Rect:
-                       return String.Format ("return new Rect ({0}.X + ({1}.X 
- {0}.X) * {2}, {0}.Y + ({1}.Y - {0}.Y) * {2}, {0}.Width + ({1}.Width - 
{0}.Width) * {2}, {0}.Height + ({1}.Height - {0}.Height) * {2})", from, to, 
progress);
-
-               case AnimatableType.Size:
-                       return String.Format ("return new Size ({0}.Width + 
({1}.Width - {0}.Width) * {2}, {0}.Height + ({1}.Height - {0}.Height) * {2})", 
from, to, progress);
-
-               case AnimatableType.Color:
-                       return String.Format ("return Color.FromScRgb 
((float)({0}.ScA + ({1}.ScA - {0}.ScA) * {2}), (float)({0}.ScR + ({1}.ScR - 
{0}.ScR) * {2}), (float)({0}.ScG + ({1}.ScG - {0}.ScG) * {2}), (float)({0}.ScB 
+ ({1}.ScB - {0}.ScB) * {2}))", from, to, progress);
-
-               default:
-                       return "XXX";
-               }
-       }
-
-       AnimatableType type;
-
-       GenAnimationTypes (AnimatableType type)
-       {
-               this.type = type;
-       }
-
-       void OutputAnimationBase (TextWriter tw)
-       {
-               tw.WriteLine (@"
-public abstract class {0}AnimationBase : AnimationTimeline
-{{
-       protected {0}AnimationBase () {{ }}
-
-       public override sealed Type TargetPropertyType {{ get {{ return typeof 
({1}); }} }}
-
-       public new {0}AnimationBase Clone ()
-       {{
-               throw new NotImplementedException ();
-       }} 
-
-       public override sealed object GetCurrentValue (object 
defaultOriginValue, object defaultDestinationValue, AnimationClock 
animationClock)
-       {{
-               return GetCurrentValue (({1})defaultOriginValue, ({1}) 
defaultDestinationValue, animationClock);
-       }}
-
-       protected abstract {1} GetCurrentValueCore ({1} defaultOriginValue, {1} 
defaultDestinationValue, AnimationClock animationClock);
-", type, gettype(type));
-
-               if (type != AnimatableType.Object) {
-                       tw.WriteLine (@"
-       public {1} GetCurrentValue ({1} defaultOriginValue, {1} 
defaultDestinationValue, AnimationClock animationClock)
-       {{
-               throw new NotImplementedException ();
-       }}
-", type, gettype(type));
-               }
-
-               tw.WriteLine ("\n}\n");
-       }
-
-
-       void OutputHeader (TextWriter tw)
-       {
-               tw.WriteLine (@"
-/* this file is generated by gen-animation-types.cs.  do not modify */
-
-using System;
-using System.Collections;
-using System.ComponentModel;
-using System.Reflection;
-using System.Windows;
-using System.Windows.Media;
-using System.Windows.Markup;
-
-namespace System.Windows.Media.Animation {
-");
-       }
-
-       void OutputAnimation (TextWriter tw)
-       {
-               tw.WriteLine (@"
-public class {0}Animation : {0}AnimationBase
-{{
-       public static readonly DependencyProperty ByProperty
-                               = DependencyProperty.Register (""By"", typeof 
({1}), typeof ({0}KeyFrame));
-       public static readonly DependencyProperty FromProperty
-                               = DependencyProperty.Register (""From"", typeof 
({1}), typeof ({0}KeyFrame));
-       public static readonly DependencyProperty ToProperty
-                               = DependencyProperty.Register (""To"", typeof 
({1}), typeof ({0}KeyFrame));
-
-       public {0}Animation ()
-       {{
-       }}
-
-       public {0}Animation ({1} toValue, Duration duration)
-       {{
-       }}
-
-       public {0}Animation ({1} toValue, Duration duration, FillBehavior 
fillBehavior)
-       {{
-       }}
-
-       public {0}Animation ({1} fromValue, {1} toValue, Duration duration)
-       {{
-       }}
-
-       public {0}Animation ({1} fromValue, {1} tovalue, Duration duration, 
FillBehavior fillBehavior)
-       {{
-       }}
-
-       public {1}? By {{
-               get {{ return ({1}?) GetValue (ByProperty); }}
-               set {{ SetValue (ByProperty, value); }}
-       }}
-
-       public {1}? From {{
-               get {{ return ({1}?) GetValue (FromProperty); }}
-               set {{ SetValue (FromProperty, value); }}
-       }}
-
-       public {1}? To {{
-               get {{ return ({1}?) GetValue (ToProperty); }}
-               set {{ SetValue (ToProperty, value); }}
-       }}
-
-       public bool IsAdditive {{
-               get {{ return (bool) GetValue 
(AnimationTimeline.IsAdditiveProperty); }}
-               set {{ SetValue (AnimationTimeline.IsAdditiveProperty, value); 
}}
-       }}
-
-       public bool IsCumulative {{
-               get {{ return (bool) GetValue 
(AnimationTimeline.IsCumulativeProperty); }}
-               set {{ SetValue (AnimationTimeline.IsCumulativeProperty, 
value); }}
-       }}
-
-       public new {0}Animation Clone ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override Freezable CreateInstanceCore ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override {1} GetCurrentValueCore ({1} defaultOriginValue, {1} 
defaultDestinationValue, AnimationClock animationClock)
-       {{
-               throw new NotImplementedException ();
-       }}
-}}
-", type, gettype(type));
-       }
-
-       void OutputAnimationUsingKeyFrames (TextWriter tw)
-       {
-               tw.WriteLine (@"
-[ContentProperty (""KeyFrames"")]
-public class {0}AnimationUsingKeyFrames : {0}AnimationBase, 
IKeyFrameAnimation, IAddChild
-{{
-       public {0}AnimationUsingKeyFrames ()
-       {{
-       }}
-
-       public {0}KeyFrameCollection KeyFrames {{
-               get {{ throw new NotImplementedException (); }}
-               set {{ throw new NotImplementedException (); }}
-       }}
-
-       IList IKeyFrameAnimation.KeyFrames {{
-               get {{ return (IList)KeyFrames; }}
-               set {{ KeyFrames = ({0}KeyFrameCollection)value; }}
-       }}
-
-       [EditorBrowsable(EditorBrowsableState.Advanced)]
-       protected virtual void AddChild (object child)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       void IAddChild.AddChild (object child)
-       {{
-               AddChild (child);
-       }}
-
-       [EditorBrowsable(EditorBrowsableState.Advanced)]
-       protected virtual void AddText (string childText)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       void IAddChild.AddText (string childText)
-       {{
-               AddText (childText);
-       }}
-
-       public new {0}AnimationUsingKeyFrames Clone ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void CloneCore (Freezable sourceFreezable)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       public new {0}AnimationUsingKeyFrames CloneCurrentValue ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void CloneCurrentValueCore (Freezable 
sourceFreezable)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override Freezable CreateInstanceCore ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override bool FreezeCore (bool isChecking)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void GetAsFrozenCore (Freezable source)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void GetCurrentValueAsFrozenCore (Freezable source)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override sealed {1} GetCurrentValueCore ({1} 
defaultOriginValue, {1} defaultDestinationValue, AnimationClock animationClock)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override sealed Duration GetNaturalDurationCore (Clock clock)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void OnChanged ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       [EditorBrowsable(EditorBrowsableState.Never)]
-       public bool ShouldSerializeKeyFrames()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-", type, gettype(type));
-
-               if (istypecontinuous (type)) {
-                       tw.WriteLine (@"
-       public bool IsAdditive {{
-               get {{ return (bool) GetValue 
(AnimationTimeline.IsAdditiveProperty); }}
-               set {{ SetValue (AnimationTimeline.IsAdditiveProperty, value); 
}}
-       }}
-
-       public bool IsCumulative {{
-               get {{ return (bool) GetValue 
(AnimationTimeline.IsCumulativeProperty); }}
-               set {{ SetValue (AnimationTimeline.IsCumulativeProperty, 
value); }}
-       }}
-", type, gettype(type));
-               }
-
-               tw.WriteLine ("\n}\n");
-       }
-
-       void OutputKeyFrame (TextWriter tw)
-       {
-               tw.WriteLine (@"
-public abstract class {0}KeyFrame : Freezable, IKeyFrame
-{{
-       public static readonly DependencyProperty KeyTimeProperty
-                               = DependencyProperty.Register (""KeyTime"", 
typeof (KeyTime), typeof ({0}KeyFrame));
-
-       public static readonly DependencyProperty ValueProperty
-                               = DependencyProperty.Register (""Value"", 
typeof ({1}), typeof ({0}KeyFrame));
-
-       protected {0}KeyFrame ()
-       {{
-       }}
-
-       protected {0}KeyFrame ({1} value)
-       {{
-       }}
-
-       protected {0}KeyFrame ({1} value, KeyTime keyTime)
-       {{
-       }}
-
-       public KeyTime KeyTime {{
-               get {{ return (KeyTime)GetValue (KeyTimeProperty); }}
-               set {{ SetValue (KeyTimeProperty, value); }}
-       }}
-
-       public {1} Value {{
-               get {{ return ({1})GetValue (ValueProperty); }}
-               set {{ SetValue (ValueProperty, value); }}
-       }}
-
-       object IKeyFrame.Value {{
-               get {{ return Value; }}
-               set {{ Value = ({1})value; }}
-       }}
-
-       public {1} InterpolateValue ({1} baseValue, double keyFrameProgress)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected abstract {1} InterpolateValueCore ({1} baseValue, double 
keyFrameProgress);
-}}
-", type, gettype(type));
-       }
-
-       void OutputFooter (TextWriter tw)
-       {
-               tw.WriteLine ("\n}"); /* close the namespace */
-       }
-
-       void OutputKeyFrameCollection (TextWriter tw)
-       {
-               tw.WriteLine (@"
-public class {0}KeyFrameCollection : Freezable, IList, ICollection, IEnumerable
-{{
-       public {0}KeyFrameCollection ()
-       {{
-       }}
-
-       public int Count {{
-               get {{ throw new NotImplementedException (); }}
-       }}
-
-       public static {0}KeyFrameCollection Empty {{
-               get {{ throw new NotImplementedException (); }}
-       }}
-
-       public bool IsFixedSize {{
-               get {{ throw new NotImplementedException (); }}
-       }}
-
-       public bool IsReadOnly {{
-               get {{ throw new NotImplementedException (); }}
-       }}
-
-       public bool IsSynchronized {{
-               get {{ throw new NotImplementedException (); }}
-       }}
-
-       public object SyncRoot {{
-               get {{ throw new NotImplementedException (); }}
-       }}
-
-       public {0}KeyFrame this[int index] {{
-               get {{ throw new NotImplementedException (); }}
-               set {{ throw new NotImplementedException (); }}
-       }}
-
-       object IList.this[int index] {{
-               get {{ return this[index]; }}
-               set {{ this[index] = ({0}KeyFrame)value; }}
-       }}
-
-       public int Add ({0}KeyFrame keyFrame)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       int IList.Add (object value)
-       {{
-               return Add (({0}KeyFrame) value);
-       }}
-
-       public void Clear ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       public new {0}KeyFrameCollection Clone ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void CloneCore (Freezable sourceFreezable)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void CloneCurrentValueCore (Freezable 
sourceFreezable)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       public bool Contains ({0}KeyFrame keyFrame)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       bool IList.Contains (object value)
-       {{
-               return Contains (({0}KeyFrame)value);
-       }}
-
-       public void CopyTo ({0}KeyFrame[] array, int index)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       void ICollection.CopyTo (Array array, int index)
-       {{
-               CopyTo (({0}KeyFrame[])array, index);
-       }}
-
-       protected override Freezable CreateInstanceCore ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override bool FreezeCore (bool isChecking)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void GetAsFrozenCore (Freezable sourceFreezable)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override void GetCurrentValueAsFrozenCore (Freezable 
sourceFreezable)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       public IEnumerator GetEnumerator()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       public int IndexOf ({0}KeyFrame keyFrame)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       int IList.IndexOf (object value)
-       {{
-               return IndexOf (({0}KeyFrame) value);
-       }}
-
-       public void Insert (int index, {0}KeyFrame keyFrame)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       void IList.Insert (int index, object value)
-       {{
-               Insert (index, ({0}KeyFrame)value);
-       }}
-
-       public void Remove ({0}KeyFrame keyFrame)
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       void IList.Remove (object value)
-       {{
-               Remove (({0}KeyFrame) value);
-       }}
-
-       public void RemoveAt (int index)
-       {{
-               throw new NotImplementedException ();
-       }}
-}}
-", type, gettype(type));
-       }
-
-       void OutputBaseClassFile (AnimationClassType ac)
-       {
-               if (ac == AnimationClassType.Animation
-                   && !istypecontinuous (type))
-                       return;
-
-               string filename = String.Format ("{0}{1}.cs", type, ac);
-               Console.WriteLine ("outputting {0}", filename);
-
-               TextWriter tw = File.CreateText (filename);
-               OutputHeader (tw);
-               switch (ac) {
-               case AnimationClassType.Animation:
-                       OutputAnimation (tw);
-                       break;
-               case AnimationClassType.AnimationBase:
-                       OutputAnimationBase (tw);
-                       break;
-               case AnimationClassType.AnimationUsingKeyFrames:
-                       OutputAnimationUsingKeyFrames (tw);
-                       break;
-               case AnimationClassType.KeyFrame:
-                       OutputKeyFrame (tw);
-                       break;
-               case AnimationClassType.KeyFrameCollection:
-                       OutputKeyFrameCollection (tw);
-                       break;
-               }
-               OutputFooter (tw);
-               tw.Close ();
-       }
-
-       void OutputDiscreteKeyFrame (TextWriter tw)
-       {
-               tw.WriteLine (@"
-public class Discrete{0}KeyFrame : {0}KeyFrame
-{{
-       {1} value;
-       KeyTime keyTime;
-
-       public Discrete{0}KeyFrame ()
-       {{
-       }}
-
-       public Discrete{0}KeyFrame ({1} value)
-       {{
-               this.value = value;
-               // XXX keytime?
-       }}
-
-       public Discrete{0}KeyFrame ({1} value, KeyTime keyTime)
-       {{
-               this.value = value;
-               this.keyTime = keyTime;
-       }}
-
-       protected override Freezable CreateInstanceCore ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override {1} InterpolateValueCore ({1} baseValue, double 
keyFrameProgress)
-       {{
-               return keyFrameProgress == 1.0 ? value : baseValue;
-       }}
-}}
-", type, gettype(type));
-       }
-
-       void OutputLinearKeyFrame (TextWriter tw)
-       {
-               tw.WriteLine (@"
-public class Linear{0}KeyFrame : {0}KeyFrame
-{{
-       {1} value;
-       KeyTime keyTime;
-
-       public Linear{0}KeyFrame ()
-       {{
-       }}
-
-       public Linear{0}KeyFrame ({1} value)
-       {{
-               this.value = value;
-               // XXX keytime?
-       }}
-
-       public Linear{0}KeyFrame ({1} value, KeyTime keyTime)
-       {{
-               this.value = value;
-               this.keyTime = keyTime;
-       }}
-
-       protected override Freezable CreateInstanceCore ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override {1} InterpolateValueCore ({1} baseValue, double 
keyFrameProgress)
-       {{
-               // standard linear interpolation
-               {2};
-       }}
-}}
-", type, gettype(type), generateLerp ("baseValue", "value", 
"keyFrameProgress"));
-       }
-
-       void OutputSplineKeyFrame (TextWriter tw)
-       {
-               tw.WriteLine (@"
-public class Spline{0}KeyFrame : {0}KeyFrame
-{{
-
-       public static readonly DependencyProperty KeySplineProperty =
-               DependencyProperty.Register (""KeySpline"", typeof (KeySpline), 
typeof (Spline{0}KeyFrame));
-
-       {1} value;
-       KeyTime keyTime;
-
-       public Spline{0}KeyFrame ()
-       {{
-       }}
-
-       public Spline{0}KeyFrame ({1} value)
-       {{
-               this.value = value;
-               // XX keytime?
-       }}
-
-       public Spline{0}KeyFrame ({1} value, KeyTime keyTime)
-       {{
-               this.value = value;
-               this.keyTime = keyTime;
-       }}
-
-       public Spline{0}KeyFrame ({1} value, KeyTime keyTime, KeySpline 
keySpline)
-       {{
-               this.value = value;
-               this.keyTime = keyTime;
-               KeySpline = keySpline;
-       }}
-
-       public KeySpline KeySpline {{
-               get {{ return (KeySpline)GetValue (KeySplineProperty); }}
-               set {{ SetValue (KeySplineProperty, value); }}
-       }}
-
-       protected override Freezable CreateInstanceCore ()
-       {{
-               throw new NotImplementedException ();
-       }}
-
-       protected override {1} InterpolateValueCore ({1} baseValue, double 
keyFrameProgress)
-       {{
-               double splineProgress = KeySpline.GetSplineProgress 
(keyFrameProgress);
-
-               {2};
-       }}
-}}
-", type, gettype(type), generateLerp ("baseValue", "value", "splineProgress"));
-       }
-
-       void OutputKeyFrameFile (KeyFrameType kt)
-       {
-               if (!istypecontinuous (type) &&
-                   (kt == KeyFrameType.Linear || kt == KeyFrameType.Spline))
-                       return;
-
-               string filename = String.Format ("{0}{1}KeyFrame.cs", kt, type);
-               Console.WriteLine ("outputting {0}", filename);
-
-               TextWriter tw = File.CreateText (filename);
-               OutputHeader (tw);
-
-               switch (kt) {
-               case KeyFrameType.Discrete:
-                       OutputDiscreteKeyFrame (tw);
-                       break;
-               case KeyFrameType.Linear:
-                       OutputLinearKeyFrame (tw);
-                       break;
-               case KeyFrameType.Spline:
-                       OutputSplineKeyFrame (tw);
-                       break;
-               }
-
-               OutputFooter (tw);
-               tw.Close ();
-       }
-
-       public static void Main (string[] args)
-       {
-               foreach (AnimatableType at in Enum.GetValues(typeof 
(AnimatableType))) {
-                       GenAnimationTypes ga = new GenAnimationTypes(at);
-
-                       /* output the base class types */
-                       foreach (AnimationClassType ac in Enum.GetValues 
(typeof (AnimationClassType)))
-                               ga.OutputBaseClassFile (ac);
-
-                       /* output the keyframe types */
-                       foreach (KeyFrameType kt in Enum.GetValues (typeof 
(KeyFrameType)))
-                               ga.OutputKeyFrameFile (kt);
-               }
-       }
-}


Property changes on: trunk/olive/class/PresentationCore/tools
___________________________________________________________________
Name: svn:ignore
   + gen-animation-types.exe


Copied: trunk/olive/class/PresentationCore/tools/gen-animation-types.cs (from 
rev 91014, 
trunk/olive/class/PresentationCore/System.Windows.Media.Animation/gen-animation-types.cs)
===================================================================
--- 
trunk/olive/class/PresentationCore/System.Windows.Media.Animation/gen-animation-types.cs
    2007-12-09 22:04:22 UTC (rev 91014)
+++ trunk/olive/class/PresentationCore/tools/gen-animation-types.cs     
2007-12-09 22:43:18 UTC (rev 91017)
@@ -0,0 +1,919 @@
+using System;
+using System.IO;
+
+public class GenAnimationTypes {
+
+       enum AnimatableType {
+               Boolean,
+               Byte,
+               Char,
+               Color,
+               Decimal,
+               Double,
+               Int16,
+               Int32,
+               Int64,
+               Matrix,
+               Object,
+               //Point3D,
+               Point,
+               //Quaternion,
+               Rect,
+               //Rotation3D,
+               Single,
+               Size,
+               String,
+               //Vector3D,
+               Vector
+       };
+
+       enum AnimationClassType {
+               /*Int32*/Animation,
+               /*Int32*/AnimationBase,
+               /*Int32*/AnimationUsingKeyFrames,
+               /*Int32*/KeyFrame,
+               /*Int32*/KeyFrameCollection
+       };
+
+       enum KeyFrameType {
+               Discrete/*Int32KeyFrame*/,
+               Linear/*Int32KeyFrame*/,
+               Spline/*Int32KeyFrame*/
+       };
+
+       static bool istypecontinuous (AnimatableType t)
+       {
+               switch (t) {
+               case AnimatableType.Boolean:
+               case AnimatableType.Char:
+               case AnimatableType.Object:
+               case AnimatableType.String:
+               case AnimatableType.Matrix:
+                       return false;
+
+               case AnimatableType.Color:
+               //case AnimatableType.Point3D:
+               //case AnimatableType.Quaternion:
+               //case AnimatableType.Rotation3D:
+               //case AnimatableType.Vector3D:
+
+               default:
+                       return true;
+               }
+       }
+
+       static string gettype (AnimatableType t)
+       {
+               switch (t) {
+               case AnimatableType.Boolean: return "bool";
+               case AnimatableType.Byte: return "byte";
+               case AnimatableType.Char: return "char";
+               case AnimatableType.Object: return "object";
+               case AnimatableType.Single: return "float";
+               case AnimatableType.Double: return "double";
+               case AnimatableType.Int16: return "short";
+               case AnimatableType.Int32: return "int";
+               case AnimatableType.Int64: return "long";
+               case AnimatableType.Decimal:
+               case AnimatableType.Color:
+               case AnimatableType.Matrix:
+                       //case AnimatableType.Point3D:
+               case AnimatableType.Point:
+                       //case AnimatableType.Quaternion:
+               case AnimatableType.Rect:
+                       //case AnimatableType.Rotation3D:
+               case AnimatableType.Size:
+               case AnimatableType.String:
+                       //case AnimatableType.Vector3D:
+               case AnimatableType.Vector:
+                       return t.ToString();
+               }
+
+               return null;
+       }
+
+       string generateLerp (string from, string to, string progress)
+       {
+               switch (type) {
+               case AnimatableType.Byte:
+               case AnimatableType.Int16:
+               case AnimatableType.Int32:
+               case AnimatableType.Int64:
+               case AnimatableType.Single:
+               case AnimatableType.Double:
+                       return String.Format ("return ({0})({1} + ({2} - {1}) * 
{3})", gettype(type), from, to, progress);
+
+               case AnimatableType.Decimal:
+                       return String.Format ("return ({0})((double){1} + 
((double){2} - (double){1}) * {3})", gettype(type), from, to, progress);
+
+               case AnimatableType.Point:
+               case AnimatableType.Vector:
+                       return String.Format ("return new {3} ({0}.X + ({1}.X - 
{0}.X) * {2}, {0}.Y + ({1}.Y - {0}.Y) * {2});", from, to, progress, type);
+               case AnimatableType.Rect:
+                       return String.Format ("return new Rect ({0}.X + ({1}.X 
- {0}.X) * {2}, {0}.Y + ({1}.Y - {0}.Y) * {2}, {0}.Width + ({1}.Width - 
{0}.Width) * {2}, {0}.Height + ({1}.Height - {0}.Height) * {2})", from, to, 
progress);
+
+               case AnimatableType.Size:
+                       return String.Format ("return new Size ({0}.Width + 
({1}.Width - {0}.Width) * {2}, {0}.Height + ({1}.Height - {0}.Height) * {2})", 
from, to, progress);
+
+               case AnimatableType.Color:
+                       return String.Format ("return Color.FromScRgb 
((float)({0}.ScA + ({1}.ScA - {0}.ScA) * {2}), (float)({0}.ScR + ({1}.ScR - 
{0}.ScR) * {2}), (float)({0}.ScG + ({1}.ScG - {0}.ScG) * {2}), (float)({0}.ScB 
+ ({1}.ScB - {0}.ScB) * {2}))", from, to, progress);
+
+               default:
+                       return "XXX";
+               }
+       }
+
+       AnimatableType type;
+
+       GenAnimationTypes (AnimatableType type)
+       {
+               this.type = type;
+       }
+
+       void OutputAnimationBaseTest (TextWriter tw)
+       {
+               tw.WriteLine (@"
+[TestFixture]
+public class {0}AnimationBaseTest
+{{
+       class {0}AnimationBasePoker : {0}AnimationBase
+       {{
+               protected override {1} GetCurrentValueCore ({1} 
defaultOriginValue, {1} defaultDestinationValue,
+                                                           AnimationClock 
animationClock)
+               {{
+                       throw new NotImplementedException ();
+               }}
+
+               protected override Freezable CreateInstanceCore ()
+               {{
+                       throw new NotImplementedException ();
+               }}
+       }}
+
+       [Test]
+       public void Properties ()
+       {{
+               {0}AnimationBasePoker poker = new {0}AnimationBasePoker ();
+               Assert.AreEqual (typeof ({1}), poker.TargetPropertyType);
+       }}
+}}
+", type, gettype(type));
+       }
+
+       void OutputAnimationBase (TextWriter tw)
+       {
+               tw.WriteLine (@"
+public abstract class {0}AnimationBase : AnimationTimeline
+{{
+       protected {0}AnimationBase () {{ }}
+
+       public override sealed Type TargetPropertyType {{ get {{ return typeof 
({1}); }} }}
+
+       public new {0}AnimationBase Clone ()
+       {{
+               throw new NotImplementedException ();
+       }} 
+
+       public override sealed object GetCurrentValue (object 
defaultOriginValue, object defaultDestinationValue, AnimationClock 
animationClock)
+       {{
+               return GetCurrentValue (({1})defaultOriginValue, ({1}) 
defaultDestinationValue, animationClock);
+       }}
+
+       protected abstract {1} GetCurrentValueCore ({1} defaultOriginValue, {1} 
defaultDestinationValue, AnimationClock animationClock);
+", type, gettype(type));
+
+               if (type != AnimatableType.Object) {
+                       tw.WriteLine (@"
+       public {1} GetCurrentValue ({1} defaultOriginValue, {1} 
defaultDestinationValue, AnimationClock animationClock)
+       {{
+               throw new NotImplementedException ();
+       }}
+", type, gettype(type));
+               }
+
+               tw.WriteLine ("\n}\n");
+       }
+
+
+       void OutputTestHeader (TextWriter tw)
+       {
+               tw.WriteLine (@"
+/* this file is generated by gen-animation-types.cs.  do not modify */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Reflection;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Markup;
+using System.Windows.Media.Animation;
+using NUnit.Framework;
+
+namespace MonoTests.System.Windows.Media.Animation {
+");
+       }
+
+       void OutputHeader (TextWriter tw)
+       {
+               tw.WriteLine (@"
+/* this file is generated by gen-animation-types.cs.  do not modify */
+
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Reflection;
+using System.Windows;
+using System.Windows.Media;
+using System.Windows.Markup;
+
+namespace System.Windows.Media.Animation {
+");
+       }
+
+       void OutputAnimationTest (TextWriter tw)
+       {
+               tw.WriteLine (@"
+[TestFixture]
+public class {0}AnimationTest
+{{
+       [Test]
+       public void Properties ()
+       {{
+               Assert.AreEqual (""By"", {0}Animation.ByProperty.Name, ""1"");
+               Assert.AreEqual (typeof ({0}Animation), 
{0}Animation.ByProperty.OwnerType, ""2"");
+               Assert.AreEqual (typeof ({1}?), 
{0}Animation.ByProperty.PropertyType, ""3"");
+
+               Assert.AreEqual (""From"", {0}Animation.FromProperty.Name, 
""4"");
+               Assert.AreEqual (typeof ({0}Animation), 
{0}Animation.FromProperty.OwnerType, ""5"");
+               Assert.AreEqual (typeof ({1}?), 
{0}Animation.FromProperty.PropertyType, ""6"");
+
+               Assert.AreEqual (""To"", {0}Animation.ToProperty.Name, ""7"");
+               Assert.AreEqual (typeof ({0}Animation), 
{0}Animation.ToProperty.OwnerType, ""8"");
+               Assert.AreEqual (typeof ({1}?), 
{0}Animation.ToProperty.PropertyType, ""9"");
+       }}
+}}
+", type, gettype(type));
+       }
+
+       void OutputAnimation (TextWriter tw)
+       {
+               tw.WriteLine (@"
+public class {0}Animation : {0}AnimationBase
+{{
+       public static readonly DependencyProperty ByProperty
+                               = DependencyProperty.Register (""By"", typeof 
({1}), typeof ({0}KeyFrame));
+       public static readonly DependencyProperty FromProperty
+                               = DependencyProperty.Register (""From"", typeof 
({1}), typeof ({0}KeyFrame));
+       public static readonly DependencyProperty ToProperty
+                               = DependencyProperty.Register (""To"", typeof 
({1}), typeof ({0}KeyFrame));
+
+       public {0}Animation ()
+       {{
+       }}
+
+       public {0}Animation ({1} toValue, Duration duration)
+       {{
+       }}
+
+       public {0}Animation ({1} toValue, Duration duration, FillBehavior 
fillBehavior)
+       {{
+       }}
+
+       public {0}Animation ({1} fromValue, {1} toValue, Duration duration)
+       {{
+       }}
+
+       public {0}Animation ({1} fromValue, {1} tovalue, Duration duration, 
FillBehavior fillBehavior)
+       {{
+       }}
+
+       public {1}? By {{
+               get {{ return ({1}?) GetValue (ByProperty); }}
+               set {{ SetValue (ByProperty, value); }}
+       }}
+
+       public {1}? From {{
+               get {{ return ({1}?) GetValue (FromProperty); }}
+               set {{ SetValue (FromProperty, value); }}
+       }}
+
+       public {1}? To {{
+               get {{ return ({1}?) GetValue (ToProperty); }}
+               set {{ SetValue (ToProperty, value); }}
+       }}
+
+       public bool IsAdditive {{
+               get {{ return (bool) GetValue 
(AnimationTimeline.IsAdditiveProperty); }}
+               set {{ SetValue (AnimationTimeline.IsAdditiveProperty, value); 
}}
+       }}
+
+       public bool IsCumulative {{
+               get {{ return (bool) GetValue 
(AnimationTimeline.IsCumulativeProperty); }}
+               set {{ SetValue (AnimationTimeline.IsCumulativeProperty, 
value); }}
+       }}
+
+       public new {0}Animation Clone ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override Freezable CreateInstanceCore ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override {1} GetCurrentValueCore ({1} defaultOriginValue, {1} 
defaultDestinationValue, AnimationClock animationClock)
+       {{
+               throw new NotImplementedException ();
+       }}
+}}
+", type, gettype(type));
+       }
+
+       void OutputAnimationUsingKeyFrames (TextWriter tw)
+       {
+               tw.WriteLine (@"
+[ContentProperty (""KeyFrames"")]
+public class {0}AnimationUsingKeyFrames : {0}AnimationBase, 
IKeyFrameAnimation, IAddChild
+{{
+       public {0}AnimationUsingKeyFrames ()
+       {{
+       }}
+
+       public {0}KeyFrameCollection KeyFrames {{
+               get {{ throw new NotImplementedException (); }}
+               set {{ throw new NotImplementedException (); }}
+       }}
+
+       IList IKeyFrameAnimation.KeyFrames {{
+               get {{ return (IList)KeyFrames; }}
+               set {{ KeyFrames = ({0}KeyFrameCollection)value; }}
+       }}
+
+       [EditorBrowsable(EditorBrowsableState.Advanced)]
+       protected virtual void AddChild (object child)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       void IAddChild.AddChild (object child)
+       {{
+               AddChild (child);
+       }}
+
+       [EditorBrowsable(EditorBrowsableState.Advanced)]
+       protected virtual void AddText (string childText)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       void IAddChild.AddText (string childText)
+       {{
+               AddText (childText);
+       }}
+
+       public new {0}AnimationUsingKeyFrames Clone ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void CloneCore (Freezable sourceFreezable)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       public new {0}AnimationUsingKeyFrames CloneCurrentValue ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void CloneCurrentValueCore (Freezable 
sourceFreezable)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override Freezable CreateInstanceCore ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override bool FreezeCore (bool isChecking)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void GetAsFrozenCore (Freezable source)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void GetCurrentValueAsFrozenCore (Freezable source)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override sealed {1} GetCurrentValueCore ({1} 
defaultOriginValue, {1} defaultDestinationValue, AnimationClock animationClock)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override sealed Duration GetNaturalDurationCore (Clock clock)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void OnChanged ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       [EditorBrowsable(EditorBrowsableState.Never)]
+       public bool ShouldSerializeKeyFrames()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+", type, gettype(type));
+
+               if (istypecontinuous (type)) {
+                       tw.WriteLine (@"
+       public bool IsAdditive {{
+               get {{ return (bool) GetValue 
(AnimationTimeline.IsAdditiveProperty); }}
+               set {{ SetValue (AnimationTimeline.IsAdditiveProperty, value); 
}}
+       }}
+
+       public bool IsCumulative {{
+               get {{ return (bool) GetValue 
(AnimationTimeline.IsCumulativeProperty); }}
+               set {{ SetValue (AnimationTimeline.IsCumulativeProperty, 
value); }}
+       }}
+", type, gettype(type));
+               }
+
+               tw.WriteLine ("\n}\n");
+       }
+
+       void OutputKeyFrameTest (TextWriter tw)
+       {
+               tw.WriteLine (@"
+[TestFixture]
+public class {0}KeyFrameTest
+{{
+       [Test]
+       public void Properties ()
+       {{
+               Assert.AreEqual (""KeyTime"", {0}KeyFrame.KeyTimeProperty.Name, 
""1"");
+               Assert.AreEqual (typeof ({0}KeyFrame), 
{0}KeyFrame.KeyTimeProperty.OwnerType, ""2"");
+               Assert.AreEqual (typeof (KeyTime), 
{0}KeyFrame.KeyTimeProperty.PropertyType, ""3"");
+
+               Assert.AreEqual (""Value"", {0}KeyFrame.ValueProperty.Name, 
""4"");
+               Assert.AreEqual (typeof ({0}KeyFrame), 
{0}KeyFrame.ValueProperty.OwnerType, ""5"");
+               Assert.AreEqual (typeof ({1}), 
{0}KeyFrame.ValueProperty.PropertyType, ""6"");
+       }}
+}}
+", type, gettype(type));
+       }
+
+       void OutputKeyFrame (TextWriter tw)
+       {
+               tw.WriteLine (@"
+public abstract class {0}KeyFrame : Freezable, IKeyFrame
+{{
+       public static readonly DependencyProperty KeyTimeProperty
+                               = DependencyProperty.Register (""KeyTime"", 
typeof (KeyTime), typeof ({0}KeyFrame));
+
+       public static readonly DependencyProperty ValueProperty
+                               = DependencyProperty.Register (""Value"", 
typeof ({1}), typeof ({0}KeyFrame));
+
+       protected {0}KeyFrame ()
+       {{
+       }}
+
+       protected {0}KeyFrame ({1} value)
+       {{
+       }}
+
+       protected {0}KeyFrame ({1} value, KeyTime keyTime)
+       {{
+       }}
+
+       public KeyTime KeyTime {{
+               get {{ return (KeyTime)GetValue (KeyTimeProperty); }}
+               set {{ SetValue (KeyTimeProperty, value); }}
+       }}
+
+       public {1} Value {{
+               get {{ return ({1})GetValue (ValueProperty); }}
+               set {{ SetValue (ValueProperty, value); }}
+       }}
+
+       object IKeyFrame.Value {{
+               get {{ return Value; }}
+               set {{ Value = ({1})value; }}
+       }}
+
+       public {1} InterpolateValue ({1} baseValue, double keyFrameProgress)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected abstract {1} InterpolateValueCore ({1} baseValue, double 
keyFrameProgress);
+}}
+", type, gettype(type));
+       }
+
+       void OutputFooter (TextWriter tw)
+       {
+               tw.WriteLine ("\n}"); /* close the namespace */
+       }
+
+       void OutputTestFooter (TextWriter tw)
+       {
+               tw.WriteLine ("\n}"); /* close the namespace */
+       }
+
+       void OutputKeyFrameCollection (TextWriter tw)
+       {
+               tw.WriteLine (@"
+public class {0}KeyFrameCollection : Freezable, IList, ICollection, IEnumerable
+{{
+       public {0}KeyFrameCollection ()
+       {{
+       }}
+
+       public int Count {{
+               get {{ throw new NotImplementedException (); }}
+       }}
+
+       public static {0}KeyFrameCollection Empty {{
+               get {{ throw new NotImplementedException (); }}
+       }}
+
+       public bool IsFixedSize {{
+               get {{ throw new NotImplementedException (); }}
+       }}
+
+       public bool IsReadOnly {{
+               get {{ throw new NotImplementedException (); }}
+       }}
+
+       public bool IsSynchronized {{
+               get {{ throw new NotImplementedException (); }}
+       }}
+
+       public object SyncRoot {{
+               get {{ throw new NotImplementedException (); }}
+       }}
+
+       public {0}KeyFrame this[int index] {{
+               get {{ throw new NotImplementedException (); }}
+               set {{ throw new NotImplementedException (); }}
+       }}
+
+       object IList.this[int index] {{
+               get {{ return this[index]; }}
+               set {{ this[index] = ({0}KeyFrame)value; }}
+       }}
+
+       public int Add ({0}KeyFrame keyFrame)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       int IList.Add (object value)
+       {{
+               return Add (({0}KeyFrame) value);
+       }}
+
+       public void Clear ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       public new {0}KeyFrameCollection Clone ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void CloneCore (Freezable sourceFreezable)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void CloneCurrentValueCore (Freezable 
sourceFreezable)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       public bool Contains ({0}KeyFrame keyFrame)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       bool IList.Contains (object value)
+       {{
+               return Contains (({0}KeyFrame)value);
+       }}
+
+       public void CopyTo ({0}KeyFrame[] array, int index)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       void ICollection.CopyTo (Array array, int index)
+       {{
+               CopyTo (({0}KeyFrame[])array, index);
+       }}
+
+       protected override Freezable CreateInstanceCore ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override bool FreezeCore (bool isChecking)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void GetAsFrozenCore (Freezable sourceFreezable)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override void GetCurrentValueAsFrozenCore (Freezable 
sourceFreezable)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       public IEnumerator GetEnumerator()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       public int IndexOf ({0}KeyFrame keyFrame)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       int IList.IndexOf (object value)
+       {{
+               return IndexOf (({0}KeyFrame) value);
+       }}
+
+       public void Insert (int index, {0}KeyFrame keyFrame)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       void IList.Insert (int index, object value)
+       {{
+               Insert (index, ({0}KeyFrame)value);
+       }}
+
+       public void Remove ({0}KeyFrame keyFrame)
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       void IList.Remove (object value)
+       {{
+               Remove (({0}KeyFrame) value);
+       }}
+
+       public void RemoveAt (int index)
+       {{
+               throw new NotImplementedException ();
+       }}
+}}
+", type, gettype(type));
+       }
+
+       void OutputBaseClassFile (AnimationClassType ac)
+       {
+               if (ac == AnimationClassType.Animation
+                   && !istypecontinuous (type))
+                       return;
+
+               string class_filename = String.Format 
("System.Windows.Media.Animation/{0}{1}.cs", type, ac);
+               string test_filename =  String.Format 
("Test/System.Windows.Media.Animation/{0}{1}Test.cs", type, ac);
+
+               Console.WriteLine ("outputting class {0}", class_filename);
+               Console.WriteLine ("           test  {0}", test_filename);
+
+               TextWriter class_tw = File.CreateText (class_filename);
+               OutputHeader (class_tw);
+
+               TextWriter test_tw = File.CreateText (test_filename);
+               OutputTestHeader (test_tw);
+
+               switch (ac) {
+               case AnimationClassType.Animation:
+                       OutputAnimation (class_tw);
+                       OutputAnimationTest (test_tw);
+                       break;
+               case AnimationClassType.AnimationBase:
+                       OutputAnimationBase (class_tw);
+                       OutputAnimationBaseTest (test_tw);
+                       break;
+               case AnimationClassType.AnimationUsingKeyFrames:
+                       OutputAnimationUsingKeyFrames (class_tw);
+                       // XXX OutputAnimationUsingKeyFramesTest (test_tw);
+                       break;
+               case AnimationClassType.KeyFrame:
+                       OutputKeyFrame (class_tw);
+                       OutputKeyFrameTest (test_tw);
+                       break;
+               case AnimationClassType.KeyFrameCollection:
+                       OutputKeyFrameCollection (class_tw);
+                       // XXX OutputKeyFrameCollectionTest (test_tw);
+                       break;
+               }
+               OutputFooter (class_tw);
+               class_tw.Close ();
+
+               OutputTestFooter (test_tw);
+               test_tw.Close ();
+       }
+
+       void OutputDiscreteKeyFrame (TextWriter tw)
+       {
+               tw.WriteLine (@"
+public class Discrete{0}KeyFrame : {0}KeyFrame
+{{
+       {1} value;
+       KeyTime keyTime;
+
+       public Discrete{0}KeyFrame ()
+       {{
+       }}
+
+       public Discrete{0}KeyFrame ({1} value)
+       {{
+               this.value = value;
+               // XXX keytime?
+       }}
+
+       public Discrete{0}KeyFrame ({1} value, KeyTime keyTime)
+       {{
+               this.value = value;
+               this.keyTime = keyTime;
+       }}
+
+       protected override Freezable CreateInstanceCore ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override {1} InterpolateValueCore ({1} baseValue, double 
keyFrameProgress)
+       {{
+               return keyFrameProgress == 1.0 ? value : baseValue;
+       }}
+}}
+", type, gettype(type));
+       }
+
+       void OutputLinearKeyFrame (TextWriter tw)
+       {
+               tw.WriteLine (@"
+public class Linear{0}KeyFrame : {0}KeyFrame
+{{
+       {1} value;
+       KeyTime keyTime;
+
+       public Linear{0}KeyFrame ()
+       {{
+       }}
+
+       public Linear{0}KeyFrame ({1} value)
+       {{
+               this.value = value;
+               // XXX keytime?
+       }}
+
+       public Linear{0}KeyFrame ({1} value, KeyTime keyTime)
+       {{
+               this.value = value;
+               this.keyTime = keyTime;
+       }}
+
+       protected override Freezable CreateInstanceCore ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override {1} InterpolateValueCore ({1} baseValue, double 
keyFrameProgress)
+       {{
+               // standard linear interpolation
+               {2};
+       }}
+}}
+", type, gettype(type), generateLerp ("baseValue", "value", 
"keyFrameProgress"));
+       }
+
+       void OutputSplineKeyFrame (TextWriter tw)
+       {
+               tw.WriteLine (@"
+public class Spline{0}KeyFrame : {0}KeyFrame
+{{
+
+       public static readonly DependencyProperty KeySplineProperty =
+               DependencyProperty.Register (""KeySpline"", typeof (KeySpline), 
typeof (Spline{0}KeyFrame));
+
+       {1} value;
+       KeyTime keyTime;
+
+       public Spline{0}KeyFrame ()
+       {{
+       }}
+
+       public Spline{0}KeyFrame ({1} value)
+       {{
+               this.value = value;
+               // XX keytime?
+       }}
+
+       public Spline{0}KeyFrame ({1} value, KeyTime keyTime)
+       {{
+               this.value = value;
+               this.keyTime = keyTime;
+       }}
+
+       public Spline{0}KeyFrame ({1} value, KeyTime keyTime, KeySpline 
keySpline)
+       {{
+               this.value = value;
+               this.keyTime = keyTime;
+               KeySpline = keySpline;
+       }}
+
+       public KeySpline KeySpline {{
+               get {{ return (KeySpline)GetValue (KeySplineProperty); }}
+               set {{ SetValue (KeySplineProperty, value); }}
+       }}
+
+       protected override Freezable CreateInstanceCore ()
+       {{
+               throw new NotImplementedException ();
+       }}
+
+       protected override {1} InterpolateValueCore ({1} baseValue, double 
keyFrameProgress)
+       {{
+               double splineProgress = KeySpline.GetSplineProgress 
(keyFrameProgress);
+
+               {2};
+       }}
+}}
+", type, gettype(type), generateLerp ("baseValue", "value", "splineProgress"));
+       }
+
+       void OutputKeyFrameFile (KeyFrameType kt)
+       {
+               if (!istypecontinuous (type) &&
+                   (kt == KeyFrameType.Linear || kt == KeyFrameType.Spline))
+                       return;
+
+               string class_filename = String.Format 
("System.Windows.Media.Animation/{0}{1}KeyFrame.cs", kt, type);
+               string test_filename = String.Format 
("Test/System.Windows.Media.Animation/{0}{1}KeyFrameTest.cs", kt, type);
+
+               Console.WriteLine ("outputting class {0}", class_filename);
+               Console.WriteLine ("           test  {0}", test_filename);
+
+               TextWriter class_tw = File.CreateText (class_filename);
+               OutputHeader (class_tw);
+
+               TextWriter test_tw = File.CreateText (test_filename);
+               OutputTestHeader (test_tw);
+
+               switch (kt) {
+               case KeyFrameType.Discrete:
+                       OutputDiscreteKeyFrame (class_tw);
+                       break;
+               case KeyFrameType.Linear:
+                       OutputLinearKeyFrame (class_tw);
+                       break;
+               case KeyFrameType.Spline:
+                       OutputSplineKeyFrame (class_tw);
+                       break;
+               }
+
+               OutputFooter (class_tw);
+               class_tw.Close ();
+
+               OutputTestFooter (test_tw);
+               test_tw.Close ();
+       }
+
+       public static void Main (string[] args)
+       {
+               foreach (AnimatableType at in Enum.GetValues(typeof 
(AnimatableType))) {
+                       GenAnimationTypes ga = new GenAnimationTypes(at);
+
+                       /* output the base class types */
+                       foreach (AnimationClassType ac in Enum.GetValues 
(typeof (AnimationClassType)))
+                               ga.OutputBaseClassFile (ac);
+
+                       /* output the keyframe types */
+                       foreach (KeyFrameType kt in Enum.GetValues (typeof 
(KeyFrameType)))
+                               ga.OutputKeyFrameFile (kt);
+               }
+       }
+}

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to