Beispiel #1
0
        /// <summary>
        /// Invoked when application is being closed by the user.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OnClosingAsync(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral = e.GetDeferral();

            if (DataManager.IsDataChanged())
            {
                var dialog          = new MessageDialog("There are unsaved changes to AnimeArchive", "Do you want to save your changes?");
                var saveCommand     = new UICommand("Save");
                var dontSaveCommand = new UICommand("Don't save");
                var cancelCommand   = new UICommand("Cancel");
                dialog.Commands.Add(saveCommand);
                dialog.Commands.Add(dontSaveCommand);
                dialog.Commands.Add(cancelCommand);

                var res = await dialog.ShowAsync();

                if (res == cancelCommand)
                {
                    e.Handled = true;
                }
                else if (res == saveCommand)
                {
                    DataManager.SaveData();
                }
            }

            deferral.Complete();
        }
Beispiel #2
0
        private async void CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            e.Handled = true;
            await vm.SaveData();

            App.Current.Exit();
        }
        private async void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            int      closeNum = 1;
            Deferral deferral = e.GetDeferral();

            if (false)
            {
                // user cancelled the close operation
                e.Handled = true;
                deferral.Complete();
            }
            else
            {
                switch (closeNum)
                {
                case 0:
                    e.Handled = false;
                    deferral.Complete();
                    break;

                case 1:
                    if (ApiInformation.IsApiContractPresent(
                            "Windows.ApplicationModel.FullTrustAppContract", 1, 0))
                    {
                        await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
                    }
                    e.Handled = false;
                    deferral.Complete();
                    break;
                }
            }
        }
Beispiel #4
0
        private async void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            ViewModel.Deferral = e.GetDeferral();

            if (ExitApplication == null)
            {
                ViewModel.Deferral.Complete();
            }
            else
            {
                e.Handled = !(await ExitApplication(ViewModel));

                if (!e.Handled)
                {
                    return;
                }

                try
                {
                    ViewModel.Deferral?.Dispose();
                }
                catch (ObjectDisposedException)
                {
                    Logger.LogDebug("Handled Deferral already disposed.");
                }
            }
        }
Beispiel #5
0
        private async void Close_Requested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            ContentDialog exitDialog = new ContentDialog
            {
                Title               = "Exit?",
                Content             = "Have you saved your latest Changes? They otherwise will be lost forever!",
                CloseButtonText     = "Cancel",
                PrimaryButtonText   = "Save",
                SecondaryButtonText = "Exit",
                DefaultButton       = ContentDialogButton.Secondary
            };

            ContentDialogResult result = await exitDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                e.Handled = true;
                Save_Click(null, null);
            }
            else if (result != ContentDialogResult.Secondary)
            {
                e.Handled = true;
            }

            deferral.Complete();
        }
Beispiel #6
0
        private async void OnWindowCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Debug.WriteLine("EditorPage.OnWindowCloseRequested");

            if (AppSettings.Current.AskSaveOnClose && measureCanvas.CanMeasure)
            {
                e.Handled = true;
                var re = await new Controls.AskSaveDialog().ShowAsync();
                if (re == ContentDialogResult.Primary)
                {
                    var file = await PickFile();

                    if (file == null)
                    {
                        return;
                    }
                    await this.measureCanvas.SaveAsync(file, false);

                    Environment.Exit(0);
                }
                else if (re == ContentDialogResult.Secondary)
                {
                    Environment.Exit(0);
                }
            }
        }
Beispiel #7
0
        private async void App_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral = e.GetDeferral();

            // Warn user if unsaved project changes exist and allow them to cancel closing the app
            var page = (Window.Current.Content as Frame)?.Content;

            if (page is MainPage mainPage &&
                mainPage.ActiveProject != null &&
                mainPage.ActiveProject.HasUnsavedChanges)
            {
                var dlg = new MessageDialog(
                    $"Project {mainPage.ActiveProject.Name} has unsaved changes.\nAre you sure you want to exit?",
                    "Warning");
                var confirmCommand = new UICommand("Yes");
                var cancelCommand  = new UICommand("Cancel");
                dlg.Commands.Add(confirmCommand);
                dlg.Commands.Add(cancelCommand);

                if (await dlg.ShowAsync() == cancelCommand)
                {
                    e.Handled = true;
                }
            }

            deferral.Complete();
        }
