public TodoListPage() { FlowDirection = Device.FlowDirection; Title = AppResources.ApplicationTitle; listView = new ListView { RowHeight = 40 }; listView.ItemTemplate = new DataTemplate(typeof(TodoItemCell)); listView.ItemSelected += async(sender, e) => { await Navigation.PushAsync(new TodoItemPage { BindingContext = (TodoItem)e.SelectedItem }); }; var layout = new StackLayout { Margin = new Thickness(20) }; layout.Children.Add(listView); 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", AppResources.Culture); tospeak = String.Format(s, todos.Count()) + tospeak; } DependencyService.Get <ITextToSpeech>().Speak(tospeak); }, 0, 0); ToolbarItems.Add(tbiSpeak); }
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 = AppResources.ApplicationTitle; // "Todo"; 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 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)), 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 = AppResources.ApplicationTitle; // "Todo"; 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 layout = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand }; layout.Children.Add(listView); Content = layout; ToolbarItem tbi = null; if (Device.RuntimePlatform == Device.iOS) { tbi = new ToolbarItem("+", null, () => { var todoItem = new TodoItem(); var todoPage = new TodoItemPage(); todoPage.BindingContext = todoItem; Navigation.PushAsync(todoPage); }, 0, 0); } if (Device.RuntimePlatform == Device.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.RuntimePlatform == Device.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 = 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 { VerticalOptions = LayoutOptions.FillAndExpand }; layout.Children.Add(listView); 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 = AppResources.ApplicationTitle; // "Todo"; 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 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)), 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); } }