Inheritance: Xamarin.Forms.ContentPage
		protected override void OnStart()
		{
			Debug.WriteLine ("OnStart");

			// always re-set when the app starts
			// users expect this (usually)
//			Properties ["ResumeAtTodoId"] = "";
			if (Properties.ContainsKey ("ResumeAtTodoId")) {
				var rati = Properties ["ResumeAtTodoId"].ToString();
				Debug.WriteLine ("   rati="+rati);
				if (!String.IsNullOrEmpty (rati)) {
					Debug.WriteLine ("   rati = " + rati);
					ResumeAtTodoId = int.Parse (rati);

					if (ResumeAtTodoId >= 0) {
						var todoPage = new TodoItemPage ();
						todoPage.BindingContext = Database.GetItem (ResumeAtTodoId);

						MainPage.Navigation.PushAsync (
							todoPage,
							false); // no animation
					}
				}
			}
		}
		public TodoListPage ()
		{
			Title = AppResources.ApplicationTitle; // "Todo";

			listView = new ListView { RowHeight = 40 };
			listView.ItemTemplate = new DataTemplate (typeof (TodoItemCell));

			listView.ItemSelected += (sender, e) => {
				var todoItem = (TodoItem)e.SelectedItem;

				// use C# localization
				var todoPage = new TodoItemPage();

				// use XAML localization
//				var todoPage = new TodoItemXaml();


				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			};

			var layout = new StackLayout();
			if (Device.OS == TargetPlatform.WinPhone) { // WinPhone doesn't have the title showing
				layout.Children.Add(new Label{Text="Todo", Font=Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold)});
			}
			layout.Children.Add(listView);
			layout.VerticalOptions = LayoutOptions.FillAndExpand;
			Content = layout;


			var tbiAdd = new ToolbarItem("Add", "plus.png", () =>
				{
					var todoItem = new TodoItem();
					var todoPage = new TodoItemPage();
					todoPage.BindingContext = todoItem;
					Navigation.PushAsync(todoPage);
				}, 0, 0);


			ToolbarItems.Add (tbiAdd);


			var tbiSpeak = new ToolbarItem ("Speak", "chat.png", () => {
				var todos = App.Database.GetItemsNotDone();
				var tospeak = "";
				foreach (var t in todos)
					tospeak += t.Name + " ";
				if (tospeak == "") tospeak = "there are no tasks to do";

				if (todos.Any ()) {
					var s = L10n.Localize ("SpeakTaskCount", "Number of tasks to do");
					tospeak = String.Format (s, todos.Count ()) + tospeak;
				}

				DependencyService.Get<ITextToSpeech>().Speak(tospeak);
			}, 0, 0);
			ToolbarItems.Add (tbiSpeak);


		}
		public TodoListPage ()
		{
			Title = "Todo";

			NavigationPage.SetHasNavigationBar (this, true);

			listView = new ListView {
			    RowHeight = 40
			};
			listView.ItemTemplate = new DataTemplate (typeof (TodoItemCell));

			listView.ItemSelected += (sender, e) => {
				var todoItem = (TodoItem)e.SelectedItem;
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			};

			var layout = new StackLayout();
			if (Device.OS == TargetPlatform.WinPhone) { // WinPhone doesn't have the title showing
				layout.Children.Add(new Label{Text="Todo", Font=Font.SystemFontOfSize(NamedSize.Large, FontAttributes.Bold)});
			}
			layout.Children.Add(listView);
			layout.VerticalOptions = LayoutOptions.FillAndExpand;
			Content = layout;


			var tbiAdd = new ToolbarItem ("+", "plus.png", () => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			}, 0, 0);

			ToolbarItems.Add (tbiAdd);

			var tbiSpeak = new ToolbarItem ("?", "chat.png", () => {
				var todos = App.Database.GetItemsNotDone();
				var tospeak = "";
				foreach (var t in todos)
					tospeak += t.Name + " ";
				if (tospeak == "") tospeak = "there are no tasks to do";

				DependencyService.Get<ITextToSpeech>().Speak(tospeak);
			}, 0, 0);
			ToolbarItems.Add (tbiSpeak);

		}
		public TodoListPage ()
		{
			Title = "Todo";

			listView = new ListView ();
			listView.ItemTemplate = new DataTemplate 
					(typeof (TodoItemCell));
			listView.ItemSelected += (sender, e) => {
				var todoItem = (TodoItem)e.SelectedItem;
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;

				((App)App.Current).ResumeAtTodoId = todoItem.ID;
				Debug.WriteLine("setting ResumeAtTodoId = " + todoItem.ID);

				Navigation.PushAsync(todoPage);
			};

			var layout = new StackLayout();
			if (Device.OS == TargetPlatform.WinPhone) { // WinPhone doesn't have the title showing
				layout.Children.Add(new Label{
					Text="Todo", 
					FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label))});
			}
			layout.Children.Add(listView);
			layout.VerticalOptions = LayoutOptions.FillAndExpand;
			Content = layout;

			#region toolbar
			ToolbarItem tbi = null;
			if (Device.OS == TargetPlatform.iOS)
			{
				tbi = new ToolbarItem("+", null, () =>
					{
						var todoItem = new TodoItem();
						var todoPage = new TodoItemPage();
						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 TodoItemPage();
					todoPage.BindingContext = todoItem;
					Navigation.PushAsync(todoPage);
				}, 0, 0);
			}
			if (Device.OS == TargetPlatform.WinPhone)
			{
				tbi = new ToolbarItem("Add", "add.png", () =>
					{
						var todoItem = new TodoItem();
						var todoPage = new TodoItemPage();
						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";

					DependencyService.Get<ITextToSpeech>().Speak(tospeak);
				}, 0, 0);
				ToolbarItems.Add (tbi2);
			}
			#endregion
		}
