3 using System
.Windows
.Controls
;
4 using System
.Windows
.Data
;
5 using System
.Windows
.Documents
;
6 using System
.Windows
.Media
;
7 using System
.Windows
.Media
.Animation
;
8 using System
.Windows
.Navigation
;
9 using System
.Windows
.Shapes
;
11 namespace Microsoft
.Samples
.Animation
14 public partial class SplineExample
: Page
16 private Point controlPoint1
= new Point(0,100);
17 private Point controlPoint2
= new Point(0,100);
19 private void OnSliderChanged (object sender
, RoutedEventArgs e
)
24 // Retrieve the name of slider.
25 string name
= ((Slider
)sender
).Name
;
27 RoutedPropertyChangedEventArgs
<double> args
= e
as RoutedPropertyChangedEventArgs
<double>;
31 case "SliderControlPoint1X":
32 mySplineKeyFrame
.KeySpline
.ControlPoint1
= new Point((double)args
.NewValue
, mySplineKeyFrame
.KeySpline
.ControlPoint1
.Y
);
33 controlPoint1
.X
= 100 * (double)args
.NewValue
;
35 case "SliderControlPoint1Y":
36 mySplineKeyFrame
.KeySpline
.ControlPoint1
= new Point(mySplineKeyFrame
.KeySpline
.ControlPoint1
.X
, (double)args
.NewValue
);
37 controlPoint1
.Y
= 100 - (100 * (double)args
.NewValue
);
39 case "SliderControlPoint2X":
40 mySplineKeyFrame
.KeySpline
.ControlPoint2
= new Point((double)args
.NewValue
, mySplineKeyFrame
.KeySpline
.ControlPoint2
.Y
);
41 controlPoint2
.X
= 100 * (double)args
.NewValue
;
43 case "SliderControlPoint2Y":
44 mySplineKeyFrame
.KeySpline
.ControlPoint2
= new Point(mySplineKeyFrame
.KeySpline
.ControlPoint2
.X
, (double)args
.NewValue
);
45 controlPoint2
.Y
= 100 - (100 * (double)args
.NewValue
);
52 // Update the animations and illustrations.
53 myVector3DSplineKeyFrame
.KeySpline
.ControlPoint1
= mySplineKeyFrame
.KeySpline
.ControlPoint1
;
54 myVector3DSplineKeyFrame
.KeySpline
.ControlPoint2
= mySplineKeyFrame
.KeySpline
.ControlPoint2
;
57 SplineIllustrationSegment
.Point1
= controlPoint1
;
58 SplineIllustrationSegment
.Point2
= controlPoint2
;
59 SplineControlPoint1Marker
.Center
= controlPoint1
;
60 SplineControlPoint2Marker
.Center
= controlPoint2
;
63 "KeySpline=\"" + mySplineKeyFrame
.KeySpline
.ControlPoint1
.X
.ToString("N") + "," +
64 mySplineKeyFrame
.KeySpline
.ControlPoint1
.Y
.ToString("N") + " " +
65 mySplineKeyFrame
.KeySpline
.ControlPoint2
.X
.ToString("N") + "," +
66 mySplineKeyFrame
.KeySpline
.ControlPoint2
.Y
.ToString("N") + "\"";
70 // Determine the storyboard's current time.
71 TimeSpan
? oldTime
= (TimeSpan
)ExampleStoryboard
.GetCurrentTime(this);
73 oldTime
= TimeSpan
.FromSeconds(0);
75 // Generate new clocks for the animations by calling
77 ExampleStoryboard
.Begin(this, true);
79 // Because the storyboard was reset, advance it to its previous
80 // position using the Seek method.
81 ExampleStoryboard
.Seek(this, (TimeSpan
)oldTime
, TimeSeekOrigin
.BeginTime
);