Beispiel #1
0
        /// <summary>
        ///     Called when the user navigates to the page
        /// </summary>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            // Get the target user (may be null)
            var targetUser = e.Parameter as User;

            // If we have both objects and they equal, do
            // nothing and return (we are navigating to the
            // same page.
            if (ViewModel.User?.Id == targetUser?.Id)
            {
                return;
            }

            // If both of these are null, we have a problem.
            // In the future we would try load the user ID from
            // a stored file. For now through an exception.
            if (targetUser == null && ViewModel.User == null)
            {
                throw new ArgumentNullException(nameof(e),
                                                "Both the view model and target user are null. UserView cannot continue");
            }

            // We need to handle window resize change events here for the
            // main pivot
            MainPivot.Height = Window.Current.Bounds.Height;
            SizeChanged     += UserView_SizeChanged;

            // If the target user is not null, we can setup the
            // the view model.
            if (targetUser != null)
            {
                // Reset the selected page for the pivot
                MainPivot.SelectedIndex = 0;

                // Clear description
                Description.Blocks.Clear();

                // Show the upload button on the users profile
                UploadButton.Visibility = targetUser.Id == SoundByteService.Instance.SoundCloudUser?.Id
                    ? Visibility.Visible
                    : Visibility.Collapsed;

                // Create the model
                await ViewModel.UpdateModel(targetUser);

                if (!string.IsNullOrEmpty(ViewModel.User.Description))
                {
                    TextHelper.ConvertTextToFormattedTextBlock(ViewModel.User.Description, ref Description);
                }
            }

            // Track Event
            TelemetryService.Instance.TrackPage("User View");
        }
        /// <summary>
        ///     Called when the user navigates to the page
        /// </summary>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            // Get the target user (may be null)
            var targetUser = e.Parameter as BaseUser;

            // If we have both objects and they equal, do
            // nothing and return (we are navigating to the
            // same page.
            if (ViewModel.User?.UserId == targetUser?.UserId)
            {
                return;
            }

            // If both of these are null, we have a problem.
            // In the future we would try load the user ID from
            // a stored file. For now through an exception.
            if (targetUser == null && ViewModel.User == null)
            {
                throw new ArgumentNullException(nameof(e),
                                                "Both the view model and target user are null. UserView cannot continue");
            }

            // If the target user is not null, we can setup the
            // the view model.
            if (targetUser != null)
            {
                // Clear description
                Description.Blocks.Clear();

                // Create the model with a new user object
                await ViewModel.UpdateModel(targetUser);

                if (!string.IsNullOrEmpty(ViewModel.User.Description))
                {
                    TextHelper.ConvertTextToFormattedTextBlock(ViewModel.User.Description, ref Description);
                }
            }

            // Track Event
            SimpleIoc.Default.GetInstance <ITelemetryService>().TrackPage("User View");
        }