Example #1
0
        // Add a voice note to the Azure database and the local
        // CollectionView for display if successful
        private async void AddVoiceNoteAsync(VoiceNote note)
        {
            //Verify network connectivity is available before attempting to add note to database
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                MessageBox.Show("Network connection unavailable. Please close app, verify your network connection, and try again.");
                return;
            }

            bool added = true;

            try
            {
                await noteTable.InsertAsync(note);
            }
            catch (MobileServiceInvalidOperationException)
            {
                added = false;
            }

            if (added)
            {
                notes.Add(note);
            }
            else
            {
                MessageBox.Show("Error adding note. The selected note was not added to the server. Verify that you are logged in and that a network connection is available.");
            }
        }
Example #2
0
        // Removes a specific VoiceNote from the Azure database. When the Azure Mobile Service
        // responds, the item is removed from the local list
        private async void DeleteNoteAsync(VoiceNote note)
        {
            //Verify network connectivity is available before attempting to add note to database
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                MessageBox.Show("Network connection unavailable. Please close app, verify your network connection, and try again.");
                return;
            }

            bool deleted = true;

            try
            {
                await noteTable.DeleteAsync(note);
            }
            catch (MobileServiceInvalidOperationException)
            {
                deleted = false;
            }

            if (deleted)
            {
                notes.Remove(note);
            }
            else
            {
                MessageBox.Show("Error with deletion. The selected note(s) have not been removed from the server.");
            }
        }
Example #3
0
        // Initiate the capture of a voice note and store it to the
        // Azure database if the user is satisfied
        private async void speechBtn_Click(object sender, EventArgs e)
        {
            // Begin recognition using the default grammar and store the result.
            SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync();

            // Check that a result was obtained
            if (recoResult.RecognitionResult != null)
            {
                // Determine if the user wants to save the note.
                var result = MessageBox.Show(string.Format("Heard you say \"{0}\" Save?", recoResult.RecognitionResult.Text), "Confirmation", MessageBoxButton.OKCancel);

                // Save the result to the Azure Mobile Service DB if the user is satisfied.
                if (result == MessageBoxResult.OK)
                {
                    var note = new VoiceNote {
                        Text = recoResult.RecognitionResult.Text
                    };
                    AddVoiceNoteAsync(note);
                }
            }
        }