Example #5
0
		public TodoListPage ()
		{
			Title = "Staff List";

			NavigationPage.SetHasNavigationBar (this, true);

			listView = new ListView {
				RowHeight = 40,
				ItemTemplate = new DataTemplate (typeof(TodoItemCell))
			};
					

			listView.ItemSelected += (sender, e) => {
				var todoItem = (TodoItem)e.SelectedItem;
				var todoPage = new TodoItemPage ();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync (todoPage);
			};

			var lv = new ListView();
			lv.BackgroundColor = Color.Yellow;

			var layout = new StackLayout ();
			if (Device.OS == TargetPlatform.WinPhone) { // WinPhone doesn't have the title showing
				layout.Children.Add (new Label {
					Text = "Staff List",
					FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
					FontAttributes = FontAttributes.Bold
				});
			}
			layout.Children.Add (listView);
			layout.VerticalOptions = LayoutOptions.FillAndExpand;
			Content = layout;


			ToolbarItem tbi = null;
			if (Device.OS == TargetPlatform.iOS) {
				tbi = new ToolbarItem ("+", null, () => {
					var todoItem = new TodoItem ();
					var todoPage = new TodoItemPage ();
					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 TodoItemPage ();
					todoPage.BindingContext = todoItem;
					Navigation.PushAsync (todoPage);
				}, 0, 0);
			}

			if (Device.OS == TargetPlatform.WinPhone) {
				tbi = new ToolbarItem ("Add", "add.png", () => {
					var todoItem = new TodoItem ();
					var todoPage = new TodoItemPage ();
					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";

					DependencyService.Get<ITextToSpeech> ().Speak (tospeak);
				}, 0, 0);
				ToolbarItems.Add (tbi2);
			}
		}
		public TodoListPage ()
		{
			Title = "Todo";

			NavigationPage.SetHasNavigationBar (this, true);

			listView = new ListView {
			    RowHeight = 40
			};
			listView.ItemTemplate = new DataTemplate (typeof (TodoItemCell));

//			listView.ItemSource = new string [] { "Buy pears", "Buy oranges", "Buy mangos", "Buy apples", "Buy bananas" };
//			listView.ItemSource = new TodoItem [] { 
//				new TodoItem {Name = "Buy pears`"}, 
//				new TodoItem {Name = "Buy oranges`", Done=true},
//				new TodoItem {Name = "Buy mangos`"}, 
//				new TodoItem {Name = "Buy apples`", Done=true},
//				new TodoItem {Name = "Buy bananas`", Done=true}
//			};

			// HACK: workaround issue #894 for now
			if (Device.OS == TargetPlatform.iOS)
				listView.ItemsSource = new string [1] {""};

			listView.ItemSelected += (sender, e) => {
				var todoItem = (TodoItem)e.SelectedItem;
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			};

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {listView}
			};

			var tbi = new ToolbarItem ("+", null, () => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemPage();
				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 TodoItemPage();
					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 TodoListPage ()
		{
			Title = "Todo";

			NavigationPage.SetHasNavigationBar (this, true);

			listView = new ListView ();
			listView.ItemTemplate = new DataTemplate (typeof (TodoItemCell));

//			listView.ItemSource = new string [] { "Buy pears", "Buy oranges", "Buy mangos", "Buy apples", "Buy bananas" };
//			listView.ItemSource = new TodoItem [] { 
//				new TodoItem {Name = "Buy pears`"}, 
//				new TodoItem {Name = "Buy oranges`", Done=true},
//				new TodoItem {Name = "Buy mangos`"}, 
//				new TodoItem {Name = "Buy apples`", Done=true},
//				new TodoItem {Name = "Buy bananas`", Done=true}
//			};

			listView.ItemSelected += (sender, e) => {
				if (e.SelectedItem == null) {
					return; // ensures we ignore this handler when the selection is just being cleared
				}
				var todoItem = (TodoItem)e.SelectedItem;
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
				((ListView)sender).SelectedItem = null; // clears the 'selected' background
			};

			// make floating (+) image at bottom of screen
			var tap = new TapGestureRecognizer (async (View obj) => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;

				var b = newImage.Bounds;
				b.Y = b.Y - 50;

				await newImage.LayoutTo(b,250, Easing.SinIn);
				b.Y = b.Y + 50;
				await newImage.LayoutTo(b,250, Easing.SinOut);

				Navigation.PushAsync(todoPage);
			});
			newImage = new Image {
				Source = "newitem.png",
				WidthRequest = 40,
				Opacity = 0.8f
			};
			newImage.GestureRecognizers.Add (tap);

			layout = new RelativeLayout ();
			layout.Children.Add (listView, 
				xConstraint: Constraint.Constant(0), 
				yConstraint: Constraint.Constant(0), 
				widthConstraint: Constraint.RelativeToParent ((parent) => {return parent.Width;}),
				heightConstraint: Constraint.RelativeToParent ((parent) => {return parent.Height;}));
			layout.Children.Add (newImage, 
				xConstraint: Constraint.RelativeToParent((parent) =>
					{
						return (parent.Width / 2) - 20; // center of image (which is 40 wide)
					}),
				yConstraint: Constraint.RelativeToParent((parent) =>
					{
						return parent.Height - 60;
					}));
			Content = layout;


			#region toolbar
			var tbi = new ToolbarItem ("+", "plus.png", () => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			}, 0, 0);

			ToolbarItems.Add (tbi);

			if (Device.OS == TargetPlatform.iOS) {
				var tbi2 = new ToolbarItem ("?", "chat.png", () => {
					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);
			}
			#endregion
		}
		public TodoListPage ()
		{
			Title = "Todo";

			listView = new ListView {StyleId = "TodoList"};
			listView.ItemTemplate = new DataTemplate (typeof (TodoItemCell));

			listView.ItemSelected += async (sender, e) => {
				if (e.SelectedItem == null) {
					return; // ensures we ignore this handler when the selection is just being cleared
				}
				var todoItem = (TodoItem)e.SelectedItem;
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				await Navigation.PushAsync(todoPage);
				((ListView)sender).SelectedItem = null; // clears the 'selected' background
			};

			// make floating (+) image at bottom of screen
			var tap = new TapGestureRecognizer (async (View obj) => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;

				var b = newImage.Bounds;
				b.Y = b.Y - 50;

				await newImage.LayoutTo(b,250, Easing.SinIn);
				b.Y = b.Y + 50;
				await newImage.LayoutTo(b,250, Easing.SinOut);

				await Navigation.PushAsync(todoPage);
			});
			newImage = new Image {
				Source = "newitem.png",
				WidthRequest = 40,
				Opacity = 0.8f,
				StyleId = "TodoAdd"
			};
			newImage.GestureRecognizers.Add (tap);

			layout = new RelativeLayout ();
			layout.Children.Add (listView, 
				xConstraint: Constraint.Constant(0), 
				yConstraint: Constraint.Constant(0), 
				widthConstraint: Constraint.RelativeToParent ((parent) => {return parent.Width;}),
				heightConstraint: Constraint.RelativeToParent ((parent) => {return parent.Height;}));
			layout.Children.Add (newImage, 
				xConstraint: Constraint.RelativeToParent((parent) =>
					{
						return (parent.Width / 2) - 20; // center of image (which is 40 wide)
					}),
				yConstraint: Constraint.RelativeToParent((parent) =>
					{
						return parent.Height - 60;
					}));
			Content = layout;


			#region toolbar
			var tbiAdd = new ToolbarItem ("+", "plus.png", () => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			}, 0, 0);
			tbiAdd.StyleId = "ToolbarAdd";
			//tbiAdd.Order = ToolbarItemOrder.Secondary;
			ToolbarItems.Add (tbiAdd);

			var tbiSpeak = new ToolbarItem ("?", "chat.png", () => {
				var todos = App.Database.GetItemsNotDone();
				var tospeak = "";
				foreach (var t in todos)
					tospeak += t.Name + " ";
				if (tospeak == "") tospeak = "there are no tasks to do";

				DependencyService.Get<ITextToSpeech>().Speak("Hello from Xamarin Forms");

			}, 0, 0);
			tbiAdd.StyleId = "ToolbarSpeak";
			// demonstrate toolbar/optionmenu
			//tbiSpeak.Order = ToolbarItemOrder.Secondary;
			ToolbarItems.Add (tbiSpeak);

			#endregion
		}
        public TodoListPage()
        {
            Title = "Todo";

            NavigationPage.SetHasNavigationBar(this, true);

            listView = new ListView
            {
                RowHeight = 40
            };
            listView.ItemTemplate = new DataTemplate(typeof(TodoItemCell));

            // These commented-out lines were used to test the ListView prior to integrating the database
            //			listView.ItemSource = new string [] { "Buy pears", "Buy oranges", "Buy mangos", "Buy apples", "Buy bananas" };
            //			listView.ItemSource = new TodoItem [] { 
            //				new TodoItem {Name = "Buy pears`"}, 
            //				new TodoItem {Name = "Buy oranges`", Done=true},
            //				new TodoItem {Name = "Buy mangos`"}, 
            //				new TodoItem {Name = "Buy apples`", Done=true},
            //				new TodoItem {Name = "Buy bananas`", Done=true}
            //			};

            // HACK: workaround issue #894 for now
            if (Device.OS == TargetPlatform.iOS)
                listView.ItemsSource = new string[1] { "" };

            listView.ItemSelected += (sender, e) =>
            {
                var todoItem = (TodoItem)e.SelectedItem;
                var todoPage = new TodoItemPage();
                todoPage.BindingContext = todoItem;
                Navigation.PushAsync(todoPage);
            };

            var layout = new StackLayout();
            if (Device.OS == TargetPlatform.WinPhone)
            { // WinPhone doesn't have the title showing
                layout.Children.Add(new Label { Text = "Todo", Font = Font.BoldSystemFontOfSize(NamedSize.Large) });
            }
            layout.Children.Add(listView);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            Content = layout;


            ToolbarItem tbi = null;
            if (Device.OS == TargetPlatform.iOS)
            {
                tbi = new ToolbarItem("+", null, () =>
                    {
                        var todoItem = new TodoItem();
                        var todoPage = new TodoItemPage();
                        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 TodoItemPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                }, 0, 0);
            }
            if (Device.OS == TargetPlatform.WinPhone)
            {
                tbi = new ToolbarItem("Add", "add.png", () =>
                    {
                        var todoItem = new TodoItem();
                        var todoPage = new TodoItemPage();
                        todoPage.BindingContext = todoItem;
                        Navigation.PushAsync(todoPage);
                    }, 0, 0);
            }
                // WINRT
            if (Device.OS == TargetPlatform.Other)
            {
                tbi = new ToolbarItem("Add", "ms-appx:///add.png", () =>
                {
                    var todoItem = new TodoItem();
                    var todoPage = new TodoItemPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                }, 0, 0);
            }
            if (tbi != null)
                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";

                    DependencyService.Get<ITextToSpeech>().Speak(tospeak);
                }, 0, 0);
                ToolbarItems.Add(tbi2);
            }

        }
		public TodoListPage ()
		{
			Title = "Todo";

			NavigationPage.SetHasNavigationBar (this, true);

			listView = new ListView ();
			listView.ItemTemplate = new DataTemplate (typeof (TodoItemCell));

//			listView.ItemSource = new string [] { "Buy pears", "Buy oranges", "Buy mangos", "Buy apples", "Buy bananas" };
//			listView.ItemSource = new TodoItem [] { 
//				new TodoItem {Name = "Buy pears`"}, 
//				new TodoItem {Name = "Buy oranges`", Done=true},
//				new TodoItem {Name = "Buy mangos`"}, 
//				new TodoItem {Name = "Buy apples`", Done=true},
//				new TodoItem {Name = "Buy bananas`", Done=true}
//			};

			listView.ItemSelected += (sender, e) => {
				var todoItem = (TodoItem)e.SelectedItem;
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			};

			var tap = new TapGestureRecognizer ((View obj) => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
			});

			newImage = new Image ();
			newImage.Source = "new.png";
			newImage.WidthRequest = 40;
			newImage.GestureRecognizers.Add (tap);

			layout = new RelativeLayout ();
			layout.Children.Add (listView, 
				xConstraint: Constraint.Constant(0), 
				yConstraint: Constraint.Constant(0), 
				widthConstraint: Constraint.RelativeToParent ((parent) => {return parent.Width;}),
				heightConstraint: Constraint.RelativeToParent ((parent) => {return parent.Height;}));
			layout.Children.Add (newImage, 
				xConstraint: Constraint.RelativeToParent((parent) =>
					{
						return (parent.Width / 2) - 20; // center of image (which is 40 wide)
					}),
				yConstraint: Constraint.RelativeToParent((parent) =>
					{
						return parent.Height - 60;
					}));
			Content = layout;


			#region toolbar
			var tbi = new ToolbarItem ("+", null, () => {
				var todoItem = new TodoItem();
				var todoPage = new TodoItemPage();
				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 TodoItemPage();
					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);
			}
			#endregion
		}
		public TodoListPage ()
		{
			Title = "Todo";
			BackgroundColor = Constants.Yellow;
			NavigationPage.SetHasNavigationBar (this, true);
            int listY = 0;

			listView = new NotesListView ();
			listView.ItemTemplate = new DataTemplate (typeof (TodoItemCell));
			listView.BackgroundColor = Constants.Yellow;

			listView.ItemSelected += (sender, e) => {
				if (e.SelectedItem == null) {
					return; // ensures we ignore this handler when the selection is just being cleared
				}
				var todoItem = (TodoItem)e.SelectedItem;
				var todoPage = new TodoItemPage();
				todoPage.BindingContext = todoItem;
				Navigation.PushAsync(todoPage);
				((ListView)sender).SelectedItem = null; // clears the 'selected' background
			};

            layout = new RelativeLayout();

            if (Device.OS == TargetPlatform.WinPhone)
            {
                listY = 60;
                layout.Children.Add(new BoxView { BackgroundColor = Constants.Brown },
                    xConstraint: Constraint.Constant(0),
                    yConstraint: Constraint.Constant(0),
                    widthConstraint: Constraint.RelativeToParent((parent) => { return parent.Width; }),
                    heightConstraint: Constraint.Constant(listY)
                );
                layout.Children.Add(new Label { Text = "Todo", Font= Font.SystemFontOfSize(36), XAlign = TextAlignment.Center },
                    xConstraint: Constraint.Constant(0),
                    yConstraint: Constraint.Constant(10),
                    widthConstraint: Constraint.RelativeToParent((parent) => { return parent.Width; }),
                    heightConstraint: Constraint.Constant(listY - 10)
                );
            }

                

            layout.Children.Add(listView,
                xConstraint: Constraint.Constant(0),
                yConstraint: Constraint.Constant(listY),
                widthConstraint: Constraint.RelativeToParent((parent) => { return parent.Width; }),
                heightConstraint: Constraint.RelativeToParent((parent) => { return parent.Height; })
            );

            #region floating Add button for iOS and Android
            if (Device.OS != TargetPlatform.WinPhone)
            {
                // make floating (+) image at bottom of screen
                var tap = new TapGestureRecognizer(async (View obj) =>
                {
                    var todoItem = new TodoItem();
                    var todoPage = new TodoItemPage();
                    todoPage.BindingContext = todoItem;

                    var b = newImage.Bounds;
                    b.X = b.X + 5;
					b.Y = b.Y + 5;

                    await newImage.LayoutTo(b, 100);
                    b.X = b.X - 5;
					b.Y = b.Y - 5;
                    await newImage.LayoutTo(b, 100);

                    Navigation.PushAsync(todoPage);
                });
                newImage = new Image
                {
                    Source = "newitem.png",
                    WidthRequest = 40,
                    Opacity = 0.8f
                };
                newImage.GestureRecognizers.Add(tap);

                layout.Children.Add(newImage,
                xConstraint: Constraint.RelativeToParent((parent) =>
                {
                    return (parent.Width / 2) - 20; // center of image (which is 40 wide)
                }),
                yConstraint: Constraint.RelativeToParent((parent) =>
                {
                    return parent.Height - 60;
                }));
            }
            #endregion

			Content = layout;


			#region toolbar for WinPhone (only)
            if (Device.OS == TargetPlatform.WinPhone)
            {
                var tbi = new ToolbarItem("add", "add.png", () =>
                {
                    var todoItem = new TodoItem();
                    var todoPage = new TodoItemPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                }, 0, 0);
                ToolbarItems.Add(tbi);
			
                var tbi2 = new ToolbarItem("speak", "transport.play.png", () =>
                {
                    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);
			} else {
				var tbi2 = new ToolbarItem("read", "chat.png", () =>
					{
						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);
			}
			#endregion
		}