Пример #1
0
        /// <summary>
        /// Raised when the user loads the page.
        /// Register to the MVVM Light Messenger.
        /// Load the menu items.
        /// Register the background task to the system.
        /// </summary>
        /// <param name="e">Navigation event arguments</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Register to the MVVM Light Messenger
            Messenger.Default.Register <VisualGenericGroup>(this, GoToMasterPage);
            Messenger.Default.Register <VisualGenericItem>(this, GoToDetailsPage);

            Messenger.Default.Register <PinnableObject>(this, Pin);
            Messenger.Default.Register <Uri>(this, GoToWebPage);
            Messenger.Default.Register <object>(this, GoToAboutPage);

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

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

                // Register the background tast to the system
                RegisterBackgroundTasksHelper helper = new RegisterBackgroundTasksHelper();
                await helper.RegisterAsync();

                // Update the application tile
                ApplicationTileManager manager = new ApplicationTileManager();
                await manager.CreateAsync();
            }
        }
Пример #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();
            }
        }
        /// <summary>
        /// Create the application tile
        /// </summary>
        /// <param name="task">Informations about the periodic task</param>
        protected override async void OnInvoke(ScheduledTask task)
        {
            try
            {
                // Update application tile
                ApplicationTileManager appTileManager = new ApplicationTileManager();
                await appTileManager.UpdateAsync();

                // Display toast notification if a new element has been published
                ToastManager manager = new NewsToastManager();
                await manager.CheckAndToastAsync();

                manager = new ConferenceToastManager();
                await manager.CheckAndToastAsync();

                manager = new ShowToastManager();
                await manager.CheckAndToastAsync();
            }
            finally
            {
                NotifyComplete();
            }
        }