protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var currentView = SystemNavigationManager.GetForCurrentView(); displayRequest.RequestActive(); //to request keep display on currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; currentView.BackRequested += CurrentView_BackRequested; if (e.NavigationMode != NavigationMode.Back) { try { _mainPageViewModel = MainPage.Current.MainPageViewModel; LayoutRoot.DataContext = _mainPageViewModel; _currentTrack = _mainPageViewModel.PlayingTrack; _canvasControl = new CanvasControl(); _canvasControl.Draw += _canvasControl_Draw; App.AudioPlayer.CurrentTrackChanged += AudioPlayer_CurrentTrackChanged; ContentPresenter.Content = _canvasControl; CreateWaveForm(); } catch (Exception ex) { ErrorLogProxy.LogError(ex.ToString()); ErrorLogProxy.NotifyErrorInDebug(ex.ToString()); } } }
protected override async void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var currentView = SystemNavigationManager.GetForCurrentView(); currentView.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; currentView.BackRequested += CurrentView_BackRequested; if (e.NavigationMode != NavigationMode.Back) { try { _mainPageViewModel = MainPage.Current.MainPageViewModel; _playlistViewPageViewModel = (PlaylistViewPageViewModel)Resources["PlaylistViewPageViewModel"]; if (e.Parameter != null && !ReferenceEquals(e.Parameter, string.Empty)) { _playlistId = e.Parameter.ToString(); _playlistViewPageViewModel.Playlist = await App.SoundCloud.GetPlaylist(Convert.ToInt32(_playlistId)); _playlistName = _playlistViewPageViewModel.Playlist.Title; } MainPage.Current.MainPageViewModel.PinButtonVisibility = Visibility.Visible; MainPage.Current.PinToStartButton.Click += PinToStartButton_Click; } catch(Exception ex) { ErrorLogProxy.LogError(ex.ToString()); ErrorLogProxy.NotifyError(ex.ToString()); } } base.OnNavigatedTo(e); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { Application.Current.Suspending += ForegroundApp_Suspending; Application.Current.Resuming += ForegroundApp_Resuming; ApplicationSettingsHelper.SaveSettingsValue(ApplicationSettingsConstants.AppState, AppState.Active.ToString()); if (e.NavigationMode != NavigationMode.Back) { try { MyFrame.Navigate(typeof(HomePage)); MainPageViewModel = (MainPageViewModel)Resources["MainPageViewModel"]; MusicPlayerControl.DataContext = App.AudioPlayer; MainPageViewModel.PageTitle = "Home"; //App.AudioPlayer.CurrentPlayer.CurrentStateChanged += CurrentPlayer_CurrentStateChanged; LoadUserAvatar(); string param = e.Parameter?.ToString(); if (!string.IsNullOrWhiteSpace(param)) { string[] arr = param.Split(','); switch (arr[0]) { case "search": Navigate(new SearchPage(), arr[1]); break; case "playlist": Navigate(new PlaylistViewPage(), arr[1]); break; } } } catch (Exception ex) { ErrorLogProxy.LogError(ex.ToString()); ErrorLogProxy.NotifyErrorInDebug(ex.ToString()); } } base.OnNavigatedTo(e); }