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


C# Storyboard.Freeze方法代码示例

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


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

示例1: UpdateIndeterminateAnimation

        private void UpdateIndeterminateAnimation()
        {
            if ((IndeterminateAnimation == null || (IndeterminateAnimation != null && IndeterminateAnimation.Name == DefaultIndeterminateAnimationName)) && Track != null && _arc != null)
            {
                if (IndeterminateAnimation != null && IsIndeterminateAnimationRunning)
                {
                    IsIndeterminateAnimationRunning = false;
                    IndeterminateAnimation.Stop(this);
                    IndeterminateAnimation.Remove(this);
                }

                IndeterminateAnimation = new Storyboard { Name = DefaultIndeterminateAnimationName, RepeatBehavior = RepeatBehavior.Forever };

                var trackSize = Math.Min(Track.ActualWidth, Track.ActualHeight);

                var time = (trackSize * Math.PI) / 100;

                var startAngleSetValueAnimation = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0d)));

                Storyboard.SetTarget(startAngleSetValueAnimation, _arc);
                Storyboard.SetTargetProperty(startAngleSetValueAnimation, new PropertyPath(Arc.StartAngleProperty));

                var endAngleSetValueAnimation = new DoubleAnimation(-270, new Duration(TimeSpan.FromSeconds(0d)));

                Storyboard.SetTarget(endAngleSetValueAnimation, _arc);
                Storyboard.SetTargetProperty(endAngleSetValueAnimation, new PropertyPath(Arc.EndAngleProperty));

                var startAngleAnimation = new DoubleAnimationUsingKeyFrames();
                // NOTE: Lack of contracts: DoubleAnimationUsingKeyFrames.KeyFrames is always have collection instance
                Contract.Assume(startAngleAnimation.KeyFrames != null);
                startAngleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(360, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(time))));

                Storyboard.SetTarget(startAngleAnimation, _arc);
                Storyboard.SetTargetProperty(startAngleAnimation, new PropertyPath(Arc.StartAngleProperty));

                var endAngleAnimation = new DoubleAnimationUsingKeyFrames();
                // NOTE: Lack of contracts: DoubleAnimationUsingKeyFrames.KeyFrames is always have collection instance
                Contract.Assume(endAngleAnimation.KeyFrames != null);
                endAngleAnimation.KeyFrames.Add(new EasingDoubleKeyFrame(90, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(time))));

                Storyboard.SetTarget(endAngleAnimation, _arc);
                Storyboard.SetTargetProperty(endAngleAnimation, new PropertyPath(Arc.EndAngleProperty));

                // NOTE: Lack of contracts
                Contract.Assume(IndeterminateAnimation != null);
                Contract.Assume(IndeterminateAnimation.Children != null);

                IndeterminateAnimation.Children.Add(startAngleSetValueAnimation);
                IndeterminateAnimation.Children.Add(endAngleSetValueAnimation);
                IndeterminateAnimation.Children.Add(startAngleAnimation);
                IndeterminateAnimation.Children.Add(endAngleAnimation);

                if (IndeterminateAnimation.CanFreeze)
                {
                    IndeterminateAnimation.Freeze();
                }

                if (State == ProgressState.Indeterminate && IsEnabled)
                {
                    IndeterminateAnimation.Begin(this, Template, true);
                    IsIndeterminateAnimationRunning = true;
                }
            }
        }
开发者ID:oysteinkrog,项目名称:MonitorControl,代码行数:64,代码来源:ProgressRing.cs

