Esempio n. 1
0
 internal static void ApplyInstantAnimation(DependencyObject target, PropertyPath propertyPath, double to, bool isVisualStateChange)
 {
     if (isVisualStateChange)
     {
         propertyPath.INTERNAL_PropertySetVisualState(target, to);
     }
     else
     {
         propertyPath.INTERNAL_PropertySetLocalValue(target, to);
     }
 }
        private void ApplyKeyFrame(DependencyObject target, IterationParameters parameters, PropertyPath propertyPath, Type propertyType, ObjectKeyFrame keyFrame, DispatcherTimer timer)
        {
            if (timer != null)
            {
                timer.Stop();
            }
            _keyFramesToObjectTimers.Remove(keyFrame);
            object value = keyFrame.Value;

            if (value is string && propertyType != typeof(string))
            {
                if (propertyType.IsEnum)
                {
                    value = Enum.Parse(propertyType, (string)value);
                }
                else
                {
                    //we convert the value from the given string:
                    value = DotNetForHtml5.Core.TypeFromStringConverters.ConvertFromInvariantString(propertyType, (string)value);
                }
            }

            var castedValue = DynamicCast(value, propertyType); //Note: we put this line here because the Xaml could use a Color gotten from a StaticResource (which was therefore not converted to a SolidColorbrush by the compiler in the .g.cs file) and led to a wrong type set in a property (Color value in a property of type Brush).

            if (parameters.IsVisualStateChange)
            {
                propertyPath.INTERNAL_PropertySetVisualState(target, castedValue);
            }
            else
            {
                propertyPath.INTERNAL_PropertySetLocalValue(target, castedValue);
            }

            CheckTimeLineEndAndRaiseCompletedEvent(parameters);

            //----------------------------------------
            //todo:clone required ?
            //----------------------------------------
        }