Ejemplo n.º 1
0
        private async void Button_ClickSave(object sender, RoutedEventArgs e)
        {
            //make sure user enters a file name. does not need to be unique, as saveaudiotofile will create a unique file if the file name already exists
            bool validateName = ValidateFileName();

            if (validateName)
            {
                //set values
                CreateVoiceMemo.DisplayName = displayName.Text;
                //unfortunately, we don't know the file name for sure until this is ran
                CreateVoiceMemo.FileName = await this._audioRecorder.SaveAudioToFile();

                CreateVoiceMemo.FullFilePath      = $"{Windows.ApplicationModel.Package.Current.InstalledLocation.Path}\\VoiceNotes";
                CreateVoiceMemo.RecordingDuration = await _audioRecorder.GetAudioDuration(CreateVoiceMemo.FileName);

                CreateVoiceMemo.DateRecorded = _audioRecorder.GetDateRecorded();
                DateTime timeRecorded = _audioRecorder.GetTimeRecorded();
                // insert the voice memo's details into the database
                StoredProcedures.CreateVoiceNote(CreateVoiceMemo.FileName, CreateVoiceMemo.DisplayName, CreateVoiceMemo.RecordingDuration, CreateVoiceMemo.FullFilePath, CreateVoiceMemo.DateRecorded, timeRecorded);

                // refresh the voice memo list and hide our controls while showing the record button
                this.PopulateListOfVoiceMemos();
                this.displayName.Text = "";
                this.HideInitialControls();
                this.startRecording.Visibility = Visibility.Visible;
            }
            else
            {
                DisplayEnterNameDialog();
            }
        }