Example #1
0
        /// <summary>
        /// Handler for the window close animation completion, this delays
        /// actually closing the window until all outro animations have completed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCloseAnimationCompleted(object sender, EventArgs e)
        {
            InlineModalDecorator panel = GetModalDecorator(Owner);

            Debug.Assert(panel != null);
            CloseDialog(panel);
        }
Example #2
0
        /// <summary>
        /// Attempts to close the front-most dialog of the provided owner.
        /// </summary>
        /// <param name="owner"></param>
        public static void CloseCurrent(DependencyObject owner)
        {
            InlineModalDecorator panel = GetModalDecorator(owner);

            if (panel == null)
            {
                return;
            }

            var current = panel.TopmostModal as InlineModalDialog;

            if (current != null)
            {
                current.Close();
            }
        }
Example #3
0
        /// <summary>
        /// Closes the modal dialog.
        /// </summary>
        public void Close()
        {
            if (!_isOpen)
            {
                return;
            }

            ValidateOwner();

            InlineModalDecorator panel = GetModalDecorator(Owner);

            if (panel == null)
            {
                return;
            }

            var cancelArgs = new CancelRoutedEventArgs(ClosingEvent);

            OnClosing(cancelArgs);
            if (cancelArgs.Cancel)
            {
                return;
            }

            if (Animator.IsAnimationEnabled)
            {
                Storyboard dialogAnim = DialogOutroAnimation;
                if (dialogAnim != null)
                {
                    if (dialogAnim.IsFrozen)
                    {
                        dialogAnim = dialogAnim.Clone();
                    }

                    // Add a handler so we know when the dialog can be closed.
                    dialogAnim.AttachCompletedEventHandler(OnCloseAnimationCompleted);
                    dialogAnim.Begin(this);
                }
            }
            else
            {
                CloseDialog(panel);
            }
        }
Example #4
0
        private void CloseDialog(InlineModalDecorator panel)
        {
            panel.RemoveModal(this, ShowBlurrer);

            OnClosed();

            var topMost = panel.TopmostModal;

            if (topMost != null)
            {
                topMost.Focus();
            }

            if (_dispatcherFrame != null)
            {
                _dispatcherFrame.Continue = false;
                _dispatcherFrame          = null;
            }

            _isOpen = false;
        }
Example #5
0
        /// <summary>
        /// Shows the modal dialog.
        /// </summary>
        public void Show()
        {
            ValidateOwner();

            InlineModalDecorator panel = GetModalDecorator(Owner);

            if (panel == null)
            {
                return;
            }
            panel.AddModal(this, ShowBlurrer);

            if (Animator.IsAnimationEnabled)
            {
                Storyboard dialogAnim = DialogIntroAnimation;
                if (dialogAnim != null)
                {
                    if (dialogAnim.IsFrozen)
                    {
                        dialogAnim = dialogAnim.Clone();
                    }

                    dialogAnim.AttachCompletedEventHandler(OnOpenAnimationCompleted);
                    dialogAnim.Begin(this);
                }
            }
            else
            {
                OpenCompleted();
            }

            _dispatcherFrame = new DispatcherFrame();
            Dispatcher.PushFrame(_dispatcherFrame);

            _isOpen = false;
        }
        private void CloseDialog(InlineModalDecorator panel)
        {
            panel.RemoveModal(this, ShowBlurrer);

            OnClosed();

            var topMost = panel.TopmostModal;
            if (topMost != null)
            {
                topMost.Focus();
            }

            if (_dispatcherFrame != null)
            {
                _dispatcherFrame.Continue = false;
                _dispatcherFrame = null;
            }

            _isOpen = false;
        }
 internal static void SetModalDecorator(DependencyObject obj, InlineModalDecorator value)
 {
     obj.SetValue(ModalDecoratorProperty, value);
 }
Example #8
0
 internal static void SetModalDecorator(DependencyObject obj, InlineModalDecorator value)
 {
     obj.SetValue(ModalDecoratorProperty, value);
 }