コード例 #1
0
		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);
//			}
		}
コード例 #2
0
		public async Task SaveTaskAsync (TodoItem item)
		{
			if (item.ID == null)
				await todoTable.InsertAsync(item);
			else
				await todoTable.UpdateAsync(item);
		}
コード例 #3
0
 // 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);
 }
コード例 #4
0
		public int SaveItem (TodoItem item) 
		{
			lock (locker) {
				if (item.ID != 0) {
					database.Update(item);
					return item.ID;
				} else {
					return database.Insert(item);
				}
			}
		}
コード例 #5
0
		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);
			}
		}
コード例 #6
0
		/// <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 ();
		}
コード例 #7
0
		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);
			}
		}
コード例 #8
0
		public Task DeleteTaskAsync (TodoItem item)
		{
			return storage.DeleteTodoItemAsync(item);
		}
コード例 #9
0
		public Task SaveTaskAsync (TodoItem item)
		{
			return storage.SaveTodoItemAsync(item);
		}
コード例 #10
0
        public int SaveItem(TodoItem item)
        {
            lock (locker)
            {
                if (item.ID == 0)
                    return database.Insert(item);

                database.Update(item);
                return item.ID;
            }
        }