Example #1
0
 public void FncOpenTabStrip(bool open)
 {
     try
     {
         if (open)
         {
             if (_RowDefinition0 != null)
             {
                 VMukti.Presentation.GridLengthAnimation gla = new VMukti.Presentation.GridLengthAnimation();
                 gla.From     = new GridLength(0, GridUnitType.Pixel);
                 gla.To       = new GridLength(30, GridUnitType.Pixel);
                 gla.Duration = new Duration(TimeSpan.FromSeconds(0.50));
                 _RowDefinition0.BeginAnimation(RowDefinition.HeightProperty, gla);
             }
         }
         else
         {
             if (_RowDefinition0 != null)
             {
                 VMukti.Presentation.GridLengthAnimation gla = new VMukti.Presentation.GridLengthAnimation();
                 gla.From     = new GridLength(30, GridUnitType.Pixel);
                 gla.To       = new GridLength(0, GridUnitType.Pixel);
                 gla.Duration = new Duration(TimeSpan.FromSeconds(0.50));
                 _RowDefinition0.BeginAnimation(RowDefinition.HeightProperty, gla);
             }
         }
     }
     catch (Exception ex)
     {
         VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "FncOpenTabStrip()", "Controls\\VMuktiGrid\\Tab\\TabControl.cs");
     }
 }
Example #2
0
        public static void AnimateRow(RowDefinition row, GridLength from, GridLength to, double duration = 500, Action postAction = null)
        {
            var animation = new GridLengthAnimation();

            animation.Duration = TimeSpan.FromMilliseconds(duration);

            animation.From = from;
            animation.To   = to;

            //https://docs.microsoft.com/en-us/dotnet/framework/wpf/graphics-multimedia/easing-functions
            var ef = new CubicEase();

            ef.EasingMode            = EasingMode.EaseOut;
            animation.EasingFunction = ef;

            animation.FillBehavior = FillBehavior.Stop;
            //row.Height = animation.To;

            animation.Completed += (s, e) =>
            {
                row.Height = to;
                if (postAction != null)
                {
                    postAction();
                }
            };

            row.BeginAnimation(RowDefinition.HeightProperty, animation);
        }
