/// <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); }
/// <summary> /// Shows the modal dialog. /// </summary> public void Show() { ValidateOwner(); InlineModalDecorator panel = GetModalDecorator(Owner); if (panel != null) { panel.AddModal(this, ShowBlurrer); if (AnimatorService.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; } }
/// <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) { var current = panel.TopmostModal as InlineModalDialog; if (current != null) { current.Close(); } } }
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; }
/// <summary> /// Closes the modal dialog. /// </summary> public void Close() { if (_isOpen) { ValidateOwner(); InlineModalDecorator panel = GetModalDecorator(Owner); if (panel != null) { var cancelArgs = new CancelRoutedEventArgs(ClosingEvent); OnClosing(cancelArgs); if (!cancelArgs.Cancel) { if (AnimatorService.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); } } } } }
internal static void SetModalDecorator(DependencyObject obj, InlineModalDecorator value) { obj.SetValue(ModalDecoratorProperty, value); }