public StickyNote CreateNote(string nameTag) { // Create the new note StickyNote newNote = new StickyNote(nameTag); newNote.NoteIsFor = FamilyModel.PersonFromName(nameTag); FamilyModel.StickyNotes.Add(newNote); return(newNote); }
private async void AddNewPersonDialog(Person currentPerson) { var dialog = new AddPersonContentDialog(); dialog.ProvideExistingPerson(currentPerson); await dialog.ShowAsync(); Person newPerson = dialog.AddedPerson; // If there is a valid person to add, add them if (newPerson != null) { // Get or create a directory for the user (we do this regardless of whether or not there is a profile picture) StorageFolder userFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(("Users\\" + newPerson.FriendlyName), CreationCollisionOption.OpenIfExists); // See if we have a profile photo if (dialog.TemporaryFile != null) { // Save off the profile photo and delete the temporary file await dialog.TemporaryFile.CopyAsync(userFolder, "ProfilePhoto.jpg", NameCollisionOption.ReplaceExisting); await dialog.TemporaryFile.DeleteAsync(); // Update the profile picture for the person newPerson.IsProfileImage = true; newPerson.ImageFileName = userFolder.Path + "\\ProfilePhoto.jpg"; if (AppSettings.FaceApiKey != "") { await FacialSimilarity.AddTrainingImageAsync(newPerson.FriendlyName, new Uri($"ms-appdata:///local/Users/{newPerson.FriendlyName}/ProfilePhoto.jpg")); } } // Add the user if it is new now that changes have been made if (currentPerson == null) { await FamilyModel.AddPersonAsync(newPerson); } // Otherwise we had a user, so update the current one else { //await FamilyModel.UpdatePersonImageAsync(newPerson); Person personToUpdate = FamilyModel.PersonFromName(currentPerson.FriendlyName); if (personToUpdate != null) { personToUpdate.IsProfileImage = true; personToUpdate.ImageFileName = userFolder.Path + "\\ProfilePhoto.jpg"; } } } }
public void Public_ShowNotesForPerson(string nameTag) { Person selectedPerson = FamilyModel.PersonFromName(nameTag); taskPanel.FilterNotes(selectedPerson); // Determine whether or not we are currently filtering if (selectedPerson.FriendlyName == _unfilteredName) { CurrentlyFiltered = false; } else { CurrentlyFiltered = true; } }
/// <summary> /// Display a friendly greeting at the top of the screen. /// </summary> /// <param name="name">Name of user for the salutation</param> private async void UpdateGreeting(string name) { var now = DateTime.Now; var greeting = now.Hour < 12 ? "Good morning" : now.Hour < 18 ? "Good afternoon" : /* otherwise */ "Good night"; var person = (string.IsNullOrEmpty(name) || name == App.EVERYONE) ? "!" : $", {name}!"; TextGreeting.Text = $"{greeting}{person}"; if (!string.IsNullOrEmpty(name) && (name != App.EVERYONE)) { await _dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { var SpeakGreeting = $"{greeting} {name}"; var notes = taskPanel.CountNotes(FamilyModel.PersonFromName(name)); if (notes > 0) { if (notes == 1) { SpeakGreeting += ",there is a note for you."; } else { SpeakGreeting += $",there are {notes} notes for you."; } } await this._speechManager.SpeakAsync( SpeakGreeting, this._media); }); } }