Beispiel #8
0
        private async void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            if (App.Services.GetService <DialogManager>().CurrentDialogView != null)
            {
                e.Handled = true;
                Logger.LogCritical("Already a dialog open.");
                return;
            }

            ViewModel.Deferral = e.GetDeferral();

            if (ExitApplication == null)
            {
                ((Windows.Foundation.Deferral)ViewModel.Deferral).Complete();
            }
            else
            {
                e.Handled = !(await ExitApplication(ViewModel));

                if (!e.Handled)
                {
                    return;
                }

                try
                {
                    ((Windows.Foundation.Deferral)ViewModel.Deferral)?.Dispose();
                }
                catch (ObjectDisposedException)
                {
                    Logger.LogDebug("Handled Deferral already disposed.");
                }
            }
        }
Beispiel #9
0
        private async void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral      deferral = e.GetDeferral();
            ContentDialog dlg      = new ContentDialog()
            {
                Title = "Do you really want to exit the application?", PrimaryButtonText = "Yes", SecondaryButtonText = "No"
            };
            ContentDialogResult result = await dlg.ShowAsync();

            if (result == ContentDialogResult.Secondary)
            {
                // user cancelled the close operation
                e.Handled = true;
                deferral.Complete();
            }
            else
            {
                if (Connection != null)
                {
                    ValueSet message = new ValueSet();
                    message.Add("InterCommunication", JsonSerializer.Serialize(new Common.InterCommunication()
                    {
                        InterCommunicationType = InterCommunicationType.Exit
                    }));
                    await Connection.SendMessageAsync(message);
                }
                e.Handled = false;
                deferral.Complete();
            }
        }
        private async void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral            deferral = e.GetDeferral();
            ConfirmCloseDialog  dlg      = new ConfirmCloseDialog();
            ContentDialogResult result   = await dlg.ShowAsync();

            if (result == ContentDialogResult.Secondary)
            {
                // user cancelled the close operation
                e.Handled = true;
                deferral.Complete();
            }
            else
            {
                switch (dlg.Result)
                {
                case CloseAction.Terminate:
                    e.Handled = false;
                    deferral.Complete();
                    break;

                case CloseAction.Systray:
                    if (ApiInformation.IsApiContractPresent(
                            "Windows.ApplicationModel.FullTrustAppContract", 1, 0))
                    {
                        await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
                    }
                    e.Handled = false;
                    deferral.Complete();
                    break;
                }
            }
        }
        // X 버튼 누르시에 할 일을 추가해야함
        private void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();


            e.Handled = false;
            deferral.Complete();
        }
Beispiel #12
0
        private async void CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral = e.GetDeferral();

            e.Handled = !await FileService.IsFileSavedAsync().ConfigureAwait(true);

            deferral.Complete();
        }
        private async void App_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral = e.GetDeferral();

            await System.Threading.Tasks.Task.Run(() => { AppCommunicator.ExitAllApp(); });

            deferral.Complete();
        }
        private async void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral = e.GetDeferral();

            e.Handled = await RequireSaveAsync();

            deferral.Complete();
        }
Beispiel #15
0
        private async void MainPage_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            // 让用户无法关闭
            e.Handled = true;

            var messageDialog = new MessageDialog("欢迎访问 blog.lindexi.com 大量 UWP 博客", "骚年你确定关闭");
            await messageDialog.ShowAsync();
        }
Beispiel #16
0
        private void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            if (!(XamarinHelpers.GetCurrentPage() is SavingPage savingPage))
            {
                return;
            }

            e.Handled = savingPage.ExitShouldBeInterrupted(e.Handled, ForceClose);
        }
