diff --git a/YetAnotherChartComponent/YetAnotherChartComponent/Decorations/ValueLabels.cs b/YetAnotherChartComponent/YetAnotherChartComponent/Decorations/ValueLabels.cs index 48811a9..b58f6e4 100644 --- a/YetAnotherChartComponent/YetAnotherChartComponent/Decorations/ValueLabels.cs +++ b/YetAnotherChartComponent/YetAnotherChartComponent/Decorations/ValueLabels.cs @@ -1,4 +1,4 @@ -#define COMPOSITION_ENABLED +#undef COMPOSITION_ENABLED using eScape.Core; using System; using System.Collections.Generic; @@ -318,6 +318,7 @@ FrameworkElement CreateElement(ISeriesItemValueDouble isiv) { // connect the shim to template root element's Visibility BindTo(shim, nameof(Visibility), fe, UIElement.VisibilityProperty); fe.DataContext = shim; + fe.SizeChanged -= Element_SizeChanged; fe.SizeChanged += Element_SizeChanged; #if COMPOSITION_ENABLED UniversalApiContract.v3.CompositionSupport.AttachAnimations(fe); diff --git a/YetAnotherChartComponent/YetAnotherChartComponent/Properties/AssemblyInfo.cs b/YetAnotherChartComponent/YetAnotherChartComponent/Properties/AssemblyInfo.cs index 28121f5..0f3c5bb 100644 --- a/YetAnotherChartComponent/YetAnotherChartComponent/Properties/AssemblyInfo.cs +++ b/YetAnotherChartComponent/YetAnotherChartComponent/Properties/AssemblyInfo.cs @@ -23,6 +23,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.5")] -[assembly: AssemblyFileVersion("1.0.0.5")] +[assembly: AssemblyVersion("1.5.1.0")] +[assembly: AssemblyFileVersion("1.5.1.0")] [assembly: ComVisible(false)] \ No newline at end of file diff --git a/YetAnotherChartComponent/YetAnotherChartComponent/Support/Composition.cs b/YetAnotherChartComponent/YetAnotherChartComponent/Support/Composition.cs index 7ac608a..782ed33 100644 --- a/YetAnotherChartComponent/YetAnotherChartComponent/Support/Composition.cs +++ b/YetAnotherChartComponent/YetAnotherChartComponent/Support/Composition.cs @@ -91,7 +91,7 @@ public static void AttachAnimations(UIElement uix) { var elementVisual = ElementCompositionPreview.GetElementVisual(uix); var compositor = elementVisual.Compositor; var elementImplicitAnimation = compositor.CreateImplicitAnimationCollection(); - // Define trigger and animation that should play when the trigger is triggered. + // Define trigger and animation that should play when the trigger is triggered. elementImplicitAnimation[nameof(Visual.Offset)] = CreateAnimationGroup(compositor, OffsetAnimationDuration); elementVisual.ImplicitAnimations = elementImplicitAnimation; } @@ -106,4 +106,79 @@ public static void DetachAnimations(UIElement uix) { } #endregion } -} \ No newline at end of file +} +namespace eScapeLLC.UWP.Charts.UniversalApiContract.v4 { + /// + /// Support class for Composition v4 APIs. + /// + /// CreateHostbackdropBrush, class , + /// GetPointerPositionPropertySet, SetImplicitHideAnimation, SetImplicitShowAnimation, SetIsTranslationEnabled + /// + public static class CompositionSupport { + #region API contract info + /// + /// Where to look for contract. + /// + public const String CONTRACT = "Windows.Foundation.UniversalApiContract"; + /// + /// Version base APIs appear in. + /// + public const int VERSION = 4; + /// + /// Get whether we have API support. + /// + public static bool IsSupported { get; } = ApiInformation.IsApiContractPresent(CONTRACT, VERSION); + /// + /// Globally set the duration of the offset animation. + /// + public static int AnimationDuration { get; set; } = 3250; + #endregion + #region internal (doesn't check CONTRACT) + /// + /// Create the . + /// Doesn't check for CONTRACT. + /// + /// + /// true: 0..1; false: 1..0. + /// Duration of animation in MS. + /// New instance. + private static ICompositionAnimationBase CreateAnimationGroup(Compositor compositor, bool fadein, int duration) { + // Define Opacity Animation for the Animation group + var animation = compositor.CreateScalarKeyFrameAnimation(); + animation.Target = nameof(Visual.Opacity); + animation.InsertKeyFrame(0f, fadein ? 0f : 1f); + animation.InsertKeyFrame(1f, fadein ? 1f : 0f); + animation.Duration = TimeSpan.FromMilliseconds(duration); + var animationGroup = compositor.CreateAnimationGroup(); + animationGroup.Add(animation); + return animation; + } + #endregion + #region external (MUST check CONTRACT) + /// + /// Attach implicit show/hide animations to given element. + /// Creates new instances of everything. + /// + /// + public static void AttachAnimations(UIElement uix) { + if (!IsSupported) return; + var elementVisual = ElementCompositionPreview.GetElementVisual(uix); + var compositor = elementVisual.Compositor; + var show = CreateAnimationGroup(compositor, true, AnimationDuration); + ElementCompositionPreview.SetImplicitShowAnimation(uix, show); + var hide = CreateAnimationGroup(compositor, false, AnimationDuration); + ElementCompositionPreview.SetImplicitHideAnimation(uix, hide); + } + /// + /// Detach implicit animations from given element. + /// + /// + public static void DetachAnimations(UIElement uix) { + if (!IsSupported) return; + var elementVisual = ElementCompositionPreview.GetElementVisual(uix); + ElementCompositionPreview.SetImplicitShowAnimation(uix, null); + ElementCompositionPreview.SetImplicitHideAnimation(uix, null); + } + #endregion + } +} diff --git a/YetAnotherChartComponent/eScape.Yacc.Demo/Properties/AssemblyInfo.cs b/YetAnotherChartComponent/eScape.Yacc.Demo/Properties/AssemblyInfo.cs index 1ce5932..e250d53 100644 --- a/YetAnotherChartComponent/eScape.Yacc.Demo/Properties/AssemblyInfo.cs +++ b/YetAnotherChartComponent/eScape.Yacc.Demo/Properties/AssemblyInfo.cs @@ -23,6 +23,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.5")] -[assembly: AssemblyFileVersion("1.0.0.5")] +[assembly: AssemblyVersion("1.5.1.*")] +[assembly: AssemblyFileVersion("1.5.1.*")] [assembly: ComVisible(false)] \ No newline at end of file