コード例 #1
0
ファイル: App.xaml.cs プロジェクト: erebuxy/BangumiArchive
        /// <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();
        }
コード例 #2
0
ファイル: MainPage.xaml.cs プロジェクト: dafengz/Work-Timer
        private async void CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            e.Handled = true;
            await vm.SaveData();

            App.Current.Exit();
        }
コード例 #3
0
        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;
                }
            }
        }
コード例 #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.");
                }
            }
        }
コード例 #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();
        }
コード例 #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);
                }
            }
        }
コード例 #7
0
ファイル: App.xaml.cs プロジェクト: jonathanruisi/MediaBase
        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();
        }
コード例 #8
0
ファイル: MainPage.xaml.cs プロジェクト: ahmed605/Quick-Pad
        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.");
                }
            }
        }
コード例 #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();
            }
        }
コード例 #10
0
        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;
                }
            }
        }
コード例 #11
0
        // X 버튼 누르시에 할 일을 추가해야함
        private void SystemNavigationManager_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            Deferral deferral = e.GetDeferral();


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

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

            deferral.Complete();
        }
コード例 #13
0
        private async void App_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral = e.GetDeferral();

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

            deferral.Complete();
        }
コード例 #14
0
        private async void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            var deferral = e.GetDeferral();

            e.Handled = await RequireSaveAsync();

            deferral.Complete();
        }
コード例 #15
0
ファイル: MainPage.xaml.cs プロジェクト: xhowar/lindexi_gd
        private async void MainPage_CloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            // 让用户无法关闭
            e.Handled = true;

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

            e.Handled = savingPage.ExitShouldBeInterrupted(e.Handled, ForceClose);
        }
コード例 #17
0
ファイル: VideoPage.xaml.cs プロジェクト: spfyyy/dyldrkcr
        /// <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);
            }
        }
コード例 #18
0
        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();
        }
コード例 #19
0
        private void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            if (_tileStore == null)
            {
                return;
            }

            _tileStore.Dispose();
            _tileStore = null;
        }
コード例 #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();
        }
コード例 #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();
        }
コード例 #22
0
ファイル: App.xaml.cs プロジェクト: sota70/Sukka
        // 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();
            }
        }
コード例 #23
0
ファイル: App.xaml.cs プロジェクト: Tlaster/FluentExplorer
        private async void OnCloseRequested(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            if (Connection != null)
            {
                var def = e.GetDeferral();
                await Connection.SendMessageAsync(new ValueSet
                {
                    { "type", "Close" }
                });

                def.Complete();
            }
        }
コード例 #24
0
        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;
                }
            }
        }
コード例 #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();
            }
        }
コード例 #26
0
ファイル: App.xaml.cs プロジェクト: qedsd/MyNCMusic
 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));
 }
コード例 #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();
        }
コード例 #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;
     }
 }
コード例 #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();
        }
コード例 #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();
            }
        }