示例#1
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                //Associate the frame with a SuspensionManager key                                
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                //  Display an extended splash screen if app was not previously running.
                if (args.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    bool loadState = (args.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, loadState);
                    //rootFrame.Content = extendedSplash;
                    Window.Current.Content = extendedSplash;
                    
                }

                // Place the frame in the current Window
                Window.Current.Activate();
                //Window.Current.Content = rootFrame;
                removeSplash(rootFrame);
            }
            if (rootFrame.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
                if (!rootFrame.Navigate(typeof(ItemsPage), "AllGroups"))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
            
        }
示例#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 async override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Set the default language
                rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += OnNavigationFailed;

                //  Display an extended splash screen if app was not previously running.
                if (e.PreviousExecutionState == ApplicationExecutionState.Running)
                {
                    bool           loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, loadState);
                    rootFrame.Content      = extendedSplash;
                    Window.Current.Content = rootFrame;
                }

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

            if (rootFrame.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
                rootFrame.Navigate(typeof(DanxMainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
示例#3
0
        private async Task ActivateAsync(IActivatedEventArgs e)
        {
            var activationInfo = ActivationService.GetActivationInfo(e);

            var frame = Window.Current.Content as Frame;

            if (frame == null)
            {
                bool           loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                ExtendedSplash extendedSplash = new ExtendedSplash(e, loadState);
                Window.Current.Content = extendedSplash;
                Window.Current.Activate();
            }
            else
            {
                var navigationService = ServiceLocator.Current.GetService <INavigationService>();
                await navigationService.CreateNewViewAsync(activationInfo.EntryViewModel, activationInfo.EntryArgs);
            }
        }
示例#4
0
        protected async override void OnLaunched(LaunchActivatedEventArgs args)
        {
            SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
            bool loadState = (args.PreviousExecutionState == ApplicationExecutionState.Terminated || args.PreviousExecutionState == ApplicationExecutionState.NotRunning);

            if (args.PreviousExecutionState != ApplicationExecutionState.Running)
            {
                // Begin executing setup operations.


                // Place the frame in the current Window
                ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen);

                Window.Current.Content = extendedSplash;
                Window.Current.Activate();
            }

            await PerformDataFetch(loadState);
        }
示例#5
0
        /// <summary>s
        /// 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)
        {
            // Load the database.
            UseSqlite();



            // Prepare the app shell and window content.
            AppShell shell = Window.Current.Content as AppShell ?? new AppShell();

            shell.Language = ApplicationLanguages.Languages[0];


            if (shell.AppFrame.Content == null)
            {
                ExtendedSplash extendedSplash = new ExtendedSplash(e);
                Window.Current.Content = extendedSplash;
                Window.Current.Activate();
            }



            CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;

            var titleBar = ApplicationView.GetForCurrentView().TitleBar;

            // Set active window colors
            titleBar.ForegroundColor              = Colors.White;
            titleBar.BackgroundColor              = Colors.Transparent;
            titleBar.ButtonForegroundColor        = Colors.White;
            titleBar.ButtonHoverForegroundColor   = Colors.White;
            titleBar.ButtonPressedForegroundColor = Colors.White;
            titleBar.ButtonBackgroundColor        = Colors.Transparent;
            titleBar.ButtonHoverBackgroundColor   = Colors.DimGray;
            titleBar.ButtonPressedBackgroundColor = Colors.Gray;

            // Set inactive window colors
            titleBar.InactiveForegroundColor       = Color.FromArgb(218, 255, 255, 255);
            titleBar.InactiveBackgroundColor       = Color.FromArgb(255, 255, 255, 255);
            titleBar.ButtonInactiveForegroundColor = Color.FromArgb(218, 255, 255, 255);
            titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
        }
示例#6
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 = false;
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;

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

                rootFrame.NavigationFailed += OnNavigationFailed;

                ExtendedSplash eSplash = new ExtendedSplash(e.SplashScreen, false);
                rootFrame.Content = eSplash;

                Window.Current.Content = rootFrame;
            }


            if (rootFrame.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
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();


            Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;
        }
示例#7
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)
        {
            var rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                // Set the default language
                rootFrame.Language = ApplicationLanguages.Languages[0];

                rootFrame.NavigationFailed += OnNavigationFailed;

                //  Display an extended splash screen if app was not previously running.
                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    var loadState      = e.PreviousExecutionState == ApplicationExecutionState.Terminated;
                    var extendedSplash = new ExtendedSplash(
                        e.SplashScreen,
                        typeof(MainPage),
                        new BitmapImage(new Uri("ms-appx:///Assets/SplashScreen.png")),
                        Color.FromArgb(200, 00, 153, 153));
                    rootFrame.Content      = extendedSplash;
                    Window.Current.Content = rootFrame;
                    Task.Run(() => PerformLoadingTask(extendedSplash));
                }
            }

            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
