Esempio n. 1
0
        //Double animation to change height and width to minimize with visibility
        private void PerformMinimizeWithVisibility(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            //Get the Child elemnts
            var Parent = sender as MinimizableGridControl;
            var childs = Parent.Children;

            var MinimizingChild = (childs.FirstOrDefault(x => x as Border != null && ((Border)x).Name == MinimizingChildName)) as Border;

            if (MinimizingChild != null)
            {
                MinimizingChild.Height = MinimizingChild.ActualHeight;
                MinimizingChild.Width  = MinimizingChild.ActualWidth;
            }


            DoubleAnimation anim;
            var             isMinimized = (bool)e.NewValue;

            OldStateValue = (bool)e.OldValue;
            if (OldStateValue != isMinimized)
            {
                CurrentElement = (MinimizableGridControl)sender;

                if (IsMinimized)
                {
                    anim = new DoubleAnimation()
                    {
                        EnableDependentAnimation = true,
                        From           = PreviousHeightWidthForVisibility,
                        To             = CompactPaneHeightWidth,
                        Duration       = new Duration(new TimeSpan(0, 0, 1)),
                        EasingFunction = new CubicEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    };
                }
                else
                {
                    anim = new DoubleAnimation()
                    {
                        EnableDependentAnimation = true,
                        From           = CompactPaneHeightWidth,
                        To             = PreviousHeightWidthForVisibility,
                        Duration       = new Duration(new TimeSpan(0, 0, 1)),
                        EasingFunction = new CubicEase()
                        {
                            EasingMode = EasingMode.EaseOut
                        }
                    };
                }

                Storyboard.SetTarget(anim, CurrentElement);
                if (FlowOrientation == Orientation.Vertical)
                {
                    Storyboard.SetTargetProperty(anim, "Height");
                }
                else
                {
                    Storyboard.SetTargetProperty(anim, "Width");
                }

                CurrentElement.SlideStoryBoard.Stop();
                CurrentElement.SlideStoryBoard = new Storyboard();
                CurrentElement.SlideStoryBoard.Children.Add(anim);
                CurrentElement.SlideStoryBoard.Begin();
            }
        }
Esempio n. 2
0
        //Simple Minimize Translate x and y animation
        private void PerformSimpleMinizie(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var isMinimized = (bool)e.NewValue;

            OldStateValue = (bool)e.OldValue;
            var VisiblePaneHeightWidth = CompactPaneHeightWidth;

            if (OldStateValue != isMinimized)
            {
                CurrentElement = (MinimizableGridControl)sender;
                var PortionToHide = CurrentElement.ActualHeight;
                CurrentElement.RenderTransform = new Windows.UI.Xaml.Media.TranslateTransform()
                {
                    Y = 0, X = 0
                };

                var animation = new DoubleAnimationUsingKeyFrames();
                EasingDoubleKeyFrame keyFrame1 = new EasingDoubleKeyFrame()
                {
                    KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = PortionToHide - VisiblePaneHeightWidth
                };
                EasingDoubleKeyFrame keyFrame2 = new EasingDoubleKeyFrame()
                {
                    KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animationTime)), Value = 0
                };
                keyFrame2.EasingFunction = new CubicEase()
                {
                    EasingMode = EasingMode.EaseOut
                };
                animation.KeyFrames.Add(keyFrame1);
                animation.KeyFrames.Add(keyFrame2);

                Storyboard.SetTarget(animation, CurrentElement);
                Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(TranslateTransform.Y)");
                if (FlowOrientation == Orientation.Horizontal)
                {
                    Storyboard.SetTargetProperty(animation, "(UIElement.RenderTransform).(TranslateTransform.X)");
                    PortionToHide = CurrentElement.ActualWidth;
                }
                CurrentElement.SlideStoryBoard.Stop();
                CurrentElement.SlideStoryBoard = new Storyboard();
                CurrentElement.SlideStoryBoard.Children.Add(animation);

                if (!isMinimized)
                {
                    //set the IsShowingMinimizedView to false as it's getting maximized.
                    this.IsShowingMinimizedView = false;
                    if (MinimizeDirection == MinimizeFlow.TowardsRightOrTowardsBottom)
                    {
                        animation.KeyFrames[0] = new EasingDoubleKeyFrame()
                        {
                            KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = PortionToHide - VisiblePaneHeightWidth
                        };
                        animation.KeyFrames[1] = new EasingDoubleKeyFrame()
                        {
                            KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animationTime)), Value = 0
                        };
                    }
                    else
                    {
                        animation.KeyFrames[0] = new EasingDoubleKeyFrame()
                        {
                            KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = -PortionToHide + VisiblePaneHeightWidth
                        };
                        animation.KeyFrames[1] = new EasingDoubleKeyFrame()
                        {
                            KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animationTime)), Value = 0
                        };
                    }
                    CurrentElement.SlideStoryBoard.Begin();
                }
                else
                {
                    if (MinimizeDirection == MinimizeFlow.TowardsRightOrTowardsBottom)
                    {
                        animation.KeyFrames[0] = new EasingDoubleKeyFrame()
                        {
                            KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0
                        };
                        animation.KeyFrames[1] = new EasingDoubleKeyFrame()
                        {
                            KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animationTime)), Value = PortionToHide - VisiblePaneHeightWidth
                        };
                    }
                    else
                    {
                        animation.KeyFrames[0] = new EasingDoubleKeyFrame()
                        {
                            KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0
                        };
                        animation.KeyFrames[1] = new EasingDoubleKeyFrame()
                        {
                            KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(animationTime)), Value = -PortionToHide + VisiblePaneHeightWidth
                        };
                    }
                    CurrentElement.SlideStoryBoard.Begin();
                }
            }
        }