Beispiel #17
0
        /// <summary>
        /// The <see cref="VideoPageViewModel"/> will only update watch playhead for a video when the video stream closes.
        /// This will capture when the user closes the app while watching a video. It can update the user's watch playhead before the app closes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void VideoPage_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var viewModel = DataContext as VideoPageViewModel;

            if (viewModel.EpisodeEndedCommand.CanExecute(null))
            {
                viewModel.EpisodeEndedCommand.Execute(null);
            }
        }
        private async void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            e.Handled = await ViewModel.TabViewManager.TabViewManager.MainTabView.GetUnclosableTabsAsync().CountAsync() > 0 ||
                        await ViewModel.TabViewManager.TabViewManager.SolutionExplorerTabView.GetUnclosableTabsAsync().CountAsync() > 0;

            deferral.Complete();
        }
Beispiel #19
0
        private void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            if (_tileStore == null)
            {
                return;
            }

            _tileStore.Dispose();
            _tileStore = null;
        }
Beispiel #20
0
        private async void App_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var  deferral    = e.GetDeferral();
            bool shouldClose = await vm.SaveOnClose();

            if (shouldClose == false)
            {
                e.Handled = true;
            }
            deferral.Complete();
        }
Beispiel #21
0
        private async void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();

            if (ApiInformation.IsApiContractPresent(
                    "Windows.ApplicationModel.FullTrustAppContract", 1, 0))
            {
                await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
            }
            e.Handled = false;
            deferral.Complete();
        }
Beispiel #22
0
        // close window confirmポップアップを出すメソッド
        private async void App_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            MainPage mainPage = MainPage.returnInstance();


            // ダイアログの中身を定義
            ContentDialog dialog = new ContentDialog()
            {
                Content = "データが保存されていないままです、本当に終了してもよろしいですか?",

                Title = "Exit",

                IsSecondaryButtonEnabled = true,

                PrimaryButtonText = "保存して終了",

                SecondaryButtonText = "はい",

                CloseButtonText = "いいえ"
            };

            bool isDataEdit = mainPage.EditOnce;

            // データが編集されていなかったらポップアップを出さないようにするために作った
            if (isDataEdit == false)
            {
                Application.Current.Exit();

                return;
            }

            var windowCloseProcess = e.GetDeferral();

            var result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                mainPage.saveAllData();

                Application.Current.Exit();
            }
            else if (result == ContentDialogResult.Secondary)
            {
                Application.Current.Exit();
            }
            else
            {
                e.Handled = true;

                windowCloseProcess.Complete();
            }
        }
Beispiel #23
0
        private async void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            if (Connection != null)
            {
                var def = e.GetDeferral();
                await Connection.SendMessageAsync(new ValueSet
                {
                    { "type", "Close" }
                });

                def.Complete();
            }
        }
        private async void CloseHandle(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral            deferral = e.GetDeferral();
            ConfirmCloseDialog  dlg      = new ConfirmCloseDialog();
            ContentDialogResult result   = await dlg.ShowAsync();

            if (result == ContentDialogResult.Secondary)
            {
                // user cancelled the close operation
                e.Handled = true;
                deferral.Complete();
            }
            else
            {
                switch (dlg.Result)
                {
                case CloseAction.Terminate:
                    e.Handled = false;
                    deferral.Complete();
                    break;

                case CloseAction.Systray:
                    if (ApiInformation.IsApiContractPresent(
                            "Windows.ApplicationModel.FullTrustAppContract", 1, 0))
                    {
                        // Add User Key
                        string lastUser = (string)ApplicationData.Current.LocalSettings.Values["LAST_USER"];
                        ApplicationData.Current.LocalSettings.Values.Remove("userInfo");
                        if (lastUser != null)
                        {
                            string lastUserKey = (string)ApplicationData.Current.LocalSettings.Values[lastUser];

                            ApplicationDataCompositeValue userInfo = new ApplicationDataCompositeValue
                            {
                                ["name"] = lastUser,
                                ["key"]  = lastUserKey
                            };

                            ApplicationData.Current.LocalSettings.Values["userInfo"] = userInfo;
                        }

                        // Start System Tray
                        await FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("UserInfo");
                    }
                    e.Handled = false;
                    deferral.Complete();
                    break;
                }
            }
        }