示例2: UpdateIndeterminateAnimation

        private void UpdateIndeterminateAnimation()
        {
            if ((IndeterminateAnimation == null || (IndeterminateAnimation != null && IndeterminateAnimation.Name == DefaultIndeterminateAnimationName)) && Track != null && _indicator != null)
            {
                if (IndeterminateAnimation != null && IsIndeterminateAnimationRunning)
                {
                    IsIndeterminateAnimationRunning = false;
                    IndeterminateAnimation.Stop(this);
                    IndeterminateAnimation.Remove(this);
                }

                IndeterminateAnimation = new Storyboard { Name = DefaultIndeterminateAnimationName, RepeatBehavior = RepeatBehavior.Forever };

                var indicatorSize = Orientation == Orientation.Horizontal ? _indicator.Width : _indicator.Height;

                var trackSize = Orientation == Orientation.Horizontal ? Track.ActualWidth : Track.ActualHeight;

                var time = trackSize / 100;

                var animation = new DoubleAnimationUsingKeyFrames { Duration = new Duration(TimeSpan.FromSeconds(time + 0.5)) };
                // NOTE: Lack of contracts: DoubleAnimationUsingKeyFrames.KeyFrames is always have collection instance
                Contract.Assume(animation.KeyFrames != null);
                animation.KeyFrames.Add(new DiscreteDoubleKeyFrame(-indicatorSize - 1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0))));
                animation.KeyFrames.Add(new LinearDoubleKeyFrame(trackSize + 1, KeyTime.FromTimeSpan(TimeSpan.FromSeconds(time))));

                Storyboard.SetTarget(animation, _indicator);
                Storyboard.SetTargetProperty(animation,
                                             new PropertyPath(Orientation == Orientation.Horizontal ? Canvas.LeftProperty : Canvas.TopProperty));

                // NOTE: Lack of contracts
                Contract.Assume(IndeterminateAnimation != null);
                Contract.Assume(IndeterminateAnimation.Children != null);
                IndeterminateAnimation.Children.Add(animation);

                if (IndeterminateAnimation.CanFreeze)
                {
                    IndeterminateAnimation.Freeze();
                }

                if (State == ProgressState.Indeterminate && IsEnabled)
                {
                    IndeterminateAnimation.Begin(this, Template, true);
                    IsIndeterminateAnimationRunning = true;
                }
            }
        }
开发者ID:oysteinkrog,项目名称:MonitorControl,代码行数:46,代码来源:ProgressBar.cs

示例3: UpdateBusyAnimation


//.........这里部分代码省略.........
                BusyAnimation = new Storyboard { Name = DefaultBusyAnimationName, RepeatBehavior = RepeatBehavior.Forever };

                var firstCycleAnimations = new Collection<DoubleAnimation>();
                var secondCycleAnimations = new Collection<DoubleAnimation>();

                const double time = 0.25;
                const double durationTime = time * 2;
                const double beginTimeIncrement = time / 2;
                const double shortPauseTime = time;
                const double longPauseTime = time * 1.5;
                var partMotionTime = (_busyBar.Children.Count - 1) * beginTimeIncrement + durationTime + shortPauseTime;

                var length = Math.Min(Track.ActualWidth, Track.ActualHeight) * Math.PI;

                for (var i = 0; i < _busyBar.Children.Count; i++)
                {
                    var element = (FrameworkElement)_busyBar.Children[_busyBar.Children.Count - i - 1];
                    if (element != null)
                    {
                        var elementLength = Math.Max(element.Width, element.Height);

                        var index = (_busyBar.Children.Count - 1) / 2 - i;

                        var endPosition = length / 2 + index * (elementLength * 2);
                        var endAngle = endPosition / length * 360d;

                        var duration = new Duration(TimeSpan.FromSeconds(durationTime));

                        var firstCycleAnimation =
                            new DoubleAnimation(0d, endAngle, duration) { BeginTime = TimeSpan.FromSeconds(i * beginTimeIncrement) };
                        Storyboard.SetTarget(firstCycleAnimation, element);
                        Storyboard.SetTargetProperty(firstCycleAnimation, new PropertyPath(AngleProperty));

                        var secondCycleAnimation =
                            new DoubleAnimation(0d, endAngle, duration)
                                { BeginTime = TimeSpan.FromSeconds(partMotionTime + durationTime + i * beginTimeIncrement) };
                        Storyboard.SetTarget(secondCycleAnimation, element);
                        Storyboard.SetTargetProperty(secondCycleAnimation, new PropertyPath(AngleProperty));

                        firstCycleAnimations.Add(firstCycleAnimation);
                        secondCycleAnimations.Add(secondCycleAnimation);
                    }
                }

                for (var i = 0; i < _busyBar.Children.Count; i++)
                {
                    var element = (FrameworkElement)_busyBar.Children[_busyBar.Children.Count - i - 1];
                    if (element != null)
                    {
                        var duration = new Duration(TimeSpan.FromSeconds(durationTime));

                        var firstCycleAnimation =
                            new DoubleAnimation(360d, duration) { BeginTime = TimeSpan.FromSeconds(partMotionTime + i * beginTimeIncrement) };
                        Storyboard.SetTarget(firstCycleAnimation, element);
                        Storyboard.SetTargetProperty(firstCycleAnimation, new PropertyPath(AngleProperty));

                        var secondCycleAnimation =
                            new DoubleAnimation(360d, duration)
                                { BeginTime = TimeSpan.FromSeconds(partMotionTime * 2 + durationTime + i * beginTimeIncrement) };
                        Storyboard.SetTarget(secondCycleAnimation, element);
                        Storyboard.SetTargetProperty(secondCycleAnimation, new PropertyPath(AngleProperty));

                        var moveAnimation =
                            new DoubleAnimation(-1.0, new Duration(TimeSpan.FromSeconds(0)))
                                { BeginTime = TimeSpan.FromSeconds(partMotionTime * 2 + durationTime * 2 + i * beginTimeIncrement) };
                        Storyboard.SetTarget(moveAnimation, element);
                        Storyboard.SetTargetProperty(moveAnimation, new PropertyPath(AngleProperty));

                        firstCycleAnimations.Add(firstCycleAnimation);
                        secondCycleAnimations.Add(secondCycleAnimation);
                        secondCycleAnimations.Add(moveAnimation);
                    }
                }

                BusyAnimation.Duration = new Duration(TimeSpan.FromSeconds(longPauseTime + partMotionTime * 3 + shortPauseTime * 2 + durationTime));

                // NOTE: Lack of contracts: Children always have collection instance
                Contract.Assume(BusyAnimation.Children != null);
                foreach (var animation in firstCycleAnimations)
                {
                    BusyAnimation.Children.Add(animation);
                }

                foreach (var animation in secondCycleAnimations)
                {
                    BusyAnimation.Children.Add(animation);
                }

                if (BusyAnimation.CanFreeze)
                {
                    BusyAnimation.Freeze();
                }

                if (State == ProgressState.Busy && IsEnabled)
                {
                    BusyAnimation.Begin(this, Template, true);
                    IsBusyAnimationRunning = true;
                }
            }
        }