示例#8
0
文件: App.xaml.cs 项目: IUsername/Lum
        private async void InitWindow(SplashScreen splash, bool skipWindowCreation = false)
        {
            _rootPage = Window.Current.Content as NavigationRoot;
            var shouldInit = _rootPage == null && !skipWindowCreation;

            if (shouldInit)
            {
                var extSplash = new ExtendedSplash(splash);
                Window.Current.Content = extSplash;
                Window.Current.Activate();

                _rootPage = new NavigationRoot();
                var adapter = new FrameAdapter(_rootPage.AppFrame);
                adapter.NavigationFailed += OnNavigationFailed;

                var builder = new ContainerBuilder();
                builder.RegisterInstance(adapter).AsImplementedInterfaces();

                builder.RegisterType <DashboardViewModel>();
                builder.RegisterType <DesktopViewModel>();
                builder.RegisterType <NavigationService>().AsImplementedInterfaces().SingleInstance();

                _container = builder.Build();

                var navService = _container.Resolve <INavigationService>();
                navService.RegisterPageViewModel <Dashboard, DashboardViewModel>();
                navService.RegisterPageViewModel <Desktop, DesktopViewModel>();
                _rootPage.InitializeNavigationService(navService);

                await navService.NavigateToDashboard(new FrameNavigationOptions());

                await extSplash.RunAsync().ConfigureAwait(true);

                Window.Current.Content = _rootPage;
                Window.Current.Activate();
            }
        }
        private static async Task ShowSplashScreen(IActivatedEventArgs e)
        {
            StatusBar statusBar = StatusBar.GetForCurrentView();
            await statusBar.HideAsync();

            var file = await StorageFile.GetFileFromApplicationUriAsync(
                new Uri("ms-appx:///Assets/SplashScreen.png", UriKind.Absolute));

            var randomAccessStream = await file.OpenReadAsync();

            var splashImage = new BitmapImage()
            {
                CreateOptions = BitmapCreateOptions.None
            };
            await splashImage.SetSourceAsync(randomAccessStream);


            var extendedSplash = new ExtendedSplash(e.SplashScreen,
                                                    e, splashImage);

            Window.Current.Content = extendedSplash;

            Window.Current.Activate();
        }
示例#10
0
        private Frame GetOrCreateRootFrame(IActivatedEventArgs args)
        {
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (Window.Current.Content is Frame rootFrame)
            {
                return(rootFrame);
            }

            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();
            rootFrame.NavigationFailed += OnNavigationFailed;
            if (args.PreviousExecutionState != ApplicationExecutionState.Running)
            {
                var loadState      = (args.PreviousExecutionState == ApplicationExecutionState.Terminated);
                var extendedSplash = new ExtendedSplash(args.SplashScreen, loadState);
                rootFrame.Content      = extendedSplash;
                Window.Current.Content = extendedSplash;
            }

            // Place the frame in the current Window
            Window.Current.Content = rootFrame;
            return(rootFrame);
        }
示例#11
0
        private async void PerformLoadingTask(ExtendedSplash extendedSplash)
        {
            await Task.Delay(3000);

            await extendedSplash.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, extendedSplash.DismissExtendedSplash);
        }
