Exemple #1
0
        private async void Window_Closing(object s, CancelEventArgs e)
        {
            if (!HasShownQuitDialog)
            {
                e.Cancel = true;

                var dialog = new CancellableDialog
                {
                    Message = { Text = "Are you sure you wish to quit?" }
                };

                dialog.AcceptButton.Command = new BaseCommand(o =>
                {
                    HasShownQuitDialog = true;
                    Application.Current.Shutdown();
                });

                await DialogHost.Show(dialog, "RootDialog");

                await DialogHost.Show(dialog, delegate(object sender, DialogOpenedEventArgs args)
                {
                    args.Session.Close(false);
                });
            }
        }
Exemple #2
0
        private async void RunQueryAsync(string query)
        {
            var connection = _connectionProvider();

            //TODO disable commands
            if (query == null || connection == null)
            {
                return;
            }

            var source     = new CancellationTokenSource();
            var waitHandle = new ManualResetEvent(false);

            source.Token.Register(() => waitHandle.Set());

            var cancellableDialogViewModel = new CancellableDialogViewModel(() => source.Cancel(), TimeSpan.FromMilliseconds(2500),
                                                                            Dispatcher.CurrentDispatcher);
            var cancellableDialog = new CancellableDialog
            {
                DataContext = cancellableDialogViewModel
            };

            await DialogHost.Show(cancellableDialog, _dialogTargetFinder.SuggestDialogHostIdentifier(), delegate(object sender, DialogOpenedEventArgs args)
            {
                RunQuery(connection, _generalSettingsProvider().MaxItemCount, query, waitHandle, source, args);
            });
        }
Exemple #3
0
        private async void ExecuteGoodByeDialog(object o)
        {
            //let's set up a little MVVM, cos that's what the cool kids are doing:
            var view = new CancellableDialog
            {
                DataContext = new DialogModel()
            };

            //show the dialog
            var result = await DialogHost.Show(view, "RootDialog", ClosingEventHandler);

            //check the result...
            Console.WriteLine("Dialog was closed, the CommandParameter used to close it was: " + (result ?? "NULL"));
        }