protected IDataDescriptor GetDataDescriptor(UIElement element)
        {
            string targetName   = Storyboard.GetTargetName(this);
            object targetObject = null;

            if (targetName == null)
            {
                targetObject = element;
            }
            else
            {
                INameScope ns = element.FindNameScope();
                if (ns != null)
                {
                    targetObject = ns.FindName(targetName);
                }
                if (targetObject == null)
                {
                    targetObject = element.FindElement(new NameMatcher(targetName));
                }
                if (targetObject == null)
                {
                    return(null);
                }
            }
            try
            {
                IDataDescriptor result = new ValueDataDescriptor(targetObject);
                if (_propertyExpression != null && _propertyExpression.Evaluate(result, out result))
                {
                    return(result);
                }
            }
            catch (XamlBindingException e)
            {
                ServiceRegistration.Get <ILogger>().Warn("PropertyAnimationTimeline: Error evaluating expression '{0}' on target object '{1}'", e, _propertyExpression, targetObject);
            }
            return(null);
        }
示例#2
0
 /// <summary>
 /// Stops the specified <paramref name="board"/> which runs in the context of the
 /// given <paramref name="element"/>.
 /// </summary>
 /// <param name="board">The storyboard to stop.</param>
 /// <param name="element">Context element on which the <paramref name="board"/> runs.</param>
 public void StopStoryboard(Storyboard board, UIElement element)
 {
   lock (_syncObject)
   {
     AnimationContext context = GetContext(board, element);
     if (context == null) return;
     ResetAllValues(context);
     _scheduledAnimations.Remove(context);
   }
 }
示例#3
0
    /// <summary>
    /// Starts the specified <paramref name="board"/> in the context of the specified
    /// <paramref name="element"/>.
    /// </summary>
    /// <remarks>
    /// Depending on the parameter <paramref name="handoffBehavior"/>, the new storyboard will
    /// be started when the last other storyboard, which occupies a conflicting property,
    /// has finished.
    /// </remarks>
    /// <param name="board">The storyboard to start.</param>
    /// <param name="element">Context element which will be used as
    /// <see cref="TimelineContext.VisualParent"/> for the new <paramref name="board"/>.</param>
    /// <param name="handoffBehavior">Controls how the new storyboard animation will be
    /// attached to already running animations, if there are conflicting properties animated
    /// by an already running anmiation an by the new <paramref name="board"/>.</param>
    public void StartStoryboard(Storyboard board, UIElement element,
        HandoffBehavior handoffBehavior)
    {
      lock (_syncObject)
      {
        AnimationContext context = new AnimationContext
          {
              Timeline = board,
              TimelineContext = board.CreateTimelineContext(element)
          };

        IDictionary<IDataDescriptor, object> conflictingProperties;
        ICollection<AnimationContext> conflictingAnimations;
        FindConflicts(context, out conflictingAnimations, out conflictingProperties);
        ExecuteHandoff(context, conflictingAnimations, handoffBehavior);

        try
        {
          board.Setup(context.TimelineContext, conflictingProperties);

          _scheduledAnimations.Add(context);
          board.Start(context.TimelineContext, SkinContext.SystemTickCount);
        }
        catch (Exception ex)
        {
          ServiceRegistration.Get<ILogger>().Error("Animator: Error initializing StoryBoard", ex);
        }

        // No animation here - has to be done in the Animate method
      }
    }
示例#4
0
 public void StopStoryboard(Storyboard board)
 {
   Screen screen = Screen;
   if (screen == null)
     return;
   screen.Animator.StopStoryboard(board, this);
 }
示例#5
0
 public void StartStoryboard(Storyboard board, HandoffBehavior handoffBehavior)
 {
   Screen screen = Screen;
   if (screen == null)
     return;
   screen.Animator.StartStoryboard(board, this, handoffBehavior);
 }
示例#6
0
    /// <summary>
    /// Starts the specified <paramref name="board"/> in the context of the specified
    /// <paramref name="element"/>.
    /// </summary>
    /// <remarks>
    /// Depending on the parameter <paramref name="handoffBehavior"/>, the new storyboard will
    /// be started when the last other storyboard, which occupies a conflicting property,
    /// has finished.
    /// </remarks>
    /// <param name="board">The storyboard to start.</param>
    /// <param name="element">Context element which will be used as
    /// <see cref="TimelineContext.VisualParent"/> for the new <paramref name="board"/>.</param>
    /// <param name="handoffBehavior">Controls how the new storyboard animation will be
    /// attached to already running animations, if there are conflicting properties animated
    /// by an already running anmiation an by the new <paramref name="board"/>.</param>
    public void StartStoryboard(Storyboard board, UIElement element,
        HandoffBehavior handoffBehavior)
    {
      lock (_syncObject)
      {
        AnimationContext context = new AnimationContext
          {
              Timeline = board,
              TimelineContext = board.CreateTimelineContext(element)
          };

        IDictionary<IDataDescriptor, object> conflictingProperties;
        ICollection<AnimationContext> conflictingAnimations;
        FindConflicts(context, out conflictingAnimations, out conflictingProperties);
        ExecuteHandoff(context, conflictingAnimations, handoffBehavior);

        board.Setup(context.TimelineContext, conflictingProperties);

        _scheduledAnimations.Add(context);
        board.Start(context.TimelineContext, SkinContext.SystemTickCount);

        // No animation here - has to be done in the Animate method
      }
    }
 public override void FinishInitialization(IParserContext context)
 {
     base.FinishInitialization(context);
       string targetProperty = Storyboard.GetTargetProperty(this);
       _propertyExpression = String.IsNullOrEmpty(targetProperty) ? null : PathExpression.Compile(context, targetProperty);
 }