示例#12
0
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            var rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context.
                rootFrame = new Frame();

                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                rootFrame.CacheSize = 1;

                // Display the extended splash screen if application is not running.
                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    var loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    var extendedSplash = new ExtendedSplash(rootFrame, e.SplashScreen, loadState);
                    rootFrame.Content = extendedSplash;

                    Window.Current.Content = rootFrame;
                    return;
                }

                // Restore the saved session state only when appropriate.
                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    try
                    {
                        // Load state from previously suspended application.
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                    }
                }

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

            if (rootFrame.Content == null)
            {
#if WINDOWS_PHONE_APP
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;
#endif

                if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
                {
                    throw new Exception("Failed to create initial page");
                }
            }

            // Ensure the current window is active.
            Window.Current.Activate();
        }
示例#13
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)
        {
            // Load Theme
            var loadedResources = App.Current.Resources.MergedDictionaries.ToList();

            foreach (var resource in loadedResources)
            {
                if (resource.Source.ToString().Contains("Theme"))
                {
                    App.Current.Resources.MergedDictionaries.Remove(resource);
                }
            }
            App.Current.Resources.MergedDictionaries.Add(BookieSettings.Theme.Resource);



            var titleBar = ApplicationView.GetForCurrentView().TitleBar;

            titleBar.BackgroundColor       = Colors.Black;
            titleBar.ButtonBackgroundColor = Colors.Black;
            titleBar.ButtonForegroundColor = Colors.White;
            titleBar.ForegroundColor       = Colors.White;
#if DEBUG
            if (Debugger.IsAttached)
            {
                // DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            var rootFrame = Window.Current.Content as Frame;

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

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }
                //  Display an extended splash screen if app was not previously running.
                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    var loadState      = e.PreviousExecutionState == ApplicationExecutionState.Terminated;
                    var extendedSplash = new ExtendedSplash(e.SplashScreen, loadState);
                    rootFrame.Content      = extendedSplash;
                    Window.Current.Content = rootFrame;
                }

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

            if (rootFrame.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
                rootFrame.Navigate(typeof(Shell), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
示例#14
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 async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            //Register VCD  Cortana
            try
            {
                // Install the main VCD.
                StorageFile vcdStorageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///Assets/VoiceCommandDefinition.xml"));

                await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.
                InstallCommandDefinitionsFromStorageFileAsync(vcdStorageFile);

                //// Update phrase list.
                //ViewModel.ViewModelLocator locator = App.Current.Resources["ViewModelLocator"] as ViewModel.ViewModelLocator;
                //if (locator != null)
                //{
                //    await locator.TripViewModel.UpdateDestinationPhraseList();
                //}
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Installing Voice Commands Failed: " + ex.ToString());
            }



            Frame rootFrame = Window.Current.Content as Frame;

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

                rootFrame.Language          = Windows.Globalization.ApplicationLanguages.Languages[0];
                rootFrame.NavigationFailed += OnNavigationFailed;


                //  Display an extended splash screen if app was not previously running.
                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    bool           loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, loadState);
                    Window.Current.Content = extendedSplash;
                }

                // Place the frame in the current Window
                Window.Current.Activate();
            }

            if (rootFrame.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
                rootFrame.Navigate(typeof(Views.NavView), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }
示例#15
0
        /// <summary>
        /// 在应用程序由最终用户正常启动时进行调用。
        /// 将在启动应用程序以打开特定文件等情况下使用。
        /// </summary>
        /// <param name="e">有关启动请求和过程的详细信息。</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;

            // 不要在窗口已包含内容时重复应用程序初始化,
            // 只需确保窗口处于活动状态
            if (rootFrame == null)
            {
                // 创建要充当导航上下文的框架,并导航到第一页
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;
                #region

                /*
                 * if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                 * {
                 * //TODO: 从之前挂起的应用程序加载状态
                 * }
                 *
                 * // 将框架放在当前窗口中
                 * Window.Current.Content = rootFrame;
                 * }
                 *
                 * if (e.PrelaunchActivated == false)
                 * {
                 * if (rootFrame.Content == null)
                 * {
                 * // 当导航堆栈尚未还原时,导航到第一页,
                 * // 并通过将所需信息作为导航参数传入来配置
                 * // 参数
                 *
                 * //ApplicationDataContainer data = ApplicationData.Current.LocalSettings;
                 * //if(data.Values.ContainsKey("statue"))
                 * //{
                 * //    if ((String)data.Values["statue"] == "user")
                 * //    {
                 * //        rootFrame.Navigate(typeof(MainPage), e.Arguments);
                 * //    }
                 * //    else
                 * //    {
                 * //        rootFrame.Navigate(typeof(UserLogIn), e.Arguments);
                 * //    }
                 * //}
                 * //else
                 * //{
                 * //    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                 * //}
                 *
                 * rootFrame.Navigate(typeof(MainPage), e.Arguments);
                 * }
                 *
                 * // 确保当前窗口处于活动状态
                 * Window.Current.Activate();
                 */
                #endregion
                if (e.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    bool           loadState      = (e.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, loadState);
                    rootFrame.Content      = extendedSplash;
                    Window.Current.Content = rootFrame;
                }
            }
            if (rootFrame.Content == null)
            {
                rootFrame.Navigate(typeof(UserLogIn), e.Arguments);
            }
            Window.Current.Activate();
        }
