1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace TamagochiProject.Pages
- {
- /// <summary>
- /// Логика взаимодействия для PickAnimalPage.xaml
- /// </summary>
- public partial class PickAnimalPage : Page
- {
- Animal PickAnimal;
- int Index = 0;
- public PickAnimalPage()
- {
- InitializeComponent();
- cbTypeAnimal.ItemsSource=Globals.Connection.Type.ToList();
- cbTypeAnimal.DisplayMemberPath = "Type1";
- cbTypeAnimal.SelectionChanged += cbTypeAnimal_SelectionChanged;
- }
- private void btnBegin_Click(object sender, RoutedEventArgs e)
- {
- if(tbNameAnimal.Text!="" && cbTypeAnimal.SelectedIndex!=-1)
- {
- PickAnimal = Globals.Connection.Animal.FirstOrDefault(x => x.Id_type == Index);
- PickAnimal.Name = tbNameAnimal.Text;
- Globals.PickAnimal = PickAnimal;
- Globals.Frame.Navigate(new MainAnimalPage());
- }
- else
- {
- MessageBox.Show("Выберите тип питомца и назовите!", "Ошибка");
- }
-
- }
- private void cbTypeAnimal_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- int selectedIndex = cbTypeAnimal.SelectedIndex;
- if (selectedIndex != -1)
- {
- Index = selectedIndex + 1;
- }
- }
- }
- }
|