//サーチイベントハンドラ private async void Search_title(object sender, EventArgs e) { string keyword = sBar.Text.ToString(); items.Clear(); if (keyword != null) { if (UserModel.selectUser_search(keyword) != null) { var query = UserModel.selectUser_search(keyword); var titleList = new List <String>(); var isbnList = new List <String>(); var RedList = new List <int>(); var BlueList = new List <int>(); var RedList2 = new List <string>(); var BlueList2 = new List <string>(); //*をリストにぶち込んで個数分addするのでもいいのでは foreach (var user in query) { titleList.Add(user.Title); isbnList.Add(user.ISBN); RedList.Add(user.RedStar); BlueList.Add(user.BlueBook); } for (var h = 0; h < query.Count; h++) { if (RedList[h] == 1) { RedList2.Add("red_star_72.png"); } else { RedList2.Add(""); } if (BlueList[h] == 1) { BlueList2.Add("blue_book_72.png"); } else { BlueList2.Add(""); } } for (var j = 0; j < query.Count; j++) { items.Add(new Book { Name = titleList[j], ISBN = isbnList[j], RedStar = RedList[j], BlueBook = BlueList[j], RedStar2 = RedList2[j], BlueBook2 = BlueList2[j] }); } } else { await DisplayAlert("ERROR!", "Not Found", "OK"); } BookListView.ItemsSource = items; //リフレッシュを止める this.BookListView.IsRefreshing = false; } }
public BookPage() { InitializeComponent(); if (UserModel.selectUser() != null) { var query = UserModel.selectUser(); var titleList = new List <String>(); var isbnList = new List <String>(); var RedList = new List <int>(); var BlueList = new List <int>(); var RedList2 = new List <string>(); var BlueList2 = new List <string>(); //*をリストにぶち込んで個数分addするのでもいいのでは foreach (var user in query) { titleList.Add(user.Title); isbnList.Add(user.ISBN); RedList.Add(user.RedStar); BlueList.Add(user.BlueBook); } for (var h = 0; h < query.Count; h++) { if (RedList[h] == 1) { RedList2.Add("red_star_72.png"); } else { RedList2.Add(""); } if (BlueList[h] == 1) { BlueList2.Add("blue_book_72.png"); } else { BlueList2.Add(""); } } for (var j = 0; j < query.Count; j++) { items.Add(new Book { Name = titleList[j], ISBN = isbnList[j], RedStar = RedList[j], BlueBook = BlueList[j], RedStar2 = RedList2[j], BlueBook2 = BlueList2[j] }); } } else { items.Add(new Book { Name = "空やで" }); } BookListView.ItemsSource = items; }
private async void OnSortButtonClicked(object sender, EventArgs e) { //2秒処理を待つ await Task.Delay(2000); items.Clear(); if (UserModel.sortselectUser(terms, sortkey) != null) { var query = UserModel.sortselectUser(terms, sortkey); var titleList = new List <String>(); var isbnList = new List <String>(); var RedList = new List <int>(); var BlueList = new List <int>(); var RedList2 = new List <string>(); var BlueList2 = new List <string>(); //*をリストにぶち込んで個数分addするのでもいいのでは foreach (var user in query) { titleList.Add(user.Title); isbnList.Add(user.ISBN); RedList.Add(user.RedStar); BlueList.Add(user.BlueBook); } for (var h = 0; h < query.Count; h++) { if (RedList[h] == 1) { RedList2.Add("red_star_72.png"); } else { RedList2.Add(""); } if (BlueList[h] == 1) { BlueList2.Add("blue_book_72.png"); } else { BlueList2.Add(""); } } for (var j = 0; j < query.Count; j++) { items.Add(new Book { Name = titleList[j], ISBN = isbnList[j], RedStar = RedList[j], BlueBook = BlueList[j], RedStar2 = RedList2[j], BlueBook2 = BlueList2[j] }); } } else { items.Add(new Book { Name = "空やで" }); } BookListView.ItemsSource = items; //リフレッシュを止める this.BookListView.IsRefreshing = false; }
public BookPage() { InitializeComponent(); var query = UserModel.countUser(j); var query2 = UserModel.selectUser(); ObservableCollection <Book> items = new ObservableCollection <Book>(); var List1 = new List <String>(); //*をリストにぶち込んで個数分addするのでもいいのでは foreach (var user in query2) { List1.Add(user.Name); } for (var j = 0; j < query2.Count; j++) { items.Add(new Book { Name = List1[j], /*Value = 2.5*/ }); } /*for (var j = 1; j == query2.Count; j++) * { * foreach (var user in UserModel.countUser(j)) * { * items.Add(new Book { Name = user.Name, Value = 2.5 }); * * } * }*/ /*foreach (var user in query2) * { * List1[0] = user.Name; * }List1.Add = List1[0];*/ /*for (var i = 0; i < items.Count; i++) * { * if (items[i].Value <= 0.25) * { * items[i].ValueImage = "value_0.gif"; * } * * else if (items[i].Value <= 0.75) * { * items[i].ValueImage = "value_0.5.gif"; * } * * else if (items[i].Value <= 1.25) * { * items[i].ValueImage = "value_1.gif"; * } * * else if (items[i].Value <= 1.75) * { * items[i].ValueImage = "value_1.5.gif"; * } * * else if (items[i].Value <= 2.25) * { * items[i].ValueImage = "value_2.gif"; * } * * else if (items[i].Value <= 2.75) * { * items[i].ValueImage = "value_2.5.gif"; * } * * else if (items[i].Value <= 3.25) * { * items[i].ValueImage = "value_3.gif"; * } * * else if (items[i].Value <= 3.75) * { * items[i].ValueImage = "value_3.5.gif"; * } * * else if (items[i].Value <= 4.25) * { * items[i].ValueImage = "value_4.gif"; * } * * else if (items[i].Value <= 4.75) * { * items[i].ValueImage = "value_4.5.gif"; * } * * else * { * items[i].ValueImage = "value_5.gif"; * } * * * if (items[i].RedStar == true) * { * items[i].RedStar2 = "red_star_72.png"; * } * * if (items[i].BlueBook == true) * { * items[i].BlueBook2 = "blue_book_72.png"; * } * * }*/ BookListView.ItemsSource = items; }