示例#16
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="args">Details about the launch request and process.</param>
        protected override async void OnLaunched(LaunchActivatedEventArgs args)
        {
            //progress bar atualizar inicial.
            try
            {
                if (args.PreviousExecutionState != ApplicationExecutionState.Running)
                {
                    bool           loadState      = (args.PreviousExecutionState == ApplicationExecutionState.Terminated);
                    ExtendedSplash extendedSplash = new ExtendedSplash(args.SplashScreen, loadState);
                    Window.Current.Content = extendedSplash;
                }

                Window.Current.Activate();

                //Verificar onde atualizar pela primeira vez.
                Preferencias preferencias = await Core.GetSPreferencias();                     //Verfica se existe preferencia registra, caso nao cria uma padrão.

                var sucesso = await Core.AtualizacaoAutomatica(preferencias.TempoAtualizacao); //Core.AtualizarObjetosDisco();

                if (sucesso != null && sucesso.Objetos != null)
                {
                }

                var sucessoHistorico = await Core.GravarObjetoHistorico();

                if (sucessoHistorico)
                {
                }
            }
            catch (Exception ex)
            {
                //Entities.LOG.MetroEventSource.Log.Error(ex.Message + "#" + ex.InnerException + "APP.cs" + "#" + "OnLaunched");
            }

            // Register handler for CommandsRequested events from the settings pane
            SettingsPane.GetForCurrentView().CommandsRequested += OnCommandsRequested;
            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active

            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                //Associate the frame with a SuspensionManager key
                SuspensionManager.RegisterFrame(rootFrame, "AppFrame");

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Restore the saved session state only when appropriate
                    try
                    {
                        await SuspensionManager.RestoreAsync();
                    }
                    catch (SuspensionManagerException)
                    {
                        //Something went wrong restoring state.
                        //Assume there is no state and continue
                    }
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }
            if (rootFrame.Content == null)
            {
                // First time execution, initialize the logger
                try
                {
                    EventListener verboseListener     = new StorageFileEventListener("LOG_MyListenerVerbose");
                    EventListener informationListener = new StorageFileEventListener("LOG_MyListenerInformation");

                    verboseListener.EnableEvents(MetroEventSource.Log, EventLevel.Verbose);
                    informationListener.EnableEvents(MetroEventSource.Log, EventLevel.Informational);
                }
                catch (Exception ex)
                {
                }

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups"))
                {
                    throw new Exception("Failed to create initial page");
                }
            }
            // Ensure the current window is active
            Window.Current.Activate();
        }