private void BookListView_Refreshing(object sender, EventArgs e) { Task.Delay(2000); items.Clear(); if (BookDB.select_title() != null) { var query = BookDB.select_title(); var List1 = new List <String>(); foreach (var user in query) { List1.Add(user.Title); } for (var j = 0; j < query.Count; j++) { items.Add(new Book { Name = List1[j], /*Value = 2.5*/ }); } } else { items.Add(new Book { Name = "表示するものがありません" }); } BookListView.ItemsSource = items; this.BookListView.IsPullToRefreshEnabled = false; }
private async Task bomb(object sender, EventArgs e) { bool x = await DisplayAlert("警告", "本棚を全削除します。\n\rよろしいですか?", "OK", "CANCEL"); if (x == true) { BookDB.dropBook(); } }
private async void OnDeleteButtonClicked(object sender, EventArgs e) { bool x = await DisplayAlert("警告", "削除してもよろしいですか?", "はい", "いいえ"); if (x == true) { BookDB.deleteBook(Isbn); Navigation.PushAsync(new BookPage()); } }
// ラベルを未読⇔既読にする private void OnToggled(object sender, ToggledEventArgs e) { if (unread1.IsToggled == true) { BookDB.ReadBook(Isbn); this.unread2.Text = "既読"; } if (unread1.IsToggled == false) { BookDB.UnreadBook(Isbn); this.unread2.Text = "未読"; } }
// お気にいりボタンを点滅させる private void OnImageClicked2(object sender, EventArgs e) { if (redstar == 1) { BookDB.Gray_Star(Isbn); this.image2.Image = "gray_star_72.png"; redstar = 0; } else { BookDB.Red_Star(Isbn); this.image2.Image = "red_star_72.png"; redstar = 1; } }
// 読みたいボタンを点滅させる private void OnImageClicked1(object sender, EventArgs e) { if (bluebook == 1) { BookDB.Gray_Book(Isbn); this.image1.Image = "gray_book_72.png"; bluebook = 0; } else { BookDB.Blue_Book(Isbn); this.image1.Image = "blue_book_72.png"; bluebook = 1; } }
//サーチイベントハンドラ private async void Search_title(object sender, EventArgs e) { string keyword = sBar.Text.ToString(); items.Clear(); if (keyword != null) { if (BookDB.selectBook_search(keyword) != null) { var query = BookDB.selectBook_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; } }
private async void OnSortButtonClicked(object sender, EventArgs e) { //2秒処理を待つ await Task.Delay(2000); items.Clear(); if (BookDB.sortselectBook(terms, sortkey) != null) { var query = BookDB.sortselectBook(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(); if (BookDB.select_all() != null) { var query = BookDB.select_all(); 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 Serch_title(object sender, EventArgs e) { string Title = title_bar.Text; //検索文字列を%EAとかの形に変える string encodedtitle = Uri.EscapeUriString(Title); //Systemアセンブリ中に存在 UTF-8のみ requestUrl = url + "&title=" + encodedtitle; //2秒処理を待つ //await Task.Delay(2000); items.Clear(); var query = BookDB.select_all(); var ListTitle = new List <String>(); var ListReview = new List <double>(); var ListValue = new List <string>(); requestUrl = requestUrl + "&booksGenreId=001" + genreid; //HTTPアクセスメソッドを呼び出す string APIdata = await GetApiAsync(); //jsonをstringで受け取る //HTTPアクセス失敗処理(404エラーとか名前解決失敗とかタイムアウトとか) if (APIdata is null) { await DisplayAlert("接続エラー", "接続に失敗しました", "OK"); } /* * //レスポンス(JSON)をstringに変換-------------->しなくていい * Stream s = GetMemoryStream(APIdata); //GetMemoryStreamメソッド呼び出し * StreamReader sr = new StreamReader(s); * string json = sr.ReadToEnd(); */ /* * //デシリアライズ------------------>しなくていい * var rakutenBooks = JsonConvert.DeserializeObject<RakutenBooks>(json.ToString()); */ //パースする *重要* パースとは、文法に従って分析する、品詞を記述する、構文解析する、などの意味を持つ英単語。 var json = JObject.Parse(APIdata); //stringのAPIdataをJObjectにパース JValue countV = (JValue)json["hits"]; string count = countV.Value.ToString(); int getCount = int.Parse(count); var Items = JArray.Parse(json["Items"].ToString()); //Itemsは配列なのでJArrayにパース //結果を出力 foreach (JObject jobj in Items) { //↓のように取り出す JValue titleValue = (JValue)jobj["title"]; string title = (string)titleValue.Value; JValue reviewAverageValue = (JValue)jobj["reviewAverage"]; string reviewAverage = (string)reviewAverageValue.Value; double Review = double.Parse(reviewAverage); JValue titleKanaValue = (JValue)jobj["titleKana"]; string titleKana = (string)titleKanaValue.Value; JValue itemCaptionValue = (JValue)jobj["itemCaption"]; string itemCaption = (string)itemCaptionValue.Value; JValue gazoValue = (JValue)jobj["largeImageUrl"]; string gazo = (string)gazoValue.Value; ListTitle.Add(title); ListReview.Add(Review); } ; for (var j = 0; j < Items.Count; j++) { if (ListReview[j] <= 0.25) { ListValue.Add("value_0_.png"); } else if (ListReview[j] <= 0.75) { ListValue.Add("value_0_5.png"); } else if (ListReview[j] <= 1.25) { ListValue.Add("value_1_.png"); } else if (ListReview[j] <= 1.75) { ListValue.Add("value_1_5.png"); } else if (ListReview[j] <= 2.25) { ListValue.Add("value_2_.png"); } else if (ListReview[j] <= 2.75) { ListValue.Add("value_2_5.png");; } else if (ListReview[j] <= 3.25) { ListValue.Add("value_3_.png"); } else if (ListReview[j] <= 3.75) { ListValue.Add("value_3_5.png"); } else if (ListReview[j] <= 4.25) { ListValue.Add("value_4_.png"); } else if (ListReview[j] <= 4.75) { ListValue.Add("value_4_5.png"); } else { ListValue.Add("value_5_.png"); } items.Add(new Book2 { Name = ListTitle[j], Value = ListReview[j], ValueImage = ListValue[j] }); } RankListView.ItemsSource = items; //リフレッシュを止める this.RankListView.IsRefreshing = false; }
async void ScanButtonClicked(object sender, EventArgs s) { var scanPage = new ZXingScannerPage() { DefaultOverlayTopText = "バーコードを読み取ります", DefaultOverlayBottomText = "", }; // スキャナページを表示 await Navigation.PushAsync(scanPage); scanPage.OnScanResult += (result) => { // スキャン停止 scanPage.IsScanning = false; // PopAsyncで元のページに戻り、結果を表示 Device.BeginInvokeOnMainThread(async() => { await Navigation.PopAsync(); string isbncode = result.Text; requestUrl = url + "&isbn=" + isbncode; //URLにISBNコードを挿入 //HTTPアクセスメソッドを呼び出す string APIdata = await GetApiAsync(); //jsonをstringで受け取る //パースする *重要* パースとは、文法に従って分析する、品詞を記述する、構文解析する、などの意味を持つ英単語。 var json = JObject.Parse(APIdata); //stringのAPIdataをJObjectにパース var Items = JArray.Parse(json["Items"].ToString()); //Itemsは配列なのでJArrayにパース //結果を出力 foreach (JObject jobj in Items) { //↓のように取り出す JValue titleValue = (JValue)jobj["title"]; string title = (string)titleValue.Value; JValue titleKanaValue = (JValue)jobj["titleKana"]; string titleKana = (string)titleKanaValue.Value; JValue itemCaptionValue = (JValue)jobj["itemCaption"]; string itemCaption = (string)itemCaptionValue.Value; JValue gazoValue = (JValue)jobj["largeImageUrl"]; string gazo = (string)gazoValue.Value; JValue isbnValue = (JValue)jobj["isbn"]; string isbn = (string)isbnValue.Value; JValue authorValue = (JValue)jobj["author"]; string author = (string)authorValue.Value; bool x = await DisplayAlert("この内容で登録してよろしいですか?", "タイトル:" + title + "\r\n著者:" + author, "OK", "CANCEL"); if (x == true) { BookDB.insertBook(isbn, title, titleKana, author, itemCaption); } } ; }); }; }
async void SerchClicked(object sender, EventArgs e) { try { requestUrl = url + "&isbn=" + serch_isbn.Text; //URLにISBNコードを挿入 //HTTPアクセスメソッドを呼び出す string APIdata = await GetApiAsync(); //jsonをstringで受け取る //HTTPアクセス失敗処理(404エラーとか名前解決失敗とかタイムアウトとか) if (APIdata is null) { await DisplayAlert("接続エラー", "接続に失敗しました", "OK"); } /* * //レスポンス(JSON)をstringに変換-------------->しなくていい * Stream s = GetMemoryStream(APIdata); //GetMemoryStreamメソッド呼び出し * StreamReader sr = new StreamReader(s); * string json = sr.ReadToEnd(); */ /* * //デシリアライズ------------------>しなくていい * var rakutenBooks = JsonConvert.DeserializeObject<RakutenBooks>(json.ToString()); */ //パースする *重要* パースとは、文法に従って分析する、品詞を記述する、構文解析する、などの意味を持つ英単語。 var json = JObject.Parse(APIdata); //stringのAPIdataをJObjectにパース var Items = JArray.Parse(json["Items"].ToString()); //Itemsは配列なのでJArrayにパース //結果を出力 foreach (JObject jobj in Items) { //↓のように取り出す JValue titleValue = (JValue)jobj["title"]; string title = (string)titleValue.Value; JValue titleKanaValue = (JValue)jobj["titleKana"]; string titleKana = (string)titleKanaValue.Value; JValue subTiv = (JValue)jobj["subTitle"]; string subTitle = (string)subTiv.Value; JValue subTiKv = (JValue)jobj["subTitleKana"]; string subTitleKana = (string)subTiKv.Value; JValue authorValue = (JValue)jobj["author"]; string author = (string)authorValue.Value; JValue authorKanaValue = (JValue)jobj["authorKana"]; string authorKana = (string)authorKanaValue.Value; JValue pubV = (JValue)jobj["publisherName"]; string publisher = (string)pubV.Value; JValue sizeV = (JValue)jobj["size"]; string size = (string)sizeV.Value; JValue isbnValue = (JValue)jobj["isbn"]; string isbn = (string)isbnValue.Value; JValue itemCaptionValue = (JValue)jobj["itemCaption"]; string itemCaption = (string)itemCaptionValue.Value; JValue salesDateV = (JValue)jobj["salesDate"]; string salesDate = (string)salesDateV.Value; JValue priceV = (JValue)jobj["itemPrice"]; var priceVV = priceV.ToString(); int price = int.Parse(priceVV); JValue gazoValue = (JValue)jobj["largeImageUrl"]; string gazo = (string)gazoValue.Value; JValue genreV = (JValue)jobj["booksGenreId"]; string genreId = (string)genreV.Value; bool x = await DisplayAlert("この内容で登録してよろしいですか?", "タイトル:" + title + "\r\n著者:" + author, "OK", "CANCEL"); if (x == true) { BookDB.insertBook(isbn, title, titleKana, subTitle, subTitleKana, author, authorKana, publisher, size, itemCaption, salesDate, price, gazo, genreId); } } ; } catch (Exception ex) { //await DisplayAlert("Error", ex.ToString(), "ok"); //デバック用なのでリリース時は削除かコメントアウト //try catch自体は置いとかないと落ちそう } }
public DetailPage(string isbn) { InitializeComponent(); //var query = BookDB.selectUserISBN(this.Isbn); Isbn = isbn; if (BookDB.select_isbn(isbn) != null) { var query = BookDB.select_isbn(isbn); foreach (var book in query) { title = book.Title; bluebook = book.BlueBook; redstar = book.RedStar; read = book.Read; author = book.Author; Date = book.SalesDate; type = book.Type; publisher = book.Publisher; itemcaption = book.ItemCaption; } } else { DisplayAlert("表なし", "表なし", "OK"); } title2.Text = title; Auther2.Text = "著者名:" + author; Type2.Text = "タイプ:" + type; SalesDate2.Text = "発売日:" + Date; Publisher2.Text = "出版社:" + publisher; ItemCaption2.Text = "説明:" + itemcaption; if (bluebook == 1) { this.image1.Image = "blue_book_72.png"; } else { this.image1.Image = "gray_book_72.png"; } if (redstar == 1) { this.image2.Image = "red_star_72.png"; } else { this.image2.Image = "gray_star_72.png"; } if (read == 0) { this.unread2.Text = "未読"; unread1.IsToggled = false; } if (read == 1) { this.unread2.Text = "既読"; unread1.IsToggled = true; } }
async void ScanButtonClicked(object sender, EventArgs s) { var scanPage = new ZXingScannerPage() { DefaultOverlayTopText = "バーコードを読み取ります", DefaultOverlayBottomText = "", }; // スキャナページを表示 await Navigation.PushAsync(scanPage); scanPage.OnScanResult += (result) => { // スキャン停止 scanPage.IsScanning = false; // PopAsyncで元のページに戻り、結果を表示 Device.BeginInvokeOnMainThread(async() => { //phoneならこっち if (_device == "Phone") { List <Manage> hoge2; hoge2 = Manage._camera(); if (hoge2 == null) { Manage.insertCamera(); hoge2 = Manage._camera(); } foreach (var x in hoge2) { c_bool = x.camera_bool; } if (c_bool == 0) { DependencyService.Get <IDeviceService>().PlayVibrate(); await Navigation.PopAsync();//元のページに戻る } if (c_bool == 1) { DependencyService.Get <IDeviceService>().PlayVibrate(); scanPage.IsScanning = false; } } //タブレットならこっち else { if (c_bool == 0) { await Navigation.PopAsync();//元のページに戻る } if (c_bool == 1) { } } string isbncode = result.Text; requestUrl = url + "&isbn=" + isbncode; //URLにISBNコードを挿入 //HTTPアクセスメソッドを呼び出す string APIdata = await GetApiAsync(); //jsonをstringで受け取る //パースする *重要* パースとは、文法に従って分析する、品詞を記述する、構文解析する、などの意味を持つ英単語。 var json = JObject.Parse(APIdata); //stringのAPIdataをJObjectにパース var Items = JArray.Parse(json["Items"].ToString()); //Itemsは配列なのでJArrayにパース //結果を出力 foreach (JObject jobj in Items) { //↓のように取り出す JValue titleValue = (JValue)jobj["title"]; string title = (string)titleValue.Value; JValue titleKanaValue = (JValue)jobj["titleKana"]; string titleKana = (string)titleKanaValue.Value; JValue subTiv = (JValue)jobj["subTitle"]; string subTitle = (string)subTiv.Value; JValue subTiKv = (JValue)jobj["subTitleKana"]; string subTitleKana = (string)subTiKv.Value; JValue authorValue = (JValue)jobj["author"]; string author = (string)authorValue.Value; JValue authorKanaValue = (JValue)jobj["authorKana"]; string authorKana = (string)authorKanaValue.Value; JValue pubV = (JValue)jobj["publisherName"]; string publisher = (string)pubV.Value; JValue sizeV = (JValue)jobj["size"]; string size = (string)sizeV.Value; JValue isbnValue = (JValue)jobj["isbn"]; string isbn = (string)isbnValue.Value; JValue itemCaptionValue = (JValue)jobj["itemCaption"]; string itemCaption = (string)itemCaptionValue.Value; JValue salesDateV = (JValue)jobj["salesDate"]; string salesDate = (string)salesDateV.Value; JValue priceV = (JValue)jobj["itemPrice"]; var priceVV = priceV.ToString(); int price = int.Parse(priceVV); JValue gazoValue = (JValue)jobj["largeImageUrl"]; string gazo = (string)gazoValue.Value; JValue genreV = (JValue)jobj["booksGenreId"]; string genreId = (string)genreV.Value; bool x = await DisplayAlert("この内容で登録してよろしいですか?", "タイトル:" + title + "\r\n著者:" + author, "OK", "CANCEL"); if (x == true) { BookDB.insertBook(isbn, title, titleKana, subTitle, subTitleKana, author, authorKana, publisher, size, itemCaption, salesDate, price, gazo, genreId); } if (title == null) { await DisplayAlert("警告", "本が楽天ブックスに登録されていない可能性があります", "OK"); } if (scanPage.IsScanning == false) { scanPage.IsScanning = true; } } ; }); }; }
//--------------------------------Serchボタンイベントハンドラ----------------------------------- private async void Serch(object sender, EventArgs e) { //2秒処理を待つ await Task.Delay(2000); items.Clear(); var query = BookDB.select_all(); var ListTitle = new List <String>(); var ListReview = new List <double>(); requestUrl = url + "&booksGenreId=001" + genreid; //URLにISBNコードを挿入 //HTTPアクセスメソッドを呼び出す string APIdata = await GetApiAsync(); //jsonをstringで受け取る //HTTPアクセス失敗処理(404エラーとか名前解決失敗とかタイムアウトとか) if (APIdata is null) { await DisplayAlert("接続エラー", "接続に失敗しました", "OK"); } /* * //レスポンス(JSON)をstringに変換-------------->しなくていい * Stream s = GetMemoryStream(APIdata); //GetMemoryStreamメソッド呼び出し * StreamReader sr = new StreamReader(s); * string json = sr.ReadToEnd(); */ /* * //デシリアライズ------------------>しなくていい * var rakutenBooks = JsonConvert.DeserializeObject<RakutenBooks>(json.ToString()); */ //パースする *重要* パースとは、文法に従って分析する、品詞を記述する、構文解析する、などの意味を持つ英単語。 var json = JObject.Parse(APIdata); //stringのAPIdataをJObjectにパース var Items = JArray.Parse(json["Items"].ToString()); //Itemsは配列なのでJArrayにパース //結果を出力 foreach (JObject jobj in Items) { //↓のように取り出す JValue titleValue = (JValue)jobj["title"]; string title = (string)titleValue.Value; JValue reviewAverageValue = (JValue)jobj["reviewAverage"]; string reviewAverage = (string)reviewAverageValue.Value; double Review = double.Parse(reviewAverage); JValue titleKanaValue = (JValue)jobj["titleKana"]; string titleKana = (string)titleKanaValue.Value; JValue itemCaptionValue = (JValue)jobj["itemCaption"]; string itemCaption = (string)itemCaptionValue.Value; JValue gazoValue = (JValue)jobj["largeImageUrl"]; string gazo = (string)gazoValue.Value; ListTitle.Add(title); ListReview.Add(Review); } ; for (var j = 0; j < 30; j++) { items.Add(new Book2 { Name = ListTitle[j], Value = ListReview[j] }); } for (var i = 0; i < items.Count; i++) { if (items[i].Value <= 0.25) { items[i].ValueImage = "value_0.png"; } else if (items[i].Value <= 0.75) { items[i].ValueImage = "value_0.5.png"; } else if (items[i].Value <= 1.25) { items[i].ValueImage = "value_1.png"; } else if (items[i].Value <= 1.75) { items[i].ValueImage = "value_1.5.png"; } else if (items[i].Value <= 2.25) { items[i].ValueImage = "value_2.png"; } else if (items[i].Value <= 2.75) { items[i].ValueImage = "value_2.5.png"; } else if (items[i].Value <= 3.25) { items[i].ValueImage = "value_3.png"; } else if (items[i].Value <= 3.75) { items[i].ValueImage = "value_3.5.png"; } else if (items[i].Value <= 4.25) { items[i].ValueImage = "value_4.png"; } else if (items[i].Value <= 4.75) { items[i].ValueImage = "value_4.5.png"; } else { items[i].ValueImage = "value_5.png"; } } RankListView.ItemsSource = items; //リフレッシュを止める this.RankListView.IsRefreshing = false; }
public BookPage() { InitializeComponent(); /* * string a = "a"; //緊急削除 * BookDB.deleteBook(a); */ if (BookDB.select_title() != null) { var query = BookDB.select_title(); var List1 = new List <String>(); foreach (var user in query) { List1.Add(user.Title); } for (var j = 0; j < query.Count; j++) { items.Add(new Book { Name = List1[j], /*Value = 2.5*/ }); } } else { items.Add(new Book { Name = "表示するものがありません" }); } for (var i = 0; i < items.Count; i++) { if (items[i].Value <= 0.25) { items[i].ValueImage = "value_0.png"; } else if (items[i].Value <= 0.75) { items[i].ValueImage = "value_0.5.png"; } else if (items[i].Value <= 1.25) { items[i].ValueImage = "value_1.png"; } else if (items[i].Value <= 1.75) { items[i].ValueImage = "value_1.5.png"; } else if (items[i].Value <= 2.25) { items[i].ValueImage = "value_2.png"; } else if (items[i].Value <= 2.75) { items[i].ValueImage = "value_2.5.png"; } else if (items[i].Value <= 3.25) { items[i].ValueImage = "value_3.png"; } else if (items[i].Value <= 3.75) { items[i].ValueImage = "value_3.5.png"; } else if (items[i].Value <= 4.25) { items[i].ValueImage = "value_4.png"; } else if (items[i].Value <= 4.75) { items[i].ValueImage = "value_4.5.png"; } else { items[i].ValueImage = "value_5.png"; } 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; }