diff --git a/SampleGallery/Assets/SampleThumbnails/AnimationController.PNG b/SampleGallery/Assets/SampleThumbnails/AnimationController.PNG
new file mode 100644
index 0000000..acf805f
Binary files /dev/null and b/SampleGallery/Assets/SampleThumbnails/AnimationController.PNG differ
diff --git a/SampleGallery/MainPage.xaml.cs b/SampleGallery/MainPage.xaml.cs
index 910a469..3155d9a 100644
--- a/SampleGallery/MainPage.xaml.cs
+++ b/SampleGallery/MainPage.xaml.cs
@@ -322,7 +322,7 @@ namespace CompositionSampleGallery
_14393, // Anniversary Update (1607)
_15063, // Creators Update (1703)
_16299, // Fall Creators Update
- _INSIDER // Insiders
+ _17134 // Version 1803
};
public RuntimeSupportedSDKs()
diff --git a/SampleGallery/SampleGallery.csproj b/SampleGallery/SampleGallery.csproj
index df46d36..3aa7bb2 100644
--- a/SampleGallery/SampleGallery.csproj
+++ b/SampleGallery/SampleGallery.csproj
@@ -15,7 +15,7 @@
512
{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
CompositionSampleGallery_TemporaryKey.pfx
- 10.0.17763.0
+ 10.0.17134.0
10.0.15063.0
True
Always
@@ -132,6 +132,7 @@
HomePage.xaml
+
@@ -325,6 +326,7 @@
+
@@ -483,6 +485,10 @@
MSBuild:Compile
Designer
+
+ MSBuild:Compile
+ Designer
+
Designer
MSBuild:Compile
@@ -727,9 +733,7 @@
SamplesCommon
-
-
-
+
2.8.0
diff --git a/SampleGallery/Samples/SDK 17134/AnimationController/AnimationControl.cs b/SampleGallery/Samples/SDK 17134/AnimationController/AnimationControl.cs
new file mode 100644
index 0000000..fcce564
--- /dev/null
+++ b/SampleGallery/Samples/SDK 17134/AnimationController/AnimationControl.cs
@@ -0,0 +1,204 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
+// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+//*********************************************************
+using System;
+using System.Numerics;
+using Windows.UI.Composition;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Hosting;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Input;
+
+namespace CompositionSampleGallery
+{
+ public sealed partial class AnimationControl : SamplePage
+ {
+ public AnimationControl()
+ {
+ InitializeComponent();
+ AnimationSetup();
+ }
+
+ public static string StaticSampleName => "Animation Controller";
+ public override string SampleName => StaticSampleName;
+ public static string StaticSampleDescription => "Play, pause, speed up, slow down, " +
+ "or scrub your animation with the AnimationController API";
+ public override string SampleDescription => StaticSampleDescription;
+ private void AnimationSetup()
+ {
+ _compositor = Window.Current.Compositor;
+ _visual = ElementCompositionPreview.GetElementVisual(Rectangle);
+ _pause = true;
+ _interval = TimeSpan.FromMilliseconds(16); // based on 60f/sec
+
+ var linear = _compositor.CreateLinearEasingFunction();
+ int animationDuration = 4;
+ float animationMax = 250f;
+
+ // set up main animation
+ ElementCompositionPreview.SetIsTranslationEnabled(Rectangle, true);
+ _animation = _compositor.CreateVector3KeyFrameAnimation();
+ _animation.InsertKeyFrame(0.25f, new Vector3(animationMax, (float)Canvas.GetTop(Rectangle), 0f), linear);
+ _animation.InsertKeyFrame(0.5f, new Vector3(animationMax, animationMax, 0f), linear);
+ _animation.InsertKeyFrame(0.75f, new Vector3((float)Canvas.GetLeft(Rectangle), animationMax, 0f), linear);
+ _animation.InsertKeyFrame(1f, new Vector3((float)Canvas.GetLeft(Rectangle), (float)Canvas.GetTop(Rectangle), 0f), linear);
+ _animation.Duration = TimeSpan.FromSeconds(animationDuration);
+ _animation.IterationBehavior = AnimationIterationBehavior.Forever;
+
+ // set up dispatcher timer to animate slider
+ _sliderAnimator = new DispatcherTimer();
+ _sliderAnimator.Tick += SliderBehavior;
+ _sliderAnimator.Interval = _interval;
+
+ // initialize amount to change slider value per tick
+ _delta = (slider.Maximum / _animation.Duration.TotalMilliseconds) * _interval.TotalMilliseconds;
+
+ // add pointer listeners to slider for smooth scrubbing action
+ slider.AddHandler(PointerPressedEvent, new PointerEventHandler(PressedThumb), true);
+ slider.AddHandler(PointerReleasedEvent, new PointerEventHandler(ReleasedThumb), true);
+ }
+ private void EnsureController()
+ {
+ if (_controller == null)
+ {
+ // start animation on visual, and grab AnimationController from visual
+ _visual.StartAnimation(nameof(Visual.Offset), _animation);
+ _controller = _visual.TryGetAnimationController(nameof(Visual.Offset));
+ _controller.Pause();
+ }
+ }
+ private void PlayPause_Animation(object sender, RoutedEventArgs e)
+ {
+ EnsureController();
+ if (_pause)
+ {
+ _controller.Resume();
+ PlaySlider();
+ PlayIcon.Symbol = Symbol.Pause;
+ }
+ else
+ {
+ _controller.Pause();
+ StopSlider();
+ PlayIcon.Symbol = Symbol.Play;
+ }
+ _pause = !_pause;
+ }
+ private void Stop_Animation(object sender, RoutedEventArgs e)
+ {
+ _pause = false;
+ PlayPause_Animation(sender, e);
+ _controller.PlaybackRate = 1;
+ _controller.Progress = 0;
+ slider.Value = 0;
+ }
+ private void SpeedUp_Animation(object sender, RoutedEventArgs e)
+ {
+ EnsureController();
+ if (Math.Abs(_controller.PlaybackRate) < Math.Abs(AnimationController.MaxPlaybackRate) && !_pause)
+ {
+ _controller.PlaybackRate *= 2;
+ }
+ }
+ private void SlowDown_Animation(object sender, RoutedEventArgs e)
+ {
+ EnsureController();
+ if (Math.Abs(_controller.PlaybackRate) > Math.Abs(AnimationController.MinPlaybackRate) && !_pause)
+ {
+ _controller.PlaybackRate /= 2;
+ }
+ }
+ private void Reverse_Animation(object sender, RoutedEventArgs e)
+ {
+ if (!_pause)
+ {
+ _controller.PlaybackRate *= -1;
+ }
+ }
+
+ // helper methods to animate slider
+ private void OnSliderValueChanged(object sender, RangeBaseValueChangedEventArgs e)
+ {
+ EnsureController();
+ // this enables scrubbing
+ _controller.Progress = (float)slider.Value * .01f;
+ }
+ private void SliderBehavior(object sender, object e)
+ {
+ // update slider.Value based on time elapsed
+ DateTimeOffset currentTime = DateTimeOffset.Now;
+ TimeSpan elapsedTime = currentTime - lastTime;
+ double numTicks = elapsedTime.TotalMilliseconds / _interval.TotalMilliseconds;
+ slider.Value += (_delta * numTicks * _controller.PlaybackRate);
+
+ // logic to loop slider animation
+ // if PlaybackRate is less than 0, playing in reverse
+ if (_controller.PlaybackRate > 0)
+ {
+ if (slider.Value == 100)
+ {
+ slider.Value = 0;
+ }
+ }
+ else
+ {
+ if (slider.Value == 0)
+ {
+ slider.Value = 100;
+ }
+ }
+ lastTime = currentTime;
+ }
+ private void PlaySlider()
+ {
+ if (_sliderAnimator != null)
+ {
+ _sliderAnimator.Start();
+ lastTime = DateTimeOffset.Now;
+ }
+ }
+ private void StopSlider()
+ {
+ if (_sliderAnimator != null)
+ _sliderAnimator.Stop();
+ }
+
+ // helper methods for mouse input on the slider for smooth scrubbing action
+ private void PressedThumb(object sender, PointerRoutedEventArgs e)
+ {
+ EnsureController();
+ StopSlider();
+ _controller.Pause();
+ }
+ private void ReleasedThumb(object sender, PointerRoutedEventArgs e)
+ {
+ EnsureController();
+ if (!_pause)
+ {
+ PlaySlider();
+ _controller.Resume();
+ }
+ }
+
+ private Compositor _compositor;
+ private Vector3KeyFrameAnimation _animation;
+ private AnimationController _controller;
+ private Visual _visual;
+ private bool _pause;
+ private DispatcherTimer _sliderAnimator;
+ private TimeSpan _interval;
+ private DateTimeOffset lastTime;
+ private double _delta;
+ }
+}
diff --git a/SampleGallery/Samples/SDK 17134/AnimationController/AnimationControl.xaml b/SampleGallery/Samples/SDK 17134/AnimationController/AnimationControl.xaml
new file mode 100644
index 0000000..140d920
--- /dev/null
+++ b/SampleGallery/Samples/SDK 17134/AnimationController/AnimationControl.xaml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/SampleGallery/Shared/SampleDefinition.cs b/SampleGallery/Shared/SampleDefinition.cs
index 7d93ed8..78017d6 100644
--- a/SampleGallery/Shared/SampleDefinition.cs
+++ b/SampleGallery/Shared/SampleDefinition.cs
@@ -179,10 +179,11 @@ namespace CompositionSampleGallery
#endif
#if SDKVERSION_16299
- new SampleDefinition(SpringyImage.StaticSampleName, typeof(SpringyImage), SampleType.Reference, SampleCategory.Motion, false, false, "ms-appx:///Assets/SampleThumbnails/SpringyImage.PNG", description: SpringyImage.StaticSampleDescription, sdkVersion: RuntimeSupportedSDKs.SDKVERSION._16299, dateAdded: new DateTime(2017,08,7), tags: new string[1]{"ExpressionBuilder"}),
+ new SampleDefinition(SpringyImage.StaticSampleName, typeof(SpringyImage), SampleType.Reference, SampleCategory.Motion, false, false, "ms-appx:///Assets/SampleThumbnails/SpringyImage.PNG", description: SpringyImage.StaticSampleDescription, sdkVersion: RuntimeSupportedSDKs.SDKVERSION._16299, dateAdded: new DateTime(2017,08,7), tags: new string[1]{"ExpressionBuilder"}),
#endif
-#if SDKVERSION_INSIDER
+#if SDKVERSION_17134
+ new SampleDefinition(AnimationControl.StaticSampleName, typeof(AnimationControl), SampleType.Reference, SampleCategory.APIReference, false, false, "ms-appx:///Assets/SampleThumbnails/AnimationController.PNG", description: AnimationControl.StaticSampleDescription, sdkVersion: RuntimeSupportedSDKs.SDKVERSION._17134, dateAdded: new DateTime(2018,12,3)),
#endif
};
diff --git a/SamplesCommon/SamplesCommon/CommonBuild.props b/SamplesCommon/SamplesCommon/CommonBuild.props
index 7e97f99..01a8fb5 100644
--- a/SamplesCommon/SamplesCommon/CommonBuild.props
+++ b/SamplesCommon/SamplesCommon/CommonBuild.props
@@ -12,7 +12,7 @@
$(DefineConstants);SDKVERSION_14393
$(DefineConstants);SDKVERSION_15063
$(DefineConstants);SDKVERSION_16299
- $(DefineConstants);SDKVERSION_INSIDER
+ $(DefineConstants);SDKVERSION_17134