public TodoListXaml () { InitializeComponent (); var tbi = new ToolbarItem ("+", null, () => { var todoItem = new TodoItem(); var todoPage = new TodoItemXaml(); todoPage.BindingContext = todoItem; Navigation.PushAsync(todoPage); }, 0, 0); if (Device.OS == TargetPlatform.Android) { // BUG: Android doesn't support the icon being null tbi = new ToolbarItem ("+", "plus", () => { var todoItem = new TodoItem(); var todoPage = new TodoItemXaml(); todoPage.BindingContext = todoItem; Navigation.PushAsync(todoPage); }, 0, 0); } ToolbarItems.Add (tbi); // if (Device.OS == TargetPlatform.iOS) { // var tbi2 = new ToolbarItem ("?", null, () => { // var todos = App.Database.GetItemsNotDone(); // var tospeak = ""; // foreach (var t in todos) // tospeak += t.Name + " "; // if (tospeak == "") tospeak = "there are no tasks to do"; // App.Speech.Speak(tospeak); // }, 0, 0); // ToolbarItems.Add (tbi2); // } }
public async Task SaveTaskAsync (TodoItem item) { if (item.ID == null) await todoTable.InsertAsync(item); else await todoTable.UpdateAsync(item); }
// menu item click public void OnAdd(object sender, EventArgs e) { //create a new model var model = new TodoItem (); //create a new view var view = new TodoDetailsView (model); // tell the navigator to show the new view Navigation.PushAsync (view, true); }
public int SaveItem (TodoItem item) { lock (locker) { if (item.ID != 0) { database.Update(item); return item.ID; } else { return database.Insert(item); } } }
public async Task DeleteTaskAsync (TodoItem item) { try { await todoTable.DeleteAsync(item); } catch (MobileServiceInvalidOperationException msioe) { Debug.WriteLine(@"INVALID {0}", msioe.Message); } catch (Exception e) { Debug.WriteLine(@"ERROR {0}", e.Message); } }
/// <summary> /// Initializes a new instance of the <see cref="TodoXaml.TodoDetailsView"/> class. /// </summary> /// <param name="model">Instance we want to display</param> public TodoDetailsView (TodoItem model) { // Bind our BindingContext Model = model; NavigationPage.SetHasNavigationBar (this, true); // Set the title if (Model.ID == 0) Title = "New Todo Item !"; else Title = String.Format ("Todo Item #{0}", Model.ID); //Run our Xaml InitializeComponent (); }
public TodoListXaml () { InitializeComponent (); // HACK: workaround issue #894 for now if (Device.OS == TargetPlatform.iOS) listView.ItemsSource = new string [1] {""}; var tbi = new ToolbarItem ("+", null, () => { var todoItem = new TodoItem(); var todoPage = new TodoItemXaml(); todoPage.BindingContext = todoItem; Navigation.PushAsync(todoPage); }, 0, 0); if (Device.OS == TargetPlatform.Android) { // BUG: Android doesn't support the icon being null tbi = new ToolbarItem ("+", "plus", () => { var todoItem = new TodoItem(); var todoPage = new TodoItemXaml(); todoPage.BindingContext = todoItem; Navigation.PushAsync(todoPage); }, 0, 0); } ToolbarItems.Add (tbi); if (Device.OS == TargetPlatform.iOS) { var tbi2 = new ToolbarItem ("?", null, () => { var todos = App.Database.GetItemsNotDone(); var tospeak = ""; foreach (var t in todos) tospeak += t.Name + " "; if (tospeak == "") tospeak = "there are no tasks to do"; App.Speech.Speak(tospeak); }, 0, 0); ToolbarItems.Add (tbi2); } }
public Task DeleteTaskAsync (TodoItem item) { return storage.DeleteTodoItemAsync(item); }
public Task SaveTaskAsync (TodoItem item) { return storage.SaveTodoItemAsync(item); }
public int SaveItem(TodoItem item) { lock (locker) { if (item.ID == 0) return database.Insert(item); database.Update(item); return item.ID; } }