ApplyAnimation() private method

private ApplyAnimation ( Position position, bool animateOpacity, bool resetShowFrame = true ) : void
position Position
animateOpacity bool
resetShowFrame bool
return void
Esempio n. 1
0
        private static void PositionChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            Flyout flyout = (Flyout)dependencyObject;
            bool   isOpen = flyout.IsOpen;
            bool   flag   = isOpen;

            if (!isOpen || !flyout.AnimateOnPositionChange)
            {
                flyout.ApplyAnimation((MahApps.Metro.Controls.Position)e.NewValue, flyout.AnimateOpacity, false);
            }
            else
            {
                flyout.ApplyAnimation((MahApps.Metro.Controls.Position)e.NewValue, flyout.AnimateOpacity, true);
                VisualStateManager.GoToState(flyout, "Hide", true);
            }
            if (flag && flyout.AnimateOnPositionChange)
            {
                flyout.ApplyAnimation((MahApps.Metro.Controls.Position)e.NewValue, flyout.AnimateOpacity, true);
                VisualStateManager.GoToState(flyout, "Show", true);
            }
        }
Esempio n. 2
0
        private static void IsOpenedChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
        {
            Flyout flyout   = (Flyout)dependencyObject;
            Action newValue = () => {
                if (e.NewValue != e.OldValue)
                {
                    if (!flyout.AreAnimationsEnabled)
                    {
                        if (!(bool)e.NewValue)
                        {
                            flyout.Focus();
                            flyout.Hide();
                        }
                        else
                        {
                            flyout.Visibility = System.Windows.Visibility.Visible;
                            flyout.TryFocusElement();
                        }
                        VisualStateManager.GoToState(flyout, (!(bool)e.NewValue ? "HideDirect" : "ShowDirect"), true);
                    }
                    else
                    {
                        if (!(bool)e.NewValue)
                        {
                            flyout.Focus();
                            if (flyout.hideStoryboard == null)
                            {
                                flyout.Hide();
                            }
                            else
                            {
                                flyout.hideStoryboard.Completed += new EventHandler(flyout.HideStoryboard_Completed);
                            }
                        }
                        else
                        {
                            if (flyout.hideStoryboard != null)
                            {
                                flyout.hideStoryboard.Completed -= new EventHandler(flyout.HideStoryboard_Completed);
                            }
                            flyout.Visibility = System.Windows.Visibility.Visible;
                            flyout.ApplyAnimation(flyout.Position, flyout.AnimateOpacity, true);
                            flyout.TryFocusElement();
                        }
                        VisualStateManager.GoToState(flyout, (!(bool)e.NewValue ? "Hide" : "Show"), true);
                    }
                }
                flyout.RaiseEvent(new RoutedEventArgs(Flyout.IsOpenChangedEvent));
            };

            flyout.Dispatcher.BeginInvoke(DispatcherPriority.Background, newValue);
        }