private void SetUpUI() { this.StartRecordingButton = VoiceMemoUIHelper.BuildStartRecordingButton(this.StartRecording); this.StopRecordingButton = VoiceMemoUIHelper.BuildStopRecordingButton(this.StopRecording); this.SaveRecordingButton = VoiceMemoUIHelper.BuildSaveRecordingButton(this.SaveRecording); this.DeleteRecordingButton = VoiceMemoUIHelper.BuildDeleteRecordingButton(this.DeleteRecording); this.RecordingNameBox = VoiceMemoUIHelper.BuildDisplayNameTextBox(); // relatively place all the components RelativePanel.SetAlignVerticalCenterWithPanel(StartRecordingButton, true); RelativePanel.SetAlignHorizontalCenterWithPanel(StartRecordingButton, true); RelativePanel.SetAlignVerticalCenterWithPanel(StopRecordingButton, true); RelativePanel.SetAlignHorizontalCenterWithPanel(StopRecordingButton, true); RelativePanel.SetAlignVerticalCenterWithPanel(SaveRecordingButton, true); RelativePanel.SetAlignHorizontalCenterWithPanel(SaveRecordingButton, true); RelativePanel.SetAlignVerticalCenterWithPanel(DeleteRecordingButton, true); RelativePanel.SetAlignHorizontalCenterWithPanel(DeleteRecordingButton, true); // place the save and delete buttons next to each other RelativePanel.SetLeftOf(DeleteRecordingButton, SaveRecordingButton); // place the text box below the save button RelativePanel.SetBelow(RecordingNameBox, SaveRecordingButton); RelativePanel.SetAlignLeftWith(RecordingNameBox, SaveRecordingButton); RelativePanel.SetAlignRightWith(RecordingNameBox, SaveRecordingButton); // hide all our buttons except the start recording one this.ResetUIComponents(); // now add everything to the dynamic area this.DynamicArea.Children.Add(StartRecordingButton); this.DynamicArea.Children.Add(StopRecordingButton); this.DynamicArea.Children.Add(SaveRecordingButton); this.DynamicArea.Children.Add(DeleteRecordingButton); this.DynamicArea.Children.Add(RecordingNameBox); }
private void SaveRecording() { // make sure to run this in the main thread so that we can access our recording name box Utils.RunOnMainThread(async() => { if (StringUtils.IsNotBlank(this.RecordingNameBox.Text)) { try { string DisplayName = RecordingNameBox.Text; string FileName = await this.AudioRecorder.SaveAudioToFile(); string FullFilePath = $"{Windows.ApplicationModel.Package.Current.InstalledLocation.Path}\\VoiceNotes"; int RecordingDuration = await this.AudioRecorder.GetAudioDuration(FileName); DateTime DateRecorded = this.AudioRecorder.GetDateRecorded(); DateTime timeRecorded = this.AudioRecorder.GetTimeRecorded(); // insert the voice memo into the database StoredProcedures.CreateVoiceNote(FileName, DisplayName, RecordingDuration, FullFilePath, DateRecorded, DateRecorded); // clear our dynamic area and show the ui for the newly-recorded voice memo this.ClearArea(); RelativePanel voiceMemoPanel = VoiceMemoUIHelper.BuildVoiceMemoPanel(StoredProcedures.QueryLatestVoiceMemo(), this.AudioRecorder, () => Utils.RunOnMainThread(() => this.ClearArea())); // position the panel in the center of the panel RelativePanel.SetAlignHorizontalCenterWithPanel(voiceMemoPanel, true); RelativePanel.SetAlignVerticalCenterWithPanel(voiceMemoPanel, true); this.DynamicArea.Children.Add(voiceMemoPanel); } catch (Exception) { // TODO display an error message } } else { UIUtils.HighlightUIElement(this.RecordingNameBox); } }); }
private void BuildMemoPanel(VoiceMemo VoiceMemoToAdd) { this.VoiceNoteList.Children.Add(VoiceMemoUIHelper.BuildVoiceMemoPanel(VoiceMemoToAdd, this._audioRecorder, PopulateListOfVoiceMemos)); }