Пример #1
0
        private async void createWarningInfo(Person person)
        {
            WarningImage.Visibility = Visibility.Visible;

            //Dialog Appearance
            RiskGrid.Visibility               = Visibility.Visible;
            VideoStackPanel.Visibility        = Visibility.Visible;
            PersonDialog.Title                = "Stranger Warning Enquiry";
            PersonDialogPanel.BorderThickness = new Thickness(3, 3, 3, 3);

            //Show the Person's Data
            defaultImage.Source = await AzureBlobService.DisplayImageFile(person.DefaultImageAddress);

            //TODO: find a list of face images...
        }
Пример #2
0
        }//end addPersonButton_Click

        private async void WarningImage_Tapped(object sender, TappedRoutedEventArgs e)
        {
            //get the stranger info
            thisPerson = await AzureDatabaseService.GetOnePersonFromId(unfinishedWarningList[0].PersonId);

            defaultImage.Source = await AzureBlobService.DisplayImageFile(thisPerson.DefaultImageAddress);

            familiarRadioButton.IsChecked = thisPerson.IsFamiliar;
            strangeRadioButton.IsChecked  = !thisPerson.IsFamiliar;

            //Update Faces
            Faces.Clear();
            ObservableCollection <Face> faces = await AzureDatabaseService.GetFaceList(thisPerson.Id);

            foreach (Face face in faces)
            {
                face.Image = await AzureBlobService.DisplayImageFile(face.ImageAddress);

                Faces.Add(face);
            }


            var result = await PersonDialog.ShowAsync();

            // Value 1 indicates primary button was selected by the user, which modify the Person
            if ((int)result == 1)
            {
                //Enable the Update of Person Info
                //Apply the Data
                showProgressDialog("Apply the Data...");
                thisPerson.Name       = PersonNameInput.Text;
                thisPerson.Relation   = PersonRelationInput.Text;
                thisPerson.RiskFactor = (int)riskSlider.Value;

                //Upload Person Info
                progressDialog.Content = "Update Person Info...";
                await AzureDatabaseService.UpdatePersonInfoWithId(thisPerson);

                //Upload Face Info
                progressDialog.Content = "Upload Faces and Images...";
                foreach (Face face in addFaceList)
                {
                    face.PersonId = thisPerson.Id;
                }
                await AzureDatabaseService.UploadFaceInfo(thisPerson.Id, addFaceList);

                foreach (Face face in deleteFaceList)
                {
                    await AzureDatabaseService.DeleteFace(face);
                }

                //TODO: Cannot update the default image address in the Person

                //Operate the Enquiry Info
                progressDialog.Content = "Operate the Enquiry Info...";
                Warning thisWarning = unfinishedWarningList[0];
                thisWarning.IsFinished = true;
                thisWarning.IsFamiliar = thisPerson.IsFamiliar;
                await AzureDatabaseService.UpdateWarningEnquiryWithId(thisWarning);

                //Reload Persons List
                loadPersonsAndCheckEnquiry();

                //Add a Person Finished!
                progressDialog.Content = "Operate the Enquiry Finished !";
                progressDialog.IsPrimaryButtonEnabled = true;
            }//end result == 1


            initializePersonInfoDialog();
        }
