void AddNewItem() { TodoItemViewModel Item = new TodoItemViewModel(); Items.Add(Item); Application.Current.MainPage.Navigation.PushModalAsync(new TodoItemDetail(Item)); }
void UpdateItem(TodoItemViewModel item) { Application.Current.MainPage.Navigation.PushModalAsync(new TodoItemDetail(item)); }
async void SpeakItem() { //change isSpeech to false if you want text interface. bool isSpeech = true; if (isSpeech) { try { if (Device.OS == TargetPlatform.Android) { audioDirectoryPath = "/sdcard/"; } else if (Device.OS == TargetPlatform.iOS) { audioDirectoryPath = ""; } DependencyService.Get <IAudio>().StopAudio(); if (recording) { DependencyService.Get <IAudio>().StopRecording(); //set the selected recognition mode & profanity mode bingSpeechClient.RecognitionMode = RecognitionMode.Interactive; bingSpeechClient.ProfanityMode = ProfanityMode.Masked; //if we're not streaming the audio as we're recording, we'll use the file-based STT API here if (audioFilePath != null) { DependencyService.Get <IAudio>().PlayAudio(audioFilePath); resultText = await SpeechToText(audioFilePath); } recording = !recording; //TODO: Update UI to indicate recording is done } else { var dateTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture); audioFilePath = audioDirectoryPath + dateTime + extension; DependencyService.Get <IAudio>().StartRecording(audioFilePath); recording = !recording; //TODO: Update UI to indicate recording is in progress return; } } catch (Exception ex) { } } else { resultText = await InputBox(); //simple text input } IsBusy = true; await DependencyService.Get <IBotConnection>().SendMessageAsync(resultText); var message = DependencyService.Get <IBotConnection>().GetMessagesAsync().Result; //Bot is directly sending detected entity in message, ideally it should be sent as parameters. TodoItemViewModel Item = new TodoItemViewModel() { Title = message, Text = "Today", IsDone = false }; Items.Add(Item); IsBusy = false; }
public TodoItemDetail(TodoItemViewModel Item) { InitializeComponent(); BindingContext = Item; }