internal static void ApplyInitialSettings(this FrameworkElement element, AnimationSettings settings) { var group = new AnimationGroup(); var visual = ElementCompositionPreview.GetElementVisual(element); visual.CenterPoint = element.GetTransformCenter(settings); if (settings.Opacity != 1) { visual.Opacity = (float)settings.Opacity; } if (settings.OffsetX != Offset.Empty || settings.OffsetY != Offset.Empty || settings.OffsetZ != 0) { visual.Properties.InsertVector3( TargetProperties.Translation, new Vector3( (float)settings.OffsetX.GetCalculatedOffset(element, OffsetTarget.X), (float)settings.OffsetY.GetCalculatedOffset(element, OffsetTarget.Y), (float)settings.OffsetZ)); } if (settings.Rotation != 0) { visual.RotationAngleInDegrees = (float)settings.Rotation; } if (settings.ScaleX != 1 || settings.ScaleY != 1 || settings.ScaleZ != 1) { visual.Scale = new Vector3((float)settings.ScaleX, (float)settings.ScaleY, (float)settings.ScaleZ); } if (settings.BlurRadius != 0 || settings.Saturation != AnimationSettings.DEFAULT_SATURATION || settings.Tint != AnimationSettings.DEFAULT_TINT) { var initialSettings = new AnimationSettings() { BlurRadius = settings.BlurRadius, Saturation = settings.Saturation, Tint = settings.Tint, Duration = 1 }; if (settings.BlurRadius != 0) { BlurTo(element, initialSettings, ref group); } if (settings.Saturation != AnimationSettings.DEFAULT_SATURATION) { SaturateTo(element, initialSettings, ref group); } if (settings.Tint != AnimationSettings.DEFAULT_TINT) { TintTo(element, initialSettings, ref group); } } group.Begin(); }
internal static void ApplyInitialSettings(this FrameworkElement element, AnimationSettings settings) { var group = new AnimationGroup(); var visual = ElementCompositionPreview.GetElementVisual(element); if (settings.Opacity != 1) { visual.Opacity = (float)settings.Opacity; } if (settings.OffsetX != 0 || settings.OffsetY != 0) { visual.Properties.InsertVector3(Constants.TargetProperties.Translation, new Vector3((float)settings.OffsetX, (float)settings.OffsetY, (float)settings.OffsetZ)); } if (settings.Rotation != 0) { visual.RotationAngleInDegrees = (float)settings.Rotation; } if (settings.ScaleX != 1 || settings.ScaleY != 1) { visual.Scale = new Vector3((float)settings.ScaleX, (float)settings.ScaleY, (float)settings.ScaleZ); } if (settings.BlurRadius != 0) { // TODO: Can we directly set the values instead of animating... var initialSettings = new AnimationSettings() { BlurRadius = settings.BlurRadius, Duration = 1 }; BlurTo(element, initialSettings, ref group); } group.Begin(); }