Esempio n. 1
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize);

                SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;

                // Update app constants from server
                AppConstants.Update();

                // Update assets from server
                AssetManager.UpdateAssets();

                // Play silent sound to avoid suspending the app when it's minimized.
                silentMediaPlayer.Play();

                // Media controls are necessary for the audio to continue when app is minimized.
                MediaControlsHelper.Init(Dispatcher);
                MediaControlsHelper.TrackChanged += (ss, trackChangedArgs) =>
                {
                    if (nowPlaying.IsOpen)
                    {
                        nowPlaying.PlayChangeTrackAnimation(
                            reverse: (trackChangedArgs.Direction == TrackChangeDirection.Backward));
                    }
                };

                // Show what's new if necessary
                if (WhatsNewHelper.ShouldShowWhatsNew())
                {
                    shouldShowWhatsNew = true;
                }

                LyricsViewerIntegrationHelper.InitIntegration();
                LiveTileHelper.InitLiveTileUpdates();
                JumpListHelper.DeleteRecentJumplistEntries();

                AnalyticsHelper.PageView("MainPage", setNewSession: true);
                AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString());

                developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage();

                // Window.Current.CoreWindow.KeyDown does not capture Alt events, but AcceleratorKeyActivated does.
                // NOTE: This event captures all key events, even when WebView is focused.
                CoreWindow.GetForCurrentThread().Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated;
            }
            catch (Exception ex)
            {
                AnalyticsHelper.Log("mainPageLoadedException", ex.Message, ex.ToString());
                await new MessageDialog(ex.ToString(), "MainPage:Loaded unhandled exception").ShowAsync();
            }
        }
Esempio n. 2
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize);

            SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;

            // Update app constants from server
            AppConstants.Update();

            // Update assets from server
            AssetManager.UpdateAssets();

            // Play silent sound to avoid suspending the app when it's minimized.
            silentMediaPlayer.Play();

            // Media controls are necessary for the audio to continue when app is minimized.
            MediaControlsHelper.Init(Dispatcher);
            MediaControlsHelper.TrackChanged += (ss, trackChangedArgs) =>
            {
                if (nowPlaying.IsOpen)
                {
                    nowPlaying.PlayChangeTrackAnimation(
                        reverse: (trackChangedArgs.Direction == TrackChangeDirection.Backward));
                }
            };

            // Show what's new if necessary
            if (WhatsNewHelper.ShouldShowWhatsNew())
            {
                shouldShowWhatsNew = true;
            }

            AnalyticsHelper.PageView("MainPage");
            AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString());

            developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage();

            LyricsViewerIntegrationHelper.InitIntegration();
            LiveTileHelper.InitLiveTileUpdates();
            JumpListHelper.DeleteRecentJumplistEntries();
        }
Esempio n. 3
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            InitTitleBar();
            ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize);
            Window.Current.CoreWindow.Activated += Window_Activated;

            SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested;

            // Update app constants from server
            AppConstants.Update();

            // Update assets from server
            AssetManager.UpdateAssets();

            // Play silent sound to avoid suspending the app when it's minimized.
            silentMediaPlayer.Play();

            // Media controls are necessary for the audio to continue when app is minimized.
            var mediaControls = SystemMediaTransportControls.GetForCurrentView();

            mediaControls.IsEnabled         = true;
            mediaControls.IsPreviousEnabled = true;
            mediaControls.IsNextEnabled     = true;
            mediaControls.IsPlayEnabled     = true;
            mediaControls.IsPauseEnabled    = true;
            mediaControls.PlaybackStatus    = MediaPlaybackStatus.Paused;
            mediaControls.ButtonPressed    += SystemControls_ButtonPressed;
            await mediaControls.DisplayUpdater.CopyFromFileAsync(MediaPlaybackType.Music,
                                                                 await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Media/silent.wav")));

            PlayStatusTracker.MediaControls = mediaControls;
            PlayStatusTracker.StartRegularRefresh();

            // Show what's new if necessary
            if (WhatsNewHelper.ShouldShowWhatsNew())
            {
                shouldShowWhatsNew = true;
            }

            webViewCheckTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(1),
            };
            webViewCheckTimer.Tick += WebViewCheckTimer_Tick;
            webViewCheckTimer.Start();

            clipboardCheckTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(3),
            };
            clipboardCheckTimer.Tick += ClipboardCheckTimer_Tick;
            clipboardCheckTimer.Start();

            stuckDetectTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(4),
            };
            stuckDetectTimer.Tick += StuckDetectTimer_Tick;
            stuckDetectTimer.Start();

            AnalyticsHelper.PageView("MainPage");
            AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString());

            if (ThemeHelper.GetCurrentTheme() == Theme.Light)
            {
                splashScreenToLightStoryboard.Begin();
            }

            developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage();

            LyricsViewerIntegrationHelper.InitIntegration();
            LiveTileHelper.InitLiveTileUpdates();
            JumpListHelper.DeleteRecentJumplistEntries();
        }