private async void EditNote_Click(object sender, RoutedEventArgs e) { // The button is only clickable when there's exactly one item selected // (baring race conditions, of course) foreach (var item in uiList.SelectedItems) { var note = item as UserNoteWithTitle; if (note == null) { continue; // should never happen } var edited = await NoteEditor.EditNoteAsync(ControlId, note.BaseNote); if (edited) { // Update the list... for (int i = 0; i < Notes.Count; i++) { if (Notes[i].Id == note.Id) { Notes.RemoveAt(i); Notes.Insert(i, new UserNoteWithTitle(note.BaseNote, note.DisplayTitle)); } } } } }
private async void OnAddNote(object sender, RoutedEventArgs e) { var location = GetCurrBookLocation().ToJson(); string currSelection = ""; if (CurrHtml != null && CurrHtml.Contains("DoGetSelection")) { currSelection = await uiHtml.InvokeScriptAsync("DoGetSelection", null); } var note = new UserNote() { BookId = BookData.BookId, CreateDate = DateTimeOffset.Now, Location = location, Text = currSelection, }; await NoteEditor.EditNoteAsync(ControlId, note); }