Beispiel #1
0
        private async void ConfirmAndExit()
        {
            // dialog is open
            if (exitConfirmationDialog != null)
            {
                return;
            }

            exitConfirmationDialog = new MessageDialog("Are you sure you want to exit?");
            exitConfirmationDialog.Commands.Add(new UICommand {
                Label = "OK", Id = 0
            });
            exitConfirmationDialog.Commands.Add(new UICommand {
                Label = "Cancel", Id = 1
            });

            var result = await exitConfirmationDialog.ShowAsync();

            exitConfirmationDialog = null;
            if (result != null && (int)result.Id == 0)
            {
                AppPersistenceManager.SaveApplicationState(ApplicationData.Current.LocalSettings);
                Application.Current.Exit();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(400, 500));

            AppShell appShell = Window.Current.Content as AppShell;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (appShell == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                appShell = new AppShell();
                BootstrapNavigationService(appShell.AppFrame);

                RegisterStoreServicesAsync();

                AppPersistenceManager.InitializeDefaultSettings(ApplicationData.Current.LocalSettings);
                appShell.DataContext = ViewModelLocator.IOCContainer.Resolve <AppShellViewModel>();
                appShell.AppFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = appShell;
            }

            if (e.PrelaunchActivated == false)
            {
                if (appShell.AppFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    //appShell.AppFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

            HideMobileStatusBar();
        }
Beispiel #3
0
 private void SaveApplicationState()
 {
     AppPersistenceManager.SaveApplicationState(ApplicationData.Current.LocalSettings);
 }