예제 #1
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)
        {
            var rootFrame = GetRootFrame(e);

            if (!e.PrelaunchActivated)
            {
                bool canEnablePrelaunch = Windows.Foundation.Metadata.ApiInformation.IsMethodPresent("Windows.ApplicationModel.Core.CoreApplication", "EnablePrelaunch");
                if (canEnablePrelaunch)
                {
                    Windows.ApplicationModel.Core.CoreApplication.EnablePrelaunch(true);
                }

                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);
                }

                var appTrigger = new TimeTrigger((uint)TimeSpan.FromHours(12).TotalMinutes, false);
                BackgroundTaskRegistrationHelper.RegisterBackgroundTask(typeof(FundsChangeAnalysisService),
                                                                        nameof(FundsChangeAnalysisService), appTrigger, null);

                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
예제 #2
0
        /// <summary>
        /// Raised when the page is loaded
        /// </summary>
        /// <param name="e">Navigation event arguments</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (_selectedPanoramaGroup != null)
            {
                int index = Panorama.Items.Cast <VisualGenericGroup>().TakeWhile(item => item != _selectedPanoramaGroup).Count();
                Panorama.DefaultItem = Panorama.Items[index];
            }

            if (e.NavigationMode == NavigationMode.New)
            {
                IMainViewModel viewModel = (IMainViewModel)DataContext;

                if (viewModel.LoadMenuCommand.CanExecute(this))
                {
                    viewModel.LoadMenuCommand.Execute(this);
                }

                BackgroundTaskRegistrationHelper taskRegistration = new BackgroundTaskRegistrationHelper();
                taskRegistration.Register();

                ApplicationTileManager tileManager = new ApplicationTileManager();
                await tileManager.UpdateAsync();
            }
        }