开发者ID:oysteinkrog,项目名称:MonitorControl,代码行数:101,代码来源:ProgressRing.cs

示例4: UpdateBusyAnimation

        private void UpdateBusyAnimation()
        {
            if ((BusyAnimation == null || (BusyAnimation != null && BusyAnimation.Name == DefaultBusyAnimationName)) && Track != null && _busyBar != null)
            {
                if (BusyAnimation != null && IsBusyAnimationRunning)
                {
                    IsBusyAnimationRunning = false;
                    BusyAnimation.Stop(this);
                    BusyAnimation.Remove(this);
                }

                // NOTE: Lack of contracts: Children always have collection instance
                Contract.Assume(_busyBar.Children != null);

                BusyAnimation = new Storyboard { Name = DefaultBusyAnimationName, RepeatBehavior = RepeatBehavior.Forever };

                const double time = 0.25;
                const double durationTime = time * 2;
                const double beginTimeIncrement = time / 2;
                const double shortPauseTime = time;
                const double longPauseTime = time * 1.5;
                var partMotionTime = (_busyBar.Children.Count - 1) * beginTimeIncrement + durationTime;

                var busyAnimations = new Collection<DoubleAnimation>();

                var width = Track.ActualWidth;
                var height = Track.ActualHeight;

                for (var i = 0; i < _busyBar.Children.Count; i++)
                {
                    var element = (FrameworkElement)_busyBar.Children[_busyBar.Children.Count - i - 1];

                    if (element != null)
                    {
                        var elementWidth = element.Width;
                        var elementHeight = element.Height;

                        var index = (_busyBar.Children.Count - 1) / 2 - i;

                        var center = (Orientation == Orientation.Horizontal ? width : height) / 2;
                        var margin = Orientation == Orientation.Horizontal ? elementWidth : elementHeight;

                        var startPosition = -(Orientation == Orientation.Horizontal ? elementWidth : elementHeight) - 1;
                        var endPosition = center + index * ((Orientation == Orientation.Horizontal ? elementWidth : elementHeight) + margin);

                        var duration = new Duration(TimeSpan.FromSeconds(durationTime));
                        var animation = new DoubleAnimation(startPosition, endPosition, duration) { BeginTime = TimeSpan.FromSeconds(i * beginTimeIncrement) };
                        Storyboard.SetTarget(animation, element);
                        Storyboard.SetTargetProperty(animation,
                                                     new PropertyPath(Orientation == Orientation.Horizontal ? Canvas.LeftProperty : Canvas.TopProperty));

                        busyAnimations.Add(animation);
                    }
                }

                for (var i = 0; i < _busyBar.Children.Count; i++)
                {
                    var element = (FrameworkElement)_busyBar.Children[_busyBar.Children.Count - i - 1];

                    if (element != null)
                    {
                        var elementWidth = element.Width;
                        var elementHeight = element.Height;

                        var endPosition = (Orientation == Orientation.Horizontal ? width : height) +
                                          (Orientation == Orientation.Horizontal ? elementWidth : elementHeight) + 1;

                        var duration = new Duration(TimeSpan.FromSeconds(durationTime));
                        var animation = new DoubleAnimation(endPosition, duration) { BeginTime = TimeSpan.FromSeconds(partMotionTime + shortPauseTime + i * beginTimeIncrement) };
                        Storyboard.SetTarget(animation, element);
                        Storyboard.SetTargetProperty(animation,
                                                     new PropertyPath(Orientation == Orientation.Horizontal ? Canvas.LeftProperty : Canvas.TopProperty));

                        busyAnimations.Add(animation);
                    }
                }

                BusyAnimation.Duration = new Duration(TimeSpan.FromSeconds(partMotionTime * 2 + shortPauseTime + longPauseTime));

                // NOTE: Lack of contracts: Children always have collection instance
                Contract.Assume(BusyAnimation.Children != null);
                foreach (var animation in busyAnimations)
                {
                    BusyAnimation.Children.Add(animation);
                }

                if (BusyAnimation.CanFreeze)
                {
                    BusyAnimation.Freeze();
                }

                if (State == ProgressState.Busy && IsEnabled)
                {
                    BusyAnimation.Begin(this, Template, true);
                    IsBusyAnimationRunning = true;
                }
            }
        }
