当前位置: 首页>>代码示例>>C#>>正文


C# DoubleAnimationUsingKeyFrames.CreateClock方法代码示例

本文整理汇总了C#中System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames.CreateClock方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleAnimationUsingKeyFrames.CreateClock方法的具体用法?C# DoubleAnimationUsingKeyFrames.CreateClock怎么用?C# DoubleAnimationUsingKeyFrames.CreateClock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames的用法示例。


在下文中一共展示了DoubleAnimationUsingKeyFrames.CreateClock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoubleAnimationKeyFrameRepeatTest

        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));
        }
开发者ID:highzion,项目名称:Granular,代码行数:32,代码来源:DoubleAnimationTest.cs

示例2: CaretElement

		/// <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;
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:43,代码来源:CaretElement.cs

示例3: SetBlinkAnimation

        // Inits or resets an opacity animation used to make the caret blink. 
        private void SetBlinkAnimation(bool visible, bool positionChanged) 
        {
            if (!_isBlinkEnabled) 
            {
                return;
            }
 
            // NB: "Blink" is the period of time between successive
            // state changes in the caret animation.  "Flash" is 
            // 2 * blink, the period of time to transition from 
            // visible, to hidden, to visible again.
            int blinkInterval = Win32GetCaretBlinkTime(); 
            if (blinkInterval > 0) // -1 if the caret shouldn't blink.
            {
                Duration blinkDuration = new Duration(TimeSpan.FromMilliseconds(blinkInterval * 2));
 
                if (_blinkAnimationClock == null || _blinkAnimationClock.Timeline.Duration != blinkDuration)
                { 
                    DoubleAnimationUsingKeyFrames blinkAnimation = new DoubleAnimationUsingKeyFrames(); 
                    blinkAnimation.BeginTime = null;
                    blinkAnimation.RepeatBehavior = RepeatBehavior.Forever; 
                    blinkAnimation.KeyFrames.Add(new DiscreteDoubleKeyFrame(1, KeyTime.FromPercent(0.0)));
                    blinkAnimation.KeyFrames.Add(new DiscreteDoubleKeyFrame(0, KeyTime.FromPercent(0.5)));
                    blinkAnimation.Duration = blinkDuration;
 
                    _blinkAnimationClock = blinkAnimation.CreateClock();
                    _blinkAnimationClock.Controller.Begin(); 
 
                    _caretElement.ApplyAnimationClock(UIElement.OpacityProperty, _blinkAnimationClock);
                } 
            }
            else if (_blinkAnimationClock != null)
            {
                // No blink (control panel option). 
                _caretElement.ApplyAnimationClock(UIElement.OpacityProperty, null);
                _blinkAnimationClock = null; 
            } 

            if (_blinkAnimationClock != null) 
            {
                // Disable the animation when the caret isn't rendered
                // to get better perf.
                if (visible && (!(_blinkAnimationClock.CurrentState == ClockState.Active) || positionChanged)) 
                {
                    // Start the blinking animation for caret 
                    _blinkAnimationClock.Controller.Begin(); 
                }
                else if (!visible) 
                {
                    // Stop the blinking animation if the caret isn't visible even we start it yet.
                    // Because ApplyAnimationClock() calling can start the animation without
                    // the calling of Begin() which case is the auto selection(with DatePicker). 
                    _blinkAnimationClock.Controller.Stop();
                } 
            } 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:57,代码来源:CaretElement.cs

示例4: MoveResourceInBounds

        private void MoveResourceInBounds(ResourceViewModel resourceViewModel)
        {
            Storyboard storyboard = new Storyboard();

            var view = (FrameworkElement)(desktopView.ItemContainerGenerator.ContainerFromItem(resourceViewModel));

            const double offset = 4;

            double left = resourceViewModel.Left;
            double right = left + view.ActualWidth;
            double top = resourceViewModel.Top;
            double bottom = top + view.ActualHeight;

            bool leftOutBound = left < 0;
            bool rightOutBound = right > desktopView.ActualWidth;
            bool topOutBound = top < 0;
            bool bottomOutBound = bottom > desktopView.ActualHeight;

            if (leftOutBound || rightOutBound)
            {
                double from = left;
                double to = (leftOutBound ? offset : (desktopView.ActualWidth - view.ActualWidth - offset));

                DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames()
                {
                    Duration = TimeSpan.FromMilliseconds(125)
                };

                animation.KeyFrames.Add(new SplineDoubleKeyFrame(from, KeyTime.FromTimeSpan(TimeSpan.Zero)));
                animation.KeyFrames.Add(new SplineDoubleKeyFrame(to + ((leftOutBound ? offset : offset * -1) * 2), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(80))));
                animation.KeyFrames.Add(new SplineDoubleKeyFrame(to, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(125))));

                AnimationClock clock = animation.CreateClock();
                clock.CurrentTimeInvalidated += (sender, e) =>
                {
                    double current = animation.GetCurrentValue(from, to, clock);
                    resourceViewModel.Left = current;
                };

                storyboard.Children.Add(animation);

                Storyboard.SetTargetProperty(animation, new PropertyPath(ResourceView.DummyLeftProperty));
            }

            if (topOutBound || bottomOutBound)
            {
                double from = top;
                double to = (topOutBound ? offset : (desktopView.ActualHeight - view.ActualHeight - offset));

                DoubleAnimationUsingKeyFrames animation = new DoubleAnimationUsingKeyFrames()
                {
                    Duration = TimeSpan.FromMilliseconds(125)
                };

                animation.KeyFrames.Add(new SplineDoubleKeyFrame(from, KeyTime.FromTimeSpan(TimeSpan.Zero)));
                animation.KeyFrames.Add(new SplineDoubleKeyFrame(to + ((topOutBound ? offset : offset * -1) * 2), KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(80))));
                animation.KeyFrames.Add(new SplineDoubleKeyFrame(to, KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(125))));

                AnimationClock clock = animation.CreateClock();
                clock.CurrentTimeInvalidated += (sender, e) =>
                {
                    double current = animation.GetCurrentValue(from, to, clock);
                    resourceViewModel.Top = current;
                };

                storyboard.Children.Add(animation);

                Storyboard.SetTargetProperty(animation, new PropertyPath(ResourceView.DummyTopProperty));
            }

            this.BeginStoryboard(storyboard);
        }
开发者ID:nevasion,项目名称:gandi-desktop,代码行数:72,代码来源:DesktopView.xaml.cs


注:本文中的System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames.CreateClock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。