private static DataPoint[] getItemList() { TodoItemDatabase itemDataBase = TodoItemDatabase.getDatabase(); Task <List <TodoItem> > taskItemList = itemDataBase.GetItemsAsync(); List <TodoItem> itemList = taskItemList.Result; DataPoint[] points = new DataPoint[itemList.Count]; int i = 0; foreach (TodoItem item in itemList) { points[i++] = new DataPoint(item.ID, item.Count); } return(points); }
void Handle_Clicked(object sender, System.EventArgs e) { var db = TodoItemDatabase.getDatabase(); String sName = eName.Text; String sNotes = eNotes.Text; Boolean bDone = eDone.IsToggled; int iCount = int.Parse(eCount.Text); DateTime dCreated = eCreated.Date; TodoItem item = new TodoItem() { Name = sName, Notes = sNotes, Done = bDone, Count = iCount, Created = dCreated }; db.SaveItemAsync(item); DisplayAlert("TodoItem", "追加されたよ", "OK"); }
protected override async void OnAppearing() { base.OnAppearing(); var layout = new StackLayout() { HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.Center }; //((App)App.Current).ResumeAtTodoId = -1; //listView.ItemsSource = await App.Database.GetItemsAsync(); TodoItemDatabase itemDataBase = TodoItemDatabase.getDatabase(); List <TodoItem> itemList; itemList = await itemDataBase.GetItemsAsync(); int size = itemList.Count; layout.Children.Add(new Label() { Text = size + "件のデータ" }); ScrollView view = new ScrollView() { Orientation = ScrollOrientation.Vertical, HorizontalOptions = LayoutOptions.CenterAndExpand, VerticalOptions = LayoutOptions.CenterAndExpand }; layout.Children.Add(view); var layout2 = new StackLayout() { }; view.Content = layout2; foreach (var i in itemList) { layout2.Children.Add(new Label() { Text = i.ID + "" }); layout2.Children.Add(new Label() { Text = i.Name }); layout2.Children.Add(new Label() { Text = i.Notes }); layout2.Children.Add(new Label() { Text = i.Count + "" }); layout2.Children.Add(new Label() { Text = i.Created.ToString() }); layout2.Children.Add(new Switch() { IsToggled = i.Done }); } Content = layout; }