开发者ID:oysteinkrog,项目名称:MonitorControl,代码行数:98,代码来源:ProgressBar.cs

示例5: SlideInMinimize

        void SlideInMinimize(DockPosition dockPosition, ActionQueueCallback completeCallback)
        {
            Log.DebugFormat("SlideInMinimize {0}", dockPosition);

            //ClearAnimations();

            DoubleAnimation widthAnimation, heightAnimation, leftAnimation, topAnimation;
            Position position = CalculateSlideInPosition(dockPosition);

            // No point doing the sliding animation when the size of the window hasn't actually changed.
            if (!HasPositionChanged(position))
            {
                Log.Debug("Window size has not changed significantly, cancelling sliding animation");
                completeCallback();
                return;
            }

            Storyboard storyBoard = new Storyboard();
            storyBoard.Duration = SlideDuration;
            storyBoard.Completed += (sender, e) =>
            {
                Position minimizedPosition = new Position();
                _appbar.Resize(ref minimizedPosition);

                DispatcherHelper.UIDispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                    {
                        Left = position.Left;
                        Top = position.Top;
                        Width = position.Width;
                        Height = position.Height;

                        Log.DebugFormat("SlideInMinimize Finished, MainGrid {0}", GetMainGridPosition());
                        completeCallback();
                    }));
            };

            switch (dockPosition.Selected)
            {
                case DockEdge.Left:
                    widthAnimation = CreateGridDoubleAnimation(Grid.WidthProperty);
                    widthAnimation.To = 0;
                    storyBoard.Children.Add(widthAnimation);
                    break;
                case DockEdge.Right:
                    widthAnimation = CreateGridDoubleAnimation(Grid.WidthProperty);
                    widthAnimation.To = 0;
                    storyBoard.Children.Add(widthAnimation);

                    leftAnimation = CreateGridDoubleAnimation(Canvas.LeftProperty);
                    leftAnimation.To = position.Width;
                    storyBoard.Children.Add(leftAnimation);
                    break;
                case DockEdge.Top:
                    heightAnimation = CreateGridDoubleAnimation(Grid.HeightProperty);
                    heightAnimation.To = 0;
                    storyBoard.Children.Add(heightAnimation);
                    break;
                case DockEdge.Bottom:
                    heightAnimation = CreateGridDoubleAnimation(Grid.HeightProperty);
                    heightAnimation.To = 0;
                    storyBoard.Children.Add(heightAnimation);

                    topAnimation = CreateGridDoubleAnimation(Canvas.TopProperty);
                    heightAnimation.To = position.Height;
                    storyBoard.Children.Add(topAnimation);
                    break;
            }

            storyBoard.Freeze();
            storyBoard.Begin(_mainGrid);
        }
开发者ID:notsonormal,项目名称:AstoundingDock,代码行数:71,代码来源:DockWindow.cs

