public LibraryCell() { Label deleteLabel = new Label() { Text = "[削除]", HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), }; var tgr = new TapGestureRecognizer(); tgr.Tapped += (sender, e) => { CheckTargetLibrarys targetLibrarys = new CheckTargetLibrarys(); targetLibrarys.DelLibrary((CheckTargetLibrary)BindingContext); }; deleteLabel.GestureRecognizers.Add(tgr); //systemname var systemName = new Label { FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)), FontAttributes = FontAttributes.Bold, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.TailTruncation, }; systemName.SetBinding(Label.TextProperty, "systemname"); View = new StackLayout { Orientation = StackOrientation.Horizontal, Children = { systemName, deleteLabel }, VerticalOptions = LayoutOptions.Start, }; }
public SelectLibraryPage(string apiKey, string pref, string city, string jsonResponseLibrary) { try { systemIdLibraryTable = LibraryGroup.getSystemIDLibraryTable(jsonResponseLibrary); List <LibraryGroup> libraryGropuList = LibraryGroup.GetLibraryGroupList(systemIdLibraryTable); ListView listView = new ListView { ItemTemplate = new DataTemplate(typeof(LibraryCell)),//セルの指定 ItemsSource = libraryGropuList, HasUnevenRows = true, }; // Define a selected handler for the ListView. listView.ItemSelected += async(sender, args) => { if (args.SelectedItem == null) { return; } ((ListView)sender).SelectedItem = null; var item = (LibraryGroup)args.SelectedItem; CheckTargetLibrarys targetLibrarys = new CheckTargetLibrarys(); if (item.IsRegist) { item.UpdateStatus(false); //DBから図書館を削除 targetLibrarys.DelLibrary(item.SystemName); } else { const int MAX_LIBRARY_NUM = 5; if (targetLibrarys.Librarys.Count() >= MAX_LIBRARY_NUM) { await DisplayAlert("図書館の登録", "6件以上は登録できません", "OK"); return; } //GA-> //図書館を仮想的に利用して膨大な蔵書を育てる人が多い事の検証。図書館追加することを検証する int libraryNum = targetLibrarys.Librarys.Count() + 1; GoogleAnalytics.Current.Tracker.SendEvent("SelectLibraryPage", "AddLibrary", libraryNum.ToString()); //GA<- item.UpdateStatus(true); //図書館をDBに登録する foreach (var keyValuePair in systemIdLibraryTable) { if (keyValuePair.Key == item.SystemName) { var library = keyValuePair.Value.First(); targetLibrarys.AddLibrary(library.systemid, library.systemname); } } } }; this.Content = listView; } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } }