/// <summary> /// Initializes a new instance of the <see cref="PhraseRecognizedEventArgs"/> class. /// </summary> /// <param name="person">The Person who the note is addressed to.</param> /// <param name="phrase">The phrase provided by the speech recognizer.</param> /// <param name="speechRecognitionArgs">Event data from the speech recognizer.</param> public PhraseRecognizedEventArgs( Person person, string phrase, CommandVerb verb, SpeechContinuousRecognitionResultGeneratedEventArgs speechRecognitionArgs) { PhraseTargetPerson = person; PhraseText = phrase; Verb = verb; IsDictation = speechRecognitionArgs.Result.Constraint == null ? false : Verb == CommandVerb.Dictation; }
public void ProvideExistingPerson(Person currentPerson) { if (currentPerson == null) return; // Change UI slightly depending on if a photo already exists, or if this is the first time // we're seeing this dialog to create a person. PersonName.Text = currentPerson.FriendlyName; PersonName.IsReadOnly = true; textBlock.Text = ""; IsPrimaryButtonEnabled = true; PrimaryButtonText = "Update photo"; // Set the image to the current image, if it exists if (currentPerson.ImageFileName != TemporaryImagePath) { Uri imageUri = new Uri(currentPerson.ImageFileName, UriKind.Relative); BitmapImage imageBitmap = new BitmapImage(imageUri); image.Source = imageBitmap; } }
private void ContentDialog_CancelButton_Click(ContentDialog sender, ContentDialogButtonClickEventArgs args) { AddedPerson = null; // abandon adding a new person }
private void ContentDialog_AddPerson_Click(ContentDialog sender, ContentDialogButtonClickEventArgs args) { AddedPerson = new Person(PersonName.Text, TemporaryImagePath); }
/// <summary> /// Adds a person to the family collection and updates speech /// to be aware of their name. /// </summary> /// <param name="newPerson"></param> public async Task AddPersonAsync(Person newPerson) { _family.Add(newPerson); await UpdateVCDPhraseList(); }
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 StickyNote CreateNote(Person person) { // Create the new note StickyNote newNote = new StickyNote(person); FamilyModel.StickyNotes.Add(newNote); return newNote; }