Пример #3
0
        private async void personGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            //Update Person Info
            thisPerson = e.ClickedItem as Person;
            familiarRadioButton.IsChecked = thisPerson.IsFamiliar;
            strangeRadioButton.IsChecked  = !thisPerson.IsFamiliar;
            PersonNameInput.Text          = thisPerson.Name;
            PersonRelationInput.Text      = thisPerson.Relation;
            if (thisPerson.DefaultImageAddress != null)
            {
                defaultImage.Source = thisPerson.DefaultIcon; //await AzureBlobService.DisplayImageFile(thisPerson.DefaultImageAddress);
            }
            else
            {
                defaultImage.Source = nullBitmapImage;
            }
            riskSlider.Value = thisPerson.RiskFactor;

            //Update Faces
            Faces.Clear();
            ObservableCollection <Face> faces = await AzureDatabaseService.GetFaceList(thisPerson.Id);

            foreach (Face face in faces)
            {
                face.Image = await AzureBlobService.DisplayImageFile(face.ImageAddress);

                Faces.Add(face);
            }

            //Show the Person Info Dialog
            var result = await PersonDialog.ShowAsync();

            // Value 1 indicates primary button was selected by the user, which modify a new Person
            if ((int)result == 1)
            {
                //Enable the Update of Person Info
                //Apply the Data
                showProgressDialog("Apply the Data...");
                thisPerson.Name       = PersonNameInput.Text;
                thisPerson.Relation   = PersonRelationInput.Text;
                thisPerson.RiskFactor = (int)riskSlider.Value;

                //Upload Person Info
                progressDialog.Content = "Update Person Info...";
                await AzureDatabaseService.UpdatePersonInfoWithId(thisPerson);

                //Upload Face Info
                progressDialog.Content = "Upload Faces and Images...";
                foreach (Face face in addFaceList)
                {
                    face.PersonId = thisPerson.Id;
                    Faces.Remove(face);
                }

                ObservableCollection <Face> newAddFaceList = await AzureDatabaseService.UploadFaceInfo(thisPerson.Id, addFaceList);

                foreach (Face face in addFaceList)
                {
                    Faces.Add(face);
                }

                foreach (Face face in deleteFaceList)
                {
                    await AzureDatabaseService.DeleteFace(face);
                }

                try
                {
                    await AzureDatabaseService.UpdateFaceIsDefault(thisPerson.Id, Faces);
                }
                catch
                {
                }

                //Reload Persons List
                loadPersonsAndCheckEnquiry();

                //Add a Person Finished!
                progressDialog.Content = "Update a Person Finished !";
                progressDialog.IsPrimaryButtonEnabled = true;
            }//end result == 1

            initializePersonInfoDialog();

            deletePersonButton.IsEnabled = true;
        }
Пример #4
0
        /// <summary>
        /// Test Internet Connection and Load Persons and Faces
        /// </summary>
        private async void testInternetConnection()
        {
            //Test Internet Connection
            try
            {
                showProgressDialog("Checking the Internet Connection and Loading the data...");
                progressDialog.Title             = "Processing: ";
                progressDialog.PrimaryButtonText = "Ok";
                //statusTextBlock.Text = "Checking the Internet Connection...";

                //Get Person List for this patient
                Persons.Clear();
                ObservableCollection <Person> persons = await AzureDatabaseService.GetPersonList(PatientId);

                //statusTextBlock.Text = persons.Count + " Persons: ";

                //Clear Local User Folder
                StorageFolder userFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(("Users\\"), CreationCollisionOption.OpenIfExists);

                await userFolder.DeleteAsync();

                userFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync(("Users\\"), CreationCollisionOption.OpenIfExists);

                //Perform initialization for facial detection.
                await FacialSimilarity.TrainDetectionAsync();

                //Download each person
                foreach (Person person in persons)
                {
                    //Update Info
                    person.DefaultIcon = await AzureBlobService.DisplayImageFile(person.DefaultImageAddress);

                    Persons.Add(person);

                    //Get Face List for each person
                    ObservableCollection <Face> faces = await AzureDatabaseService.GetFaceList(person.Id);

                    foreach (Face face in faces)
                    {
                        face.Image = await AzureBlobService.DisplayImageFile(face.ImageAddress);
                    }
                    Faces.Add(faces);

                    AddNewPersonFromDB(person, faces);

                    //statusTextBlock.Text += faces.Count + " faces ";
                }
            }
            catch (System.Net.Http.HttpRequestException)
            {
                internetConnection = false;
                //statusTextBlock.Text = " ";
                //showProgressDialog("Internet Connection Error! Please check your Internet connection.");
                progressDialog.Title                  = "Internet Connection Error!";
                progressDialog.PrimaryButtonText      = "Ok, I know";
                progressDialog.IsPrimaryButtonEnabled = true;
                //await progressDialog.ShowAsync();

                return;
                //Test Internet Connection Again
                //testInternetConnection();
            }

            internetConnection = true;
            //statusTextBlock.Text = "Internet Connection Success!";
            progressDialog.Content = "Success!";
            progressDialog.IsPrimaryButtonEnabled = true;
            return;
        }