示例#1
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            var delta = DateTime.Now - Started;

            if (delta >= Duration)
            {
                if (Loop)
                {
                    Started = DateTime.Now;
                }
                else
                {
                    System.Windows.Media.CompositionTarget.Rendering -= CompositionTarget_Rendering;
                    Animator(1);
                    IsAnimating = false;
                }

                CompletedAction?.Invoke();
                Completed?.Invoke(this, new EventArgs());
            }
            else
            {
                Animator(delta.TotalMilliseconds / Duration.TotalMilliseconds);
            }
        }
示例#2
0
        public void Stop()
        {
            System.Windows.Media.CompositionTarget.Rendering -= CompositionTarget_Rendering;

            if (IsAnimating)
            {
                CompletedAction?.Invoke();
                Completed?.Invoke(this, new EventArgs());
                IsAnimating = false;
            }
        }