示例6: OnIsOpenChanged

        protected virtual void OnIsOpenChanged(bool oldIsOpen, bool newIsOpen)
        {
            if (newIsOpen && !oldIsOpen)
            {
                IsOpening = true;

                OnOpening(new RoutedEventArgs(OpeningEvent, this));

                if (TransitionMode == ApplicationBarTransitionMode.None)
                {
                    Mouse.Capture(this, CaptureMode.SubTree);

                    _isOpen = true;
                    InvalidateArrange();

                    OnOpened(new RoutedEventArgs(OpenedEvent, this));

                    IsOpening = false;
                }
                else
                {
                    var storyboard = new Storyboard
                                         {
                                             FillBehavior = FillBehavior.Stop
                                         };

                    Timeline animation;
                    switch (TransitionMode)
                    {
                        case ApplicationBarTransitionMode.Fade:
                            animation = new DoubleAnimation(0d, 1d, General.GetMinimumDuration(this));
                            Storyboard.SetTarget(animation, this);
                            Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity"));
                            // NOTE: Lack of contracts
                            Contract.Assume(storyboard.Children != null);
                            storyboard.Children.Add(animation);
                            break;
                        case ApplicationBarTransitionMode.Slide:
                            animation = new DoubleAnimation(0d, DesiredSize.Height, General.GetMinimumDuration(this));
                            Storyboard.SetTarget(animation, this);
                            Storyboard.SetTargetProperty(animation, new PropertyPath("Height"));
                            // NOTE: Lack of contracts
                            Contract.Assume(storyboard.Children != null);
                            storyboard.Children.Add(animation);
                            break;
                    }

                    storyboard.Completed += (sender, e) =>
                    {
                        storyboard.Stop(this);
                        storyboard.Remove(this);

                        OnOpened(new RoutedEventArgs(OpenedEvent, this));

                        IsOpening = false;
                    };

                    if (!StaysOpen)
                    {
                        Mouse.Capture(this, CaptureMode.SubTree);
                    }

                    storyboard.Freeze();
                    storyboard.Begin(this, true);

                    _isOpen = true;
                    InvalidateArrange();
                }
            }
            if (!newIsOpen && oldIsOpen)
            {
                IsClosing = true;

                OnClosing(new RoutedEventArgs(ClosingEvent, this));

                if (TransitionMode == ApplicationBarTransitionMode.None)
                {
                    Mouse.Capture(null);

                    _isOpen = false;
                    InvalidateArrange();

                    OnClosed(new RoutedEventArgs(ClosedEvent, this));

                    IsClosing = false;
                }
                else
                {
                    var storyboard = new Storyboard
                                         {
                                             FillBehavior = FillBehavior.Stop
                                         };

                    Timeline animation;
                    switch (TransitionMode)
                    {
                        case ApplicationBarTransitionMode.Fade:
                            animation = new DoubleAnimation(1d, 0d, General.GetMinimumDuration(this));
                            Storyboard.SetTarget(animation, this);
                            Storyboard.SetTargetProperty(animation, new PropertyPath("Opacity"));
//.........这里部分代码省略.........
开发者ID:oysteinkrog,项目名称:MonitorControl,代码行数:101,代码来源:ApplicationBar.cs

示例7: Init

        private void Init()
        {
            storyboard = new Storyboard();
            storyboard.Duration = new Duration(TimeSpan.FromMilliseconds(1000));
            storyboard.RepeatBehavior = RepeatBehavior.Forever;

            var animation = new DoubleAnimation();

            animation.From = 0;
            animation.To = 360;

            animation.Duration = storyboard.Duration;
            animation.RepeatBehavior = storyboard.RepeatBehavior;

            Storyboard.SetTarget(animation, canvas);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)"));

            storyboard.Children.Add(animation);

            animation.Freeze();
            storyboard.Freeze();
        }
开发者ID:TrakHound,项目名称:TrakHound-Community,代码行数:22,代码来源:Spinner.xaml.cs

示例8: CreateEmptyStoryboard

 private static Storyboard CreateEmptyStoryboard()
 {
     var storyboard = new Storyboard { FillBehavior = FillBehavior.Stop };
     if (storyboard.CanFreeze)
     {
         storyboard.Freeze();
     }
     return storyboard;
 }
开发者ID:JohanLarsson,项目名称:Gu.Wpf.FlipView,代码行数:9,代码来源:TransitionControl.cs


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