Esempio n. 1
0
        private void Hide(ContentDialogResult result)
        {
            void Complete(ContentDialogClosingEventArgs args)
            {
                if (!args.Cancel)
                {
                    _popup.IsOpen = false;

                    Closed?.Invoke(this, new ContentDialogClosedEventArgs(result));
                }
            }

            var closingArgs = new ContentDialogClosingEventArgs(Complete, result);

            Closing?.Invoke(this, closingArgs);

            if (!closingArgs.IsDeferred)
            {
                Complete(closingArgs);
            }
            else
            {
                closingArgs.EventRaiseCompleted();
            }
        }
Esempio n. 2
0
        private bool Hide(ContentDialogResult result)
        {
            void Complete(ContentDialogClosingEventArgs args)
            {
                if (!args.Cancel)
                {
                    m_isShowing   = false;
                    _popup.IsOpen = false;
                    _popup.Child  = null;
                    UpdateVisualState();
                    Closed?.Invoke(this, new ContentDialogClosedEventArgs(result));
                    _tcs.SetResult(result);
                }
                _hiding = false;
            }

            var closingArgs = new ContentDialogClosingEventArgs(Complete, result);

            Closing?.Invoke(this, closingArgs);

            if (!closingArgs.IsDeferred)
            {
                Complete(closingArgs);
            }
            else
            {
                closingArgs.EventRaiseCompleted();
            }

            return(!closingArgs.Cancel);
        }
Esempio n. 3
0
        private bool Hide(ContentDialogResult result)
        {
            void Complete(ContentDialogClosingEventArgs args)
            {
                if (!args.Cancel)
                {
                    m_isShowing   = false;
                    _popup.IsOpen = false;
                    _popup.Child  = null;
                    UpdateVisualState();
                    Closed?.Invoke(this, new ContentDialogClosedEventArgs(result));

                    // Make sure all clean-up is done before returning result,
                    // to prevent problems when the dialog is reopened synchronously
                    (var tcs, _tcs) = (_tcs, null);
                    DispatcherQueue.TryEnqueue(() => tcs?.TrySetResult(result));
                }
                _hiding = false;
            }

            var closingArgs = new ContentDialogClosingEventArgs(Complete, result);

            Closing?.Invoke(this, closingArgs);

            var completedSynchronously = closingArgs.DeferralManager.EventRaiseCompleted();

            return(completedSynchronously && !closingArgs.Cancel);
        }