Ejemplo n.º 1
0
        protected void BroadCastAni(DrawingContext drawingContext, float radius, TimeSpan ts)
        {
            if (needAni)
            {
                needAni = false;

                Pen           Stroke = new Pen(Brushes.Blue, 2.0);
                Pen           myPen  = new Pen(Brushes.Blue, 2.0);
                Typeface      Font   = new Typeface(new FontFamily("GenericSansSerif"), FontStyles.Normal, FontWeights.Bold, FontStretches.Normal);
                FormattedText FText  = new FormattedText(Text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Font, FontSize, Foreground);
                DoubleAnimationUsingKeyFrames myAnimation = new DoubleAnimationUsingKeyFrames();
                var keyFrames = myAnimation.KeyFrames;
                keyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(0)));
                keyFrames.Add(new SplineDoubleKeyFrame(radius, TimeSpan.FromSeconds(0.5), new KeySpline(0, 0, 1, 1)));
                keyFrames.Add(new SplineDoubleKeyFrame(0, TimeSpan.FromSeconds(0.5)));
                myAnimation.RepeatBehavior = new RepeatBehavior(ts);

                // Create a clock the for the animation.
                AnimationClock myClock = myAnimation.CreateClock();

                //drawingContext.DrawEllipse(null, Stroke, new Point(Width / 2, Height / 2), Width / 2 + Stroke.Thickness / 2, Height / 2 + Stroke.Thickness / 2);
                //drawingContext.DrawEllipse(Background, null, new Point(Width / 2, Height / 2), Width / 2, Height / 2);
                drawingContext.DrawEllipse(null, myPen, new Point(Width / 2, Height / 2), null, Width / 2, myClock, Height / 2, myClock);
                drawingContext.DrawText(FText, new Point(-FText.Width / 2, -FText.Height));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        public CaretElement(EditorView editorView)
        {
            SizeChangedEventHandler handler = null;

            _editorView                = editorView;
            _caretPlacement            = CaretPlacement.LeftOfCharacter;
            _insertionPoint            = new TextPoint(editorView.TextBuffer, 0);
            _preferredVerticalPosition = _preferredHorizontalPosition = 0;
            _textViewHelper            = new TextViewHelper(_editorView);
            this.ConstructCaretGeometry();
            TextLine line = TextFormatter.Create().FormatLine(new DefaultLineGutterTextSource("W", TextFormattingRunProperties.DefaultProperties), 0, 10, new TextFormattingParagraphProperties(), null);

            _defaultOverwriteCaretWidth  = line.Width;
            _overwriteCaretBrush         = new SolidColorBrush(Colors.Gray);
            _overwriteCaretBrush.Opacity = 0.5;
            DoubleAnimationUsingKeyFrames frames = new DoubleAnimationUsingKeyFrames();

            frames.BeginTime      = new TimeSpan((long)0);
            frames.RepeatBehavior = RepeatBehavior.Forever;
            frames.KeyFrames.Add(new DiscreteDoubleKeyFrame(1, KeyTime.FromPercent(0)));
            Int32 caretBlinkTime = User32.GetCaretBlinkTime();

            if (caretBlinkTime > 0)
            {
                frames.KeyFrames.Add(new DiscreteDoubleKeyFrame(0, KeyTime.FromPercent(0.5)));
            }
            else
            {
                caretBlinkTime = 500;
            }
            frames.Duration      = new Duration(new TimeSpan(0, 0, 0, 0, caretBlinkTime * 2));
            _blinkAnimationClock = frames.CreateClock();
            base.ApplyAnimationClock(UIElement.OpacityProperty, _blinkAnimationClock);
            this.PositionChanged = (EventHandler <CaretPositionChangedEventArgs>)Delegate.Combine(this.PositionChanged, new EventHandler <CaretPositionChangedEventArgs>(this.CaretElement_PositionChanged));
            if (handler == null)
            {
                handler = delegate
                {
                    this.ConstructCaretGeometry();
                };
            }
            base.SizeChanged      += handler;
            base.IsVisibleChanged += new DependencyPropertyChangedEventHandler(this.UIElement_VisibleChanged);
            this.OverwriteMode     = false;
        }
        // Token: 0x06002B31 RID: 11057 RVA: 0x000C51D0 File Offset: 0x000C33D0
        private void SetBlinkAnimation(bool visible, bool positionChanged)
        {
            if (!this._isBlinkEnabled)
            {
                return;
            }
            int num = this.Win32GetCaretBlinkTime();

            if (num > 0)
            {
                Duration duration = new Duration(TimeSpan.FromMilliseconds((double)(num * 2)));
                if (this._blinkAnimationClock == null || this._blinkAnimationClock.Timeline.Duration != duration)
                {
                    DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
                    doubleAnimationUsingKeyFrames.BeginTime      = null;
                    doubleAnimationUsingKeyFrames.RepeatBehavior = RepeatBehavior.Forever;
                    doubleAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, KeyTime.FromPercent(0.0)));
                    doubleAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteDoubleKeyFrame(0.0, KeyTime.FromPercent(0.5)));
                    doubleAnimationUsingKeyFrames.Duration = duration;
                    Timeline.SetDesiredFrameRate(doubleAnimationUsingKeyFrames, new int?(10));
                    this._blinkAnimationClock = doubleAnimationUsingKeyFrames.CreateClock();
                    this._blinkAnimationClock.Controller.Begin();
                    this._caretElement.ApplyAnimationClock(UIElement.OpacityProperty, this._blinkAnimationClock);
                }
            }
            else if (this._blinkAnimationClock != null)
            {
                this._caretElement.ApplyAnimationClock(UIElement.OpacityProperty, null);
                this._blinkAnimationClock = null;
            }
            if (this._blinkAnimationClock != null)
            {
                if (visible && (this._blinkAnimationClock.CurrentState > ClockState.Active || positionChanged))
                {
                    this._blinkAnimationClock.Controller.Begin();
                    return;
                }
                if (!visible)
                {
                    this._blinkAnimationClock.Controller.Stop();
                }
            }
        }