Example #3
0
        private void AnimateMaxHeight(RowDefinition rowDefinition, double from, double to, double duration)
        {
            rowDefinition.BeginAnimation(RowDefinition.MaxHeightProperty, null);
            if (duration < MinimumDuration)
            {
                duration = MinimumDuration;
            }

            var storyboard = new Storyboard();

            var animationDuration = new Duration(TimeSpan.FromMilliseconds(duration));
            var ease = new CubicEase {
                EasingMode = EasingMode.EaseOut
            };

            var animation = new DoubleAnimation {
                EasingFunction = ease, Duration = animationDuration
            };

            storyboard.Children.Add(animation);
            animation.From = from;
            animation.To   = to;
            Storyboard.SetTarget(animation, rowDefinition);
            Storyboard.SetTargetProperty(animation, new PropertyPath("(RowDefinition.MaxHeight)"));

            storyboard.Completed += OnRowMaxHeightAnimationCompleted;

            storyboard.Begin();
        }
        public static void AnimateTo(this RowDefinition row, double pixelValue, TimeSpan duration)
        {
            GridLengthAnimation heightAnim = new GridLengthAnimation()
            {
                To       = pixelValue,
                Duration = new Duration(duration)
            };

            row.BeginAnimation(RowDefinition.HeightProperty, heightAnim);
        }
        private void AnimateGridLength(RowDefinition rowDef, GridLength toLength)
        {
            GridLengthAnimation PrecTopAnim = new GridLengthAnimation();

            PrecTopAnim.GridUnitType      = GridUnitType.Pixel;
            PrecTopAnim.From              = rowDef.Height;
            PrecTopAnim.To                = toLength;
            PrecTopAnim.Duration          = new Duration(new TimeSpan(0, 0, 0, 0, 300));
            PrecTopAnim.AccelerationRatio = 0.1;
            PrecTopAnim.DecelerationRatio = 0.9;
            rowDef.BeginAnimation(RowDefinition.HeightProperty, PrecTopAnim);
        }
        /// <summary>
        /// Animate expand/collapse of a grid row.
        /// </summary>
        /// <param name="gridRow">The grid row to expand/collapse.</param>
        /// <param name="expandedHeight">The expanded height.</param>
        /// <param name="collapsedHeight">The collapesed height.</param>
        /// <param name="minHeight">The minimum height.</param>
        /// <param name="milliseconds">The milliseconds component of the duration.</param>
        /// <param name="seconds">The seconds component of the duration.</param>
        /// <param name="expand">If true, expand, otherwise collapse.</param>
        public static void AnimateGridRowExpandCollapse(RowDefinition gridRow, bool expand, double expandedHeight, double collapsedHeight, double minHeight, TimeSpan duration)
        {
            if (expand && gridRow.ActualHeight >= expandedHeight)
            {
                // It's as high as it needs to be.
                return;
            }

            if (!expand && gridRow.ActualHeight == collapsedHeight)
            {
                // It's already collapsed.
                return;
            }

            Storyboard storyBoard = new Storyboard();

            GridLengthAnimation animation = new GridLengthAnimation();

            animation.From     = new GridLength(gridRow.ActualHeight);
            animation.To       = new GridLength(expand ? expandedHeight : collapsedHeight);
            animation.Duration = duration;

            // Set delegate that will fire on completioon.
            animation.Completed += delegate
            {
                // Set the animation to null on completion. This allows the grid to be resized manually
                gridRow.BeginAnimation(RowDefinition.HeightProperty, null);

                // Set the final height.
                gridRow.Height = new GridLength(expand ? expandedHeight : collapsedHeight);

                // Set the minimum height.
                gridRow.MinHeight = minHeight;
            };

            storyBoard.Children.Add(animation);

            Storyboard.SetTarget(animation, gridRow);
            Storyboard.SetTargetProperty(animation, new PropertyPath(RowDefinition.HeightProperty));
            storyBoard.Children.Add(animation);

            // Begin the animation.
            storyBoard.Begin();
        }
        public void ToggleHeightAnimation()
        {
            GridLengthAnimation a = new GridLengthAnimation();

            if (row.ActualHeight == 0)
            {
                // Going up
                a.From     = new GridLength(0, GridUnitType.Pixel);
                a.To       = SaveHeight;
                a.Duration = GetDuration(SaveHeight.Value);
            }
            else
            {
                // Going down
                a.From     = new GridLength(row.ActualHeight, GridUnitType.Pixel);
                SaveHeight = a.From;
                a.To       = new GridLength(0, GridUnitType.Pixel);
                a.Duration = GetDuration(SaveHeight.Value);
            }

            row.BeginAnimation(RowDefinition.HeightProperty, a);
        }
        public void AnimateRowGrid(RowDefinition Source, RowDefinition Destination, Grid GridSource, Grid GridDestination, ref GridLength PrevHeight)
        {
            AnimateRowGridGridSource   = GridSource;
            GridSource.Visibility      = System.Windows.Visibility.Visible;
            GridDestination.Visibility = System.Windows.Visibility.Visible;

            GridLengthAnimation GridAnimHiddenCol = new GridLengthAnimation();

            GridAnimHiddenCol.From     = Source.Height;
            GridAnimHiddenCol.To       = new GridLength(0);
            GridAnimHiddenCol.Duration = new Duration(TimeSpan.FromSeconds(0.3));

            GridLengthAnimation GridAnimVisibleCol = new GridLengthAnimation();

            GridAnimVisibleCol.From       = new GridLength(0);
            GridAnimVisibleCol.To         = PrevHeight;
            GridAnimVisibleCol.Duration   = new Duration(TimeSpan.FromSeconds(0.3));
            GridAnimVisibleCol.Completed += GridAnimVisibleCol_Completed;


            PrevHeight = Source.Height;
            Source.BeginAnimation(RowDefinition.HeightProperty, GridAnimHiddenCol);
            Destination.BeginAnimation(RowDefinition.HeightProperty, GridAnimVisibleCol);
        }
 /// <summary>
 /// Method starts row animation
 /// </summary>
 /// <param name="row"></param>
 /// <param name="startSize"></param>
 /// <param name="endSize"></param>
 /// <param name="duration"></param>
 private void _StartRowAnimation(RowDefinition row, double startSize, double endSize, int duration)
 {
     GridLengthAnimation sizeAnimation = new GridLengthAnimation();
     sizeAnimation.From = new GridLength(startSize, GridUnitType.Pixel);
     sizeAnimation.To = new GridLength(endSize, GridUnitType.Pixel);
     sizeAnimation.Duration = new TimeSpan(0, 0, 0, 0, duration);
     row.BeginAnimation(RowDefinition.HeightProperty, sizeAnimation);
 }