private void AddPlanet() { newPlanet = new Planet(""); Title = "Добавление планеты"; //данные о планете nameEntry = new EntryCell { Label = "Название:", Placeholder = "Введите название", Keyboard = Keyboard.Default }; weightEntry = new EntryCell { Label = "Масса:", Placeholder = "Введите массу в килограммах", Keyboard = Keyboard.Numeric, }; radiusEntry = new EntryCell { Label = "Радиус:", Placeholder = "Введите радиус в метрах", Keyboard = Keyboard.Numeric }; root.Add(new TableSection("Общие данные") { nameEntry, weightEntry, radiusEntry }); //звезда var searchStarButton = new Button { Text = "Звезда", TextColor = Color.Black, BackgroundColor = Color.FromHex("9E9E9E"), HorizontalOptions = LayoutOptions.Start }; var searchStarEntry = new Entry { Placeholder = "Звезда", Keyboard = Keyboard.Default }; searchParentListView = new ListView() { ItemsSource = Stars }; searchStarButton.Clicked += (s, e) => { NavigationPage.SetHasBackButton(this, false); OurStackLayout.Children.Clear(); searchStarEntry.TextChanged += (_s, _e) => { searchParentListView.ItemsSource = Stars.Search(searchStarEntry.Text); }; OurStackLayout.Children.Add(searchStarEntry); OurStackLayout.Children.Add(searchParentListView); OurStackLayout.Children.Add(cancelButton); }; searchParentListView.ItemTapped += (s, e) => { searchStarButton.Text = searchParentListView.SelectedItem.ToString(); OurStackLayout.Children.Clear(); OurStackLayout.Children.Add(tableview); OurStackLayout.Children.Add(SaveButton); }; root.Add(new TableSection("Звезда") { new ViewCell { View = searchStarButton } }); }
private void searchBar_Changed(object sender, EventArgs e) { if (TypeItem == TypeItemsOfColl.Constellation) { OurListView.ItemsSource = Constellations.Search(searchBar.Text); } else if (TypeItem == TypeItemsOfColl.Star) { OurListView.ItemsSource = Stars.Search(searchBar.Text); } else if (TypeItem == TypeItemsOfColl.Planet) { OurListView.ItemsSource = Planets.Search(searchBar.Text); } }
private void AddConstellation() { newConstellation = new Constellation(""); Title = "Добавление зв. системы"; //данные о звездной системе nameEntry = new EntryCell { Label = "Название:", Placeholder = "Введите название", Keyboard = Keyboard.Default }; root.Add(new TableSection("Общие данные") { nameEntry }); //звезды var searchStarButton = new Button { Text = "Звезды", TextColor = Color.Black, BackgroundColor = Color.FromHex("9E9E9E"), HorizontalOptions = LayoutOptions.Start }; var searchStarEntry = new Entry { Placeholder = "Звезда", Keyboard = Keyboard.Default }; var searchStarListView = new ListView { ItemsSource = Stars }; searchStarButton.Clicked += (s, e) => { NavigationPage.SetHasBackButton(this, false); searchStarEntry.TextChanged += (_s, _e) => { if (newConstellation.Stars != null) { searchStarListView.ItemsSource = (Stars.Search(searchStarEntry.Text)).Where(stars => stars.Constellation != newConstellation); } else { searchStarListView.ItemsSource = Stars.Search(searchStarEntry.Text); } }; OurStackLayout.Children.Clear(); OurStackLayout.Children.Add(searchStarEntry); OurStackLayout.Children.Add(searchStarListView); OurStackLayout.Children.Add(cancelButton); }; searchStarListView.ItemTapped += async(s, e) => { Planet planet = (Planet)searchStarListView.SelectedItem; if (await DisplayActionSheet(searchStarListView.SelectedItem.ToString(), "Отмена", null, "Добавить звезду") == "Добавить звезду") { planet.Star = newStar; searchStarEntry.Text = ""; searchStarListView.ItemsSource = (Stars.Search(searchStarEntry.Text)).Where(stars => stars.Constellation != newConstellation); } }; root.Add(new TableSection("Звезды") { new ViewCell { View = searchStarButton } }); }