/// <summary> /// Triggered every time the page is navigated to. /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { try { // Catches the passed UserProfilePage parameters UserProfileObject userProfileParameters = e.Parameter as UserProfileObject; // Sets current user as the passed through Visitor object currentUser = userProfileParameters.Visitor; // Sets the VisitorNameBlock as the current user's name VisitorNameBlock.Text = currentUser.Name; // Sets the local WebcamHelper as the passed through intialized one webcam = userProfileParameters.WebcamHelper; } catch { // Something went wrong... It's likely the page was navigated to without a Visitor parameter. Navigate back to MainPage Frame.Navigate(typeof(MainPage)); } }
/// <summary> /// Updates the list of Visitor objects with all whitelisted visitors stored on disk /// </summary> private async Task UpdateWhitelistedVisitorsList() { // Clears whitelist whitelistedVisitors.Clear(); // If the whitelistFolder has not been opened, open it if (whitelistFolder == null) { whitelistFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync(GeneralConstants.WhiteListFolderName, CreationCollisionOption.OpenIfExists); } // Populates subFolders list with all sub folders within the whitelist folders. // Each of these sub folders represents the Id photos for a single visitor. var subFolders = await whitelistFolder.GetFoldersAsync(); // Iterate all subfolders in whitelist foreach (StorageFolder folder in subFolders) { string visitorName = folder.Name; var filesInFolder = await folder.GetFilesAsync(); var photoStream = await filesInFolder[0].OpenAsync(FileAccessMode.Read); BitmapImage visitorImage = new BitmapImage(); await visitorImage.SetSourceAsync(photoStream); Visitor whitelistedVisitor = new Visitor(visitorName, folder, visitorImage, visitorIDPhotoGridMaxWidth); whitelistedVisitors.Add(whitelistedVisitor); } }
/// <summary> /// Initializes a new UserProfileObject with relevant information /// </summary> public UserProfileObject(Visitor visitor, WebcamHelper webcamHelper) { Visitor = visitor; WebcamHelper = webcamHelper; }