Beispiel #1
0
        /// <summary>
        /// Helper used by the four Freezable clone methods to copy the resolved key times and
        /// key frames. The Get*AsFrozenCore methods are implemented the same as the Clone*Core
        /// methods; Get*AsFrozen at the top level will recursively Freeze so it's not done here.
        /// </summary>
        /// <param name="sourceAnimation"></param>
        /// <param name="isCurrentValueClone"></param>
        private void CopyCommon(RectAnimationUsingKeyFrames sourceAnimation, bool isCurrentValueClone)
        {
            _areKeyTimesValid = sourceAnimation._areKeyTimesValid;

            if (_areKeyTimesValid &&
                sourceAnimation._sortedResolvedKeyFrames != null)
            {
                // _sortedResolvedKeyFrames is an array of ResolvedKeyFrameEntry so the notion of CurrentValueClone doesn't apply
                _sortedResolvedKeyFrames = (ResolvedKeyFrameEntry[])sourceAnimation._sortedResolvedKeyFrames.Clone();
            }

            if (sourceAnimation._keyFrames != null)
            {
                if (isCurrentValueClone)
                {
                    _keyFrames = (RectKeyFrameCollection)sourceAnimation._keyFrames.CloneCurrentValue();
                }
                else
                {
                    _keyFrames = (RectKeyFrameCollection)sourceAnimation._keyFrames.Clone();
                }

                OnFreezablePropertyChanged(null, _keyFrames);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Implementation of <see cref="System.Windows.Freezable.CloneCore(System.Windows.Freezable)">Freezable.CloneCore</see>.
        /// </summary>
        protected override void CloneCore(Freezable sourceFreezable)
        {
            RectAnimationUsingKeyFrames sourceAnimation = (RectAnimationUsingKeyFrames)sourceFreezable;

            base.CloneCore(sourceFreezable);

            CopyCommon(sourceAnimation, /* isCurrentValueClone = */ false);
        }
Beispiel #3
0
        /// <summary>
        /// Implementation of <see cref="System.Windows.Freezable.GetCurrentValueAsFrozenCore(Freezable)">Freezable.GetCurrentValueAsFrozenCore</see>.
        /// </summary>
        protected override void GetCurrentValueAsFrozenCore(Freezable source)
        {
            RectAnimationUsingKeyFrames sourceAnimation = (RectAnimationUsingKeyFrames)source;

            base.GetCurrentValueAsFrozenCore(source);

            CopyCommon(sourceAnimation, /* isCurrentValueClone = */ true);
        }
Beispiel #4
0
        private void UserDrawWPF(DrawingContext dc)
        {
            if (bFound == true)
            {
                VMMainViewModel.Instance.ConvertCoordGroundToPixel(fx, fy, ref PixelX, ref PixelY);
                RectAnimationUsingKeyFrames n = new RectAnimationUsingKeyFrames();
                n.Duration = TimeSpan.FromMilliseconds(700);
                n.RepeatBehavior = RepeatBehavior.Forever;
                n.AutoReverse = true;
                n.KeyFrames.Add(
                new LinearRectKeyFrame(
                    new Rect(new Point(PixelX - 40, PixelY - 40), new Size(80, 80)), // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(350))) // KeyTime
                );

                n.KeyFrames.Add(
                new LinearRectKeyFrame(
                    new Rect(new Point(PixelX - 25, PixelY - 25), new Size(50, 50)), // Target value (KeyValue)
                    KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(700))) // KeyTime
                );

                Rect rect = new Rect(new Point(PixelX - 25, PixelY - 25), new Size(50, 50));
                AnimationClock myClock = n.CreateClock();


                BitmapImage b = new BitmapImage();
                b.BeginInit();
                b.UriSource = new Uri("pack://application:,,,/images/Sight.png");
                b.EndInit();



                dc.DrawImage(b, rect, myClock);

              

            }

        }
        /// <summary>
        /// Helper used by the four Freezable clone methods to copy the resolved key times and 
        /// key frames. The Get*AsFrozenCore methods are implemented the same as the Clone*Core
        /// methods; Get*AsFrozen at the top level will recursively Freeze so it's not done here.
        /// </summary>
        /// <param name="sourceAnimation"></param>
        /// <param name="isCurrentValueClone"></param>
        private void CopyCommon(RectAnimationUsingKeyFrames sourceAnimation, bool isCurrentValueClone)
        {    
            _areKeyTimesValid = sourceAnimation._areKeyTimesValid;

            if (   _areKeyTimesValid 
                && sourceAnimation._sortedResolvedKeyFrames != null)
            {
                // _sortedResolvedKeyFrames is an array of ResolvedKeyFrameEntry so the notion of CurrentValueClone doesn't apply
                _sortedResolvedKeyFrames = (ResolvedKeyFrameEntry[])sourceAnimation._sortedResolvedKeyFrames.Clone(); 
            }

            if (sourceAnimation._keyFrames != null)
            {
                if (isCurrentValueClone)
                {
                    _keyFrames = (RectKeyFrameCollection)sourceAnimation._keyFrames.CloneCurrentValue();
                }
                else
                {
                    _keyFrames = (RectKeyFrameCollection)sourceAnimation._keyFrames.Clone();
                }

                OnFreezablePropertyChanged(null, _keyFrames);
            }
        }