private void ToTarget(INavigationTarget target) { Navigated?.Invoke(this, target); switch (target) { case ListTarget l: SelectedListChanged?.Invoke(this, l.ListId); break; default: break; } }
public async Task SelectListAsync(ToDoList list) { if (list.Id == SelectedList?.Id) { return; } SelectedList = list; await SelectedListChanged.InvokeAsync(list) .ConfigureAwait(true); OnStateChanged(); }
private void Navigator_SelectedListChanged(object sender, int listId) { Todos.Clear(); foreach (var todo in _todos.Where(x => x.ListId == listId)) { Todos.Add(new TodoViewModel { Todo = todo }); } var vm = TodoLists.FirstOrDefault(x => x.TodoList.Id == listId); SelectedListChanged?.Invoke(this, vm); }
private void Item_SelectedChanged(object sender, EventArgs e) { FileListItem fileItem = (FileListItem)sender; if (fileItem.Selected) { SelectedFiles.Add(fileItem.File); } else { SelectedFiles.Remove(fileItem.File); } SelectedListChanged?.Invoke(this, EventArgs.Empty); }
public async Task EditListAsync(ToDoList list, string newName) { try { var item = await _listsService.EditListAsync(list.Id, newName) .ConfigureAwait(true); list.Name = item.Name; if (SelectedList?.Id == list.Id) { await SelectedListChanged.InvokeAsync(SelectedList) .ConfigureAwait(true); } OnStateChanged(); } catch (Exception ex) { await ShowErrorAsync(ex) .ConfigureAwait(true); } }
public async Task RemoveListAsync(ToDoList list) { try { await _listsService.DeleteListAsync(list.Id) .ConfigureAwait(true); Lists.Remove(list); if (SelectedList?.Id == list.Id) { SelectedList = null; await SelectedListChanged.InvokeAsync(null) .ConfigureAwait(true); } OnStateChanged(); } catch (Exception ex) { await ShowErrorAsync(ex) .ConfigureAwait(true); } }