Ejemplo n.º 4
0
        public void DoubleAnimationKeyFrameRepeatTest()
        {
            DoubleAnimationUsingKeyFrames animation;

            animation = new DoubleAnimationUsingKeyFrames();
            animation.KeyFrames.Add(new LinearDoubleKeyFrame {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0
            });
            animation.KeyFrames.Add(new LinearDoubleKeyFrame {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)), Value = 1
            });
            animation.Duration       = new Duration(TimeSpan.FromSeconds(2));
            animation.RepeatBehavior = RepeatBehavior.Forever;

            TestRootClock          rootClock = new TestRootClock();
            AnimationTimelineClock clock     = (AnimationTimelineClock)animation.CreateClock();

            clock.Begin(rootClock);

            rootClock.Tick(TimeSpan.FromSeconds(0.1));
            Assert.AreEqual(0.1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(0.9));
            Assert.AreEqual(0.9, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1));
            Assert.AreEqual(1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(1.9));
            Assert.AreEqual(1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.1));
            Assert.AreEqual(0.1, (double)animation.GetCurrentValue(0.0, 0.0, clock));

            rootClock.Tick(TimeSpan.FromSeconds(2.9));
            Assert.AreEqual(0.9, (double)animation.GetCurrentValue(0.0, 0.0, clock));
        }
Ejemplo n.º 5
0
        private void beginPanZoom(Image image, List <Keyframe> keys)
        {
            var iw = image.ActualWidth;
            var ih = image.ActualHeight;

            TimeSpan duration        = TimeSpan.FromSeconds(keys.Sum(k => k.duration));
            TimeSpan partialDuration = TimeSpan.FromSeconds(0);
            var      animZoom        = new DoubleAnimationUsingKeyFrames();

            animZoom.Duration = duration;
            var animCtrX = new DoubleAnimationUsingKeyFrames();

            animCtrX.Duration = duration;
            var animCtrY = new DoubleAnimationUsingKeyFrames();

            animCtrY.Duration = duration;
            var animPanX = new DoubleAnimationUsingKeyFrames();

            animPanX.Duration = duration;
            var animPanY = new DoubleAnimationUsingKeyFrames();

            animPanY.Duration = duration;

            animPanY.Completed += new EventHandler(endPanZoom);

            keys.ForEach(key =>
            {
                partialDuration += TimeSpan.FromSeconds(key.duration);
                KeyTime kt       = KeyTime.FromTimeSpan(partialDuration);
                animZoom.KeyFrames.Add(new EasingDoubleKeyFrame(key.zoomFactor, kt, easeInOut));
                animCtrX.KeyFrames.Add(new EasingDoubleKeyFrame(iw / 2, kt, easeInOut));
                animCtrY.KeyFrames.Add(new EasingDoubleKeyFrame(ih / 2, kt, easeInOut));
                animPanX.KeyFrames.Add(new EasingDoubleKeyFrame((0.5 - key.x) * iw, kt, easeInOut));
                animPanY.KeyFrames.Add(new EasingDoubleKeyFrame((0.5 - key.y) * ih, kt, easeInOut));
            });

            AnimationClock zClock  = animZoom.CreateClock();
            AnimationClock cxClock = animCtrX.CreateClock();
            AnimationClock cyClock = animCtrY.CreateClock();
            AnimationClock pxClock = animPanX.CreateClock();
            AnimationClock pyClock = animPanY.CreateClock();

            currentClocks.Clear();
            currentClocks.Add(zClock);
            currentClocks.Add(cxClock);
            currentClocks.Add(cyClock);
            currentClocks.Add(pxClock);
            currentClocks.Add(pyClock);

            currentClocks.ForEach(c =>
            {
                c.Controller.SpeedRatio = speedFactor;
            });

            var tg = (TransformGroup)image.RenderTransform;

            tg.Children[0].ApplyAnimationClock(TranslateTransform.XProperty, pxClock);
            tg.Children[0].ApplyAnimationClock(TranslateTransform.YProperty, pyClock);
            tg.Children[1].ApplyAnimationClock(ScaleTransform.ScaleXProperty, zClock);
            tg.Children[1].ApplyAnimationClock(ScaleTransform.ScaleYProperty, zClock);
            tg.Children[1].ApplyAnimationClock(ScaleTransform.CenterXProperty, cxClock);
            tg.Children[1].ApplyAnimationClock(ScaleTransform.CenterYProperty, cyClock);

            status.Text       = " " + (currentSlideIndex + 1).ToString() + " of " + slides.Count + " ";
            status.Visibility = Visibility.Visible;
            timer.Visibility  = Visibility.Visible;
            animationState    = PAN_ZOOM;
        }