Beispiel #25
0
        private async void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            ContentDialog cDialog = GetCurrentContentDialog();

            e.Handled = true;

            if (cDialog != null)
            {
                cDialog.Hide();
                return;
            }

            CanShowDeviceUpdateDialog = false;

            e.Handled = true;
            ContentDialogResult result = ContentDialogResult.Secondary;

            if (NeedSave)
            {
                YesNoCancelDialog dialog = new YesNoCancelDialog
                {
                    DialogTitle               = resourceLoader.GetString("YesNoCancelDialog_SaveFile"),
                    DialogContent             = resourceLoader.GetString("YesNoCancelDialog_SaveHint"),
                    DialogYesButtonContent    = resourceLoader.GetString("YesNoCancelDialog_Save"),
                    DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Discard")
                };

                await dialog.ShowAsync();

                result = dialog.Result;
            }

            if (result != ContentDialogResult.None)
            {
                if (result == ContentDialogResult.Primary)
                {
                    bool successful = await SaveCurrentUserFile();

                    if (!successful)
                    {
                        return;
                    }
                }

                SaveSettings();
                Log.Debug("[OnCloseRequest] Exit ...");
                CoreApplication.Exit();
            }
        }
Beispiel #26
0
 private void Page_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
 {
     PlayingService.Volume = myMainPage._mediaPlayer.Volume;
     PlayingService.Save();
     if (myMainPage == null || PlayingService.PlayDurationStopwatch == null)
     {
         return;
     }
     myMainPage.playDurationStopwatch.Stop();
     if (PlayingService.PlayingSong == null)
     {
         return;
     }
     System.Threading.Tasks.Task.Run(() => SongService.MarkPlayDuration(PlayingService.PlayingSong.Id, PlayingService.PlayingListId, PlayingService.PlayDurationStopwatch.ElapsedMilliseconds / 1000));
 }
Beispiel #27
0
        private async void App_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral       = e.GetDeferral();
            var dialog         = new MessageDialog("Are you sure you want to exit?", "Exit");
            var confirmCommand = new UICommand("Yes");
            var cancelCommand  = new UICommand("No");

            dialog.Commands.Add(confirmCommand);
            dialog.Commands.Add(cancelCommand);
            if (await dialog.ShowAsync() == cancelCommand)
            {
                //cancel close by handling the event
                e.Handled = true;
            }
            deferral.Complete();
        }
Beispiel #28
0
 private async void CameraViewPage_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
 {
     if (cameraStatus != 0)
     {
         System.Diagnostics.Debug.WriteLine(cameraStatus);
         e.Handled = true;
         var d         = new MessageDialog("カメラをシャットダウンしてください");
         var okCommand = new UICommand("OK");
         d.Commands.Add(okCommand);
         await d.ShowAsync();
     }
     else
     {
         e.Handled = false;
     }
 }
Beispiel #29
0
        private async void CloseRequestedTests_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral = e.GetDeferral();
            var dialog   = new ContentDialog();

            dialog.Title               = "Exit";
            dialog.Content             = "Are you sure you want to exit?";
            dialog.PrimaryButtonText   = "Yes";
            dialog.SecondaryButtonText = "No";
            if (await dialog.ShowAsync() != ContentDialogResult.Primary)
            {
                //cancel close by handling the event
                e.Handled = true;
            }
            deferral.Complete();
        }
Beispiel #30
0
        private async void MainPage_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            e.Handled = true;

            if (CheckExit())
            {
                Application.Current.Exit();
            }
            else
            {
                var d         = new MessageDialog("終了を許可できません。以下を確認して下さい。\n\n・カメラのシャットダウン\n・データの書き出し中");
                var okCommand = new UICommand("OK");
                d.Commands.Add(okCommand);
                await d.ShowAsync();
            }
        }