in FamilyNotes/MainPage.xaml.cs [365:407]
private async Task EnableFaceDetection()
{
// Inform the user if we do not have a Azure Face service key and then exit without doing anything.
if (AppSettings.FaceApiKey == "")
{
ContentDialog noFaceKeyDialog = new ContentDialog
{
Title = "No Azure Face key",
Content = "You need an Azure Face service key, which you define in settings, to use facial recognition.",
CloseButtonText = "Ok"
};
await noFaceKeyDialog.ShowAsync();
FaceDetectionButton.IsChecked = false;
return;
}
if (SetCameraButton.IsEnabled)
{
// Make sure the user accepts privacy implications.
var dialog = new WarningDialog();
await dialog.ShowAsync();
if (dialog.WarningAccept == false)
{
FaceDetectionButton.IsChecked = false;
return;
}
}
bool result = await _presence.EnableFaceDetection();
if (result)
{
_presence.FilterOnFace += UserFilterFromDetection;
}
else
{
_presence.FilterOnFace -= UserFilterFromDetection;
}
ImageWarningBar.IsOpen = result;
// Update the face detection icon depending on whether the effect exists or not.
(FaceDetectionButton.Icon as SymbolIcon).Symbol = (result) ? Symbol.View : Symbol.WebCam;
SetCameraButton.IsEnabled = result != true;
}